ADR-0002 SS3 models Zorgverlener/Medewerker as different Principal variants with different login flows. Actor #2 (apps/behandelportal) landed in WP-61/67 and the union never followed: grep -rn "Principal" returned one hit, a comment. Both apps' auth/domain/session.ts stayed byte-identical (`{ bsn, naam }`), so the backoffice's Behandelaar carried a BSN and logged into the backoffice as a citizen, by DigiD, under a fabricated citizen's name (login.page.ts). The divergence ADR-0002 predicted took an orthogonal side door instead (medewerker.interceptor.ts's X-Medewerker/X-Rollen stamp, which never touches SessionStore) -- which is why ssp/auth and bhp/auth still measured as 100%/84% duplicated after ADR-C-006 shared the route guards. RB-09 (landed the day before) made the backend's IIdentityProvider able to say "no identity" and fail closed; this ticket is its named FE half. Each app's auth/domain/session.ts becomes principal.ts, holding the one Principal variant that app actually has an actor for: ssp keeps `{ kind: 'zorgverlener', bsn, naam }` (G1 still strips the BSN before persisting); behandelportal gets `{ kind: 'medewerker', medewerkerId, naam, rollen }` (no BSN to strip -- G2 shape validation only). A new MedewerkerAdapter replaces DigidAdapter in behandelportal, resolving the existing MEDEWERKER_ID/currentRollen() dev stand-in into a Principal; because there is no credential to check, it returns Principal directly rather than a Result whose error variant could never occur. login.page.ts stops being a BSN/wachtwoord form -- one explainer line and an "Inloggen met SSO" button -- and its dead error-handling branch goes with the Result wrapper that justified it. Measured with tools/baseline-scan.mjs --dup: auth duplication drops from 168/168 (ssp) and 168/200 (bhp) to 32/179 and 32/259 -- under the backlog's <40 target. What remains is the ADR-C-006 route-guard re-export (deliberately identical), generic test/story-file boilerplate, and one shared fragment of the root-singleton-store idiom -- not re-converged identity or login-flow logic. SS3's prediction that the two actors would authenticate differently enough to justify not sharing auth has now actually been tested, not just asserted, and held. Also: renamed Session.bsn to Principal.bsn in two doc comments (libs/shared/src/infrastructure/subject.ts, subject.interceptor.ts) that cited the old type name; regenerated libs/shared/docs/behaviour-spec.mdx (generated file, per its own banner); recorded the resolution in ADR-0002 as a new amendment, replacing its "Known debt" section. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Refactoring backlog — automated setup
What's in this package
refactor-backlog-setup/
setup.sh ← run this once, from the root of the target repo
agents/ ← source prompts (edit these if you need to tweak
scope/wording before running setup.sh)
_persistence-protocol.md
00-baseline.prompt.md
01-readability.prompt.md
02-testability.prompt.md
03-ddd-hexagonal.prompt.md
04-cqrs-light.prompt.md
05-bdd.prompt.md
06-adr-conformance.prompt.md
07-bio2-compliance.prompt.md
08-consolidation.prompt.md
09-implementation.prompt.md (template — one TICKET-ID per Phase 3 dispatch)
Usage
- Copy this
refactor-backlog-setup/folder into the root of the target repo (or reference it via a relative path). - Edit anything in
agents/if scope/exclusions need repo-specific detail (e.g. exact module paths, ADR folder location) — the prompts currently use the defaults agreed in the design conversation. - Run:
This creates
bash refactor-backlog-setup/setup.sh./refactor-backlog/with:_status.mdinitialized, all agentsnot_started00-baseline.mdthrough07-bio2-compliance.mdinitialized with headers99-backlog.mdempty, ready for Consolidationimplementation/folder for Phase 3 notesfinal-prompts/— every agent prompt with the persistence protocol already merged in. These are the exact prompts to dispatch — no manual copy-paste needed.
Dispatch order
- Dispatch
final-prompts/00-baseline.prompt.md(Opus). Wait for_status.md→ baseline: complete. - Dispatch the 7 Phase 1 prompts in parallel (Opus):
01through07. Each checks its own dependency in_status.mdbefore starting. - Once all 7 show
complete, dispatchfinal-prompts/08-consolidation.prompt.md(Opus). It writes99-backlog.mdand halts for human approval — check the file for anyADR-fixor BIO2-flagged tickets before proceeding. - For each approved ticket, copy
final-prompts/09-implementation.prompt.md, fill inTICKET-ID:, dispatch (Sonnet). Run tickets in parallel within a CD batch, sequential across batches, per theDepends oncolumn in99-backlog.md.
Re-running / resuming
Safe to re-run setup.sh only on a fresh workspace — it does not check for an
existing ./refactor-backlog/ and will overwrite _status.md and the phase
output files. If a run is already in progress, don't re-run setup.sh; just
re-dispatch the relevant final-prompts/*.prompt.md — each agent reads
_status.md and its own output file first and resumes from where it left off.