@@ -28,6 +28,47 @@ The routing model is exactly pds-gatekeeper's: **Caddy routes by path**, sending
2828auth-service process and everything else to the PDS. The auth-service stays a
2929separate process; only its _ origin_ changes.
3030
31+ ## Two levels of "merge" — keep them distinct
32+
33+ This matters for both benefits and risks, so fix the terms up front:
34+
35+ - ** Merge the _ origin_ (recommended baseline).** One hostname, Caddy path-routes
36+ to two still-separate processes. Dissolves every cross-origin cost; keeps the
37+ HMAC trust boundary; carries ** no** npm-version risk.
38+ - ** Merge the _ processes_ (optional, later).** Fold auth-service into the
39+ pds-core Node process. Adds the "fewer privileged endpoints" benefit in full
40+ (calls become in-process) but is the only variant that can surface
41+ dependency conflicts. Treat as a separate, later decision.
42+
43+ ## Positive benefits (beyond deleting costs)
44+
45+ - ** Fewer privileged cross-service endpoints.** The split _ requires_ the two
46+ services to communicate over authenticated HTTP: the HMAC-signed
47+ ` /oauth/epds-callback ` plus the internal lookup endpoints (` /_internal/* ` ,
48+ ` /_magic/check-email ` , ` account-by-email ` ). Each is an attack surface that
49+ must be signed, gated, and version-matched across the boundary. Merging the
50+ origin lets some of these relax; merging the processes lets most become
51+ in-process calls with no wire boundary at all.
52+ - ** Operational simplicity.** One TLS cert, one DNS record, one CSP surface, one
53+ origin's worth of cross-origin edge cases — instead of a parent/subdomain pair
54+ whose ` endsWith('.'+pdsHostname) ` relationship is itself load-bearing config
55+ threaded through several modules.
56+
57+ ## Risk: npm version clashes (process-merge only)
58+
59+ Applies ** only** to the process-merge variant, not the origin-merge baseline.
60+
61+ - Today the repo is a ** pnpm workspace** (` pnpm --recursive ` ) with pnpm's
62+ default non-flat ` node_modules ` , so ` auth-service ` and ` pds-core ` already
63+ resolve their dependencies independently.
64+ - Overlap is small: ` pds-core ` owns the heavy ` @atproto/* ` stack, ` auth-service `
65+ owns ` better-auth ` ; the only shared runtime dep is ` express ^4.18.2 ` , already
66+ aligned.
67+ - A single Node process would force one resolution of any shared/peer dep. The
68+ realistic conflict surface is a future ` express ` (or a transitive peer both
69+ pull) diverging. Bounded, but a real reason to prefer keeping two processes
70+ unless the in-process-call benefit is specifically wanted.
71+
3172## What gets deleted
3273
3374The whole point. These exist solely because of cross-origin-same-site:
@@ -44,6 +85,10 @@ The whole point. These exist solely because of cross-origin-same-site:
4485 ` session-reuse.ts:195-200 ` , the ` parentCookieDomain ` derivation in
4586 ` pds-core/src/index.ts:930 ` , and ` authOrigin ` derivation in
4687 ` chooser-enrichment.ts ` . The two hostnames become one.
88+ 4 . ** (Process-merge only) some privileged cross-service endpoints** — the
89+ ` /_internal/* ` / ` /_magic/* ` HTTP lookups become in-process calls. The
90+ HMAC-signed ` /oauth/epds-callback ` can also collapse to an in-process call
91+ if the processes merge. See "Two levels of merge" above.
4792
4893## What stays
4994
0 commit comments