From e3eb4c174962aa84ab4686c8cafd214799bffb87 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Mon, 16 Nov 2026 07:56:52 +0800 Subject: [PATCH] test: state the current contract in tests named after removed limits (#11588) Eleven tests were named "beyond the former ..." and pinned a value just above a limit that no longer exists. Each now states and checks the current contract: - jsonShape: the caller's byte allowance is the only bound; a shape that fits exactly is complete and one byte less is a capacity refusal. - Hopper download: chunks arriving just inside the stall bound complete (the trickle case already covers the total bound). - Firmware: a selected analysis_timeout_ms above the default governs the owned command, expressed from the default constant. - Provider process output, CDP resources/timeline/WebMCP frames, Playwright steps/artifacts/Electron waits, scenario diff and Bun ELF names: renamed to the unbounded-count or exact-selection contract they check, with a note on what bound (if any) still applies and where it is covered. The six JavaScript analyzer tests with the same naming are left to their workstream. Refs #10515 --- src/artifacts/bun/BunModuleGraph.test.ts | 2 +- .../PlaywrightBrowserScenarioProvider.test.ts | 2 +- .../PlaywrightElectronActiveActions.test.ts | 2 +- .../PlaywrightScenarioArtifacts.test.ts | 3 +- src/domain/browserScenarioDiff.test.ts | 2 +- src/domain/jsonShape.test.ts | 33 +++++++++++++++---- ...cdpBrowserProvider.document_script.test.ts | 6 ++-- .../cdpBrowserProvider.timelineEvents.test.ts | 3 +- .../browser/cdpElectronProvider.test.ts | 4 ++- .../boundary/process/providerProcess.test.ts | 4 ++- tests/fixtures/fakeCdpBrowserEvents.ts | 2 +- .../firmwarePublicationDeadline.test.ts | 10 +++--- .../hopperDownloadDeadline.test.ts | 9 +++-- tests/support/providerLifecycleCoverage.ts | 2 +- 14 files changed, 58 insertions(+), 26 deletions(-) diff --git a/src/artifacts/bun/BunModuleGraph.test.ts b/src/artifacts/bun/BunModuleGraph.test.ts index 104b7cfe0b..b28bb216d3 100644 --- a/src/artifacts/bun/BunModuleGraph.test.ts +++ b/src/artifacts/bun/BunModuleGraph.test.ts @@ -419,7 +419,7 @@ it.each([ }, ); -it("recognizes an ELF Bun name beyond the former string-table prefix without reading the prefix", async () => { +it("recognizes an ELF Bun section name deep in the string table by reading only that name", async () => { const bytes = elfBunSection( bunPrefixedPayload( bunModuleGraphPayload({ diff --git a/src/browser/PlaywrightBrowserScenarioProvider.test.ts b/src/browser/PlaywrightBrowserScenarioProvider.test.ts index a6fcf15996..ce099e1c82 100644 --- a/src/browser/PlaywrightBrowserScenarioProvider.test.ts +++ b/src/browser/PlaywrightBrowserScenarioProvider.test.ts @@ -537,7 +537,7 @@ describe("PlaywrightBrowserScenarioProvider", () => { expect(result.value.limitations).toContain(session.storageGaps[0]); }); - it("returns an initial state and every step beyond the former action ceiling", async () => { + it("returns an initial state and every step of a long scenario", async () => { const session = new FakeSession("launch"); const provider = new PlaywrightBrowserScenarioProvider(() => Promise.resolve(session), diff --git a/src/browser/PlaywrightElectronActiveActions.test.ts b/src/browser/PlaywrightElectronActiveActions.test.ts index aa67c25253..db591fbc76 100644 --- a/src/browser/PlaywrightElectronActiveActions.test.ts +++ b/src/browser/PlaywrightElectronActiveActions.test.ts @@ -406,7 +406,7 @@ it("runs an untargeted deep-link without requiring a BrowserWindow", async () => ]); }); -it("honors caller-selected Electron waits beyond the former action timeout", async () => { +it("honors a caller-selected Electron wait duration exactly", async () => { const input = electronActiveObservationInputSchema.parse({ executable_path: "/opt/electron", application_path: "/opt/app/main.js", diff --git a/src/browser/PlaywrightScenarioArtifacts.test.ts b/src/browser/PlaywrightScenarioArtifacts.test.ts index be2f9964c8..343de7e7e3 100644 --- a/src/browser/PlaywrightScenarioArtifacts.test.ts +++ b/src/browser/PlaywrightScenarioArtifacts.test.ts @@ -15,7 +15,8 @@ const scenario = browserScenarioSchema.parse({ }); const secrets = resolveScenarioSecrets(scenario, {}); -it("returns a complete requested text artifact beyond the former inline ceiling", async () => { +// Text artifacts have no inline size ceiling; the content is returned whole. +it("returns a large requested text artifact complete", async () => { const page = { url: () => "https://app.example.test/", content: () => Promise.resolve("x".repeat(16 * 1_024 * 1_024 + 1)), diff --git a/src/domain/browserScenarioDiff.test.ts b/src/domain/browserScenarioDiff.test.ts index 108a9ad598..2bccff9a50 100644 --- a/src/domain/browserScenarioDiff.test.ts +++ b/src/domain/browserScenarioDiff.test.ts @@ -1026,7 +1026,7 @@ describe("browser scenario comparison validation", () => { ).toBe(false); }); - it("returns every aligned step beyond the former capture ceiling", () => { + it("returns every aligned step of long scenarios", () => { const before = multiStepScenarioCapture(130, "before"); const after = multiStepScenarioCapture(130, "after"); const result = compareBrowserScenarios( diff --git a/src/domain/jsonShape.test.ts b/src/domain/jsonShape.test.ts index 260b37d033..96db5f8133 100644 --- a/src/domain/jsonShape.test.ts +++ b/src/domain/jsonShape.test.ts @@ -201,18 +201,37 @@ describe("JSON shape completeness and ordering", () => { } }); - it("retains every parsed property beyond the former shape-node limit", () => { - const content = Object.fromEntries( - Array.from({ length: 5_001 }, (_, index) => [`field_${index}`, index]), + // The caller's byte allowance is the only bound: a shape that fits exactly + // is complete, and one byte less is a capacity refusal naming both sizes. + it("retains every parsed property within the byte allowance and refuses one byte less", () => { + const source = JSON.stringify( + Object.fromEntries( + Array.from({ length: 5_001 }, (_, index) => [`field_${index}`, index]), + ), + ); + const unbounded = inferJsonShape(source, Number.MAX_SAFE_INTEGER); + if (!unbounded.ok) throw unbounded.error; + const { serializedBytes } = unbounded.value; + expect(serializedBytes).toBe( + Buffer.byteLength(JSON.stringify(unbounded.value.shape)), ); - const shape = completeShape(JSON.stringify(content)); - expect(shape.properties).toHaveLength(5_001); - expect(shape.node_count).toBe(5_002); - expect(shape.properties).toContainEqual({ + const exact = inferJsonShape(source, serializedBytes); + if (!exact.ok) throw exact.error; + expect(exact.value.shape.properties).toHaveLength(5_001); + expect(exact.value.shape.node_count).toBe(5_002); + expect(exact.value.shape.properties).toContainEqual({ path: [property("field_5000")], types: ["number"], observations: 1, }); + + const refused = inferJsonShape(source, serializedBytes - 1); + if (refused.ok || refused.error.kind !== "capacity") + throw new Error("A shape one byte over its allowance was admitted"); + expect(refused.error.maximumBytes).toBe(serializedBytes - 1); + expect(refused.error.requiredBytesAtLeast).toBeGreaterThan( + serializedBytes - 1, + ); }); }); diff --git a/tests/boundary/browser/cdpBrowserProvider.document_script.test.ts b/tests/boundary/browser/cdpBrowserProvider.document_script.test.ts index 545184d5ad..00c88a882a 100644 --- a/tests/boundary/browser/cdpBrowserProvider.document_script.test.ts +++ b/tests/boundary/browser/cdpBrowserProvider.document_script.test.ts @@ -757,7 +757,9 @@ describe("CdpBrowserProvider: WebMCP replay inventory", () => { ); }); - it("retains registrations from authorized frames beyond the former frame cap", async () => { + // Frame count has no ceiling: the last of many authorized frames still + // contributes its registration. + it("retains registrations from every authorized frame of a page with many frames", async () => { const browser = await startFakeCdpBrowser({ webMcpTools: true, webMcpFrameCount: 1_001, @@ -776,7 +778,7 @@ describe("CdpBrowserProvider: WebMCP replay inventory", () => { expect(result.value.tools.items).toEqual( expect.arrayContaining([ expect.objectContaining({ - name: "beyond_frame_limit_tool", + name: "last_frame_tool", frame_id: "webmcp-frame-1000", }), ]), diff --git a/tests/boundary/browser/cdpBrowserProvider.timelineEvents.test.ts b/tests/boundary/browser/cdpBrowserProvider.timelineEvents.test.ts index 30c74c920a..f97d47176c 100644 --- a/tests/boundary/browser/cdpBrowserProvider.timelineEvents.test.ts +++ b/tests/boundary/browser/cdpBrowserProvider.timelineEvents.test.ts @@ -422,7 +422,8 @@ describe("CdpBrowserProvider navigation timeline", () => { } }, ); - it("returns every event beyond the former default collection cap", async () => { + // Event count has no ceiling; only a dropped event truncates the timeline. + it("returns every event of a long session timeline without truncating it", async () => { const additionalEvents = 2_001; const browser = await startFakeCdpBrowser({ pageScopedVersionWebSocket: true, diff --git a/tests/boundary/browser/cdpElectronProvider.test.ts b/tests/boundary/browser/cdpElectronProvider.test.ts index f6c7fe9eaa..5e6fdec21e 100644 --- a/tests/boundary/browser/cdpElectronProvider.test.ts +++ b/tests/boundary/browser/cdpElectronProvider.test.ts @@ -516,7 +516,9 @@ describe("CdpElectronProvider target access", () => { expect(browser.activeConnectionCount()).toBe(0); }); - it("returns every in-scope resource beyond the former collection ceiling", async () => { + // Resource count has no ceiling; only an exhausted resource budget + // truncates the section. + it("returns every in-scope resource of a large inventory without truncating the section", async () => { const root = await electronFixture(); const index = join(root, "index.html"); const count = 2_001; diff --git a/tests/boundary/process/providerProcess.test.ts b/tests/boundary/process/providerProcess.test.ts index 414fdf5052..c60eb870ab 100644 --- a/tests/boundary/process/providerProcess.test.ts +++ b/tests/boundary/process/providerProcess.test.ts @@ -235,7 +235,9 @@ describe("provider process output and cleanup primitives", () => { }); }); - it("retains complete stdout and stderr beyond the former fixed ceiling", async () => { + // Without a selected diagnostic budget every byte is retained; a selected + // budget drains and reports overflow (providerProcessOutput.test.ts). + it("retains complete stdout and stderr when no diagnostic budget is selected", async () => { const outputBytes = 70_000; const child = spawnProviderProcessFixture("burst", outputBytes); const diagnostics: ProviderProcessDiagnostic[] = []; diff --git a/tests/fixtures/fakeCdpBrowserEvents.ts b/tests/fixtures/fakeCdpBrowserEvents.ts index 602f0a636a..b5d943f89b 100644 --- a/tests/fixtures/fakeCdpBrowserEvents.ts +++ b/tests/fixtures/fakeCdpBrowserEvents.ts @@ -112,7 +112,7 @@ const emitMainWebMcpTools = ( ...(options.webMcpFrameCount !== undefined && options.webMcpFrameCount > 0 ? [ { - name: "beyond_frame_limit_tool", + name: "last_frame_tool", description: "Registered in an in-scope frame after index 999", frameId: `webmcp-frame-${String(options.webMcpFrameCount - 1)}`, }, diff --git a/tests/process-global/firmwarePublicationDeadline.test.ts b/tests/process-global/firmwarePublicationDeadline.test.ts index c4140c857d..91b499c9cc 100644 --- a/tests/process-global/firmwarePublicationDeadline.test.ts +++ b/tests/process-global/firmwarePublicationDeadline.test.ts @@ -249,7 +249,9 @@ test("keeps each queued request's independent analysis and publication budgets", await assertFirmwareCleanup(fixture.launches); }); -test("uses the selected phase deadline inside an owned command beyond the former 120-second cap", async () => { +// A selected analysis_timeout_ms governs the owned command, not the default: +// time past the default elapses inside the command and analysis completes. +test("uses a selected analysis deadline above the default inside an owned command", async () => { const fixture = await firmwareFixture(); const advance = phaseClock(); const wait = ProviderProcessSupervisor.prototype.waitForOutputClose; @@ -264,18 +266,18 @@ test("uses the selected phase deadline inside an owned command beyond the former const closed = await wait.apply(this, args); if (!advanced) { advanced = true; - advance(120_001); + advance(DEFAULT_FIRMWARE_ANALYSIS_TIMEOUT_MS + 1); return false; } return closed; }); const result = await fixture.service.execute("inspect_firmware_regions", { path: fixture.path, - analysis_timeout_ms: 240_000, + analysis_timeout_ms: 2 * DEFAULT_FIRMWARE_ANALYSIS_TIMEOUT_MS, }); if (!result.ok) throw result.error; expect(result.value.normalized_result).toMatchObject({ - analysis_timeout_ms: 240_000, + analysis_timeout_ms: 2 * DEFAULT_FIRMWARE_ANALYSIS_TIMEOUT_MS, }); expect(fixture.launches).toHaveLength(2); expect( diff --git a/tests/process-global/hopperDownloadDeadline.test.ts b/tests/process-global/hopperDownloadDeadline.test.ts index a73c609c28..52c08291f1 100644 --- a/tests/process-global/hopperDownloadDeadline.test.ts +++ b/tests/process-global/hopperDownloadDeadline.test.ts @@ -53,10 +53,13 @@ const stubPackage = (chunkEveryMs: number, chunks: number) => { return fetch; }; -it("completes a slow download that keeps delivering bytes past the former 120 s deadline", async () => { - stubPackage(20_000, 9); +// Each chunk arrives just inside the stall bound; the download completes +// well before the total bound (the trickle case below exceeds it). +it("completes a slow download whose bytes keep arriving within the stall bound", async () => { + const chunkEveryMs = HOPPER_DOWNLOAD_STALL_MS - 1; + stubPackage(chunkEveryMs, 9); const pending = downloadHopperPackage(url); - await vi.advanceTimersByTimeAsync(9 * 20_000); + await vi.advanceTimersByTimeAsync(9 * chunkEveryMs); expect(await pending).toEqual(ok(Buffer.alloc(9 * 1024))); }); diff --git a/tests/support/providerLifecycleCoverage.ts b/tests/support/providerLifecycleCoverage.ts index a1aa5053d3..e27d0c7a8e 100644 --- a/tests/support/providerLifecycleCoverage.ts +++ b/tests/support/providerLifecycleCoverage.ts @@ -1435,7 +1435,7 @@ export const PROVIDER_LIFECYCLE_COVERAGE: Readonly< operation: covered( test( "src/browser/PlaywrightBrowserScenarioProvider.test.ts", - "returns an initial state and every step beyond the former action ceiling", + "returns an initial state and every step of a long scenario", ), ), cancel: covered(