chore(test): разбить приёмку scoped-маршрутизации на три шарда

Опция `part` (forward, inverse, route-ai) запускает один этап приёмки; без опции
выполняются все три, как раньше. Основной набор пропускает приёмку целиком, только
если в шардах перечислены все её части; неполный набор частей - ошибка
(acceptance-shards.test.ts).

Замер: весь набор 334 с (был 430 с, до шардов 958 с проверок), 149 строк
результатов совпадают с прошлым шардированным прогоном, каждый этап выполнен один раз.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
DenozordecandClaude Opus 5.5 committed 2026-11-19 12:19:14 +07:00
1 parent aca54ec213
commit 816660b239
5 files changed
+38 -5

No files matched your search

@@ -5,9 +5,11 @@
import { spawn } from 'node:child_process'
import { fileURLToPath } from 'node:url'
// Grouped by measured duration (2026-11-19): scoped routing ~370 s, the rest ~130-150 s each.
// Grouped by measured duration (2026-11-19): each shard ~110-190 s, the primary ~320 s.
const shards = {
'scoped-routing': ['acceptScopedRouteCommunitySwitch'],
'scoped-forward': ['acceptScopedRouteCommunitySwitch:forward'],
'scoped-inverse': ['acceptScopedRouteCommunitySwitch:inverse'],
'scoped-route-ai': ['acceptScopedRouteCommunitySwitch:route-ai'],
'wireguard-create': ['acceptWireguardInterfaceCreation', 'acceptRouteCommunityContextMcp', 'acceptWireguardPeerCreation'],
'wireguard-change': ['acceptWireguardInterfaceUpdate', 'acceptWireguardImport'],
}
@@ -0,0 +1,9 @@
import assert from "node:assert/strict"
import { skippedAcceptances } from "./acceptance-shards.js"
const scoped = ["forward", "inverse", "route-ai"].map(part => `acceptScopedRouteCommunitySwitch:${part}`)
assert.deepEqual([...skippedAcceptances([...scoped, "acceptWireguardImport"].join(","))].sort(), ["acceptScopedRouteCommunitySwitch", "acceptWireguardImport"])
assert.throws(() => skippedAcceptances(scoped[0]), /is split/, "a partly sharded acceptance must not drop out of the primary run")
assert.throws(() => skippedAcceptances("unknownAcceptance"), /Unknown acceptance shard/)
assert.equal(skippedAcceptances(undefined).size, 0)
console.log("Acceptance shards: whole or all-parts skip only; partial split and unknown names refused")
@@ -5,6 +5,9 @@ import type { AuthUser } from "../../lib/permissions.js"
* MCP_INTEGRATION_SKIP; acceptance-shard.test.ts runs the names listed in MCP_ACCEPTANCE_SHARD. */
export const ACCEPTANCE_SHARDS: Record<string, (actor: AuthUser) => Promise<unknown>> = {
acceptScopedRouteCommunitySwitch: async actor => (await import("./routing-community-scoped-acceptance.js")).acceptScopedRouteCommunitySwitch(actor),
"acceptScopedRouteCommunitySwitch:forward": async actor => (await import("./routing-community-scoped-acceptance.js")).acceptScopedRouteCommunitySwitch(actor, { part: "forward" }),
"acceptScopedRouteCommunitySwitch:inverse": async actor => (await import("./routing-community-scoped-acceptance.js")).acceptScopedRouteCommunitySwitch(actor, { part: "inverse" }),
"acceptScopedRouteCommunitySwitch:route-ai": async actor => (await import("./routing-community-scoped-acceptance.js")).acceptScopedRouteCommunitySwitch(actor, { part: "route-ai" }),
acceptWireguardInterfaceCreation: async actor => (await import("./wireguard-interface-create-acceptance.js")).acceptWireguardInterfaceCreation(actor),
acceptRouteCommunityContextMcp: async actor => (await import("./routing-community-context-acceptance.js")).acceptRouteCommunityContextMcp(actor),
acceptWireguardPeerCreation: async actor => (await import("./wireguard-peer-create-acceptance.js")).acceptWireguardPeerCreation(actor),
@@ -12,6 +15,19 @@ export const ACCEPTANCE_SHARDS: Record<string, (actor: AuthUser) => Promise<unkn
acceptWireguardImport: async actor => (await import("./wireguard-import-acceptance.js")).acceptWireguardImport(actor),
}
/** Acceptances the primary run may skip: a listed name, or a name whose every `name:part` is listed.
* Listing only some parts of a name is an error, so a stage can never drop out of both runs. */
export function skippedAcceptances(value: string | undefined): Set<string> {
const listed = new Set(acceptanceShardNames(value)), skipped = new Set<string>()
for (const name of listed) {
const base = name.split(":")[0], parts = Object.keys(ACCEPTANCE_SHARDS).filter(key => key.startsWith(base + ":"))
if (name === base) { skipped.add(base); continue }
if (!parts.every(part => listed.has(part))) throw new Error(`Acceptance ${base} is split: list all of ${parts.join(", ")}`)
skipped.add(base)
}
return skipped
}
/** Names from an environment list; an unknown name is an error, never a silent skip. */
export function acceptanceShardNames(value: string | undefined): string[] {
const names = (value ?? "").split(",").map(name => name.trim()).filter(Boolean)
+1 -1
View File
@@ -37,7 +37,7 @@ const soft = async (name: string, check: () => Promise<unknown>) => {
try { return await check() } catch (error) { softFailures.push(`${name}: ${error instanceof Error ? error.stack ?? error.message : String(error)}`) }
}
// Acceptances run by parallel shards (scripts/test-mcp-postgres-sharded.mjs) are skipped here, by exact name.
const shardedOut = new Set((await import("./acceptance-shards.js")).acceptanceShardNames(process.env.MCP_INTEGRATION_SKIP))
const shardedOut = (await import("./acceptance-shards.js")).skippedAcceptances(process.env.MCP_INTEGRATION_SKIP)
const shardable = async (name: string) => {
if (shardedOut.has(name)) { console.log(`- ${name}: runs in a parallel shard`); return }
await soft(name, async () => (await import("./acceptance-shards.js")).ACCEPTANCE_SHARDS[name](actor))
@@ -47,7 +47,7 @@ type BrowserRoutingJourney = <T>(access: { token: string; connectionId: string;
type ForwardCheckpoint = (approved: { token: string; connectionId: string; planId: string }) => Promise<string>
type InverseToolCall = (token: string, name: string, input: Record<string, unknown>) => Promise<unknown>
export async function acceptScopedRouteCommunitySwitch(actor: AuthUser, options: { originalEffectsOnly?: boolean; controllerFailoverOnly?: boolean; originalCredentialRevocationOnly?: boolean; forwardRoundsOnly?: boolean; manualForwardExpiry?: "before-intent" | "after-intent"; manualInverseChargeOnly?: boolean; manualInverseChargeCase?: "positive" | "quota" | "concurrent" | "unknown" | "revoked" | "nonpersistent" | "mixed-forward"; lateInverseAuthorityChange?: "edit" | "disable" | "grant" | "path-proof" | "path-age"; browserJourney?: BrowserRoutingJourney; bareReadbackOnly?: boolean; forwardCheckpoint?: ForwardCheckpoint; expireDuringInverseProbe?: boolean; expireDuringInversePostProbe?: boolean; inverseCheckpointDrift?: boolean; inverseRouteEffects?: boolean; inverseEffectsCheckpointDrift?: boolean; loseInverseAck?: boolean; inverseToolCall?: InverseToolCall } = {}) {
export async function acceptScopedRouteCommunitySwitch(actor: AuthUser, options: { /** One stage of the default run (shards); default runs all three. */ part?: "forward" | "inverse" | "route-ai"; originalEffectsOnly?: boolean; controllerFailoverOnly?: boolean; originalCredentialRevocationOnly?: boolean; forwardRoundsOnly?: boolean; manualForwardExpiry?: "before-intent" | "after-intent"; manualInverseChargeOnly?: boolean; manualInverseChargeCase?: "positive" | "quota" | "concurrent" | "unknown" | "revoked" | "nonpersistent" | "mixed-forward"; lateInverseAuthorityChange?: "edit" | "disable" | "grant" | "path-proof" | "path-age"; browserJourney?: BrowserRoutingJourney; bareReadbackOnly?: boolean; forwardCheckpoint?: ForwardCheckpoint; expireDuringInverseProbe?: boolean; expireDuringInversePostProbe?: boolean; inverseCheckpointDrift?: boolean; inverseRouteEffects?: boolean; inverseEffectsCheckpointDrift?: boolean; loseInverseAck?: boolean; inverseToolCall?: InverseToolCall } = {}) {
if (options.browserJourney || options.bareReadbackOnly || options.manualForwardExpiry) assert.equal(process.env.NODE_ENV, "test")
if (options.expireDuringInverseProbe || options.expireDuringInversePostProbe || options.inverseCheckpointDrift || options.inverseRouteEffects) assert(options.bareReadbackOnly)
if (options.inverseEffectsCheckpointDrift) assert(options.inverseRouteEffects)
@@ -1540,7 +1540,7 @@ export async function acceptScopedRouteCommunitySwitch(actor: AuthUser, options:
// valid, while the external native body changes to B BEFORE preparation.
// Public ingress cannot set internal profile context; this trusted-host
// preparation case proves the native gate independently binds enrollment.
{
if (!options.part || options.part === "forward") {
const driftId=randomUUID(),driftCurrent=await effectiveMcpConnection(principal),driftExpiry=new Date(Math.min(Date.now()+600000,driftCurrent.owner_valid_until.getTime(),Date.parse(principal.credentialExpiresAt),Date.parse(driftCurrent.policy.expiresAt)))
await withApplicationMutationLock(()=>withConfigMutationLock([sid],async()=>{
const baseline=await prepareRoutingControllerBaseline(driftId,1,profile("a"),driftExpiry.toISOString(),{principal,connection:driftCurrent})
@@ -1619,6 +1619,7 @@ export async function acceptScopedRouteCommunitySwitch(actor: AuthUser, options:
securityProof: false, logCoverage: "unknown", forwardingVerified: false }))
return { accepted: true, forwardRoundCases: accepted, securityProof: false, forwardingVerified: false }
}
if (!options.part || options.part === "forward") {
for (const key of ["a", "b"]) {
const before = structuredClone(filters), { plan, input } = await prepare(key), count = writes
const op = await execute(plan.planId); assert.equal(op.state, "applied"); assert.equal(writes, count + 1)
@@ -1715,6 +1716,9 @@ export async function acceptScopedRouteCommunitySwitch(actor: AuthUser, options:
console.log("Scoped post-write authority: protection, endpoint epoch, policy pause and immutable path-row tampering still stop configuration confirmation; exact one PATCH and no replay")
assert.ok(postCheckpointsObserved >= 4)
console.log("Scoped CONFIG_APPLIED SQL/HTTP: encrypted exact operation checkpoint precedes post-probe, native body/candidate/proofs bound, tamper blocked, failed control probe partial, unknown probe unknown, no inverse or replay")
}
if (options.part === "forward") return { accepted: true, part: options.part }
if (!options.part || options.part === "inverse") {
for (const scenario of ["normal", "concurrent", "lost", "ignored", "collateral", "late-protection", "late-epoch", "primary-down"] as const) {
console.log("Scoped inverse scenario:", scenario)
reset(); await refresh()
@@ -1812,6 +1816,8 @@ export async function acceptScopedRouteCommunitySwitch(actor: AuthUser, options:
}
assert.ok(inversePostChecks >= 2)
console.log("Scoped inverse SQL/HTTP: exact encrypted source/op/step, fresh A proof in B context, one durable inverse slot, exact original bytes, RECOVERY_VERIFIED, lost/ignored/collateral no replay, late protection/ABA fences, primary-down alternate and generic VERIFIED separation")
}
if (options.part === "inverse") return { accepted: true, part: options.part }
for (const scenario of ["stale", "late-epoch-aba", "late-protection", "late-pause"] as const) {
reset(); await refresh(); const { plan } = await prepare(), before = writes, protection = randomUUID()
afterIntent = async () => {