| new file mode 100644 |
| index 000000000..7a18f66e7 |
| --- /dev/null |
| +++ b/implementation/custom-domain-placements-447.md |
| @@ -0,0 +1,349 @@ |
| +# Custom-domain regional placements — #447 |
| + |
| +Status: design proposal; implementation and independent review have not started. |
| +Author: OpenAI GPT-6 Astra, 2026-10-28. |
| +Base: amadan main a9536235caa1679132d866f80b7076e9aed8bcf9. |
| +Branch: custom-domain-placements-447. |
| +Review history: no completed rounds. The initial read-only Opus discovery |
| +request was refused by the provider's weekly limit; it produced no findings. |
| +This is an implementation specification, not approved CLI or documentation copy. |
| + |
| +## 1. Contract and scope |
| + |
| +One verified custom domain, optionally with its delegated wildcard and |
| +catch-all, selects one explicitly named instance in each configured region. |
| +A request arriving at the box serving that instance uses that instance. It |
| +never falls back to another region when the local target is absent, stale, |
| +stopped or unhealthy. The app may accept writes on every instance and owns |
| +replication and write arbitration. CARLOS preserves each instance's existing |
| +regional storage, lease, backup and restore contract. |
| + |
| +Woodstar World (#447) is the first consumer: account bdm, app woodstar-relay, |
| +regions ie, uk, us and au, public apex woodstar.app and its one-label |
| +catch-all. Its bridges and indexer remain singletons. No Woodstar hostname, |
| +account, region list or replication protocol is hard-coded into the feature. |
| + |
| +The proposed first code merge must include the CLI, API, serving behaviour |
| +and per-region verification together. No preparatory schema-only or dormant |
| +routing merge. Switch-on for Woodstar is a separately approved migration |
| +after the feature's release is installed; no deployment date is authorized. |
| +Under AGENTS.md stopping rule 5, retain the implementation on its branch |
| +until the release/migration window is agreed if it would otherwise be dormant. |
| + |
| +## 2. What main actually does |
| + |
| +- `internal/provision/provision.go:243` defines Role and Replicas, but no |
| + home-instance binding. `internal/provision/replica.go` constructs a new |
| + instance in a region. An app can have several unrelated instances. |
| +- `internal/domains/aliases.go:372` derives a domain only from its exact |
| + locally present Claim.Route. It also derives wildcard and path rows. |
| + The #162 alias/residence follow-up was not part of its final merge. |
| +- `internal/edge/edge.go:1675` resolves local routes, then may backhaul on |
| + a miss. Deleting an alias alone does not establish local-only semantics. |
| + Exact remote names also outrank local wildcard matches. |
| +- `internal/edgesfile/homeelect.go` elects ONE global home. Publishing |
| + several ordinary home-role aliases does not describe regional routing. |
| +- `internal/edge/homemap.go:809` accepts home and delegated-wildcard roles; |
| + unrecognized roles are ignored. Certificate admission and routing share |
| + some data but are different authorities. |
| +- `internal/domains/claims.go:440,689` refuses/skips schemas above 1. |
| + `AttachClaimProven` presently stamps schema 1 and repoints Route. |
| +- `internal/console/apidomains.go:1025` interprets an empty Route as a |
| + first-route claim and can delete its provision record on detach. A new |
| + claim mode must never accidentally enter that branch. |
| +- `internal/activator/instancekey.go:280` withholds a newly minted instance |
| + key from replica rows. `replicaKeyGate` has special home-key checks in |
| + exec and rootfs launch paths. Therefore role=replica is not merely a |
| + harmless label even though its prose describes app-level replication. |
| +- `internal/console/apiregions.go` lists armed regions and AWS region |
| + identifiers; it does not return the serving addresses for a domain. |
| + `domainRecords` in `domainstate.go` gives deployment-wide DNS targets, |
| + which are insufficient for this feature's per-region local-only promise. |
| +- #169's latest ruling says flagship latency DNS is already active. Do |
| + not base this change on the earlier claim that it is unarmed. Its |
| + remaining multi-box and withdrawal issues are separate work. |
| + |
| +Woodstar DESIGN.md section 11.2 was read through the repository API on |
| +2026-10-28 (default-branch HEAD observed as |
| +0fecb07c28bb4b5a5710a1191aad5b47480f5c85). Public signed events replicate |
| +between peers; names, invites and other unique state use one home writer. |
| +That protocol is outside this branch. |
| + |
| +## 3. Decision: bind domains to ordinary instances |
| + |
| +Use explicit region-to-instance bindings on the domain claim. Use normal, |
| +socket-backed writable instances with independent identities. Do not infer |
| +a target from account/app equality, and do not extend role=replica or its |
| +instance-key sharing rules for World. This is a routing capability, not a |
| +new storage or instance role. |
| + |
| +The smallest supported shape is a verified ordinary alias claim: an |
| +explicit Route, no Instances catch-all, and no Paths map. Wildcard plus |
| +Catchall is supported and uses the same regional target as the apex. |
| +Reject first-route, platform-alias delegation, fleet/tunnel, TCP addrs, |
| +sidecar, static and replica-role targets in the first slice. Restricting |
| +shape prevents this work acquiring root launch or placement authority. |
| +Rootfs instances may participate only through the existing normal instance |
| +contract; there is no new rootfs start, worker, termination or filesystem path. |
| + |
| +Woodstar's current TCP route remains on the platform box under H24 until |
| +Paul explicitly approves the migration. Preparing socket instances and |
| +repointing its public claim is a deployment action, not something this |
| +proposal or its merge authorizes. The current first-route/public-route shape |
| +must be retired or converted through supported API/CLI operations before |
| +regional mode can be enabled. If that conversion lacks a member-facing |
| +operation, add it to the migration prerequisite; never use a box command |
| +or a direct bucket edit as a substitute. |
| + |
| +## 4. Desired state and mutation |
| + |
| +Extend Claim with a regional mode at schema 2. Legacy schema 1 parsing and |
| +behaviour remain unchanged. Proposed data shape: |
| + |
| + "schema": 2, |
| + "route": "world-ie.bdm.oncarlos.com", |
| + "placements": { |
| + "ie": {"host": "world-ie.bdm.oncarlos.com", "incarnation": 7}, |
| + "uk": {"host": "world-uk.bdm.oncarlos.com", "incarnation": 3} |
| + } |
| + |
| +Names and incarnation numbers above are examples, not observed resources. |
| +The server captures the currently judged incarnation, never trusts a |
| +client-supplied lifetime. Route stays nonempty for compatibility with |
| +first-route classification; in regional mode it is a designation of the |
| +ordinary single-target route, NEVER a fallback destination. It must be one |
| +of the explicit targets. Removing regional mode must explicitly name and |
| +validate the single target; an empty map must not silently restore Route. |
| + |
| +Map size 1..8, normalized unique placement codes, exactly one target per |
| +region, no duplicate hosts. Reject normalization collisions rather than |
| +silently choosing one. Region normalization uses the deployment's home |
| +region conventions, including the internal empty home-region code. |
| +Bindings require lifetime support; refuse unjudged/legacy targets rather |
| +than treating hostname equality as continuity after deletion/recreation. |
| + |
| +One conditional claim write changes the whole map, using the existing |
| +claim ownership/acquisition machinery and its exact claim ETag. Preserve |
| +proof, capabilities, creation metadata and ownership fields. No side object |
| +with an independent lifetime. A stale same-owner retry must not overwrite |
| +a newer map; return conflict and require a fresh read. Bump control serial |
| +only on a changed write. Return a desired-state digest to verification. |
| + |
| +Proposed member surface (syntax, not reviewed help copy): |
| + |
| + carlos domains placements --app APP HOST |
| + carlos domains placements --app APP --file placements.json HOST |
| + carlos domains placements --app APP --single-route TARGET HOST |
| + |
| +GET and PUT `/api/cli/apps/{account}/{app}/domains/{host}/placements`. |
| +PUT explicitly selects regional or single mode. Its region-to-host input |
| +is simpler than the stored binding; the server supplies lifetimes. |
| +`--wait` on writes waits for the returned digest and full serving checks; |
| +without it, output must identify desired state as pending, not ready. |
| + |
| +Use the existing domains principal, app binding and convergence-rate gate. |
| +Preserve platform-domain operator restrictions and neutral ownership |
| +refusals before target validation. Initially person-only mutation; service |
| +roles, including team, are explicitly denied by the route reach table. |
| +GET follows domain ownership and must not reveal another scope's bindings. |
| +No new credential authority is implied by this feature. |
| + |
| +Every target is checked under the app record lock with lifetime-aware record |
| +reads: same account and app, supported shape, exact region, current live |
| +incarnation, no active move/retirement. Reconcile repeats those checks; a |
| +race after validation can make a placement unavailable but cannot bind a |
| +replacement instance. Never hold a distributed claim CAS out as an atomic |
| +transaction with instance records. |
| + |
| +All existing writers must explicitly understand regional claims. Attach |
| +must refuse to silently repoint one; Paths must refuse a nonempty map; |
| +capability changes preserve placements; detach removes only the claim and |
| +its derived routing, never any target instance. Proof renewal and domain |
| +ownership transitions must not drop the mode or retain a foreign owner's |
| +bindings. Browser and CLI read paths must expose the mode accurately. |
| + |
| +## 5. Serving and failure behaviour |
| + |
| +Introduce a dedicated derived regional-domain policy table in the registry. |
| +It is owned by the domains reconcile pass, separate from ordinary aliases, |
| +so a missing primary cannot erase the knowledge that a name is local-only. |
| +Each policy carries host, optional one-label catch-all, owner/app, desired |
| +digest, and this region's bound target plus its lifetime (or no target). |
| +It grants no path, process, file or credential authority. |
| + |
| +All participating edges receive the policy, including an edge with no local |
| +instance. Unknown region, invalid target, wrong lifetime, inactive route, |
| +unreadable target, unavailable same-region placement or absent local target |
| +means unavailable, never a cross-region hop. A hibernating valid local |
| +instance may wake through its existing activator; failure does not widen. |
| + |
| +One resolver decides before asset-cache fallback and every backhaul arm: |
| + |
| +1. Preserve exact-name ownership and real-route precedence, including exact |
| + names on other boxes overriding a wildcard. Regional claims colliding |
| + with a real public route are refused at mutation and reconcile. |
| +2. For an exact regional name, or its eligible one-label catch-all, consult |
| + the local policy and resolve ONLY the bound local live route. |
| +3. If regional policy applies but cannot resolve locally, return the |
| + existing unavailable response (503). Do not try global Home, a far asset |
| + cache fill, another region, an app-default route or a different target. |
| +4. Names outside regional policies retain existing routing, hop and door |
| + rules. A verified inbound hop still cannot cause another hop. |
| + |
| +Map a regional entry to the existing upstream object so authentication, |
| +accounting, gates, compression, WebSockets and instance wake retain the |
| +normal path. Disable far asset reuse for regional names; local cache keys |
| +must include the target lifetime/generation and policy revision so a |
| +repoint cannot reuse the previous target's content or authentication result. |
| + |
| +A request landing on a different box in the same region is also unavailable |
| +in the first slice. Report only addresses of boxes that actually serve the |
| +bound target. Do not turn a region into a promise that every edge there |
| +holds the same database. Same-region proxy/failover is not part of #447. |
| + |
| +An unreadable claim cannot be interpreted as removal of a local-only rule. |
| +Preserve a last-known regional DENIAL policy and mark the pass incomplete; |
| +stop serving uncertain bindings. Removal requires an authoritative absence |
| +or a successfully read new single-route mode. Fresh startup with incomplete |
| +policy evidence must gate public serving until the applicable policy set |
| +is known; otherwise a restart would bypass the no-backhaul invariant. |
| + |
| +## 6. Publication, TLS and DNS |
| + |
| +Regional publications need a new role understood by new readers and ignored |
| +by old readers, never several ordinary `home` entries. They carry the |
| +policy digest and target lifetime. Keep certificate eligibility separate |
| +from global home election: an exact regional host can qualify for the |
| +existing bounded certificate machinery without acquiring a global dial |
| +home. Wildcard parents use the existing delegated issuance and mirroring |
| +contract. Preserve DNS/proof checks and issuance caps; no arbitrary SNI |
| +becomes certable because a catch-all matches it. |
| + |
| +Readers to change together: host edges writer, edge homemap/cert admission, |
| +`internal/edgesfile` election and deployment route folds, steering's narrow |
| +decoder, console served-by joins, domain status, and asset publication. |
| +Regional roles must never enter old home election or automatic per-host |
| +steering as though one target were authoritative everywhere. |
| + |
| +The GET response reports every requested placement with desired digest, |
| +observed digest, target/lifetime, serving addresses, certificate/delegation |
| +status, observation age and readiness. No result is green from one region's |
| +success. A stale heartbeat, incomplete listing or mismatched digest remains |
| +pending/unavailable. Verification is performed through the console and |
| +reported by the CLI; it must not require SSM, AWS credentials or on-box |
| +commands. Define the authenticated edge probe for policy/lifetime identity |
| +before implementation; do not accept a generic 200 or version header alone |
| +as proof of the correct regional database. |
| + |
| +For customer-managed DNS, offer provider-neutral record data for the apex |
| +and wildcard with region codes, provider region identifiers when known, |
| +TTL and ONLY currently verified serving addresses. Do not claim raw IPs |
| +are durable simply because they appear in a heartbeat. Address stability |
| +must come from a supported deployment endpoint contract exposed through |
| +the API; if none exists, that is a blocking product gap to implement, |
| +not permission to copy EIPs out of infrastructure files. Unsupported or |
| +unverified addresses must not be emitted as ready-to-use latency records. |
| + |
| +Woodstar may manage its own DNS through its normal account once the scoped |
| +migration is approved. This change does not edit its zone or require the |
| +oncarlos steering converger to own a customer zone. DNS failover may send a |
| +later client request to another configured region; CARLOS never retries an |
| +already received write against a different regional instance. |
| + |
| +## 7. Compatibility, lifecycle and rollout |
| + |
| +Schema 2 makes old claim readers refuse the new mode rather than silently |
| +strip its fields. It is necessary but NOT sufficient: old aliases, persisted |
| +registry rows and stale homemaps may survive until reconciliation, and old |
| +startup behaviour cannot enforce the new denial policy. |
| + |
| +Before enabling regional mode, require complete evidence that every public |
| +serving edge and relevant console runs the release carrying this feature; |
| +missing/unparseable evidence refuses. The exact release floor is assigned |
| +when the implementation is ready to release. Do not treat zero candidates |
| +as success. The readiness protocol must show the current policy digest has |
| +been applied everywhere traffic can arrive before reporting completion. |
| +Prevent rollback/arrival of an older serving binary while regional claims |
| +exist using the deployment's supported admission mechanism. If that cannot |
| +be enforced, refuse activation: a heartbeat-only check is insufficient. |
| +This admission mechanism remains a design prerequisite to resolve in review. |
| + |
| +Deleting/moving a target must not delete another region's state. For the |
| +first slice, reject member deletion and moves of a referenced live target |
| +until the map is changed; inspect references with the same locking and |
| +lifetime rules used by the map writer. Operator disaster recovery may still |
| +make a target disappear; routing then fails closed. Name reuse never |
| +reattaches an old mapping. Detaching a domain leaves every instance and its |
| +backup intact. Clearing placements requires an explicit single-route choice |
| +and completes only after its desired digest is observed. |
| + |
| +No inference about whether an app's data is disposable follows from this |
| +routing map. Ordinary instances keep their existing independent backups; |
| +CARLOS does not drain, merge, promote or discard Woodstar's event journals. |
| +Do not rewrite role=replica documentation to promise arbitrary writable |
| +semantics without auditing its separate key and lifecycle rules. Document |
| +regional domain placements as an independent capability and correct the |
| +old claim that #162 already serves the account's public host regionally. |
| + |
| +## 8. Acceptance witnesses |
| + |
| +- API: cross-account/app targets; unknown/reused lifetime; region mismatch; |
| + no fresh eligible box; incomplete listing; duplicate normalized regions; |
| + unsupported shape; team/service denial; proof/platform/collision checks. |
| + Unknown and foreign targets give identical neutral refusals. |
| +- CAS race: stale whole-map replacement loses; concurrent detach/reacquire |
| + cannot preserve bindings across ownership; instance delete/recreate never |
| + yields a newly authorized database through an old binding. |
| +- Two-region HTTP test: distinct local counters, same public apex and |
| + wildcard. POST reaches only the edge's selected counter. Block/remove the |
| + local target and assert 503 plus zero home/backhaul/asset-fill calls. |
| + Mutation: removing the pre-backhaul policy guard must fail this witness. |
| +- Wildcard precedence: foreign exact route/alias on another box wins its |
| + exact name; one-label match only; sidecar suffix and arbitrary SNI refused. |
| +- Lifecycle: sleeping local target wakes; stopped target does not forward; |
| + wrong lifetime denies; detach preserves all instances and backups; |
| + removal/repoint clears stale upstream and cache identity. |
| +- Rootfs: use the existing supported test backend; no new launch authority. |
| + Instance identities stay independent; no replica home-key gate is bypassed. |
| +- TLS: apex and wildcard served from two edges with the public host as SNI; |
| + unrelated names cannot issue; issuance/mirroring uses existing bounds. |
| +- Mixed versions: schema-1 round trip unchanged; old-reader fixture refuses |
| + schema 2; all writers preserve/refuse regional mode as specified; activation |
| + refuses stale evidence and old serving members, including later arrivals. |
| +- Convergence: claim/record/listing failures and reboot never restore global |
| + fallback; immutable route-policy snapshots prevent check/dispatch mismatch. |
| +- Verification: one healthy region cannot hide another stale/failed region; |
| + probe must match policy digest AND target lifetime; no ready DNS target |
| + without an address-stability contract. |
| + |
| +Run targeted witnesses during development. Before landing: whole-tree |
| +formatting, go build, vet and the repository make test gate once; hub CI |
| +including cross-compiles on the exact tip. Use default Go caches and disk |
| +scratch, never a per-task cache under /tmp. Production tests need approval. |
| + |
| +## 9. Implementation order and review |
| + |
| +1. Resolve the two design prerequisites with an independent Opus review: |
| + stable serving endpoint/API contract and admission of serving versions. |
| + Neither can be substituted with a box command or a heartbeat assumption. |
| +2. Implement desired state, CLI/API and denial-before-backhaul serving as |
| + one branch slice, with lifecycle and consumer changes together. Delegate |
| + bounded mechanical tasks to Sonnet/Haiku after the interfaces settle. |
| +3. Add end-to-end witnesses, per-region verification and approved help/docs |
| + copy. The copy-review gate applies before language enters product files. |
| +4. Generate the census proposal from the actual changed units/envelopes. |
| + Independent Opus/Fable review covers the whole branch and census; record |
| + the census verdict on #280. No guessed census updates in this design. |
| +5. Push and describe the branch on amadan. Merge only with review, exact-tip |
| + green CI and an agreed activation window. Read main's gate after merge. |
| + |
| +Review budget follows AGENTS.md: first no-P1 round stops; apply P2s without |
| +reopening except required changed-boundary/census review; P3s are follow-ups. |
| +Two consecutive rounds in one fault family stop implementation of that |
| +family. A fourth round needs Paul. No review has yet consumed a round. |
| + |
| +This branch does not grant production approval. A rollout proposal must |
| +name the account/region/domain/resources, permissions/traffic effects, |
| +costs, duration, rollback and verification. H24 migration approval and DNS |
| +changes belong in that explicit scope. #447 stays open until the routing |
| +capability and usable migration path actually exist. |