diff --git a/packages/core/tests/document-writes.test.ts b/packages/core/tests/document-writes.test.ts index 580bab436b..30254c4b30 100644 --- a/packages/core/tests/document-writes.test.ts +++ b/packages/core/tests/document-writes.test.ts @@ -104,6 +104,7 @@ describe("brain_update", () => { const PLAIN_WRITERS: Record = { "cli/commands/init.ts": "scaffolds a new brain: each file is written only when absent", "lib/indexer/caches.ts": "derived caches, regenerated by `brain index --force`", + "lib/module-state.ts": "the module state area's own .gitignore, created only when absent (`wx`), never a brain document", "lib/skills/emitters/codex.ts": "agent instruction files, not brain documents", "lib/skills/emitters/gemini.ts": "agent instruction files, not brain documents", "lib/skills/emitters/index-block.ts": "agent instruction files, not brain documents", diff --git a/packages/ui-server/tests/admission-sub-phases.test.ts b/packages/ui-server/tests/admission-sub-phases.test.ts index c078711c2c..e4a2012404 100644 --- a/packages/ui-server/tests/admission-sub-phases.test.ts +++ b/packages/ui-server/tests/admission-sub-phases.test.ts @@ -1,16 +1,15 @@ /** #3355: governed admission and journal begin attribute their time to named steps. */ -import { expect, spyOn, test } from "bun:test"; +import { expect, test } from "bun:test"; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import type { ActivityTurnLifecycle } from "@schlessera/brain-ui-sdk/protocol"; -import * as startup from "../../ui-sdk/src/server/worker-startup-view.js"; -import { createFixtureWorkerStartupView } from "../../ui-sdk/tests/helpers/worker-startup-view-fixture.js"; import { createUiDb } from "../src/db/client.js"; import { createActivityStore } from "../src/activity/store.js"; import { createTurnLifecycle } from "../src/activity/turn-lifecycle.js"; import { createGovernedTurns } from "../src/brain/governed-turn.js"; import { createTurnJournal } from "../src/brain/turn-journal.js"; +import { replaceNativeStartupAcquisitionForFixture } from "./helpers/fixture-native-startup.js"; import { createNativeJournalFixture } from "./helpers/native-journal-fixture.js"; type Step = NonNullable[number]; @@ -46,11 +45,11 @@ test("steps persist with the next milestone and follow the phase failure rules", }); test("real governed admission records each step inside governedAdmissionMs", async () => { - const brain = mkdtempSync(join(tmpdir(), "odysseus-admission-steps-")), views: startup.WorkerStartupView[] = []; + const brain = mkdtempSync(join(tmpdir(), "odysseus-admission-steps-")); writeFileSync(join(brain, ".gitignore"), ".brain/scratch/\n"); - const acquire = spyOn(startup, "prepareNativeWorkerStartupView").mockImplementation(async path => { - const view = createFixtureWorkerStartupView(path); views.push(view); return view; - }); + // The shared stand-in copies the startup view and admits it at the managed-storage + // refusal only (#3314); that refusal keeps its own tests. + const restore = replaceNativeStartupAcquisitionForFixture(); const execution = { boundary: { async prepare() { return { available: true }; }, maintenance: {} }, gate() { return { async acquire() { return { release() {} }; } }; }, manifests() { return {}; } }; const turns = createGovernedTurns({ nativeManager: {} as never, brainPath: brain, execution: execution as never, profile: "strict", maskPaths: [], async index() {}, report() {} }); @@ -68,7 +67,7 @@ test("real governed admission records each step inside governedAdmissionMs", asy expectWithin(record.subPhases!, "governed", record.governedStartedAt!, record.governedAcquiredAt!); } finally { await hold.end(); } } finally { - acquire.mockRestore(); for (const view of views) await view.cleanup(); await turns.close(); db.close(); + await turns.close(); restore(); db.close(); rmSync(brain, { recursive: true, force: true }); } }); diff --git a/packages/ui-server/tests/private-index-stdio-release.test.ts b/packages/ui-server/tests/private-index-stdio-release.test.ts index b69fd0396c..0cf4d196ae 100644 --- a/packages/ui-server/tests/private-index-stdio-release.test.ts +++ b/packages/ui-server/tests/private-index-stdio-release.test.ts @@ -69,7 +69,7 @@ for (const mode of ["success", "failure", "oversized", "timeout", "abort"] as co const seen = observeLaunch({ pool: true, script: blocked ? "printf Ithaca; exec sleep 30" : `printf Ithaca; printf Penelope >&2; exit ${mode === "failure" ? 3 : 0}`, ...(mode === "abort" ? { launched: (child: Launched) => { child.stdout.once("data", () => controller.abort()); } } : {}) }); - const result = await outcome(runMaskedBrainCli({ ...f, signal: controller.signal, command: [], + const result = await outcome(runMaskedBrainCli({ ...f, signal: controller.signal, command: ["/bin/sh"], ...(mode === "timeout" ? { timeoutMs: 100 } : {}), ...(mode === "oversized" ? { outputBytes: 2 } : {}) })); const open = seen.open(); expect(seen.held(), "POOL_HELD_THROUGH_MASKED_CLI_TEARDOWN").toBe(true); @@ -91,7 +91,7 @@ test("a masked CLI output read failure stops its worker and releases its stdio", child = launched; child.stdout.once("data", () => child!.stdout.destroy(new Error("Odysseus stopped the read"))); } }); - const work = outcome(runMaskedBrainCli({ ...f, signal: new AbortController().signal, command: [] })); + const work = outcome(runMaskedBrainCli({ ...f, signal: new AbortController().signal, command: ["/bin/sh"] })); try { const result = await Promise.race([work, Bun.sleep(10_000).then(() => undefined)]); expect(result, "OUTPUT_READ_FAILURE_STOPS_WORKER").toBeDefined(); @@ -127,7 +127,7 @@ for (const path of ["masked CLI", "turn tree"] as const) for (const abort of [fa const tree = path === "turn tree" ? await createTurnDataTree({ brainPath: f.brain, view: f.startupView, maskPaths: [], mount: true }) : undefined; if (tree) cleanup.push(() => tree.close()); const work = outcome(tree ? tree.planAdd({}, controller.signal) - : runMaskedBrainCli({ ...f, signal: controller.signal, command: [] })).then(result => { settled = true; return result; }); + : runMaskedBrainCli({ ...f, signal: controller.signal, command: ["/bin/sh"] })).then(result => { settled = true; return result; }); try { expect(await Promise.race([calling.promise.then(() => true), work.then(() => false), Bun.sleep(10_000).then(() => false)]), "SETTLEMENT_REACHES_RELEASE").toBe(true); expect(await Promise.race([child!.exited, Bun.sleep(10_000).then(() => "no exit")]), "EXIT_REPORTED_WHILE_RELEASE_PENDING").toBe(0); diff --git a/scripts/source-browser-payloads.ts b/scripts/source-browser-payloads.ts index 11e3a50d63..04f12905da 100644 --- a/scripts/source-browser-payloads.ts +++ b/scripts/source-browser-payloads.ts @@ -7,7 +7,7 @@ import { resolve } from "node:path"; // Other HTML (including interpolated fixture payloads) remains unresolved. const literals:Record = { "packages/ui-kit/tests/visual/form-browser.ts": { - "source": "3ccf67a71fa64af195bbf8cf6d173064dc9d2d4fc6abc699fa0a638c352ca62e", + "source": "5def3875a8e16e41b22bf1ff2a25b045a3adc59bdc2df2e0c7754126f3c8e27b", "expression": "route.fulfill({ status: 200, contentType: \"image/svg+xml\", body: '' })" }, "packages/ui-kit/tests/visual/ghost-browser.ts": {