tests: inventory linked deployments in the repo-wide guards
TestTopLevelWordsUnchanged: the word list gains the new top-level commands link and links. TestRouteWriterInventoryIsComplete: PutLinkChannel's prune, RevokeLinkChannel and DeleteLinkForward delete link-placed forward rows by design, so the writer table (which asks a writer to leave a forward row alone) cannot hold them. They go in a new linkRowWriters set beside the five exceptions, each with what it deletes and why, and every routes statement in one must carry kind = 'forward'; the link class is held by links_test.go. migrateHomeLink's ALTER TABLE home_link and activeLinkMap's SELECT over link_channels are classified as a schema migration and a read. TestGroupNameClassCensus: edgesFileWriteClaims, provision Reconcile and Edge.Reload are re-pinned with their consequence recorded: link forward rows published in the edges file under their exact host, a host held by a link row skipped by reconcile, link auth applied first in Reload. No new name class.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+58
−9
commands_test.go+1 −1internal/host/group_names_test.go+22 −3internal/registry/forward_inventory_test.go+35 −5
CI failed — run details
diff --git a/commands_test.go b/commands_test.go| index d6f6c865b..b915c3a06 100644 |
| --- a/commands_test.go |
| +++ b/commands_test.go |
| @@ -35,7 +35,7 @@ func TestTopLevelWordsUnchanged(t *testing.T) { |
| "relay", "email", "logs", "errors", "availability", "geo", "explain", |
| "analytics", "protection", "channels", "pipeline", "skills", |
| "releases", "rollback", "ledger", "auth", "config", "accounts", |
| - "billing", "apps", "fleets", "services", "env", "secrets", |
| + "billing", "apps", "link", "links", "fleets", "services", "env", "secrets", |
| "release-keygen", "proof", "ops", "system", "move", "status", "agent", |
| "bootstrap", "adopt", "instance-control", "instance-exec", |
| "instance-exit", "instance-stop", "instance-probe", "vet", "update", |
diff --git a/internal/host/group_names_test.go b/internal/host/group_names_test.go| index a879b782b..a457cef18 100644 |
| --- a/internal/host/group_names_test.go |
| +++ b/internal/host/group_names_test.go |
| @@ -412,6 +412,22 @@ func (p *haIngressProjection) publishAliases(names map[string]Route) { p.aliases |
| // pages and opt-in marks by scope; nothing is added to the route table. |
| // - routeScope reads a route's page scope; it produces no name. |
| // |
| +// Linked deployments slice 1 keeps the existing name classes: |
| +// - edgesFileWriteClaims takes edge.ForwardOwners from fleetArmInputs (the |
| +// fleets table and, on a hub, the active links' owners), so |
| +// FleetArmVerdict judges a link-placed forward row (Region "link/<id>") |
| +// by its link's owner: an eligible one is published in the edges file |
| +// as a forward row of its own exact host, as a fleet forward row is, |
| +// and a refused one is withheld the same way. No name is derived. |
| +// - Reconcile skips a record whose host a link-placed forward row holds: |
| +// no pass retires a link's row (only the link's own doors remove it), |
| +// so the record is not applied and nothing is minted over the name. |
| +// - Reload reads and applies the link channel credentials first |
| +// (LinkChannelAuth, SetLinkAuth), merges them into the hub's channel |
| +// set, and judges link-placed forward rows by LinkOwners; an eligible |
| +// 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. |
| +// |
| // TestHAIngressNamesWithoutLocalRow, TestHAIngressAliasBinding and |
| // TestHAIngressStartupNames exercise these existing name classes end to end. |
| var groupNameProducerInventory = map[string]string{ |
| @@ -439,7 +455,10 @@ var groupNameProducerInventory = map[string]string{ |
| // Held requests move speed: the six tenant proxies' response hook is |
| // wrapped by classifyMoveStreams, which reads only the response head to |
| // mark a stream for a move's cut; no name is derived, published or routed. |
| - "../edge/edge.go:*Edge.Reload": "9dc1db78179479c5d2d1ac25c5c696c09edf86e6a088f7a6145db11c6ac6f1a9", |
| + // Linked deployments slice 1: link channel auth is applied first and a |
| + // link-placed forward row is served under its exact host down its |
| + // link's channel (ArmLink); no name is derived (see above). |
| + "../edge/edge.go:*Edge.Reload": "ada1fc1e86d4e9f82f7e8e1104518223bb00fc3bcfe296dbc12012e645472acb", |
| // Edge page cache slice 1: routeScope builds an in-memory upstream only to |
| // read the route's page scope (account, app, primary host). It publishes, |
| // registers and routes no name; no name class. |
| @@ -447,7 +466,7 @@ var groupNameProducerInventory = map[string]string{ |
| "../edge/platformalias.go:PlatformAliasFold": "a18e4963cf88320ef3fb94b666b02838dc12cc3e9b2df3f2cbe2576ca682735f", |
| "../edge/regional.go:*Edge.foldRegional": "2c52d0d9147ab4b426649a78573a8550e0ba1073e2f5e5ef10e894f2570e9a8d", |
| "../provision/forward.go:forwardRowFor": "e7294d6a3c96e51646257200f5cedb26aaf491afea23be3d943b3e3f742c4db4", |
| - "../provision/reconcile.go:Reconcile": "b2bc85f6ea8218fe4114a2847c7f4b828daa28181562f104bd5023179c03b9d0", |
| + "../provision/reconcile.go:Reconcile": "1a56897323c0b0b26c6e7346b66bca03c95eeb56faded94b598082ae3eeff848", |
| // Resident replicas use nested local paths; exact-route names and owners do not change. |
| "../provision/reconcile.go:RouteFor": "f42827f4faca3572837e627a694c72928048e245573c50a75c357a44be28bb8d", |
| "../provision/reconcile.go:mintHeld": "9fe4ad876c727af36cc06bd0105baf344748c61e6f21ced48e5288a323851344", |
| @@ -462,7 +481,7 @@ var groupNameProducerInventory = map[string]string{ |
| "claimunit_binding.go:claimUnitShape.route": "f38fd6e10aba680354ee908c255fd34e731fe2d1a22fffd41ac449e8b763dd2c", |
| "claimunit_policy.go:claimUnitShapeCheck": "45f16830e5ed834995ca573a710f1e390a504b7eb78c3c0465ac70e7f306e50c", |
| "claimunit_policy.go:rootClaimRestartShape": "1d0370516c32482b1784f4bd4ab0deb042c31120d81f4dc8c417f52b24ef76ac", |
| - "edgesfile.go:edgesFileWriteClaims": "f19e0a6547b891ad689fb58b11d842ba9b7214f6df766bc46e9da0a4cce4d9d7", // held floor capability: constant ha_handover=1 on every pass; no name or class derivation |
| + "edgesfile.go:edgesFileWriteClaims": "8d9cde73780773694f5ac0ad0da697dbc738b37c6479f9919a25415f6e5eac8e", // held floor capability: constant ha_handover=1 on every pass; linked deployments: link forward rows published as exact forward names; no name or class derivation |
| "movesheldenv.go:composeHeldEnv": "17ad3714758d1c07a71375734c125496855a16ca800eb814bde58283d3a5318b", |
| "movesheldrelease_root.go:heldReleaseRoute": "10bf824edc963319a38a47b91877b865977b1dc4a27c6e7680c46704289a7df7", |
| "movesstage.go:heldReleasePublished": "edad51c04a01657b77a9fc469404db5fde51cff1f2c61e243d6a717fb6224e85", |
diff --git a/internal/registry/forward_inventory_test.go b/internal/registry/forward_inventory_test.go| index 4ec12e1a0..c8010ddea 100644 |
| --- a/internal/registry/forward_inventory_test.go |
| +++ b/internal/registry/forward_inventory_test.go |
| @@ -23,11 +23,26 @@ var forwardRowWriters = map[string]bool{ |
| "PutForward": true, "DeleteForward": true, "SetFleetBoxIf": true, "SetDNSStatus": true, "SetCertExpiresAt": true, |
| } |
| +// linkRowWriters are linked deployments' writers of link-placed forward |
| +// rows (Region "link/<id>"), beside the five exceptions: they delete forward |
| +// rows by design, so the writer table (which asks a writer to leave a forward |
| +// row alone) cannot hold them. Every routes statement in one of them must |
| +// carry kind = 'forward', so it never touches an ordinary row; the link class |
| +// (only rows placed on that link, never a fleet row) is held by |
| +// TestForwardClassesDisjoint, TestPutLinkChannelOneWriter and |
| +// TestLinkForwardNeedsActiveChannel in links_test.go. |
| +var linkRowWriters = map[string]string{ |
| + "PutLinkChannel": "prunes the link's forward rows whose account no longer holds the active channel, in the transaction that applied a newer generation (pruneLinkForwardsSQL)", |
| + "RevokeLinkChannel": "deletes every forward row placed on the link, in the transaction that marks its channel revoked", |
| + "DeleteLinkForward": "deletes one host's row while it is a forward row placed exactly on the link (unpublish); DeleteForward refuses link rows", |
| +} |
| + |
| // unresolvedSQL classifies one SQL argument with no constant value. |
| // writesRoutes marks a call that executes a routes write the scan cannot |
| // read (a statement built at run time, a prepared statement's Exec, a |
| // package variable): its enclosing function must be reached by the writer |
| -// table, or be one of the five exceptions, exactly as a resolved write's. |
| +// table, or be one of the five exceptions or a link-row writer, exactly as |
| +// a resolved write's. |
| type unresolvedSQL struct { |
| writesRoutes bool |
| why string |
| @@ -58,6 +73,8 @@ var unresolvedRouteSQL = map[string]unresolvedSQL{ |
| "timers.go:PruneTimers": {false, "DELETE FROM timers built at run time; timers only"}, |
| "timers.go:DeleteTimersExcept": {false, "DELETE FROM timers built at run time; timers only"}, |
| "forward.go:PutForward": {true, "putForwardSQL, the forward row's own writer (an exception), built once from ForwardForbidden"}, |
| + "homelink.go:migrateHomeLink": {false, "ALTER TABLE home_link ADD COLUMN unlink_pending|rotate_pending: a schema migration of the home_link table, writes no row"}, |
| + "links.go:activeLinkMap": {false, "SELECT link_id, token_hash|account FROM link_channels WHERE status = 'active', from LinkChannelAuth and LinkOwners: a read of link_channels"}, |
| } |
| // sqlMethods are the database calls whose argument at the index is SQL. |
| @@ -167,9 +184,10 @@ func routeSQLSites(t *testing.T) (sites []routeSQLSite, unresolved map[string][] |
| // TestRouteWriterInventoryIsComplete keeps TestEveryRouteWriterRefusesAForwardRow's |
| // table whole: every statement in internal/registry that writes routes sits in |
| // a function that some entry of the table reaches (its encloses list), or in |
| -// one of the five exceptions. Every non-exception UPDATE, DELETE and upsert on |
| -// routes carries kind <> 'forward' in its text. A SQL argument with no constant |
| -// value is classified in unresolvedRouteSQL. |
| +// one of the five exceptions, or in a link-row writer whose statements carry |
| +// kind = 'forward'. Every other UPDATE, DELETE and upsert on routes carries |
| +// kind <> 'forward' in its text. A SQL argument with no constant value is |
| +// classified in unresolvedRouteSQL. |
| func TestRouteWriterInventoryIsComplete(t *testing.T) { |
| sites, unresolved := routeSQLSites(t) |
| if len(sites) < 60 { |
| @@ -195,16 +213,23 @@ func TestRouteWriterInventoryIsComplete(t *testing.T) { |
| } |
| fn := k[strings.Index(k, ":")+1:] |
| seen[fn] = true |
| - if !forwardRowWriters[fn] && len(reached[fn]) == 0 { |
| + if !forwardRowWriters[fn] && linkRowWriters[fn] == "" && len(reached[fn]) == 0 { |
| t.Errorf("%s (%v): a routes write classified in unresolvedRouteSQL, and no entry of the writer table reaches %s (nor is it one of the five exceptions)", k, unresolved[k], fn) |
| } |
| } |
| guard := regexp.MustCompile(`(?i)\bkind\s*<>\s*'forward'`) |
| + linkGuard := regexp.MustCompile(`(?i)\bkind\s*=\s*'forward'`) |
| for _, s := range sites { |
| seen[s.fn] = true |
| if forwardRowWriters[s.fn] { |
| continue |
| } |
| + if linkRowWriters[s.fn] != "" { |
| + if !linkGuard.MatchString(s.text) { |
| + t.Errorf("%s: %s is a link-row writer and its routes statement does not carry kind = 'forward':\n %q", s.pos, s.fn, s.text) |
| + } |
| + continue |
| + } |
| if len(reached[s.fn]) == 0 { |
| t.Errorf("%s: %s writes routes and no entry of the writer table reaches it (nor is it one of the five exceptions):\n %q", s.pos, s.fn, s.text) |
| continue |
| @@ -225,6 +250,11 @@ func TestRouteWriterInventoryIsComplete(t *testing.T) { |
| t.Errorf("exception %s holds no routes write", fn) |
| } |
| } |
| + for fn := range linkRowWriters { |
| + if !seen[fn] { |
| + t.Errorf("link-row writer %s holds no routes write", fn) |
| + } |
| + } |
| var keys []string |
| for k := range unresolved { |