Skip to content

programs(web): authoring API and embedded interface - #17

Merged
TusanHomichi merged 1 commit into
mainfrom
claude/status-check-wwwfh6
Aug 28, 2026
Merged

TusanHomichi merged 1 commit into
mainfrom
claude/status-check-wwwfh6

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #16

Problem And Outcome

Slice 1 (#15) delivered the schema, services, and export/import with no way for a person to use them. After merge, a signed-in coordinator holding manage_programs builds a complete program version in the browser — phases, transitions, competencies with tasks, all three rating-scale kinds, modifiers, forms, and standards citations — publishes it (with an explicit irreversibility confirmation), sees it render read-only, compares any two versions section by section, exports the documented JSON, and imports one, without hand-writing JSON.

Changes

Server

  • src/programs_http.rs: the program endpoints — list/create programs, list/create versions, get version (summary + content), replace draft content, publish, discard, export (as a download with Content-Disposition), import as new program or next version. Handlers only translate refusal enums into stable codes (capability_required, no_such_program, no_such_version, already_published, name_taken, name_empty, invalid_content, incomplete, unsupported_format); policy stays in the services. Reads need a session; mutations are refused by the services without manage_programs.
  • src/http.rs stays the hub (router, ApiError, CurrentUser) and now documents that boundary; the error envelope gains an optional problems array so validation and completeness refusals arrive itemized.
  • src/programs.rs: Serialize on the summaries plus get_program / version_summary lookups.
  • tests/programs_api.rs: five integration tests — authentication gates, the full authoring flow over HTTP, every refusal's stable code (problems array included), read-vs-mutate capability split, and export/import over the wire.

Interface

  • First primary navigation in the shell (Home / Programs), main widened for authoring tables (existing form cards keep their 44rem measure), and shared tokens for tables, panels, status pills, rows, selects/textareas, and problem lists — all light-dark() aware.
  • /programs: list, create, import. /programs/{id}: version table with publish/discard/export/new-draft-from-version, import-as-next-version, and a compare picker. /programs/{id}/versions/{vid}: the structured editor over the typed content document — wholesale draft replacement per ADR 0007, published versions read-only, refusal problems listed inline. /programs/{id}/compare?a&b: section-level structural diff.
  • Editor components under $lib/editor/ (phases+transitions, competencies+tasks, scales+anchors+modifiers, forms+bindings+narratives, and a citations editor reused at program, competency, and task level). Scale-kind changes keep shapes coherent (pass/fail fixes anchors 0/1, narrative-only clears them).
  • $lib/api.ts grows the typed program client and ApiError.problems; $lib/format.ts dedupes the instant() helper the status page previously declared locally.
  • web/e2e/programs.spec.ts: a browser proof that creates a program, authors a version in the editor, publishes through the confirmation, verifies the frozen read-only state, branches a new draft from it, and reads the compare view.

Scope

Verification

  • Listed the exact verification commands run below
  • Added or updated tests when behavior changed
  • Added or updated an ADR when a durable decision changed (none changed; this implements ADR 0005/0007)
  • All fixtures and examples are invented; no real agency data
web/: npm run check                                      # 0 errors, 0 warnings
web/: npm run build                                      # clean
web/: CONSOLEBOOK_E2E_CHROMIUM=… npm run e2e             # 2 passed (shell + programs)
cargo fmt --check                                        # clean
cargo clippy --workspace --all-targets -- -D warnings    # clean (pedantic)
cargo test --workspace                                   # 10 suites, 57 tests, 0 failed

Web built before cargo, so the embedded-asset paths were exercised.

Review And Merge Notes

  • Review focus: the refusal-code table in programs_http.rs against the service enums, and the editor's read-only discipline on published versions (disabled derives from published_at and capability).
  • User or operator impact: signed-in users gain a Programs section; mutations stay capability-gated server-side. No migration; no configuration change.

Generated by Claude Code

Add the Milestone 2 authoring slice over the slice-1 services: program
HTTP endpoints in their own handler module with http.rs as the hub and
stable refusal codes (itemized problems included in the error envelope),
plus the embedded interface — programs list with create/import, version
management with publish, discard, export, and import-as-next-version, a
structured content editor over the typed document (draft editable,
published read-only), and a section-level compare view. Proven by API
integration tests and a browser e2e that authors, publishes, and
compares a version.

Refs #16
@TusanHomichi
TusanHomichi merged commit 1b79f68 into main Aug 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Milestone 2 slice 2: program authoring API and web interface

2 participants