Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11d295eeab | ||
|
|
a9195c3a98 | ||
|
|
0d31902b7f | ||
|
|
ccc009412e | ||
|
|
0d2bb5fb09 | ||
|
|
47dd84ea69 | ||
|
|
4e829cea2f | ||
|
|
bf30b081db | ||
|
|
15efa61149 | ||
|
|
70435de2c6 | ||
|
|
1b3371ad7f | ||
|
|
c7fdd7e153 | ||
|
|
3c794a5cc0 | ||
|
|
16caa5ca9b | ||
|
|
2a6bef5589 | ||
|
|
cace19caad | ||
|
|
87b7bf8db1 | ||
|
|
3b66532e26 | ||
|
|
3ad063b454 | ||
|
|
69485e27f7 |
@@ -209,9 +209,11 @@ native/runtime questions retain their own authority and coverage.
|
|||||||
Names and semantic labels do not establish durable member identity. Comparison
|
Names and semantic labels do not establish durable member identity. Comparison
|
||||||
preserves observed differences, structural inferences, and unknowns separately.
|
preserves observed differences, structural inferences, and unknowns separately.
|
||||||
|
|
||||||
Cross-version matching first prefers exact CIL/signature identity. When that
|
Cross-version matching first prefers exact raw CIL/signature identity, with
|
||||||
does not match, it pairs an exact declared type, method name, and raw signature
|
equal decoded fingerprints. Equal decoded fingerprints alone cannot establish
|
||||||
before trying structural body shape. The exact-signature key uses names only
|
an exact match: they omit switch targets and collapse distinct NaN encodings.
|
||||||
|
When that does not match, it pairs an exact declared type, method name, and raw
|
||||||
|
signature before trying structural body shape. The exact-signature key uses names only
|
||||||
as part of that full tuple; names alone never select a pair. Duplicate tuples
|
as part of that full tuple; names alone never select a pair. Duplicate tuples
|
||||||
remain ambiguous rather than being paired by token order. Fields follow the
|
remain ambiguous rather than being paired by token order. Fields follow the
|
||||||
same exact tiers. The raw signature is exact whether or not REA decoded it, so
|
same exact tiers. The raw signature is exact whether or not REA decoded it, so
|
||||||
@@ -222,8 +224,11 @@ unpaired member, one-sided or ambiguous, with the same declared type and name
|
|||||||
whose signature was not decoded.
|
whose signature was not decoded.
|
||||||
|
|
||||||
For a matched method, an unavailable or partial body makes body-shape facets
|
For a matched method, an unavailable or partial body makes body-shape facets
|
||||||
unknown while preserving observed signature differences. Structural identity
|
unknown while preserving observed signature differences. For complete bodies,
|
||||||
compares normalized signatures, the limited decoded-CIL tuple fingerprint,
|
a difference in either the raw CIL digest or the decoded fingerprint is reported
|
||||||
|
in the `cil` dimension, including reordered switch targets with equal decoded
|
||||||
|
fingerprints. Structural identity compares normalized signatures, the limited
|
||||||
|
decoded-CIL tuple fingerprint,
|
||||||
constants, and bounded shape context. It reports all candidates at the winning
|
constants, and bounded shape context. It reports all candidates at the winning
|
||||||
score and remains ambiguous when the evidence does not distinguish them. The
|
score and remains ambiguous when the evidence does not distinguish them. The
|
||||||
digest does not itself remap metadata tokens.
|
digest does not itself remap metadata tokens.
|
||||||
@@ -360,8 +365,8 @@ Opcode names retain short/long forms and prefix opcodes. This makes the value a
|
|||||||
reproducible decoded-tuple fingerprint, not a canonical semantic CIL identity:
|
reproducible decoded-tuple fingerprint, not a canonical semantic CIL identity:
|
||||||
it does not resolve tokens across MVIDs, does not commit full control flow or
|
it does not resolve tokens across MVIDs, does not commit full control flow or
|
||||||
exception semantics, and does not replace the raw CIL digest. Cross-build
|
exception semantics, and does not replace the raw CIL digest. Cross-build
|
||||||
comparison uses the value only as one unique-only structural tier and reports
|
comparison requires equal raw CIL digests as well for exact CIL/signature
|
||||||
ambiguity when that evidence is insufficient.
|
matches and reports ambiguity when structural evidence is insufficient.
|
||||||
|
|
||||||
For example, a decoded `nop; ret` body serializes exactly as
|
For example, a decoded `nop; ret` body serializes exactly as
|
||||||
`[["nop","none",null],["ret","none",null]]` and has digest
|
`[["nop","none",null],["ret","none",null]]` and has digest
|
||||||
|
|||||||
@@ -162,14 +162,21 @@ const resolveSourceHead = async (
|
|||||||
// The library probes readFile() without a path to detect promise APIs.
|
// The library probes readFile() without a path to detect promise APIs.
|
||||||
// Reject that invocation without attributing it to a source read.
|
// Reject that invocation without attributing it to a source read.
|
||||||
if (path === undefined)
|
if (path === undefined)
|
||||||
throw new TypeError("Git filesystem read requires a path");
|
throw new TypeError("Git metadata path is required");
|
||||||
try {
|
try {
|
||||||
const bytes = await readMetadataBytes(path);
|
const bytes = await readMetadataBytes(path);
|
||||||
const encoding =
|
const encoding =
|
||||||
typeof options === "string" ? options : options?.encoding;
|
typeof options === "string"
|
||||||
return encoding === undefined || encoding === null
|
? options
|
||||||
? bytes
|
: typeof options === "object" &&
|
||||||
: bytes.toString(encoding);
|
options !== null &&
|
||||||
|
"encoding" in options
|
||||||
|
? options.encoding
|
||||||
|
: undefined;
|
||||||
|
if (encoding === undefined || encoding === null) return bytes;
|
||||||
|
if (typeof encoding !== "string" || !Buffer.isEncoding(encoding))
|
||||||
|
throw new TypeError("Unsupported Git metadata text encoding");
|
||||||
|
return bytes.toString(encoding);
|
||||||
} catch (cause: unknown) {
|
} catch (cause: unknown) {
|
||||||
if (cause instanceof ArtifactReaderFailure) {
|
if (cause instanceof ArtifactReaderFailure) {
|
||||||
cleanupFailures.push(cause);
|
cleanupFailures.push(cause);
|
||||||
|
|||||||
@@ -73,7 +73,11 @@ const methodDimensions = (
|
|||||||
if (bothAbsent) return { dimensions, bodyUnknown: false };
|
if (bothAbsent) return { dimensions, bodyUnknown: false };
|
||||||
if (!leftBodyComplete || !rightBodyComplete)
|
if (!leftBodyComplete || !rightBodyComplete)
|
||||||
return { dimensions, bodyUnknown: true };
|
return { dimensions, bodyUnknown: true };
|
||||||
if (left.body.normalized_il_sha256 !== right.body.normalized_il_sha256)
|
// The decoded fingerprint omits switch targets and is not exact CIL identity.
|
||||||
|
if (
|
||||||
|
left.body.il_sha256 !== right.body.il_sha256 ||
|
||||||
|
left.body.normalized_il_sha256 !== right.body.normalized_il_sha256
|
||||||
|
)
|
||||||
dimensions.push("cil");
|
dimensions.push("cil");
|
||||||
if (
|
if (
|
||||||
canonicalize(left.body.opcode_counts) !==
|
canonicalize(left.body.opcode_counts) !==
|
||||||
|
|||||||
@@ -49,10 +49,13 @@ interface Ambiguous<Item> {
|
|||||||
const keyMethod = (item: Method): Keyed<Method> => ({
|
const keyMethod = (item: Method): Keyed<Method> => ({
|
||||||
item,
|
item,
|
||||||
exactKey:
|
exactKey:
|
||||||
item.body.status === "present" && item.body.normalized_il_sha256 !== null
|
item.body.status === "present" &&
|
||||||
|
item.body.il_sha256 !== null &&
|
||||||
|
item.body.normalized_il_sha256 !== null
|
||||||
? sha256([
|
? sha256([
|
||||||
"method-exact",
|
"method-exact",
|
||||||
item.signature.raw_sha256,
|
item.signature.raw_sha256,
|
||||||
|
item.body.il_sha256,
|
||||||
item.body.normalized_il_sha256,
|
item.body.normalized_il_sha256,
|
||||||
])
|
])
|
||||||
: null,
|
: null,
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|||||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||||
|
|
||||||
cliTest(
|
cliTest(
|
||||||
"rejects malformed oversized JSON through both CLI and Evidence readers",
|
"rejects malformed oversized input through CLI and Evidence readers",
|
||||||
async ({ cli, processes }) => {
|
async ({ cli, processes }) => {
|
||||||
const root = await createTestTempDirectory("rea-json-string-limit-");
|
const root = await createTestTempDirectory("rea-json-string-limit-");
|
||||||
const input = join(root, "oversized.json");
|
const input = join(root, "oversized.json");
|
||||||
const file = await open(input, "wx");
|
const file = await open(input, "wx");
|
||||||
try {
|
try {
|
||||||
// Sparse zero bytes are valid UTF-8 but invalid JSON. Both readers
|
// Sparse zero bytes are valid UTF-8. Both streaming readers reject
|
||||||
// stream the input and reject the syntax before assembling a value.
|
// their invalid JSON syntax without assembling a whole-document string.
|
||||||
await file.truncate(constants.MAX_STRING_LENGTH + 1);
|
await file.truncate(constants.MAX_STRING_LENGTH + 1);
|
||||||
} finally {
|
} finally {
|
||||||
await file.close();
|
await file.close();
|
||||||
@@ -175,7 +175,7 @@ cliTest(
|
|||||||
|
|
||||||
cliTest(
|
cliTest(
|
||||||
"returns a typed string assembly constraint under a bounded heap",
|
"returns a typed string assembly constraint under a bounded heap",
|
||||||
async ({ cli }) => {
|
async ({ cli, processes }) => {
|
||||||
const root = await createTestTempDirectory("rea-json-string-headroom-");
|
const root = await createTestTempDirectory("rea-json-string-headroom-");
|
||||||
const input = join(root, "long-string.json");
|
const input = join(root, "long-string.json");
|
||||||
const file = await open(input, "wx");
|
const file = await open(input, "wx");
|
||||||
@@ -207,5 +207,21 @@ cliTest(
|
|||||||
action: expect.stringContaining("re-analyze a smaller selection"),
|
action: expect.stringContaining("re-analyze a smaller selection"),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const evidence = await processes.run(process.execPath, [
|
||||||
|
"--max-old-space-size=768",
|
||||||
|
"--input-type=module",
|
||||||
|
"-e",
|
||||||
|
`import { readJsonFile } from "./dist/application/JsonFiles.js";
|
||||||
|
import { projectAnalysisError } from "./dist/domain/analysisErrorProjection.js";
|
||||||
|
const result = await readJsonFile(process.argv[1]);
|
||||||
|
console.log(JSON.stringify(result.ok ? result : projectAnalysisError(result.error)));`,
|
||||||
|
input,
|
||||||
|
]);
|
||||||
|
expect(JSON.parse(evidence.stdout)).toMatchObject({
|
||||||
|
code: "resource_constraint",
|
||||||
|
details: { operation: "read_evidence_file", resource: "memory" },
|
||||||
|
});
|
||||||
|
expect(evidence.stderr).toBe("");
|
||||||
|
expect(evidence.exitCode).toBe(0);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
+16
-12
@@ -72,17 +72,8 @@ describe("static Electron application analysis", () => {
|
|||||||
|
|
||||||
const result = await reconstructJavaScriptArtifact({ input_path: root });
|
const result = await reconstructJavaScriptArtifact({ input_path: root });
|
||||||
const graph = parseJavaScriptApplicationGraph(result.graph);
|
const graph = parseJavaScriptApplicationGraph(result.graph);
|
||||||
// Computed access keeps no known members; the unknown access is an
|
const nativeBindings = graph.nodes.filter(
|
||||||
// explicit dynamic flag rather than a "*" sentinel inside members.
|
(node) => node.kind === "native-export",
|
||||||
const accesses = graph.nodes.flatMap((node) =>
|
|
||||||
node.kind === "native-export"
|
|
||||||
? node.observations.map(({ properties }) => ({
|
|
||||||
members: Array.isArray(properties.requested_members)
|
|
||||||
? properties.requested_members
|
|
||||||
: [],
|
|
||||||
dynamicMemberAccess: properties.dynamic_member_access ?? false,
|
|
||||||
}))
|
|
||||||
: [],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.electron_summary).toMatchObject({
|
expect(result.electron_summary).toMatchObject({
|
||||||
@@ -90,7 +81,20 @@ describe("static Electron application analysis", () => {
|
|||||||
native_addon_bindings: 1,
|
native_addon_bindings: 1,
|
||||||
resolved_native_addon_bindings: 1,
|
resolved_native_addon_bindings: 1,
|
||||||
});
|
});
|
||||||
expect(accesses).toEqual([{ members: [], dynamicMemberAccess: true }]);
|
expect(nativeBindings).toMatchObject([
|
||||||
|
{
|
||||||
|
observations: [
|
||||||
|
{
|
||||||
|
properties: {
|
||||||
|
requested_members: [],
|
||||||
|
namespace_access: false,
|
||||||
|
dynamic_member_access: true,
|
||||||
|
native_export_verification: "not-performed",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("maps Electron boundaries through bundler-renamed bindings", async () => {
|
it("maps Electron boundaries through bundler-renamed bindings", async () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { mkdir, writeFile } from "node:fs/promises";
|
import { chmod, mkdir, writeFile } from "node:fs/promises";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { expect, it } from "vitest";
|
import { expect, it } from "vitest";
|
||||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||||
@@ -108,3 +108,33 @@ it("reads a linked worktree's own branch and detached HEAD through shared Git re
|
|||||||
dirty: null,
|
dirty: null,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.skipIf(process.platform === "win32")(
|
||||||
|
"keeps unreadable loose refs unknown instead of falling back to packed refs",
|
||||||
|
async () => {
|
||||||
|
const root = await createTestTempDirectory("rea-reference-loose-ref-");
|
||||||
|
const gitdir = join(root, ".git");
|
||||||
|
const looseRef = join(gitdir, "refs", "heads", "main");
|
||||||
|
await mkdir(join(gitdir, "refs", "heads"), { recursive: true });
|
||||||
|
const head = "1234567890abcdef1234567890abcdef12345678";
|
||||||
|
await writeFile(join(gitdir, "HEAD"), "ref: refs/heads/main\n");
|
||||||
|
await writeFile(join(gitdir, "packed-refs"), `${head} refs/heads/main\n`);
|
||||||
|
expect(await readVcs(root)).toEqual({
|
||||||
|
kind: "git",
|
||||||
|
head,
|
||||||
|
dirty: null,
|
||||||
|
});
|
||||||
|
if (process.getuid?.() === 0) return;
|
||||||
|
await writeFile(looseRef, `${head}\n`);
|
||||||
|
await chmod(looseRef, 0);
|
||||||
|
try {
|
||||||
|
expect(await readVcs(root)).toEqual({
|
||||||
|
kind: "unknown",
|
||||||
|
head: null,
|
||||||
|
dirty: null,
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
await chmod(looseRef, 0o600);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|||||||
@@ -116,6 +116,63 @@ describe("managed member comparison", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("managed member comparison with equal decoded fingerprints", () => {
|
||||||
|
it.each([
|
||||||
|
{ name: "Main", basis: "exact-signature" },
|
||||||
|
{ name: "Renamed", basis: "structural-method-shape" },
|
||||||
|
])("detects reordered switch targets in $name", ({ name, basis }) => {
|
||||||
|
const observe = (targets: readonly number[], methodName: string) => {
|
||||||
|
// ldarg.0; switch (case 0, case 1); ldc.i4.0; ret; ldc.i4.1; ret.
|
||||||
|
// Both cases target instruction starts, relative to the end of the table.
|
||||||
|
const il = Buffer.alloc(18);
|
||||||
|
il[0] = 0x02;
|
||||||
|
il[1] = 0x45;
|
||||||
|
il.writeUInt32LE(2, 2);
|
||||||
|
targets.forEach((target, index) =>
|
||||||
|
il.writeInt32LE(target, 6 + index * 4),
|
||||||
|
);
|
||||||
|
Buffer.from([0x16, 0x2a, 0x17, 0x2a]).copy(il, 14);
|
||||||
|
return inspect(
|
||||||
|
buildManagedPeFixture({
|
||||||
|
methodName,
|
||||||
|
methodSignature: Buffer.from([0x00, 0x01, 0x08, 0x08]),
|
||||||
|
ilBody: Buffer.concat([Buffer.from([(il.length << 2) | 2]), il]),
|
||||||
|
}),
|
||||||
|
`/tmp/${methodName}-${targets.join("-")}.dll`,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const left = observe([0, 2], "Main");
|
||||||
|
const right = observe([2, 0], name);
|
||||||
|
const leftBody = left.result.methods[0]?.body;
|
||||||
|
const rightBody = right.result.methods[0]?.body;
|
||||||
|
expect(leftBody?.status).toBe("present");
|
||||||
|
expect(rightBody?.status).toBe("present");
|
||||||
|
expect(leftBody?.normalized_il_sha256).toBe(
|
||||||
|
rightBody?.normalized_il_sha256,
|
||||||
|
);
|
||||||
|
expect(leftBody?.il_sha256).not.toBe(rightBody?.il_sha256);
|
||||||
|
|
||||||
|
const result = compareManagedMembers(left, right);
|
||||||
|
expect(result.matching.exact_il_signature).toBe(0);
|
||||||
|
expect(result.methods[0]).toMatchObject({
|
||||||
|
status: "changed",
|
||||||
|
match: { status: "matched", basis },
|
||||||
|
dimensions: ["cil"],
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
compareManagedMembers(right, observe([2, 0], name)).methods[0],
|
||||||
|
).toMatchObject({
|
||||||
|
status: "unchanged",
|
||||||
|
match: {
|
||||||
|
status: "matched",
|
||||||
|
basis: "exact-il-signature",
|
||||||
|
confidence: "exact",
|
||||||
|
},
|
||||||
|
dimensions: [],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("managed member comparison floating-point constants", () => {
|
describe("managed member comparison floating-point constants", () => {
|
||||||
it.each([
|
it.each([
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -319,6 +319,8 @@ describe("updated executable maintenance planning", () => {
|
|||||||
it("runs real setup as a noninteractive dry run and creates no new integrations or backups", async () => {
|
it("runs real setup as a noninteractive dry run and creates no new integrations or backups", async () => {
|
||||||
const configPath = await writeClient("codex", staleCodex);
|
const configPath = await writeClient("codex", staleCodex);
|
||||||
const untouched = await writeClient("claude_code", '{"mcpServers":{}}');
|
const untouched = await writeClient("claude_code", '{"mcpServers":{}}');
|
||||||
|
const skillContent = `---\nname: ${PRODUCT_IDENTITY.skillName}\nmetadata:\n version: "1"\n---\n# REA\n`;
|
||||||
|
const skillPath = await writeSkill(skillContent);
|
||||||
vi.stubEnv("npm_command", "exec");
|
vi.stubEnv("npm_command", "exec");
|
||||||
const result = await planIntegrationMaintenance(
|
const result = await planIntegrationMaintenance(
|
||||||
home,
|
home,
|
||||||
@@ -328,18 +330,35 @@ describe("updated executable maintenance planning", () => {
|
|||||||
);
|
);
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
status: "planned",
|
status: "planned",
|
||||||
scope: { clients: ["codex"], skill: false },
|
scope: {
|
||||||
plannedActions: [
|
clients: ["codex"],
|
||||||
{ id: "configure_client:codex", kind: "configure_client" },
|
skill: true,
|
||||||
],
|
skillDestinations: [{ client: "shared", path: dirname(skillPath) }],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
if (result.status !== "planned") throw new Error(JSON.stringify(result));
|
||||||
|
expect(result.plannedActions).toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: "configure_client:codex",
|
||||||
|
kind: "configure_client",
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: "install_skill",
|
||||||
|
kind: "install_skill",
|
||||||
|
target: dirname(skillPath),
|
||||||
|
}),
|
||||||
|
]);
|
||||||
expect(await readFile(configPath, "utf8")).toBe(staleCodex);
|
expect(await readFile(configPath, "utf8")).toBe(staleCodex);
|
||||||
expect(await readFile(untouched, "utf8")).toBe('{"mcpServers":{}}');
|
expect(await readFile(untouched, "utf8")).toBe('{"mcpServers":{}}');
|
||||||
|
expect(await readFile(skillPath, "utf8")).toBe(skillContent);
|
||||||
await expect(access(`${configPath}.rea.backup`)).rejects.toMatchObject({
|
await expect(access(`${configPath}.rea.backup`)).rejects.toMatchObject({
|
||||||
code: "ENOENT",
|
code: "ENOENT",
|
||||||
});
|
});
|
||||||
|
await expect(access(`${skillPath}.rea.backup`)).rejects.toMatchObject({
|
||||||
|
code: "ENOENT",
|
||||||
|
});
|
||||||
await expect(
|
await expect(
|
||||||
access(join(home, ".agents", "skills", PRODUCT_IDENTITY.skillName)),
|
access(join(home, ".claude", "skills", PRODUCT_IDENTITY.skillName)),
|
||||||
).rejects.toMatchObject({ code: "ENOENT" });
|
).rejects.toMatchObject({ code: "ENOENT" });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user