Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/tests/document-writes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe("brain_update", () => {
const PLAIN_WRITERS: Record<string, string> = {
"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",
Expand Down
15 changes: 7 additions & 8 deletions packages/ui-server/tests/admission-sub-phases.test.ts
Original file line number Diff line number Diff line change
@@ -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<ActivityTurnLifecycle["subPhases"]>[number];
Expand Down Expand Up @@ -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() {} });
Expand All @@ -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 });
}
});
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-server/tests/private-index-stdio-release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scripts/source-browser-payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { resolve } from "node:path";
// Other HTML (including interpolated fixture payloads) remains unresolved.
const literals:Record<string,{source:string;expression:string}> = {
"packages/ui-kit/tests/visual/form-browser.ts": {
"source": "3ccf67a71fa64af195bbf8cf6d173064dc9d2d4fc6abc699fa0a638c352ca62e",
"source": "5def3875a8e16e41b22bf1ff2a25b045a3adc59bdc2df2e0c7754126f3c8e27b",
"expression": "route.fulfill({ status: 200, contentType: \"image/svg+xml\", body: '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100\" height=\"60\"><rect width=\"100\" height=\"60\" fill=\"teal\"/></svg>' })"
},
"packages/ui-kit/tests/visual/ghost-browser.ts": {
Expand Down
Loading