test(agents): await foreign maintenance startup in ownership fixtures

The ownership fixture scheduled durable background maintenance and used
Vitest's default one-second poll to detect callback entry. Asynchronous
task-worker preparation can outlast that poll. Two sibling cases failed
at 1698ms and 1728ms even though startup was progressing normally.

Signal entry from the fixture callback before its existing completion hold,
then retain the exact called-once assertion. Keep foreign work held while
proving that the memory-owned operation neither coalesces with it nor waits
for it. All task, transcript, completion and ownership checks remain intact.
No shared helper or production behavior changes.

Two-CPU pressure with a CPU contender passed 20 full-file runs (200 cases)
and three canonical 17-file CI envelopes (636 cases each). Five current
owner/sibling files passed 50 tests, including the separately landed
shutdown fixture repair. One-worker file wall was 32.490s; these existing
cases exercise real native task admission and transcript ownership.

Full original-lock changed checks passed in 268.032s, with formatting,
whitespace checks and independent P2 review clean. The separate harness
startup case is already repaired on main by 0589c8360b; keep its stronger
start-versus-settlement check.

Current-toolchain integration on Testbox run 35961104900 passed a fresh
full build (1095.958s), the canonical upstream harness (28.232s), and this
ownership file (22.792s). The lockfile changed for the native compiler
migration; this check preserves the previous pressure and shard evidence.
This commit is contained in:
Peter Steinberger 2026-09-23 23:19:10 -07:00
parent 9f4b6e9714
commit 3b1f037214
No known key found for this signature in database

View file

@ -237,7 +237,9 @@ describe("context-engine maintenance transcript ownership", () => {
async (executionMode) => {
await withTranscriptOwners(async ({ memory, durable, params, target }) => {
const release = createDeferredCore();
const foreignStarted = createDeferredCore();
const foreignMaintain = vi.fn(async () => {
foreignStarted.resolve();
await release.promise;
return { changed: false, rewrittenEntries: 0, bytesFreed: 0 };
});
@ -250,7 +252,8 @@ describe("context-engine maintenance transcript ownership", () => {
});
let run: Promise<unknown> | undefined;
try {
await vi.waitFor(() => expect(foreignMaintain).toHaveBeenCalledOnce());
await foreignStarted.promise;
expect(foreignMaintain).toHaveBeenCalledOnce();
const tasksBefore = listTasksForOwnerKey(target.sessionKey);
const maintain = vi.fn(async () => ({
changed: false,