fix(mcp): принять однократный возврат LL моста при сверке с запечатанной контрольной точкой

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
DenozordecandClaude Sonnet 5.5 committed 2026-11-18 13:32:15 +07:00
1 parent 729987ead3
commit ca82daded6
2 files changed
+65 -2

No files matched your search

@@ -4,7 +4,7 @@ import { readFile } from "node:fs/promises"
import { sealVrfProductionAdmission, VRF_PRODUCTION_REQUIRED_CATALOGS, type VrfProductionRequest, type VrfProductionSnapshot, type VrfProductionRow as Row } from "./vrf-production-admission.js"
import { readVrfTransitionRefusal, settleVrfTransition, VRF_SETTLING_REREADS } from "./vrf-transition-refusal.js"
import { vrfExecutionDiagnostic } from "./vrf-execution-diagnostic.js"
import { vrfProductionDependencyObjects, classifyVrfProductionTransition, sealVrfProductionTransitionCheckpoint, openVrfProductionTransitionCheckpoint, assertVrfProductionHistoryProvenance, type VrfProductionTransitionCheckpoint } from "./vrf-production-transition.js"
import { vrfProductionDependencyObjects, assertVrfProductionTransitionCheckpoint, classifyVrfProductionTransition, sealVrfProductionTransitionCheckpoint, openVrfProductionTransitionCheckpoint, assertVrfProductionHistoryProvenance, type VrfProductionTransitionCheckpoint } from "./vrf-production-transition.js"
const secret = Buffer.alloc(32, 7), now = 1000, sourceProof = "a".repeat(64)
const binding = { serverId: 7, sourceProof, actorId: "human", planId: "gre-local-proof" }
@@ -317,5 +317,35 @@ 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 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.
{
const sealedLeft = () => open(leftResult.checkpoint)
const opened = sealedLeft()
assertVrfProductionTransitionCheckpoint(opened, left); cases++
assertVrfProductionTransitionCheckpoint(opened, transferred); cases++
assert.throws(() => assertVrfProductionTransitionCheckpoint(opened, transferred), /checkpoint parent\/configuration\/order drift/); cases++ // second appearance
const drifted = structuredClone(transferred); drifted.catalogs.ipv4_address.find(row => row.interface === leaving)!.comment = "drift"
assert.throws(() => assertVrfProductionTransitionCheckpoint(sealedLeft(), drifted), /checkpoint parent\/configuration\/order drift/); cases++
const changedLl = structuredClone(transferred); changedLl.catalogs.ipv6_address.find(row => row.dynamic === "true" && row.interface === leaving)!["auto-link-local"] = "false"
assert.throws(() => assertVrfProductionTransitionCheckpoint(sealedLeft(), changedLl), /checkpoint parent\/configuration\/order drift/); cases++
const routeOnly = structuredClone(left); routeOnly.catalogs.ipv6_route = transferred.catalogs.ipv6_route
assert.throws(() => assertVrfProductionTransitionCheckpoint(sealedLeft(), routeOnly), /checkpoint parent\/configuration\/order drift/); cases++
// A bridge with no debt in that checkpoint (bridge b at the reenable checkpoint, still in main) gets its LL: refused.
const deleted = snapshot(stages[5], false)
const bLl = deleted.catalogs.ipv6_address.filter(row => row.dynamic === "true" && row.interface === joining)
const bRoute = deleted.catalogs.ipv6_route.filter(row => linkLocalRoute(row, joining))
assert.equal(bLl.length, 1); assert.equal(bRoute.length, 1)
const noDebt = structuredClone(reenabled); noDebt.catalogs.ipv6_address.push(structuredClone(bLl[0])); noDebt.catalogs.ipv6_route.push(structuredClone(bRoute[0]))
assert.equal(durable(chainPrevious).leftBridgeLl, undefined)
assertVrfProductionTransitionCheckpoint(open(chainPrevious), reenabled)
assert.throws(() => assertVrfProductionTransitionCheckpoint(open(chainPrevious), noDebt), /checkpoint parent\/configuration\/order drift/); cases++
// A GRE (absentLl acquisition debt of the GRE model) is never a revival here.
const greCheckpoint = classifyVrfProductionTransition(inputs[4]).checkpoint
const greLl = inputs[5].after.catalogs.ipv6_address.filter(row => row.dynamic === "true" && !inputs[4].after.catalogs.ipv6_address.some(other => other.address === row.address))
const greRevived = structuredClone(inputs[4].after); greRevived.catalogs.ipv6_address.push(...structuredClone(greLl))
assert.ok(greLl.length > 0)
assert.throws(() => assertVrfProductionTransitionCheckpoint(greCheckpoint, greRevived), /VRF production transition refused/); cases++
}
}
console.log("GRE captured auto-LL, synthetic lifecycle, durable endpoints, negative conservation cases:", cases)
@@ -50,7 +50,40 @@ export function openVrfProductionTransitionCheckpoint(sealed: string, scope: Vrf
export function assertVrfProductionTransitionCheckpoint(checkpoint: VrfProductionTransitionCheckpoint, before: VrfProductionSnapshot): void {
const history = histories.get(checkpoint)
must(history, "unknown private checkpoint")
snapshotSame(history.snapshot, before)
try { snapshotSame(history.snapshot, before) } catch (error) {
// Owner decision 2026-11-18 (run v21 step 31): RouterOS may re-create a left bridge LL after the post-read was sealed.
if (!revivedBridgeLinkLocal(checkpoint, history, before)) throw error
}
}
const revivalsSettled = new WeakSet<VrfProductionTransitionCheckpoint>()
/** The fresh read may differ from the sealed checkpoint ONLY by the revival of
* bridge LLs the checkpoint itself owes (leftBridgeLl, or absentLl of a concrete
* bridge): per owed bridge exactly one automatic LL equal to the recorded one
* and exactly its one proven connected route, compared like the accepted
* revival in classification. Every other catalog row stays digest-exact. Once
* per opened checkpoint; any doubt keeps the original refusal. */
function revivedBridgeLinkLocal(checkpoint: VrfProductionTransitionCheckpoint, history: History, current: VrfProductionSnapshot): boolean {
if (revivalsSettled.has(checkpoint)) return false
try {
const bridge = (name: string) => current.catalogs.interface_inventory.filter(row => row.name === name).length === 1 && current.catalogs.interface_inventory.find(row => row.name === name)!.type === "bridge"
const debts = [...(history.leftBridgeLl ?? []).map(debt => ({ debt, omit: [".id", "vrf"] })), ...history.absentLl.map(debt => ({ debt, omit: [".id"] }))].filter(item => bridge(item.debt.member))
if (new Set(debts.map(item => item.debt.member)).size !== debts.length) return false
const addresses = new Set<Row>(), routes = new Set<Row>()
for (const { debt, omit } of debts) {
const revived = addressSources(current, [debt.member]).filter(source => source.ll)
if (revived.length === 0) continue
if (revived.length !== 1 || revived[0].family !== 6) return false
same(revived[0].resource, debt.address, revived[0].row, omit)
const matches = current.catalogs.ipv6_route.filter(row => routeFor(row, revived[0], current.catalogs.vrf))
if (matches.length !== 1 || Object.hasOwn(debt.route, "local-address") !== Object.hasOwn(matches[0], "local-address")) return false
same("ipv6_route", debt.route, matches[0], [".id", "gateway", "immediate-gw", "routing-table", "local-address"])
addresses.add(revived[0].row); routes.add(matches[0])
}
if (addresses.size === 0) return false
snapshotSame(history.snapshot, { ...current, catalogs: { ...current.catalogs, ipv6_address: current.catalogs.ipv6_address.filter(row => !addresses.has(row)), ipv6_route: current.catalogs.ipv6_route.filter(row => !routes.has(row)) } })
revivalsSettled.add(checkpoint)
return true
} catch { return false }
}
export function vrfProductionCheckpointCatalogs(checkpoint: VrfProductionTransitionCheckpoint): string[] {
const history = histories.get(checkpoint); must(history, "unknown private checkpoint")