Skip to content

Commit 6010a57

Browse files
test(file-safety,core): land the sweep assertions that kill the 1910 survivors
The round-U33 changed-code sweep left 54 surviving mutants whose behaviour no shipped test pinned. The controls that killed them move into the shipped specs here: 48 tests into services/file-safety/__tests__/safeWriteText.spec.ts and 13 byte-offset cases into core/tools/__tests__/applyDiffTool.failureReporting.spec.ts. Each test keeps the assertion shape the control proved and names the mutant line it kills. K313b carries one widened realpath annotation because the package tsconfig rejects the sweep annotation; its behaviour and assertions are unchanged. Re-run against every mutant after the port: 48 of 48 safeWriteText arms and 5 of 5 ApplyDiffTool arms now die under the shipped specs. Lines 402, 572 and 692 stay reported rather than ported, and equivalence at 475, 476, 490, 714, 758 plus the line 474 mutant that does not reproduce here stay named in the PR comment. SafeWriteText.spec 75 to 123 tests, failureReporting.spec 46 to 59 tests. No shipped source file changes, no changeset, and the gate still prices the extension package at 355 changed executable lines against merge base 73931fe.
1 parent c137906 commit 6010a57

2 files changed

Lines changed: 630 additions & 0 deletions

File tree

‎src/core/tools/__tests__/applyDiffTool.failureReporting.spec.ts‎

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,4 +648,147 @@ describe("ApplyDiffTool failure reporting", () => {
648648
expect(output).not.toContain("--- Diff block")
649649
})
650650
})
651+
652+
// ApplyDiffTool.ts lines 108-110 hold the three comparisons that decide whether a replacement
653+
// character already in the file is stepped over or reported as the failure position. Each byte
654+
// sequence below was run through the tool in round U35 and the offset it prints is asserted here.
655+
// The offsets each case must not print are the offsets the surviving mutants at those lines print
656+
// instead; the changed-code mutation report numbers those rows one higher than the head lines
657+
// (printed 109, 110, 111 for head 108, 109, 110), the shift I measured and named on the triage
658+
// comment, so the bytes and the printed offset are the anchors, not the report line number. The
659+
// mutant each case kills is named above it. The 0x41 and 0x3f cases are the shape where the
660+
// replacement character is not at the start of the file, so the reported offset is one.
661+
describe("the guard that steps past an encoded replacement character", () => {
662+
async function runBytesFor(bytes: Buffer): Promise<string> {
663+
mockedReadFile.mockResolvedValue(bytes)
664+
const applyDiff = vi.fn().mockResolvedValue({ success: true, content: "unused" })
665+
mockTask.diffStrategy = { getName: () => "test", applyDiff }
666+
await applyDiffTool.execute({ path: testFilePath, diff: buildDiffContent(1) }, mockTask, {
667+
askApproval: mockAskApproval,
668+
handleError: mockHandleError,
669+
toolCallId: "tool-call-1",
670+
pushToolResult: vi.fn((result: ToolResponse) => {
671+
pushedResult = result
672+
}),
673+
})
674+
return String(pushedResult ?? "")
675+
}
676+
677+
// kills line 108 outer_or_and, line 108 inner_or_and, line 109 clauseB_false
678+
it("reports offset 0 for the bytes 0xef 0xef 0xbd", async () => {
679+
const output = await runBytesFor(Buffer.from([0xef, 0xef, 0xbd]))
680+
681+
expect(output).toContain("is not valid UTF-8")
682+
expect(output).toContain("first undecodable byte at offset 0).")
683+
expect(output).not.toContain("offset 3)")
684+
})
685+
686+
// kills line 108 outer_or_and, line 110 clauseC_false
687+
it("reports offset 0 for the bytes 0xef 0xbf 0xef", async () => {
688+
const output = await runBytesFor(Buffer.from([0xef, 0xbf, 0xef]))
689+
690+
expect(output).toContain("is not valid UTF-8")
691+
expect(output).toContain("first undecodable byte at offset 0).")
692+
expect(output).not.toContain("offset 3)")
693+
})
694+
695+
// kills line 108 outer_or_and, line 110 clauseC_false
696+
it("reports offset 0 for the bytes 0xef 0xbf 0xff", async () => {
697+
const output = await runBytesFor(Buffer.from([0xef, 0xbf, 0xff]))
698+
699+
expect(output).toContain("is not valid UTF-8")
700+
expect(output).toContain("first undecodable byte at offset 0).")
701+
expect(output).not.toContain("offset 3)")
702+
})
703+
704+
// kills line 108 outer_or_and, line 110 clauseC_false
705+
it("reports offset 0 for the bytes 0xef 0xbf 0x41", async () => {
706+
const output = await runBytesFor(Buffer.from([0xef, 0xbf, 0x41]))
707+
708+
expect(output).toContain("is not valid UTF-8")
709+
expect(output).toContain("first undecodable byte at offset 0).")
710+
expect(output).not.toContain("offset 4)")
711+
})
712+
713+
// kills line 108 outer_or_and, line 110 clauseC_false
714+
it("reports offset 0 for the bytes 0xef 0xbf 0x3f", async () => {
715+
const output = await runBytesFor(Buffer.from([0xef, 0xbf, 0x3f]))
716+
717+
expect(output).toContain("is not valid UTF-8")
718+
expect(output).toContain("first undecodable byte at offset 0).")
719+
expect(output).not.toContain("offset 4)")
720+
})
721+
722+
// kills line 108 outer_or_and, line 108 inner_or_and, line 109 clauseB_false
723+
it("reports offset 0 for the bytes 0xef 0xff 0xbd", async () => {
724+
const output = await runBytesFor(Buffer.from([0xef, 0xff, 0xbd]))
725+
726+
expect(output).toContain("is not valid UTF-8")
727+
expect(output).toContain("first undecodable byte at offset 0).")
728+
expect(output).not.toContain("offset 3)")
729+
})
730+
731+
// kills line 108 outer_or_and, line 108 inner_or_and, line 109 clauseB_false
732+
it("reports offset 0 for the bytes 0xef 0x41 0xbd", async () => {
733+
const output = await runBytesFor(Buffer.from([0xef, 0x41, 0xbd]))
734+
735+
expect(output).toContain("is not valid UTF-8")
736+
expect(output).toContain("first undecodable byte at offset 0).")
737+
expect(output).not.toContain("offset 4)")
738+
})
739+
740+
// kills line 108 outer_or_and, line 108 inner_or_and, line 109 clauseB_false
741+
it("reports offset 0 for the bytes 0xef 0x3f 0xbd", async () => {
742+
const output = await runBytesFor(Buffer.from([0xef, 0x3f, 0xbd]))
743+
744+
expect(output).toContain("is not valid UTF-8")
745+
expect(output).toContain("first undecodable byte at offset 0).")
746+
expect(output).not.toContain("offset 4)")
747+
})
748+
749+
// kills line 108 outer_or_and, line 110 clauseC_false
750+
it("reports offset 1 for the bytes 0x41 0xef 0xbf", async () => {
751+
const output = await runBytesFor(Buffer.from([0x41, 0xef, 0xbf]))
752+
753+
expect(output).toContain("is not valid UTF-8")
754+
expect(output).toContain("first undecodable byte at offset 1).")
755+
expect(output).not.toContain("offset 4)")
756+
})
757+
758+
// kills line 108 outer_or_and, line 110 clauseC_false
759+
it("reports offset 1 for the bytes 0x3f 0xef 0xbf", async () => {
760+
const output = await runBytesFor(Buffer.from([0x3f, 0xef, 0xbf]))
761+
762+
expect(output).toContain("is not valid UTF-8")
763+
expect(output).toContain("first undecodable byte at offset 1).")
764+
expect(output).not.toContain("offset 4)")
765+
})
766+
767+
// kills line 108 inner_or_and, line 108 clauseA_false
768+
it("reports offset 0 for the bytes 0xbf 0xbf 0xbd", async () => {
769+
const output = await runBytesFor(Buffer.from([0xbf, 0xbf, 0xbd]))
770+
771+
expect(output).toContain("is not valid UTF-8")
772+
expect(output).toContain("first undecodable byte at offset 0).")
773+
expect(output).not.toContain("offset 3)")
774+
})
775+
776+
// kills line 108 inner_or_and, line 108 clauseA_false
777+
it("reports offset 0 for the bytes 0xbd 0xbf 0xbd", async () => {
778+
const output = await runBytesFor(Buffer.from([0xbd, 0xbf, 0xbd]))
779+
780+
expect(output).toContain("is not valid UTF-8")
781+
expect(output).toContain("first undecodable byte at offset 0).")
782+
expect(output).not.toContain("offset 3)")
783+
})
784+
785+
// kills line 108 inner_or_and, line 108 clauseA_false
786+
it("reports offset 0 for the bytes 0xff 0xbf 0xbd", async () => {
787+
const output = await runBytesFor(Buffer.from([0xff, 0xbf, 0xbd]))
788+
789+
expect(output).toContain("is not valid UTF-8")
790+
expect(output).toContain("first undecodable byte at offset 0).")
791+
expect(output).not.toContain("offset 3)")
792+
})
793+
})
651794
})

0 commit comments

Comments
 (0)