# Step 5b — implementation checklist

**Not frozen — update freely as work lands.** Unlike `contracts.md`, this file's job is to
track *how far* step 5b's implementation has gotten, not to define the wire format itself. The
design is fixed in [`contracts.md` §9](contracts.md) (Contract H), [`outil-local/spec.md`
§3.1/§4.1/§5](outil-local/spec.md), and [`platform/spec.md` §B5/§B5bis/A4](platform/spec.md) —
this file just turns that design into checkable, resumable work. Linked from the build-order
table in `contracts.md` §0 and `architecture.md` §12.1 (row `5b`) so it's reachable from "the
main list" either way.

**Done 2026-09-25.** Every item below implemented and live-verified against the real stub +
real PDS (Boot jar) — not just unit tests. Full detail in the memory body / commit; summary:

## Platform — stub

- [x] `POST /mandates` also mints a setup code atomically (§9.1 step 2, §5.3) — response gains
      `setup_code` / `setup_redeem_url` / `setup_code_expires_at`. `setup_redeem_url` is built
      from the request's own `Host` header, not a fixed config value, so it's correct under
      both host and compose-net addressing without a new env var.
- [x] `POST /setup-codes/:code/redeem` (§5.9, §9.2) — 200/404/410, burns on success
- [x] setup-codes in-memory `Map`, same pattern as `linkSessions`
- [x] `GET /mandates?itsme_sub=` response gains `provider_id` + `agent_label` per row (§5.6)
- [x] audit event `SETUP_CODE_REDEEMED` wired into the Trace Plateforme (§5.7)
- [x] tests: redeem happy path, double-redeem → `404`, past-TTL → `410`, unknown code → `404`,
      atomic minting on `POST /mandates` — 5 new `node:test` cases, 34/34 green

## Platform — SPA

- [x] mandate form (`/mandate/new`): pre-submit collision check — `GET /mandates?itsme_sub=`,
      filter by `agent_label` (any provider) + `status:VALID` + not expired (§9.4)
- [x] collision prompt: Replace / Change label / Cancel — **no** "keep both" option (§B5)
- [x] "Replace" calls `POST /mandates/:jti/revoke` on the old `jti` before proceeding
- [x] default `agent_label` changed to `<provider-name>-<firstname>` (was
      `claude-desktop-<firstname>`) (§B5) — waits for both the itsme identity and the loaded
      provider record so the default is never re-derived out from under a human's own edit
- [x] success screen shows both onboarding paths: one-line `setup` command, and the raw config
      block captioned with the exact `<agent_label>/config.json` folder it belongs in (§B5)
- [x] new §B5bis accordion: Claude Desktop / Claude Code / GitHub Copilot CLI panels, secrets
      never shown (only `NP_MANDATE=<agent_label>` + the launch command)
- [x] `ng build` clean, `tsc --noEmit` clean; API-level verification of the exact response
      shapes the new UI code consumes (no headless browser available in this sandbox — same
      constraint noted for step 7's original build)

## Outil Local

- [x] `init --force`: enumerates `${NP_HOME}/*/config.json`, decodes each token's `act.sub`/
      `exp` (no signature check needed), prints the "N mandates will break" warning, requires
      interactive `y` unless `--yes` (§3.1) — O-1b/c/d/e all live-verified
- [x] new `setup <redeem-url>` subcommand: refuses without `agent.key`; `POST`s the URL; on 200,
      slugifies `agent_label` and writes `${NP_HOME}/<slug>/config.json` (mode 0600, always
      overwrites that one folder); on 404/410/network-error, refuses with a named reason (§5) —
      U-1 through U-7 all live-verified against the real stub
- [x] `runtime` config loading rewritten for the `NP_HOME`/`NP_MANDATE` split (§4.1): zero
      folders → refuse; one folder → use it; many folders + no `NP_MANDATE` → refuse and list
      them; `NP_MANDATE=<name>` → use that folder or refuse if missing; both env vars set still
      wins outright, bypassing folder resolution entirely (manual-testing escape hatch, spec
      §4.1) — O-6/O-7/O-8 all live-verified
- [x] `index.ts` wired for the `setup` subcommand
- [x] manual test pass (this module's convention — MANUAL-TESTING.md, no automated suite):
      O-1b/c/d/e, U-1 through U-7, O-6/O-7/O-8 — all live-verified, not just reasoned about
- [x] `MANUAL-TESTING.md` + `README.md` updated to match

## Cross-cutting

- [x] end-to-end smoke test: real mandate minted on the running stub (real PDS account-link
      assertion, not a fake) → real `setup` → real outil-local `runtime` (`NP_MANDATE` selecting
      the setup-written folder) → a real `tools/call get_balance` against the real PDS jar
      succeeded, correct balance data back (`€12 802,50`, Sofie's seed row)
- [x] `contracts.md` row `5b` flipped to ✅ done

## Deferred — noted, not blocking this step

- No hot-reload: a running outil-local process doesn't notice `config.json` being replaced
  underneath it — the AI client has to be restarted to pick up a new mandate. Matches how these
  clients already expect MCP server config changes to be picked up; revisit only if it becomes
  an actual friction point in the demo.
- Dashboard doesn't yet visually group "these rows are the same client over time" now that
  `agent_label` exists per row — cheap future polish, not needed for the POC.
