domains: boxes derive account subdomain aliases (T3)
Spec 2026-11-11-account-subdomains §4.4, §4.7. The alias pass, given
AliasReport.AppsDomain (the agent sets it from PLATFORM_APPS_DOMAIN),
derives <prefix>.<name>.<apps> -> <prefix>.<sqid>.<apps> for every
Provisioned or Platform route of an account holding a namespace claim
(not sidecars or replicas). Exact claims, local routes and deployment
routes win; the rows share maxInstanceAliases with the instance
catch-all. HA instances derive into AliasIngress, zeroed entries kept
present but unavailable.
New registry table account_namespaces (name -> sqid), hashed in
Fingerprint, with remote branches and dispatch cases. The pass writes
it once per pass when it differs; it does not shrink under
StartupNoRemoval. An unread namespace body keeps its recorded rows and
table row and makes the pass incomplete; a not-found body (the fleet
door's decision) drops them and leaves the pass complete.
Derived rows start with their twin's DNS status ("pointing" when the
twin has none) and the pass keeps them in step; StampHealth no longer
DNS-stamps them, so _acme-challenge.<name> cannot unpublish them.
Census: group-name producers re-pinned with an "account namespace"
class witness; root-read overlay re-proposed under account-subdomains
(needs a reviewer ruling).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-proposal-account-subdomains.md+32 −3internal/domains/aliases.go+74 −13internal/domains/namespacealiases.go+289 −0internal/domains/namespacealiases_ha_test.go+84 −0internal/domains/namespacealiases_test.go+444 −0internal/domains/reconcile.go+21 −3internal/edge/storedoor_test.go+51 −0internal/host/agent.go+3 −0internal/host/edgesfile_test.go+53 −0internal/host/group_names_test.go+29 −10internal/provision/testdata/plan14-root-reads-account-subdomains.tsv+31 −2internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/registry/registry.go+99 −1internal/registry/registry_test.go+106 −0internal/registry/remote_dispatch.go+5 −0
Intent
<task-notification> <task-id>a0100a1d46be39289</task-id> <tool-use-id>toolu_016AkbvZzb8HkGFVAswiTHMX</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/709ac745-ee81-4971-97b8-321e18b19cf6/tasks/a0100a1d46be39289.output</output-file> <status>completed</status> <summary>Agent "Implement Task 2: namespace claim" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status:** DONE_WITH_CONCERNS **Commit:** `c81d61f2 domains: account namespace claim (subdomains T2)` **Tests:** all 10 new domains tests pass: the six the brief names, plus four for catch-all safety, bad-shape refusal and a stable `byAccount` pick. The census tests also pass: provision write and root-read, and host `TestGroupNameClassCensus` and `TestGroupNameProducerCensusScope`. Vet passes for linux, darwin and windows. **Concerns:** 1. The root-read census overlay (`plan14-root-reads-account-subdomains.tsv`, plus `docs/superpowers/notes/census-proposal-account-subdomains.md`) re-pins the `internal/domains` envelope and changes no units. It still needs an independent reviewer (Astra) to approve it on #280; I did not approve it myself. Task 8 re-proposes under the same NAME, so a single review then may be enough. 2. `AccountNamespaces` is stricter than the brief: it also skips namespace claims that carry App, Route, Wildcard, Catchall, Paths, Instances or Placements, or whose account is not valid. If one account holds two names, `byAccount` keeps the alphabetically first. Loosen this in a later task if needed. 3. Go tests had to run with the sandbox off, because inside it the default go-build cache is read-only. **Report:** `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-account-name-hosts/.superpowers/sdd/2026-11-11-account-subdomains/task-2-report.md`</result> <usage><subagent_tokens>124918</subagent_tokens><tool_uses>44</tool_uses><duration_ms>696335</duration_ms></usage> </task-notification>
<task-notification> <task-id>b64dmjnz8</task-id> <tool-use-id>toolu_01FM1H9MvRm48neszaHUQcMg</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/709ac745-ee81-4971-97b8-321e18b19cf6/tasks/b64dmjnz8.output</output-file> <status>completed</status> <summary>Background command "Run Astra and Fable task-2 reviews in parallel" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 25.6 g CO₂e (3,179,689 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-account-name-hosts, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/notes/census-proposal-account-subdomains.md b/docs/superpowers/notes/census-proposal-account-subdomains.md| index 7717864e5..29f2d437e 100644 |
| --- a/docs/superpowers/notes/census-proposal-account-subdomains.md |
| +++ b/docs/superpowers/notes/census-proposal-account-subdomains.md |
| @@ -1,11 +1,40 @@ |
| # Census approval: account-subdomains |
| -Ruling `census-ruling-account-subdomains`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| +Ruling `census-ruling-account-subdomains`. The independent reviewer approves or rejects every change below, 8 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| -Envelopes re-pinned: `internal/domains`. |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/domains/aliases.go` `deriveInstanceAliases` | body | unchanged (28) | takes a *int budget shared with the namespace pass instead of a local counter; the same checks and cap (maxInstanceAliases, now a var so a test can lower it); same reads; body change only | |
| +| `internal/host/agent.go` `aliasPassReportingComplete` | body | unchanged (5) | sets AliasReport.AppsDomain from PLATFORM_APPS_DOMAIN (trimmed), the variable domainsTickConfig reads; same reads and calls otherwise; body change only | |
| +| `internal/domains/aliases.go` `ReconcileAliasesReport` | sites | +whole:Route ×3, +whole:RouteAlias ×2 | with AliasReport.AppsDomain set, reads the box's own account_namespaces table (reg.ListAccountNamespaces), sorts a listed-but-unread namespace claim (ParseNamespaceHost on the dropped host): a not-found body keeps nothing and is not counted by relevantDropped, any other failure keeps that name's recorded rows; runs deriveNamespaceAliases after deriveInstanceAliases on the routes, alias rows and claims it already read (AccountNamespaces over the read claims), keepNamespaceAliases for unread names, and writes the table through writeAccountNamespaces (once, only when it differs; no shrink under StartupNoRemoval); the added sites are the routes and alias rows already read handed to those helpers; no file or bucket read added | |
| +| `internal/domains/reconcile.go` `StampHealth` | sites | +whole:RouteAlias ×6 | reads the box's own account_namespaces table (only when DNS stamping runs) and leaves out of the DNS loop the alias rows isNamespaceDerived names (an alias under a held name, of that name's account, pointing at its sqid twin); the added RouteAlias sites are that filter over rows already listed; stamps less, never more; TLS stamping unchanged | |
| +| `internal/registry/registry.go` `Registry.Fingerprint` | sites | +file:Query | hashes account_namespaces (name, account) over the same fresh connection, with a section marker written only when a row exists, so a registry with no held names digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; a digest, never a decision | |
| +| `internal/registry/registry.go` `Registry.migrate` | sites | +file:Exec, +registry:sql | one more CREATE TABLE IF NOT EXISTS account_namespaces (name TEXT PRIMARY KEY, account TEXT NOT NULL), an in-binary literal (+file:Exec, +registry:sql); additive, no existing statement changed | |
| + |
| +Envelopes re-pinned: `internal/domains`, `internal/host`, `internal/registry`. |
| Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| -Seal: `b3d35a0bd7c0500c74efbe5e8f566adb623696d31bd9860164907e08a2e79369` → `b3d35a0bd7c0500c74efbe5e8f566adb623696d31bd9860164907e08a2e79369`. |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/domains/aliases.go` `deriveInstanceAliases`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): rev3=J1's body; a stale body under a retired lifetime no longer makes a label shared, and a label with a record that cannot be judged keeps its existing alias row of the catch-all's own account and app (reading that row's Account and App) only once the derived name has passed every precedence check a derived name answers to (validity, an exact claim, a local real route, a deployment route, the per-box cap), and derives no new one; a report-only conservative keep, never a new route;rev3=census-ruling-regional-domains-447;basis=#447 Task 2: an instance catch-all whose parent claim is regional is inert (logged once, continue), as one whose parent is not held is; it only narrows what derives; no read added |
| +- `internal/host/agent.go` `aliasPassReportingComplete`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-g2-fixes;basis=Extract the existing serialized alias pass, add cancellable locking and routing-only alias/regional publication from its completeness report; existing deployment/claim/registry reads retained, new in-memory Route/RegionalDomain passes.;rev3=census-ruling-fix-incomplete-domains-pass;basis=gains a startup bool parameter that it copies into domains.AliasReport.StartupNoRemoval; runHAIngressStartup passes true, aliasPassReporting (the ordinary agent pass) passes false; same reads and calls, body change only; no root pass calls it; no root decision |
| +- `internal/domains/aliases.go` `ReconcileAliasesReport`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in its alias pass (aliasPassReporting in runAgent; ReconcileAliases, now a wrapper, is its other caller): main's ReconcileAliases body, moved here with the same reads and writes, plus a completeness report (AliasReport) set false at every point that already logged a failure and carried on, and when relevantDropped names a listed claim the pass could not rule out; the box's asset authority clock advances only after a complete pass; one more whole:Route and whole:RouteAlias site each, the routes and alias rows the pass already read handed to relevantDropped; no registry, file or bucket read added; no root pass calls it; no root decision;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: in the alias pass inside the agent: reads the existing regional_domains rows (reg.ListRegional) beside the alias rows, derives a regional claim's rows through deriveRegional for AliasReport.Region (the caller's ReconcileConfig.Region, set by aliasPassReporting) and its wildcard parent when bound, skipping the alias, paths and catch-all halves for it, writes them through writeRegional, and keeps an unread regional claim's wildcard parent while the kept apex row still binds a target RegionalTarget accepts on the routes this pass read (same account and app, per-box cap); claims are read as before (the listing and per-claim GETs it already does); the added reads are the registry's regional rows and fields of rows the pass already holds;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 fix rounds 2-3: AliasReport.FleetRefused (edge.FleetArmVerdict's refused set) is called once on the pass's own listing; a Wildcard claim whose primary is fleet-refused derives no wildcard_domains row (an earlier one goes with the ordinary removal); the catch-all alias is derived as before (+registry:Host, +whole:Route). Rows already read; writes less, never more; no root pass calls it.;rev3=census-ruling-region-ha-g2-fixes;basis=Project accepted regional exact/catchall names and plain/delegated aliases into routing-only reports using existing claims and pre-pool metadata; new whole Route/RegionalDomain uses, no new external reader.;rev3=census-ruling-fix-incomplete-domains-pass;basis=adds AliasReport.StartupNoRemoval, an input set only by the agent startup HA ingress pass (host startupAliasPass via runHAIngressStartup): when set, the pass skips the route_aliases, wildcard_domains and route_paths removals (each skipped removal marks the pass incomplete) and the removal rules themselves are unchanged; derivations, refusals and writes are unchanged; same read sites (body change only); no new registry, file or bucket read; deletes less, never more, and only on the startup pass; no root pass calls it; no root decision |
| +- `internal/domains/reconcile.go` `StampHealth`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts, which first hands the pass's hostnames to Config.FreshRetain (the resolver forgets its in-memory backoff and strike for names no longer carried) and then decides each hostname once per pass and applies the verdict to every row carrying it: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address, A or AAAA, "pointing", other "elsewhere", authoritative not-found "", authoritative NODATA for A and AAAA with the zone's SOA "" with no cached query), falling back to the cached lookup past the budget or on the second fresh failure in a row; the first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again); a previously "pointing" name keeps cached-first plus the upgrade-only fresh look (ResolveUpgrade, nearest zones first), so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; new names are ordered never-checked first then oldest check, and lookups answered from the backoff do not count against the budget; StampHealth's own body is unchanged by the last round; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724) |
| +- `internal/registry/registry.go` `Registry.Fingerprint`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user); the remote arm, unchanged, in the process that holds a remote handle: census-ruling-seeded-instances's body with the row's lifetime pair (incarnation, serving_seq) folded into the edge's change poll, each only when non-zero, so a registry with no pair digests as before; self-serve moves 1 Task 7;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: hashes regional_domains (host, target, account, app, region; created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no regional rows digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; no file path read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R1 finding 1: the routes SELECT also reads host, kind, account, app, platform and fingerprintForwardInert (one CASE over the ForwardForbidden columns), and every row folds host, kind, account and app (tagged, quoted), platform when set, and forward_inert=0 for a forward row that is not inert, so a rowid reused by another hostname, an in-place account or app rewrite, or a stray forbidden column moves the edge's change poll. Same one SELECT per table on the same fresh connection to the box's own registry database, as carlos; no table, file or bucket read added; a digest, never a decision.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the SELECT also reads fleet_label and, only when it is set, hashes "fleet_label=<q>" into the digest, so labelling a row moves the edge's reload fingerprint. Read sites unchanged (33). Registry side, not root; an unlabelled registry's digest is byte-identical.;rev3=census-ruling-stateless-replicas-1;basis=Read the additive stateless projection in the existing registry SELECT and hash only when set; no new read source.;rev3=census-ruling-agent-start-demo-1;basis=Existing SELECT reads four more demo columns; only a marked row adds them to the hash, so ordinary hashes remain unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Four additive projection columns join the existing routes SELECT and hash only when nonzero; no new query or file read. merge of origin/main 6be08467: Union main demo identity and expiry with replica columns in the same SELECT and hash; merge-only body change.;rev3=census-ruling-agent-start-demo-3;basis=Hash moved-notice wire bytes so notice-only changes invalidate an edge route snapshot. Census read-site delta: +file:QueryRow.;rev3=census-ruling-edge-page-cache-1;basis=selects the new pages_off column with the rest and folds "pages_off=1" into the hash only when set, as assets_off, so a registry that never sets it fingerprints as before; same routes SELECT, no new table; read sites unchanged (34); no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: hashes link_channels (link_id, account, token_hash, status, generation; connected, seen_at, seq and created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no links digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; a digest, never a decision; linked deployments slice 1 Task 7: also folds home_link (id, serving_url, tunnel_url, the token's sha256 never the token, account, apps_domain, box_label, conn_gen; state and created_at not) and home_link_apps (name, home_account, home_app, home_host) through fingerprintHomeLink over the same fresh connection, each section marker written only when a row exists, so a registry with no link digests as before; no file path read; a digest, never a decision |
| +- `internal/registry/registry.go` `Registry.migrate`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user), on every registry open; a box CLI verb that opens the registry directly runs it as whoever runs the verb: census-ruling-seeded-instances's body with two more columns added to routes (incarnation and serving_seq, INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule); self-serve moves 1 Task 7;rev3=census-ruling-rootfs-apps-2;basis=one more ALTER TABLE, routes ADD COLUMN runtime TEXT NOT NULL DEFAULT '', beside main's rate_limit, assets_off, asset_gen, incarnation and serving_seq (the last four from the merges of origin/main 3c33f2eb and 953b9fda); the same sixteen sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 4: three more ALTER TABLE statements in the existing loop, routes ADD COLUMN egress_allow, size and policy_expires_at, each TEXT NOT NULL DEFAULT '' and idempotent through the duplicate-column rule; the same sixteen sites, no read added.;rev3=census-ruling-region-ha-p1a;basis=one more ALTER TABLE in the existing loop: routes ADD COLUMN ha INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule; the same sixteen sites, no read added;rev3=census-ruling-ha-p1a-433;basis=the registry's SQLite side as carlos (agent, registry child; a box CLI verb that opens the registry directly runs it as whoever runs it), on every registry open: the ALTER TABLE routes statements are now built from the one migration definition routeAddedColumns (addedColumn name, type, default; review r1 P2): for each entry without the Claim mark, "ALTER TABLE routes ADD COLUMN " + spec(), byte for byte the statements main runs, in main's order, under the same duplicate-column rule. +registry:Claim is that mark, +whole:addedColumn the struct. Every name, type and default is an in-binary literal; no statement added, removed or changed; no read added.;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: one more CREATE TABLE IF NOT EXISTS regional_domains (host TEXT PRIMARY KEY, target, account, app, region TEXT NOT NULL DEFAULT '', created_at INTEGER NOT NULL DEFAULT 0), beside wildcard_domains; the added sites are that statement (+file:Exec, +registry:sql), an in-binary literal; additive, no existing statement changed;rev3=census-ruling-region-ha-p1b3b-t;basis=Create local HA duty/replay tables and revision triggers in the existing registry connection; no new database path.;rev3=census-ruling-agent-start-demo-3;basis=Create moved-notice storage as a single (id, wire) row; fingerprints include the stored wire bytes. Census read-site delta: +file:Exec, +registry:sql.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: calls migrateLinks after migrateHADuties (one CREATE TABLE IF NOT EXISTS link_channels, an in-binary literal); additive, no existing statement changed; linked deployments slice 1 Task 7: also runs migrateHomeLink (CREATE TABLE IF NOT EXISTS home_link and home_link_apps) after migrateLinks; additive, the box's own registry database, as carlos |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/domains/namespacealiases.go:deriveNamespaceAliases`: reads +registry:Account ×2, +registry:Alias, +registry:App ×3, +registry:DNSCheckedAt ×2, +registry:DNSStatus, +registry:HA, +registry:Host ×6, +registry:Platform, +registry:Provisioned, +registry:Replica, +whole:Route ×14, +whole:RouteAlias ×5; written legacy, accepted-legacy, frozen |
| +- new `internal/domains/namespacealiases.go:isNamespaceDerived`: reads +registry:Account, +registry:Alias, +registry:Host; written legacy, accepted-legacy, frozen |
| +- new `internal/domains/namespacealiases.go:keepNamespaceAliases`: reads +registry:Alias ×5, +whole:Route, +whole:RouteAlias ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/domains/namespacealiases.go:namespaceTwinStatus`: reads +registry:DNSStatus ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/registry/registry.go:Registry.ListAccountNamespaces`: reads +file:Query, +registry:StringMap ×3, +registry:remote ×2, +registry:sql, +whole:remoteClient ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/registry/registry.go:Registry.SetAccountNamespaces`: reads +file:Exec ×2, +registry:remote ×2, +registry:sql, +whole:remoteClient ×2; written legacy, accepted-legacy, frozen |
| +- other `changed registry schema`: closed only if it is the registry schema (re-pinned) |
| +- reads `internal/registry/remote_dispatch.go:Registry.dispatchRemote`: +registry:Names, +registry:StringMap; keeps hint, task E2 |
| + |
| +Seal: `b3d35a0bd7c0500c74efbe5e8f566adb623696d31bd9860164907e08a2e79369` → `caa598435ef98388152440e03eb0e83bcaa83f20e1634d8fc9031d11416c0a73`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-account-subdomains.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/domains/aliases.go b/internal/domains/aliases.go| index 6bff906b0..9320d5fd3 100644 |
| --- a/internal/domains/aliases.go |
| +++ b/internal/domains/aliases.go |
| @@ -45,14 +45,16 @@ const maxWildcardDomains = 32 |
| // primary, not a Kind=="sidecar" row at all. |
| const sidecarSuffix = ".sidecar.internal" |
| -// maxInstanceAliases caps the alias rows instance catch-alls derive on one |
| -// box. Every alias row costs a serial DNS lookup in the box's health stamp |
| +// maxInstanceAliases caps the alias rows instance catch-alls and account |
| +// namespaces derive on one box, together (one budget per pass). Every alias |
| +// row costs a serial DNS lookup in the box's health stamp |
| // and about 140 bytes in its status snapshot, which readers skip whole |
| // above 1 MiB — and a skipped box drops out of the deployment's route and |
| // edge-address folds. The cap keeps a large app from carrying a box past |
| // that. Deterministic (claims in list order, routes in host order), so a |
| -// rerun keeps the same names; the overflow is logged, never silent. |
| -const maxInstanceAliases = 1000 |
| +// rerun keeps the same names; the overflow is logged, never silent. A var |
| +// only so a test can lower it. |
| +var maxInstanceAliases = 1000 |
| // instanceCatchallSaid holds the instance catch-alls whose refusal has |
| // already been logged by this process, keyed by claim host and reason. The |
| @@ -123,15 +125,18 @@ func sayInstanceCatchallOnce(host, reason string) { |
| // could not be judged (unknown) keeps its existing row as it is and derives |
| // no new one, unless the judged records alone already share it. |
| // |
| +// budget is the per-box allowance of derived names (maxInstanceAliases), |
| +// shared with the account namespaces' names (deriveNamespaceAliases, which |
| +// runs after this): each name kept or derived here takes one. |
| +// |
| // The result is true when the pass was INCOMPLETE here: the label count |
| // failed (the names were kept, not decided), a label's count was unknown, |
| // or an alias write failed. The caller folds it into the pass's report. |
| -func deriveInstanceAliases(claims []Claim, listed map[string]bool, routes []registry.Route, byHost map[string]registry.Route, existing []registry.RouteAlias, deploymentRoutes map[string]bool, desired map[string]bool, labelHosts func(account, app string) (map[string]int, map[string]bool, error), reg *registry.Registry, now func() time.Time) (incomplete bool) { |
| +func deriveInstanceAliases(claims []Claim, listed map[string]bool, routes []registry.Route, byHost map[string]registry.Route, existing []registry.RouteAlias, deploymentRoutes map[string]bool, desired map[string]bool, labelHosts func(account, app string) (map[string]int, map[string]bool, error), budget *int, reg *registry.Registry, now func() time.Time) (incomplete bool) { |
| claimed := make(map[string]Claim, len(claims)) |
| for _, c := range claims { |
| claimed[c.Host] = c |
| } |
| - derived := 0 |
| have := make(map[string]registry.RouteAlias, len(existing)) |
| for _, a := range existing { |
| have[a.Alias] = a |
| @@ -213,22 +218,22 @@ func deriveInstanceAliases(claims []Claim, listed map[string]bool, routes []regi |
| // the count is uncertain: the name, an exact claim and the |
| // routes above outrank it as they outrank any derived name. |
| if a, ok := have[name]; ok && a.Account == c.Account && a.App == c.App { |
| - if derived >= maxInstanceAliases { |
| + if *budget <= 0 { |
| sayInstanceCatchallOnce(c.Host, "this box is at its cap of "+strconv.Itoa(maxInstanceAliases)+" derived names; the rest of the app's instances here serve on their own hosts only") |
| break |
| } |
| - derived++ |
| + *budget-- |
| desired[name] = true |
| } |
| sayInstanceCatchallOnce(c.Host, "a record of label "+label+" could not be judged; its name is kept as it is until it can be") |
| incomplete = true |
| continue |
| } |
| - if derived >= maxInstanceAliases { |
| + if *budget <= 0 { |
| sayInstanceCatchallOnce(c.Host, "this box is at its cap of "+strconv.Itoa(maxInstanceAliases)+" derived names; the rest of the app's instances here serve on their own hosts only") |
| break |
| } |
| - derived++ |
| + *budget-- |
| desired[name] = true |
| if a, ok := have[name]; ok && a.Host == rt.Host && a.Account == c.Account && a.App == c.App { |
| continue // already the row we want: no write, so no reload |
| @@ -336,6 +341,13 @@ type AliasReport struct { |
| // existed (v0.34.4) a restarted box made no removal until its first |
| // ordinary pass, which is the behaviour this restores. |
| StartupNoRemoval bool |
| + // AppsDomain is an INPUT, set by the caller before the pass: the |
| + // deployment's apps domain, from the same PLATFORM_APPS_DOMAIN the |
| + // domains tick reads (account subdomains spec §4.4). An account |
| + // namespace claim under it derives <prefix>.<name>.<AppsDomain> beside |
| + // each of the account's <prefix>.<sqid>.<AppsDomain> routes. "" derives |
| + // no namespace names and writes no account_namespaces row. |
| + AppsDomain string |
| } |
| // relevantDropped returns the hosts of the listed-but-unread claims that the |
| @@ -403,7 +415,10 @@ func relevantDropped(dropped []droppedClaim, routes []registry.Route, aliases [] |
| // because its claim was listed but not read this pass |
| // - a listed claim yielded no claim and the pass cannot rule it out |
| // (relevantDropped: any read error, unparseable body or newer schema; a |
| -// not-found body only when its account owns a route on this box) |
| +// not-found body only when its account owns a route on this box; a |
| +// not-found account namespace body, never: that is a decision) |
| +// - an account namespace derived-alias write or account_namespaces write |
| +// failed, or the startup pass left a recorded name it would drop |
| // - deploymentRoutes is nil (its read failed, so the "another box serves |
| // this as a route" guard was off for the pass) or rep.DeploymentRoutesPartial |
| // says the read skipped an unusable edges file |
| @@ -445,7 +460,36 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry. |
| if err != nil { |
| return err |
| } |
| - if h := relevantDropped(dropped, routes, existing); len(h) > 0 { |
| + // Account namespaces (spec §4.4) need the apps domain; without one the |
| + // pass derives none and writes no account_namespaces row. A namespace |
| + // claim the listing shows but whose body did not read is sorted here: |
| + // not-found is a decision (the fleet store door 404s only a foreign or |
| + // pending body; a store error is not a 404), so it keeps nothing and |
| + // does not make the pass incomplete; any other failure keeps the name's |
| + // recorded rows below, and relevantDropped counts it as unread. |
| + appsDomain := "" |
| + if rep != nil { |
| + appsDomain = rep.AppsDomain |
| + } |
| + var existingNS map[string]string |
| + var nsUnread []string |
| + reportDropped := dropped |
| + if appsDomain != "" { |
| + if existingNS, err = reg.ListAccountNamespaces(); err != nil { |
| + return err |
| + } |
| + reportDropped = nil |
| + for _, d := range dropped { |
| + if name, ok := ParseNamespaceHost(d.host, appsDomain); ok { |
| + if d.notFound { |
| + continue |
| + } |
| + nsUnread = append(nsUnread, name) |
| + } |
| + reportDropped = append(reportDropped, d) |
| + } |
| + } |
| + if h := relevantDropped(reportDropped, routes, existing); len(h) > 0 { |
| log.Printf("domains: %d claim(s) listed but unreadable this pass (e.g. %s) — the pass is incomplete", len(h), h[0]) |
| incomplete = true |
| } |
| @@ -779,15 +823,32 @@ func ReconcileAliasesReport(ctx context.Context, s release.Store, reg *registry. |
| } |
| } |
| } |
| + budget := maxInstanceAliases |
| if deriveInstanceAliases(claims, listed, routes, byHost, existing, deploymentRoutes, desired, |
| func(account, app string) (map[string]int, map[string]bool, error) { |
| // The judge rides in the pass's context (provision.WithLifetimes |
| // records it here too); none is today's key count. |
| return InstanceLabelCountsJudged(ctx, s, InstanceObserverFrom(ctx), account, app, 2) |
| - }, reg, now) { |
| + }, &budget, reg, now) { |
| incomplete = true |
| } |
| noRemoval := rep != nil && rep.StartupNoRemoval |
| + if appsDomain != "" { |
| + held, _ := AccountNamespaces(claims, appsDomain) |
| + if deriveNamespaceAliases(held, appsDomain, routes, byHost, existing, listed, deploymentRoutes, desired, &budget, reg, now, rep) { |
| + incomplete = true |
| + } |
| + kept := map[string]string{} |
| + for _, name := range nsUnread { |
| + if sqid, ok := existingNS[name]; ok { |
| + kept[name] = sqid |
| + } |
| + } |
| + keepNamespaceAliases(kept, appsDomain, existing, listed, byHost, deploymentRoutes, desired, &budget) |
| + if writeAccountNamespaces(reg, existingNS, held, kept, noRemoval) { |
| + incomplete = true |
| + } |
| + } |
| for _, a := range existing { |
| if !desired[a.Alias] { |
| if noRemoval { |
diff --git a/internal/domains/namespacealiases.go b/internal/domains/namespacealiases.go| new file mode 100644 |
| index 000000000..a16fe2b91 |
| --- /dev/null |
| +++ b/internal/domains/namespacealiases.go |
| @@ -0,0 +1,289 @@ |
| +package domains |
| + |
| +// Account subdomains on each box (spec |
| +// docs/superpowers/specs/2026-11-11-account-subdomains-design.md §4.4, §4.7). |
| +// An account holding the name N has every one of its app URLs |
| +// <prefix>.<sqid>.<apps> served at <prefix>.N.<apps> too. Each box derives |
| +// those names from its own routes as ordinary route_aliases rows, beside the |
| +// instance catch-all's, and records the held names in account_namespaces. |
| + |
| +import ( |
| + "log" |
| + "maps" |
| + "sort" |
| + "strconv" |
| + "strings" |
| + "sync" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// namespaceSaid holds the namespace notices this process has already logged. |
| +// The pass runs every couple of seconds on every box, and a capped box is a |
| +// standing state, not an event. |
| +var namespaceSaid sync.Map |
| + |
| +func sayNamespaceOnce(key, msg string) { |
| + if _, said := namespaceSaid.LoadOrStore(key, true); !said { |
| + log.Print(msg) |
| + } |
| +} |
| + |
| +// splitUnderApps splits a host under appsDomain into the label directly |
| +// under the apps domain and everything before it: "c1.shop.bdq.apps.test" |
| +// gives prefix "c1.shop" and label "bdq". ok is false for a host that is not |
| +// at least two labels under appsDomain. |
| +func splitUnderApps(host, appsDomain string) (prefix, label string, ok bool) { |
| + if appsDomain == "" { |
| + return "", "", false |
| + } |
| + rest, ok := strings.CutSuffix(host, "."+appsDomain) |
| + if !ok { |
| + return "", "", false |
| + } |
| + i := strings.LastIndexByte(rest, '.') |
| + if i <= 0 || i == len(rest)-1 { |
| + return "", "", false |
| + } |
| + return rest[:i], rest[i+1:], true |
| +} |
| + |
| +// namespaceDerivedName is the name a host under sqid's label derives under |
| +// name: "<prefix>.<name>.<appsDomain>". ok is false when the host is not |
| +// under sqid's label or the result is not a normalised alias hostname (too |
| +// long once joined). |
| +func namespaceDerivedName(host, sqid, name, appsDomain string) (string, bool) { |
| + prefix, label, ok := splitUnderApps(host, appsDomain) |
| + if !ok || label != sqid { |
| + return "", false |
| + } |
| + derived := prefix + "." + name + "." + appsDomain |
| + if n, ok := NormalizeAliasHost(derived); !ok || n != derived || strings.HasSuffix(derived, sidecarSuffix) { |
| + return "", false |
| + } |
| + return derived, true |
| +} |
| + |
| +// isNamespaceDerived reports whether a is a row the namespace pass derives: |
| +// its name sits under a held name of a's own account and it points at that |
| +// name's sqid twin (<prefix>.<sqid>.<appsDomain> for <prefix>.<name>.<appsDomain>). |
| +// held is account_namespaces (name to sqid). |
| +func isNamespaceDerived(a registry.RouteAlias, held map[string]string, appsDomain string) bool { |
| + prefix, name, ok := splitUnderApps(a.Alias, appsDomain) |
| + if !ok { |
| + return false |
| + } |
| + sqid, ok := held[name] |
| + return ok && a.Account == sqid && a.Host == prefix+"."+sqid+"."+appsDomain |
| +} |
| + |
| +// namespaceTwinStatus is the DNS status a derived row carries: its sqid |
| +// twin's stamp if the twin has one, and otherwise "pointing", because the |
| +// apps domain's wildcard answers the derived name exactly as it answers the |
| +// twin (spec §4.7). That is what lets the edges file publish the row on the |
| +// pass that writes it. |
| +func namespaceTwinStatus(twin registry.Route) string { |
| + if twin.DNSStatus != "" { |
| + return twin.DNSStatus |
| + } |
| + return "pointing" |
| +} |
| + |
| +// deriveNamespaceAliases adds the alias rows the account namespaces derive |
| +// (spec §4.4) to desired and writes them, after deriveInstanceAliases and |
| +// before the pass's removal sweep. held is the names in force (name to |
| +// sqid, AccountNamespaces' byName). For each held name and each route on |
| +// this box that is Provisioned or Platform, not a sidecar or replica row, of |
| +// the name's account, and whose host is <prefix>.<sqid>.<appsDomain> with a |
| +// prefix, the row <prefix>.<name>.<appsDomain> -> that host is derived. |
| +// |
| +// A derived name never beats an exact claim on that name, whoever holds it |
| +// (judged from the listing, so an unread claim still wins), a real route on |
| +// this box or on any live box (deploymentRoutes), or a name the pass already |
| +// desires. The rows share budget with the instance catch-all's names; past |
| +// it nothing more is derived, and that is logged once. |
| +// |
| +// A derived row is written with its twin's DNS status (namespaceTwinStatus) |
| +// and kept at it: StampHealth leaves these rows alone (isNamespaceDerived), |
| +// and this pass corrects a row whose status no longer matches its twin's. |
| +// |
| +// With a report, HA instances (which are never local routes) derive their |
| +// names into rep.AliasIngress instead, from rep.HAIngressRoutes: an entry |
| +// under the sqid's label that is HA, has a host and is the account's, or a |
| +// zeroed entry under the label (evidence refuses forwarding), which keeps |
| +// the derived name present but unavailable. The precedence is the same, |
| +// plus a name the HA scan knows as its own host or one already accepted. |
| +// |
| +// existing is the alias table as the pass read it, so a row that is already |
| +// right is not rewritten. The result is true when a write failed. |
| +func deriveNamespaceAliases(held map[string]string, appsDomain string, routes []registry.Route, byHost map[string]registry.Route, existing []registry.RouteAlias, listed map[string]bool, deploymentRoutes map[string]bool, desired map[string]bool, budget *int, reg *registry.Registry, now func() time.Time, rep *AliasReport) (incomplete bool) { |
| + if appsDomain == "" || len(held) == 0 { |
| + return false |
| + } |
| + // Names by account, each sorted, so the cap truncates the same way on |
| + // every pass. |
| + namesOf := map[string][]string{} |
| + for name, sqid := range held { |
| + namesOf[sqid] = append(namesOf[sqid], name) |
| + } |
| + for _, names := range namesOf { |
| + sort.Strings(names) |
| + } |
| + have := make(map[string]registry.RouteAlias, len(existing)) |
| + for _, a := range existing { |
| + have[a.Alias] = a |
| + } |
| + free := func(derived string) bool { |
| + if listed[derived] || desired[derived] || deploymentRoutes[derived] { |
| + return false |
| + } |
| + _, taken := byHost[derived] |
| + return !taken |
| + } |
| + // routes come from reg.List, in host order. |
| +routes: |
| + for _, rt := range routes { |
| + if !(rt.Provisioned || rt.Platform) || rt.IsSidecar() || rt.Replica { |
| + continue |
| + } |
| + sqid := release.RouteAccount(rt) |
| + for _, name := range namesOf[sqid] { |
| + derived, ok := namespaceDerivedName(rt.Host, sqid, name, appsDomain) |
| + if !ok || !free(derived) { |
| + continue |
| + } |
| + if *budget <= 0 { |
| + sayNamespaceOnce("cap", "domains: account namespaces: this box is at its cap of "+strconv.Itoa(maxInstanceAliases)+ |
| + " derived names; the rest of its app URLs serve on their <sqid> hosts only") |
| + break routes |
| + } |
| + *budget-- |
| + desired[derived] = true |
| + status := namespaceTwinStatus(rt) |
| + a, had := have[derived] |
| + if !had || a.Host != rt.Host || a.Account != sqid || a.App != rt.App { |
| + if err := reg.UpsertAlias(registry.RouteAlias{ |
| + Alias: derived, Host: rt.Host, Account: sqid, App: rt.App, |
| + DNSStatus: status, DNSCheckedAt: rt.DNSCheckedAt, CreatedAt: now().Unix(), |
| + }); err != nil { |
| + log.Printf("domains: upsert account namespace alias %s: %v", derived, err) |
| + incomplete = true |
| + continue |
| + } |
| + } |
| + // UpsertAlias never rewrites dns_status on a row that exists. |
| + if had && a.DNSStatus != status { |
| + at := rt.DNSCheckedAt |
| + if at == 0 { |
| + at = now().Unix() |
| + } |
| + if err := reg.SetAliasDNSStatus(derived, status, at); err != nil { |
| + log.Printf("domains: stamp account namespace alias %s: %v", derived, err) |
| + incomplete = true |
| + } |
| + } |
| + } |
| + } |
| + if rep == nil || len(rep.HAIngressRoutes) == 0 { |
| + return incomplete |
| + } |
| + keys := make([]string, 0, len(rep.HAIngressRoutes)) |
| + for k := range rep.HAIngressRoutes { |
| + keys = append(keys, k) |
| + } |
| + sort.Strings(keys) |
| + for _, key := range keys { |
| + _, sqid, ok := splitUnderApps(key, appsDomain) |
| + if !ok { |
| + continue |
| + } |
| + rt := rep.HAIngressRoutes[key] |
| + if rt.Host == "" || !rt.HA { |
| + rt = registry.Route{} // known, but its evidence refuses forwarding |
| + } else if rt.Host != key || rt.Account != sqid { |
| + continue |
| + } |
| + for _, name := range namesOf[sqid] { |
| + derived, ok := namespaceDerivedName(key, sqid, name, appsDomain) |
| + if !ok || listed[derived] || deploymentRoutes[derived] { |
| + continue |
| + } |
| + if _, taken := byHost[derived]; taken { |
| + continue |
| + } |
| + if _, taken := rep.HAIngressRoutes[derived]; taken { |
| + continue |
| + } |
| + if _, taken := rep.AliasIngress[derived]; taken { |
| + continue |
| + } |
| + rep.AliasIngress[derived] = rt |
| + } |
| + } |
| + return incomplete |
| +} |
| + |
| +// keepNamespaceAliases keeps, for this pass, the derived rows of names whose |
| +// namespace claim the listing shows but whose body was not read (kept: name |
| +// to the sqid account_namespaces recorded for it). Only rows that |
| +// isNamespaceDerived says belong to that recorded account are kept, and only |
| +// while no exact claim or real route has taken the name since. They count |
| +// against budget like any derived row. |
| +func keepNamespaceAliases(kept map[string]string, appsDomain string, existing []registry.RouteAlias, listed map[string]bool, byHost map[string]registry.Route, deploymentRoutes map[string]bool, desired map[string]bool, budget *int) { |
| + if len(kept) == 0 { |
| + return |
| + } |
| + for _, a := range existing { |
| + if !isNamespaceDerived(a, kept, appsDomain) { |
| + continue |
| + } |
| + if listed[a.Alias] || desired[a.Alias] || deploymentRoutes[a.Alias] { |
| + continue |
| + } |
| + if _, taken := byHost[a.Alias]; taken { |
| + continue |
| + } |
| + if *budget <= 0 { |
| + sayNamespaceOnce("cap", "domains: account namespaces: this box is at its cap of "+strconv.Itoa(maxInstanceAliases)+ |
| + " derived names; the rest of its app URLs serve on their <sqid> hosts only") |
| + return |
| + } |
| + *budget-- |
| + desired[a.Alias] = true |
| + } |
| +} |
| + |
| +// writeAccountNamespaces brings account_namespaces to the names this pass |
| +// holds (held, from the claims it read) plus the names it kept because their |
| +// claim body did not read (kept, as recorded). It writes once, and only when |
| +// the table differs. With noRemoval (the startup pass) the table does not |
| +// shrink, matching the alias rows that pass leaves: a recorded name the pass |
| +// would drop stays, and the pass is incomplete. The result is true when a |
| +// name was left for the next pass or the write failed. |
| +func writeAccountNamespaces(reg *registry.Registry, existing, held, kept map[string]string, noRemoval bool) (incomplete bool) { |
| + want := make(map[string]string, len(held)+len(kept)) |
| + for name, sqid := range kept { |
| + want[name] = sqid |
| + } |
| + for name, sqid := range held { |
| + want[name] = sqid |
| + } |
| + if noRemoval { |
| + for name, sqid := range existing { |
| + if _, ok := want[name]; !ok { |
| + want[name] = sqid |
| + incomplete = true // left for the next ordinary pass |
| + } |
| + } |
| + } |
| + if maps.Equal(want, existing) { |
| + return incomplete |
| + } |
| + if err := reg.SetAccountNamespaces(want); err != nil { |
| + log.Printf("domains: write account namespaces (%d name(s)): %v; the table is left as it was", len(want), err) |
| + return true |
| + } |
| + return incomplete |
| +} |
diff --git a/internal/domains/namespacealiases_ha_test.go b/internal/domains/namespacealiases_ha_test.go| new file mode 100644 |
| index 000000000..e560e0e3d |
| --- /dev/null |
| +++ b/internal/domains/namespacealiases_ha_test.go |
| @@ -0,0 +1,84 @@ |
| +package domains_test |
| + |
| +import ( |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/domains" |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// TestNamespaceHAIngress (account subdomains spec §4.4, brief rule 3): an HA |
| +// instance is not a local route on any box, so its derived name rides the |
| +// HA ingress projection instead of a registry row. The projection is built |
| +// by provision.HAIngressRoutesFromRecords, the production builder, whose |
| +// entries carry neither Provisioned nor Platform. A zeroed entry (a retired |
| +// record: evidence refuses forwarding) keeps its derived name present but |
| +// unavailable, and an exact claim on a derived name wins over it. |
| +func TestNamespaceHAIngress(t *testing.T) { |
| + ctx := t.Context() |
| + s := release.NewDirStore(t.TempDir()) |
| + if created, err := domains.AttachAccountNamespace(ctx, s, "harbour", "apps.test", "bdq", "2026-11-11T00:00:00Z", "ops@example.com"); err != nil || !created { |
| + t.Fatalf("hold: %v %v", created, err) |
| + } |
| + if err := provision.PutManifest(ctx, s, "bdq", "shop", provision.Manifest{Schema: 1, App: "shop", Domain: "bdq.apps.test"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + rec := func(slug string) provision.Record { |
| + return provision.Record{Schema: 1, Host: slug + ".bdq.apps.test", Slug: slug, Account: "bdq", App: "shop", Channel: "stable", Pool: "ha", HA: true} |
| + } |
| + live, api, old := rec("live"), rec("api"), rec("old") |
| + old.Retired = true |
| + other := provision.Record{Schema: 1, Host: "live.bcd.apps.test", Slug: "live", Account: "bcd", App: "shop", Channel: "stable", Pool: "ha", HA: true} |
| + if err := provision.PutManifest(ctx, s, "bcd", "shop", provision.Manifest{Schema: 1, App: "shop", Domain: "bcd.apps.test"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + routes, err := provision.HAIngressRoutesFromRecords(ctx, s, []provision.Record{live, api, old, other}, "") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if rt := routes[live.Host]; !rt.HA || rt.Host != live.Host || rt.Provisioned || rt.Platform { |
| + t.Fatalf("setup: live entry = %+v; want an HA entry with neither Provisioned nor Platform", rt) |
| + } |
| + if rt, ok := routes[old.Host]; !ok || rt != (registry.Route{}) { |
| + t.Fatalf("setup: retired entry = %+v %v; want a zeroed entry", rt, ok) |
| + } |
| + // bcd claimed api.harbour: the listing alone reserves it. |
| + body := []byte(`{"schema":1,"host":"api.harbour.apps.test","account":"bcd","app":"other","route":"x.bcd.apps.test"}`) |
| + if _, err := s.Put(ctx, domains.ClaimKey("api.harbour.apps.test"), body, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + reg, err := registry.Open(t.TempDir() + "/registry.db") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer reg.Close() |
| + rep := domains.AliasReport{AppsDomain: "apps.test", HAIngressRoutes: routes} |
| + if err := domains.ReconcileAliasesReport(ctx, s, reg, time.Now, map[string]bool{}, &domains.ClaimCache{}, &rep); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !rep.Complete { |
| + t.Fatal("pass incomplete") |
| + } |
| + if got, ok := rep.AliasIngress["live.harbour.apps.test"]; !ok || got != routes[live.Host] { |
| + t.Errorf("live.harbour = %+v %v; want the live entry %+v", got, ok, routes[live.Host]) |
| + } |
| + if got, ok := rep.AliasIngress["old.harbour.apps.test"]; !ok || got != (registry.Route{}) { |
| + t.Errorf("old.harbour = %+v %v; want present and unavailable", got, ok) |
| + } |
| + if got, ok := rep.AliasIngress["api.harbour.apps.test"]; ok { |
| + t.Errorf("api.harbour = %+v; an exact claim on the name wins", got) |
| + } |
| + for name := range rep.AliasIngress { |
| + switch name { |
| + case "live.harbour.apps.test", "old.harbour.apps.test": |
| + default: |
| + t.Errorf("unexpected HA alias %s", name) |
| + } |
| + } |
| + if aliases, err := reg.ListAliases(); err != nil || len(aliases) != 0 { |
| + t.Errorf("registry aliases = %+v, %v; HA names are never registry rows", aliases, err) |
| + } |
| +} |
diff --git a/internal/domains/namespacealiases_test.go b/internal/domains/namespacealiases_test.go| new file mode 100644 |
| index 000000000..850d1f088 |
| --- /dev/null |
| +++ b/internal/domains/namespacealiases_test.go |
| @@ -0,0 +1,444 @@ |
| +package domains |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "fmt" |
| + "net" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// Account subdomains, Task 3 (spec 2026-11-11-account-subdomains-design.md |
| +// §4.4, §4.7): every box derives <prefix>.<name>.<apps> beside each of the |
| +// account's <prefix>.<sqid>.<apps> routes, records the held names in |
| +// account_namespaces, and keeps both through a failed read. |
| + |
| +const nsApps = "apps.test" |
| + |
| +// reconcileNS runs one alias pass the way the agent does: with a report that |
| +// carries the apps domain, the deployment's routes known (so completeness |
| +// means something) and a claim cache, so the claim fold reads through |
| +// ListMod and per-key Get, the methods production calls. |
| +func reconcileNS(t *testing.T, s release.Store, reg *registry.Registry, appsDomain string) *AliasReport { |
| + t.Helper() |
| + return reconcileNSWith(t, s, reg, appsDomain, map[string]bool{}) |
| +} |
| + |
| +func reconcileNSWith(t *testing.T, s release.Store, reg *registry.Registry, appsDomain string, deploymentRoutes map[string]bool) *AliasReport { |
| + t.Helper() |
| + rep := &AliasReport{AppsDomain: appsDomain} |
| + if err := ReconcileAliasesReport(context.Background(), s, reg, aliasNow(), deploymentRoutes, &ClaimCache{}, rep); err != nil { |
| + t.Fatal(err) |
| + } |
| + return rep |
| +} |
| + |
| +// holdNamespace writes name's namespace claim for account through Task 2's |
| +// writer, the one the console door uses. |
| +func holdNamespace(t *testing.T, s release.Store, name, account string) { |
| + t.Helper() |
| + created, err := AttachAccountNamespace(context.Background(), s, name, nsApps, account, "2026-11-11T00:00:00Z", "ops@example.com") |
| + if err != nil || !created { |
| + t.Fatalf("hold %s for %s: created=%v err=%v", name, account, created, err) |
| + } |
| +} |
| + |
| +// addPlatformRoute upserts a minted app URL: Platform, not Provisioned |
| +// (mintedRoute's shape). |
| +func addPlatformRoute(t *testing.T, reg *registry.Registry, host, account, app string) { |
| + t.Helper() |
| + if err := reg.Upsert(registry.Route{ |
| + Host: host, App: app, Account: account, Kind: "service", Addr: "10.0.0.1:3000", Status: "ready", Platform: true, |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +func namespaces(t *testing.T, reg *registry.Registry) map[string]string { |
| + t.Helper() |
| + m, err := reg.ListAccountNamespaces() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return m |
| +} |
| + |
| +// wantAliases fails unless reg's alias rows are exactly want (alias -> |
| +// target host), each held by account. |
| +func wantAliases(t *testing.T, reg *registry.Registry, account string, want map[string]string) { |
| + t.Helper() |
| + got := aliasMap(t, reg) |
| + if len(got) != len(want) { |
| + t.Fatalf("aliases = %v; want %v", aliasTargets(got), want) |
| + } |
| + for alias, target := range want { |
| + a, ok := got[alias] |
| + if !ok || a.Host != target || a.Account != account { |
| + t.Fatalf("alias %s = %+v (present %v); want -> %s for %s (all: %v)", alias, a, ok, target, account, aliasTargets(got)) |
| + } |
| + } |
| +} |
| + |
| +func aliasTargets(m map[string]registry.RouteAlias) map[string]string { |
| + out := map[string]string{} |
| + for k, a := range m { |
| + out[k] = a.Host |
| + } |
| + return out |
| +} |
| + |
| +// claimListFailStore fails every listing of the claims prefix, by both |
| +// methods the claim fold can use. |
| +type claimListFailStore struct{ *release.DirStore } |
| + |
| +func (f claimListFailStore) List(ctx context.Context, prefix string) ([]string, error) { |
| + if strings.HasPrefix(prefix, ClaimsPrefix) { |
| + return nil, errors.New("synthetic list failure") |
| + } |
| + return f.DirStore.List(ctx, prefix) |
| +} |
| + |
| +func (f claimListFailStore) ListMod(ctx context.Context, prefix string) ([]release.KeyMod, error) { |
| + if strings.HasPrefix(prefix, ClaimsPrefix) { |
| + return nil, errors.New("synthetic list failure") |
| + } |
| + return f.DirStore.ListMod(ctx, prefix) |
| +} |
| + |
| +func TestNamespaceDerivesEveryAccountRoute(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + addInstance(t, reg, "shop.bdq.apps.test", "shop", "bdq", "shop") |
| + addPlatformRoute(t, reg, "site.bdq.apps.test", "bdq", "site") |
| + addInstance(t, reg, "team1.bdq.apps.test", "team1", "bdq", "teams") |
| + rep := reconcileNS(t, s, reg, nsApps) |
| + if !rep.Complete { |
| + t.Fatal("a clean pass is incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{ |
| + "shop.harbour.apps.test": "shop.bdq.apps.test", |
| + "site.harbour.apps.test": "site.bdq.apps.test", |
| + "team1.harbour.apps.test": "team1.bdq.apps.test", |
| + }) |
| + if a := aliasMap(t, reg)["site.harbour.apps.test"]; a.App != "site" { |
| + t.Errorf("derived row app = %q; want the route's, site", a.App) |
| + } |
| + if got := namespaces(t, reg); fmt.Sprint(got) != fmt.Sprint(map[string]string{"harbour": "bdq"}) { |
| + t.Errorf("account_namespaces = %v; want harbour:bdq", got) |
| + } |
| + // A second pass over the same input changes nothing. |
| + before := aliasMap(t, reg) |
| + if rep := reconcileNS(t, s, reg, nsApps); !rep.Complete { |
| + t.Fatal("second pass incomplete") |
| + } |
| + if fmt.Sprint(aliasMap(t, reg)) != fmt.Sprint(before) { |
| + t.Errorf("second pass rewrote rows: %v -> %v", before, aliasMap(t, reg)) |
| + } |
| +} |
| + |
| +func TestNamespaceSkipsOtherAccountsSidecarsReplicas(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + addInstance(t, reg, "ok.bdq.apps.test", "ok", "bdq", "shop") |
| + // Another account's route, under its own sqid and under bdq's label. |
| + addInstance(t, reg, "shop.bcd.apps.test", "shop", "bcd", "shop") |
| + addInstance(t, reg, "odd.bdq.apps.test", "odd", "bcd", "shop") |
| + // A sidecar and a replica row of bdq's. |
| + if err := reg.Upsert(registry.Route{Host: "side.bdq.apps.test", App: "shop", Account: "bdq", Kind: "sidecar", Status: "ready", Platform: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + addInstance(t, reg, "copy.bdq.apps.test", "copy", "bdq", "shop") |
| + if err := reg.SetReplica("copy.bdq.apps.test", true); err != nil { |
| + t.Fatal(err) |
| + } |
| + // A hand-added row (neither Provisioned nor Platform), and the sqid's |
| + // own apex (no prefix). |
| + addRoute(t, reg, "hand.bdq.apps.test", "bdq", "shop") |
| + addPlatformRoute(t, reg, "bdq.apps.test", "bdq", "site") |
| + // A route under the apps domain's sibling that merely ends in the sqid. |
| + addPlatformRoute(t, reg, "shop.xbdq.apps.test", "bdq", "shop") |
| + if rt, err := reg.Get("copy.bdq.apps.test"); err != nil || rt == nil || !rt.Replica { |
| + t.Fatalf("setup: replica row = %+v, %v", rt, err) |
| + } |
| + if rep := reconcileNS(t, s, reg, nsApps); !rep.Complete { |
| + t.Fatal("pass incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{"ok.harbour.apps.test": "ok.bdq.apps.test"}) |
| +} |
| + |
| +func TestNamespaceExactClaimAndRoutesWin(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + for _, p := range []string{"shop", "blog", "api", "www", "docs", "free"} { |
| + addInstance(t, reg, p+".bdq.apps.test", p, "bdq", "shop") |
| + } |
| + // bdq attached blog.harbour by hand to another of its routes: the exact |
| + // claim's row stands. |
| + putClaim(t, s, Claim{Host: "blog.harbour.apps.test", Account: "bdq", App: "shop", Route: "shop.bdq.apps.test"}) |
| + // A claim on api.harbour that this box cannot use (another account's): |
| + // the listing alone reserves the name. |
| + putClaim(t, s, Claim{Host: "api.harbour.apps.test", Account: "bcd", App: "other", Route: "x.bcd.apps.test"}) |
| + // A real route on this box, and one another box publishes. |
| + addRoute(t, reg, "www.harbour.apps.test", "bdq", "hand") |
| + rep := reconcileNSWith(t, s, reg, nsApps, map[string]bool{"docs.harbour.apps.test": true}) |
| + if !rep.Complete { |
| + t.Fatal("pass incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{ |
| + "blog.harbour.apps.test": "shop.bdq.apps.test", // the exact claim's target |
| + "shop.harbour.apps.test": "shop.bdq.apps.test", |
| + "free.harbour.apps.test": "free.bdq.apps.test", |
| + }) |
| +} |
| + |
| +func TestNamespaceNoRoutesThenFirstRoute(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + if rep := reconcileNS(t, s, reg, nsApps); !rep.Complete { |
| + t.Fatal("pass with no routes incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{}) |
| + if got := namespaces(t, reg); got["harbour"] != "bdq" { |
| + t.Fatalf("account_namespaces = %v; a name with no routes here is still held", got) |
| + } |
| + addPlatformRoute(t, reg, "shop.bdq.apps.test", "bdq", "shop") |
| + if rep := reconcileNS(t, s, reg, nsApps); !rep.Complete { |
| + t.Fatal("pass incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{"shop.harbour.apps.test": "shop.bdq.apps.test"}) |
| +} |
| + |
| +func TestNamespaceWithoutAppsDomain(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + addPlatformRoute(t, reg, "shop.bdq.apps.test", "bdq", "shop") |
| + if err := reg.SetAccountNamespaces(map[string]string{"cove": "bcd"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + rep := reconcileNS(t, s, reg, "") |
| + if !rep.Complete { |
| + t.Fatal("a box with no apps domain reported incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{}) |
| + if got := namespaces(t, reg); fmt.Sprint(got) != fmt.Sprint(map[string]string{"cove": "bcd"}) { |
| + t.Errorf("account_namespaces = %v; with no apps domain the pass writes nothing", got) |
| + } |
| +} |
| + |
| +func TestNamespaceRemovedDropsRows(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + addPlatformRoute(t, reg, "shop.bdq.apps.test", "bdq", "shop") |
| + reconcileNS(t, s, reg, nsApps) |
| + wantAliases(t, reg, "bdq", map[string]string{"shop.harbour.apps.test": "shop.bdq.apps.test"}) |
| + deleteClaim(t, s, NamespaceHost("harbour", nsApps)) |
| + if rep := reconcileNS(t, s, reg, nsApps); !rep.Complete { |
| + t.Fatal("pass incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{}) |
| + if got := namespaces(t, reg); len(got) != 0 { |
| + t.Errorf("account_namespaces = %v; want empty after the claim went", got) |
| + } |
| +} |
| + |
| +func TestNamespaceKeepsRowsWhenListingFails(t *testing.T) { |
| + for leg, cache := range map[string]*ClaimCache{"uncached": nil, "cached": {}} { |
| + t.Run(leg, func(t *testing.T) { |
| + dir := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, dir, "harbour", "bdq") |
| + addPlatformRoute(t, reg, "shop.bdq.apps.test", "bdq", "shop") |
| + reconcileNS(t, dir, reg, nsApps) |
| + before := aliasMap(t, reg) |
| + rep := &AliasReport{AppsDomain: nsApps} |
| + err := ReconcileAliasesReport(context.Background(), claimListFailStore{dir}, reg, aliasNow(), map[string]bool{}, cache, rep) |
| + if err == nil || rep.Complete { |
| + t.Fatalf("listing failure: err=%v complete=%v; want an error and incomplete", err, rep.Complete) |
| + } |
| + if fmt.Sprint(aliasMap(t, reg)) != fmt.Sprint(before) { |
| + t.Errorf("rows changed on a failed listing: %v -> %v", before, aliasMap(t, reg)) |
| + } |
| + if got := namespaces(t, reg); got["harbour"] != "bdq" { |
| + t.Errorf("account_namespaces = %v; want harbour:bdq kept", got) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestNamespaceKeepsRowsWhenClaimBodyUnread(t *testing.T) { |
| + dir := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, dir, "harbour", "bdq") |
| + addPlatformRoute(t, reg, "shop.bdq.apps.test", "bdq", "shop") |
| + addPlatformRoute(t, reg, "site.bdq.apps.test", "bdq", "site") |
| + reconcileNS(t, dir, reg, nsApps) |
| + // Rows under the name that are not the sqid twin of their target, or |
| + // are another account's, are not kept. |
| + for _, a := range []registry.RouteAlias{ |
| + {Alias: "blog.harbour.apps.test", Host: "shop.bdq.apps.test", Account: "bdq", App: "shop"}, |
| + {Alias: "x.harbour.apps.test", Host: "x.bcd.apps.test", Account: "bcd", App: "shop"}, |
| + } { |
| + if err := reg.UpsertAlias(a); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + unread := getFailStore{dir, ClaimKey(NamespaceHost("harbour", nsApps))} |
| + rep := reconcileNS(t, unread, reg, nsApps) |
| + if rep.Complete { |
| + t.Fatal("a namespace claim whose body failed to read left the pass complete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{ |
| + "shop.harbour.apps.test": "shop.bdq.apps.test", |
| + "site.harbour.apps.test": "site.bdq.apps.test", |
| + }) |
| + if got := namespaces(t, reg); fmt.Sprint(got) != fmt.Sprint(map[string]string{"harbour": "bdq"}) { |
| + t.Errorf("account_namespaces = %v; want harbour:bdq kept", got) |
| + } |
| + // With nothing recorded for the name, nothing is kept. |
| + fresh := aliasRegWith(t) |
| + addPlatformRoute(t, fresh, "shop.bdq.apps.test", "bdq", "shop") |
| + if rep := reconcileNS(t, unread, fresh, nsApps); rep.Complete { |
| + t.Fatal("unread body on a fresh box left the pass complete") |
| + } |
| + wantAliases(t, fresh, "bdq", map[string]string{}) |
| + if got := namespaces(t, fresh); len(got) != 0 { |
| + t.Errorf("account_namespaces = %v; nothing to keep on a fresh box", got) |
| + } |
| +} |
| + |
| +func TestForeignNamespaceOnFleetBoxIsComplete(t *testing.T) { |
| + t.Run("foreign name", func(t *testing.T) { |
| + dir := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, dir, "cove", "bcd") |
| + addPlatformRoute(t, reg, "shop.bdq.apps.test", "bdq", "shop") |
| + fleet := withholdStore{dir, map[string]bool{ClaimKey(NamespaceHost("cove", nsApps)): true}} |
| + if rep := reconcileNS(t, fleet, reg, nsApps); !rep.Complete { |
| + t.Fatal("a foreign namespace the door withholds left the pass incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{}) |
| + if got := namespaces(t, reg); len(got) != 0 { |
| + t.Errorf("account_namespaces = %v; want empty", got) |
| + } |
| + }) |
| + t.Run("reassigned away", func(t *testing.T) { |
| + dir := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, dir, "harbour", "bdq") |
| + addPlatformRoute(t, reg, "shop.bdq.apps.test", "bdq", "shop") |
| + reconcileNS(t, dir, reg, nsApps) |
| + wantAliases(t, reg, "bdq", map[string]string{"shop.harbour.apps.test": "shop.bdq.apps.test"}) |
| + // The operator removes harbour from bdq and gives it to bcd. bdq's |
| + // fleet box now gets the door's 404 for the body. |
| + deleteClaim(t, dir, NamespaceHost("harbour", nsApps)) |
| + holdNamespace(t, dir, "harbour", "bcd") |
| + fleet := withholdStore{dir, map[string]bool{ClaimKey(NamespaceHost("harbour", nsApps)): true}} |
| + if rep := reconcileNS(t, fleet, reg, nsApps); !rep.Complete { |
| + t.Fatal("a name reassigned away left the pass incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{}) |
| + if got := namespaces(t, reg); len(got) != 0 { |
| + t.Errorf("account_namespaces = %v; want harbour dropped", got) |
| + } |
| + }) |
| +} |
| + |
| +func TestDerivedRowStatusSurvivesStamp(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + addPlatformRoute(t, reg, "shop.bdq.apps.test", "bdq", "shop") |
| + addPlatformRoute(t, reg, "site.bdq.apps.test", "bdq", "site") |
| + addPlatformRoute(t, reg, "mail.bdq.apps.test", "bdq", "mail") |
| + if err := reg.SetDNSStatus("shop.bdq.apps.test", "pointing", 100); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.SetDNSStatus("mail.bdq.apps.test", "elsewhere", 100); err != nil { |
| + t.Fatal(err) |
| + } |
| + // An exact custom-domain alias beside them, the stamp's control. |
| + putClaim(t, s, Claim{Host: "www.example.com", Account: "bdq", App: "shop", Route: "shop.bdq.apps.test"}) |
| + reconcileNS(t, s, reg, nsApps) |
| + status := func() map[string]string { |
| + out := map[string]string{} |
| + for k, a := range aliasMap(t, reg) { |
| + out[k] = a.DNSStatus |
| + } |
| + return out |
| + } |
| + want := map[string]string{ |
| + "shop.harbour.apps.test": "pointing", // the twin's stamp |
| + "site.harbour.apps.test": "pointing", // an unstamped twin: the apps wildcard answers both |
| + "mail.harbour.apps.test": "elsewhere", // the twin's stamp, whatever it is |
| + "www.example.com": "", |
| + } |
| + if got := status(); fmt.Sprint(got) != fmt.Sprint(want) { |
| + t.Fatalf("first pass dns_status = %v; want %v", got, want) |
| + } |
| + gone := Config{AppsDomain: nsApps, EdgeIPs: func() []string { return []string{"203.0.113.7"} }, |
| + Resolve: func(string) ([]string, error) { return nil, &net.DNSError{Err: "no such host", IsNotFound: true} }, |
| + Now: func() time.Time { return time.Unix(3000, 0) }} |
| + if err := reg.SetAliasDNSStatus("www.example.com", "pointing", 100); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := StampHealth(context.Background(), reg, gone, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + want["www.example.com"] = "" // the control was stamped |
| + if got := status(); fmt.Sprint(got) != fmt.Sprint(want) { |
| + t.Fatalf("after a not-found stamp dns_status = %v; want %v", got, want) |
| + } |
| + // The twins were stamped "" too; the next pass still gives the derived |
| + // rows the apps wildcard's answer. |
| + want["mail.harbour.apps.test"] = "pointing" |
| + reconcileNS(t, s, reg, nsApps) |
| + if got := status(); fmt.Sprint(got) != fmt.Sprint(want) { |
| + t.Fatalf("after the next pass dns_status = %v; want %v", got, want) |
| + } |
| +} |
| + |
| +func TestNamespaceSharesInstanceCap(t *testing.T) { |
| + old := maxInstanceAliases |
| + maxInstanceAliases = 3 |
| + t.Cleanup(func() { maxInstanceAliases = old }) |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + putClaim(t, s, Claim{Host: "example.com", Account: "bdq", App: "site"}) |
| + putClaim(t, s, Claim{Host: "*.example.com", Account: "bdq", App: "shop", Instances: true}) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + addInstance(t, reg, "a1.bdq.apps.test", "a1", "bdq", "shop") |
| + addInstance(t, reg, "a2.bdq.apps.test", "a2", "bdq", "shop") |
| + addPlatformRoute(t, reg, "site.bdq.apps.test", "bdq", "site") |
| + reconcileNS(t, s, reg, nsApps) |
| + got := aliasMap(t, reg) |
| + if len(got) != 3 { |
| + t.Fatalf("aliases = %v; want the shared cap of 3", aliasTargets(got)) |
| + } |
| + for _, name := range []string{"a1.example.com", "a2.example.com", "a1.harbour.apps.test"} { |
| + if _, ok := got[name]; !ok { |
| + t.Errorf("%s missing from %v: instance names first, then namespace names in host order", name, aliasTargets(got)) |
| + } |
| + } |
| +} |
| + |
| +func TestCanaryHostIsMirrored(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + reg := aliasRegWith(t) |
| + holdNamespace(t, s, "harbour", "bdq") |
| + addPlatformRoute(t, reg, "c1.shop.bdq.apps.test", "bdq", "shop") |
| + if rep := reconcileNS(t, s, reg, nsApps); !rep.Complete { |
| + t.Fatal("pass incomplete") |
| + } |
| + wantAliases(t, reg, "bdq", map[string]string{"c1.shop.harbour.apps.test": "c1.shop.bdq.apps.test"}) |
| +} |
diff --git a/internal/domains/reconcile.go b/internal/domains/reconcile.go| index 540659ebf..5fd45d1c3 100644 |
| --- a/internal/domains/reconcile.go |
| +++ b/internal/domains/reconcile.go |
| @@ -477,6 +477,24 @@ func StampHealth(ctx context.Context, reg *registry.Registry, cfg Config, routes |
| return fmt.Errorf("domains: list aliases: %w", err) |
| } |
| } |
| + // The account namespaces' derived rows (spec §4.4, §4.7) are not |
| + // DNS-stamped here: the alias pass gives each its sqid twin's status |
| + // (namespaceTwinStatus), since the apps wildcard answers both. Stamping |
| + // them would unpublish them whenever an authoritative not-found came |
| + // back, which is what "_acme-challenge.<name>.<apps>" causes while a |
| + // wildcard order validates. TLS expiry is still stamped below. |
| + var dnsAliases []registry.RouteAlias |
| + if cfg.Resolve != nil && cfg.EdgeIPs != nil && len(aliases) > 0 { |
| + held, err := reg.ListAccountNamespaces() |
| + if err != nil { |
| + return fmt.Errorf("domains: list account namespaces: %w", err) |
| + } |
| + for _, a := range aliases { |
| + if !isNamespaceDerived(a, held, cfg.AppsDomain) { |
| + dnsAliases = append(dnsAliases, a) |
| + } |
| + } |
| + } |
| // --- 4. DNS health -------------------------------------------------------- |
| // The edge set is asked for ONCE PER PASS, not once per box start: under |
| @@ -515,12 +533,12 @@ func StampHealth(ctx context.Context, reg *registry.Registry, cfg Config, routes |
| // "pointing" — refusing that news would be the same lie in the |
| // opposite direction. |
| routeStatus := make([]string, len(routes)) |
| - aliasStatus := make([]string, len(aliases)) |
| + aliasStatus := make([]string, len(dnsAliases)) |
| var candidates []freshCandidate |
| for i, rt := range routes { |
| candidates = append(candidates, freshCandidate{rt.Host, rt.DNSStatus, rt.DNSCheckedAt, &routeStatus[i]}) |
| } |
| - for i, a := range aliases { |
| + for i, a := range dnsAliases { |
| candidates = append(candidates, freshCandidate{a.Alias, a.DNSStatus, a.DNSCheckedAt, &aliasStatus[i]}) |
| } |
| dnsVerdicts(cfg, edge, candidates) |
| @@ -533,7 +551,7 @@ func StampHealth(ctx context.Context, reg *registry.Registry, cfg Config, routes |
| log.Printf("domains: stamp dns on %s: %v", rt.Host, err) |
| } |
| } |
| - for i, a := range aliases { |
| + for i, a := range dnsAliases { |
| status := aliasStatus[i] |
| if status == heldDNS || status == unresolvedDNS && a.DNSStatus != "" { |
| continue |
diff --git a/internal/edge/storedoor_test.go b/internal/edge/storedoor_test.go| index eea553adb..72ca12c7e 100644 |
| --- a/internal/edge/storedoor_test.go |
| +++ b/internal/edge/storedoor_test.go |
| @@ -1435,3 +1435,54 @@ func TestStoreDoorManagedReadyKeyMatchesConsole(t *testing.T) { |
| t.Fatal("the door's matcher does not recognise the console's key") |
| } |
| } |
| + |
| +// TestStoreDoorReturnsOwnNamespaceClaim (account subdomains spec §4.4): a |
| +// box on a customer fleet reads its own account's namespace claim through |
| +// the store door, which is all it needs to derive the account's names. The |
| +// key carries a "*"; the door serves it like any other claim key. Another |
| +// account's fleet sees the name in the listing and gets the door's 404 for |
| +// the body, which its alias pass reads as a decision, not a failure. |
| +func TestStoreDoorReturnsOwnNamespaceClaim(t *testing.T) { |
| + const apps = "oncarlos.com" |
| + doorFor := func(account string) (*storeDoor, *release.DirStore) { |
| + d, store := newTestDoor(t) |
| + d.fleetAccount = func(fleet string) (string, bool) { |
| + if fleet == testFleet { |
| + return account, true |
| + } |
| + return "", false |
| + } |
| + return d, store |
| + } |
| + own, store := doorFor("bdq") |
| + if created, err := domains.AttachAccountNamespace(context.Background(), store, "harbour", apps, "bdq", "2026-11-11T00:00:00Z", "ops@example.com"); err != nil || !created { |
| + t.Fatalf("hold: %v %v", created, err) |
| + } |
| + key := domains.ClaimKey(domains.NamespaceHost("harbour", apps)) |
| + w := doorDo(own, "GET", "/store/list?prefix=domains/", "", nil) |
| + if w.Code != http.StatusOK || !strings.Contains(w.Body.String(), `"`+key+`"`) { |
| + t.Fatalf("listing = %d %s; want %s in it", w.Code, w.Body.String(), key) |
| + } |
| + w = doorDo(own, "GET", "/store/o/"+key, "", nil) |
| + if w.Code != http.StatusOK { |
| + t.Fatalf("own namespace claim = %d %s", w.Code, w.Body.String()) |
| + } |
| + var c domains.Claim |
| + if err := json.Unmarshal(w.Body.Bytes(), &c); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !c.AccountNamespace || c.Account != "bdq" || c.Host != domains.NamespaceHost("harbour", apps) || c.CreatedBy != "" { |
| + t.Fatalf("own namespace claim body = %s; want bdq's namespace claim without created_by", w.Body.String()) |
| + } |
| + if byName, _ := domains.AccountNamespaces([]domains.Claim{c}, apps); byName["harbour"] != "bdq" { |
| + t.Fatalf("the body the door served is not a namespace in force: %v", byName) |
| + } |
| + |
| + foreign, _ := doorFor("bcd") |
| + foreign.store = store |
| + want := doorDo(foreign, "GET", "/store/o/domains/absent.example.com.json", "", nil) |
| + got := doorDo(foreign, "GET", "/store/o/"+key, "", nil) |
| + if got.Code != http.StatusNotFound || got.Body.String() != want.Body.String() || fmt.Sprint(got.Header()) != fmt.Sprint(want.Header()) { |
| + t.Fatalf("bcd's fleet reading bdq's namespace claim = %d %q; want the same 404 an absent claim gets", got.Code, got.Body.String()) |
| + } |
| +} |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index c4f2449d2..e0654466f 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -1493,6 +1493,9 @@ func aliasPassReportingComplete(ctx context.Context, store release.Store, reg *r |
| defer auth.passEnd() |
| deploymentRoutes, routesWhole := edgesfile.DeploymentRoutesComplete(ctx, store, time.Now()) |
| rep := domains.AliasReport{DeploymentRoutesPartial: deploymentRoutes != nil && !routesWhole, Region: region, StartupNoRemoval: startup} |
| + // The apps domain as domainsTickConfig reads it: account subdomains |
| + // (spec §4.4) derive <prefix>.<name>.<apps> from it, and none without it. |
| + rep.AppsDomain = strings.TrimSpace(os.Getenv("PLATFORM_APPS_DOMAIN")) |
| if routes := boxHAIngress.routes.Load(); routes != nil { |
| rep.HAIngressRoutes = *routes |
| } |
diff --git a/internal/host/edgesfile_test.go b/internal/host/edgesfile_test.go| index 3985157e0..4f0febd35 100644 |
| --- a/internal/host/edgesfile_test.go |
| +++ b/internal/host/edgesfile_test.go |
| @@ -2606,3 +2606,56 @@ func TestDemoClaimSeedCapabilityRequiresConfiguration(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// TestEdgesFilePublishesDerivedRowAtOnce (account subdomains spec §4.4): the |
| +// alias pass, as the agent runs it, derives shop.harbour.<apps> from an |
| +// account namespace claim with the apps domain the box is configured with, |
| +// and writes the row with its twin's DNS status, so the very next edges file |
| +// publishes the name as an alias of its twin. No DNS sweep runs in between. |
| +func TestEdgesFilePublishesDerivedRowAtOnce(t *testing.T) { |
| + aliasClaimCache.Reset() |
| + oldAuthority := boxAssetAuthority |
| + boxAssetAuthority = newAssetAuthority(nil) |
| + t.Cleanup(func() { |
| + aliasClaimCache.Reset() |
| + boxAssetAuthority = oldAuthority |
| + }) |
| + t.Setenv("CARLOS_REGION_HA", "") |
| + t.Setenv("PLATFORM_APPS_DOMAIN", "apps.test") |
| + ctx := context.Background() |
| + store := release.NewDirStore(t.TempDir()) |
| + reg := edgesTestRegistry(t) |
| + if err := reg.Upsert(registry.Route{Host: "shop.bdq.apps.test", Account: "bdq", App: "shop", Kind: "service", |
| + Addr: "10.0.0.1:3000", Status: "ready", Platform: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if created, err := domains.AttachAccountNamespace(ctx, store, "harbour", "apps.test", "bdq", "2026-11-11T00:00:00Z", "ops@example.com"); err != nil || !created { |
| + t.Fatalf("hold: %v %v", created, err) |
| + } |
| + if ok, err := aliasPassReportingComplete(ctx, store, reg, &aliasClaimCache, boxAssetAuthority, "", false); err != nil || !ok { |
| + t.Fatalf("alias pass: complete=%v err=%v", ok, err) |
| + } |
| + var lastBody []byte |
| + if err := edgesFilePass(ctx, store, reg, edgesFile{Box: "annie"}, "1.2.3.4", &lastBody); err != nil { |
| + t.Fatal(err) |
| + } |
| + body, _, err := store.Get(ctx, "control/edges/annie.json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var f struct { |
| + Hosts map[string]struct { |
| + Role string `json:"role"` |
| + Alias bool `json:"alias"` |
| + Account string `json:"account"` |
| + TargetHost string `json:"target_host"` |
| + } `json:"hosts"` |
| + } |
| + if err := json.Unmarshal(body, &f); err != nil { |
| + t.Fatal(err) |
| + } |
| + h, ok := f.Hosts["shop.harbour.apps.test"] |
| + if !ok || h.Role != "home" || !h.Alias || h.TargetHost != "shop.bdq.apps.test" || h.Account != "bdq" { |
| + t.Fatalf("shop.harbour.apps.test = %+v (published %v); want a home alias of shop.bdq.apps.test owned by bdq", h, ok) |
| + } |
| +} |
diff --git a/internal/host/group_names_test.go b/internal/host/group_names_test.go| index 5e6b6fc4c..85454c316 100644 |
| --- a/internal/host/group_names_test.go |
| +++ b/internal/host/group_names_test.go |
| @@ -36,6 +36,7 @@ func groupNameCases(acct string) []groupNameCase { |
| {class: "platform alias", name: "shop." + acct + ".apps.test", route: true}, |
| {class: "plain alias", name: "alias.customer.test", alias: true}, |
| {class: "instance catchall", name: "shop.instances.test", alias: true}, |
| + {class: "account namespace", name: "shop.harbour.apps.test", alias: true}, |
| {class: "delegated catchall", name: "*.customer.test", alias: true, wildcard: true}, |
| {class: "certificate parent", name: "*.cert.test", wildcard: true}, |
| {class: "replica", name: "replica.example.com", route: true, replica: true}, |
| @@ -113,10 +114,14 @@ func TestGroupNamesBeforeAdmission(t *testing.T) { |
| {Schema: 1, Host: "cert.test", Account: acct, App: "shop", Route: "shop.example.com", Wildcard: true}, |
| {Schema: 1, Host: "instances.test", Account: acct, App: "shop"}, |
| {Schema: 1, Host: "*.instances.test", Account: acct, App: "shop", Instances: true}, |
| + {Schema: 1, Host: domains.NamespaceHost("harbour", "apps.test"), Account: acct, AccountNamespace: true}, |
| } { |
| put(domains.ClaimKey(c.Host), c) |
| } |
| - if err := domains.ReconcileAliases(ctx, s, reg, func() time.Time { return now }, nil, nil); err != nil { |
| + // With the apps domain, as the agent's alias pass runs it: the account |
| + // namespace derives shop.harbour.apps.test beside the minted |
| + // shop.<acct>.apps.test (account subdomains spec §4.4). |
| + if err := domains.ReconcileAliasesReport(ctx, s, reg, func() time.Time { return now }, nil, nil, &domains.AliasReport{AppsDomain: "apps.test"}); err != nil { |
| t.Fatal(err) |
| } |
| if err := domains.Reconcile(ctx, s, reg, cfg); err != nil { |
| @@ -204,7 +209,7 @@ func TestGroupNamesBeforeAdmission(t *testing.T) { |
| // Every producer is pinned as well as its schema: a new derivation must add |
| // a behavioral row above before the producer's inventory can be renewed. |
| func TestGroupNameClassCensus(t *testing.T) { |
| - required := []string{"exact route", "platform alias", "plain alias", "instance catchall", "delegated catchall", "certificate parent", "replica", "path ambiguity", "sidecar"} |
| + required := []string{"exact route", "platform alias", "plain alias", "instance catchall", "account namespace", "delegated catchall", "certificate parent", "replica", "path ambiguity", "sidecar"} |
| got := map[string]bool{} |
| for _, c := range groupNameCases(domains.Sqid(2)) { |
| if got[c.class] { |
| @@ -428,6 +433,19 @@ func (p *haIngressProjection) publishAliases(names map[string]Route) { p.aliases |
| // one is served under its exact host down its link's channel (ArmLink), |
| // like a fleet forward row. No name is derived or published anew. |
| // |
| +// Account subdomains (Task 3) add one alias class, "account namespace": |
| +// - deriveNamespaceAliases derives <prefix>.<name>.<apps> -> the account's |
| +// own <prefix>.<sqid>.<apps> route, an ordinary route_aliases row of the |
| +// account's, published and admitted exactly as a plain alias is (the |
| +// class row above). Exact claims and real routes win; the rows share the |
| +// instance catch-all's per-box cap. HA names go to AliasIngress only, as |
| +// deriveHAIngressAliases' do; no local route is created. |
| +// - deriveInstanceAliases takes that shared budget; its names and classes |
| +// are unchanged. |
| +// - ReconcileAliasesReport runs the namespace pass with AliasReport's |
| +// AppsDomain, writes account_namespaces, keeps an unread namespace's |
| +// recorded rows and treats a not-found namespace body as a decision. |
| +// |
| // TestHAIngressNamesWithoutLocalRow, TestHAIngressAliasBinding and |
| // TestHAIngressStartupNames exercise these existing name classes end to end. |
| var groupNameProducerInventory = map[string]string{ |
| @@ -437,14 +455,15 @@ var groupNameProducerInventory = map[string]string{ |
| "haingress.go:*haIngressProjection.publish": "060b22fd87d0a20f7d3c4b58838139f9b2b86d9da19d7d31dc29152eb31e9132", |
| "haingress.go:*haIngressProjection.publishAliases": "c577688de88de5f13faf189eff94e291075bafb52ca653c70c7b897749ca3482", |
| - "../provision/haingress.go:HAIngressRoutesFromRecords": "731822d67daf83884aa037e2a42e0dd3358edc9a31cecba45a609672a88dc7c3", |
| - "../provision/demo_claim_seed.go:abortDemoClaimSeed": "e010b4e6b026a0744b7eacf6ffdb09647de6e1541e33ce73e71e7c99964a9f7a", |
| - "../domains/aliases.go:ReconcileAliasesReport": "7e8b5d72f23f5e540fc9504666b05098c78fbd3b1c77a84654898f8a121df459", |
| - "../domains/aliases.go:deriveInstanceAliases": "47b40b392927d9c50cab6c350083af24565e4e148cd1b5ddc257e9803153c0c2", |
| - "../domains/aliases.go:deriveRegional": "79fd7c432e6b0a9ffd945312851e52af2c450769416ef44ff9a4bea681b44cde", |
| - "../domains/reconcile.go:Reconcile": "8b2848535d0a15117d578ac28c7486997c6ad8960b58b6dca5d4b35cde14eed0", |
| - "../domains/reconcile.go:mintedRoute": "dbd2211f62fc606661c6d8258ecfbf18f0b3c865e775522c5b363d01c442fca9", |
| - "../edge/assetcatch.go:*Edge.AssetOwners": "2b9ce5620a6defa16f12cb38d389ac59aa594049d37d84746f0a76419ab05b5f", |
| + "../provision/haingress.go:HAIngressRoutesFromRecords": "731822d67daf83884aa037e2a42e0dd3358edc9a31cecba45a609672a88dc7c3", |
| + "../provision/demo_claim_seed.go:abortDemoClaimSeed": "e010b4e6b026a0744b7eacf6ffdb09647de6e1541e33ce73e71e7c99964a9f7a", |
| + "../domains/aliases.go:ReconcileAliasesReport": "7f9f02f6023edba342c6c5c5cbbbca02c53241baeb2ef1432aa31ffca04362a7", |
| + "../domains/aliases.go:deriveInstanceAliases": "1b453aa7739be5f3c54ae0dbaf0a52795e8821ca009d07dd4ed766e1ac5073ee", |
| + "../domains/namespacealiases.go:deriveNamespaceAliases": "3bc340f2b0c3ee766e9b0c4124e981097bcbfd1229ebc11dd62011c2da78e6ba", |
| + "../domains/aliases.go:deriveRegional": "79fd7c432e6b0a9ffd945312851e52af2c450769416ef44ff9a4bea681b44cde", |
| + "../domains/reconcile.go:Reconcile": "8b2848535d0a15117d578ac28c7486997c6ad8960b58b6dca5d4b35cde14eed0", |
| + "../domains/reconcile.go:mintedRoute": "dbd2211f62fc606661c6d8258ecfbf18f0b3c865e775522c5b363d01c442fca9", |
| + "../edge/assetcatch.go:*Edge.AssetOwners": "2b9ce5620a6defa16f12cb38d389ac59aa594049d37d84746f0a76419ab05b5f", |
| // Name resolution and owner binding unchanged in class; farForward now resolves owner and destination from one snapshot via backhaul; no new name class produced. |
| "../edge/assetcatch.go:*Edge.serveAssetFar": "775ee62d683e07fbcee8a9ea21e03b0b364a5d07aadef8f333da37985c2eaa9b", |
| // Demo protections wrap existing proxies and retain refusal-only names. |
diff --git a/internal/provision/testdata/plan14-root-reads-account-subdomains.tsv b/internal/provision/testdata/plan14-root-reads-account-subdomains.tsv| index a2f68a582..2b9c62fe5 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-account-subdomains.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-account-subdomains.tsv |
| @@ -1,3 +1,32 @@ |
| # Census overlay account-subdomains, written by census-propose (#369). census-ruling-account-subdomains, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-account-subdomains.md. |
| -# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -@coverage internal/domains 193d28bd67b0ece5f2a69ae7b44d287839edd2d074d16f915ff0882920274556 |
| +# 2 body, 4 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 8 new dispositions: 1 reads re-frozen at their disposition with the claim, 6 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 1 other. |
| +@legacy c2cfff6c738fb2f53726a5f537873a72720c4413262be1a39d8b7cff3d79a939 internal/domains/aliases.go deriveInstanceAliases legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): rev3=J1's body; a stale body under a retired lifetime no longer makes a label shared, and a label with a record that cannot be judged keeps its existing alias row of the catch-all's own account and app (reading that row's Account and App) only once the derived name has passed every precedence check a derived name answers to (validity, an exact claim, a local real route, a deployment route, the per-box cap), and derives no new one; a report-only conservative keep, never a new route;rev3=census-ruling-regional-domains-447;basis=#447 Task 2: an instance catch-all whose parent claim is regional is inert (logged once, continue), as one whose parent is not held is; it only narrows what derives; no read added;rev3=census-ruling-account-subdomains;basis=takes a *int budget shared with the namespace pass instead of a local counter; the same checks and cap (maxInstanceAliases, now a var so a test can lower it); same reads; body change only registry:Account@2487,registry:Account@3805,registry:Account@4604,registry:Alias@2549,registry:Alias@2617,registry:Alias@2661,registry:Alias@574,registry:App@1987,registry:App@2513,registry:App@3831,registry:App@4630,registry:Host@2144,registry:Host@4583,registry:Host@4593,registry:Host@4789,registry:Provisioned@1937,registry:Replica@1973,registry:Slug@2076,whole:Route@1921,whole:Route@2027,whole:Route@3347,whole:RouteAlias@2467,whole:RouteAlias@3787,whole:RouteAlias@4565,whole:RouteAlias@526,whole:RouteAlias@556,whole:RouteAlias@569,whole:RouteAlias@585 e0e3f4f651bc7fde2c37c0259d993ca02b36bac67adee10140227eaa30c41ab3 |
| +@legacy 25840eb4a2ba81e4108851318ad48bc9d7bdccc6a824c7a8ca372306428913bb internal/host/agent.go aliasPassReportingComplete legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-g2-fixes;basis=Extract the existing serialized alias pass, add cancellable locking and routing-only alias/regional publication from its completeness report; existing deployment/claim/registry reads retained, new in-memory Route/RegionalDomain passes.;rev3=census-ruling-fix-incomplete-domains-pass;basis=gains a startup bool parameter that it copies into domains.AliasReport.StartupNoRemoval; runHAIngressStartup passes true, aliasPassReporting (the ordinary agent pass) passes false; same reads and calls, body change only; no root pass calls it; no root decision;rev3=census-ruling-account-subdomains;basis=sets AliasReport.AppsDomain from PLATFORM_APPS_DOMAIN (trimmed), the variable domainsTickConfig reads; same reads and calls otherwise; body change only whole:RegionalDomain@1778,whole:Route@1856,whole:Route@957,whole:Route@979,whole:Route@998 8a439cd701910b91d9bf8c39e96a56141c20c063f590dc26f557eb5337884ad6 |
| +@legacy a0a1447e90876551a7b8eeb96a4f230a8bf126676b9a4aebe0cd67c772728741 internal/domains/namespacealiases.go deriveNamespaceAliases legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: derives <prefix>.<name>.<apps> -> <prefix>.<sqid>.<apps> alias rows from the routes, alias rows and claim listing the pass already read (Provisioned or Platform, not sidecar or replica, of the name's account), writes them with UpsertAlias and SetAliasDNSStatus to the box's own registry, and HA names into the in-memory AliasIngress report; no file, path or bucket read registry:Account@1703,registry:Account@2933,registry:Alias@760,registry:App@1724,registry:App@1733,registry:App@1849,registry:DNSCheckedAt@1895,registry:DNSCheckedAt@2199,registry:DNSStatus@2165,registry:HA@2824,registry:Host@1238,registry:Host@1682,registry:Host@1692,registry:Host@1820,registry:Host@2806,registry:Host@2915,registry:Platform@1062,registry:Provisioned@1044,registry:Replica@1096,whole:Route@1028,whole:Route@1156,whole:Route@1637,whole:Route@2478,whole:Route@2560,whole:Route@2598,whole:Route@2780,whole:Route@2835,whole:Route@3173,whole:Route@3238,whole:Route@3312,whole:Route@3368,whole:Route@3392,whole:Route@919,whole:RouteAlias@1654,whole:RouteAlias@712,whole:RouteAlias@742,whole:RouteAlias@755,whole:RouteAlias@771 bb4ec44dd39e5c89503a2971791c79bef78f9d859e005e97c7f0ce5345af75a3 |
| +@legacy bfff2db67ed66e28eac929243b4893d7d29c6753020540e504a1eba8d66e2f3d internal/domains/namespacealiases.go isNamespaceDerived legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: pure predicate over one alias row and the held-name map; no read registry:Account@220,registry:Alias@133,registry:Host@241 c647beeb6870d420d9748a891d9889a264757b22f141f08925157e7ac0f2628d |
| +@legacy e8451b20617a4257e7f9a03a40a1dd1ba4319cfcb42a8baeda9dc3b657f708f6 internal/domains/namespacealiases.go keepNamespaceAliases legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: marks already-read alias rows of an unread namespace name as desired for this pass; no read, no write registry:Alias@372,registry:Alias@392,registry:Alias@421,registry:Alias@472,registry:Alias@762,whole:Route@465,whole:RouteAlias@285,whole:RouteAlias@321 57298aa31f68e53ee4637b28d912e0ec150f93d36f551044a6f8ae7c925c31ac |
| +@legacy 22d03c2950438f46f732ae4efdc14b1e3c1006267877e844a1f0c6202e9574c4 internal/domains/namespacealiases.go namespaceTwinStatus legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: returns a route's dns_status or "pointing"; no read beyond the row it is handed registry:DNSStatus@59,registry:DNSStatus@91 d1c6dcaf957f4d831e85e9659271de89e90e6f0f0a79a049032f1c910ca11b75 |
| +@legacy d3ef96a89c5bfefe22d04298c1b245cb6c52f764bab4f057d12f32479ee9990c internal/registry/registry.go Registry.ListAccountNamespaces legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: SELECT name, account FROM account_namespaces on the box's own registry database (or the remote child's), as carlos file:Query@311,registry:StringMap@199,registry:StringMap@225,registry:StringMap@274,registry:remote@108,registry:remote@76,registry:sql@311,whole:remoteClient@110,whole:remoteClient@78 53daf0d3d3181b71297bbaa2bb6f15cc3ae37a97bc7016cea2946a6cb193c33a |
| +@legacy efbd87025cac8bbe390ed1fb3fd107a981ecc5e5ab95b32ed79e84d0d78cd4f3 internal/registry/registry.go Registry.SetAccountNamespaces legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: replaces account_namespaces in one transaction (DELETE then INSERTs) on the box's own registry database (or through the remote child); refuses an empty name or account before writing file:Exec@459,file:Exec@578,registry:remote@237,registry:remote@267,registry:sql@377,whole:remoteClient@239,whole:remoteClient@269 f9d6350014a1e7cd0f3776bb6a9355df0fefbf228c385198c878bf76ecc64a5d |
| +@legacy 85b866393537ad5f3e0b3fde656fa84111f09553b091a010983c3cc138f13fcf internal/domains/aliases.go ReconcileAliasesReport legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in its alias pass (aliasPassReporting in runAgent; ReconcileAliases, now a wrapper, is its other caller): main's ReconcileAliases body, moved here with the same reads and writes, plus a completeness report (AliasReport) set false at every point that already logged a failure and carried on, and when relevantDropped names a listed claim the pass could not rule out; the box's asset authority clock advances only after a complete pass; one more whole:Route and whole:RouteAlias site each, the routes and alias rows the pass already read handed to relevantDropped; no registry, file or bucket read added; no root pass calls it; no root decision;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: in the alias pass inside the agent: reads the existing regional_domains rows (reg.ListRegional) beside the alias rows, derives a regional claim's rows through deriveRegional for AliasReport.Region (the caller's ReconcileConfig.Region, set by aliasPassReporting) and its wildcard parent when bound, skipping the alias, paths and catch-all halves for it, writes them through writeRegional, and keeps an unread regional claim's wildcard parent while the kept apex row still binds a target RegionalTarget accepts on the routes this pass read (same account and app, per-box cap); claims are read as before (the listing and per-claim GETs it already does); the added reads are the registry's regional rows and fields of rows the pass already holds;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 fix rounds 2-3: AliasReport.FleetRefused (edge.FleetArmVerdict's refused set) is called once on the pass's own listing; a Wildcard claim whose primary is fleet-refused derives no wildcard_domains row (an earlier one goes with the ordinary removal); the catch-all alias is derived as before (+registry:Host, +whole:Route). Rows already read; writes less, never more; no root pass calls it.;rev3=census-ruling-region-ha-g2-fixes;basis=Project accepted regional exact/catchall names and plain/delegated aliases into routing-only reports using existing claims and pre-pool metadata; new whole Route/RegionalDomain uses, no new external reader.;rev3=census-ruling-fix-incomplete-domains-pass;basis=adds AliasReport.StartupNoRemoval, an input set only by the agent startup HA ingress pass (host startupAliasPass via runHAIngressStartup): when set, the pass skips the route_aliases, wildcard_domains and route_paths removals (each skipped removal marks the pass incomplete) and the removal rules themselves are unchanged; derivations, refusals and writes are unchanged; same read sites (body change only); no new registry, file or bucket read; deletes less, never more, and only on the startup pass; no root pass calls it; no root decision;rev3=census-ruling-account-subdomains;basis=with AliasReport.AppsDomain set, reads the box's own account_namespaces table (reg.ListAccountNamespaces), sorts a listed-but-unread namespace claim (ParseNamespaceHost on the dropped host): a not-found body keeps nothing and is not counted by relevantDropped, any other failure keeps that name's recorded rows; runs deriveNamespaceAliases after deriveInstanceAliases on the routes, alias rows and claims it already read (AccountNamespaces over the read claims), keepNamespaceAliases for unread names, and writes the table through writeAccountNamespaces (once, only when it differs; no shrink under StartupNoRemoval); the added sites are the routes and alias rows already read handed to those helpers; no file or bucket read added registry:Account@21164,registry:Account@21179,registry:Account@21297,registry:Account@21649,registry:Account@21662,registry:Alias@19158,registry:Alias@19291,registry:Alias@19361,registry:App@15181,registry:App@15381,registry:App@15537,registry:App@15738,registry:App@21192,registry:App@21203,registry:App@21310,registry:App@21675,registry:App@21684,registry:App@5232,registry:App@5428,registry:App@9052,registry:App@9251,registry:Host@16104,registry:Host@20974,registry:Host@21049,registry:Host@21072,registry:Host@21124,registry:Host@21458,registry:Host@21530,registry:Host@21634,registry:Host@21945,registry:Host@22091,registry:Host@22163,registry:Host@22697,registry:Host@22810,registry:Host@22962,registry:Host@23043,registry:Host@834,registry:Prefix@22705,registry:Prefix@22824,registry:Prefix@22970,registry:Prefix@23051,registry:Region@21319,registry:Status@11915,registry:Target@21144,registry:Target@21249,whole:RegionalDomain@19938,whole:RegionalDomain@19956,whole:RegionalDomain@20902,whole:RegionalDomain@20940,whole:RegionalDomain@20961,whole:RegionalDomain@20984,whole:RegionalDomain@21111,whole:RegionalDomain@276,whole:RegionalDomain@3683,whole:RegionalDomain@3884,whole:Route@1045,whole:Route@11245,whole:Route@11697,whole:Route@11859,whole:Route@15150,whole:Route@15225,whole:Route@15372,whole:Route@15434,whole:Route@15577,whole:Route@15733,whole:Route@16986,whole:Route@18111,whole:Route@18119,whole:Route@18665,whole:Route@18673,whole:Route@18972,whole:Route@21242,whole:Route@21293,whole:Route@2251,whole:Route@337,whole:Route@3865,whole:Route@4284,whole:Route@4575,whole:Route@5272,whole:Route@5423,whole:Route@5479,whole:Route@787,whole:Route@816,whole:Route@827,whole:Route@8398,whole:Route@845,whole:Route@9096,whole:Route@9242,whole:RouteAlias@18127,whole:RouteAlias@18681,whole:RouteAlias@18954,whole:RouteAlias@19133,whole:RouteAlias@2259,whole:RoutePath@13442,whole:RoutePath@22590,whole:RoutePath@22632,whole:RoutePath@22767,whole:RoutePath@22797,whole:WildcardDomain@16300,whole:WildcardDomain@21008,whole:WildcardDomain@21037,whole:WildcardDomain@21518,whole:WildcardDomain@21540,whole:WildcardDomain@21564,whole:WildcardDomain@21613,whole:WildcardDomain@21776,whole:WildcardDomain@21904,whole:WildcardDomain@21933,whole:WildcardDomain@4098 fad4463c6717c5a068087aa8d5d67a97dcedfa699b553b754f39298911d9db06 |
| +@legacy 9a95aa6d853b34a08ae96a3e9c479277a949001776d26d47114f4658f3fba0e7 internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts, which first hands the pass's hostnames to Config.FreshRetain (the resolver forgets its in-memory backoff and strike for names no longer carried) and then decides each hostname once per pass and applies the verdict to every row carrying it: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address, A or AAAA, "pointing", other "elsewhere", authoritative not-found "", authoritative NODATA for A and AAAA with the zone's SOA "" with no cached query), falling back to the cached lookup past the budget or on the second fresh failure in a row; the first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again); a previously "pointing" name keeps cached-first plus the upgrade-only fresh look (ResolveUpgrade, nearest zones first), so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; new names are ordered never-checked first then oldest check, and lookups answered from the backoff do not count against the budget; StampHealth's own body is unchanged by the last round; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724);rev3=census-ruling-account-subdomains;basis=reads the box's own account_namespaces table (only when DNS stamping runs) and leaves out of the DNS loop the alias rows isNamespaceDerived names (an alias under a held name, of that name's account, pointing at its sqid twin); the added RouteAlias sites are that filter over rows already listed; stamps less, never more; TLS stamping unchanged registry:Alias@3986,registry:Alias@4575,registry:Alias@4665,registry:Alias@5099,registry:Alias@5163,registry:Alias@5251,registry:DNSCheckedAt@3861,registry:DNSCheckedAt@4008,registry:DNSStatus@3847,registry:DNSStatus@3995,registry:DNSStatus@4200,registry:DNSStatus@4499,registry:Host@3838,registry:Host@4272,registry:Host@4356,registry:Host@4868,registry:Host@4927,registry:Host@5009,whole:Route@199,whole:Route@236,whole:Route@3662,whole:Route@3778,whole:Route@4107,whole:Route@4822,whole:RouteAlias@1404,whole:RouteAlias@1570,whole:RouteAlias@1606,whole:RouteAlias@1637,whole:RouteAlias@1657,whole:RouteAlias@1669,whole:RouteAlias@3708,whole:RouteAlias@3922,whole:RouteAlias@4402,whole:RouteAlias@5052,whole:RouteAlias@780 c7378e603993650aa12ef694d3ebbee430797e12ae2e2ce7a3b8e8f031d508c0 |
| +@legacy d5b19e5fea9c3ef9f7b7c68012a8529fcab3fe0a670e1e4a64d90366ab25bf10 internal/registry/registry.go Registry.Fingerprint legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user); the remote arm, unchanged, in the process that holds a remote handle: census-ruling-seeded-instances's body with the row's lifetime pair (incarnation, serving_seq) folded into the edge's change poll, each only when non-zero, so a registry with no pair digests as before; self-serve moves 1 Task 7;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: hashes regional_domains (host, target, account, app, region; created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no regional rows digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; no file path read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R1 finding 1: the routes SELECT also reads host, kind, account, app, platform and fingerprintForwardInert (one CASE over the ForwardForbidden columns), and every row folds host, kind, account and app (tagged, quoted), platform when set, and forward_inert=0 for a forward row that is not inert, so a rowid reused by another hostname, an in-place account or app rewrite, or a stray forbidden column moves the edge's change poll. Same one SELECT per table on the same fresh connection to the box's own registry database, as carlos; no table, file or bucket read added; a digest, never a decision.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the SELECT also reads fleet_label and, only when it is set, hashes "fleet_label=<q>" into the digest, so labelling a row moves the edge's reload fingerprint. Read sites unchanged (33). Registry side, not root; an unlabelled registry's digest is byte-identical.;rev3=census-ruling-stateless-replicas-1;basis=Read the additive stateless projection in the existing registry SELECT and hash only when set; no new read source.;rev3=census-ruling-agent-start-demo-1;basis=Existing SELECT reads four more demo columns; only a marked row adds them to the hash, so ordinary hashes remain unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Four additive projection columns join the existing routes SELECT and hash only when nonzero; no new query or file read. merge of origin/main 6be08467: Union main demo identity and expiry with replica columns in the same SELECT and hash; merge-only body change.;rev3=census-ruling-agent-start-demo-3;basis=Hash moved-notice wire bytes so notice-only changes invalidate an edge route snapshot. Census read-site delta: +file:QueryRow.;rev3=census-ruling-edge-page-cache-1;basis=selects the new pages_off column with the rest and folds "pages_off=1" into the hash only when set, as assets_off, so a registry that never sets it fingerprints as before; same routes SELECT, no new table; read sites unchanged (34); no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: hashes link_channels (link_id, account, token_hash, status, generation; connected, seen_at, seq and created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no links digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; a digest, never a decision; linked deployments slice 1 Task 7: also folds home_link (id, serving_url, tunnel_url, the token's sha256 never the token, account, apps_domain, box_label, conn_gen; state and created_at not) and home_link_apps (name, home_account, home_app, home_host) through fingerprintHomeLink over the same fresh connection, each section marker written only when a row exists, so a registry with no link digests as before; no file path read; a digest, never a decision;rev3=census-ruling-account-subdomains;basis=hashes account_namespaces (name, account) over the same fresh connection, with a section marker written only when a row exists, so a registry with no held names digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; a digest, never a decision file:Exec@284,file:Open@188,file:Query@10785,file:Query@11707,file:Query@12810,file:Query@368,file:Query@6655,file:Query@7134,file:Query@8120,file:Query@8816,file:Query@9728,file:QueryRow@13727,registry:ClaimIncarnation@1729,registry:ClaimIncarnation@5563,registry:ClaimIncarnation@5640,registry:ClaimOwner@1773,registry:ClaimOwner@5764,registry:ClaimOwner@5829,registry:ClaimRowID@1792,registry:ClaimRowID@5856,registry:ClaimRowID@5922,registry:ClaimStamp@1754,registry:ClaimStamp@5673,registry:ClaimStamp@5737,registry:Incarnation@1848,registry:Incarnation@6143,registry:Incarnation@6207,registry:ServingSeq@1867,registry:ServingSeq@6234,registry:ServingSeq@6297,registry:Text@158,registry:path@207,registry:remote@55,registry:remote@87,whole:remoteClient@57,whole:remoteClient@89 a52e0bc25d555bbf22f35655c54c0fa3aca6cedec5f0b6b80157d9d95f921a29 |
| +@legacy 5d46724aa4ebbec5cc075b3d28c1efd3fdd89e73abcb73ceaabc6bc2c68c36e5 internal/registry/registry.go Registry.migrate legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user), on every registry open; a box CLI verb that opens the registry directly runs it as whoever runs the verb: census-ruling-seeded-instances's body with two more columns added to routes (incarnation and serving_seq, INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule); self-serve moves 1 Task 7;rev3=census-ruling-rootfs-apps-2;basis=one more ALTER TABLE, routes ADD COLUMN runtime TEXT NOT NULL DEFAULT '', beside main's rate_limit, assets_off, asset_gen, incarnation and serving_seq (the last four from the merges of origin/main 3c33f2eb and 953b9fda); the same sixteen sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 4: three more ALTER TABLE statements in the existing loop, routes ADD COLUMN egress_allow, size and policy_expires_at, each TEXT NOT NULL DEFAULT '' and idempotent through the duplicate-column rule; the same sixteen sites, no read added.;rev3=census-ruling-region-ha-p1a;basis=one more ALTER TABLE in the existing loop: routes ADD COLUMN ha INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule; the same sixteen sites, no read added;rev3=census-ruling-ha-p1a-433;basis=the registry's SQLite side as carlos (agent, registry child; a box CLI verb that opens the registry directly runs it as whoever runs it), on every registry open: the ALTER TABLE routes statements are now built from the one migration definition routeAddedColumns (addedColumn name, type, default; review r1 P2): for each entry without the Claim mark, "ALTER TABLE routes ADD COLUMN " + spec(), byte for byte the statements main runs, in main's order, under the same duplicate-column rule. +registry:Claim is that mark, +whole:addedColumn the struct. Every name, type and default is an in-binary literal; no statement added, removed or changed; no read added.;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: one more CREATE TABLE IF NOT EXISTS regional_domains (host TEXT PRIMARY KEY, target, account, app, region TEXT NOT NULL DEFAULT '', created_at INTEGER NOT NULL DEFAULT 0), beside wildcard_domains; the added sites are that statement (+file:Exec, +registry:sql), an in-binary literal; additive, no existing statement changed;rev3=census-ruling-region-ha-p1b3b-t;basis=Create local HA duty/replay tables and revision triggers in the existing registry connection; no new database path.;rev3=census-ruling-agent-start-demo-3;basis=Create moved-notice storage as a single (id, wire) row; fingerprints include the stored wire bytes. Census read-site delta: +file:Exec, +registry:sql.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: calls migrateLinks after migrateHADuties (one CREATE TABLE IF NOT EXISTS link_channels, an in-binary literal); additive, no existing statement changed; linked deployments slice 1 Task 7: also runs migrateHomeLink (CREATE TABLE IF NOT EXISTS home_link and home_link_apps) after migrateLinks; additive, the box's own registry database, as carlos;rev3=census-ruling-account-subdomains;basis=one more CREATE TABLE IF NOT EXISTS account_namespaces (name TEXT PRIMARY KEY, account TEXT NOT NULL), an in-binary literal (+file:Exec, +registry:sql); additive, no existing statement changed file:Exec@1124,file:Exec@1855,file:Exec@212,file:Exec@2409,file:Exec@3057,file:Exec@3822,file:Exec@4101,file:Exec@4964,file:Exec@51,file:Exec@5140,file:Exec@761,registry:Claim@686,registry:sql@1124,registry:sql@1855,registry:sql@212,registry:sql@2409,registry:sql@3057,registry:sql@3822,registry:sql@4101,registry:sql@4964,registry:sql@51,registry:sql@5140,registry:sql@761,whole:addedColumn@661 0c5fdaf1215e8f81c156a1fc1576cb075c2a52238bde75fc8320d49472fd117d |
| +internal/domains/aliases.go deriveInstanceAliases legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): rev3=J1's body; a stale body under a retired lifetime no longer makes a label shared, and a label with a record that cannot be judged keeps its existing alias row of the catch-all's own account and app (reading that row's Account and App) only once the derived name has passed every precedence check a derived name answers to (validity, an exact claim, a local real route, a deployment route, the per-box cap), and derives no new one; a report-only conservative keep, never a new route;rev3=census-ruling-regional-domains-447;basis=#447 Task 2: an instance catch-all whose parent claim is regional is inert (logged once, continue), as one whose parent is not held is; it only narrows what derives; no read added;rev3=census-ruling-account-subdomains;basis=takes a *int budget shared with the namespace pass instead of a local counter; the same checks and cap (maxInstanceAliases, now a var so a test can lower it); same reads; body change only registry:Account@2487,registry:Account@3805,registry:Account@4604,registry:Alias@2549,registry:Alias@2617,registry:Alias@2661,registry:Alias@574,registry:App@1987,registry:App@2513,registry:App@3831,registry:App@4630,registry:Host@2144,registry:Host@4583,registry:Host@4593,registry:Host@4789,registry:Provisioned@1937,registry:Replica@1973,registry:Slug@2076,whole:Route@1921,whole:Route@2027,whole:Route@3347,whole:RouteAlias@2467,whole:RouteAlias@3787,whole:RouteAlias@4565,whole:RouteAlias@526,whole:RouteAlias@556,whole:RouteAlias@569,whole:RouteAlias@585 e0e3f4f651bc7fde2c37c0259d993ca02b36bac67adee10140227eaa30c41ab3 |
| +internal/host/agent.go aliasPassReportingComplete legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-g2-fixes;basis=Extract the existing serialized alias pass, add cancellable locking and routing-only alias/regional publication from its completeness report; existing deployment/claim/registry reads retained, new in-memory Route/RegionalDomain passes.;rev3=census-ruling-fix-incomplete-domains-pass;basis=gains a startup bool parameter that it copies into domains.AliasReport.StartupNoRemoval; runHAIngressStartup passes true, aliasPassReporting (the ordinary agent pass) passes false; same reads and calls, body change only; no root pass calls it; no root decision;rev3=census-ruling-account-subdomains;basis=sets AliasReport.AppsDomain from PLATFORM_APPS_DOMAIN (trimmed), the variable domainsTickConfig reads; same reads and calls otherwise; body change only whole:RegionalDomain@1778,whole:Route@1856,whole:Route@957,whole:Route@979,whole:Route@998 8a439cd701910b91d9bf8c39e96a56141c20c063f590dc26f557eb5337884ad6 |
| +internal/domains/namespacealiases.go deriveNamespaceAliases legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: derives <prefix>.<name>.<apps> -> <prefix>.<sqid>.<apps> alias rows from the routes, alias rows and claim listing the pass already read (Provisioned or Platform, not sidecar or replica, of the name's account), writes them with UpsertAlias and SetAliasDNSStatus to the box's own registry, and HA names into the in-memory AliasIngress report; no file, path or bucket read registry:Account@1703,registry:Account@2933,registry:Alias@760,registry:App@1724,registry:App@1733,registry:App@1849,registry:DNSCheckedAt@1895,registry:DNSCheckedAt@2199,registry:DNSStatus@2165,registry:HA@2824,registry:Host@1238,registry:Host@1682,registry:Host@1692,registry:Host@1820,registry:Host@2806,registry:Host@2915,registry:Platform@1062,registry:Provisioned@1044,registry:Replica@1096,whole:Route@1028,whole:Route@1156,whole:Route@1637,whole:Route@2478,whole:Route@2560,whole:Route@2598,whole:Route@2780,whole:Route@2835,whole:Route@3173,whole:Route@3238,whole:Route@3312,whole:Route@3368,whole:Route@3392,whole:Route@919,whole:RouteAlias@1654,whole:RouteAlias@712,whole:RouteAlias@742,whole:RouteAlias@755,whole:RouteAlias@771 bb4ec44dd39e5c89503a2971791c79bef78f9d859e005e97c7f0ce5345af75a3 |
| +internal/domains/namespacealiases.go isNamespaceDerived legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: pure predicate over one alias row and the held-name map; no read registry:Account@220,registry:Alias@133,registry:Host@241 c647beeb6870d420d9748a891d9889a264757b22f141f08925157e7ac0f2628d |
| +internal/domains/namespacealiases.go keepNamespaceAliases legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: marks already-read alias rows of an unread namespace name as desired for this pass; no read, no write registry:Alias@372,registry:Alias@392,registry:Alias@421,registry:Alias@472,registry:Alias@762,whole:Route@465,whole:RouteAlias@285,whole:RouteAlias@321 57298aa31f68e53ee4637b28d912e0ec150f93d36f551044a6f8ae7c925c31ac |
| +internal/domains/namespacealiases.go namespaceTwinStatus legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: returns a route's dns_status or "pointing"; no read beyond the row it is handed registry:DNSStatus@59,registry:DNSStatus@91 d1c6dcaf957f4d831e85e9659271de89e90e6f0f0a79a049032f1c910ca11b75 |
| +internal/registry/registry.go Registry.ListAccountNamespaces legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: SELECT name, account FROM account_namespaces on the box's own registry database (or the remote child's), as carlos file:Query@311,registry:StringMap@199,registry:StringMap@225,registry:StringMap@274,registry:remote@108,registry:remote@76,registry:sql@311,whole:remoteClient@110,whole:remoteClient@78 53daf0d3d3181b71297bbaa2bb6f15cc3ae37a97bc7016cea2946a6cb193c33a |
| +internal/registry/registry.go Registry.SetAccountNamespaces legacy accepted-legacy accepted-legacy;rev3=census-ruling-account-subdomains;basis=new: replaces account_namespaces in one transaction (DELETE then INSERTs) on the box's own registry database (or through the remote child); refuses an empty name or account before writing file:Exec@459,file:Exec@578,registry:remote@237,registry:remote@267,registry:sql@377,whole:remoteClient@239,whole:remoteClient@269 f9d6350014a1e7cd0f3776bb6a9355df0fefbf228c385198c878bf76ecc64a5d |
| +internal/registry/remote_dispatch.go Registry.dispatchRemote hint E2 rev3=census-ruling-self-serve-moves-1;basis=the registry child (carlos __registry-child, the service user a root pass forks): plan14-root-reads-e's mixed declaration (E2 adds only the ArtifactHosts read; every other arm is the local method of the same name), with three more write arms, SetHoldIfSeq, ReleaseHoldSeq and InstallLifetimeIf, each calling the local setter; no read operation added; self-serve moves 1 Task 7;rev3=census-ruling-instance-egress-sizes-328-329;identity=the registry child (carlos __registry-child, the service user a root pass forks);basis=#328/#329 plan 1 Task 4: one more write arm, SetPolicy, calling the local Registry.SetPolicy with the request's Host, EgressAllow, Size and PolicyExpiresAt (remoteRequest fields sent by the remote handle's holder); the new kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, plus one more registry:Host site, all of the request; no read operation added; the read-only worker never reaches it (serveRemote's method gate); no production root pass sends SetPolicy;rev3=census-ruling-region-ha-p1a;basis=the registry child (carlos __registry-child, the service user a root pass forks): one more write arm, SetHA, calling the local Registry.SetHA with the request's Host (+registry:Host); no read operation added; only the provision pass sends it;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 8: two new remote methods, UpsertUnlessRootfs (carlos add's guarded write) and ResidentInstances (the residency sweep's list), each calling the same-named Registry method;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: two more methods on the existing remote registry transport, ListRegional and ReplaceRegionalSet (request field RDs, response field Regional), each calling the local method of the same name, which validates its own input; no new kind of read;rev3=census-ruling-fleet-secrets-key;basis=one new case, SetFleetSecretsKey, reading the request's Name, Pub, KeyFP, By and At fields and calling SetFleetSecretsKey;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 1-2: three new cases (SetFleetBoxIf reads the request's Fleet and answers Changed; PutForward reads TValue, a whole Route; DeleteForward reads Host and answers Changed); SetFleetBox gone (+registry:Changed x2, +registry:Fleet, +registry:Host, +registry:TValue, +whole:Route). Each case calls the local writer with its own guards.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Tasks 2 and 6b): three more remote methods dispatched to their local forms, SetFleetBoxDraining (q.Fleet, q.Label, q.At, answering Number64), MarkFleetBoxLabelled (q.Fleet, q.Label, q.At) and SetFleetAssignment (q.Host, q.Assigned, q.Moved); remoteRequest gains Assigned and Moved. The registry child, not root.;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Add SetServingMode dispatch using the existing remote request Host, Ver and On fields; the same local narrow writer handles it. No new transport or root path. Task 4 R24: dispatch SeedStateless with the existing Observed Route and On carriers to its symmetric guarded local method. No new transport; the existing read-only service gate still refuses writes.;rev3=census-ruling-region-ha-p1b3b-t;basis=Dispatch typed duty, import, exact replacement and guarded receipt operations through the existing service-user registry transport, preserving comparisons and errors. B2 fix r1: dispatch AdvanceHADuty through the existing service-user registry channel and error mapping, reading the request Host only. Read-only method allowlist remains unchanged. B3b: transport bounded typed local journal requests and results over the existing authenticated registry channel; no arbitrary SQL or disk path.;rev3=census-ruling-managed-fleets-2a;basis=Expose the two owned managed preparation methods with Fleet envelope fields, preserving conditional result. Witness TestManagedRegistryPreparationMethods local/remote parity. Dispatch ClearFleetBoxDraining with fleet, label and timestamp to validated local method; no new transport or root path. Witness TestManagedConditionalDrainClear. Dispatch managed insert with FleetBox and At, and return Changed for conditional drain clear. Existing transport and local validation; no new root path. Witness TestAddManagedFleetBox local/remote parity.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: adds ClearReplicaAssignment over the existing typed registry RPC; local writer checks the complete observed row. Existing read-only RPC gate unchanged. merge of origin/main 9b8b2c50: retain all HA journal/duty/wake/adoption RPCs alongside replica assignment RPCs; union of request/response fields and error sentinels, unchanged transport and read-only gate. Merge 0b3098cb also retains main's two managed fleet RPCs; the replica RPCs and shared refusal gate remain intact.;rev3=census-ruling-managed-fleets-2b1;basis=managed fleets 2b-1 Task 1: the registry child (carlos __registry-child, the service user a root pass forks) answers GetFleet and ListFleetBoxes with GetFleetContext(ctx, q.Name) and ListFleetBoxesContext(ctx, q.Fleet), passing its existing request context so a cancelled caller ends the child's SQL read; same request fields (Name, Fleet) and same local queries; no method, field or read operation added; read-only method gate unchanged;rev3=census-ruling-edge-page-cache-1;basis=adds the SetPages method: r.SetPages(q.Host, q.PagesOff), the request's PagesOff field (the +registry:Host and +registry:PagesOff sites); the same dispatch as SetAssets. Merged onto main's body at 04dc1dc0 (managed fleets 2b-1: GetFleet and ListFleetBoxes now go through their Context forms with the dispatch ctx), which this branch does not change;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: nine more cases (PutLinkChannel, RevokeLinkChannel, LinkChannelAuth, LinkOwners, SetLinkSeen, ResetLinkSeen, LinkSeen, LinkForwards, DeleteLinkForward), each calling the local method with request fields; no other case changed; linked deployments slice 1 Task 7: ten cases for the home link methods (HomeLink, PutHomeLink, DeleteHomeLink, ClaimHomeLink, SetHomeLinkState, HomeLinkConnGen, HomeLinkApps, HomeLinkAppByName, PutHomeLinkApp, DeleteHomeLinkApp), each passing the request's HomeLink, HomeLinkApp, Label, Status or Name to the registry method of that name; the same transport, no read added; linked deployments slice 1 Task 7 fix round 1: one more case, SetHomeLinkUnlinkPending, passing the request's LinkID and On to the registry method of that name; no read added; linked deployments final review fix: HomeLinkConnGen's case removed (-registry:Number64); HomeLinkAppByName passes the request's LinkID as well as Name; one more case, SetHomeLinkRotatePending, passing the request's LinkID and On to the registry method of that name; no read added; rotation fix (Astra final re-review, C): SetHomeLinkRotatePending's case removed; two cases added, RotateHomeLinkKey (passing the request's HomeLink ID, Token and RotatePending) and ClearHomeLinkRotatePending (passing LinkID and Seq, answering Changed), each to the registry method of that name, which validates its own input; no read added;rev3=census-ruling-account-subdomains;basis=two more cases: ListAccountNamespaces (answers in StringMap) and SetAccountNamespaces (request field Names), each calling the registry method of the same name on the child's own database; no other case changed registry:A@10963,registry:Account@2988,registry:Account@3087,registry:Account@7179,registry:Accounts@5841,registry:Addr@7756,registry:Addrs@7764,registry:Adoption@1013,registry:Adoption@818,registry:Alias@11011,registry:Alias@11075,registry:Alias@11163,registry:Aliases@10885,registry:Alive@12988,registry:Args@10587,registry:AssetGen@7963,registry:AssetsOff@7950,registry:Assigned@8441,registry:Assignment@9857,registry:Assignment@9955,registry:At@11094,registry:At@11172,registry:At@12736,registry:At@3322,registry:At@3390,registry:At@3782,registry:At@3879,registry:At@3964,registry:At@9335,registry:Attempts@12758,registry:B@3385,registry:B@3439,registry:Backing@7575,registry:Bucket@3100,registry:BuildState@8200,registry:By@3316,registry:Changed@12668,registry:Changed@2860,registry:Changed@2933,registry:Changed@3034,registry:Changed@322,registry:Changed@3721,registry:Changed@4152,registry:Changed@4225,registry:Changed@464,registry:Changed@4674,registry:Changed@4915,registry:Changed@5259,registry:Changed@5572,registry:Changed@564,registry:Changed@6264,registry:Changed@6351,registry:Changed@6440,registry:Changed@6511,registry:Changed@6615,registry:Changed@6702,registry:Changed@6795,registry:Changed@6877,registry:Changed@832,registry:Changed@8788,registry:Changed@8925,registry:Changed@929,registry:Changed@9522,registry:Changed@9710,registry:Channel@7239,registry:Channel@8631,registry:Channel@9180,registry:CheckedAt@9261,registry:Class@7694,registry:DoneBefore@12997,registry:Due@10288,registry:Due@10352,registry:Due@12780,registry:Duty@312,registry:Duty@390,registry:Duty@634,registry:EgressAllow@8103,registry:Env@8699,registry:Env@9091,registry:Env@9191,registry:ExcludeHosts@12463,registry:ExcludeHosts@12558,registry:ExpectGood@9460,registry:ExpectOp@6319,registry:ExpectOp@6569,registry:ExpectPair@6749,registry:Expected@1001,registry:Expected@1153,registry:Expected@1626,registry:Expected@1803,registry:Expected@2114,registry:F@2832,registry:F@2893,registry:F@2978,registry:F@2988,registry:F@3077,registry:F@3087,registry:F@3100,registry:Fleet@3132,registry:Fleet@3497,registry:Fleet@3579,registry:Fleet@3660,registry:Fleet@3764,registry:Fleet@3861,registry:Fleet@3946,registry:Fleet@4047,registry:Fleet@8831,registry:FleetBoxes@3996,registry:Fleets@3202,registry:From@7350,registry:From@7411,registry:FromDB@7486,registry:FromOp@6407,registry:FromSock@7496,registry:HAJournal@183,registry:HAJournal@221,registry:Hash@8505,registry:Health@7773,registry:HomeLink@4751,registry:HomeLink@4827,registry:HomeLink@5162,registry:HomeLink@5177,registry:HomeLink@5195,registry:HomeLinkApp@5418,registry:HomeLinkApp@5528,registry:HomeLinkApps@5348,registry:Host@10089,registry:Host@10165,registry:Host@10225,registry:Host@10280,registry:Host@10344,registry:Host@10528,registry:Host@10579,registry:Host@10646,registry:Host@10721,registry:Host@10784,registry:Host@1136,registry:Host@11381,registry:Host@11507,registry:Host@11811,registry:Host@12099,registry:Host@12163,registry:Host@12222,registry:Host@12305,registry:Host@12388,registry:Host@12619,registry:Host@12704,registry:Host@12836,registry:Host@12917,registry:Host@13080,registry:Host@1888,registry:Host@1999,registry:Host@286,registry:Host@350,registry:Host@422,registry:Host@4713,registry:Host@501,registry:Host@602,registry:Host@6025,registry:Host@6066,registry:Host@6219,registry:Host@6295,registry:Host@6381,registry:Host@6473,registry:Host@6545,registry:Host@6651,registry:Host@6741,registry:Host@6829,registry:Host@6921,registry:Host@694,registry:Host@7171,registry:Host@7231,registry:Host@7289,registry:Host@7342,registry:Host@7403,registry:Host@7478,registry:Host@7567,registry:Host@7621,registry:Host@7686,registry:Host@772,registry:Host@7748,registry:Host@7826,registry:Host@7883,registry:Host@7942,registry:Host@8030,registry:Host@8095,registry:Host@8192,registry:Host@8257,registry:Host@8318,registry:Host@8368,registry:Host@8433,registry:Host@8497,registry:Host@8558,registry:Host@869,registry:Host@8691,registry:Host@8745,registry:Host@8823,registry:Host@8960,registry:Host@9013,registry:Host@9243,registry:Host@9327,registry:Host@9384,registry:Host@9452,registry:Host@9667,registry:Host@973,registry:Host@9932,registry:Hosts@1051,registry:Hosts@5904,registry:Hosts@8622,registry:Hosts@9082,registry:Hosts@9171,registry:ID@5162,registry:Id@2108,registry:Id@2419,registry:Id@2518,registry:Id@2598,registry:Id@2749,registry:IdValue@5660,registry:Idle@10654,registry:Import@734,registry:Journal@1306,registry:Journal@2126,registry:Journal@2425,registry:Journal@2604,registry:Keep@13096,registry:KeyFP@3307,registry:Kind@12925,registry:Kind@13088,registry:Label@3506,registry:Label@3588,registry:Label@3669,registry:Label@3773,registry:Label@3870,registry:Label@3955,registry:Label@4950,registry:Label@8840,registry:Lifetime@358,registry:Lifetime@430,registry:Lifetime@517,registry:Lifetime@610,registry:Lifetime@877,registry:Limit@12454,registry:Limit@12549,registry:Link@4188,registry:LinkID@4264,registry:LinkID@4443,registry:LinkID@4635,registry:LinkID@4721,registry:LinkID@5091,registry:LinkID@5307,registry:LinkID@5461,registry:LinkSeen@4545,registry:MaxRun@10662,registry:Method@151,registry:Moved@8453,registry:Ms@12752,registry:Name@12171,registry:Name@12230,registry:Name@12313,registry:Name@12627,registry:Name@12712,registry:Name@12844,registry:Name@1896,registry:Name@2007,registry:Name@2978,registry:Name@3077,registry:Name@3172,registry:Name@3292,registry:Name@5471,registry:Name@5611,registry:Name@5679,registry:Names@11663,registry:Next@1165,registry:NextAt@12770,registry:NextGood@9474,registry:NextValue@2678,registry:NextValue@2776,registry:Now@10855,registry:Now@12447,registry:Now@12542,registry:Now@12635,registry:Now@2031,registry:Number64@3819,registry:Number64@5767,registry:Number@12885,registry:Number@12956,registry:Number@13041,registry:Observed@10022,registry:Observed@1229,registry:Observed@9568,registry:Observed@9655,registry:Observed@9755,registry:Observed@9830,registry:ObservedValue@1507,registry:Old@2671,registry:Old@2769,registry:On@10034,registry:On@10104,registry:On@10233,registry:On@10729,registry:On@10792,registry:On@4460,registry:On@5101,registry:On@9969,registry:Op@6237,registry:Op@6313,registry:Op@6481,registry:Op@6563,registry:Op@6659,registry:Op@6837,registry:Op@6929,registry:Owner@1144,registry:Owner@1241,registry:Owner@1524,registry:P@11765,registry:PagesOff@7891,registry:Pair@509,registry:Pair@6581,registry:Pair@6665,registry:Pair@6763,registry:Pair@780,registry:Pair@981,registry:Path@11996,registry:Paths@11693,registry:PolicyExpiresAt@8126,registry:Prefix@11819,registry:Prev@9399,registry:Pub@3300,registry:RDs@11515,registry:RateLimit@8566,registry:Receipt@889,registry:Regional@11413,registry:Registration@12321,registry:Registration@12720,registry:Registration@1904,registry:Registration@2015,registry:Replica@8326,registry:ReplicaLife@9842,registry:ReplicaLife@9940,registry:Replicas@8265,registry:Retirement@2755,registry:Revision@529,registry:Revision@622,registry:Revision@989,registry:RotatePending@5195,registry:Route@6002,registry:Routes@10386,registry:Routes@10453,registry:Routes@10822,registry:Routes@4602,registry:Routes@5960,registry:Routes@6955,registry:Rows@12107,registry:Seed@10536,registry:SeenAt@4466,registry:Seq@4453,registry:Seq@5317,registry:Size@8118,registry:Sqid@5671,registry:Sqid@5734,registry:Sqid@5813,registry:Status@11084,registry:Status@12742,registry:Status@12852,registry:Status@1920,registry:Status@3678,registry:Status@5012,registry:Status@6227,registry:Status@6303,registry:Status@6389,registry:Status@6553,registry:Status@7297,registry:Status@9251,registry:Steering@7834,registry:StringMap@11555,registry:StringMap@4084,registry:StringMap@4301,registry:StringMap@4364,registry:T@12047,registry:T@1621,registry:T@1715,registry:T@1798,registry:TValue@6107,registry:TValue@6174,registry:TValue@8890,registry:TValue@9580,registry:Tags@3597,registry:Target@9021,registry:Targets@1317,registry:Text@11852,registry:Text@11915,registry:Text@2324,registry:Text@2471,registry:Text@5781,registry:Timer@12135,registry:Timer@1573,registry:Timer@1755,registry:Timers@12358,registry:Timers@12417,registry:Timers@12506,registry:Times@13130,registry:To@7358,registry:To@7419,registry:ToDB@7508,registry:ToOp@6399,registry:ToSock@7516,registry:Token@5177,registry:TokenHash@3515,registry:Tunnel@8753,registry:Unit@7629,registry:UpdateSettings@8038,registry:Ver@10097,registry:Ver@10173,registry:Ver@9392,registry:W@11315,registry:Wake@702,registry:Wake@788,registry:Wildcards@11209,whole:Account@5845,whole:ClaimOwnership@1146,whole:ClaimOwnership@1243,whole:ClaimOwnership@1526,whole:ClaimRow@1319,whole:ClaimRowArchive@1425,whole:ClaimRowArchive@1435,whole:ColdRows@2673,whole:ColdRows@2680,whole:ColdRows@2771,whole:ColdRows@2778,whole:DutyState@316,whole:DutyState@394,whole:DutyState@636,whole:Fleet@2834,whole:Fleet@2895,whole:Fleet@2980,whole:Fleet@2990,whole:Fleet@3079,whole:Fleet@3089,whole:Fleet@3102,whole:Fleet@3136,whole:Fleet@3206,whole:FleetBox@3387,whole:FleetBox@3441,whole:FleetBox@4000,whole:GoodBuild@9462,whole:GoodBuild@9476,whole:HAAdoption@1015,whole:HAAdoption@822,whole:HAWakeImport@704,whole:HAWakeImport@790,whole:HomeLink@4755,whole:HomeLink@4829,whole:HomeLink@5164,whole:HomeLink@5179,whole:HomeLink@5197,whole:HomeLinkApp@5352,whole:HomeLinkApp@5422,whole:HomeLinkApp@5530,whole:LinkChannel@4190,whole:LinkSeen@4549,whole:Pair@511,whole:Pair@6583,whole:Pair@6667,whole:Pair@6751,whole:Pair@6765,whole:Pair@782,whole:Pair@983,whole:RegionalDomain@11417,whole:RegionalDomain@11517,whole:Route@10024,whole:Route@10390,whole:Route@10457,whole:Route@10826,whole:Route@1231,whole:Route@4606,whole:Route@5964,whole:Route@6006,whole:Route@6109,whole:Route@6176,whole:Route@6959,whole:Route@7114,whole:Route@7120,whole:Route@8892,whole:Route@9570,whole:Route@9582,whole:Route@9657,whole:Route@9757,whole:Route@9832,whole:RouteAlias@10889,whole:RouteAlias@10965,whole:RoutePath@11697,whole:RoutePath@11767,whole:Timer@12049,whole:Timer@12109,whole:Timer@12139,whole:Timer@12362,whole:Timer@12421,whole:Timer@12510,whole:Timer@1509,whole:Timer@1577,whole:Timer@1623,whole:Timer@1717,whole:Timer@1759,whole:Timer@1800,whole:WildcardDomain@11213,whole:WildcardDomain@11317,whole:haJournalRequest@223,whole:haJournalResponse@187 1e4389350f87aa622a6e083cd51345fdaf34ab009bf744a9fb9f9ae010688366 |
| +internal/domains/aliases.go ReconcileAliasesReport legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in its alias pass (aliasPassReporting in runAgent; ReconcileAliases, now a wrapper, is its other caller): main's ReconcileAliases body, moved here with the same reads and writes, plus a completeness report (AliasReport) set false at every point that already logged a failure and carried on, and when relevantDropped names a listed claim the pass could not rule out; the box's asset authority clock advances only after a complete pass; one more whole:Route and whole:RouteAlias site each, the routes and alias rows the pass already read handed to relevantDropped; no registry, file or bucket read added; no root pass calls it; no root decision;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: in the alias pass inside the agent: reads the existing regional_domains rows (reg.ListRegional) beside the alias rows, derives a regional claim's rows through deriveRegional for AliasReport.Region (the caller's ReconcileConfig.Region, set by aliasPassReporting) and its wildcard parent when bound, skipping the alias, paths and catch-all halves for it, writes them through writeRegional, and keeps an unread regional claim's wildcard parent while the kept apex row still binds a target RegionalTarget accepts on the routes this pass read (same account and app, per-box cap); claims are read as before (the listing and per-claim GETs it already does); the added reads are the registry's regional rows and fields of rows the pass already holds;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 fix rounds 2-3: AliasReport.FleetRefused (edge.FleetArmVerdict's refused set) is called once on the pass's own listing; a Wildcard claim whose primary is fleet-refused derives no wildcard_domains row (an earlier one goes with the ordinary removal); the catch-all alias is derived as before (+registry:Host, +whole:Route). Rows already read; writes less, never more; no root pass calls it.;rev3=census-ruling-region-ha-g2-fixes;basis=Project accepted regional exact/catchall names and plain/delegated aliases into routing-only reports using existing claims and pre-pool metadata; new whole Route/RegionalDomain uses, no new external reader.;rev3=census-ruling-fix-incomplete-domains-pass;basis=adds AliasReport.StartupNoRemoval, an input set only by the agent startup HA ingress pass (host startupAliasPass via runHAIngressStartup): when set, the pass skips the route_aliases, wildcard_domains and route_paths removals (each skipped removal marks the pass incomplete) and the removal rules themselves are unchanged; derivations, refusals and writes are unchanged; same read sites (body change only); no new registry, file or bucket read; deletes less, never more, and only on the startup pass; no root pass calls it; no root decision;rev3=census-ruling-account-subdomains;basis=with AliasReport.AppsDomain set, reads the box's own account_namespaces table (reg.ListAccountNamespaces), sorts a listed-but-unread namespace claim (ParseNamespaceHost on the dropped host): a not-found body keeps nothing and is not counted by relevantDropped, any other failure keeps that name's recorded rows; runs deriveNamespaceAliases after deriveInstanceAliases on the routes, alias rows and claims it already read (AccountNamespaces over the read claims), keepNamespaceAliases for unread names, and writes the table through writeAccountNamespaces (once, only when it differs; no shrink under StartupNoRemoval); the added sites are the routes and alias rows already read handed to those helpers; no file or bucket read added registry:Account@21164,registry:Account@21179,registry:Account@21297,registry:Account@21649,registry:Account@21662,registry:Alias@19158,registry:Alias@19291,registry:Alias@19361,registry:App@15181,registry:App@15381,registry:App@15537,registry:App@15738,registry:App@21192,registry:App@21203,registry:App@21310,registry:App@21675,registry:App@21684,registry:App@5232,registry:App@5428,registry:App@9052,registry:App@9251,registry:Host@16104,registry:Host@20974,registry:Host@21049,registry:Host@21072,registry:Host@21124,registry:Host@21458,registry:Host@21530,registry:Host@21634,registry:Host@21945,registry:Host@22091,registry:Host@22163,registry:Host@22697,registry:Host@22810,registry:Host@22962,registry:Host@23043,registry:Host@834,registry:Prefix@22705,registry:Prefix@22824,registry:Prefix@22970,registry:Prefix@23051,registry:Region@21319,registry:Status@11915,registry:Target@21144,registry:Target@21249,whole:RegionalDomain@19938,whole:RegionalDomain@19956,whole:RegionalDomain@20902,whole:RegionalDomain@20940,whole:RegionalDomain@20961,whole:RegionalDomain@20984,whole:RegionalDomain@21111,whole:RegionalDomain@276,whole:RegionalDomain@3683,whole:RegionalDomain@3884,whole:Route@1045,whole:Route@11245,whole:Route@11697,whole:Route@11859,whole:Route@15150,whole:Route@15225,whole:Route@15372,whole:Route@15434,whole:Route@15577,whole:Route@15733,whole:Route@16986,whole:Route@18111,whole:Route@18119,whole:Route@18665,whole:Route@18673,whole:Route@18972,whole:Route@21242,whole:Route@21293,whole:Route@2251,whole:Route@337,whole:Route@3865,whole:Route@4284,whole:Route@4575,whole:Route@5272,whole:Route@5423,whole:Route@5479,whole:Route@787,whole:Route@816,whole:Route@827,whole:Route@8398,whole:Route@845,whole:Route@9096,whole:Route@9242,whole:RouteAlias@18127,whole:RouteAlias@18681,whole:RouteAlias@18954,whole:RouteAlias@19133,whole:RouteAlias@2259,whole:RoutePath@13442,whole:RoutePath@22590,whole:RoutePath@22632,whole:RoutePath@22767,whole:RoutePath@22797,whole:WildcardDomain@16300,whole:WildcardDomain@21008,whole:WildcardDomain@21037,whole:WildcardDomain@21518,whole:WildcardDomain@21540,whole:WildcardDomain@21564,whole:WildcardDomain@21613,whole:WildcardDomain@21776,whole:WildcardDomain@21904,whole:WildcardDomain@21933,whole:WildcardDomain@4098 fad4463c6717c5a068087aa8d5d67a97dcedfa699b553b754f39298911d9db06 |
| +internal/domains/reconcile.go StampHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-dns-fresh-lookup-724;basis=section 4 now computes every cached verdict first, then freshUpgrade gives up to 64 randomly ordered names that could have a public zone (not under the apps domain, not special-use like .internal) and whose verdict is "" or "elsewhere" an uncached lookup (30 s pass budget) that may only upgrade to "pointing", then stamps; the extra sites are the indexed loops over the same rows (#724);rev3=census-ruling-no-negative-prime-724;basis=section 4 now hands each route and alias, with its previous stamp (the two new registry:DNSStatus reads, rt.DNSStatus and a.DNSStatus, same rows already listed), to dnsVerdicts, which first hands the pass's hostnames to Config.FreshRetain (the resolver forgets its in-memory backoff and strike for names no longer carried) and then decides each hostname once per pass and applies the verdict to every row carrying it: a name not "pointing" before this pass and eligible for a fresh lookup (public name, not under the apps domain, ResolveFresh set) is looked at uncached first within the same 64-lookup/30 s budget (shared, with previously "pointing" names' upgrade looks serviced before any fresh-first name so new names cannot starve a published one) and stamped from it (edge address, A or AAAA, "pointing", other "elsewhere", authoritative not-found "", authoritative NODATA for A and AAAA with the zone's SOA "" with no cached query), falling back to the cached lookup past the budget or on the second fresh failure in a row; the first fresh failure in a row is held (stamp and check time untouched, the resolver forgives it so the next pass asks fresh again); a previously "pointing" name keeps cached-first plus the upgrade-only fresh look (ResolveUpgrade, nearest zones first), so the fresh path still never unpublishes; a fresh-first name that ends the pass "pointing" (fresh or cached) has its fresh failure backoff cleared through Config.FreshForget, so an onboarding failure never suppresses the upgrade look that keeps it published; new names are ordered never-checked first then oldest check, and lookups answered from the backoff do not count against the budget; StampHealth's own body is unchanged by the last round; no new file, path or command input; the dropped Alias/Host/Route/RouteAlias sites are the old indexed loops folded into the candidate build (#724);rev3=census-ruling-account-subdomains;basis=reads the box's own account_namespaces table (only when DNS stamping runs) and leaves out of the DNS loop the alias rows isNamespaceDerived names (an alias under a held name, of that name's account, pointing at its sqid twin); the added RouteAlias sites are that filter over rows already listed; stamps less, never more; TLS stamping unchanged registry:Alias@3986,registry:Alias@4575,registry:Alias@4665,registry:Alias@5099,registry:Alias@5163,registry:Alias@5251,registry:DNSCheckedAt@3861,registry:DNSCheckedAt@4008,registry:DNSStatus@3847,registry:DNSStatus@3995,registry:DNSStatus@4200,registry:DNSStatus@4499,registry:Host@3838,registry:Host@4272,registry:Host@4356,registry:Host@4868,registry:Host@4927,registry:Host@5009,whole:Route@199,whole:Route@236,whole:Route@3662,whole:Route@3778,whole:Route@4107,whole:Route@4822,whole:RouteAlias@1404,whole:RouteAlias@1570,whole:RouteAlias@1606,whole:RouteAlias@1637,whole:RouteAlias@1657,whole:RouteAlias@1669,whole:RouteAlias@3708,whole:RouteAlias@3922,whole:RouteAlias@4402,whole:RouteAlias@5052,whole:RouteAlias@780 c7378e603993650aa12ef694d3ebbee430797e12ae2e2ce7a3b8e8f031d508c0 |
| +internal/registry/registry.go Registry.Fingerprint legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user); the remote arm, unchanged, in the process that holds a remote handle: census-ruling-seeded-instances's body with the row's lifetime pair (incarnation, serving_seq) folded into the edge's change poll, each only when non-zero, so a registry with no pair digests as before; self-serve moves 1 Task 7;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: hashes regional_domains (host, target, account, app, region; created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no regional rows digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; no file path read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R1 finding 1: the routes SELECT also reads host, kind, account, app, platform and fingerprintForwardInert (one CASE over the ForwardForbidden columns), and every row folds host, kind, account and app (tagged, quoted), platform when set, and forward_inert=0 for a forward row that is not inert, so a rowid reused by another hostname, an in-place account or app rewrite, or a stray forbidden column moves the edge's change poll. Same one SELECT per table on the same fresh connection to the box's own registry database, as carlos; no table, file or bucket read added; a digest, never a decision.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the SELECT also reads fleet_label and, only when it is set, hashes "fleet_label=<q>" into the digest, so labelling a row moves the edge's reload fingerprint. Read sites unchanged (33). Registry side, not root; an unlabelled registry's digest is byte-identical.;rev3=census-ruling-stateless-replicas-1;basis=Read the additive stateless projection in the existing registry SELECT and hash only when set; no new read source.;rev3=census-ruling-agent-start-demo-1;basis=Existing SELECT reads four more demo columns; only a marked row adds them to the hash, so ordinary hashes remain unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Four additive projection columns join the existing routes SELECT and hash only when nonzero; no new query or file read. merge of origin/main 6be08467: Union main demo identity and expiry with replica columns in the same SELECT and hash; merge-only body change.;rev3=census-ruling-agent-start-demo-3;basis=Hash moved-notice wire bytes so notice-only changes invalidate an edge route snapshot. Census read-site delta: +file:QueryRow.;rev3=census-ruling-edge-page-cache-1;basis=selects the new pages_off column with the rest and folds "pages_off=1" into the hash only when set, as assets_off, so a registry that never sets it fingerprints as before; same routes SELECT, no new table; read sites unchanged (34); no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: hashes link_channels (link_id, account, token_hash, status, generation; connected, seen_at, seq and created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no links digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; a digest, never a decision; linked deployments slice 1 Task 7: also folds home_link (id, serving_url, tunnel_url, the token's sha256 never the token, account, apps_domain, box_label, conn_gen; state and created_at not) and home_link_apps (name, home_account, home_app, home_host) through fingerprintHomeLink over the same fresh connection, each section marker written only when a row exists, so a registry with no link digests as before; no file path read; a digest, never a decision;rev3=census-ruling-account-subdomains;basis=hashes account_namespaces (name, account) over the same fresh connection, with a section marker written only when a row exists, so a registry with no held names digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; a digest, never a decision file:Exec@284,file:Open@188,file:Query@10785,file:Query@11707,file:Query@12810,file:Query@368,file:Query@6655,file:Query@7134,file:Query@8120,file:Query@8816,file:Query@9728,file:QueryRow@13727,registry:ClaimIncarnation@1729,registry:ClaimIncarnation@5563,registry:ClaimIncarnation@5640,registry:ClaimOwner@1773,registry:ClaimOwner@5764,registry:ClaimOwner@5829,registry:ClaimRowID@1792,registry:ClaimRowID@5856,registry:ClaimRowID@5922,registry:ClaimStamp@1754,registry:ClaimStamp@5673,registry:ClaimStamp@5737,registry:Incarnation@1848,registry:Incarnation@6143,registry:Incarnation@6207,registry:ServingSeq@1867,registry:ServingSeq@6234,registry:ServingSeq@6297,registry:Text@158,registry:path@207,registry:remote@55,registry:remote@87,whole:remoteClient@57,whole:remoteClient@89 a52e0bc25d555bbf22f35655c54c0fa3aca6cedec5f0b6b80157d9d95f921a29 |
| +internal/registry/registry.go Registry.migrate legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user), on every registry open; a box CLI verb that opens the registry directly runs it as whoever runs the verb: census-ruling-seeded-instances's body with two more columns added to routes (incarnation and serving_seq, INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule); self-serve moves 1 Task 7;rev3=census-ruling-rootfs-apps-2;basis=one more ALTER TABLE, routes ADD COLUMN runtime TEXT NOT NULL DEFAULT '', beside main's rate_limit, assets_off, asset_gen, incarnation and serving_seq (the last four from the merges of origin/main 3c33f2eb and 953b9fda); the same sixteen sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 4: three more ALTER TABLE statements in the existing loop, routes ADD COLUMN egress_allow, size and policy_expires_at, each TEXT NOT NULL DEFAULT '' and idempotent through the duplicate-column rule; the same sixteen sites, no read added.;rev3=census-ruling-region-ha-p1a;basis=one more ALTER TABLE in the existing loop: routes ADD COLUMN ha INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule; the same sixteen sites, no read added;rev3=census-ruling-ha-p1a-433;basis=the registry's SQLite side as carlos (agent, registry child; a box CLI verb that opens the registry directly runs it as whoever runs it), on every registry open: the ALTER TABLE routes statements are now built from the one migration definition routeAddedColumns (addedColumn name, type, default; review r1 P2): for each entry without the Claim mark, "ALTER TABLE routes ADD COLUMN " + spec(), byte for byte the statements main runs, in main's order, under the same duplicate-column rule. +registry:Claim is that mark, +whole:addedColumn the struct. Every name, type and default is an in-binary literal; no statement added, removed or changed; no read added.;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: one more CREATE TABLE IF NOT EXISTS regional_domains (host TEXT PRIMARY KEY, target, account, app, region TEXT NOT NULL DEFAULT '', created_at INTEGER NOT NULL DEFAULT 0), beside wildcard_domains; the added sites are that statement (+file:Exec, +registry:sql), an in-binary literal; additive, no existing statement changed;rev3=census-ruling-region-ha-p1b3b-t;basis=Create local HA duty/replay tables and revision triggers in the existing registry connection; no new database path.;rev3=census-ruling-agent-start-demo-3;basis=Create moved-notice storage as a single (id, wire) row; fingerprints include the stored wire bytes. Census read-site delta: +file:Exec, +registry:sql.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: calls migrateLinks after migrateHADuties (one CREATE TABLE IF NOT EXISTS link_channels, an in-binary literal); additive, no existing statement changed; linked deployments slice 1 Task 7: also runs migrateHomeLink (CREATE TABLE IF NOT EXISTS home_link and home_link_apps) after migrateLinks; additive, the box's own registry database, as carlos;rev3=census-ruling-account-subdomains;basis=one more CREATE TABLE IF NOT EXISTS account_namespaces (name TEXT PRIMARY KEY, account TEXT NOT NULL), an in-binary literal (+file:Exec, +registry:sql); additive, no existing statement changed file:Exec@1124,file:Exec@1855,file:Exec@212,file:Exec@2409,file:Exec@3057,file:Exec@3822,file:Exec@4101,file:Exec@4964,file:Exec@51,file:Exec@5140,file:Exec@761,registry:Claim@686,registry:sql@1124,registry:sql@1855,registry:sql@212,registry:sql@2409,registry:sql@3057,registry:sql@3822,registry:sql@4101,registry:sql@4964,registry:sql@51,registry:sql@5140,registry:sql@761,whole:addedColumn@661 0c5fdaf1215e8f81c156a1fc1576cb075c2a52238bde75fc8320d49472fd117d |
| +@coverage internal/domains 0debaf45750879d4189230d9a9d3779e8bbf4bf688db73f56331a4a6c9efa074 |
| +@coverage internal/host aa8f6c1a0b8dd200cb7656622d1fb6004ea0e1bbac292459b4eafa463da7f9bb |
| +@coverage internal/registry 87edc805294acb90abb7637f64fd174bd8ced08978783dbb2631855082955582 |
| +@fields ?,A,Account,Accounts,AcquiredGeneration,AddedAt,Addr,Addrs,Adoption,Alias,Aliases,Alive,AllowAbsent,App,AppsDomain,Archives,Args,AssetGen,AssetsOff,Assigned,Assignment,At,Attempts,B,Backing,Basis,Binding,Blocked,Body,BoxLabel,Bucket,BuildState,By,Callback,CallbackError,CallbackFailed,Canary,Caps,CertExpiresAt,Changed,Channel,CheckedAt,Claim,ClaimIncarnation,ClaimOwner,ClaimOwnership,ClaimRowID,ClaimStamp,Class,Code,Column,ConnGen,Connected,Contents,Copies,Count,CreatedAt,Cursor,DBPath,DNSCheckedAt,DNSStatus,Deadline,Default,DeleteUncertain,Demand,DemoExpiresAt,DemoHost,DemoID,DemoLifetime,Departure,DepartureIID,DepartureRef,Departures,Digest,DoneBefore,DrainingSince,Due,DueAt,Duty,EdgesETag,EgressAllow,EnrolledAt,Env,EnvBefore,Environment,Error,ErrorKind,ExcludeHosts,ExpectGood,ExpectOp,ExpectPair,Expected,ExpectedPair,F,Failed,FenceGen,Field,FillLegacyRegistration,Fleet,FleetBox,FleetBoxes,FleetLabel,Fleets,Found,From,FromDB,FromOp,FromSock,Gate,Generation,GoodDemand,GoodDigest,GoodVersion,HA,HAJournal,Hash,Health,Held,Hibernate,Hint,Hints,HoldOp,HolderEpoch,HolderIID,HolderRef,HomeAccount,HomeApp,HomeHost,HomeLink,HomeLinkApp,HomeLinkApps,Host,Hosts,ID,IID,Id,IdValue,Identity,Idle,IdleSeconds,Import,ImportGate,Inbox,Incarnation,InventoryGeneration,Journal,Keep,Key,KeyFP,Keys,Kind,Label,LabelledAt,LastAt,LastBlocked,LastError,LastMs,LastPage,LastStatus,Lifetime,Limit,Link,LinkID,LinkSeen,LockETag,LockGeneration,Managed,MaxRun,MaxRunSeconds,MessageID,Method,Moved,Ms,Name,Names,Next,NextAt,NextAttempt,NextDue,NextGood,NextValue,NotBefore,Now,Number,Number64,Observation,Observed,ObservedValue,Offset,Old,Oldest,On,OnConflict,Op,Original,Owner,Ownership,P,Page,PagesOff,Pair,Path,Paths,PermissionAlerted,Phase,Platform,PolicyExpiresAt,Pool,Prefix,Prev,PrevVersion,ProofDigest,ProofKey,Provisioned,Pub,RDs,RateLimit,Raw,Receipt,ReceivedAt,RecordDigest,RecordKey,Ref,Region,Regional,Registration,Replica,ReplicaIncarnation,ReplicaLife,ReplicaRevision,Replicas,Replication,Rescan,Result,Retirement,RetryCount,Revision,RotateGen,RotatePending,Route,Routes,Row,Rows,Runtime,Scan,SecretsKeyFP,SecretsKeySetAt,SecretsKeySetBy,SecretsPub,Seed,SeedID,SeedSource,SeenAt,Seq,Sequence,ServingSeq,ServingURL,ServingVersion,Size,Slug,Socket,Spec,Sqid,StartedAt,State,Stateless,Status,StatusNamed,Steering,StringMap,Summary,T,TValue,Tags,Target,Targets,Text,Timer,Timers,Times,To,ToDB,ToOp,ToSock,Token,TokenHash,Tunnel,TunnelURL,Type,Unit,UnlinkPending,Unresolved,UpdateSettings,Ver,Version,ViewKey,Visited,W,Waiting,Wake,WakeDigest,WakeIncarnation,Walk,Wildcards,closed,conn,connect,ctx,d,dec,done,enc,full,input,output,path,readOnly,remote,slot,sql,wait |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 20af63c41..925fcf106 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -173,4 +173,4 @@ plan14-root-reads-stats-prune-400.tsv 75b32391a24d2c9269fc579aae68ac80b7b1d4ccf0 |
| plan14-root-reads-group-observation-carry.tsv 587f6e92c5e594b9bb6436a2d0066849454407202e311f43483bed3be4591940 |
| plan14-root-reads-activator-settle-wait.tsv b3d35a0bd7c0500c74efbe5e8f566adb623696d31bd9860164907e08a2e79369 |
| plan14-root-reads-lease-checkpoint-no-compaction.tsv b3d35a0bd7c0500c74efbe5e8f566adb623696d31bd9860164907e08a2e79369 |
| -plan14-root-reads-account-subdomains.tsv b3d35a0bd7c0500c74efbe5e8f566adb623696d31bd9860164907e08a2e79369 |
| +plan14-root-reads-account-subdomains.tsv caa598435ef98388152440e03eb0e83bcaa83f20e1634d8fc9031d11416c0a73 |
diff --git a/internal/registry/registry.go b/internal/registry/registry.go| index b0c03500f..05b31ad4c 100644 |
| --- a/internal/registry/registry.go |
| +++ b/internal/registry/registry.go |
| @@ -856,6 +856,18 @@ CREATE TABLE IF NOT EXISTS regional_domains ( |
| app TEXT NOT NULL DEFAULT '', |
| region TEXT NOT NULL DEFAULT '', |
| created_at INTEGER NOT NULL DEFAULT 0 |
| +);`); err != nil { |
| + return err |
| + } |
| + // account_namespaces is a derived table (account subdomains spec §4.4, |
| + // §4.6): the alias pass writes the account subdomains in force, name to |
| + // account sqid, so the edge can tell a held name from any other label |
| + // under the apps domain. Wholly pass-owned, additive, same shape as the |
| + // tables above. |
| + if _, err := r.sql.Exec(` |
| +CREATE TABLE IF NOT EXISTS account_namespaces ( |
| + name TEXT PRIMARY KEY, |
| + account TEXT NOT NULL |
| );`); err != nil { |
| return err |
| } |
| @@ -3712,6 +3724,65 @@ func (r *Registry) DeleteWildcardDomain(host string) error { |
| return err |
| } |
| +// ListAccountNamespaces returns the account_namespaces table (account |
| +// subdomains spec §4.4): each held name mapped to its account's sqid. An |
| +// empty table is an empty, non-nil map. |
| +func (r *Registry) ListAccountNamespaces() (map[string]string, error) { |
| + if r.remote != nil { |
| + out, err := r.remote.call(nil, remoteRequest{Method: "ListAccountNamespaces"}, nil) |
| + if err == nil && out.StringMap == nil { |
| + out.StringMap = map[string]string{} |
| + } |
| + return out.StringMap, err |
| + } |
| + |
| + rows, err := r.sql.Query(`SELECT name, account FROM account_namespaces ORDER BY name`) |
| + if err != nil { |
| + return nil, err |
| + } |
| + defer rows.Close() |
| + out := map[string]string{} |
| + for rows.Next() { |
| + var name, account string |
| + if err := rows.Scan(&name, &account); err != nil { |
| + return nil, err |
| + } |
| + out[name] = account |
| + } |
| + return out, rows.Err() |
| +} |
| + |
| +// SetAccountNamespaces makes the account_namespaces table exactly m (name to |
| +// account sqid), in one SQLite transaction: a name m leaves out is deleted, |
| +// and a failed write leaves the table as it was. The alias pass is its only |
| +// writer. An empty name or account is refused before anything is written. |
| +func (r *Registry) SetAccountNamespaces(m map[string]string) error { |
| + for name, account := range m { |
| + if name == "" || account == "" { |
| + return fmt.Errorf("account namespaces: empty name or account (%q: %q)", name, account) |
| + } |
| + } |
| + if r.remote != nil { |
| + _, err := r.remote.call(nil, remoteRequest{Method: "SetAccountNamespaces", Names: m}, nil) |
| + return err |
| + } |
| + |
| + tx, err := r.sql.Begin() |
| + if err != nil { |
| + return err |
| + } |
| + defer tx.Rollback() |
| + if _, err := tx.Exec(`DELETE FROM account_namespaces`); err != nil { |
| + return err |
| + } |
| + for name, account := range m { |
| + if _, err := tx.Exec(`INSERT INTO account_namespaces (name, account) VALUES (?, ?)`, name, account); err != nil { |
| + return err |
| + } |
| + } |
| + return tx.Commit() |
| +} |
| + |
| // RegionalDomain is one derived row of the regional_domains table (#447, |
| // spec §7.2): a regional claim's key (its apex, or "*.<apex>" for a |
| // catch-all) and the target this box may serve it with. Every box writes a |
| @@ -3885,7 +3956,8 @@ func (r *Registry) DeletePath(host, prefix string) error { |
| } |
| // Fingerprint summarizes the routes, fleets, fleet_boxes, route_aliases, |
| -// wildcard_domains, route_paths, regional_domains, link_channels, home_link |
| +// wildcard_domains, route_paths, regional_domains, account_namespaces, |
| +// link_channels, home_link |
| // and home_link_apps tables (link_channels without its connection columns, |
| // home_link without its state column and with only its token's sha256) over |
| // a fresh |
| @@ -4279,6 +4351,32 @@ FROM route_paths ORDER BY host, prefix`) |
| return "", err |
| } |
| + // account_namespaces (account subdomains spec §4.6): a held name makes |
| + // "*.<name>.<apps-domain>" a wildcard parent on the edge, so a change |
| + // must reload it. Both columns hash. Same marker rule as |
| + // regional_domains: written only when a row exists, so a registry with |
| + // no held names digests as it did before the table existed. |
| + nsrows, err := db.Query(`SELECT name, account FROM account_namespaces ORDER BY name`) |
| + if err != nil { |
| + return "", err |
| + } |
| + defer nsrows.Close() |
| + marked = false |
| + for nsrows.Next() { |
| + var name, account string |
| + if err := nsrows.Scan(&name, &account); err != nil { |
| + return "", err |
| + } |
| + if !marked { |
| + fmt.Fprint(h, "\x1daccount_namespaces\x1e") |
| + marked = true |
| + } |
| + fmt.Fprintf(h, "%s\x1f%s\x1e", name, account) |
| + } |
| + if err := nsrows.Err(); err != nil { |
| + return "", err |
| + } |
| + |
| // link_channels (linked deployments §6.2): a link's token hash and |
| // status decide whether the hub admits its channel, and its owner |
| // decides whether the hub serves its forward rows, so a channel write or |
diff --git a/internal/registry/registry_test.go b/internal/registry/registry_test.go| index 85079fae8..cb987eb49 100644 |
| --- a/internal/registry/registry_test.go |
| +++ b/internal/registry/registry_test.go |
| @@ -3756,3 +3756,109 @@ func TestUpsertKeepsPagesOffUnlessTheTenantChanges(t *testing.T) { |
| t.Fatal("replacement tenant inherited PagesOff") |
| } |
| } |
| + |
| +// TestAccountNamespacesRoundTrip pins the account_namespaces table (account |
| +// subdomains spec §4.4, §4.6): the alias pass records the held names, name |
| +// to account sqid, and SetAccountNamespaces replaces the whole set. |
| +func TestAccountNamespacesRoundTrip(t *testing.T) { |
| + r := openTestRegistry(t) |
| + got, err := r.ListAccountNamespaces() |
| + if err != nil || len(got) != 0 { |
| + t.Fatalf("fresh table = %v, %v; want empty", got, err) |
| + } |
| + if got == nil { |
| + t.Fatal("fresh table = nil map; want an empty one a caller can read") |
| + } |
| + want := map[string]string{"harbour": "bdq", "cove": "bcd"} |
| + if err := r.SetAccountNamespaces(want); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := r.ListAccountNamespaces(); err != nil || fmt.Sprint(got) != fmt.Sprint(want) { |
| + t.Fatalf("after set = %v, %v; want %v", got, err, want) |
| + } |
| + // Replace, not merge: a name left out goes, a changed account moves. |
| + if err := r.SetAccountNamespaces(map[string]string{"harbour": "bcd"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := r.ListAccountNamespaces(); err != nil || fmt.Sprint(got) != fmt.Sprint(map[string]string{"harbour": "bcd"}) { |
| + t.Fatalf("after replace = %v, %v; want harbour:bcd alone", got, err) |
| + } |
| + if err := r.SetAccountNamespaces(nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := r.ListAccountNamespaces(); err != nil || len(got) != 0 { |
| + t.Fatalf("after clearing = %v, %v; want empty", got, err) |
| + } |
| + for _, bad := range []map[string]string{{"": "bdq"}, {"harbour": ""}} { |
| + if err := r.SetAccountNamespaces(bad); err == nil { |
| + t.Errorf("SetAccountNamespaces(%v) = nil; want a refusal", bad) |
| + } |
| + } |
| +} |
| + |
| +// TestAccountNamespacesChangeFingerprint: the held names decide the edge's |
| +// wildcard parents (spec §4.6), so a change reloads the edge. Writing the |
| +// same set again does not, and an empty table digests as it did before the |
| +// table existed. |
| +func TestAccountNamespacesChangeFingerprint(t *testing.T) { |
| + r := openTestRegistry(t) |
| + fp := func() string { |
| + t.Helper() |
| + s, err := r.Fingerprint() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return s |
| + } |
| + empty := fp() |
| + if err := r.SetAccountNamespaces(map[string]string{"harbour": "bdq"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + one := fp() |
| + if one == empty { |
| + t.Fatal("Fingerprint blind to a new held name") |
| + } |
| + if err := r.SetAccountNamespaces(map[string]string{"harbour": "bdq"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if fp() != one { |
| + t.Fatal("the same set written again moved the Fingerprint") |
| + } |
| + if err := r.SetAccountNamespaces(map[string]string{"harbour": "bcd"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if fp() == one { |
| + t.Fatal("Fingerprint blind to a name changing account") |
| + } |
| + if err := r.SetAccountNamespaces(nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if fp() != empty { |
| + t.Fatal("an emptied table does not digest as a registry that never had one") |
| + } |
| +} |
| + |
| +// TestRemoteAccountNamespacesRoundTrip: a root pass writes the table through |
| +// the service-user child like every other registry write; without the remote |
| +// branch it would reach a nil *sql.DB. |
| +func TestRemoteAccountNamespacesRoundTrip(t *testing.T) { |
| + r, path := remoteTestRegistry(t) |
| + want := map[string]string{"harbour": "bdq", "cove": "bcd"} |
| + if err := r.SetAccountNamespaces(want); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := r.ListAccountNamespaces(); err != nil || fmt.Sprint(got) != fmt.Sprint(want) { |
| + t.Fatalf("remote list = %v, %v; want %v", got, err, want) |
| + } |
| + local, err := Open(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer local.Close() |
| + if got, err := local.ListAccountNamespaces(); err != nil || fmt.Sprint(got) != fmt.Sprint(want) { |
| + t.Fatalf("the child's write, read directly = %v, %v; want %v", got, err, want) |
| + } |
| + if err := r.SetAccountNamespaces(map[string]string{"": "bdq"}); err == nil { |
| + t.Fatal("a refused set came back nil over the transport") |
| + } |
| +} |
diff --git a/internal/registry/remote_dispatch.go b/internal/registry/remote_dispatch.go| index 08272e13e..568e9ceaa 100644 |
| --- a/internal/registry/remote_dispatch.go |
| +++ b/internal/registry/remote_dispatch.go |
| @@ -98,6 +98,7 @@ type remoteRequest struct { |
| Alias string |
| W WildcardDomain |
| RDs []RegionalDomain |
| + Names map[string]string // SetAccountNamespaces |
| P RoutePath |
| Prefix string |
| Path string |
| @@ -483,6 +484,10 @@ func (r *Registry) dispatchRemote(ctx context.Context, q remoteRequest, callback |
| out.Regional, err = r.ListRegional() |
| case "ReplaceRegionalSet": |
| err = r.ReplaceRegionalSet(q.Host, q.RDs) |
| + case "ListAccountNamespaces": |
| + out.StringMap, err = r.ListAccountNamespaces() |
| + case "SetAccountNamespaces": |
| + err = r.SetAccountNamespaces(q.Names) |
| case "ListPaths": |
| out.Paths, err = r.ListPaths() |
| case "UpsertPath": |