chore(native): integrate archive case controls and current catalogs
This commit is contained in:
@@ -100,7 +100,6 @@ describe("entry-order validation and reader controls", () => {
|
||||
it.each([
|
||||
["pkg/data.txt", "pkg/data.txt/"],
|
||||
["pkg/data.txt/", "pkg/data.txt"],
|
||||
["pkg/data.txt", "PKG/other.txt"],
|
||||
["pkg/data.txt", "pkg"],
|
||||
["../escape.txt"],
|
||||
])("keeps invalid/colliding paths rejected for %j", async (...entries) => {
|
||||
@@ -112,6 +111,25 @@ describe("entry-order validation and reader controls", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps case-distinct directory names separate in either entry order", async () => {
|
||||
const root = await createTestTempDirectory("rea-entry-order-case-");
|
||||
const archive = join(root, "case-distinct.zip");
|
||||
const entries = ["pkg/", "pkg/data.txt", "PKG/", "PKG/other.txt"];
|
||||
const parents = {
|
||||
".": null,
|
||||
pkg: ".",
|
||||
"pkg/data.txt": "pkg",
|
||||
PKG: ".",
|
||||
"PKG/other.txt": "PKG",
|
||||
};
|
||||
for (const ordered of [entries, entries.toReversed()]) {
|
||||
await writeOrderedZip(archive, ordered);
|
||||
expect(artifactParentPaths(await inventoryArtifact(archive))).toEqual(
|
||||
parents,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves ordinary directory and ASAR structure", async () => {
|
||||
const root = await createTestTempDirectory("rea-entry-order-readers-");
|
||||
const directory = join(root, "source");
|
||||
|
||||
@@ -59,6 +59,7 @@ describe("client configuration filesystem lifecycle", () => {
|
||||
"antigravity",
|
||||
"copilot_cli",
|
||||
"commandcode",
|
||||
"qwen_code",
|
||||
"vscode",
|
||||
"grok_build",
|
||||
"omp",
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { join, resolve } from "node:path";
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { parse as parseJsonc } from "jsonc-parser";
|
||||
|
||||
import { readClientRegistrationStatuses } from "../../../src/application/ClientRegistrationStatus.js";
|
||||
import { configureClientConfiguration } from "../../../src/application/SetupClientConfiguration.js";
|
||||
import { systemSetupHost } from "../../../src/application/SetupHost.js";
|
||||
import { supportedClients } from "../../../src/application/SupportedClients.js";
|
||||
import { systemUninstallHost } from "../../../src/application/Uninstall.js";
|
||||
import { PRODUCT_IDENTITY } from "../../../src/identity.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import {
|
||||
clearClientLocationEnvironment,
|
||||
NPX_REGISTRATION_COMMAND,
|
||||
} from "../../fixtures/clientEnvironment.js";
|
||||
|
||||
const command = NPX_REGISTRATION_COMMAND;
|
||||
|
||||
beforeEach(clearClientLocationEnvironment);
|
||||
afterEach(() => vi.unstubAllEnvs());
|
||||
|
||||
const qwenPath = (
|
||||
home: string,
|
||||
platform: NodeJS.Platform,
|
||||
env: Parameters<typeof supportedClients>[2] = {},
|
||||
) =>
|
||||
supportedClients(home, platform, env).find(
|
||||
({ name }) => name === "qwen_code",
|
||||
);
|
||||
|
||||
describe("Qwen Code configuration paths", () => {
|
||||
it("resolves the user settings file and marker directory", () => {
|
||||
expect(qwenPath("/home/a", "linux")).toEqual({
|
||||
name: "qwen_code",
|
||||
displayName: "Qwen Code",
|
||||
configPath: join("/home/a", ".qwen", "settings.json"),
|
||||
markerPath: join("/home/a", ".qwen"),
|
||||
format: "json",
|
||||
});
|
||||
expect(qwenPath("/Users/a", "darwin")?.configPath).toBe(
|
||||
join("/Users/a", ".qwen", "settings.json"),
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["", join("/home/a", ".qwen")],
|
||||
["~", "/home/a"],
|
||||
["~/profiles/work", join("/home/a", "profiles", "work")],
|
||||
["~\\profiles\\work", join("/home/a", "profiles", "work")],
|
||||
["profiles/work", resolve("profiles/work")],
|
||||
[" profile ", resolve(" profile ")],
|
||||
["$PROFILE", resolve("$PROFILE")],
|
||||
])("matches Qwen's QWEN_HOME resolution for %j", (override, directory) => {
|
||||
vi.stubEnv("QWEN_HOME", override);
|
||||
const client = qwenPath("/home/a", process.platform, {
|
||||
QWEN_HOME: override,
|
||||
});
|
||||
expect(
|
||||
supportedClients("/home/a").find(({ name }) => name === "qwen_code"),
|
||||
).toEqual(client);
|
||||
expect(client).toMatchObject({
|
||||
configPath: join(directory, "settings.json"),
|
||||
markerPath: directory,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Qwen Code client lifecycle", () => {
|
||||
const qwenClient = async () => {
|
||||
const home = await createTestTempDirectory("rea-qwen-");
|
||||
const client = qwenPath(home, process.platform, {});
|
||||
if (client?.markerPath === undefined)
|
||||
throw new Error("missing Qwen Code client");
|
||||
await mkdir(client.markerPath, { recursive: true });
|
||||
return { home, client };
|
||||
};
|
||||
|
||||
it("registers rea in mcpServers while preserving unrelated settings and comments", async () => {
|
||||
const { home, client } = await qwenClient();
|
||||
await writeFile(
|
||||
client.configPath,
|
||||
`{
|
||||
// Keep this note.
|
||||
"model": { "name": "qwen3-coder-plus" },
|
||||
"mcpServers": { "other": { "command": "other-server" } }
|
||||
}
|
||||
`,
|
||||
);
|
||||
expect(
|
||||
(await configureClientConfiguration(client, {}, command)).status,
|
||||
).toBe("configured");
|
||||
const text = await readFile(client.configPath, "utf8");
|
||||
expect(text).toContain("// Keep this note.");
|
||||
expect(parseJsonc(text)).toEqual({
|
||||
model: { name: "qwen3-coder-plus" },
|
||||
mcpServers: {
|
||||
other: { command: "other-server" },
|
||||
rea: { command: "npx", args: command.slice(1) },
|
||||
},
|
||||
});
|
||||
expect(await configureClientConfiguration(client, {}, command)).toEqual({
|
||||
status: "unchanged",
|
||||
});
|
||||
expect((await systemUninstallHost(home).removeClient(client)).status).toBe(
|
||||
"removed",
|
||||
);
|
||||
const removedText = await readFile(client.configPath, "utf8");
|
||||
const removed = parseJsonc(removedText);
|
||||
expect(removed).toEqual({
|
||||
model: { name: "qwen3-coder-plus" },
|
||||
mcpServers: { other: { command: "other-server" } },
|
||||
});
|
||||
expect(removedText).toContain("// Keep this note.");
|
||||
});
|
||||
|
||||
it("reports a package-runner registration as aligned", async () => {
|
||||
const { home, client } = await qwenClient();
|
||||
expect(
|
||||
(await configureClientConfiguration(client, {}, command)).status,
|
||||
).toBe("configured");
|
||||
const entry = resolve("scripts/rea.mjs");
|
||||
const status = (
|
||||
await readClientRegistrationStatuses(home, entry, { environment: {} })
|
||||
).find(({ client: name }) => name === "qwen_code");
|
||||
expect(status).toMatchObject({ state: "aligned" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("Qwen Code profile setup", () => {
|
||||
it.each([false, true])(
|
||||
"installs and removes the shared skill with a custom home: %s",
|
||||
async (customHome) => {
|
||||
const home = await createTestTempDirectory("rea-qwen-profile-");
|
||||
const profile = join(home, customHome ? "qwen-profile" : ".qwen");
|
||||
const environment = {
|
||||
HOME: home,
|
||||
USERPROFILE: home,
|
||||
...(customHome ? { QWEN_HOME: profile } : {}),
|
||||
};
|
||||
await mkdir(profile);
|
||||
const setup = systemSetupHost(undefined, environment);
|
||||
const client = (await setup.detectedClients()).find(
|
||||
({ name }) => name === "qwen_code",
|
||||
);
|
||||
if (client === undefined) throw new Error("missing Qwen Code client");
|
||||
expect(client.configPath).toBe(join(profile, "settings.json"));
|
||||
expect(await setup.configureClient(client, {}, command)).toEqual({
|
||||
status: "configured",
|
||||
});
|
||||
expect(await setup.installSkill([client.name])).toBe("installed");
|
||||
const skill = join(home, ".agents", "skills", PRODUCT_IDENTITY.skillName);
|
||||
expect(await readFile(join(skill, "SKILL.md"), "utf8")).toContain(
|
||||
"reverse-engineer-anything",
|
||||
);
|
||||
expect(await setup.clientNeedsConfigure(client, {}, command)).toBe(false);
|
||||
expect(await setup.skillNeedsInstall([client.name])).toBe(false);
|
||||
expect(await setup.installSkill([client.name])).toBe("unchanged");
|
||||
expect(
|
||||
(
|
||||
await readClientRegistrationStatuses(
|
||||
home,
|
||||
resolve("scripts/rea.mjs"),
|
||||
{ environment },
|
||||
)
|
||||
).find(({ client: name }) => name === "qwen_code"),
|
||||
).toMatchObject({ state: "aligned" });
|
||||
const uninstall = systemUninstallHost(home, undefined, environment);
|
||||
const registered = (await uninstall.clients()).find(
|
||||
({ name }) => name === "qwen_code",
|
||||
);
|
||||
expect(registered).toEqual(client);
|
||||
expect((await uninstall.removeClient(client)).status).toBe("removed");
|
||||
expect((await uninstall.removeSkill()).status).toBe("removed");
|
||||
await expect(access(skill)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
if (customHome)
|
||||
await expect(access(join(home, ".qwen"))).rejects.toMatchObject({
|
||||
code: "ENOENT",
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -117,7 +117,7 @@ function expectKnownAuthorityHints(tools: readonly ToolSchemas[]): void {
|
||||
expect(advertised.get(name), name).toMatchObject({ annotations });
|
||||
}
|
||||
|
||||
function expectRecursivePropertyDescriptions(
|
||||
function expectMeaningfulPropertyDescriptions(
|
||||
schema: unknown,
|
||||
path: string,
|
||||
root: unknown = schema,
|
||||
@@ -125,7 +125,7 @@ function expectRecursivePropertyDescriptions(
|
||||
): void {
|
||||
if (!isRecord(schema)) return;
|
||||
if (typeof schema.$ref === "string" && !active.has(schema.$ref))
|
||||
expectRecursivePropertyDescriptions(
|
||||
expectMeaningfulPropertyDescriptions(
|
||||
resolveReference(root, schema.$ref),
|
||||
`${path}.${schema.$ref}`,
|
||||
root,
|
||||
@@ -133,10 +133,13 @@ function expectRecursivePropertyDescriptions(
|
||||
);
|
||||
if (isRecord(schema.properties)) {
|
||||
for (const [property, child] of Object.entries(schema.properties)) {
|
||||
expect(child, `${path}.${property}`).toMatchObject({
|
||||
description: expect.any(String),
|
||||
});
|
||||
expectRecursivePropertyDescriptions(
|
||||
// Omit a description rather than restate the property name.
|
||||
const description = isRecord(child) ? child.description : undefined;
|
||||
if (description !== undefined)
|
||||
expect(description, `${path}.${property}`).toEqual(
|
||||
expect.not.stringMatching(/^(?:Value for .*)?$/u),
|
||||
);
|
||||
expectMeaningfulPropertyDescriptions(
|
||||
child,
|
||||
`${path}.${property}`,
|
||||
root,
|
||||
@@ -147,12 +150,12 @@ function expectRecursivePropertyDescriptions(
|
||||
|
||||
for (const key of ["items", "additionalProperties"])
|
||||
if (schema[key] !== undefined)
|
||||
expectRecursivePropertyDescriptions(schema[key], path, root, active);
|
||||
expectMeaningfulPropertyDescriptions(schema[key], path, root, active);
|
||||
for (const key of ["allOf", "anyOf", "oneOf", "prefixItems"]) {
|
||||
const children = schema[key];
|
||||
if (Array.isArray(children))
|
||||
children.forEach((child: unknown, index: number) =>
|
||||
expectRecursivePropertyDescriptions(
|
||||
expectMeaningfulPropertyDescriptions(
|
||||
child,
|
||||
`${path}.${key}[${index}]`,
|
||||
root,
|
||||
@@ -358,7 +361,7 @@ describe("MCP JSON Schema validity", () => {
|
||||
contract.inputSchema.safeParse(example.input).success,
|
||||
`${contract.name}: ${example.title}`,
|
||||
).toBe(true);
|
||||
expectRecursivePropertyDescriptions(tool?.inputSchema, contract.name);
|
||||
expectMeaningfulPropertyDescriptions(tool?.inputSchema, contract.name);
|
||||
}
|
||||
} finally {
|
||||
await Promise.allSettled([client.close(), server.close()]);
|
||||
|
||||
@@ -60,6 +60,15 @@ describe("artifact archive inventory", () => {
|
||||
expect(inspectionEvidence.evidence_links).toEqual(
|
||||
inspection.evidence_links,
|
||||
);
|
||||
// The graph is delivered once, in the nested inventory Evidence.
|
||||
expect(
|
||||
artifactInventoryResultSchema.parse(
|
||||
inspection.substeps[0]?.evidence.normalized_result,
|
||||
).occurrences,
|
||||
).toHaveLength(3);
|
||||
expect(inspection.observations.map(({ kind }) => kind)).toEqual([
|
||||
"root-manifest",
|
||||
]);
|
||||
const cancellation = new AbortController();
|
||||
cancellation.abort();
|
||||
await expect(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import { lstat, readFile, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { TextReader, Uint8ArrayWriter, ZipWriter } from "@zip.js/zip.js";
|
||||
@@ -9,6 +9,8 @@ import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js
|
||||
import { createDirectAnalysis } from "../../../../src/composition/directAnalysis.js";
|
||||
import {
|
||||
ArtifactPathRegistry,
|
||||
destinationCaseCollisionMessage,
|
||||
ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION,
|
||||
normalizeArtifactPath,
|
||||
} from "../../../../src/artifacts/ArtifactPaths.js";
|
||||
import { ArtifactProvider } from "../../../../src/artifacts/ArtifactProvider.js";
|
||||
@@ -18,6 +20,7 @@ import { artifactInventoryResultSchema } from "../../../../src/domain/artifactGr
|
||||
import type { BinaryTarget } from "../../../../src/domain/binaryTargetTypes.js";
|
||||
import { parseBinaryTarget } from "../../../../src/application/BinaryTargetResolver.js";
|
||||
import { parseEvidence } from "../../../../src/domain/evidence.js";
|
||||
import { projectAnalysisError } from "../../../../src/domain/analysisErrorProjection.js";
|
||||
|
||||
const { runProviderAnalysis } = createDirectAnalysis({});
|
||||
|
||||
@@ -95,17 +98,8 @@ describe("artifact archive safety", () => {
|
||||
});
|
||||
const registry = new ArtifactPathRegistry();
|
||||
registry.add("A.js", "file");
|
||||
let collisionError: unknown;
|
||||
try {
|
||||
registry.add("a.js", "file");
|
||||
} catch (error: unknown) {
|
||||
collisionError = error;
|
||||
}
|
||||
expect(collisionError).toBeInstanceOf(ArtifactReaderFailure);
|
||||
expect(collisionError).toMatchObject({
|
||||
reason: "path",
|
||||
message: "Artifact path collision: a.js differs only in case from A.js",
|
||||
});
|
||||
expect(() => registry.add("a.js", "file")).not.toThrow();
|
||||
expect(() => registry.add("A.js", "file")).toThrow(ArtifactReaderFailure);
|
||||
|
||||
for (const [filePath, childPath] of [
|
||||
["Foo", "foo/bar"],
|
||||
@@ -113,11 +107,15 @@ describe("artifact archive safety", () => {
|
||||
] as const) {
|
||||
const casePrefixRegistry = new ArtifactPathRegistry();
|
||||
casePrefixRegistry.add(filePath, "file");
|
||||
expect(() => casePrefixRegistry.add(childPath, "file")).toThrow(
|
||||
ArtifactReaderFailure,
|
||||
);
|
||||
expect(() => casePrefixRegistry.add(childPath, "file")).not.toThrow();
|
||||
}
|
||||
|
||||
const exactPrefixRegistry = new ArtifactPathRegistry();
|
||||
exactPrefixRegistry.add("Foo", "file");
|
||||
expect(() => exactPrefixRegistry.add("Foo/bar", "file")).toThrow(
|
||||
ArtifactReaderFailure,
|
||||
);
|
||||
|
||||
const sameDirectoryRegistry = new ArtifactPathRegistry();
|
||||
sameDirectoryRegistry.add("Foo/one.js", "file");
|
||||
expect(() => sameDirectoryRegistry.add("Foo/two.js", "file")).not.toThrow();
|
||||
@@ -126,8 +124,64 @@ describe("artifact archive safety", () => {
|
||||
caseVariantDirectoryRegistry.add("Foo/one.js", "file");
|
||||
expect(() =>
|
||||
caseVariantDirectoryRegistry.add("foo/two.js", "file"),
|
||||
).toThrow(ArtifactReaderFailure);
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it("names a destination case collision from the directory listing", () => {
|
||||
expect(
|
||||
destinationCaseCollisionMessage("res/2f.xml", ["2F.xml", "other.xml"]),
|
||||
).toBe(
|
||||
"Destination filesystem cannot store both res/2f.xml and res/2F.xml; inventory retains both logical names.",
|
||||
);
|
||||
expect(
|
||||
destinationCaseCollisionMessage("res/2f.xml", ["2f.xml", "2F.xml"]),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("extracts case-distinct names only when the destination can preserve them", async () => {
|
||||
const root = await createTestTempDirectory("rea-case-distinct-zip-");
|
||||
await writeFile(join(root, "case-probe"), "lower");
|
||||
await writeFile(join(root, "CASE-PROBE"), "upper");
|
||||
const caseSensitive =
|
||||
(await readFile(join(root, "case-probe"), "utf8")) === "lower";
|
||||
const path = join(root, "fixture.zip");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
await writer.add("Main.js", new TextReader("upper"));
|
||||
await writer.add("main.js", new TextReader("lower"));
|
||||
await writeFile(path, await writer.close());
|
||||
const parsed = await parseBinaryTarget(path);
|
||||
if (!parsed.ok) throw parsed.error;
|
||||
const result = await inventory(parsed.value);
|
||||
expect(result.limitations).toContain(
|
||||
ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION,
|
||||
);
|
||||
expect(
|
||||
result.occurrences
|
||||
.filter(({ logical_path }) => logical_path !== ".")
|
||||
.map(({ logical_path }) => logical_path)
|
||||
.sort(),
|
||||
).toEqual(["Main.js", "main.js"]);
|
||||
const output = join(root, "output");
|
||||
const extracted = await new ArtifactProvider(process.env)
|
||||
.createClient(parsed.value)
|
||||
.execute(
|
||||
"extract_artifact",
|
||||
artifactExtractionExecutionSchema.parse({ output_root: output }),
|
||||
);
|
||||
if (!caseSensitive) {
|
||||
if (extracted.ok) throw new Error("expected a destination case collision");
|
||||
expect(projectAnalysisError(extracted.error)).toMatchObject({
|
||||
message:
|
||||
"Destination filesystem cannot store both main.js and Main.js; inventory retains both logical names.",
|
||||
details: { operation: "extract_artifact", reason: "path" },
|
||||
});
|
||||
await expect(lstat(output)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
return;
|
||||
}
|
||||
if (!extracted.ok) throw extracted.error;
|
||||
expect(await readFile(join(output, "Main.js"), "utf8")).toBe("upper");
|
||||
expect(await readFile(join(output, "main.js"), "utf8")).toBe("lower");
|
||||
});
|
||||
const inventory = async (targetValue: BinaryTarget) => {
|
||||
const result = await new ArtifactProvider(process.env)
|
||||
|
||||
@@ -6,30 +6,73 @@ import { writeOrderedZip } from "../../../fixtures/artifactEntryOrder.js";
|
||||
import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { parseBinaryTarget } from "../../../../src/application/BinaryTargetResolver.js";
|
||||
import {
|
||||
destinationCaseCollisionMessage,
|
||||
ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION,
|
||||
} from "../../../../src/artifacts/ArtifactPaths.js";
|
||||
import { ArtifactProvider } from "../../../../src/artifacts/ArtifactProvider.js";
|
||||
import { artifactInventoryResultSchema } from "../../../../src/domain/artifactGraph.js";
|
||||
import { ArtifactOperationError } from "../../../../src/domain/artifactOperationError.js";
|
||||
import { projectAnalysisError } from "../../../../src/domain/analysisErrorProjection.js";
|
||||
|
||||
it.each([
|
||||
[
|
||||
["Main.js", "main.js"],
|
||||
"Artifact path collision: main.js differs only in case from Main.js",
|
||||
],
|
||||
[["a\\b.js"], 'Artifact path is absolute or unsafe: "a\\\\b.js"'],
|
||||
] as const)(
|
||||
"reports the failed path constraint for %j",
|
||||
async (entries, detail) => {
|
||||
const root = await createTestTempDirectory("rea-artifact-detail-");
|
||||
const path = join(root, "fixture.zip");
|
||||
await writeOrderedZip(path, entries);
|
||||
const target = await parseBinaryTarget(path);
|
||||
if (!target.ok) throw new Error("expected a ZIP target");
|
||||
const result = await new ArtifactProvider(process.env)
|
||||
.createClient(target.value)
|
||||
.execute("inventory_artifact", {});
|
||||
if (result.ok) throw new Error("expected the path constraint to fail");
|
||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||
code: "artifact_operation_failed",
|
||||
details: { operation: "inventory_artifact", reason: "path", detail },
|
||||
});
|
||||
},
|
||||
);
|
||||
it("keeps logical names that differ only in case and records the limitation", async () => {
|
||||
const root = await createTestTempDirectory("rea-artifact-detail-");
|
||||
const path = join(root, "fixture.zip");
|
||||
await writeOrderedZip(path, ["Main.js", "main.js"]);
|
||||
const target = await parseBinaryTarget(path);
|
||||
if (!target.ok) throw new Error("expected a ZIP target");
|
||||
const result = await new ArtifactProvider(process.env)
|
||||
.createClient(target.value)
|
||||
.execute("inventory_artifact", {});
|
||||
if (!result.ok) throw result.error;
|
||||
const inventory = artifactInventoryResultSchema.parse(result.value.result);
|
||||
expect(inventory.occurrences.map(({ logical_path }) => logical_path)).toEqual(
|
||||
expect.arrayContaining(["Main.js", "main.js"]),
|
||||
);
|
||||
expect(inventory.limitations).toContain(
|
||||
ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION,
|
||||
);
|
||||
for (const logicalPath of ["Main.js", "main.js"]) {
|
||||
expect(
|
||||
inventory.occurrences
|
||||
.find((occurrence) => occurrence.logical_path === logicalPath)
|
||||
?.limitations.join("\n"),
|
||||
).toContain("English (en-US) Unicode case folding");
|
||||
}
|
||||
});
|
||||
|
||||
it("reports an unsafe path as a hostile artifact path", async () => {
|
||||
const root = await createTestTempDirectory("rea-artifact-detail-");
|
||||
const path = join(root, "fixture.zip");
|
||||
await writeOrderedZip(path, ["a\\b.js"]);
|
||||
const target = await parseBinaryTarget(path);
|
||||
if (!target.ok) throw new Error("expected a ZIP target");
|
||||
const result = await new ArtifactProvider(process.env)
|
||||
.createClient(target.value)
|
||||
.execute("inventory_artifact", {});
|
||||
if (result.ok) throw new Error("expected the path constraint to fail");
|
||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||
code: "artifact_operation_failed",
|
||||
message:
|
||||
"Artifact contains an unsafe internal path. Inspect the reported path and correct the artifact before retrying.",
|
||||
details: {
|
||||
operation: "inventory_artifact",
|
||||
reason: "path",
|
||||
detail: 'Artifact path is absolute or unsafe: "a\\\\b.js"',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a destination case collision as the user-facing path message", () => {
|
||||
const detail = destinationCaseCollisionMessage("res/2f.xml", ["2F.xml"]);
|
||||
expect(detail).toEqual(expect.any(String));
|
||||
if (detail === undefined) return;
|
||||
expect(
|
||||
projectAnalysisError(
|
||||
new ArtifactOperationError("extract_artifact", "path", undefined, detail),
|
||||
),
|
||||
).toMatchObject({
|
||||
message: detail,
|
||||
details: { reason: "path", detail },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -86,6 +86,12 @@ describe("Android application projection", () => {
|
||||
expect(left.bridge_candidates).toEqual([
|
||||
expect.objectContaining({ basis: "react-native-convention" }),
|
||||
]);
|
||||
expect(left.limitations).toEqual(
|
||||
expect.arrayContaining([
|
||||
"A bridge basis is inferred from the native path and is repeated for every managed component.",
|
||||
"ZIP inventory cannot see the APK Signing Block, so an empty signing array does not mean the APK is unsigned.",
|
||||
]),
|
||||
);
|
||||
expect(JSON.stringify(left)).not.toContain("opaque signing");
|
||||
});
|
||||
|
||||
@@ -146,6 +152,45 @@ describe("Android application projection", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("case-distinct APK resource names", () => {
|
||||
it("inventories and projects an APK whose resource names differ only in case", async () => {
|
||||
const root = await createTestTempDirectory("rea-android-case-");
|
||||
const path = join(root, "Shrunk.apk");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
await writer.add(
|
||||
"AndroidManifest.xml",
|
||||
new Uint8ArrayReader(Uint8Array.from([3, 0, 8, 0])),
|
||||
);
|
||||
await writer.add(
|
||||
"classes.dex",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x35, 0]),
|
||||
),
|
||||
);
|
||||
await writer.add("res/2F.xml", new TextReader("upper"));
|
||||
await writer.add("res/2f.xml", new TextReader("lower"));
|
||||
await writeFile(path, await writer.close());
|
||||
|
||||
const inventory = parseEvidence(
|
||||
await runProviderAnalysis(path, "inventory_artifact", {}),
|
||||
);
|
||||
const result = projectAndroidApplicationEvidence({
|
||||
inventory_evidence: [inventory],
|
||||
});
|
||||
const projection = androidApplicationProjectionResultSchema.parse(
|
||||
requireSuccessfulProjection(result).normalized_result,
|
||||
);
|
||||
expect(projection.root_format).toBe("apk");
|
||||
expect(projection.components.manifests).toHaveLength(1);
|
||||
expect(projection.components.dex).toHaveLength(1);
|
||||
expect(JSON.stringify(inventory)).toContain("res/2F.xml");
|
||||
expect(JSON.stringify(inventory)).toContain("res/2f.xml");
|
||||
expect(JSON.stringify(inventory)).toContain(
|
||||
"English (en-US) Unicode case folding",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Android bridge candidate coverage", () => {
|
||||
it("returns every component and bridge candidate from the inventory", async () => {
|
||||
const root = await createTestTempDirectory("rea-android-complete-");
|
||||
|
||||
Vendored
+5
-4
@@ -74,10 +74,11 @@ export const createJadxProtocolFixture = async (
|
||||
ownsProcessLifetime: true,
|
||||
cleanup: () => cleanupOwnedProcessGroup(spawned.ownership),
|
||||
});
|
||||
const stopped = await supervisor.stop();
|
||||
expect(stopped, JSON.stringify(stopped)).not.toMatchObject({
|
||||
status: "incomplete",
|
||||
});
|
||||
// The SDK can close the child transport before process exit settles.
|
||||
// Retry retained ownership without bypassing the supervisor's proof.
|
||||
await expect
|
||||
.poll(() => supervisor.stop(), { timeout: 5_000 })
|
||||
.not.toMatchObject({ status: "incomplete" });
|
||||
if (options.cwd !== undefined)
|
||||
await rm(options.cwd, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
Vendored
+1
@@ -22,6 +22,7 @@ export const CLIENT_LOCATION_ENVIRONMENT = [
|
||||
"PI_CODING_AGENT_DIR",
|
||||
"PI_CONFIG_DIR",
|
||||
"PI_PROFILE",
|
||||
"QWEN_HOME",
|
||||
"SAND_DATA_ROOT",
|
||||
"XDG_CONFIG_HOME",
|
||||
] as const;
|
||||
|
||||
Reference in New Issue
Block a user