Skip to content

Commit ec56c1d

Browse files
committed
fix(setup): preserve registration identity and recovery ownership
Keep layered environment choices, current byte-exact recovery snapshots, and package-manager failure details. Report pinned package drift without claiming runner resolution. Retain failed Linux installer cleanup for host-owned retry while preserving the install outcome. Reviewed fixes include #2632, #2769, #2783, #2959, #2979, #2983, #2995, #3009, and #2559. Validation: 98 focused setup/registration tests passed; 45 Linux installer tests passed. Real Linux package installation remains unverified.
1 parent 599a8ee commit ec56c1d

42 files changed

Lines changed: 2418 additions & 213 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/client-configuration.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ and Claude Code reports that autocompact is thrashing. To avoid this:
129129
The sizes above come from REA's own `tools/list`. A live Claude Code session
130130
against DeepSeek's API is unverified.
131131

132+
For a client whose stdio reader rejects the complete catalog frame, add
133+
`"REA_MCP_OUTPUT_SCHEMA_PROFILE": "off"` to REA's `env` object and restart the
134+
client. This omits only advertised output schemas; REA still validates complete
135+
structured results against its canonical contracts. See [MCP output schema
136+
profiles](mcp-contracts.md#output-schemas).
137+
132138
## Kimi Code
133139

134140
Setup registers `rea` in `~/.kimi-code/mcp.json`, or
@@ -279,7 +285,11 @@ the first native server into an empty table, it copies the fallback's
279285
`mcpServers` entries into the native table so they keep loading, and leaves
280286
the fallback file untouched. Existing REA environment overrides are preserved
281287
when refreshing its command. A malformed or unreadable fallback file fails setup instead of
282-
being silently suppressed; repair or remove it and rerun. ZCode disables a
288+
being silently suppressed; repair or remove it and rerun. Uninstall removes an
289+
REA-owned `rea` entry from both the native table and the fallback, backing up
290+
each changed file, so an emptied native table cannot load a leftover fallback
291+
registration; other fallback servers, settings and a foreign `rea` entry are
292+
kept. ZCode disables a
283293
server with `enable: false` on its entry; doctor reports such a registration
284294
as stale, and rerunning setup removes the flag to repair it. Native configuration
285295
uses strict JSON; setup refuses comments, trailing commas and a BOM rather than

‎docs/installation.md‎

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,21 @@ preserves a verified `.rea.backup.<sha256>.recovery` copy of the current bytes.
6464
Both snapshots remain available; a failed rollback reports the current recovery
6565
copy's path and the restore failure.
6666
Setup also retains valid environment overrides in REA's existing server entry,
67-
such as `REA_MCP_INPUT_SCHEMA_PROFILE` and `REA_MCP_MAX_RESPONSE_BYTES`.
67+
such as `REA_MCP_INPUT_SCHEMA_PROFILE`, `REA_MCP_OUTPUT_SCHEMA_PROFILE`, and
68+
`REA_MCP_MAX_RESPONSE_BYTES`.
6869
Detected provider settings replace only matching environment keys.
6970
Setup and doctor report a malformed REA environment map or invalid runtime
7071
setting before setup writes files. Repair the named setting in the client
7172
configuration; setup does not silently discard the rest of the map.
73+
This includes malformed loader/exclusion JSON arrays and a Ghidra compiler
74+
specification without its required language identifier. Valid overrides keep
75+
their original strings, including empty Hopper arguments. DeepSeek Harness
76+
`!!js` environment expressions remain unevaluated and preserved; registration
77+
alignment does not verify the runtime values those expressions will produce.
78+
For layered OpenCode files, each file's values are checked before merging, while
79+
setting dependencies are checked against the effective merged environment.
80+
Setup preserves each layer's overrides instead of copying inherited settings
81+
into the file it updates.
7282

7383
After setup, REA reports which agents, analysis tools, and workflow files passed
7484
its final checks. Restart any agent named in the completion message, then begin
@@ -334,6 +344,20 @@ document for the same target. REA does not currently identify, focus, or reuse
334344
that existing GUI document, and the supported launcher exposes no attach or
335345
reuse action for it.
336346

347+
REA currently declines saved Hopper database (`.hop`) targets on macOS because
348+
the native `open database` launch route does not run REA's bridge script. To
349+
analyze that program with REA, select its original executable as the target and
350+
open it through Hopper; this starts the supported bridge route. This does not
351+
recover database-only annotations or analysis changes. Saved-database analysis
352+
on Linux continues to use its supported demo-launch route.
353+
354+
Hopper lease directories must be readable and owned by the current user.
355+
REA validates and secures an opened directory before reserving a lease. If
356+
directory access fails, the error identifies the path and recovery steps;
357+
REA leaves its permissions unchanged. Check ownership and parent-directory
358+
access, then restore owner-only read, write, and search permissions (`0700`)
359+
on a directory you own before retrying.
360+
337361
On supported Linux distributions, approved setup verifies Hopper's official
338362
`.deb`, `.rpm`, or Arch package before invoking the native package manager.
339363
REA runs the supported demo build on a private Xvfb display and selects Hopper's
@@ -346,6 +370,13 @@ host mount and the rest of `/tmp` remain unchanged; this fallback never invokes
346370
`sudo`. `rea doctor --provider hopper --json` reports the selected
347371
strategy and both host and effective mount facts.
348372

373+
When the package-manager step fails, setup reports the failing command and its
374+
captured output, so a package conflict is distinguishable from an authorization
375+
failure. On CachyOS, an unversioned compatibility package such as
376+
`zlib-ng-compat` may conflict with Hopper's versioned `zlib` dependency. Resolve
377+
the package conflict yourself or install Hopper's official package manually,
378+
then rerun `rea setup`.
379+
349380
The supported Linux demo forwards additional launches into its existing
350381
application, even across private displays. REA therefore reserves one Linux
351382
Hopper application per user across cooperating REA processes. A competing
@@ -370,8 +401,9 @@ sessions before removing that recovery directory and retrying.
370401
On macOS, REA uses
371402
`/Applications/Hopper Disassembler.app/Contents/MacOS/hopper` by default.
372403
On Linux, it prefers executable `/opt/hopper/bin/Hopper`, then executable
373-
`~/.local/share/rea/hopper/bin/Hopper`; if neither exists, the former remains
374-
the diagnostic fallback. `HOPPER_LAUNCHER_PATH` overrides those choices:
404+
`~/.local/share/rea/hopper/bin/Hopper`, followed by `/opt/hopper-v4/bin/hopper`
405+
and `/usr/bin/hopper`; if none exists, the former remains the diagnostic
406+
fallback. `HOPPER_LAUNCHER_PATH` overrides those choices:
375407

376408
```bash
377409
export HOPPER_LAUNCHER_PATH=/absolute/path/to/Hopper
@@ -511,7 +543,7 @@ reported as incompatible instead of being admitted from its directory name, and
511543
a header that cannot be read or recognized is reported as unknown. REA does not
512544
build or install native tools, or change Gatekeeper quarantine settings.
513545

514-
The adapter exposes 25 read-only operations: thirteen inventory/name/search
546+
The adapter exposes 26 read-only operations: fourteen inventory/name/search
515547
operations and twelve function-analysis operations. These cover metadata,
516548
decompilation, assembly, resolved calls, typed references, xrefs, function
517549
dossiers, instructions, recovered data types, measured load mappings, loaded
@@ -799,7 +831,7 @@ On a controlled Windows x64 runner, use
799831
`npm run verify:ghidra:windows`. The verifier generates a deterministic native
800832
PE fixture from source bytes and requires the Windows native authority before
801833
opening the provider. The controls are implemented on main; see the
802-
[release boundary](#released-package-and-main). The lane verifies all 25 admitted
834+
[release boundary](#released-package-and-main). The lane verifies all 26 admitted
803835
read-only operations, digest identity, and runtime cleanup. The separate
804836
`verify:ghidra:windows:package` lane checks the packed CLI/MCP boundary with an
805837
ordinary user. It requires the built Windows native bundle and an existing

‎install.sh‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ prerelease_identifier="(${numeric_identifier}|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]
1616
build_identifier='[0-9A-Za-z-]+'
1717
version_pattern="${numeric_identifier}\\.${numeric_identifier}\\.${numeric_identifier}(-${prerelease_identifier}(\\.${prerelease_identifier})*)?(\\+${build_identifier}(\\.${build_identifier})*)?"
1818
version="${REA_VERSION:-}"
19+
version_requested=false
1920
dry_run=false
2021
start_setup=true
2122
verbose=false
@@ -81,6 +82,7 @@ main() {
8182
--version)
8283
(($# >= 2)) || fail "--version requires a value."
8384
version="$2"
85+
version_requested=true
8486
shift 2
8587
;;
8688
--dry-run)
@@ -121,7 +123,7 @@ main() {
121123
fail_node_version "$node_version"
122124
fi
123125

124-
if [ -n "$version" ]; then
126+
if [ "$version_requested" = true ] || [ -n "$version" ]; then
125127
matches "$version" "^${version_pattern}$" || fail "version must be an exact semantic version."
126128
else
127129
release_json="$(curl -fsSL --proto '=https' --tlsv1.2 --retry 3 -H 'Accept: application/vnd.github+json' "https://api.github.com/repos/$REPOSITORY/releases/latest")" || fail "the latest REA release could not be resolved. Check network access or pass --version VERSION, then retry."
@@ -164,6 +166,7 @@ main() {
164166
npm "${install_args[@]}" || fail "npm could not install REA. Check registry access and npm permissions, then retry."
165167
[ -x "$install_bin" ] || fail "npm completed without installing the rea command. Check the npm global bin directory and PATH, then retry."
166168
installed_version="$("$install_bin" --version 2>/dev/null | tr -d '[:space:]')" || fail "the installed REA version could not be read. Reinstall the requested version, then retry."
169+
[ -n "$installed_version" ] || fail "the installed REA version could not be read. Reinstall the requested version, then retry."
167170
[ "$installed_version" = "$version" ] || fail "installed version $installed_version does not match $version. Reinstall the requested version, then retry."
168171

169172
printf 'REA %s is installed.\n' "$version"

‎src/android/JadxDoctor.ts‎

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import type {
2+
DoctorProviderCheck,
3+
DoctorProviderInspection,
4+
} from "../application/Doctor.js";
5+
import type { ProviderAvailability } from "../application/AnalysisProvider.js";
6+
import type { JsonValue } from "../domain/jsonValue.js";
7+
import {
8+
inspectJadxAvailability,
9+
JADX_FAILURE_KINDS,
10+
projectJadxFailureOutcome,
11+
type JadxFailureKind,
12+
} from "./JadxConfiguration.js";
13+
14+
/** Project the validated JADX configuration into the doctor contract. */
15+
export const inspectJadxProvider = async (
16+
environment: Readonly<Record<string, string | undefined>>,
17+
): Promise<DoctorProviderInspection> => {
18+
const configured = environment.REA_JADX_MCP_JAR !== undefined;
19+
const availability = await inspectJadxAvailability(environment);
20+
// diagnostics is a loosely-typed JsonValue map; guard the published path
21+
// even though the success path always sets jar_path today.
22+
const jarPath =
23+
availability.status === "available" &&
24+
typeof availability.diagnostics["jar_path"] === "string"
25+
? availability.diagnostics["jar_path"]
26+
: undefined;
27+
const available =
28+
availability.status === "available" && jarPath !== undefined;
29+
// Preserve the caller-selected JAR path (it may be a stable symlink) and
30+
// the validated JAVA_HOME selection; the resolved jarPath stays in
31+
// diagnostics as inspection evidence.
32+
const configuredJar = environment.REA_JADX_MCP_JAR;
33+
return {
34+
id: "jadx",
35+
configured,
36+
available,
37+
providerVersion: null,
38+
registrationEnvironment:
39+
jarPath === undefined || configuredJar === undefined
40+
? {}
41+
: {
42+
REA_JADX_MCP_JAR: configuredJar,
43+
...optionalEntry("JAVA_HOME", environment.JAVA_HOME),
44+
...optionalEntry(
45+
"REA_JADX_HEAP_MIB",
46+
environment.REA_JADX_HEAP_MIB,
47+
),
48+
...optionalEntry(
49+
"REA_JADX_ACTIVE_PROCESSOR_COUNT",
50+
environment.REA_JADX_ACTIVE_PROCESSOR_COUNT,
51+
),
52+
},
53+
checks: [configurationCheck(configured, availability, jarPath)],
54+
};
55+
};
56+
57+
/**
58+
* Publish a caller-selected variable only when explicitly set; never persist
59+
* ambient inheritance. Values are validated before this point.
60+
*/
61+
const optionalEntry = (
62+
name: string,
63+
value: string | undefined,
64+
): Record<string, string> => (value === undefined ? {} : { [name]: value });
65+
66+
const configurationCheck = (
67+
configured: boolean,
68+
availability: ProviderAvailability,
69+
jarPath: string | undefined,
70+
): DoctorProviderCheck => {
71+
const code = availability.status === "unavailable" ? availability.code : null;
72+
if (availability.status === "available" && jarPath !== undefined) {
73+
return {
74+
name: "configuration",
75+
ok: true,
76+
code: null,
77+
detail: `JADX MCP bridge JAR validated at ${jarPath}; its path is recorded for agent registrations.`,
78+
remediation: null,
79+
classification: "config_drift",
80+
};
81+
}
82+
// The failure kind is tagged at the configuration boundary; project its
83+
// remediation and classification here instead of reinterpreting the
84+
// phase/setting evidence. Every failed check keeps a remediation.
85+
const kind =
86+
availability.status === "unavailable"
87+
? asFailureKind(availability.diagnostics["failure_kind"])
88+
: null;
89+
const outcome = projectJadxFailureOutcome(kind, configured);
90+
return {
91+
name: "configuration",
92+
ok: false,
93+
code,
94+
detail:
95+
availability.status === "available"
96+
? "Validated JADX configuration reported no JAR path."
97+
: availability.reason,
98+
remediation: outcome.remediation,
99+
classification: outcome.classification,
100+
...(kind === "java_probe" && availability.status === "unavailable"
101+
? { details: probeDetails(availability.diagnostics) }
102+
: kind !== null &&
103+
kind.startsWith("windows_native_") &&
104+
availability.status === "unavailable"
105+
? { details: windowsNativeFailureDetails(availability.diagnostics) }
106+
: {}),
107+
};
108+
};
109+
110+
const windowsNativeFailureDetails = (
111+
diagnostics: Readonly<Record<string, JsonValue>>,
112+
): Record<string, JsonValue> => {
113+
const details: Record<string, JsonValue> = {};
114+
for (const key of ["failure_stage", "remediation"] as const) {
115+
const value = diagnostics[key];
116+
if (value !== undefined) details[key] = value;
117+
}
118+
return details;
119+
};
120+
121+
/** Validate the loose diagnostics tag against the boundary's failure kinds. */
122+
const asFailureKind = (value: JsonValue | undefined): JadxFailureKind | null =>
123+
typeof value === "string" &&
124+
(JADX_FAILURE_KINDS as readonly string[]).includes(value)
125+
? (value as JadxFailureKind)
126+
: null;
127+
128+
/**
129+
* Project bounded Java probe metadata for the doctor report. The full
130+
* stdout/stderr can reach the 1 MiB probe budget, so only the bounded
131+
* outcome metadata is carried; the message already references the retained
132+
* output.
133+
*/
134+
const probeDetails = (
135+
diagnostics: Readonly<Record<string, JsonValue>>,
136+
): Record<string, JsonValue> => {
137+
const details: Record<string, JsonValue> = {};
138+
for (const key of [
139+
"java_executable",
140+
"failure",
141+
"output_truncated",
142+
"exit_code",
143+
"process_error_code",
144+
"signal",
145+
"killed",
146+
"output_limit_bytes",
147+
"deadline_ms",
148+
"jdk_compiler",
149+
"java_major",
150+
] as const) {
151+
const value = diagnostics[key];
152+
if (value !== undefined) details[key] = value;
153+
}
154+
return details;
155+
};

‎src/application/ClientConfigurationDocument.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const parseZcodeFallbackConfiguration = (
167167
? {}
168168
: requireObject(document.mcpServers, "ZCode fallback mcpServers"),
169169
serversPath: ["mcpServers"],
170-
dialect: "json",
170+
dialect: "zcode_fallback",
171171
legacyServers: {},
172172
};
173173
};
@@ -183,6 +183,7 @@ export const parseClientConfiguration = (
183183
if (format === undefined || format === "unsupported")
184184
throw new TypeError("client does not have a supported MCP config format");
185185
// DeepSeek Harness stores a Cordis patch list, not a server table.
186+
if (format === "zcode_fallback") return parseZcodeFallbackConfiguration(text);
186187
if (format === "dsh") return parseDshCordisDocument(text);
187188
const document = parseDocument(text, format);
188189
const serversKey = clientConfigurationServersKey(format);

0 commit comments

Comments
 (0)