chore: sync current main into the CI baseline repair

Validate the formatting and reconstruction fixture repairs against the
latest merged feature and correctness changes.

Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
N0zoM1z0
2026-10-13 15:48:34 +00:00
co-authored by Kaoru0822
33 changed files with 1306 additions and 474 deletions
@@ -429,7 +429,12 @@ export const addSourceMapDirectives = (
end === null
)
continue;
const commentSource = source.slice(start, end);
// The parser owns comment boundaries. Exclude only the closing block
// delimiter; an asterisk elsewhere remains part of the declared URL.
const commentSource = source.slice(
start,
comment.type === "CommentBlock" ? end - 2 : end,
);
if (
!(commentSource.startsWith("//") || commentSource.startsWith("/*")) ||
!(commentSource[2] === "#" || commentSource[2] === "@")
@@ -449,9 +454,7 @@ export const addSourceMapDirectives = (
const urlOffset = commentSource.slice(equalsStart + 1).search(/\S/u);
if (urlOffset === -1) continue;
const declaredStart = equalsStart + 1 + urlOffset;
const terminator = commentSource
.slice(declaredStart)
.search(commentSource.startsWith("//") ? /\s/u : /[\s*]/u);
const terminator = commentSource.slice(declaredStart).search(/\s/u);
const declaredEnd =
terminator === -1 ? commentSource.length : declaredStart + terminator;
if (declaredEnd === declaredStart) continue;
@@ -72,10 +72,10 @@ describe("source map directives", () => {
it("preserves Unicode whitespace and URL terminator boundaries", () => {
const source =
"ğ/*@\u00a0sourceMappingURL\u2003=\ufeffapp.js.map* ignored */";
const declaredEnd = source.indexOf("* ignored");
const declaredEnd = source.indexOf(" ignored");
expect(analyzeJavaScriptStaticSource(source).source_map_urls).toEqual([
{
declared_url: "app.js.map",
declared_url: "app.js.map*",
location: {
start: { line: 1, column: 1 },
end: { line: 1, column: declaredEnd },
@@ -84,6 +84,29 @@ describe("source map directives", () => {
]);
});
it.each([
["/*#", "app*part.js.map", " */"],
["/*@", "*part.js.map", "*/"],
["/*#", "app.js.map*", "*/"],
["/*#", "**part.js.map", " */"],
["/*#", "app.js.map", "*/"],
["//#", "app*part.js.map", ""],
])("preserves the URL and range in %s %s%s", (marker, url, suffix) => {
const directive = marker + " sourceMappingURL=" + url;
const result = analyzeJavaScriptStaticSource(
"export const value = 1;\n" + directive + suffix,
);
expect(result.source_map_urls).toEqual([
{
declared_url: url,
location: {
start: { line: 2, column: 0 },
end: { line: 2, column: directive.length },
},
},
]);
});
it("reports nothing when no directive is present", () => {
expect(sourceMapUrls("const value = 1;")).toEqual([]);
});
+2
View File
@@ -1,4 +1,5 @@
import { z } from "zod";
import { providerSchema } from "../evidence.js";
import {
compareUnicodeCodePoints,
@@ -115,6 +116,7 @@ export const nativeMetadataEvidenceSchema = z.strictObject({
"decompiler",
]),
description: z.string().min(1),
provider: providerSchema.optional(),
location: nativeMetadataLocationSchema,
artifact_path: z.string().min(1).nullable().default(null),
artifact_sha256: z
@@ -143,3 +143,13 @@ export const completeReconstructionCoverageData = () => {
],
});
};
/** Complete workspace with its first verifier result and boundary narrowed once. */
export const completeReconstructionCoverageFixture = () => {
const workspace = completeReconstructionCoverageData();
const result = workspace.verifier_results[0];
const boundary = workspace.boundaries[0];
if (result === undefined || boundary === undefined)
throw new Error("Expected complete reconstruction coverage fixture");
return { workspace, result, boundary };
};
+28 -64
View File
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import {
completeReconstructionCoverageData,
completeReconstructionCoverageFixture,
RECONSTRUCTION_COVERAGE_NOW,
reconstructionCoverageEvidenceId,
} from "./reconstructionCoverage.fixture.js";
@@ -288,11 +289,8 @@ describe("reconstruction coverage verifier selection", () => {
describe("reconstruction coverage conflicting latest verifier observations", () => {
it("keeps conflicting tied assessments unknown regardless of input order", () => {
const workspace = completeReconstructionCoverageData();
const result = workspace.verifier_results[0];
const boundary = workspace.boundaries[0];
if (result === undefined || boundary === undefined)
throw new Error("Expected complete reconstruction coverage fixture");
const { workspace, result, boundary } =
completeReconstructionCoverageFixture();
const failed = {
...result,
status: "fail" as const,
@@ -338,11 +336,8 @@ describe("reconstruction coverage conflicting latest verifier observations", ()
describe("reconstruction coverage equivalent latest verifier observations", () => {
it("coalesces equivalent equal-instant observations and retains all evidence", () => {
const workspace = completeReconstructionCoverageData();
const result = workspace.verifier_results[0];
const boundary = workspace.boundaries[0];
if (result === undefined || boundary === undefined)
throw new Error("Expected complete reconstruction coverage fixture");
const { workspace, result, boundary } =
completeReconstructionCoverageFixture();
const first = {
...result,
observed_at: "2026-07-16T11:00:00.123456789012345678900Z",
@@ -388,11 +383,8 @@ describe("reconstruction coverage equivalent latest verifier observations", () =
describe("reconstruction coverage verifier timestamp selection", () => {
it("lets a later unambiguous observation supersede an older tie", () => {
const workspace = completeReconstructionCoverageData();
const result = workspace.verifier_results[0];
const boundary = workspace.boundaries[0];
if (result === undefined || boundary === undefined)
throw new Error("Expected complete reconstruction coverage fixture");
const { workspace, result, boundary } =
completeReconstructionCoverageFixture();
const failed = { ...result, status: "fail" as const };
const latestPass = {
...result,
@@ -412,50 +404,14 @@ describe("reconstruction coverage verifier timestamp selection", () => {
).toMatchObject({ status: "ready", reasons: [] });
});
it("orders offset-bearing verifier timestamps chronologically", () => {
const workspace = completeReconstructionCoverageData();
const result = workspace.verifier_results[0];
if (result === undefined)
throw new Error("Expected fixture verifier result");
const semantic = workspace;
const changed = createReconstructionCoverageData({
...semantic,
verifier_results: [
{ ...result, observed_at: "2026-07-16T08:00:00.000Z" },
{
...result,
observed_at: "2026-07-16T04:00:00.000-05:00",
status: "fail",
},
],
});
expect(
evaluateReconstructionClosure(
changed,
"replacement.cli",
RECONSTRUCTION_COVERAGE_NOW,
),
).toMatchObject({
status: "failed",
reasons: [expect.objectContaining({ code: "verifier-failed" })],
});
});
it("selects the later result when timestamps differ below millisecond precision", () => {
const workspace = completeReconstructionCoverageData();
const result = workspace.verifier_results[0];
if (result === undefined)
throw new Error("Expected fixture verifier result");
/** Evaluate a workspace whose newest verifier observation fails the closure. */
const expectNewestObservationFails = (passedAt: string, failedAt: string) => {
const { workspace, result } = completeReconstructionCoverageFixture();
const changed = createReconstructionCoverageData({
...workspace,
verifier_results: [
{ ...result, observed_at: "2026-07-16T11:00:00.1231Z" },
{
...result,
observed_at: "2026-07-16T11:00:00.1239Z",
status: "fail",
},
{ ...result, observed_at: passedAt },
{ ...result, observed_at: failedAt, status: "fail" },
],
});
@@ -469,15 +425,26 @@ describe("reconstruction coverage verifier timestamp selection", () => {
status: "failed",
reasons: [expect.objectContaining({ code: "verifier-failed" })],
});
};
it("orders offset-bearing verifier timestamps chronologically", () => {
expectNewestObservationFails(
"2026-07-16T08:00:00.000Z",
"2026-07-16T04:00:00.000-05:00",
);
});
it("selects the later result when timestamps differ below millisecond precision", () => {
expectNewestObservationFails(
"2026-07-16T11:00:00.1231Z",
"2026-07-16T11:00:00.1239Z",
);
});
});
describe("reconstruction coverage verifier future timestamps", () => {
it("treats an observation beyond millisecond-precision now as future", () => {
const workspace = completeReconstructionCoverageData();
const result = workspace.verifier_results[0];
if (result === undefined)
throw new Error("Expected fixture verifier result");
const { workspace, result } = completeReconstructionCoverageFixture();
const changed = createReconstructionCoverageData({
...workspace,
verifier_results: [
@@ -505,10 +472,7 @@ describe("reconstruction coverage verifier future timestamps", () => {
});
it("rejects verifier observations from the future", () => {
const workspace = completeReconstructionCoverageData();
const result = workspace.verifier_results[0];
if (result === undefined)
throw new Error("Expected fixture verifier result");
const { workspace, result } = completeReconstructionCoverageFixture();
const semantic = workspace;
const changed = createReconstructionCoverageData({
...semantic,