# Feature-first implementation roadmap

Recorded 2026-11-10 after source/documentation reconciliation.

Integration status2026-11-12: tickets10–13 have isolated application evidence;
ticket14 remains an incomplete native/trust/resource release gate. Baseline
missing-header descriptions below are historical; ticket13 now fails closed.
Owner customer-signing considerations do not expand this approved scope.

## Priority decision

The owner raised authentication work as an impediment to feature implementation.
Proceed with core workflow repairs first. Signet consumes trusted forwarded
identity (`Remote-User`, with the existing configurable group/role mapping);
it does not implement or administer an authentication server. The provider,
including whether to use Authelia at all, is the deployment administrator's
choice. Provider-specific setup is outside product scope. Fail-closed identity
handling and verification of the forwarded-header trust boundary remain
mandatory before production release or exposure to untrusted users.

Use explicit development identity headers and the existing configurable roles
for feature tests. Keep the stack isolated: current missing-header behavior
silently grants an admin identity. This roadmap does not approve that behavior
for production, introduce new auth machinery, or relax party/file authorization.
Preserve unrelated working-tree changes, including unfinished auth experiments.

The agreed model remains in `CONTEXT.md`, `HANDOFF.md` §2 and the ADR. Source
findings are in `HANDOFF.md` §4. Historical completed tasks are not fresh evidence.
Each implementation task must extend `test/e2e.sh`, build cleanly with
`-Wall -Wextra`, and record actual results. Rendering changes also require the
edit/proof/stamped visual comparisons specified by `AGENTS.md`.

## 1. Repair the render-job contract — ticket 10

Completed: evidence in `ticket-10.md`; actual release coverage added by ticket 11.
The original implementation scope follows.

Start here. API, worker, retry logic and browser must agree on what work is
requested and how completion is tracked.

- Define and use consistent document-job payloads containing document id,
  revision, render sequence and kind; keep enrolment jobs distinct.
- Use `render_seq`/`rendered_seq` for render progress, not comparisons against
  document revision. Revision still scopes submits and decisions.
- Ignore stale jobs without changing current output or database state.
- Keep `BRPOPLPUSH`/`LREM` and startup recovery. Check database update results
  before acknowledging processed work; preserve jobs on database failure.
- Make retry authorization and behavior match the stored render kind.
- Ensure retry/recovery does not apply a facsimile twice.

Acceptance: cover stamp/sign/release dispatch, stale jobs, retry, database-update
failure, processing-queue recovery and client progress/error handling. Where
release remains a placeholder, test dispatch now and defer actual release
success to ticket 11; do not claim the whole signing flow works yet.

## 2. Complete sequential signing and worker-owned release — ticket 11

Completed 2026-11-12: real API/worker/browser acceptance and visual evidence in
`ticket-11.md`. Submit-time snapshots and production identity remain separate.

Depends on ticket 10, not authentication integration.

- Render the decision of the party that just signed, even after current-party
  advancement. Read enrolled facsimiles through configured `sig_dir` in the
  worker only; validate placement page, bounds and minimum dimensions.
- Support check-only parties without a facsimile overlay.
- Move final rendering out of the API. The worker overlays the last facsimile,
  appends the complete event log, computes the body hash and sets `RELEASED`
  only after the final artifact is ready.
- Enforce sequential file visibility, including direct file endpoints; later
  parties cannot fetch early and `final.pdf` is available only after release.
  Preserve drafter/signer self-service and legitimate admin access.
- Reject empty titles at submit. On correction/resubmit preserve serial and
  document date, void prior sign-offs, restart at party one, and record
  `RESUBMITTED` rather than `SUBMITTED`.

Acceptance: a multi-party route with a non-final zone party, a check-only party,
first-signing enrolment and a final zone party; earlier facsimile visible to the
next party; later-party access denied until its turn; self-service; correction
and resubmit; terminal disapproval; failed sign/release and successful retry;
full audit history and final hash. Compare placements and facsimiles visually
on both pages. No API reads of `sig_dir` or synchronous API release remain.

## 3. Freeze submit-time content — ticket 12

Completed2026-11-12: implementation, mutation/replay/browser/visual evidence and
resource-measurement limits in `ticket-12.md`. Native production acceptance is
not implied. The original scope follows.

Depends on ticket 11 in this implementation sequence.

- Resolve and persist organisation PIM text/image references at submit.
- Freeze the DAM inputs needed for that revision, including fonts and images;
  storing a mutable path alone is not a snapshot.
- Produce one flattened proof per revision and derive the initial stamped copy
  from that same output, rather than resolving/rendering twice.
- Sign-offs and retries use only that revision's frozen content. A correction
  and resubmit creates a new revision snapshot without changing serial/date.
- Keep clients reference-only, worker-only facsimile access, existing DOM layout
  state, identical browser/server text fitting, and the resource constraints.

Acceptance: change PIM text, seal and font after submit but before worker
processing, between sign-offs and before retry. The submitted revision must
retain its frozen content throughout. A new revision may use updated inputs.
Verify proof/stamped base equality, final output and both-page visual alignment;
measure resource use against the under-60-MB Signet RSS budget.

## 4. Harden identity handling — ticket 13 (deferred release blocker)

Completed2026-11-12 on the integration branch; both-API/role/header remapping
and environment-backdoor evidence in `ticket-13.md`. Proxy trust remains ticket14.

Not a prerequisite for tickets 10–12. Schedule before deployment verification.

- Remove the unconditional missing-header admin/group fallback.
- Fail closed on missing or invalid identity; define and test handling of absent
  group headers so no privilege is fabricated. Keep group names config-only.
- Retain explicit isolated-dev test headers; avoid requiring Authelia just to
  run feature tests. Separate production proxy integration from this small
  identity-handling change.

Acceptance: regression tests against both APIs for absent, invalid and incomplete
identity headers; explicit test users receive only configured roles. Missing
identity never yields admin access. Feature tests still run without Authelia.

## 5. Verify production deployment — ticket 14 (release gate)

Depends on tickets 10–13. No public/production deployment until complete.

- Verify Signet's contract with the deployment's trusted forward-auth proxy:
  forwarded identity reaches the app, client identity headers are overwritten,
  and direct backend bypass is prevented. The administrator owns authentication
  server choice, configuration and sessions; no provider-specific implementation
  or administration belongs in Signet.
- Prove authenticated identities/roles reach both APIs. Test spoofed headers,
  unauthenticated requests and authorization failures end to end.
- Settle the owner's DAM writer policy and implement it; enforce PIM writes.
- Keep unfinished provider-specific auth/dev-stack experiments separate from
  core application work; their presence is not integration evidence.
- Verify native Alpine installation, OpenRC services, separate OS users,
  filesystem/database permissions, Redis AOF and production lighttpd CSP.
- Run full acceptance and measure RSS on the target-class environment.

Acceptance: recorded evidence for all checks above on bare-metal/VM Alpine with
OpenRC, not just the development container. All Signet processes stay under
60 MB RSS on the 1-vCPU/1-GB target. No prohibited production dependencies.

## Later improvements

Font-list validation and document-list pagination/search follow core workflow
correctness. They do not justify delaying tickets 10–12 for auth integration,
nor bypassing the production gate. Scope and acceptance criteria should be
specified separately before implementation.
