From 78e1308f49492011be448c9b35ce16d98d60c4ad Mon Sep 17 00:00:00 2001 From: Ysopwnable <161784452+N0zoM1z0@users.noreply.github.com> Date: Sat, 10 Oct 2026 14:58:15 +0800 Subject: [PATCH 01/19] docs(process): clarify normalized terminal line representation --- docs/process-capture.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/process-capture.md b/docs/process-capture.md index c315e3e9e..5cc246ec2 100644 --- a/docs/process-capture.md +++ b/docs/process-capture.md @@ -110,11 +110,14 @@ while comparisons and trace assertions use the normalized text. Retaining the original adds at most `limits.output_bytes` of text, because it comes from the same admitted PTY chunks rather than a second unbounded stream. -Rendered frame `lines` hold the visible rows after normalization, without -trailing spaces; pad a line to the frame's `columns` to restore the fixed-width -row. `serialized_state` keeps the exact terminal state. Captures commit this -line format in their comparison contract, so a capture whose lines were padded -to full width does not compare as the same contract. +Rendered frame `lines` hold the visible rows after normalization, with trailing +U+0020 spaces removed. Blank rows and internal spaces remain. `columns` records +terminal cell width; normalization and Unicode can make string lengths differ +from that width. `serialized_state` holds terminal serialization after the +selected normalization. Original admitted PTY chunks are available through +`raw_data ?? data`, as described above. Captures commit this line format in their +comparison contract, so a capture whose lines were padded to full width does not +compare as the same contract. Port normalization recognizes explicit `port`, `tcp_port`, `udp_port`, and `listen` fields, URL authorities, IP endpoints, and `localhost` endpoints, with From 79f6756239105164eac7aa5618844ffd9bdf41e5 Mon Sep 17 00:00:00 2001 From: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Date: Sat, 10 Oct 2026 00:00:09 -0700 Subject: [PATCH 02/19] docs(website): link the Discord community and REA on X (#1469) Add an X link beside the GitHub and Discord header icons on every content page, name the footer links "Join the community" and "Follow us on X", and close the homepage with a "Join the community" section. On narrow screens, pad the footer so the floating Top link no longer covers its last row of links. Co-authored-by: Claude Opus 5.5 --- website/README.md | 4 +- website/public/assets/styles.css | 12 ++++-- website/public/examples/dino-lab/index.html | 22 +++++++++- website/public/faq/index.html | 22 +++++++++- website/public/first-investigation/index.html | 22 +++++++++- website/public/get-started/index.html | 22 +++++++++- website/public/guides/browser/index.html | 22 +++++++++- website/public/guides/index.html | 22 +++++++++- website/public/guides/javascript/index.html | 22 +++++++++- website/public/guides/native/index.html | 22 +++++++++- website/public/index.html | 40 ++++++++++++++++++- website/public/showcase/aegis/index.html | 22 +++++++++- website/public/showcase/ctf/index.html | 22 +++++++++- website/public/showcase/dx-ball/index.html | 22 +++++++++- website/public/showcase/index.html | 22 +++++++++- website/public/showcase/notion/index.html | 22 +++++++++- website/public/showcase/th04/index.html | 22 +++++++++- 17 files changed, 345 insertions(+), 19 deletions(-) diff --git a/website/README.md b/website/README.md index 2005c633d..4262ccb24 100644 --- a/website/README.md +++ b/website/README.md @@ -181,7 +181,9 @@ the analysis guides. Case-study previews live on the Showcases page. The closing section offers copyable project prompts, from cloning `rea.tools` to reconstructing a game from its executable. The experienced-reader shortcut lands directly on the guide links below these prompts. -The page ends with FAQ, Discord and issue-report links under “Any questions?”. +“Any questions?” offers FAQ, Discord and issue-report links. The page ends +with “Join the community”, which links Discord and REA's X account. +Every content page's header and footer link GitHub, Discord and X. A right-side table of contents stays visible at widths of 1440px and above. On narrower screens it becomes a sticky, native disclosure; selecting a link closes the menu and focuses the destination. The homepage script follows diff --git a/website/public/assets/styles.css b/website/public/assets/styles.css index fb7093b9e..2020fd5f8 100644 --- a/website/public/assets/styles.css +++ b/website/public/assets/styles.css @@ -178,7 +178,8 @@ section[id] { gap: 8px; } .nav-github, -.nav-discord { +.nav-discord, +.nav-x { display: inline-flex; align-items: center; justify-content: center; @@ -192,12 +193,14 @@ section[id] { text-decoration: none; } .nav-github:hover, -.nav-discord:hover { +.nav-discord:hover, +.nav-x:hover { background: var(--soft); color: var(--ink); } .nav-github svg, -.nav-discord svg { +.nav-discord svg, +.nav-x svg { display: block; flex-shrink: 0; } @@ -2117,6 +2120,9 @@ pre code { right: calc(1rem + env(safe-area-inset-right, 0px)); bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); } + .site-footer { + padding-bottom: calc(2rem + 44px + env(safe-area-inset-bottom, 0px)); + } .container { width: calc(100% - 2.5rem); } diff --git a/website/public/examples/dino-lab/index.html b/website/public/examples/dino-lab/index.html index bfae79460..d0bc84c76 100644 --- a/website/public/examples/dino-lab/index.html +++ b/website/public/examples/dino-lab/index.html @@ -107,6 +107,25 @@ /> + + + @@ -383,7 +402,8 @@ SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/faq/index.html b/website/public/faq/index.html index 60fe1183d..fa4a64a83 100644 --- a/website/public/faq/index.html +++ b/website/public/faq/index.html @@ -107,6 +107,25 @@ /> + + + @@ -482,7 +501,8 @@ SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/first-investigation/index.html b/website/public/first-investigation/index.html index 349ece913..a642735c2 100644 --- a/website/public/first-investigation/index.html +++ b/website/public/first-investigation/index.html @@ -106,6 +106,25 @@ /> + + + @@ -420,7 +439,8 @@ JS SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/get-started/index.html b/website/public/get-started/index.html index b86987e9e..d13ad67ba 100644 --- a/website/public/get-started/index.html +++ b/website/public/get-started/index.html @@ -106,6 +106,25 @@ /> + + + @@ -479,7 +498,8 @@ npx rea-agents@latest setup SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/guides/browser/index.html b/website/public/guides/browser/index.html index 95a0aaaae..b1567f9f1 100644 --- a/website/public/guides/browser/index.html +++ b/website/public/guides/browser/index.html @@ -100,6 +100,25 @@ /> + + + @@ -403,7 +422,8 @@ link.click(); SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/guides/index.html b/website/public/guides/index.html index babd58bdf..eeed0e7f1 100644 --- a/website/public/guides/index.html +++ b/website/public/guides/index.html @@ -100,6 +100,25 @@ /> + + + @@ -186,7 +205,8 @@ SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/guides/javascript/index.html b/website/public/guides/javascript/index.html index 5212b579d..8e77022fe 100644 --- a/website/public/guides/javascript/index.html +++ b/website/public/guides/javascript/index.html @@ -106,6 +106,25 @@ /> + + + @@ -405,7 +424,8 @@ SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/guides/native/index.html b/website/public/guides/native/index.html index a0e19caf5..f3c4a658a 100644 --- a/website/public/guides/native/index.html +++ b/website/public/guides/native/index.html @@ -100,6 +100,25 @@ /> + + + @@ -335,7 +354,8 @@ return (DxBallInt)pan; SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/index.html b/website/public/index.html index 0282d64de..11d70c1d9 100644 --- a/website/public/index.html +++ b/website/public/index.html @@ -109,6 +109,25 @@ /> + + + @@ -134,6 +153,7 @@
  • Try REA
  • Go deeper
  • Help & feedback
  • +
  • Community
  • @@ -1052,6 +1072,23 @@ SPEED: 6

    +
    +
    +

    Join the community

    +

    + Share investigations and get help from other REA users on Discord. + Follow REA on X for project updates. +

    + +
    +
    diff --git a/website/public/showcase/aegis/index.html b/website/public/showcase/aegis/index.html index 05a230501..7949addfd 100644 --- a/website/public/showcase/aegis/index.html +++ b/website/public/showcase/aegis/index.html @@ -108,6 +108,25 @@ /> + + + @@ -718,7 +737,8 @@ npx rea-agents@latest inspect-android-package \ SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/showcase/ctf/index.html b/website/public/showcase/ctf/index.html index ed2002924..afe735fee 100644 --- a/website/public/showcase/ctf/index.html +++ b/website/public/showcase/ctf/index.html @@ -107,6 +107,25 @@ /> + + + @@ -688,7 +707,8 @@ chmod +x ms_flag_checker SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/showcase/dx-ball/index.html b/website/public/showcase/dx-ball/index.html index d47449978..d89d2bf5b 100644 --- a/website/public/showcase/dx-ball/index.html +++ b/website/public/showcase/dx-ball/index.html @@ -107,6 +107,25 @@ /> + + + @@ -696,7 +715,8 @@ SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/showcase/index.html b/website/public/showcase/index.html index f0a537f69..168afcde9 100644 --- a/website/public/showcase/index.html +++ b/website/public/showcase/index.html @@ -107,6 +107,25 @@ /> + + + @@ -228,7 +247,8 @@ SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/showcase/notion/index.html b/website/public/showcase/notion/index.html index 5120d8ca6..c276d16c9 100644 --- a/website/public/showcase/notion/index.html +++ b/website/public/showcase/notion/index.html @@ -107,6 +107,25 @@ /> + + + @@ -534,7 +553,8 @@ mimeTypes: SourceMIT licenseCommunity + >Join the communityFollow us on X diff --git a/website/public/showcase/th04/index.html b/website/public/showcase/th04/index.html index e08f8f2a3..9a89af639 100644 --- a/website/public/showcase/th04/index.html +++ b/website/public/showcase/th04/index.html @@ -107,6 +107,25 @@ /> + + + @@ -711,7 +730,8 @@ no_aim: SourceMIT licenseCommunity + >Join the communityFollow us on X From 934ffd28d15f4fbe6687ca8986a949e1b41a07d1 Mon Sep 17 00:00:00 2001 From: keemsisi Date: Sat, 10 Oct 2026 08:09:18 +0100 Subject: [PATCH 03/19] perf(javascript): derive the application graph ID once createJavaScriptApplicationGraph hashed the whole graph to derive its graph_id, then parsed it with the public schema, whose invariant check hashed the same content again to verify that ID. Validate the content with every other invariant first, then derive graph_id once from the validated copy. The public schema still verifies graph_id for stored and untrusted graphs, and created graphs are unchanged. --- .../javascriptApplicationGraph.test.ts | 15 +++++++++++++ .../javascript/javascriptApplicationGraph.ts | 22 ++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/domain/javascript/javascriptApplicationGraph.test.ts b/src/domain/javascript/javascriptApplicationGraph.test.ts index efedf78c0..58f127928 100644 --- a/src/domain/javascript/javascriptApplicationGraph.test.ts +++ b/src/domain/javascript/javascriptApplicationGraph.test.ts @@ -547,6 +547,21 @@ describe("JavaScript Application Graph: source maps and observations", () => { /Edge identifier/u, ); }); + + it("creates exactly the graph the public schema accepts", () => { + const graph = buildSyntheticJavaScriptApplicationGraph(); + expect(JSON.stringify(graph)).toBe( + JSON.stringify( + javascriptApplicationGraphSchema.parse(structuredClone(graph)), + ), + ); + + const { graph_id: _graphId, ...semantic } = structuredClone(graph); + firstOf(semantic.edges, "edge").edge_id = `jag_edge_${"f".repeat(64)}`; + expect(() => createJavaScriptApplicationGraph(semantic)).toThrow( + /Edge identifier/u, + ); + }); }); describe("JavaScript Application Graph: duplicate and orphan rejection", () => { diff --git a/src/domain/javascript/javascriptApplicationGraph.ts b/src/domain/javascript/javascriptApplicationGraph.ts index ba122e1f0..e16aded75 100644 --- a/src/domain/javascript/javascriptApplicationGraph.ts +++ b/src/domain/javascript/javascriptApplicationGraph.ts @@ -304,8 +304,8 @@ const checkNode = ( type GraphRecord = z.infer; -const checkGraphInvariants = ( - graph: GraphRecord, +const checkGraphContent = ( + graph: JavaScriptApplicationGraphInput, context: z.RefinementCtx, ): void => { sortedUniqueIssue( @@ -394,7 +394,13 @@ const checkGraphInvariants = ( context, ); } +}; +const checkGraphInvariants = ( + graph: GraphRecord, + context: z.RefinementCtx, +): void => { + checkGraphContent(graph, context); const { graph_id: identifier, ...semantic } = graph; if ( identifier !== @@ -411,6 +417,9 @@ const checkGraphInvariants = ( export const javascriptApplicationGraphSchema = javascriptApplicationGraphRecordSchema.superRefine(checkGraphInvariants); +const javascriptApplicationGraphContentSchema = + javascriptApplicationGraphInputSchema.superRefine(checkGraphContent); + /** Fully validated JavaScript Application Graph. */ export type JavaScriptApplicationGraph = z.infer< typeof javascriptApplicationGraphSchema @@ -482,10 +491,11 @@ export const createJavaScriptApplicationGraph = ( }, limitations: uniqueSorted(parsed.limitations), }; - return javascriptApplicationGraphSchema.parse({ - ...semantic, - graph_id: `jag_${digestCanonicalValue(semantic, "JavaScript Application Graph")}`, - }); + const content = javascriptApplicationGraphContentSchema.parse(semantic); + return { + ...content, + graph_id: `jag_${digestCanonicalValue(content, "JavaScript Application Graph")}`, + }; }; const validatedImmutableApplicationGraphs = new WeakSet(); From aa23ec883f6c7101db184767a1f48cddb636d597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=93=E8=89=AF?= <1204183885@qq.com> Date: Sat, 10 Oct 2026 15:12:09 +0800 Subject: [PATCH 04/19] feat(clients): register Qwen Code during setup (#1415) * feat(clients): register Qwen Code during setup * fix(clients): honor Qwen home and shared skill discovery --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> --- docs/installation.md | 15 +- scripts/verify-package-environment.mjs | 1 + src/application/ClientRegistrationStatus.ts | 1 + src/application/SupportedClients.ts | 31 ++- .../filesystem/clientLifecycle.test.ts | 1 + .../qwenClientConfiguration.test.ts | 183 ++++++++++++++++++ tests/fixtures/clientEnvironment.ts | 1 + 7 files changed, 228 insertions(+), 5 deletions(-) create mode 100644 tests/boundary/filesystem/qwenClientConfiguration.test.ts diff --git a/docs/installation.md b/docs/installation.md index 38ea09f5a..acc285e69 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -135,10 +135,17 @@ listed after the table because its connector is not one of these files: | Antigravity | `antigravity` | | GitHub Copilot CLI | `copilot_cli` | | Command Code | `commandcode` | +| Qwen Code | `qwen_code` | | VS Code | `vscode` | | Grok Build | `grok_build` | | OMP | `omp` | +For Qwen Code, setup registers `rea` in the `mcpServers` table of the +user-level `~/.qwen/settings.json`, or `$QWEN_HOME/settings.json` when configured. +Setup and doctor follow Qwen Code's tilde and working-directory-relative home +overrides. Qwen Code also discovers personal skills in `~/.agents/skills`, +where setup installs the bundled workflow. + For OMP, setup writes a `type: "stdio"` entry to the user-level `~/.omp/agent/mcp.json`. It follows `PI_CONFIG_DIR`, an absolute `PI_CODING_AGENT_DIR`, and the profile selected by `OMP_PROFILE` or @@ -194,10 +201,10 @@ save verified paths for an existing Ghidra installation. The bundled skill is installed where each selected client discovers personal skills: Claude Code uses `~/.claude/skills` (or -`$CLAUDE_CONFIG_DIR/skills` when configured), while other supported clients -use the shared `~/.agents/skills` directory. A mixed selection plans both -paths. Selecting the skill without a client uses the shared directory. Setup -leaves existing skill copies in other locations untouched. +`$CLAUDE_CONFIG_DIR/skills` when configured), while other supported clients, +including Qwen Code, use the shared `~/.agents/skills` directory. A mixed selection +plans the relevant paths. Selecting the skill without a client uses the shared +directory. Setup leaves existing skill copies in other locations untouched. `doctor --skill --json` verifies the selected copies against the bundled instructions and references. Consumers should use `identity.skill.state`, diff --git a/scripts/verify-package-environment.mjs b/scripts/verify-package-environment.mjs index f9ee010af..1a97cfbab 100644 --- a/scripts/verify-package-environment.mjs +++ b/scripts/verify-package-environment.mjs @@ -85,6 +85,7 @@ export async function verifyPackageEnvironment({ PI_CODING_AGENT_DIR: undefined, PI_CONFIG_DIR: undefined, PI_PROFILE: undefined, + QWEN_HOME: undefined, OPENCODE_CONFIG: undefined, XDG_CONFIG_HOME: join(home, ".config"), PATH: `${fakeBin}:${process.env.PATH ?? ""}`, diff --git a/src/application/ClientRegistrationStatus.ts b/src/application/ClientRegistrationStatus.ts index a657f1df4..1f5a12473 100644 --- a/src/application/ClientRegistrationStatus.ts +++ b/src/application/ClientRegistrationStatus.ts @@ -91,6 +91,7 @@ export const readClientRegistrationStatuses = async ( PI_CODING_AGENT_DIR: options.environment.PI_CODING_AGENT_DIR, PI_CONFIG_DIR: options.environment.PI_CONFIG_DIR, PI_PROFILE: options.environment.PI_PROFILE, + QWEN_HOME: options.environment.QWEN_HOME, SAND_DATA_ROOT: options.environment.SAND_DATA_ROOT, XDG_CONFIG_HOME: options.environment.XDG_CONFIG_HOME, }, diff --git a/src/application/SupportedClients.ts b/src/application/SupportedClients.ts index 97467a227..52f5577ca 100644 --- a/src/application/SupportedClients.ts +++ b/src/application/SupportedClients.ts @@ -1,4 +1,4 @@ -import { isAbsolute, join } from "node:path"; +import { isAbsolute, join, resolve } from "node:path"; import { lstatSync } from "node:fs"; /** One supported client configuration location. */ @@ -35,6 +35,7 @@ interface ClientPathContext { readonly PI_CODING_AGENT_DIR?: string | undefined; readonly PI_CONFIG_DIR?: string | undefined; readonly PI_PROFILE?: string | undefined; + readonly QWEN_HOME?: string | undefined; readonly SAND_DATA_ROOT?: string | undefined; readonly XDG_CONFIG_HOME?: string | undefined; }; @@ -85,6 +86,25 @@ const claudeCodeMarkerDirectory = ({ home, env }: ClientPathContext): string => const codexDirectory = ({ home, env }: ClientPathContext): string => env.CODEX_HOME ?? join(home, ".codex"); +/** Match Qwen Code's home override, including tilde and cwd-relative paths. */ +const qwenCodeDirectory = ({ home, env }: ClientPathContext): string => { + const override = env.QWEN_HOME; + if (!override) return join(home, ".qwen"); + const expanded = + override === "~" + ? home + : override.startsWith("~/") || override.startsWith("~\\") + ? join( + home, + ...override + .slice(2) + .split(/[/\\]+/) + .filter(Boolean), + ) + : override; + return isAbsolute(expanded) ? expanded : resolve(expanded); +}; + const grokDirectory = ({ home, env }: ClientPathContext): string => env.GROK_HOME ?? join(home, ".grok"); @@ -272,6 +292,14 @@ export const SUPPORTED_CLIENT_DEFINITIONS = [ markerPath: commandCodeDirectory, format: "commandcode", }, + { + name: "qwen_code", + displayName: "Qwen Code", + configPath: (context: ClientPathContext) => + join(qwenCodeDirectory(context), "settings.json"), + markerPath: qwenCodeDirectory, + format: "json", + }, { name: "vscode", displayName: "VS Code", @@ -323,6 +351,7 @@ export const supportedClients = ( PI_CODING_AGENT_DIR: process.env.PI_CODING_AGENT_DIR, PI_CONFIG_DIR: process.env.PI_CONFIG_DIR, PI_PROFILE: process.env.PI_PROFILE, + QWEN_HOME: process.env.QWEN_HOME, SAND_DATA_ROOT: process.env.SAND_DATA_ROOT, XDG_CONFIG_HOME: process.env.XDG_CONFIG_HOME, }, diff --git a/tests/boundary/filesystem/clientLifecycle.test.ts b/tests/boundary/filesystem/clientLifecycle.test.ts index 88eab9953..297787a10 100644 --- a/tests/boundary/filesystem/clientLifecycle.test.ts +++ b/tests/boundary/filesystem/clientLifecycle.test.ts @@ -59,6 +59,7 @@ describe("client configuration filesystem lifecycle", () => { "antigravity", "copilot_cli", "commandcode", + "qwen_code", "vscode", "grok_build", "omp", diff --git a/tests/boundary/filesystem/qwenClientConfiguration.test.ts b/tests/boundary/filesystem/qwenClientConfiguration.test.ts new file mode 100644 index 000000000..0fae29640 --- /dev/null +++ b/tests/boundary/filesystem/qwenClientConfiguration.test.ts @@ -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[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", + }); + }, + ); +}); diff --git a/tests/fixtures/clientEnvironment.ts b/tests/fixtures/clientEnvironment.ts index 79961e49d..0db5a69ec 100644 --- a/tests/fixtures/clientEnvironment.ts +++ b/tests/fixtures/clientEnvironment.ts @@ -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; From 3c7b176a3df18b3971d9ea9ff40f7ebbd85fa40a Mon Sep 17 00:00:00 2001 From: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Date: Sat, 10 Oct 2026 00:12:17 -0700 Subject: [PATCH 05/19] perf(artifacts): deliver the inspected artifact graph once (#1473) inspect_artifact nested the complete inventory Evidence and then restated every artifact node and occurrence as an observation and every edge as a derived relationship. No caller reads those copies; comparison and tests use the nested inventory Evidence. On Transmission.app the result shrinks from 2.46 MB to 1.10 MB. Observations keep the root manifest and integrity findings. Co-authored-by: Claude Opus 5.5 --- src/contracts/artifactToolContracts.ts | 2 +- src/domain/artifactInspection.ts | 59 +------------------ .../artifactProvider.archiveInventory.test.ts | 9 +++ 3 files changed, 13 insertions(+), 57 deletions(-) diff --git a/src/contracts/artifactToolContracts.ts b/src/contracts/artifactToolContracts.ts index a6926a19f..744ea34c3 100644 --- a/src/contracts/artifactToolContracts.ts +++ b/src/contracts/artifactToolContracts.ts @@ -63,7 +63,7 @@ const artifact = < export const ARTIFACT_TOOL_CONTRACTS = [ artifact( "inspect_artifact", - "Inspect an active archive or application package in one call. Returns the complete content-addressed artifact graph, source Evidence, observations, relationships, integrity contradictions, hypotheses, unexplored branches, limitations, and next probes inline. Read-only DMG mounting is used automatically on supported macOS hosts. Integrity mismatches fail by default; record-and-continue keeps mismatches explicitly untrusted. It does not extract files; use extract_artifact to materialize its regular contents.", + "Inspect an active archive or application package in one call. Returns the complete content-addressed artifact graph once, as the nested inventory Evidence, with root and integrity observations, integrity contradictions, hypotheses, unexplored branches, limitations, and next probes inline. Read-only DMG mounting is used automatically on supported macOS hosts. Integrity mismatches fail by default; record-and-continue keeps mismatches explicitly untrusted. It does not extract files; use extract_artifact to materialize its regular contents.", artifactInventoryInputSchema, ), artifact( diff --git a/src/domain/artifactInspection.ts b/src/domain/artifactInspection.ts index f4c197b9c..19ccb9b8f 100644 --- a/src/domain/artifactInspection.ts +++ b/src/domain/artifactInspection.ts @@ -16,30 +16,12 @@ const artifactIdSchema = prefixedDigestSchema("art"); const inspectionObservationSchema = z.strictObject({ observation_id: prefixedDigestSchema("aio"), - kind: z.enum(["root-manifest", "artifact", "occurrence", "integrity"]), + kind: z.enum(["root-manifest", "integrity"]), subject: textSchema, value: jsonValueSchema, evidence_id: evidenceIdSchema, }); -const inspectionRelationshipSchema = z.strictObject({ - relationship_id: prefixedDigestSchema("air"), - relation: z.enum([ - "contains", - "extracts", - "slice-of", - "embeds", - "loads", - "maps-source", - "derived-from", - ]), - source_artifact_id: artifactIdSchema, - target_artifact_id: artifactIdSchema, - occurrence_id: prefixedDigestSchema("occ"), - logical_path: textSchema.nullable(), - evidence_id: evidenceIdSchema, -}); - const inspectionHypothesisSchema = z.strictObject({ hypothesis_id: prefixedDigestSchema("aih"), statement: textSchema, @@ -97,7 +79,6 @@ export const artifactInspectionResultSchema = z.strictObject({ ) .min(1), observations: z.array(inspectionObservationSchema), - derived_relationships: z.array(inspectionRelationshipSchema), hypotheses: z.array(inspectionHypothesisSchema), contradictions: z.array(inspectionContradictionSchema), unexplored_branches: z.array(unexploredBranchSchema), @@ -107,8 +88,6 @@ export const artifactInspectionResultSchema = z.strictObject({ substeps_completed: z.literal(1), observations_retained: z.number().int().min(0), observations_omitted: z.number().int().min(0), - relationships_retained: z.number().int().min(0), - relationships_omitted: z.number().int().min(0), hypotheses_retained: z.number().int().min(0), hypotheses_omitted: z.number().int().min(0), unexplored_branches_retained: z.number().int().min(0), @@ -136,10 +115,6 @@ export const createArtifactInspection = ( inventory, inventoryEvidence.evidence_id, ); - const relationships = allRelationships( - inventory, - inventoryEvidence.evidence_id, - ); const hypotheses = allHypotheses(inventory, inventoryEvidence.evidence_id); const nextProbes = probesFor(inventory); const branches = allUnexploredBranches( @@ -149,14 +124,12 @@ export const createArtifactInspection = ( ); const retained = { observations, - relationships, hypotheses, branches, probes: nextProbes, }; const omissions = { observations: 0, - relationships: 0, hypotheses: 0, branches: 0, probes: 0, @@ -184,7 +157,6 @@ export const createArtifactInspection = ( }, ], observations: retained.observations, - derived_relationships: retained.relationships, hypotheses: retained.hypotheses, contradictions: contradictions(inventory, inventoryEvidence.evidence_id), unexplored_branches: retained.branches, @@ -194,8 +166,6 @@ export const createArtifactInspection = ( substeps_completed: 1 as const, observations_retained: retained.observations.length, observations_omitted: omissions.observations, - relationships_retained: retained.relationships.length, - relationships_omitted: omissions.relationships, hypotheses_retained: retained.hypotheses.length, hypotheses_omitted: omissions.hypotheses, unexplored_branches_retained: retained.branches.length, @@ -224,6 +194,8 @@ const parseInventoryEvidence = (input: unknown): Evidence => { return evidence; }; +// Artifact, occurrence, and edge records stay in the nested inventory Evidence; +// restating each one here would repeat the complete graph in every result. const allObservations = ( inventory: ArtifactInventoryResult, evidenceId: string, @@ -234,12 +206,6 @@ const allObservations = ( inventory.manifest, evidenceId, ), - ...inventory.nodes.map((node) => - observation("artifact", node.artifact_id, node, evidenceId), - ), - ...inventory.occurrences.map((occurrence) => - observation("occurrence", occurrence.occurrence_id, occurrence, evidenceId), - ), ...inventory.integrity_contradictions.map((value) => observation("integrity", value.contradiction_id, value, evidenceId), ), @@ -263,25 +229,6 @@ const observation = ( }; }; -const allRelationships = ( - inventory: ArtifactInventoryResult, - evidenceId: string, -): ArtifactInspectionResult["derived_relationships"] => - inventory.edges.map((edge) => { - const semantic = { - relation: edge.relation, - source_artifact_id: edge.parent_artifact_id, - target_artifact_id: edge.child_artifact_id, - occurrence_id: edge.occurrence_id, - logical_path: edge.logical_path, - evidence_id: evidenceId, - }; - return { - relationship_id: `air_${digestCanonicalValue(semantic, "Artifact inspection")}`, - ...semantic, - }; - }); - const allHypotheses = ( inventory: ArtifactInventoryResult, evidenceId: string, diff --git a/tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts b/tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts index 06fe70527..2da4a98f4 100644 --- a/tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts +++ b/tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts @@ -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( From 7296f2b5bfff921b2ca16f942a09616c8adf2b3f Mon Sep 17 00:00:00 2001 From: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Date: Sat, 10 Oct 2026 00:13:34 -0700 Subject: [PATCH 06/19] perf(javascript)!: stop repeating the semantic identifier strategy per fact (#1474) Every semantic graph node and relation carried an identifier_strategy object whose schema admits exactly one value per record type. The constant made up about 9% of analyze_javascript_application output (Obsidian app.asar: 12.04 MB to 10.96 MB), and semantic traces repeated it on every returned fact. The node_id and relation_id schema descriptions now state how each identifier is derived. BREAKING CHANGE: Semantic graph nodes and relations no longer include identifier_strategy, and relation IDs no longer hash that constant. Evidence recorded by earlier versions does not validate against the new semantic graph schema. Co-authored-by: Claude Opus 5.5 --- src/domain/javascript/javascriptSemanticGraph.ts | 8 -------- .../javascript/javascriptSemanticGraphSchemas.ts | 16 ++++++---------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/domain/javascript/javascriptSemanticGraph.ts b/src/domain/javascript/javascriptSemanticGraph.ts index 69b3bb967..9ab2dd485 100644 --- a/src/domain/javascript/javascriptSemanticGraph.ts +++ b/src/domain/javascript/javascriptSemanticGraph.ts @@ -127,10 +127,6 @@ export const createJavaScriptSemanticGraphNode = ( ...parsed, application_node_ids: uniqueSorted(parsed.application_node_ids), evidence: evidenceContexts.intern(parsed.evidence), - identifier_strategy: { - strategy: "semantic-content-sha256" as const, - stability: "artifact-version" as const, - }, }; return javaScriptSemanticNodeSchema.parse({ ...semantic, @@ -147,10 +143,6 @@ export const createJavaScriptSemanticGraphRelation = ( const semantic = { ...parsed, evidence: evidenceContexts.intern(parsed.evidence), - identifier_strategy: { - strategy: "semantic-content-sha256" as const, - stability: "relationship-exact" as const, - }, }; return javaScriptSemanticRelationSchema.parse({ ...semantic, diff --git a/src/domain/javascript/javascriptSemanticGraphSchemas.ts b/src/domain/javascript/javascriptSemanticGraphSchemas.ts index fb03f1a4d..4048ae698 100644 --- a/src/domain/javascript/javascriptSemanticGraphSchemas.ts +++ b/src/domain/javascript/javascriptSemanticGraphSchemas.ts @@ -233,11 +233,9 @@ export const javaScriptSemanticNodeInputSchema = z.strictObject({ export const javaScriptSemanticNodeSchema = javaScriptSemanticNodeInputSchema.extend({ evidence: javaScriptSemanticEvidenceReferenceSchema, - node_id: semanticNodeIdSchema, - identifier_strategy: z.strictObject({ - strategy: z.literal("semantic-content-sha256"), - stability: z.literal("artifact-version"), - }), + node_id: semanticNodeIdSchema.describe( + "SHA-256 of the node kind and identity; stable for one artifact version.", + ), }); /** One directed semantic relationship before its ID is derived. */ @@ -254,11 +252,9 @@ export const javaScriptSemanticRelationInputSchema = z.strictObject({ export const javaScriptSemanticRelationSchema = javaScriptSemanticRelationInputSchema.extend({ evidence: javaScriptSemanticEvidenceReferenceSchema, - relation_id: semanticRelationIdSchema, - identifier_strategy: z.strictObject({ - strategy: z.literal("semantic-content-sha256"), - stability: z.literal("relationship-exact"), - }), + relation_id: semanticRelationIdSchema.describe( + "SHA-256 of the exact relation content, including its evidence reference.", + ), }); /** Reasons semantic analysis can leave an explicit frontier. */ From 1f0775684b2cf8089bddfa7e2f0ee9aa6517c8a8 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sat, 10 Oct 2026 15:21:16 +0800 Subject: [PATCH 07/19] fix(artifacts): keep case-distinct archive names in inventory (#1480) ZIP member names are case-sensitive. Inventory was folding them with a filesystem case rule, so shrunk APKs never became evidence for the Android application graph. Logical registration now keeps both spellings and records an English Unicode case-folding limitation. Extraction fails only when the destination directory already holds the other spelling. Co-authored-by: Cursor Agent --- docs/android-analysis.md | 9 +- src/artifacts/ArtifactPaths.ts | 168 ++++++++++++++++-- src/artifacts/SafeOutputTree.ts | 35 +++- src/artifacts/inventory/scanCanonical.ts | 23 ++- src/artifacts/inventory/scanReader.ts | 16 +- src/domain/analysisErrorPresentation.ts | 23 ++- src/domain/android/androidApplication.ts | 37 +--- src/domain/zipPackageFormat.ts | 3 +- .../artifactProvider.archiveSafety.test.ts | 70 ++++++-- .../artifactProvider.failureDetail.test.ts | 91 +++++++--- tests/composition/android/application.test.ts | 45 +++++ 11 files changed, 425 insertions(+), 95 deletions(-) diff --git a/docs/android-analysis.md b/docs/android-analysis.md index efcb05c64..849aeb2b1 100644 --- a/docs/android-analysis.md +++ b/docs/android-analysis.md @@ -126,8 +126,13 @@ also stops target hashing before provider admission. These operations do not execute the APK or provide split APK/AAB handling, signature validation, full resource-table semantics, native-library analysis or -Android runtime capture. Existing artifact inventory/extraction tools can supply -archive evidence. Project that Evidence with the execution-free inventory tool: +Android runtime capture. An `.aab` suffix is a ZIP archive, not an APK, so +Android tools and the application graph do not treat it as a standalone APK. +Existing artifact inventory/extraction tools can supply archive evidence. +Inventory keeps ZIP names that differ only in case and records that a +case-insensitive destination cannot store both spellings. Extraction fails +only when that destination directory cannot keep both names. Project that +Evidence with the execution-free inventory tool: ```sh rea project-android-application-graph '{"inventory_evidence":[]}' diff --git a/src/artifacts/ArtifactPaths.ts b/src/artifacts/ArtifactPaths.ts index d5ec35cb4..ce8d6c515 100644 --- a/src/artifacts/ArtifactPaths.ts +++ b/src/artifacts/ArtifactPaths.ts @@ -1,9 +1,24 @@ import { posix } from "node:path"; +import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js"; import { ArtifactReaderFailure } from "./ArtifactReader.js"; const DRIVE_OR_UNC = /^(?:[A-Za-z]:|\\|\/\/)/u; +/** + * English Unicode case folding used only to describe logical names a + * case-insensitive destination might collapse. It is not a filesystem case table. + */ +const ENGLISH_UNICODE_CASE_NOTE = + "This comparison is not a filesystem observation."; + +/** Inventory limitation when logical names collide under English Unicode case folding. */ +export const ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION = `Logical archive names collide under English (en-US) Unicode case folding; a case-insensitive destination cannot store both spellings. ${ENGLISH_UNICODE_CASE_NOTE}`; + +/** User-facing prefix for a destination that cannot keep two logical spellings. */ +export const DESTINATION_CASE_COLLISION_PREFIX = + "Destination filesystem cannot store both "; + /** Normalize an untrusted logical archive path without touching filesystem. */ export const normalizeArtifactPath = (input: string): string => { if ( @@ -30,7 +45,7 @@ export const normalizeArtifactPath = (input: string): string => { return normalized; }; -/** Reject exact, Unicode-normalized, case-folded, and prefix collisions. */ +/** Reject exact and same-spelling prefix collisions. Case-distinct names stay distinct. */ export class ArtifactPathRegistry { readonly #root: PathTrieNode = { kind: undefined, children: new Map() }; @@ -43,16 +58,10 @@ export class ArtifactPathRegistry { "path", `Artifact prefix conflict: ${path}`, ); - const foldedPart = part.toLocaleLowerCase("en-US"); - let child = node.children.get(foldedPart); - if (child !== undefined && child.spelling !== part) - throw new ArtifactReaderFailure( - "path", - `Artifact path collision: ${path} differs only in case from ${[...parts.slice(0, index), child.spelling].join("/")}`, - ); + let child = node.children.get(part); if (child === undefined) { - child = { spelling: part, kind: undefined, children: new Map() }; - node.children.set(foldedPart, child); + child = { kind: undefined, children: new Map() }; + node.children.set(part, child); } node = child; if (index === parts.length - 1) { @@ -73,7 +82,144 @@ export class ArtifactPathRegistry { } interface PathTrieNode { - readonly spelling?: string; kind: "file" | "directory" | "symlink" | "slice" | undefined; readonly children: Map; } + +interface CaseNode { + readonly bySpelling: Map; + readonly spellingsByFold: Map; + readonly terminals: string[]; +} + +const emptyCaseNode = (): CaseNode => ({ + bySpelling: new Map(), + spellingsByFold: new Map(), + terminals: [], +}); + +const englishCaseFold = (part: string): string => + part.toLocaleLowerCase("en-US"); + +/** + * Record English (en-US) Unicode case collisions on each affected occurrence. + * Returns the inventory limitation when any logical names collide. + */ +export const annotateEnglishUnicodeCaseCollisions = ( + occurrences: readonly { + readonly logical_path: string; + limitations: string[]; + }[], +): string | undefined => { + const collisions = englishUnicodeCaseCollisions( + occurrences.map(({ logical_path }) => logical_path), + ); + if (collisions.size === 0) return undefined; + for (const occurrence of occurrences) { + const others = collisions.get(occurrence.logical_path); + if (others === undefined || others.length === 0) continue; + occurrence.limitations.push( + `Logical path ${occurrence.logical_path} collides under English (en-US) Unicode case folding with ${others.join(", ")}; a case-insensitive destination cannot store both. ${ENGLISH_UNICODE_CASE_NOTE}`, + ); + } + return ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION; +}; + +/** + * Name the directory-listing spelling that differs from the requested segment + * only by English (en-US) Unicode case. Exact matches are the same logical name. + */ +export const destinationCaseCollisionMessage = ( + requestedPath: string, + existingNames: readonly string[], +): string | undefined => { + const slash = requestedPath.lastIndexOf("/"); + const segment = slash < 0 ? requestedPath : requestedPath.slice(slash + 1); + if (existingNames.includes(segment)) return undefined; + const folded = englishCaseFold(segment); + const existing = existingNames + .filter((name) => englishCaseFold(name) === folded) + .sort(compareUnicodeCodePoints)[0]; + if (existing === undefined) return undefined; + const parent = slash < 0 ? "" : requestedPath.slice(0, slash + 1); + return `${DESTINATION_CASE_COLLISION_PREFIX}${requestedPath} and ${parent}${existing}; inventory retains both logical names.`; +}; + +const englishUnicodeCaseCollisions = ( + paths: readonly string[], +): ReadonlyMap => { + const root = emptyCaseNode(); + for (const path of paths) { + if (path.length === 0 || path === ".") continue; + let node = root; + for (const part of path.split("/")) { + const folded = englishCaseFold(part); + const spellings = node.spellingsByFold.get(folded); + if (spellings === undefined) node.spellingsByFold.set(folded, [part]); + else if (!spellings.includes(part)) spellings.push(part); + let child = node.bySpelling.get(part); + if (child === undefined) { + child = emptyCaseNode(); + node.bySpelling.set(part, child); + } + node = child; + } + node.terminals.push(path); + } + const collisions = new Map>(); + recordCaseCollisions(root, collisions); + return new Map( + [...collisions.entries()].map(([path, others]) => [ + path, + [...others].sort(compareUnicodeCodePoints), + ]), + ); +}; + +const recordCaseCollisions = ( + node: CaseNode, + collisions: Map>, +): void => { + for (const spellings of node.spellingsByFold.values()) + if (spellings.length > 1) noteFoldedSpellings(node, spellings, collisions); + for (const child of node.bySpelling.values()) + recordCaseCollisions(child, collisions); +}; + +const noteFoldedSpellings = ( + node: CaseNode, + spellings: readonly string[], + collisions: Map>, +): void => { + const groups = spellings.map((spelling) => { + const child = node.bySpelling.get(spelling); + return child === undefined ? [] : terminalsUnder(child); + }); + for (const [index, group] of groups.entries()) + noteCaseGroup( + group, + groups.flatMap((candidate, candidateIndex) => + candidateIndex === index ? [] : candidate, + ), + collisions, + ); +}; + +const noteCaseGroup = ( + group: readonly string[], + others: readonly string[], + collisions: Map>, +): void => { + for (const path of group) { + const set = collisions.get(path) ?? new Set(); + for (const other of others) if (other !== path) set.add(other); + collisions.set(path, set); + } +}; + +const terminalsUnder = (node: CaseNode): readonly string[] => { + const paths = [...node.terminals]; + for (const child of node.bySpelling.values()) + paths.push(...terminalsUnder(child)); + return paths; +}; diff --git a/src/artifacts/SafeOutputTree.ts b/src/artifacts/SafeOutputTree.ts index fafb6fee4..05ce0ac68 100644 --- a/src/artifacts/SafeOutputTree.ts +++ b/src/artifacts/SafeOutputTree.ts @@ -4,6 +4,7 @@ import { lstat, mkdir, open, + readdir, realpath, rm, type FileHandle, @@ -14,6 +15,7 @@ import { streamChunkToBuffer } from "./StreamBytes.js"; import { ArtifactPathRegistry, + destinationCaseCollisionMessage, normalizeArtifactPath, } from "./ArtifactPaths.js"; import { ArtifactReaderFailure } from "./ArtifactReader.js"; @@ -134,7 +136,8 @@ export class SafeOutputTree { constants.O_WRONLY | constants.O_NOFOLLOW, 0o600, - ).catch((cause: unknown) => { + ).catch(async (cause: unknown) => { + await throwIfDestinationCaseCollision(dirname(destination), path, cause); throw new ArtifactReaderFailure( "path", `Could not exclusively create extraction path: ${path}`, @@ -245,17 +248,28 @@ export class SafeOutputTree { if (fileName === undefined) throw new ArtifactReaderFailure("path", "Invalid extraction path"); let current = this.#outputRoot; + let logicalParent = ""; for (const part of parts) { + const parentDirectory = current; + const logicalPath = + logicalParent.length === 0 ? part : `${logicalParent}/${part}`; current = join(current, part); + let created = true; await mkdir(current, { mode: 0o700 }).catch((cause: unknown) => { if (!isAlreadyExists(cause)) throw cause; + created = false; }); + if (!created) + await throwIfDestinationCaseCollision(parentDirectory, logicalPath); const metadata = await lstat(current); - if (!metadata.isDirectory() || metadata.isSymbolicLink()) + if (!metadata.isDirectory() || metadata.isSymbolicLink()) { + await throwIfDestinationCaseCollision(parentDirectory, logicalPath); throw new ArtifactReaderFailure( "path", `Unsafe extraction parent: ${relativePath}`, ); + } + logicalParent = logicalPath; } return join(current, fileName); } @@ -330,6 +344,23 @@ const isNotFound = (cause: unknown): boolean => const isAlreadyExists = (cause: unknown): boolean => cause instanceof Error && "code" in cause && cause.code === "EEXIST"; +/** Fail when this directory already holds another spelling of the requested segment. */ +const throwIfDestinationCaseCollision = async ( + parentDirectory: string, + logicalPath: string, + cause?: unknown, +): Promise => { + const names = await readdir(parentDirectory).catch(() => undefined); + if (names === undefined) return; + const message = destinationCaseCollisionMessage(logicalPath, names); + if (message === undefined) return; + throw new ArtifactReaderFailure( + "path", + message, + cause === undefined ? undefined : { cause }, + ); +}; + const abortIfNeeded = (signal?: AbortSignal): void => { if (signal?.aborted === true) throw new ArtifactReaderFailure( diff --git a/src/artifacts/inventory/scanCanonical.ts b/src/artifacts/inventory/scanCanonical.ts index abd524693..0719e58f4 100644 --- a/src/artifacts/inventory/scanCanonical.ts +++ b/src/artifacts/inventory/scanCanonical.ts @@ -73,12 +73,12 @@ export const scanCanonicalArtifactInventory = async ( try { if (reader instanceof AsarArtifactReader) await reader.prepareContainer(rootDigest?.sha256, options.signal); - const { nodes, occurrences, pendingContradictions } = await scanReader( - reader, - ownedReaders, - options.signal, - integrity, - ); + const { + nodes, + occurrences, + pendingContradictions, + caseCollisionLimitation, + } = await scanReader(reader, ownedReaders, options.signal, integrity); outcome = { kind: "completed", snapshot: await buildInventorySnapshot({ @@ -91,6 +91,7 @@ export const scanCanonicalArtifactInventory = async ( nodes, occurrences, pendingContradictions, + caseCollisionLimitation, }), }; } catch (cause: unknown) { @@ -130,6 +131,7 @@ interface SnapshotBuildInput { readonly nodes: Map; readonly occurrences: MutableOccurrence[]; readonly pendingContradictions: PendingIntegrityContradiction[]; + readonly caseCollisionLimitation: string | undefined; } const buildInventorySnapshot = async ( @@ -202,7 +204,12 @@ const buildInventorySnapshot = async ( edges: orderedEdges, provenance: reader?.provenance() ?? [], integrity_contradictions: integrityContradictions, - limitations: buildLimitations(rootFormat, reader, integrityContradictions), + limitations: buildLimitations( + rootFormat, + reader, + integrityContradictions, + input.caseCollisionLimitation, + ), }; }; @@ -310,8 +317,10 @@ const buildLimitations = ( rootFormat: ArtifactOccurrence["artifact_format"], reader: ArtifactReader | undefined, integrityContradictions: readonly IntegrityContradiction[], + caseCollisionLimitation: string | undefined, ): string[] => [ ...inventoryLimitations(rootFormat, reader), + ...(caseCollisionLimitation === undefined ? [] : [caseCollisionLimitation]), ...(integrityContradictions.length === 0 ? [] : [ diff --git a/src/artifacts/inventory/scanReader.ts b/src/artifacts/inventory/scanReader.ts index 1ee691a74..89b1b628e 100644 --- a/src/artifacts/inventory/scanReader.ts +++ b/src/artifacts/inventory/scanReader.ts @@ -1,6 +1,7 @@ import { isAbsolute } from "node:path"; import { + annotateEnglishUnicodeCaseCollisions, ArtifactPathRegistry, normalizeArtifactPath, } from "../ArtifactPaths.js"; @@ -64,10 +65,16 @@ export const scanReader = async ( readonly nodes: Map; readonly occurrences: MutableOccurrence[]; readonly pendingContradictions: PendingIntegrityContradiction[]; + readonly caseCollisionLimitation: string | undefined; }> => { const { nodes, occurrences, pendingContradictions } = emptyScan(); if (reader === undefined) - return { nodes, occurrences, pendingContradictions }; + return { + nodes, + occurrences, + pendingContradictions, + caseCollisionLimitation: undefined, + }; const context: ScanContext = { reader, signal, @@ -90,7 +97,12 @@ export const scanReader = async ( context.occurrenceByPath, context.expandedContainerIds, )?.occurrence_id ?? null; - return { nodes, occurrences, pendingContradictions }; + return { + nodes, + occurrences, + pendingContradictions, + caseCollisionLimitation: annotateEnglishUnicodeCaseCollisions(occurrences), + }; }; const visitArtifactEntries = async ( diff --git a/src/domain/analysisErrorPresentation.ts b/src/domain/analysisErrorPresentation.ts index 7c71a9b5d..b4fe4ad64 100644 --- a/src/domain/analysisErrorPresentation.ts +++ b/src/domain/analysisErrorPresentation.ts @@ -191,7 +191,7 @@ export const analysisErrorUserMessage = (error: AnalysisError): string => { const standardMessage = standardErrorMessage(error._tag); if (standardMessage !== undefined) return standardMessage; if (error instanceof ArtifactOperationError) - return artifactMessage(error.operation, error.reason); + return artifactMessage(error.operation, error.reason, error.detail); if (error instanceof EvidenceReferenceError) return error.reason === "missing" ? `Evidence ${error.evidenceId} is not retained in this session. Supply complete inline Evidence, re-run its producer, or import its bundle before using this reference.` @@ -329,13 +329,13 @@ const START_FAILURE_TAGS: ReadonlySet = new Set([ const artifactMessage = ( operation: ArtifactOperationError["operation"], reason: ArtifactOperationError["reason"], + detail?: string, ): string => { if (reason === "cancelled") return "Artifact operation was cancelled. Start it again when ready."; if (reason === "limit") return "Artifact is too large to process safely. Narrow the requested path or use a smaller artifact."; - if (reason === "path") - return "Artifact contains an unsafe or conflicting internal path. Inspect the reported path and correct the artifact before retrying."; + if (reason === "path") return artifactPathMessage(detail); if (reason === "unavailable") return "Artifact processing is unavailable for the current target or host. Check artifact support and required tools."; if (reason === "integrity" && operation === "analyze_javascript_application") @@ -345,6 +345,23 @@ const artifactMessage = ( return "Artifact could not be read or written. Check file access and try again."; }; +const artifactPathMessage = (detail: string | undefined): string => { + // Kept in step with DESTINATION_CASE_COLLISION_PREFIX. Domain does not import + // the artifact adapter that produces the detail. + if ( + detail !== undefined && + detail.startsWith("Destination filesystem cannot store both ") + ) + return detail; + if ( + detail !== undefined && + (detail.startsWith("Artifact path is absolute or unsafe:") || + detail.startsWith("Artifact path is not normalized:")) + ) + return "Artifact contains an unsafe internal path. Inspect the reported path and correct the artifact before retrying."; + return "Artifact contains a conflicting internal path. Inspect the reported path before retrying."; +}; + const evidenceFileMessage = ({ operation, reason, diff --git a/src/domain/android/androidApplication.ts b/src/domain/android/androidApplication.ts index 745b8e0c4..674425749 100644 --- a/src/domain/android/androidApplication.ts +++ b/src/domain/android/androidApplication.ts @@ -125,6 +125,8 @@ export const projectAndroidApplication = ( "Manifest, resource, signing, and bytecode semantics require a dedicated Android provider; this projection reports exact inventory paths and hashes only.", "Runtime families are inferred from inventory formats and paths; filename suffixes do not establish valid DEX or JVM class bytes.", "Bridge candidates are path-based hypotheses, not decoded JNI declarations or observed runtime calls.", + "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.", ...(bridgeProjection.coverage.status === "partial" ? [ `Bridge candidate pairs exceeded the projection safety budget; ${bridgeProjection.coverage.omitted_candidates} hypotheses are omitted. Component arrays still include every component from the supplied inventory pages.`, @@ -157,23 +159,12 @@ export const projectAndroidApplication = ( }; const classify = (all: readonly Component[]) => ({ - manifests: all.filter( - ({ path, format }) => - format === "android-manifest" || - /(?:^|\/)AndroidManifest\.xml$/u.test(path), - ), - resources: all.filter( - ({ path, format }) => - format === "android-resources" || /(?:^|\/)resources\.arsc$/u.test(path), - ), - dex: all.filter( - ({ path, format }) => - format === "dex" || /(?:^|\/)[^/]+\.dex$/iu.test(path), - ), - jvm_classes: all.filter( - ({ path, format }) => - format === "jvm-class" || /(?:^|\/)[^/]+\.class$/iu.test(path), + manifests: all.filter(({ path }) => + /(?:^|\/)AndroidManifest\.xml$/u.test(path), ), + resources: all.filter(({ path }) => /(?:^|\/)resources\.arsc$/u.test(path)), + dex: all.filter(({ path }) => /(?:^|\/)[^/]+\.dex$/iu.test(path)), + jvm_classes: all.filter(({ path }) => /(?:^|\/)[^/]+\.class$/iu.test(path)), native_libraries: all.filter( ({ path, format }) => format === "elf" || /(?:^|\/)lib\/[^/]+\/[^/]+\.so$/iu.test(path), @@ -189,19 +180,9 @@ const runtimeFamilies = (all: readonly Component[]) => { const families = new Set< AndroidApplicationProjectionResult["runtime_families"][number] >(); - if ( - all.some( - ({ path, format }) => - format === "dex" || path.toLowerCase().endsWith(".dex"), - ) - ) + if (all.some(({ path }) => path.toLowerCase().endsWith(".dex"))) families.add("dalvik-art"); - if ( - all.some( - ({ path, format }) => - format === "jvm-class" || path.toLowerCase().endsWith(".class"), - ) - ) + if (all.some(({ path }) => path.toLowerCase().endsWith(".class"))) families.add("java-kotlin"); if (all.some(({ format }) => format === "elf")) families.add("native"); if (all.some(({ format }) => format === "javascript-bundle")) diff --git a/src/domain/zipPackageFormat.ts b/src/domain/zipPackageFormat.ts index c45109135..39a8f86a5 100644 --- a/src/domain/zipPackageFormat.ts +++ b/src/domain/zipPackageFormat.ts @@ -22,7 +22,8 @@ export const zipPackageFormatForPath = ( const lower = path.toLowerCase(); if (lower.endsWith(".zip")) return "zip"; if (lower.endsWith(".ipa")) return "ipa"; - if (lower.endsWith(".apk") || lower.endsWith(".aab")) return "apk"; + // An Android App Bundle is a ZIP archive, not a standalone APK. + if (lower.endsWith(".apk")) return "apk"; if (lower.endsWith(".msix") || lower.endsWith(".msixbundle")) return "msix"; if (lower.endsWith(".appx") || lower.endsWith(".appxbundle")) return "appx"; return undefined; diff --git a/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts b/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts index 368d029dc..92f88aa9d 100644 --- a/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts +++ b/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts @@ -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"; @@ -95,17 +97,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 +106,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,7 +123,50 @@ 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 logical names that differ only in case", async () => { + const root = await createTestTempDirectory("rea-case-distinct-zip-"); + 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); + expect(parsed.ok).toBe(true); + if (!parsed.ok) return; + 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 }), + ); + expect(extracted.ok).toBe(true); + 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) => { diff --git a/tests/boundary/providers/native/artifactProvider.failureDetail.test.ts b/tests/boundary/providers/native/artifactProvider.failureDetail.test.ts index dcec03c93..e2b2fd385 100644 --- a/tests/boundary/providers/native/artifactProvider.failureDetail.test.ts +++ b/tests/boundary/providers/native/artifactProvider.failureDetail.test.ts @@ -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 }, + }); +}); diff --git a/tests/composition/android/application.test.ts b/tests/composition/android/application.test.ts index 082a706b0..3529dc4e8 100644 --- a/tests/composition/android/application.test.ts +++ b/tests/composition/android/application.test.ts @@ -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-"); From b09d02d93cbadfa0ced21e7c489c7d47fb317228 Mon Sep 17 00:00:00 2001 From: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Date: Sat, 10 Oct 2026 13:55:18 +0800 Subject: [PATCH 08/19] feat(website): add a blog for methods and project notes --- website/public/blog/index.html | 154 ++++++++++++++++++ website/public/examples/dino-lab/index.html | 3 +- website/public/faq/index.html | 1 + website/public/first-investigation/index.html | 3 +- website/public/get-started/index.html | 3 +- website/public/guides/browser/index.html | 3 +- website/public/guides/index.html | 3 +- website/public/guides/javascript/index.html | 3 +- website/public/guides/native/index.html | 3 +- website/public/index.html | 1 + website/public/showcase/aegis/index.html | 1 + website/public/showcase/ctf/index.html | 1 + website/public/showcase/dx-ball/index.html | 1 + website/public/showcase/index.html | 1 + website/public/showcase/notion/index.html | 1 + website/public/showcase/th04/index.html | 1 + 16 files changed, 176 insertions(+), 7 deletions(-) create mode 100644 website/public/blog/index.html diff --git a/website/public/blog/index.html b/website/public/blog/index.html new file mode 100644 index 000000000..eec6da2a6 --- /dev/null +++ b/website/public/blog/index.html @@ -0,0 +1,154 @@ + + + + + + Reverse Engineering Methods and Project Notes — REA + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +

    Methods and project notes.

    +

    + How we approach reverse engineering, game reconstruction, ports and + mods. +

    +
    +
    +
    +

    Game reconstruction
    Article outline

    +
    +

    Reconstructing Touhou with AI agents

    +

    + A repeatable workflow, illustrated by TH08, TH095 and TH04: build + on existing work, carry lessons into a new game, and adapt the + method to an older platform. +

    +

    By N0zoM1z0 · Outline in progress

    +
    +
    +
    +
    + +

    + + Top + + + diff --git a/website/public/examples/dino-lab/index.html b/website/public/examples/dino-lab/index.html index d0bc84c76..02452bda9 100644 --- a/website/public/examples/dino-lab/index.html +++ b/website/public/examples/dino-lab/index.html @@ -63,7 +63,8 @@ >Reverse Engineer Anything diff --git a/website/public/faq/index.html b/website/public/faq/index.html index fa4a64a83..3ab51b9d3 100644 --- a/website/public/faq/index.html +++ b/website/public/faq/index.html @@ -63,6 +63,7 @@ >