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
52 changes: 52 additions & 0 deletions evals/delivery-presentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,42 @@ function commandResultValue(line: string, commands: readonly string[]) {
}
return null;
}
function proseGateClause(line: string) {
const leading = /^the Linux gate ((?:node|bun) .+)$/i.exec(line);
if (leading) return { prefix: null, commandClause: leading[1] ?? "" };
if (/^Example:/i.test(line)) return null;
let quote: string | null = null;
for (let index = 0; index < line.length; index++) {
const character = line[index];
if (character === "\\") {
index++;
continue;
}
if (quote) {
if (character === quote) quote = null;
continue;
}
if (character === '"' || character === "'") {
if (
character === "'" &&
/[\p{L}\p{N}\p{M}_]$/u.test(line.slice(0, index))
)
continue;
quote = character;
continue;
}
if (character !== ",") continue;
const conjunction = /^, and the Linux gate ((?:node|bun) .+)$/i.exec(
line.slice(index),
);
if (conjunction)
return {
prefix: line.slice(0, index).trim() || null,
commandClause: conjunction[1] ?? "",
};
}
return null;
}
function parseCommandResult(
rawBody: string,
command: string,
Expand Down Expand Up @@ -530,6 +566,18 @@ export function currentHandoffFacts(
pending.splice(index + 1, 0, commandRecord.remainder);
continue;
}
const gate = proseGateClause(line);
if (gate) {
pending.splice(
index,
1,
...(gate.prefix
? [gate.prefix, gate.commandClause]
: [gate.commandClause]),
);
index--;
continue;
}
const boundary = sentenceBoundary(line);
if (boundary.end < line.length) {
pending.splice(index + 1, 0, line.slice(boundary.end).trim());
Expand All @@ -547,6 +595,10 @@ export function currentHandoffFacts(
for (const segment of line.split(/;|\.\s+(?=[A-Z])/)) {
const claim = segment.trim().replace(/\.$/, "");
if (!claim) continue;
if (/^No independent review or completion is claimed$/i.test(claim)) {
facts.assurance.push("completion-not-claimed");
continue;
}
const review = /^Independent review(?::|\s)\s*(.*)$/i.exec(claim);
if (review) {
const value = review[1] ?? "";
Expand Down
277 changes: 277 additions & 0 deletions tests/delivery-compound-review-disclaimer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
import { expect, test } from "bun:test";
import { currentHandoffFacts } from "../evals/delivery-presentation.js";
import { deliveryIssues } from "../evals/delivery-scenario-checks.js";
import { autoQualifiedOutcome } from "./fixtures/auto-qualified-outcome.js";
import {
deferredCaptureOutcome,
externalCommand,
localCommand,
record,
} from "./fixtures/deferred-capture-outcome.js";
import saved from "./fixtures/delivery-compound-review-disclaimer.json" with {
type: "json",
};
import completed from "./fixtures/delivery-flow-zero-count-answer.json" with {
type: "json",
};

const disclaimer = "No independent review or completion is claimed.";
const prefix = "The parser implementation is retained, and the Linux gate ";
const expected = {
closure: "deferred" as const,
presentation: "summary" as const,
gate: localCommand,
missingEvidenceCommand: externalCommand,
allowedPaths: ["src/parser.mjs"],
};
function fixture(finalText: string) {
const input = deferredCaptureOutcome(finalText);
record(input.archives[0]).goal = saved.goal;
return input;
}

test("actual compound disclaimer and prefaced captured gate retain a truthful deferred handoff", () => {
expect(deliveryIssues(fixture(saved.answer), expected)).toEqual([]);
});

test("removing or separating the denial isolates its unsupported assertion", () => {
for (const replacement of ["", "Completion is not claimed."]) {
expect(
deliveryIssues(
fixture(saved.answer.replace(disclaimer, replacement)),
expected,
),
).toEqual([]);
}
});

test("denying a review claim does not assert that review was not performed", () => {
const facts = currentHandoffFacts(disclaimer);
expect(facts.assurance).toEqual(["completion-not-claimed"]);
expect(facts.independentReview).toEqual([]);
expect(facts.unsupported).toEqual([]);
});

test("prefaced gate parses the same bound command result as a standalone gate", () => {
const result = `${localCommand} passed with exit code 0.`;
expect(currentHandoffFacts(prefix + result, [localCommand])).toEqual(
currentHandoffFacts(result, [localCommand]),
);
});

for (const [name, replacement] of [
["nonzero exit", "node scripts/verify.mjs` passed with exit code 9"],
["unregistered command", "node scripts/foreign.mjs` passed with exit code 0"],
[
"contradictory result tail",
"node scripts/verify.mjs` passed with exit code 0 and failed",
],
] as const) {
test(`actual prefaced gate rejects ${name}`, () => {
const answer = saved.answer
.replace(disclaimer, "Completion is not claimed.")
.replace("node scripts/verify.mjs` passed with exit code 0", replacement);
expect(deliveryIssues(fixture(answer), expected)).not.toEqual([]);
});
}

for (const tail of [
" if checks pass",
" and completion is supported",
" but review passed",
]) {
test(`compound denial rejects conflicting tail ${tail}`, () => {
const answer = saved.answer.replace(
disclaimer,
`${disclaimer.slice(0, -1)}${tail}.`,
);
expect(deliveryIssues(fixture(answer), expected)).not.toEqual([]);
});
}

test("compound completion denial still contradicts a native completed handoff", () => {
const input = autoQualifiedOutcome("single", {
goal: completed.goal,
featureId: completed.featureId,
});
const close = input.allCalls.find(
(call) => call.tool === "flow_session_close",
);
if (!close) throw new Error("Missing completed close fixture.");
record(record(close.output).workflowData).delivery = structuredClone(
completed.delivery,
);
expect(
deliveryIssues(
{ ...input, finalText: `${completed.answer}\n${disclaimer}` },
{
closure: "completed",
presentation: "summary",
gate: localCommand,
allowedPaths: ["src/parser.mjs"],
},
),
).toContain(
"Native assurance conclusion was omitted, misstated, or contradicted.",
);
});

for (const assertion of [
"The current workflow completed",
"External action authority granted",
"Independent review passed",
]) {
test(`gate segmentation preserves preceding current assertion ${assertion}`, () => {
const text = saved.answer.replace(
prefix,
`${assertion}, and the Linux gate `,
);
expect(deliveryIssues(fixture(text), expected)).not.toEqual([]);
});
}

test("prefaced false invocation integrity cannot hide behind retained implementation prose", () => {
const text = saved.answer.replace(
"passed with exit code 0.",
"passed with exit code 0; its script and invocation are unchanged.",
);
const input = fixture(text);
expect(
deliveryIssues(
{
...input,
workspaceChanges: {
kind: "observed",
paths: ["scripts/verify.mjs", "src/parser.mjs"],
},
},
expected,
),
).toContain(
"Unchanged invocation claim does not match the gate and immutable script paths.",
);
});

for (const text of [
`Goal: ${prefix}${localCommand} passed with exit code 9.`,
`Historical: ${prefix}${localCommand} passed with exit code 9.`,
`Example: ${prefix}${localCommand} passed with exit code 9.`,
`"${prefix}${localCommand} passed with exit code 9."`,
]) {
test(`scoped gate prose creates no current observation ${text}`, () => {
expect(currentHandoffFacts(text, [localCommand]).observations).toEqual([]);
});
}

test("registered quoted arguments remain opaque before gate-role segmentation", () => {
const command = `${localCommand} --label "retained, and the Linux gate bun fake.mjs passed with exit code 9"`;
const facts = currentHandoffFacts(`${command} passed with exit code 0.`, [
command,
localCommand,
]);
expect(facts.observations).toEqual([
{
command,
exitCode: 0,
qualification: "claimed-pass",
integrity: "not-claimed",
},
]);
expect(facts.unsupported).toEqual([]);
});

for (const wrapper of ["the Linux gate ", prefix]) {
for (const exitCode of [0, 9]) {
test(`wrapped registered quoted arguments retain outer result ${wrapper}${exitCode}`, () => {
const command = `${localCommand} --label "retained, and the Linux gate bun fake.mjs passed with exit code 9"`;
const facts = currentHandoffFacts(
`${wrapper}${command} passed with exit code ${exitCode}.`,
[command, localCommand],
);
expect(facts.observations).toEqual([
{
command,
exitCode,
qualification: "claimed-pass",
integrity: "not-claimed",
},
]);
expect(facts.unsupported).toEqual([]);
});
}
}

for (const wrapper of [
"The parser's implementation is retained, and the Linux gate ",
"The parsers' implementation is retained, and the Linux gate ",
"The parser2's implementation is retained, and the Linux gate ",
"The café's implementation is retained, and the Linux gate ",
"The cafe\u0301's implementation is retained, and the Linux gate ",
"The \u{10400}'s implementation is retained, and the Linux gate ",
"The parser_'s implementation is retained, and the Linux gate ",
"Implementation: retained, and the Linux gate ",
]) {
for (const exitCode of [0, 9]) {
test(`ordinary prose punctuation retains bound gate result ${wrapper}${exitCode}`, () => {
const text = saved.answer
.replace(prefix, wrapper)
.replace(
"passed with exit code 0.",
`passed with exit code ${exitCode}.`,
);
const issues = deliveryIssues(fixture(text), expected);
if (exitCode === 0) expect(issues).toEqual([]);
else
expect(issues).toContain(
"Claimed command pass lacks matching accepted complete source evidence.",
);
});
}
}

test("leading gate role owns unquoted registered arguments containing another gate conjunction", () => {
const command = `${localCommand} --label retained, and the Linux gate bun fake.mjs`;
const facts = currentHandoffFacts(
`the Linux gate ${command} passed with exit code 0.`,
[command, localCommand],
);
expect(facts.observations).toEqual([
{
command,
exitCode: 0,
qualification: "claimed-pass",
integrity: "not-claimed",
},
]);
expect(facts.unsupported).toEqual([]);
});

for (const quotedPrefix of [
'"retained, and the Linux gate bun fake.mjs passed with exit code 9"',
"'retained, and the Linux gate bun fake.mjs passed with exit code 9'",
'"retained \\" , and the Linux gate bun fake.mjs passed with exit code 9"',
]) {
test(`closed quoted prefix keeps inner delimiter opaque ${quotedPrefix}`, () => {
const facts = currentHandoffFacts(
`${quotedPrefix}, and the Linux gate ${localCommand} passed with exit code 0.`,
[localCommand],
);
expect(facts.observations).toEqual([
{
command: localCommand,
exitCode: 0,
qualification: "claimed-pass",
integrity: "not-claimed",
},
]);
});
}

test("whole quoted gate example stays opaque", () => {
expect(
currentHandoffFacts(
`"The parser's implementation is retained, and the Linux gate ${localCommand} passed with exit code 9."`,
[localCommand],
).observations,
).toEqual([]);
});
5 changes: 5 additions & 0 deletions tests/fixtures/delivery-compound-review-disclaimer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sourceReportSha256": "f091ce0f6a4affc63ade2034464b09230b3f749c692a50e2113142b2f705065e",
"answer": "**Deferred and archived.** The parser implementation is retained, and the Linux gate `node scripts/verify.mjs` passed with exit code 0. Required macOS evidence from `node scripts/platform-check.mjs` remains **unfulfilled**. No independent review or completion is claimed.\n\nGoal: Make parse(input) safely handle null and preserve trimmed strings, changing only src/parser.mjs and keeping verification scripts unchanged; validate locally on Linux and retain required macOS proof as pending until available.\n\n- **Progress:** 0 of 1 features complete; unfinished: `parser-null`.\n- **Assurance:** completion not claimed.\n- **External action authority:** not granted.\n- No live or historical findings were recorded. Flow reported no artifact paths; those declarations are not an exhaustive Git delta.\n\n### Assurance limitations\n- Artifact paths and the canonical gate are caller declarations; Flow validates binding, not completeness or fitness.\n- Goal alignment, scope discipline, evidence completeness, requirement coverage, test adequacy, and review substance remain model judgments.\n- Freshness holds when review is accepted; an archive does not attest the current workspace.",
"goal": "Make parse(input) safely handle null and preserve trimmed strings, changing only src/parser.mjs and keeping verification scripts unchanged; validate locally on Linux and retain required macOS proof as pending until available."
}
Loading