diff --git a/backend/src/services/vrf-production-gre-link-local.test.ts b/backend/src/services/vrf-production-gre-link-local.test.ts index 39bf064a..6f5eaf5a 100644 --- a/backend/src/services/vrf-production-gre-link-local.test.ts +++ b/backend/src/services/vrf-production-gre-link-local.test.ts @@ -317,6 +317,44 @@ for (const [label, current, mutate] of [ await assert.rejects(settleVrfTransition(greAfter, after => classifyVrfProductionTransition({ ...inputs[4], after }), async () => { greRereads++; return greAfter }, async () => {}), /VRF production transition refused/) assert.equal(greRereads, VRF_SETTLING_REREADS); cases++ assert.ok(joining && joining !== leaving) + // Owner decision 2026-11-18 (run v24 step 31): the rejoin post-read holds the owed bridge's fe80 route but not yet its + // LL address (non-atomic read). That shape alone is re-read (settling); nothing is accepted without the address. + { + const addressGone = (s: VrfProductionSnapshot) => { const copy = structuredClone(s); copy.catalogs.ipv6_address = copy.catalogs.ipv6_address.filter(row => !(row.dynamic === "true" && row.interface === leaving)); return copy } + const routeOnly = addressGone(rejoined) + assert.ok(routeOnly.catalogs.ipv6_route.some(row => linkLocalRoute(row, leaving))) + const classifyRejoin = (previous: VrfProductionTransitionCheckpoint | undefined) => (after: VrfProductionSnapshot) => classifyVrfProductionTransition(input(left, after, rejoin, previous)) + let count = 0 + // Re-read, then the address and route are both there: the accepted revival path settles the debt. + const settled = await settleVrfTransition(routeOnly, classifyRejoin(leftPrevious), async () => { count++; return structuredClone(rejoined) }, async () => {}) + assert.equal(settled.status, "explained-native-transition"); assert.equal(count, 1); assert.equal(durable(settled.checkpoint).leftBridgeLl, undefined); cases++ + // Unchanged on every re-read: the same FOREIGN refusal after the bound. + count = 0 + const exhausted = await settleVrfTransition(routeOnly, classifyRejoin(leftPrevious), async () => { count++; return structuredClone(routeOnly) }, async () => {}).then(() => undefined, (error: unknown) => error) + assert.equal(readVrfTransitionRefusal(exhausted)?.guard, "FOREIGN_CATALOG_CONFIGURATION_ORDER_CHANGED"); assert.equal(count, VRF_SETTLING_REREADS); cases++ + // Immediate refusal (no re-read): no debt, an extra foreign row, a route of a bridge without debt, the route of a GRE. + const immediate = async (first: VrfProductionSnapshot, classify: (after: VrfProductionSnapshot) => unknown, label: string) => { + let rereads = 0 + await assert.rejects(settleVrfTransition(first, classify as (after: VrfProductionSnapshot) => never, async () => { rereads++; return structuredClone(rejoined) }, async () => {}), /foreign ipv6_route configuration\/order changed/, label) + assert.equal(rereads, 0, label); cases++ + } + await immediate(routeOnly, classifyRejoin(undefined), "no debt") + const extraForeign = structuredClone(routeOnly); extraForeign.catalogs.ipv6_route.push({ ".id": "*ffc1", "dst-address": "2001:db8::/64", gateway: "foreign", dynamic: "false", "routing-table": "main" }) + await immediate(extraForeign, classifyRejoin(leftPrevious), "extra foreign row") + const otherBridge = structuredClone(routeOnly), owedRoute = otherBridge.catalogs.ipv6_route.find(row => linkLocalRoute(row, leaving))! + otherBridge.catalogs.ipv6_route = otherBridge.catalogs.ipv6_route.filter(row => row !== owedRoute) + otherBridge.catalogs.ipv6_route.push({ ...structuredClone(owedRoute), ".id": "*ffc2", gateway: "other-bridge", "immediate-gw": "other-bridge" }) + await immediate(otherBridge, classifyRejoin(leftPrevious), "bridge without debt") + // GRE: the GRE model's acquisition debt (absentLl) never makes a GRE fe80 route transient here. + const gre = inputs[4], greName = String(gre.after.catalogs.vrf.find(row => row[".id"] === gre.request.id)!.interfaces) + const greRoute = inputs[5].after.catalogs.ipv6_route.find(row => linkLocalRoute(row, greName)) + if (greRoute) { + const greAfter = structuredClone(gre.after); greAfter.catalogs.ipv6_route.push({ ...structuredClone(greRoute), ".id": "*ffc3" }) + let rereads = 0 + await assert.rejects(settleVrfTransition(greAfter, after => classifyVrfProductionTransition({ ...gre, after }), async () => { rereads++; return greAfter }, async () => {}), /VRF production transition refused/) + assert.equal(rereads, 0); cases++ + } + } // Owner decision 2026-11-18 (run v21 step 31): the reconcile of a verified checkpoint may see the owed bridge LL come // back after the post-read was sealed. Accepted once per opened checkpoint, only as exactly the owed LL + its route. { diff --git a/backend/src/services/vrf-production-transition.ts b/backend/src/services/vrf-production-transition.ts index a0ec5a85..600390e4 100644 --- a/backend/src/services/vrf-production-transition.ts +++ b/backend/src/services/vrf-production-transition.ts @@ -557,11 +557,26 @@ export function classifyVrfProductionTransition(input: VrfProductionTransitionIn } }) // No explained successor may acquire an ID belonging to a foreign row. + const owedBridges = new Set([...priorLeft.filter(item => !settledLeft.has(item)).map(item => item.member), ...(history?.absentLl ?? []).map(item => item.member)].filter(name => { + const rows = after.catalogs.interface_inventory.filter(row => row.name === name) + return rows.length === 1 && rows[0].type === "bridge" && !after.catalogs.ipv6_address.some(row => yes(row.dynamic) && row.interface === name) + })) + const owedBridgeRoute = (row: Row) => { try { + return yes(row.dynamic) && [row.connect, row.connected].some(yes) && prefix(row["dst-address"], 6).network === prefix("fe80::/64", 6).network && [...owedBridges].some(name => row["immediate-gw"] === name && (row.gateway === name || String(row.gateway).startsWith(name + "@"))) + } catch { return false } } + const owedBridgeRouteOnly = (foreignBefore: Row[], foreignAfter: Row[]) => { + const extra = foreignAfter.filter(row => owedBridgeRoute(row) && !foreignBefore.some(previous => previous[".id"] === row[".id"])) + return extra.length > 0 && isDeepStrictEqual(foreignBefore.map(row => projected("ipv6_route", row)), foreignAfter.filter(row => !extra.includes(row)).map(row => projected("ipv6_route", row))) + } withVrfTransitionSection("foreign", () => { for (const resource of Object.keys(before.catalogs)) { const a = exemptBefore.get(resource) ?? new Set(), b = exemptAfter.get(resource) ?? new Set() const foreignBefore = before.catalogs[resource].filter(row => !a.has(row)), foreignAfter = after.catalogs[resource].filter(row => !b.has(row)) - must(isDeepStrictEqual(foreignBefore.map(row => projected(resource, row)), foreignAfter.map(row => projected(resource, row))), `foreign ${resource} configuration/order changed`, "FOREIGN_CATALOG_CONFIGURATION_ORDER_CHANGED") + // Owner decision 2026-11-18 (run v24 step 31): a non-atomic post-ACK read may already hold the revived fe80 connected + // route of an owed bridge but not yet its LL address. Only that exact shape is marked transient (re-read); nothing + // is accepted without the address, and after the bound the same refusal stands. + settling(() => resource === "ipv6_route" && owedBridgeRouteOnly(foreignBefore, foreignAfter), () => + must(isDeepStrictEqual(foreignBefore.map(row => projected(resource, row)), foreignAfter.map(row => projected(resource, row))), `foreign ${resource} configuration/order changed`, "FOREIGN_CATALOG_CONFIGURATION_ORDER_CHANGED")) for (const row of b) must(!foreignBefore.some(previous => nativeId(previous[".id"]) === nativeId(row[".id"])), "companion acquired foreign ID") } })