Compare commits

...
Author SHA1 Message Date
N0zoM1z0 c7fdd7e153 test(artifacts): share ASAR member fixture setup 2026-10-11 03:54:57 +08:00
N0zoM1z0 3c794a5cc0 Merge commit '5100a1a1a56b810c8246b8c7ed19ff42c4d9dbe1' into fix/ci-duplicate-boundaries-1603 2026-10-11 03:50:21 +08:00
N0zoM1z0 16caa5ca9b chore(ci): refresh maintenance checks against current main 2026-10-11 03:44:06 +08:00
N0zoM1z0 2a6bef5589 chore(ci): include current snapshot and runtime repairs 2026-10-11 01:50:32 +08:00
N0zoM1z0 cace19caad fix(ci): reconcile lifecycle checks with current main
Preserve failed event finalization across retries and current capture ownership checks. Retain Git unreadable-ref and bounded-heap Evidence coverage, pinned maintenance destinations, and explicit native binding facts.
2026-10-11 01:08:09 +08:00
N0zoM1z0 87b7bf8db1 fix(reference-source): distinguish Git API probes from failed reads 2026-10-10 16:59:30 +00:00
N0zoM1z0 3b66532e26 Merge commit '603d04ee3ac6ed496f84478164f832a9b5ce3b91' into fix/main-maintenance-ci-20261010
# Conflicts:
#	tests/process-global/updateMaintenance.test.ts
2026-10-10 16:36:42 +00:00
N0zoM1z0 3ad063b454 Merge remote-tracking branch 'origin/main' into fix/main-maintenance-ci-20261010 2026-10-10 16:34:18 +00:00
N0zoM1z0 69485e27f7 fix(ci): restore capture and maintenance regression checks 2026-10-10 16:34:17 +00:00
6 changed files with 173 additions and 131 deletions
+15 -14
View File
@@ -53,24 +53,25 @@ const resolveSourceHead = async (
...fs.promises,
// isomorphic-git treats every read failure as absence. Preserve real
// failures so a readable packed ref cannot hide an unreadable loose ref.
readFile: async (
path: string | undefined,
options:
| BufferEncoding
| { readonly encoding?: BufferEncoding | null }
| null = null,
) => {
// The library probes readFile() without a path to detect promise APIs.
// Reject that invocation without attributing it to a source read.
readFile: async (path?: string, options?: unknown) => {
// isomorphic-git probes promise support with readFile() before reading
// metadata. Its rejected probe must not count as a failed file read.
if (path === undefined)
throw new TypeError("Git filesystem read requires a path");
throw new TypeError("Git metadata path is required");
try {
const bytes = await readRegularFile(path, { signal });
const encoding =
typeof options === "string" ? options : options?.encoding;
return encoding === undefined || encoding === null
? bytes
: bytes.toString(encoding);
typeof options === "string"
? options
: typeof options === "object" &&
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) {
if (errorCode(cause) !== "ENOENT") failedRead ??= { cause };
throw cause;
+20 -4
View File
@@ -8,14 +8,14 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
cliTest(
"rejects malformed oversized JSON through both CLI and Evidence readers",
"rejects malformed oversized input through CLI and Evidence readers",
async ({ cli, processes }) => {
const root = await createTestTempDirectory("rea-json-string-limit-");
const input = join(root, "oversized.json");
const file = await open(input, "wx");
try {
// Sparse zero bytes are valid UTF-8 but invalid JSON. Both readers
// stream the input and reject the syntax before assembling a value.
// Sparse zero bytes are valid UTF-8. Both streaming readers reject
// their invalid JSON syntax without assembling a whole-document string.
await file.truncate(constants.MAX_STRING_LENGTH + 1);
} finally {
await file.close();
@@ -118,7 +118,7 @@ cliTest(
cliTest(
"returns a typed string assembly constraint under a bounded heap",
async ({ cli }) => {
async ({ cli, processes }) => {
const root = await createTestTempDirectory("rea-json-string-headroom-");
const input = join(root, "long-string.json");
const file = await open(input, "wx");
@@ -150,5 +150,21 @@ cliTest(
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);
},
);
@@ -56,28 +56,43 @@ const waitForNoMatchingDescriptor = async (identity: Stats): Promise<void> => {
expect(await matchingDescriptorCount(identity)).toBe(0);
};
const createSmallMemberArchive = async (
prefix: string,
unpacked = false,
): Promise<string> => {
const root = await createTestTempDirectory(prefix);
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(
source,
archive,
unpacked ? { unpack: "small.js" } : {},
);
return archive;
};
const readSmallMember = async (reader: AsarArtifactReader) => {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected small ASAR member");
return entry;
};
describe("ASAR entry streaming", () => {
it.skipIf(process.platform === "win32")(
"closes a packed member handle when its unopened output stream is destroyed",
async () => {
const root = await createTestTempDirectory(
const archive = await createSmallMemberArchive(
"rea-asar-destroy-before-read-",
);
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(source, archive, {});
const reader = new AsarArtifactReader(archive);
try {
const entries = [];
for await (const entry of reader.entries()) {
entries.push(entry);
}
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected packed ASAR member");
const entry = await readSmallMember(reader);
const snapshot = await reader.openContainer();
const identity = await lstat(snapshot.path);
await buffer(snapshot);
@@ -102,20 +117,14 @@ describe("ASAR entry streaming", () => {
it.skipIf(process.platform === "win32")(
"closes a packed member handle when cancellation arrives during open",
async () => {
const root = await createTestTempDirectory("rea-asar-abort-during-stat-");
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(source, archive, {});
const archive = await createSmallMemberArchive(
"rea-asar-abort-during-stat-",
);
const reader = new AsarArtifactReader(archive);
try {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected packed ASAR member");
const entry = await readSmallMember(reader);
const snapshot = await reader.openContainer();
const identity = await lstat(snapshot.path);
await buffer(snapshot);
@@ -131,19 +140,11 @@ describe("ASAR entry streaming", () => {
);
it("keeps captured packed bytes readable after the original container disappears", async () => {
const root = await createTestTempDirectory("rea-asar-missing-member-");
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(source, archive, {});
const archive = await createSmallMemberArchive("rea-asar-missing-member-");
const reader = new AsarArtifactReader(archive);
try {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected packed ASAR member");
const entry = await readSmallMember(reader);
await rm(archive);
expect((await buffer(await reader.open(entry))).toString()).toBe(
"module.exports = 1;\n",
@@ -175,10 +176,7 @@ describe("ASAR entry producer identity", () => {
const reader = new AsarArtifactReader(archive);
try {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected ASAR file entry");
const entry = await readSmallMember(reader);
expect(entry.unpacked).toBe(unpacked);
expect(await matchingDescriptorCount(identity)).toBe(0);
if (entry.declaredSize === null)
@@ -292,12 +290,10 @@ describe("ASAR read failures", () => {
it.skipIf(process.platform === "win32")(
"closes the opened unpacked file and retains ASAR context when handle stat fails",
async () => {
const root = await createTestTempDirectory("rea-asar-unpacked-stat-");
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(source, archive, { unpack: "small.js" });
const archive = await createSmallMemberArchive(
"rea-asar-unpacked-stat-",
true,
);
const unpackedPath = join(`${archive}.unpacked`, "small.js");
const identity = await lstat(unpackedPath);
const ioError = Object.assign(new Error("device stat failed"), {
@@ -328,11 +324,7 @@ describe("ASAR read failures", () => {
});
try {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined)
throw new Error("Expected unpacked ASAR member");
const entry = await readSmallMember(reader);
await expect(reader.open(entry)).rejects.toMatchObject({
name: "ArtifactReaderFailure",
@@ -364,12 +356,10 @@ describe("ASAR read failures", () => {
it.skipIf(process.platform === "win32")(
"retries cleanup when cancellation arrives immediately after unpacked stat",
async () => {
const root = await createTestTempDirectory("rea-asar-unpacked-abort-stat-");
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(source, archive, { unpack: "small.js" });
const archive = await createSmallMemberArchive(
"rea-asar-unpacked-abort-stat-",
true,
);
const unpackedPath = join(`${archive}.unpacked`, "small.js");
const identity = await lstat(unpackedPath);
const controller = new AbortController();
@@ -392,10 +382,7 @@ it.skipIf(process.platform === "win32")(
});
try {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected unpacked ASAR member");
const entry = await readSmallMember(reader);
await expect(reader.open(entry, controller.signal)).rejects.toMatchObject(
{
@@ -420,12 +407,10 @@ it.skipIf(process.platform === "win32")(
it.skipIf(process.platform === "win32")(
"preserves an unpacked identity failure when closing its handle fails",
async () => {
const root = await createTestTempDirectory("rea-asar-unpacked-identity-");
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(source, archive, { unpack: "small.js" });
const archive = await createSmallMemberArchive(
"rea-asar-unpacked-identity-",
true,
);
const unpackedPath = join(`${archive}.unpacked`, "small.js");
const identity = await lstat(unpackedPath);
const closeError = new Error("first close failed");
@@ -449,10 +434,7 @@ it.skipIf(process.platform === "win32")(
});
try {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected unpacked ASAR member");
const entry = await readSmallMember(reader);
await expect(reader.open(entry)).rejects.toMatchObject({
name: "ArtifactReaderFailure",
@@ -479,12 +461,10 @@ it.skipIf(process.platform === "win32")(
it.skipIf(process.platform === "win32")(
"retains unpacked handles and snapshots across combined cleanup failures",
async () => {
const root = await createTestTempDirectory("rea-asar-combined-cleanup-");
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(source, archive, { unpack: "small.js" });
const archive = await createSmallMemberArchive(
"rea-asar-combined-cleanup-",
true,
);
const unpackedPath = join(`${archive}.unpacked`, "small.js");
const identity = await lstat(unpackedPath);
const closeError = new Error("unpacked close denied");
@@ -519,10 +499,7 @@ it.skipIf(process.platform === "win32")(
);
try {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected unpacked ASAR member");
const entry = await readSmallMember(reader);
await expect(reader.open(entry)).rejects.toMatchObject({
reason: "io",
@@ -567,20 +544,15 @@ it.skipIf(process.platform === "win32")(
it.skipIf(process.platform === "win32")(
"releases unpacked handles after stream completion and cancellation",
async () => {
const root = await createTestTempDirectory("rea-asar-unpacked-stream-");
const source = join(root, "source");
const archive = join(root, "fixture.asar");
await mkdir(source);
await writeFile(join(source, "small.js"), "module.exports = 1;\n");
await createPackageWithOptions(source, archive, { unpack: "small.js" });
const archive = await createSmallMemberArchive(
"rea-asar-unpacked-stream-",
true,
);
const identity = await lstat(join(`${archive}.unpacked`, "small.js"));
const reader = new AsarArtifactReader(archive);
try {
const entries = [];
for await (const entry of reader.entries()) entries.push(entry);
const entry = entries.find(({ path }) => path === "small.js");
if (entry === undefined) throw new Error("Expected unpacked ASAR member");
const entry = await readSmallMember(reader);
expect((await buffer(await reader.open(entry))).toString()).toBe(
"module.exports = 1;\n",
);
@@ -1,4 +1,4 @@
import { mkdir, writeFile } from "node:fs/promises";
import { chmod, mkdir, rm, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect, it } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
@@ -84,14 +84,6 @@ it("reads a linked worktree's own branch and detached HEAD through shared Git re
head: mainHead,
dirty: null,
});
// A non-regular loose ref must remain unknown even when packed-refs has
// a readable value. The library's promise-API probe is not a source failure.
await mkdir(join(repository, ".git", "refs", "heads", "main"));
expect(await readReferenceSourceVcs(repository)).toEqual({
kind: "unknown",
head: null,
dirty: null,
});
const controller = new AbortController();
controller.abort();
expect(await readReferenceSourceVcs(linked, controller.signal)).toEqual({
@@ -100,3 +92,41 @@ it("reads a linked worktree's own branch and detached HEAD through shared Git re
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 readReferenceSourceVcs(root)).toEqual({
kind: "git",
head,
dirty: null,
});
// A non-file loose ref is an actual read failure, not an absent ref.
await mkdir(looseRef);
expect(await readReferenceSourceVcs(root)).toEqual({
kind: "unknown",
head: null,
dirty: null,
});
await rm(looseRef, { recursive: true });
if (process.getuid?.() === 0) return;
await writeFile(looseRef, `${head}\n`);
await chmod(looseRef, 0);
try {
expect(await readReferenceSourceVcs(root)).toEqual({
kind: "unknown",
head: null,
dirty: null,
});
} finally {
await chmod(looseRef, 0o600);
}
},
);
@@ -72,17 +72,8 @@ describe("static Electron application analysis", () => {
const result = await reconstructJavaScriptArtifact({ input_path: root });
const graph = parseJavaScriptApplicationGraph(result.graph);
// Computed access keeps no known members; the unknown access is an
// explicit dynamic flag rather than a "*" sentinel inside members.
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,
}))
: [],
const nativeBindings = graph.nodes.filter(
(node) => node.kind === "native-export",
);
expect(result.electron_summary).toMatchObject({
@@ -90,7 +81,20 @@ describe("static Electron application analysis", () => {
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 () => {
+24 -5
View File
@@ -282,6 +282,8 @@ describe("updated executable maintenance planning", () => {
it("runs real setup as a noninteractive dry run and creates no new integrations or backups", async () => {
const configPath = await writeClient("codex", staleCodex);
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");
const result = await planIntegrationMaintenance(
home,
@@ -291,18 +293,35 @@ describe("updated executable maintenance planning", () => {
);
expect(result).toMatchObject({
status: "planned",
scope: { clients: ["codex"], skill: false },
plannedActions: [
{ id: "configure_client:codex", kind: "configure_client" },
],
scope: {
clients: ["codex"],
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(untouched, "utf8")).toBe('{"mcpServers":{}}');
expect(await readFile(skillPath, "utf8")).toBe(skillContent);
await expect(access(`${configPath}.rea.backup`)).rejects.toMatchObject({
code: "ENOENT",
});
await expect(access(`${skillPath}.rea.backup`)).rejects.toMatchObject({
code: "ENOENT",
});
await expect(
access(join(home, ".agents", "skills", PRODUCT_IDENTITY.skillName)),
access(join(home, ".claude", "skills", PRODUCT_IDENTITY.skillName)),
).rejects.toMatchObject({ code: "ENOENT" });
});
});