Repository navigation
Description
Refs #13415, #9077. Policy: Drew's identity-linking policy, recorded on #13415 §5.
1. Problem + context
Auto-provisioning (policy §2, workstream the pending-link workstream) means one person can legitimately end up with more than one account: sign in with Microsoft before the Google-established account ever sees the claim, and there are two accounts that are both them. Drew's policy therefore requires account merge:
- There can't be objects that are guaranteed unique per account (or only a limited set) — otherwise merge has nowhere to put the duplicate.
- On merge the user chooses which account is primary.
- No data is lost — everything joins together.
- Profile attributes (picture, summary, etc.) can be repointed one by one between the merged accounts.
Today there is no merge operation, and no inventory of what is unique per account. Known per-account state in pkgs/idp-provider to start the audit from: the account row itself and its role set (roles live on the account, per the design note §3); identity rows keyed (provider, subject) pointing at one account_id (mechanically repointable, but the append-only identity_events and audit rows name the old account_id forever — merge must define how history reads, not rewrite it); tokens carry sub = account id (post-merge, which sub survives is a consumer-visible decision); the config seed list binds identities to the seeded account. Downstream, the fold-path debt matters: provider accounts later bind to id accounts via the #2852 ceremony, so a merged provider account must present exactly one binding target. the passkey workstream passkeys and the factor-policy workstream factor policies are new per-account objects being designed in parallel — both are many-per-account by construction, and this audit's constraints bind their schemas.
2. Goals / non-goals
Goals:
- A uniqueness audit: every object type in (and planned for) the provider enumerated with its per-account cardinality — unique-per-account, limited-set, or unlimited — with the unique/limited ones named as the merge-critical set Drew's rule allows ("or there's a limited set").
- A merge operation: two accounts join into the user-chosen primary; all identities, passkeys, history references, and data from the secondary remain present and reachable; nothing is hard-deleted (consistent with the store's existing never-hard-delete rule).
- Per-attribute repointing after merge: profile attributes (picture, summary, and the rest of the audited attribute set) can be individually sourced from either pre-merge account, changed one by one, each change audited.
- Merge is an audited account event on both accounts' histories, and the secondary account's identifiers keep resolving (as merged-into pointers) so old audit trails and token
subreferences remain interpretable.
Non-goals: automatic/duplicate-detection merge (merges are user-chosen, never inferred), unmerge (not in the policy; recorded as an open question, §8), recovery/deletion interplay (undecided — Drew), merging across the future id-system boundary (the #2852 binding is a constraint on the design, not part of this build).
3. Alternatives
- Do nothing / forbid second accounts instead. Contradicts auto-provisioning: duplicates are a designed-for outcome of policy §2, and forbidding them pushes the problem onto sign-in denial. Rejected.
- Delete-and-recreate (close the secondary, re-register its identities on the primary). Loses history and violates the no-loss rule and the store's never-hard-delete discipline. Rejected.
- Absorb with aliasing (chosen): the secondary account row survives as a merged-into shell pointing at the primary; its identities repoint to the primary (with the repoint recorded as events, history untouched); unique-per-account objects resolve by the primary-wins default with per-attribute override (the repointing surface). This is the only shape that satisfies no-loss + primary choice + per-attribute repointing simultaneously.
4. Chosen approach
Uniqueness audit (slice 1, the gate for the rest): a written inventory — object type × cardinality × merge treatment — covering today's provider state and the the passkey workstream/the factor-policy workstream objects, landed as a comment on this issue and reflected in the dated design record. The rule it enforces going forward: no new object type may introduce per-account uniqueness without being added to the merge-critical set with a stated merge treatment.
Merge operation: initiated from the primary account's established session (the pending-link workstream) with the secondary account's own established session also satisfied in the same flow (both accounts prove possession — merge is a two-key act, so a single compromised account cannot absorb or be absorbed silently). Steps, all audited on both histories: primary chosen → identities repoint (events recorded; original history rows unchanged) → unique-set objects resolved primary-wins with overrides deferred to the repointing surface → secondary marked merged_into: <primary> → secondary's sign-in paths thereafter authenticate as the primary (its identities are the primary's now). Roles: the merged account's role set is the primary's, with any secondary-only roles surfaced for explicit keep/drop during the merge flow — never silently granted, never silently dropped.
Repointing surface: per-attribute source selection over the audited attribute set (profile picture, summary/display fields, factor policy per the factor-policy workstream, and any other unique-set member), each change an audited event, available any time after merge — "one by one", per the policy, not a one-shot merge-time form.
Security analysis: the two-session requirement is the core control (merge joins everything either account can reach — it is the most powerful account act in the system). Role handling is the subtle risk: merging must not become a privilege-escalation path (a low-role secondary must not absorb a high-role primary's roles without the primary's own session consenting — which the two-key shape provides) nor a silent privilege loss. Append-only history is never rewritten: post-merge reads resolve account_id through the merged-into pointer for display, while the stored rows keep the original ids — audit continuity is the design's founding rule (#13415) and merge does not bend it.
5. Build slices (dependency-ordered, each with acceptance)
- Uniqueness audit. The inventory of §4, covering current + the passkey workstream/the factor-policy workstream planned objects. Acceptance: the inventory is posted on this issue, every object type in the provider schema appears in it, and the merge-critical set is explicitly named.
- Merge operation. Two-session initiation, identity repointing, primary-wins unique resolution, merged-into shell, role keep/drop surfacing. Acceptance (mock upstreams): two auto-provisioned accounts for the same person merge; every pre-merge object from both accounts is reachable post-merge; both histories read continuously; sign-in via a former-secondary identity reaches the primary.
- Repointing surface. Per-attribute source selection with audit. Acceptance: picture and summary repointed independently from the secondary's values, changed back, each step in the audit record.
- Constraint check on siblings. the passkey workstream/the factor-policy workstream schemas reviewed against the audit's rule before their builds land. Acceptance: a comment on each sibling issue confirming no unlisted per-account uniqueness was introduced.
6. Rollout + rollback
Merge is an explicit user act; shipping the capability changes nothing for unmerged accounts. Rollback = previous binary (merged-into shells are inert rows under old code; identities already repointed stay repointed — the merge itself is not auto-reversed, which the merge flow must state to the user before confirming).
7. Verification plan
Slice acceptances in the crate suite over mock upstreams; a no-loss checklist test that snapshots both accounts' full object sets pre-merge and diffs post-merge reachability; history-continuity test (pre-merge audit queries return identical rows post-merge).
8. Open questions (named deciders)
- Unmerge — Drew (not in the policy; not designed).
- Recovery requests and account deletion policy — Drew (policy §6; how merge interacts with a future deletion rule waits on it).
- Whether operator-CLI merge (without both sessions) should exist for Drew-only administration — Drew.
Dependencies
Largely independent of the pending-link workstream–the factor-policy workstream mechanically (store-level work), with two couplings: merge initiation uses the pending-link workstream's account session (so implementation follows it), and slice 1's audit should complete before the passkey workstream's schema lands so passkeys are merge-safe from day one. Slice 4 is the enforcement of that ordering.
{
"direct_parent": null,
"links": [],
"lineage": {
"design": null,
"roadmap_item": null,
"priority": null
},
"pm_meta": 1,
"provenance": {
"queue_id": null,
"scheduled_start": null,
"picked_up_at": null,
"work_started_at": null,
"created_at": "2026-11-24T01:26:44Z",
"session_id": null,
"lane": null,
"host": "htch-runtime",
"worktree": null,
"model": null,
"lane_start_issues": [],
"workspace_ref": null,
"auth_subject": "archer",
"stamped_by": "fleet 0.1.0 (native)"
}
}
Activity
developing-today commentedon Nov 24, 2026
CODE-5144
dezren39 commentedon Nov 24, 2026
Sibling map — filed together 2026-11-24 as the four workstreams of Drew's identity-linking policy (recorded on #13415):
Dependency order: (a) first; (b) builds on (a)'s account session; (c) builds on (a) + (b); (d) is independent of (a)–(c) mechanically, except its uniqueness audit (slice 1) should complete before (b)'s schema lands, and merge initiation uses (a)'s session. Issue bodies refer to siblings by workstream name; this comment is the number map.
dezren39 commentedon Nov 24, 2026
Triage (task 22485): #13975 OPEN, fresh workstream (d) with no actionable queue item and no open PR. Routed small_fix task 22734 (slice 1: report-only uniqueness audit + history/token rules, timed before #13973 schema lands). Merge initiation depends on workstream (a) #13972 session — noted for later slices.
dezren39 commentedon Nov 24, 2026
Lane oc-code-05, queue task 22734 (2026-11-24): slice 1 uniqueness audit posted as PR #14216 (doc/2026-11-24T09-10-00Z_design_account-merge-uniqueness-13975). Report-only: merge-critical set is account_id, display_name, local_credential_hash, roles, and the seed-list binding; passkeys and factor policy are unlimited or limited with stated treatment; history stays append-only with merged_into resolution; token sub survival decided. Slice 1 complete on merge of #14216.