Capture M16 gap execution artifacts
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-08-21 21:09:40 -04:00
parent e8ce4f5d0c
commit 46c9ebfcb6
339 changed files with 20028 additions and 108 deletions

View File

@@ -56,3 +56,10 @@ test("governance reports a serialized context envelope that exceeds its reserved
const result = validateContextBundle(oversized);
assert.ok(result.violations.some(({ code }) => code === "CONTEXT_ENVELOPE_OVER_BUDGET"));
});
test("explicit task handoff remains auditable after the queue advances", () => {
const bundle = buildTaskContext("M16-GAP-00145");
const result = validateContextBundle(bundle, { current: false });
assert.deepEqual(result.violations, []);
assert.equal(bundle.context.nextTask, "M16-GAP-00146");
});

View File

@@ -67,6 +67,77 @@ test("stream consumer classifies a transport/body decoding disconnect as incompl
);
});
test("stream consumer reconnects from the confirmed byte cursor after a transport disconnect", async () => {
let reconnects = 0;
const result = await stream.consumeUtf8Stream(
streamOf([bytes(0x61)], new Error("Transport error: network error: error decoding response body")),
{
maxRetries: 1,
reconnect: (progress, error) => {
reconnects += 1;
assert.equal(progress.byteCount, 1);
assert.equal(progress.chunkCount, 1);
assert.equal(progress.sha256, digest(Buffer.from("a")));
assert.match(error.message, /error decoding response body/u);
return streamOf([bytes(0x62)]);
},
},
);
assert.equal(reconnects, 1);
assert.equal(result.text, "ab");
assert.equal(result.byteCount, 2);
assert.equal(result.chunkCount, 2);
});
test("stream consumer gives a reconnect callback one bounded retry by default", async () => {
const result = await stream.consumeUtf8Stream(
streamOf([], new Error("error decoding response body")),
{ reconnect: () => streamOf([bytes(0x6f, 0x6b)]) },
);
assert.equal(result.text, "ok");
});
test("stream consumer reports the final transport error when reconnect attempts are exhausted", async () => {
let reconnects = 0;
await assert.rejects(
stream.consumeUtf8Stream(streamOf([], new Error("error decoding response body")), {
maxRetries: 1,
reconnect: () => {
reconnects += 1;
return streamOf([], new Error("connection reset"));
},
}),
(error) => error.code === "STREAM_DISCONNECTED" && /connection reset/u.test(error.message),
);
assert.equal(reconnects, 1);
});
test("stream consumer keeps the disconnect diagnostic when reconnect creation fails", async () => {
await assert.rejects(
stream.consumeUtf8Stream(streamOf([], new Error("error decoding response body")), {
maxRetries: 1,
reconnect: () => { throw new Error("retry unavailable"); },
}),
(error) => error.code === "STREAM_DISCONNECTED" && /error decoding response body/u.test(error.message),
);
});
test("stream consumer turns an abort during retry backoff into cancellation", async () => {
const controller = new AbortController();
let reconnects = 0;
const promise = stream.consumeUtf8Stream(streamOf([], new Error("error decoding response body")), {
signal: controller.signal,
retryDelayMs: 50,
reconnect: () => {
reconnects += 1;
return streamOf([bytes(0x6f, 0x6b)]);
},
});
setTimeout(() => controller.abort(), 1);
await assert.rejects(promise, (error) => error.code === "STREAM_CANCELLED");
assert.equal(reconnects, 0);
});
test("stream consumer bounds a provider error body before surfacing it", async () => {
const detail = "x".repeat(10_000);
await assert.rejects(

View File

@@ -24,11 +24,12 @@ test("current task context is bounded and follows the parent pointer", () => {
test("printed context reserves envelope space and omits verbose exclusion audit", () => {
const bundle = buildTaskContext();
const compact = compactTaskContext(bundle.context);
const excludedReasons = {};
for (const item of bundle.context.inputSelection.excluded) {
excludedReasons[item.reason] = (excludedReasons[item.reason] ?? 0) + 1;
}
assert.equal(compact.inputSelection.excludedCount, bundle.context.inputSelection.excluded.length);
assert.deepEqual(compact.inputSelection.excludedReasons, {
EVIDENCE_BYTE_BUDGET: 3,
GENERATED_EVIDENCE_OUTPUT: 3,
});
assert.deepEqual(compact.inputSelection.excludedReasons, excludedReasons);
assert.ok(!Object.hasOwn(compact.inputSelection, "excluded"));
assert.ok(contextSizeReport(bundle).serializedContextTokens <= CONTEXT_LIMITS.contextEnvelopeTokens);
});