Merge commit '5100a1a1a56b810c8246b8c7ed19ff42c4d9dbe1' into fix/ci-duplicate-boundaries-1603

This commit is contained in:
N0zoM1z0
2026-10-11 03:50:21 +08:00
120 changed files with 5518 additions and 1142 deletions
@@ -252,6 +252,65 @@ describe("trace-dylib-resolution CLI", () => {
);
});
cliTest(
"retains directory requirements when resolving dylib install names",
async ({ cli }) => {
const directory = await createTestTempDirectory("rea-dylib-path-cli-");
const names = [
"@loader_path/lib/libhelper.dylib/",
"@loader_path/lib/libhelper.dylib/.",
"@rpath/libhelper.dylib/",
"@rpath/libhelper.dylib/.",
"@rpath/",
"@loader_path/lib/./libhelper.dylib",
"@loader_path/lib//libhelper.dylib",
];
await writeFiles(directory, {
tool: machoImage({
commands: [
buildVersionCommand(1),
rpathCommand("@loader_path/lib/libhelper.dylib"),
rpathCommand("@loader_path/lib"),
...names.map((name) => dylibCommand(LC.LOAD_DYLIB, name)),
],
}),
"lib/libhelper.dylib": machoImage({
fileType: FILE_TYPE.dylib,
commands: [buildVersionCommand(1)],
}),
});
const result = await cli.run({
arguments: ["trace-dylib-resolution", join(directory, "tool"), "--json"],
environment: ENVIRONMENT,
});
expect(result.exitCode, JSON.stringify(result.json)).toBe(0);
const trace = dylibResolutionResultSchema.parse(
parseEvidence(result.json).normalized_result,
);
expect(
trace.edges.map(({ install_name, candidates, resolution }) => ({
install_name,
outcome: candidates[0]?.outcome,
resolution,
})),
).toEqual(
names.map((name, index) => ({
install_name: name,
outcome: index < 5 ? "absent" : "resolved",
resolution:
index < 5
? { status: "unresolved", image: null }
: { status: "resolved", image: "lib/libhelper.dylib" },
})),
);
expect(
trace.findings.map(({ kind, edge_index }) => [kind, edge_index]),
).toEqual(
[0, 1, 2, 3, 4].map((index) => ["required-load-unresolved", index]),
);
},
);
describe.skipIf(process.getuid?.() === 0)(
"trace-dylib-resolution permissions",
() => {
@@ -0,0 +1,96 @@
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect } from "vitest";
import { createEvidence } from "../../../src/domain/evidence.js";
import { createEvidenceBundle } from "../../../src/domain/evidenceBundle.js";
import {
createResidualUnknown,
updateResidualUnknown,
} from "../../../src/domain/residualUnknown.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
const revisionBundle = () => {
const records = ["open", "investigate"].map((operation) =>
createEvidence(
undefined,
{ id: "fixture", name: "Fixture", version: "1" },
{ operation, parameters: {}, result: { observed: operation } },
),
);
const [opened, investigated] = records;
if (opened === undefined || investigated === undefined)
throw new Error("Missing mutation Evidence");
const details = {
severity: "high" as const,
supporting_evidence_ids: [],
contradicting_evidence_ids: [],
required_authority: null,
required_confidence: "observed" as const,
required_environment: null,
recommended_probes: [],
relationships: [],
};
const initial = createResidualUnknown(
{ question: "How is this input handled?", domain: "protocol", ...details },
opened.evidence_id,
null,
);
const revised = updateResidualUnknown(
initial,
{
unknown_id: initial.unknown_id,
expected_revision: initial.revision,
status: "investigating",
...details,
resolution: null,
},
investigated.evidence_id,
);
return createEvidenceBundle(records, [initial, revised]);
};
cliTest(
"reports standalone import counts for every unknown revision",
async ({ cli }) => {
const root = await createTestTempDirectory("rea-evidence-import-");
const path = join(root, "bundle.json");
await writeFile(path, JSON.stringify(revisionBundle()));
const result = await cli.run({
arguments: ["evidence-import", path, "--json"],
});
expect(result.exitCode).toBe(0);
expect(result.json).toEqual({ imported: 2, unknowns_added: 2, total: 2 });
},
);
cliTest(
"rejects altered Evidence and incomplete unknown history before reporting counts",
async ({ cli }) => {
const root = await createTestTempDirectory("rea-evidence-import-invalid-");
const path = join(root, "bundle.json");
const bundle = revisionBundle();
for (const invalid of [
{
...bundle,
records: bundle.records.map((record) => ({
...record,
normalized_result: "altered",
})),
},
{ ...bundle, unknowns: bundle.unknowns.slice(1) },
]) {
await writeFile(path, JSON.stringify(invalid));
const result = await cli.run({
arguments: ["evidence-import", path, "--json"],
});
expect(result.exitCode).toBe(1);
expect(result.json).toMatchObject({
code: "evidence_integrity_mismatch",
});
expect(result.json).not.toHaveProperty("imported");
}
},
);