Compare commits

...
Author SHA1 Message Date
N0zoM1z0 e65a13f54d fix(experiments): bound execution and record cross-domain findings
Reject timer overflow at the named execution contract and validate published SDK schemas through real stdio clients. Preserve explicit unknowns and value types in fact grading.

Record sixteen serial Terra-high trials, guided inventory questions and a migration decision that retains existing REA APIs. Twelve fact/reference checks pass; remaining managed trials expose classification omissions or transcript truncation. Twelve actual stdio tests pass, including guest allocation recovery, cancellation and retained partial Evidence.
2026-10-11 19:29:48 +00:00
N0zoM1z0 c11a75cbe9 test(experiments): compare source facts across equivalent report forms 2026-10-11 18:33:39 +00:00
N0zoM1z0 22326e8199 feat(experiments): add typed discovery and reproducible cross-domain questions 2026-10-11 18:18:22 +00:00
N0zoM1z0 3f6dcbc096 perf(experiments): stage discovery and verify managed agent facts 2026-10-11 18:02:47 +00:00
N0zoM1z0 89a7ca8486 fix(experiments): preserve partial evidence and queued cancellation ownership 2026-10-11 17:26:35 +00:00
N0zoM1z0 15cc7ce6a6 test(experiments): expand real-provider corpus and grade Codex projections 2026-10-11 17:10:53 +00:00
N0zoM1z0 d0b60a97ab perf(experiments): trim discovery and record real Codex health trials 2026-10-11 16:40:08 +00:00
N0zoM1z0 e3d4ac12b3 feat(experiments): add optional codemode MCP bridge and Codex trials 2026-10-11 16:20:16 +00:00
N0zoM1z0 b5e4920823 docs(experiments): pin codemode baseline and real-artifact corpus 2026-10-11 15:50:19 +00:00
19 changed files with 3954 additions and 0 deletions
+174
View File
@@ -0,0 +1,174 @@
# REA Code Mode experiment
Frozen baseline: `fb94d9dde0ccda83ae520ac6fb22b1d283562cf3`, fetched from
`origin/main` on 2026-10-11. Branch: `experiment/codemode-bridge-20261011`.
This is a local experiment, not a change to the published CLI or MCP API.
The analyst question is whether composing REA's existing named tools in code
improves investigation efficiency enough to justify an optional bridge. Existing
users must keep their current names, input schemas, Evidence and session behavior.
Provider analysis settings must stay identical between comparison profiles.
The bridge owns one upstream stdio MCP connection and discovers its complete live
catalog. Only discovery and JavaScript execution are exposed downstream. Code
calls `tools.<original_name>(original_arguments)` and receives the original MCP
result envelope. REA still validates input, chooses providers, retains Evidence,
and owns analysis resources. There is no second tool implementation or schema
catalog to keep synchronized. A fresh QuickJS WASM context exposes only those
tool calls, JSON helpers and explicit output; it has no host filesystem, network,
process or module loader.
Start the bridge without changing an existing registration:
```bash
node bridge.mjs /absolute/path/to/node /absolute/path/to/rea/scripts/rea.mjs mcp
```
Register that command as a separate, temporary MCP server for a trial. Existing
REA registrations keep their original tools. `rea_search` accepts a query or exact
names; use `schemas: false` for the complete lightweight name/description list.
Query discovery returns names/descriptions by default; exact-name discovery
returns original input schemas and derived input/output TypeScript declarations.
These declarations help write code; they do not replace JSON validation contracts.
`schemas` explicitly overrides that choice.
Start with one domain word and request all selected exact names in one call.
Request `output_schemas: true` when a
result contract is needed; the original output schema is then returned unchanged.
`catalog_sha256` identifies the SDK catalog; it must not be substituted for REA's
`server_identity.catalog.digests` fields.
`rea_execute` accepts a JavaScript async function body. For example:
```js
const session = json(await tools.binary_session({})).result;
return { open: session.open, identity: session.server_identity };
```
The returned projection is not a new Evidence record. `calls` preserves operation,
argument/result digests, upstream errors and actual producer Evidence IDs when
provided, including original `evidence_links`. The upstream ledger retains complete original Evidence for later views
and exports. Non-Evidence session responses have no invented Evidence ID.
Calls and executions sharing one active target are serialized; `Promise.all`
currently provides composition rather than parallel provider execution.
`npm test` runs actual upstream and downstream stdio MCP against this checkout's
compiled runtime. The standalone experiment's twelve tests cover discovery parity,
original results/errors, bulk promise settlement, host capability absence, CPU
deadline recovery, retained Evidence after an error or provider timeout,
queued-call cancellation, unresolved promises and the
two-tool downstream boundary, guest heap exhaustion/reuse, and SDK-converted
schemas validated as [JSON Schema 2020-12](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#schema-dialect).
Execution rejects delays above Node's signed 32-bit timer range instead of
allowing Node to coerce them to 1 ms. These tests do not establish real native/Android/
firmware provider behavior. A lifecycle regression revealed that the QuickJS job
pump can allocate an additional context: the execution scope now owns every
context at creation and releases them before the runtime. Increasing memory did
not fix that regression.
Install experimental dependencies separately with `npm ci` in this directory.
They do not change the production package or lockfile. Use the repository's pinned
Node and npm versions. No binary, provider database or raw third-party source is
committed. Corpus identities and upstream download locations are in `corpus.json`.
Measure three baselines: normal full-catalog MCP, discovery-only MCP, and Code
Mode. Count discovery, input code, intermediate results, final output, errors and
retries. Report actual wall time separately from model-facing turns and local
token estimates. Existing summary/page/workflow tools are fair alternatives;
do not manufacture a gain by forcing full output on the direct-tool baseline.
Replay measurements establish mechanism costs, not model task accuracy or
inference latency. Real-agent trials must additionally verify supported facts,
source identity, omissions and preserved Evidence references.
`benchmark.mjs` replays a fixed question against real providers with identical
original arguments. For example:
```bash
python3 resource-run.py -- node benchmark.mjs --artifact newpipe.apk \
--mode bridge --artifact-root /absolute/path/artifacts \
--providers /absolute/path/selected-provider-settings.json \
--output /absolute/path/new-result-directory
```
Modes are `direct`, `discovery` and `bridge`. The discovery mode isolates catalog
cost while retaining original results; it is not a new production MCP client.
Raw responses remain outside Git. Result summaries separate complete envelopes
from single text content and count code explicitly. Measured findings and failures
are recorded in [results.md](results.md).
`--artifact obsidian.asar --workflow obsidian-inventory` asks a distinct package
inventory question using existing tools. It must not be compared as an equivalent
completion of the JavaScript AST question. Workflow names and original arguments
are retained in replay summaries.
`agent-trial.py` runs a real local Codex CLI with a disposable account/config and
one MCP registration. It copies authentication only, removes the profile on normal
completion, timeout and handled termination, and retains JSONL events, the answer
and measured API usage outside the repo.
It defaults to `gpt-5.6-terra` with high reasoning, as requested. Run one task under
the resource wrapper:
```bash
python3 resource-run.py -- python3 agent-trial.py \
--mode direct --prompt /absolute/path/question.txt \
--output /absolute/path/new-trial-directory
```
Reproducible questions are in [questions/](questions/). Supply a template with
`--prompt questions/android.txt --artifact-path /absolute/path/NewPipe_v0.29.1.apk`
(or another matching corpus target). The runner preserves the supplied path in
the rendered prompt and records template and rendered-prompt digests. Native's
entry-address seed is derived from this corpus's jq header and is not reusable
for another build. Run comparisons serially with the same question and provider
settings; retain failures as well as successful repetitions.
Use `--mode bridge` for the experimental server; `--mode client-code` requests
Codex's own Code Mode. Optional `--providers` selects a JSON object of explicit
provider settings. No ambient environment snapshot is retained. A configured flag
or a model's `tool_mode` does not prove the model actually composed tools or
filtered an intermediate result. Inspect the transcript, and mark accuracy as
unassessed until the requested facts and source support have been reviewed.
`grade-trial.py` checks Android (default), managed, native, firmware or
electron-inventory (`--task NAME`) against a successful
real-provider replay and verifies cited IDs in producer values, their original
Evidence links or the bridge audit. This verifies references observed in the
transcript; the grader does not resolve every cited payload. It accepts
JSON or one complete JSON fence, without repairing prose or partial values. This
checks requested producer facts and reference existence, not runtime behavior or
independent decompiler correctness. Unparseable result text is reported explicitly;
IDs in a truncated JSON fragment cannot satisfy the automated reference check.
The Android projection includes the provider's overload index, so a supported
signature with that field omitted fails this stronger assertion.
An omitted DEX descriptor differs from an explicit null, and booleans differ from
numeric counts. Native containing-procedure reports compare resolved identity;
the full analyzed procedure is verified separately.
Firmware's run-local region UUIDs remain in answers but are excluded from parity
against an independently acquired report. Classification evidence, explicit
unknowns and coverage remain part of the requested fact checks.
The question comparison accepts grouped original path records, extra known
coverage counts and explicitly named firmware length/coverage report fields.
Derived extent ends must agree with offset plus reported length. It verifies
engine version and executable digest rather than display capitalization; a manual
review is still needed for limitations and claims beyond these assertions.
Grades record the grader source digest, and earlier strict grades are retained
when the comparison changes. These are report parsers, not REA API aliases.
The completed serial cohort is in [agent-results.json](agent-results.json), with
source/configuration fingerprints, measured API usage and sampled cgroup stats.
The recommendation and migration boundaries are in [decision.md](decision.md).
Raw transcripts and original replay replies remain outside Git.
The supplied feedback is a research lead. Its Ghidra timing claim also changed
auto-analysis options, so it does not isolate Code Mode's effect. Relevant primary
sources: [Cloudflare Code Mode](https://blog.cloudflare.com/code-mode/),
[MCP patterns](https://developers.cloudflare.com/agents/model-context-protocol/codemode/),
[Anthropic code execution](https://www.anthropic.com/engineering/code-execution-with-mcp),
and [QuickJS WASM](https://github.com/justjake/quickjs-emscripten).
Run expensive commands with `python3 resource-run.py -- COMMAND ARGS...` on Linux
with a user systemd manager. It uses a transient scope with one CPU, a 4 GiB hard
memory ceiling, a 3 GiB early-stop threshold, no swap, and a task ceiling. It
refuses to start when less than 8 GiB is available and stops if host available
memory drops below 4 GiB. These limits protect the host; a resource abort is a
failed measurement, never a successful benchmark. Also cap Node and Java heaps.
The task ceiling is 192. The wrapper records observed memory/task events and
stops a trial that touches the task limit. A limit event invalidates a measurement
even when the application later returns successfully.
+995
View File
@@ -0,0 +1,995 @@
{
"baseline_sha": "fb94d9dde0ccda83ae520ac6fb22b1d283562cf3",
"scope": "real_cli_requested_fact_parity_and_observed_references_not_independent_runtime_truth",
"runtime_source_commit": "22326e8199975f31d8b7c99aaf5fd64140fbe00e",
"artifact_ids": "corpus.json",
"resource_limits": {
"cpu_affinity": [15],
"cpu_quota_percent": 100,
"hard_memory_bytes": 4294967296,
"early_stop_bytes": 3221225472,
"tasks_max": 192
},
"notes": [
"Profiles differ in required mode-specific instructions; original model-selected arguments may differ.",
"Two Android/managed repetitions are descriptive samples, without confidence intervals or a causal speed claim.",
"Managed classification container omissions fail a stronger complete-object assertion; remaining requested facts match.",
"Normal-MCP managed JSONL truncation leaves one ID unavailable to the complete-envelope reference parser.",
"Uncached input is input minus cached input, not a currency cost estimate."
],
"trials": [
{
"trial": "android-direct-5",
"task": "android",
"mode": "direct",
"artifact": "newpipe.apk",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 67.329,
"input_tokens": 107007,
"cached_input_tokens": 83712,
"uncached_input_tokens": 23295,
"output_tokens": 1670,
"completed_mcp_calls": 3,
"original_operations": [
"inspect_android_package",
"search_android_classes",
"inspect_android_class"
],
"fact_assertions": 6,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "7129418f2d4428d86cc737124b53636ba4a46de522e702e8861180fc175acb23",
"developer_instructions_sha256": "eaddc85aa5b141538ec280d640c62db799231b394679a17f2e6cc6bc2146a95c",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "3424dd6ba375f96d88fd0ac38102998948fa0fc46e08af8fae414572ba97a62f",
"peak_memory_bytes_sampled": 1336168448,
"peak_tasks_sampled": 108,
"cpu_stat_last_observed": {
"usage_usec": 23974584,
"user_usec": 21485565,
"system_usec": 2489019,
"nr_periods": 636,
"nr_throttled": 45,
"throttled_usec": 67840,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "android-bridge-7",
"task": "android",
"mode": "bridge",
"artifact": "newpipe.apk",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 48.231,
"input_tokens": 113256,
"cached_input_tokens": 91648,
"uncached_input_tokens": 21608,
"output_tokens": 1456,
"completed_mcp_calls": 3,
"original_operations": [
"inspect_android_package",
"search_android_classes",
"inspect_android_class"
],
"fact_assertions": 6,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "7129418f2d4428d86cc737124b53636ba4a46de522e702e8861180fc175acb23",
"developer_instructions_sha256": "247ca3314340f748d1479cc1a0a1f33a234231f17b5768044034bdfe517299c6",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "27e234285e493b50929c0f98938284771d0d4a3787045872f2f517b2297aefeb",
"peak_memory_bytes_sampled": 1659629568,
"peak_tasks_sampled": 126,
"cpu_stat_last_observed": {
"usage_usec": 27717810,
"user_usec": 25042151,
"system_usec": 2675658,
"nr_periods": 458,
"nr_throttled": 50,
"throttled_usec": 73614,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "managed-bridge-2",
"task": "managed",
"mode": "bridge",
"artifact": "sharex.dll",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 73.145,
"input_tokens": 116974,
"cached_input_tokens": 92672,
"uncached_input_tokens": 24302,
"output_tokens": 2065,
"completed_mcp_calls": 3,
"original_operations": [
"inspect_managed_artifact",
"inspect_managed_native_boundaries"
],
"fact_assertions": 7,
"fact_mismatches": ["classification"],
"strict_grade_passed": false,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "fe5a74687126fca7aee78b3ba51f03401983ffeae593924b7c738d50d0f04e61",
"developer_instructions_sha256": "247ca3314340f748d1479cc1a0a1f33a234231f17b5768044034bdfe517299c6",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "06cbdda60ac930d00ade7e115cd4ba234527e297e6cfd931eedc175e00efa1c7",
"peak_memory_bytes_sampled": 939290624,
"peak_tasks_sampled": 103,
"cpu_stat_last_observed": {
"usage_usec": 12114716,
"user_usec": 9701516,
"system_usec": 2413200,
"nr_periods": 630,
"nr_throttled": 16,
"throttled_usec": 15944,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "managed-direct-2",
"task": "managed",
"mode": "direct",
"artifact": "sharex.dll",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 33.15,
"input_tokens": 108096,
"cached_input_tokens": 75776,
"uncached_input_tokens": 32320,
"output_tokens": 2315,
"completed_mcp_calls": 2,
"original_operations": [
"inspect_managed_artifact",
"inspect_managed_native_boundaries"
],
"fact_assertions": 7,
"fact_mismatches": [],
"strict_grade_passed": false,
"cited_ids_observed": false,
"unreadable_result_texts": 1,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "fe5a74687126fca7aee78b3ba51f03401983ffeae593924b7c738d50d0f04e61",
"developer_instructions_sha256": "eaddc85aa5b141538ec280d640c62db799231b394679a17f2e6cc6bc2146a95c",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "5d6957541bd979252d019817e631f5d889ff2dc3efb7f03b9de1033fe34d8430",
"peak_memory_bytes_sampled": 688373760,
"peak_tasks_sampled": 108,
"cpu_stat_last_observed": {
"usage_usec": 5863642,
"user_usec": 4359666,
"system_usec": 1503976,
"nr_periods": 282,
"nr_throttled": 4,
"throttled_usec": 6216,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "electron-inventory-direct-1",
"task": "electron-inventory",
"mode": "direct",
"artifact": "obsidian.asar",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 89.494,
"input_tokens": 266121,
"cached_input_tokens": 238848,
"uncached_input_tokens": 27273,
"output_tokens": 3215,
"completed_mcp_calls": 3,
"original_operations": [
"open_binary",
"inspect_artifact",
"close_binary"
],
"fact_assertions": 7,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "22941dc5d77ce06824e40b01abd3f725aa773d131648d7bba2e607b410ccbef9",
"developer_instructions_sha256": "eaddc85aa5b141538ec280d640c62db799231b394679a17f2e6cc6bc2146a95c",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "fcd0df1a3ae0b5103143addaa4922323354ddee7ba3d0e3020de64f05b6fe3d3",
"peak_memory_bytes_sampled": 703275008,
"peak_tasks_sampled": 115,
"cpu_stat_last_observed": {
"usage_usec": 7720494,
"user_usec": 5691854,
"system_usec": 2028640,
"nr_periods": 782,
"nr_throttled": 7,
"throttled_usec": 15453,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "electron-inventory-bridge-1",
"task": "electron-inventory",
"mode": "bridge",
"artifact": "obsidian.asar",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 145.577,
"input_tokens": 462809,
"cached_input_tokens": 407040,
"uncached_input_tokens": 55769,
"output_tokens": 5624,
"completed_mcp_calls": 8,
"original_operations": [
"open_binary",
"inspect_artifact",
"close_binary",
"open_binary",
"inspect_artifact",
"close_binary"
],
"fact_assertions": 7,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "22941dc5d77ce06824e40b01abd3f725aa773d131648d7bba2e607b410ccbef9",
"developer_instructions_sha256": "247ca3314340f748d1479cc1a0a1f33a234231f17b5768044034bdfe517299c6",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "ab7e25e4345a0e9bba6a06bb0a79aa39e1bf1308b6a66f8173a62bbc9e2d9fc9",
"peak_memory_bytes_sampled": 1029238784,
"peak_tasks_sampled": 112,
"cpu_stat_last_observed": {
"usage_usec": 14650718,
"user_usec": 12106416,
"system_usec": 2544302,
"nr_periods": 1224,
"nr_throttled": 24,
"throttled_usec": 30318,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "firmware-bridge-1",
"task": "firmware",
"mode": "bridge",
"artifact": "openwrt.bin",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 81.944,
"input_tokens": 152886,
"cached_input_tokens": 126976,
"uncached_input_tokens": 25910,
"output_tokens": 2192,
"completed_mcp_calls": 3,
"original_operations": ["inspect_firmware_regions"],
"fact_assertions": 5,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "93c94e26dc4a4b1985b3f8c4246ca5aff886f75dc2349a717ee940243dc73b80",
"developer_instructions_sha256": "247ca3314340f748d1479cc1a0a1f33a234231f17b5768044034bdfe517299c6",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "a5604d0d3140f6232851a81a952e51daf43c8e7f12ba062fac68a8fae0bef708",
"peak_memory_bytes_sampled": 927666176,
"peak_tasks_sampled": 104,
"cpu_stat_last_observed": {
"usage_usec": 11575373,
"user_usec": 9366624,
"system_usec": 2208749,
"nr_periods": 744,
"nr_throttled": 18,
"throttled_usec": 26000,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "firmware-direct-1",
"task": "firmware",
"mode": "direct",
"artifact": "openwrt.bin",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 30.161,
"input_tokens": 103224,
"cached_input_tokens": 74752,
"uncached_input_tokens": 28472,
"output_tokens": 1761,
"completed_mcp_calls": 1,
"original_operations": ["inspect_firmware_regions"],
"fact_assertions": 5,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "93c94e26dc4a4b1985b3f8c4246ca5aff886f75dc2349a717ee940243dc73b80",
"developer_instructions_sha256": "eaddc85aa5b141538ec280d640c62db799231b394679a17f2e6cc6bc2146a95c",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "c0bbd1aec08c9c30061f92064355c3213f680fab545a050271096e85db771a71",
"peak_memory_bytes_sampled": 686739456,
"peak_tasks_sampled": 109,
"cpu_stat_last_observed": {
"usage_usec": 5700866,
"user_usec": 4167696,
"system_usec": 1533169,
"nr_periods": 266,
"nr_throttled": 6,
"throttled_usec": 3978,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "native-direct-1",
"task": "native",
"mode": "direct",
"artifact": "jq",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 327.15,
"input_tokens": 151343,
"cached_input_tokens": 122368,
"uncached_input_tokens": 28975,
"output_tokens": 2458,
"completed_mcp_calls": 4,
"original_operations": [
"open_binary",
"resolve_containing_procedure",
"analyze_function",
"close_binary"
],
"fact_assertions": 7,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "234bfe93d09f9c76c1a64383c11cf7c174eafa4e4ad563124f705a7d5c8920aa",
"developer_instructions_sha256": "eaddc85aa5b141538ec280d640c62db799231b394679a17f2e6cc6bc2146a95c",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "681f38e4ba9b441e7816e868b30e347005fe074907349cd0022fc44302c5b14a",
"peak_memory_bytes_sampled": 1328496640,
"peak_tasks_sampled": 109,
"cpu_stat_last_observed": {
"usage_usec": 263737951,
"user_usec": 256864795,
"system_usec": 6873156,
"nr_periods": 3192,
"nr_throttled": 456,
"throttled_usec": 756678,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "native-bridge-1",
"task": "native",
"mode": "bridge",
"artifact": "jq",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 334.642,
"input_tokens": 285961,
"cached_input_tokens": 245504,
"uncached_input_tokens": 40457,
"output_tokens": 2129,
"completed_mcp_calls": 4,
"original_operations": [
"open_binary",
"analyze_function",
"close_binary"
],
"fact_assertions": 7,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "234bfe93d09f9c76c1a64383c11cf7c174eafa4e4ad563124f705a7d5c8920aa",
"developer_instructions_sha256": "247ca3314340f748d1479cc1a0a1f33a234231f17b5768044034bdfe517299c6",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "6c64953708df4a06b69fb57e5d70141147e4495adabd7340e87e727fcd340742",
"peak_memory_bytes_sampled": 1441775616,
"peak_tasks_sampled": 123,
"cpu_stat_last_observed": {
"usage_usec": 271095966,
"user_usec": 263888347,
"system_usec": 7207618,
"nr_periods": 3267,
"nr_throttled": 450,
"throttled_usec": 784719,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "android-bridge-8",
"task": "android",
"mode": "bridge",
"artifact": "newpipe.apk",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 134.555,
"input_tokens": 159370,
"cached_input_tokens": 134400,
"uncached_input_tokens": 24970,
"output_tokens": 3250,
"completed_mcp_calls": 7,
"original_operations": [
"inspect_android_package",
"search_android_classes",
"inspect_android_class",
"inspect_android_package",
"inspect_android_package",
"search_android_classes",
"inspect_android_class"
],
"fact_assertions": 6,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "7129418f2d4428d86cc737124b53636ba4a46de522e702e8861180fc175acb23",
"developer_instructions_sha256": "247ca3314340f748d1479cc1a0a1f33a234231f17b5768044034bdfe517299c6",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "f1743a341d334bd41760b54980aa70d5f3c8c1aed57c3ae9e470be63449c594d",
"peak_memory_bytes_sampled": 1659744256,
"peak_tasks_sampled": 115,
"cpu_stat_last_observed": {
"usage_usec": 29619173,
"user_usec": 26495167,
"system_usec": 3124005,
"nr_periods": 1229,
"nr_throttled": 60,
"throttled_usec": 84762,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "android-direct-6",
"task": "android",
"mode": "direct",
"artifact": "newpipe.apk",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 71.624,
"input_tokens": 153031,
"cached_input_tokens": 117504,
"uncached_input_tokens": 35527,
"output_tokens": 1501,
"completed_mcp_calls": 3,
"original_operations": [
"inspect_android_package",
"search_android_classes",
"inspect_android_class"
],
"fact_assertions": 6,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "7129418f2d4428d86cc737124b53636ba4a46de522e702e8861180fc175acb23",
"developer_instructions_sha256": "eaddc85aa5b141538ec280d640c62db799231b394679a17f2e6cc6bc2146a95c",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "b8d0422eec6bfd31a9a6ed79ac29e9487c2e68c47ff200904ec239daee9720c3",
"peak_memory_bytes_sampled": 1348767744,
"peak_tasks_sampled": 115,
"cpu_stat_last_observed": {
"usage_usec": 23033331,
"user_usec": 20566262,
"system_usec": 2467069,
"nr_periods": 674,
"nr_throttled": 40,
"throttled_usec": 61573,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "managed-direct-3",
"task": "managed",
"mode": "direct",
"artifact": "sharex.dll",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 75.229,
"input_tokens": 108593,
"cached_input_tokens": 75776,
"uncached_input_tokens": 32817,
"output_tokens": 2774,
"completed_mcp_calls": 2,
"original_operations": [
"inspect_managed_artifact",
"inspect_managed_native_boundaries"
],
"fact_assertions": 7,
"fact_mismatches": [],
"strict_grade_passed": false,
"cited_ids_observed": false,
"unreadable_result_texts": 1,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "fe5a74687126fca7aee78b3ba51f03401983ffeae593924b7c738d50d0f04e61",
"developer_instructions_sha256": "eaddc85aa5b141538ec280d640c62db799231b394679a17f2e6cc6bc2146a95c",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "64f0769b7ad83f8d86c005a48de7a0cf397043d77378983fabfaa226dcb70f87",
"peak_memory_bytes_sampled": 651026432,
"peak_tasks_sampled": 110,
"cpu_stat_last_observed": {
"usage_usec": 6252846,
"user_usec": 4688766,
"system_usec": 1564079,
"nr_periods": 635,
"nr_throttled": 7,
"throttled_usec": 11469,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "managed-bridge-3",
"task": "managed",
"mode": "bridge",
"artifact": "sharex.dll",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 40.609,
"input_tokens": 125519,
"cached_input_tokens": 96000,
"uncached_input_tokens": 29519,
"output_tokens": 2274,
"completed_mcp_calls": 3,
"original_operations": [
"inspect_managed_artifact",
"inspect_managed_native_boundaries"
],
"fact_assertions": 7,
"fact_mismatches": ["classification"],
"strict_grade_passed": false,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "fe5a74687126fca7aee78b3ba51f03401983ffeae593924b7c738d50d0f04e61",
"developer_instructions_sha256": "247ca3314340f748d1479cc1a0a1f33a234231f17b5768044034bdfe517299c6",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "5fbc3cf0b41224f2ef44ab996b174c8a48fe07a818ac2ad334ef59e5ddf26de6",
"peak_memory_bytes_sampled": 1005625344,
"peak_tasks_sampled": 113,
"cpu_stat_last_observed": {
"usage_usec": 11185145,
"user_usec": 9300437,
"system_usec": 1884707,
"nr_periods": 366,
"nr_throttled": 21,
"throttled_usec": 24147,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "electron-inventory-guided-bridge-1",
"task": "electron-inventory",
"mode": "bridge",
"artifact": "obsidian.asar",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 85.909,
"input_tokens": 101994,
"cached_input_tokens": 61440,
"uncached_input_tokens": 40554,
"output_tokens": 2563,
"completed_mcp_calls": 3,
"original_operations": [
"open_binary",
"inspect_artifact",
"close_binary"
],
"fact_assertions": 7,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "f070cdf721805d590c1bd5255ecf1f647ea165885cd5052af35c30ba531da815",
"developer_instructions_sha256": "247ca3314340f748d1479cc1a0a1f33a234231f17b5768044034bdfe517299c6",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "566391b8a6db73228fec00dc7cbf0eaf56ed899178a405d5d8f0c8002fb05d89",
"peak_memory_bytes_sampled": 1007996928,
"peak_tasks_sampled": 109,
"cpu_stat_last_observed": {
"usage_usec": 13304542,
"user_usec": 10842042,
"system_usec": 2462499,
"nr_periods": 787,
"nr_throttled": 19,
"throttled_usec": 27407,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
},
{
"trial": "electron-inventory-guided-direct-1",
"task": "electron-inventory",
"mode": "direct",
"artifact": "obsidian.asar",
"requested_model": "gpt-5.6-terra",
"reasoning": "high",
"codex_version": "codex-cli 0.161.0",
"wall_seconds": 67.54,
"input_tokens": 263484,
"cached_input_tokens": 221952,
"uncached_input_tokens": 41532,
"output_tokens": 2499,
"completed_mcp_calls": 4,
"original_operations": [
"open_binary",
"inspect_artifact",
"inspect_artifact",
"close_binary"
],
"fact_assertions": 7,
"fact_mismatches": [],
"strict_grade_passed": true,
"cited_ids_observed": true,
"unreadable_result_texts": 0,
"grader_sha256": "707e4eef05634db5075ac64382500b9eea03b38f828358315e54381f9d4a8979",
"prompt_sha256": "f070cdf721805d590c1bd5255ecf1f647ea165885cd5052af35c30ba531da815",
"developer_instructions_sha256": "eaddc85aa5b141538ec280d640c62db799231b394679a17f2e6cc6bc2146a95c",
"provider_settings_sha256": "1db4e19adcb32bb64a3baad58a1b4ef04b52ba648bab29678693f9ab8dbdabb4",
"experiment_sources_sha256": {
"agent-trial.py": "3c96d0f7b4b3dd02d168258d8aedd79049bb8647f1ebb174b056bd8eaa582502",
"bridge.mjs": "c1afb88a3045f233006826ffd466590b33027cc7b95f9c6c551ba1aa93fa4727",
"package-lock.json": "6dab2b2dba5101992e9a881ce1820475bd304511dc44362bb1614b08e9b37a87"
},
"events_sha256": "564711cf28211bb7059a04b919f1b6925a816ded3e2dbeb9678382568f700e58",
"peak_memory_bytes_sampled": 728817664,
"peak_tasks_sampled": 114,
"cpu_stat_last_observed": {
"usage_usec": 8708686,
"user_usec": 6609914,
"system_usec": 2098771,
"nr_periods": 597,
"nr_throttled": 12,
"throttled_usec": 19564,
"nr_bursts": 0,
"burst_usec": 0
},
"resource_abort": null,
"resource_events_last_observed": {
"memory.events": {
"low": 0,
"high": 0,
"max": 0,
"oom": 0,
"oom_kill": 0,
"oom_group_kill": 0
},
"pids.events": {
"max": 0
}
}
}
]
}
+205
View File
@@ -0,0 +1,205 @@
"""Evaluate one real Codex CLI task with an isolated REA MCP registration."""
import argparse
import hashlib
import json
import os
from pathlib import Path
import shutil
import signal
import subprocess
import tempfile
import time
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--mode', choices=['direct', 'client-code', 'bridge'], required=True)
parser.add_argument('--prompt', type=Path, required=True)
parser.add_argument('--artifact-path', help='Replace {{artifact_path}} in a question template')
parser.add_argument('--output', type=Path, required=True)
parser.add_argument('--model', default='gpt-5.6-terra')
parser.add_argument('--reasoning', default='high')
parser.add_argument('--timeout', type=int, default=900)
parser.add_argument('--codex', default='/usr/bin/codex')
parser.add_argument('--providers', type=Path)
args = parser.parse_args()
def terminate(signum, _frame):
# The outer resource scope terminates descendants together. Ensure the
# runner's copied credentials are also removed on a resource abort.
raise SystemExit(128 + signum)
signal.signal(signal.SIGTERM, terminate)
repository = Path(__file__).resolve().parents[2]
experiment = Path(__file__).resolve().parent
node = shutil.which('node')
if subprocess.check_output([node, '--version'], text=True).strip() != 'v24.18.0':
raise SystemExit('Use pinned Node 24.18.0 on PATH')
args.output.mkdir(parents=True, exist_ok=False, mode=0o700)
profile = Path(tempfile.mkdtemp(prefix='profile-', dir=args.output))
trial_codex_home = profile / 'codex'
account = profile / 'account'
workspace = profile / 'workspace'
for directory in [trial_codex_home, account, workspace]:
directory.mkdir(mode=0o700)
source_auth = Path(os.environ.get('CODEX_HOME', str(Path.home() / '.codex'))) / 'auth.json'
auth = trial_codex_home / 'auth.json'
started = time.monotonic()
timeout = False
exit_code = None
environment = dict(os.environ)
environment.update({
'CODEX_HOME': str(trial_codex_home), 'HOME': str(account),
'XDG_CONFIG_HOME': str(account / '.config'),
'XDG_CACHE_HOME': str(account / '.cache'),
'XDG_DATA_HOME': str(account / '.local/share'),
'NODE_OPTIONS': '--max-old-space-size=512',
})
provider_env = {'REA_LOG_LEVEL': 'silent', 'NODE_OPTIONS': '--max-old-space-size=512'}
if args.providers:
# This explicit caller file supplies only selected provider settings.
provider_env.update(json.loads(args.providers.read_text()))
command_args = [str(repository / 'scripts/rea.mjs'), 'mcp']
if args.mode == 'bridge':
command_args = [str(experiment / 'bridge.mjs'), node, *command_args]
instruction = (
'Use the registered REA MCP server for this investigation. Static analysis '
'only: do not execute target code, fetch URLs, launch a GUI, or modify targets. '
'Preserve observations, derivations, inferences, limitations, and real Evidence IDs. '
'An Evidence value has evidence_id, normalized_result and limitations; '
'non-Evidence session values have result. '
'The analyzed target digest is Evidence.subject.digest.sha256. '
'normalized_result.engine.artifact_sha256 identifies the analysis engine '
'artifact and must never be substituted for the target digest. '
'Prefer summary/focused views where appropriate. Do not invent successful facts '
'after a tool error. No other agents. Stop once the requested facts are supported.'
)
if args.mode == 'bridge':
instruction += (
' Original REA operations are available through rea_search and rea_execute. '
'Discover tool names/schemas on demand. Execute JavaScript bodies using '
'tools.<original_name>(original_arguments), json(reply) to parse the original '
'MCP result, and return only the needed facts plus their Evidence IDs and '
'limitations. Compose known dependent calls in one script when useful. '
'Select needed fields from normalized_result inside the script; do not '
'return entire Evidence, raw_result or full method/class inventories when '
'the question requests a subset. '
'Await every call; the upstream session persists across scripts.'
)
if args.mode == 'client-code':
instruction += (
' Use the client JavaScript executor to compose registered MCP calls when '
'possible and select the requested normalized_result fields before returning '
'intermediate output to model context. Keep real Evidence IDs and limitations.'
)
quote = json.dumps
config = '\n'.join([
'approval_policy = "never"', 'sandbox_mode = "read-only"',
'web_search = "disabled"', 'model = ' + quote(args.model),
'model_reasoning_effort = ' + quote(args.reasoning),
'developer_instructions = ' + quote(instruction),
'[features]', 'multi_agent = false', 'shell_snapshot = false',
'shell_tool = false', 'unified_exec = false',
'code_mode = ' + ('true' if args.mode == 'client-code' else 'false'),
'code_mode_only = ' + ('true' if args.mode == 'client-code' else 'false'),
'[history]', 'persistence = "none"',
'[mcp_servers.rea]', 'command = ' + quote(node),
'args = ' + quote(command_args), 'startup_timeout_sec = 60',
'tool_timeout_sec = 600', '[mcp_servers.rea.env]',
*[key + ' = ' + quote(value) for key, value in provider_env.items()],
'[mcp_servers.rea.tools.rea_execute]', 'approval_mode = "approve"',
]) + '\n'
# MCP read-only hints cover normal static tools. Explicitly authorize only
# the session-opening primitive needed by the requested native tasks.
config += '[mcp_servers.rea.tools.open_binary]\napproval_mode = "approve"\n'
for tool in ['analyze_javascript_application', 'inspect_analysis_view',
'inspect_android_package', 'search_android_classes',
'inspect_android_class', 'inspect_android_method',
'inspect_firmware_regions', 'inspect_managed_artifact',
'inspect_managed_members', 'inspect_managed_native_boundaries',
'inspect_artifact', 'inspect_wasm_artifact',
'resolve_containing_procedure', 'analyze_function', 'close_binary']:
config += '[mcp_servers.rea.tools.' + tool + ']\napproval_mode = "approve"\n'
try:
if source_auth.exists():
shutil.copyfile(source_auth, auth)
auth.chmod(0o600)
(trial_codex_home / 'config.toml').write_text(config)
(trial_codex_home / 'config.toml').chmod(0o600)
prompt = args.prompt.read_text()
template_digest = hashlib.sha256(prompt.encode()).hexdigest()
if '{{artifact_path}}' in prompt:
if not args.artifact_path or not os.path.isabs(args.artifact_path):
raise ValueError('A question template requires an absolute --artifact-path')
prompt = prompt.replace('{{artifact_path}}', args.artifact_path)
elif args.artifact_path:
raise ValueError('--artifact-path requires the literal template marker')
(args.output / 'prompt.txt').write_text(prompt)
(args.output / 'trial-settings.json').write_text(json.dumps({
'mode': args.mode, 'model': args.model, 'reasoning': args.reasoning,
'experiment_commit': subprocess.check_output(
['git', 'rev-parse', 'HEAD'], cwd=repository, text=True).strip(),
'experiment_sources_sha256': {
name: hashlib.sha256((experiment / name).read_bytes()).hexdigest()
for name in ['agent-trial.py', 'bridge.mjs', 'package-lock.json']
},
'developer_instructions': instruction,
'developer_instructions_sha256': hashlib.sha256(instruction.encode()).hexdigest(),
'prompt_sha256': hashlib.sha256(prompt.encode()).hexdigest(),
'question_template_sha256': template_digest,
'provider_settings_sha256': hashlib.sha256(
json.dumps(provider_env, sort_keys=True).encode()).hexdigest(),
'features': {'shell_tool': False, 'unified_exec': False,
'multi_agent': False, 'code_mode': args.mode == 'client-code',
'code_mode_only': args.mode == 'client-code'},
}, indent=2) + '\n')
invocation = [args.codex, '--no-daemon', 'exec', '--ephemeral',
'--skip-git-repo-check', '--ignore-rules', '--json',
'--color', 'never', '-C', str(workspace),
'--output-last-message', str(args.output.resolve() / 'answer.txt'), '-']
with (args.output / 'events.jsonl').open('w') as events, (args.output / 'stderr.log').open('w') as errors:
child = subprocess.Popen(invocation, env=environment, cwd=workspace,
stdin=subprocess.PIPE, stdout=events, stderr=errors, text=True)
child.stdin.write(prompt)
child.stdin.close()
try:
exit_code = child.wait(timeout=args.timeout)
except subprocess.TimeoutExpired:
timeout = True
child.terminate()
try:
exit_code = child.wait(timeout=10)
except subprocess.TimeoutExpired:
child.kill()
exit_code = child.wait()
usage = []
tools = []
event_types = {}
for line in (args.output / 'events.jsonl').read_text().splitlines():
event = json.loads(line)
kind = event.get('type', 'unknown')
event_types[kind] = event_types.get(kind, 0) + 1
if 'usage' in event:
usage.append(event['usage'])
item = event.get('item', {})
if item.get('type') == 'mcp_tool_call' and kind == 'item.completed':
tools.append({k: item.get(k) for k in ['server', 'tool', 'arguments', 'status', 'error']})
summary = {
'mode': args.mode, 'requested_model': args.model, 'reasoning': args.reasoning,
'baseline_sha': 'fb94d9dde0ccda83ae520ac6fb22b1d283562cf3',
'codex_version': subprocess.check_output([args.codex, '--version'], text=True).strip(),
'exit_code': exit_code, 'timeout': timeout,
'wall_seconds': round(time.monotonic() - started, 3),
'usage': usage, 'completed_mcp_calls': tools, 'event_types': event_types,
'factual_correctness': 'not_assessed',
'scope': 'real_cli_trial_requires_transcript_and_fact_review',
}
(args.output / 'summary.json').write_text(json.dumps(summary, indent=2) + '\n')
print(json.dumps(summary))
finally:
# Always remove copied credentials, config, caches and profile state.
shutil.rmtree(profile)
raise SystemExit(124 if timeout else exit_code)
if __name__ == '__main__':
main()
+369
View File
@@ -0,0 +1,369 @@
import { createHash } from "node:crypto";
import { readFile, writeFile, mkdir } from "node:fs/promises";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { parseArgs } from "node:util";
import { getEncoding } from "js-tiktoken";
import { CodeModeBridge, connectUpstream, json } from "./bridge.mjs";
// Replay isolates transport/discovery costs. It does not simulate model reasoning.
const workflows = {
"sharex.dll": {
tools: ["inspect_managed_artifact", "inspect_managed_native_boundaries"],
question:
"Report assembly/module identity, target framework and declared P/Invoke libraries with their uncertainty.",
code: `
const artifact = await call("inspect_managed_artifact", {path: input.path});
const boundaries = await call("inspect_managed_native_boundaries", {});
const n = artifact.normalized_result;
return {artifact_sha256: artifact.subject?.digest.sha256,
classification: n.classification, assembly: n.assembly, module: n.module,
target_frameworks: n.target_frameworks, coverage: n.coverage,
native_boundaries: boundaries.normalized_result,
evidence_ids: [artifact.evidence_id, boundaries.evidence_id],
limitations: [...artifact.limitations, ...boundaries.limitations]};`,
},
"sqlite.wasm": {
tools: ["inspect_wasm_artifact"],
question:
"Report exact WASM validation, all exported names and runtime/network observation states without executing it.",
code: `
const wasm = await call("inspect_wasm_artifact", {path: input.path});
const n = wasm.normalized_result;
return {artifact_sha256: wasm.subject?.digest.sha256,
validation: n.validation, sections: n.sections, exports: n.exports,
runtime_execution: n.runtime_execution, network_fetch: n.network_fetch,
evidence_ids: [wasm.evidence_id], limitations: [...wasm.limitations, ...n.limitations]};`,
},
"obsidian.asar": {
tools: ["analyze_javascript_application", "inspect_analysis_view"],
question:
"Report application identity, analysis coverage/counts and the first eight module identities.",
code: `
const summary = await call("analyze_javascript_application", {
input_path: input.path, detail: "summary", max_heap_mb: 1024,
analysis_timeout_ms: 300000, integrity_policy: "fail"
});
const parent = summary.normalized_result.parent_evidence_id;
const page = await call("inspect_analysis_view", {
source: {kind: "retained-evidence", evidence_id: parent},
view: {kind: "page", collection: "modules", offset: 0, limit: 8}
});
return {artifact_sha256: summary.subject?.digest.sha256,
summary: summary.normalized_result, modules: page.normalized_result,
evidence_ids: [summary.evidence_id, parent, page.evidence_id],
limitations: [...summary.limitations, ...page.limitations]};`,
},
"obsidian-inventory": {
artifact: "obsidian.asar",
tools: ["open_binary", "inspect_artifact", "close_binary"],
question:
"Report ASAR identity, complete inventory manifest, entry-kind counts, root package/main/preload occurrences, integrity contradictions and inventory coverage; do not claim AST or runtime analysis.",
code: `
await call("open_binary", {path: input.path});
try {
const inspected = await call("inspect_artifact", {integrity_policy: "fail"});
const n = inspected.normalized_result;
const inventory = n.substeps.find(x => x.operation === "inventory_artifact").evidence;
const graph = inventory.normalized_result;
const counts = {};
for (const row of graph.occurrences)
counts[row.entry_kind] = (counts[row.entry_kind] ?? 0) + 1;
return {artifact_sha256: inspected.subject.digest.sha256,
manifest: graph.manifest, entry_kind_counts: counts,
requested_paths: graph.occurrences.filter(x => ["package.json", "main.js", "preload.js"].includes(x.logical_path)),
integrity_contradictions: graph.integrity_contradictions,
coverage: n.coverage, unexplored_branches: n.unexplored_branches,
evidence_ids: [inspected.evidence_id, inventory.evidence_id],
limitations: [...inspected.limitations, ...n.limitations, ...inventory.limitations]};
} finally { await call("close_binary", {}); }`,
},
"newpipe.apk": {
tools: [
"inspect_android_package",
"search_android_classes",
"inspect_android_class",
],
question:
"Report package/version, exact MainActivity matches and its onCreate method descriptors.",
code: `
const pkg = await call("inspect_android_package", {path: input.path});
const found = await call("search_android_classes", {path: input.path, query: "MainActivity"});
if (!found.normalized_result.matches.includes("org.schabi.newpipe.MainActivity"))
throw new Error("Requested shipped MainActivity was not found");
const cls = await call("inspect_android_class", {
path: input.path, class_name: "org.schabi.newpipe.MainActivity"
});
return {artifact_sha256: pkg.subject?.digest.sha256,
package_name: pkg.normalized_result.package_name,
version_name: pkg.normalized_result.version_name,
version_code: pkg.normalized_result.version_code,
matches: found.normalized_result.matches, coverage: found.normalized_result.coverage,
onCreate: cls.normalized_result.methods.filter(x => x.name === "onCreate"),
evidence_ids: [pkg.evidence_id, found.evidence_id, cls.evidence_id],
limitations: [...pkg.limitations, ...found.limitations, ...cls.limitations]};`,
},
"openwrt.bin": {
tools: ["inspect_firmware_regions"],
question:
"Report firmware identity, every reported region offset/signature and examined coverage.",
code: `
const inspected = await call("inspect_firmware_regions", {path: input.path});
return {artifact_sha256: inspected.subject?.digest.sha256,
result: inspected.normalized_result, evidence_ids: [inspected.evidence_id],
limitations: inspected.limitations};`,
},
jq: {
tools: [
"open_binary",
"resolve_containing_procedure",
"analyze_function",
"close_binary",
],
question:
"Resolve the observed ELF entry address and report the recovered function's first 512 pseudocode units and caller/callee counts.",
code: `
await call("open_binary", {path: input.path, provider_id: "ghidra"});
try {
const found = await call("resolve_containing_procedure", {address: input.entry_address});
const fn = await call("analyze_function", {procedure: input.entry_address});
const n = fn.normalized_result;
return {artifact_sha256: fn.subject?.digest.sha256,
entry_address: input.entry_address, containing_procedure: found.normalized_result, procedure: n.procedure,
pseudocode_prefix: n.pseudocode.slice(0, 512),
caller_count: n.callers.length, callee_count: n.callees.length,
evidence_ids: [found.evidence_id, fn.evidence_id],
limitations: [...found.limitations, ...fn.limitations, ...n.limitations]};
} finally { await call("close_binary", {}); }`,
},
};
const { values } = parseArgs({
options: {
artifact: { type: "string" },
workflow: { type: "string" },
mode: { type: "string", default: "direct" },
"artifact-root": { type: "string" },
providers: { type: "string" },
output: { type: "string" },
},
});
if (
!workflows[values.workflow ?? values.artifact] ||
!["direct", "discovery", "bridge"].includes(values.mode) ||
!values["artifact-root"] ||
!values.output
)
throw new Error(
"Use --artifact ID [--workflow NAME] --mode direct|discovery|bridge --artifact-root ABS --output NEW_DIR [--providers JSON]",
);
const experiment = dirname(fileURLToPath(import.meta.url));
const repository = resolve(experiment, "../..");
const corpus = JSON.parse(
await readFile(resolve(experiment, "corpus.json"), "utf8"),
);
const artifact = corpus.artifacts.find((x) => x.id === values.artifact);
const workflowName = values.workflow ?? values.artifact;
const workflow = workflows[workflowName];
if (!artifact || artifact.id !== (workflow.artifact ?? workflowName))
throw new Error(
"Selected workflow does not match the frozen corpus artifact",
);
const artifactPath = resolve(values["artifact-root"], artifact.file);
const bytes = await readFile(artifactPath);
const sha256 = createHash("sha256").update(bytes).digest("hex");
if (sha256 !== artifact.sha256 || bytes.length !== artifact.bytes)
throw new Error("Artifact identity differs from frozen corpus");
await mkdir(values.output, { recursive: false, mode: 0o700 });
const encoding = getEncoding("cl100k_base");
const measure = (value) => {
const text = typeof value === "string" ? value : JSON.stringify(value);
return {
bytes: Buffer.byteLength(text),
cl100k_estimated_tokens: encoding.encode(text).length,
};
};
const modelText = (reply) =>
reply.content
.filter((item) => item.type === "text")
.map((item) => item.text)
.join("\n");
const environment = values.providers
? JSON.parse(await readFile(values.providers, "utf8"))
: {};
const started = performance.now();
const upstream = await connectUpstream({
command: process.execPath,
args: [resolve(repository, "scripts/rea.mjs"), "mcp"],
env: environment,
});
const connected = performance.now();
const records = [];
const realCall = upstream.call;
upstream.call = async (name, args, options) => {
const began = performance.now();
try {
const reply = await realCall(name, args, { timeout: 600_000, ...options });
const parsed = json(reply);
records.push({
name,
arguments: args,
elapsed_ms: performance.now() - began,
is_error: reply.isError === true,
input: measure(args),
output: measure(reply),
text_output: measure(modelText(reply)),
evidence_id: parsed.evidence_id,
reply,
});
return reply;
} catch (error) {
records.push({
name,
arguments: args,
elapsed_ms: performance.now() - began,
failure: String(error),
input: measure(args),
});
throw error;
}
};
const bridge = new CodeModeBridge(upstream);
const input = { path: artifactPath };
if (artifact.id === "jq") {
if (bytes.subarray(0, 6).toString("hex") !== "7f454c460201")
throw new Error("Expected ELF64 little-endian header for entry seed");
input.entry_address = `0x${bytes.readBigUInt64LE(24).toString(16)}`;
}
const code = `const input = ${JSON.stringify(input)};
async function call(name, args) {
const reply = await tools[name](args);
const parsed = json(reply);
if (reply.isError) throw new Error(JSON.stringify(parsed));
return parsed;
}
${workflow.code}`;
let discovery;
let value;
let failure;
let bridgeReply;
const recovery = [];
const operationStarted = performance.now();
try {
if (values.mode !== "direct")
discovery = await bridge.search({ names: workflow.tools });
if (values.mode === "bridge") {
bridgeReply = await bridge.execute({ code, timeout_ms: 900_000 });
value = bridgeReply.value;
failure = bridgeReply.bridge_error;
} else {
const tools = Object.fromEntries(
upstream.catalog.map((tool) => [
tool.name,
(args) => upstream.call(tool.name, args),
]),
);
const AsyncFunction = Object.getPrototypeOf(
async function () {},
).constructor;
value = await new AsyncFunction("tools", "json", code)(tools, json);
}
} catch (error) {
failure = String(error);
} finally {
const partials = new Set(
records.flatMap((record) => {
if (!record.reply?.isError) return [];
try {
const partial = json(record.reply).error?.details?.partial_observation;
return partial?.kind === "retained-evidence"
? [partial.evidence_id]
: [];
} catch {
return []; // Preserve non-JSON failures in calls.json, without inventing IDs.
}
}),
);
for (const evidence_id of partials) {
// Capture already retained partial facts before disposing the replay session.
// Recovery is not a successful completion of the failed analyst workflow.
try {
const reply = await realCall(
"inspect_analysis_view",
{
source: { kind: "retained-evidence", evidence_id },
view: { kind: "summary" },
},
{ timeout: 60_000 },
);
recovery.push({ parent_evidence_id: evidence_id, reply });
} catch (error) {
recovery.push({
parent_evidence_id: evidence_id,
failure: String(error),
});
}
}
await upstream.close();
}
const catalogExposure = values.mode === "direct" ? upstream.catalog : discovery;
const summary = {
scope: "deterministic_real_provider_replay_not_model_accuracy",
baseline_sha: "fb94d9dde0ccda83ae520ac6fb22b1d283562cf3",
artifact: artifact.id,
workflow: workflowName,
artifact_sha256: sha256,
mode: values.mode,
question: workflow.question,
startup_ms: connected - started,
operation_ms: performance.now() - operationStarted,
original_calls: records.map(({ reply: _reply, ...metadata }) => metadata),
exposed_catalog: catalogExposure ? measure(catalogExposure) : null,
direct_input_definitions: measure(
upstream.catalog.map((tool) => ({
name: tool.name,
description: tool.description,
inputSchema: tool.inputSchema,
})),
),
execution_code: values.mode === "bridge" ? measure(code) : null,
exposed_tool_results:
values.mode === "bridge"
? [measure(bridgeReply)]
: records.filter((x) => x.output).map((x) => x.output),
exposed_text_results:
values.mode === "bridge"
? [measure(bridgeReply)]
: records.filter((x) => x.text_output).map((x) => x.text_output),
projection: value,
failure: failure ?? null,
partial_recovery: recovery,
correctness: failure
? "failed_workflow"
: "requires_cross_profile_fact_review",
estimator:
"cl100k_base_compact_MCP_JSON_including_envelope_not_actual_model_tokens",
};
await writeFile(
resolve(values.output, "summary.json"),
JSON.stringify(summary, null, 2),
);
await writeFile(resolve(values.output, "calls.json"), JSON.stringify(records));
await writeFile(resolve(values.output, "code.js"), code);
console.log(
JSON.stringify({
artifact: artifact.id,
mode: values.mode,
calls: records.length,
startup_ms: summary.startup_ms,
operation_ms: summary.operation_ms,
failure: summary.failure
? String(
typeof summary.failure === "object"
? summary.failure.message
: summary.failure,
).slice(0, 1000)
: null,
}),
);
if (failure) process.exitCode = 1;
+426
View File
@@ -0,0 +1,426 @@
import { createHash } from "node:crypto";
import { pathToFileURL } from "node:url";
import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { McpServer } from "@modelcontextprotocol/server";
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
import { compile } from "json-schema-to-typescript";
import { newQuickJSWASMModule, Scope } from "quickjs-emscripten";
import { z } from "zod";
// Node maps larger delays to 1 ms. Reject them before creating a timer.
const executeInputSchema = z.strictObject({
code: z.string(),
timeout_ms: z.number().int().positive().max(2_147_483_647).optional(),
memory_bytes: z
.number()
.int()
.positive()
.max(128 * 1024 * 1024)
.optional(),
});
const digest = (value) =>
createHash("sha256").update(JSON.stringify(value)).digest("hex");
export const json = (reply) => {
if (reply.structuredContent !== undefined) return reply.structuredContent;
const texts = reply.content.filter((item) => item.type === "text");
if (texts.length !== 1) throw new Error("Expected one REA JSON text block");
return JSON.parse(texts[0].text);
};
/** One upstream session, original tool names, complete live catalog. */
export async function connectUpstream({
command,
args,
env,
stderr = "inherit",
}) {
const transport = new StdioClientTransport({ command, args, env, stderr });
const client = new Client({
name: "rea-codemode-experiment",
version: "0.0.0",
});
try {
await client.connect(transport, { timeout: 60_000 });
const catalog = [];
let cursor;
do {
const page = await client.listTools(cursor ? { cursor } : undefined);
catalog.push(...page.tools);
cursor = page.nextCursor;
} while (cursor !== undefined);
if (new Set(catalog.map((tool) => tool.name)).size !== catalog.length)
throw new Error("Duplicate upstream tool names");
return {
client,
catalog,
call: (name, args, options) =>
client.callTool({ name, arguments: args }, options),
close: () => client.close(),
};
} catch (error) {
await client.close();
throw error;
}
}
export class CodeModeBridge {
constructor(upstream) {
this.upstream = upstream;
this.byName = new Map(upstream.catalog.map((tool) => [tool.name, tool]));
this.catalogDigest = digest(upstream.catalog);
this.declarations = new Map();
this.queue = Promise.resolve();
}
/** The live catalog is immutable for this connection; derive each type once. */
declarationsFor(tool) {
if (!this.declarations.has(tool.name)) {
const options = { bannerComment: "", format: false, unknownAny: true };
const pending = Promise.all([
compile(tool.inputSchema, `${tool.name}_Input`, options),
tool.outputSchema
? compile(
{ ...tool.outputSchema, title: `${tool.name}_Output` },
`${tool.name}_Output`,
options,
)
: undefined,
]);
this.declarations.set(tool.name, pending);
}
return this.declarations.get(tool.name);
}
/** Search exposes original schemas and generated input types on demand. */
async search({ query = "", names = [], schemas, output_schemas = false }) {
const includeSchemas = schemas ?? (names.length > 0 || output_schemas);
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
const selected = this.upstream.catalog.filter((tool) =>
names.length
? names.includes(tool.name)
: terms.every((term) =>
`${tool.name} ${tool.description ?? ""}`
.toLowerCase()
.includes(term),
),
);
// Failed all-word searches keep their original semantics. Offer only the
// best positive lexical matches as names, without expanding their schemas.
const ranked =
selected.length || !terms.length || names.length
? []
: this.upstream.catalog.map((tool) => ({
tool,
score: terms.filter((term) =>
`${tool.name} ${tool.description ?? ""}`
.toLowerCase()
.includes(term),
).length,
}));
const bestScore = Math.max(0, ...ranked.map((row) => row.score));
const suggestions = ranked
.filter((row) => row.score === bestScore && bestScore > 0)
.map(({ tool }) => ({ name: tool.name, description: tool.description }));
const tools = [];
for (const tool of selected) {
const [inputType, outputType] = includeSchemas
? await this.declarationsFor(tool)
: [];
tools.push(
includeSchemas
? {
...tool,
...(!output_schemas ? { outputSchema: undefined } : {}),
typescript: inputType,
output_typescript: outputType,
}
: {
name: tool.name,
description: tool.description,
annotations: tool.annotations,
},
);
}
return {
catalog_sha256: this.catalogDigest,
total_tools: this.byName.size,
matched_tools: tools.length,
tools,
...(suggestions.length ? { suggestions } : {}),
};
}
/** Serialize scripts sharing the active target; no implicit batch races. */
execute(input, options = {}) {
const parsed = executeInputSchema.parse(input);
const work = this.queue.then(() => this.run(parsed, options));
this.queue = work.catch(() => undefined);
return work;
}
async run(
{ code, timeout_ms = 120_000, memory_bytes = 128 * 1024 * 1024 },
options,
) {
const controller = new AbortController();
const signal = options.signal
? AbortSignal.any([controller.signal, options.signal])
: controller.signal;
signal.throwIfAborted();
const deadline = Date.now() + timeout_ms;
const timer = setTimeout(
() => controller.abort(new Error("Code Mode deadline exceeded")),
timeout_ms,
);
const QuickJS = await newQuickJSWASMModule();
const runtime = QuickJS.newRuntime();
// Pending-job execution can create another context in the runtime.
// Own contexts at creation, including those allocated by the job pump.
const contexts = new Scope();
const newContext = runtime.newContext.bind(runtime);
runtime.newContext = (options) => contexts.manage(newContext(options));
runtime.setMemoryLimit(memory_bytes);
runtime.setMaxStackSize(1024 * 1024);
runtime.setInterruptHandler(() => signal.aborted || Date.now() > deadline);
const vm = runtime.newContext();
const pending = new Set();
const calls = [];
let toolQueue = Promise.resolve();
let finished = false;
let promise;
let value;
let failure;
const checkedEval = (source) => {
const result = vm.evalCode(source);
if (result.error) {
const error = vm.dump(result.error);
result.error.dispose();
throw new Error(JSON.stringify(error));
}
return result.value;
};
const pump = () => {
const result = runtime.executePendingJobs();
if (result.error) {
failure = vm.dump(result.error);
result.error.dispose();
finished = true;
}
};
const fromJson = (data) =>
checkedEval(`JSON.parse(${JSON.stringify(JSON.stringify(data))})`);
const callHandle = vm.newFunction("call", (nameHandle, argumentsHandle) => {
const name = vm.getString(nameHandle);
const args = JSON.parse(vm.getString(argumentsHandle));
if (!this.byName.has(name))
throw new Error(`Unknown upstream tool: ${name}`);
signal.throwIfAborted();
const deferred = vm.newPromise();
const audit = { name, arguments_sha256: digest(args) };
calls.push(audit);
const work = toolQueue.then(async () => {
const started = performance.now();
try {
signal.throwIfAborted();
const reply = await this.upstream.call(name, args, {
signal,
timeout: Math.max(1, deadline - Date.now()),
onprogress: options.onprogress,
});
audit.elapsed_ms = performance.now() - started;
audit.result_sha256 = digest(reply);
audit.is_error = reply.isError === true;
try {
const record = json(reply);
if (record.evidence_id) audit.evidence_id = record.evidence_id;
if (Array.isArray(record.evidence_links))
audit.evidence_links = record.evidence_links;
const partial = record.error?.details?.partial_observation;
if (partial?.kind === "retained-evidence")
audit.partial_evidence_id = partial.evidence_id;
} catch {
/* Non-JSON MCP content is still preserved in reply. */
}
const handle = fromJson(reply);
deferred.resolve(handle);
handle.dispose();
} catch (error) {
audit.transport_error = error.message;
const handle = fromJson({ name: error.name, message: error.message });
deferred.reject(handle);
handle.dispose();
} finally {
deferred.dispose();
pump();
}
});
const settled = work.catch((error) => {
failure = { message: error.message };
finished = true;
});
toolQueue = settled;
pending.add(settled);
void settled.then(() => pending.delete(settled));
// The callback transfers its returned handle to QuickJS. Keep the
// deferred's original host handle until settlement, with a separate
// guest handle; otherwise bulk promise cleanup shares one lifetime.
return deferred.handle.dup();
});
const doneHandle = vm.newFunction("done", (data) => {
value = JSON.parse(vm.getString(data));
finished = true;
});
const failHandle = vm.newFunction("fail", (error) => {
failure = vm.dump(error);
finished = true;
});
try {
vm.setProp(vm.global, "__call", callHandle);
vm.setProp(vm.global, "__done", doneHandle);
vm.setProp(vm.global, "__fail", failHandle);
checkedEval(`
const tools = Object.freeze(Object.fromEntries(${JSON.stringify([...this.byName.keys()])}.map(
name => [name, args => __call(name, JSON.stringify(args))]
)));
const json = reply => {
if (reply.structuredContent !== undefined) return reply.structuredContent;
const texts = reply.content.filter(item => item.type === 'text');
if (texts.length !== 1) throw new Error('Expected one REA JSON text block');
return JSON.parse(texts[0].text);
};
`).dispose();
promise = checkedEval(`(async () => {\n${code}\n})().then(
value => __done(JSON.stringify(value === undefined ? null : value)),
error => __fail({name: error?.name, message: error?.message ?? String(error)})
)`);
pump();
while (!finished && !signal.aborted) {
if (pending.size) await Promise.race(pending);
else
throw new Error(
"Guest promise cannot progress: no pending tool calls",
);
pump();
}
signal.throwIfAborted();
if (calls.some((call) => !call.result_sha256 && !call.transport_error)) {
controller.abort(
new Error("Code returned before awaiting all tool calls"),
);
await Promise.allSettled(pending);
failure = {
message:
"Code returned before awaiting all tool calls; calls were cancelled",
};
} else await Promise.allSettled(pending);
} catch (error) {
failure = { name: error.name, message: error.message };
controller.abort(error);
await Promise.allSettled(pending);
} finally {
clearTimeout(timer);
promise?.dispose();
callHandle.dispose();
doneHandle.dispose();
failHandle.dispose();
contexts.dispose();
runtime.dispose();
}
return {
catalog_sha256: this.catalogDigest,
calls,
...(failure ? { bridge_error: failure } : { value }),
};
}
}
export function createBridgeServer(bridge) {
const server = new McpServer({
name: "rea-codemode-experiment",
version: "0.0.0",
});
const reply = (result) => ({
content: [{ type: "text", text: JSON.stringify(result) }],
...(result.bridge_error ? { isError: true } : {}),
});
server.registerTool(
"rea_search",
{
description:
"Discover original upstream REA tools. Start with one domain word, e.g. query=android; query words must all occur. Query/empty discovery defaults to names and descriptions. Then supply all selected exact names together to obtain exact input schemas plus derived input/output TypeScript for code authoring. schemas=true/false overrides this choice. Request output_schemas=true only for original JSON validation contracts. rea_search and rea_execute are already declared bridge tools, not upstream catalog entries. catalog_sha256 hashes the SDK catalog, not REA server_identity.catalog.digests. Code calls tools.<name>(original_arguments); json(reply) parses the original MCP value.",
inputSchema: z.strictObject({
query: z.string().default(""),
names: z.array(z.string()).default([]),
schemas: z.boolean().optional(),
output_schemas: z.boolean().default(false),
}),
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
},
async (input) => reply(await bridge.search(input)),
);
server.registerTool(
"rea_execute",
{
description:
"Run a JavaScript async function body with tools.<original_REA_name>(original_arguments), json(reply) and return. Await every call. json(reply) returns the original REA value: Evidence has normalized_result, evidence_id and limitations; session values have result. Select the needed normalized_result fields inside code before returning them with Evidence IDs and limitations. One upstream session persists. Calls run in order, including Promise.all. All original REA effects, validation and retention apply; projections are caller selections, not new Evidence. No host IO or imports. Call audit and Evidence IDs survive script errors. Default deadline 120s and guest memory 128 MiB; use longer deadline for native analysis.",
inputSchema: executeInputSchema,
annotations: {
readOnlyHint: false,
destructiveHint: true,
idempotentHint: false,
openWorldHint: true,
},
},
async (input, context) =>
reply(
await bridge.execute(input, {
signal: context.mcpReq.signal,
onprogress:
context.mcpReq._meta?.progressToken === undefined
? undefined
: (progress) =>
context.mcpReq.notify({
method: "notifications/progress",
params: {
...progress,
progressToken: context.mcpReq._meta.progressToken,
},
}),
}),
),
);
return server;
}
async function main() {
const [command, ...args] = process.argv.slice(2);
if (!command) throw new Error("Usage: node bridge.mjs COMMAND [ARG...]");
const upstream = await connectUpstream({ command, args, env: process.env });
const server = createBridgeServer(new CodeModeBridge(upstream));
let closing = false;
const close = async () => {
if (closing) return;
closing = true;
await server.close();
await upstream.close();
};
process.once("SIGINT", () => void close());
process.once("SIGTERM", () => void close());
const transport = new StdioServerTransport();
transport.onclose = () => void close();
await server.connect(transport);
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
+313
View File
@@ -0,0 +1,313 @@
import assert from "node:assert/strict";
import { after, before, test } from "node:test";
import { fileURLToPath } from "node:url";
import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import Ajv2020 from "ajv/dist/2020.js";
import { CodeModeBridge, connectUpstream, json } from "./bridge.mjs";
const entrypoint = fileURLToPath(
new URL("../../scripts/rea.mjs", import.meta.url),
);
const fixture = fileURLToPath(
new URL("../../tests/conformance/readiness/javascript-cli", import.meta.url),
);
const analysisArgs = {
input_path: fixture,
detail: "summary",
max_heap_mb: 128,
};
let upstream;
let bridge;
before(async () => {
upstream = await connectUpstream({
command: process.execPath,
args: [entrypoint, "mcp"],
env: { ...process.env, REA_LOG_LEVEL: "silent" },
});
bridge = new CodeModeBridge(upstream);
});
after(async () => {
await upstream?.close();
});
test("discovery preserves exact current REA schemas and names", async () => {
const result = await bridge.search({
names: ["binary_session"],
output_schemas: true,
});
assert.equal(result.total_tools, upstream.catalog.length);
const original = upstream.catalog.find(
(tool) => tool.name === "binary_session",
);
const { typescript, output_typescript, ...discovered } = result.tools[0];
assert.deepEqual(discovered, original);
assert.match(typescript, /export interface BinarySession_Input/);
assert.match(output_typescript, /export interface BinarySession_Output/);
const inputOnly = await bridge.search({ names: ["binary_session"] });
assert.deepEqual(inputOnly.tools[0].inputSchema, original.inputSchema);
assert.equal(inputOnly.tools[0].outputSchema, undefined);
assert.equal(inputOnly.tools[0].output_typescript, output_typescript);
const all = await bridge.search({ schemas: false });
assert.deepEqual(
all.tools.map((tool) => tool.name),
upstream.catalog.map((tool) => tool.name),
);
const query = await bridge.search({ query: "android" });
assert.ok(query.tools.length > 0);
assert.ok(query.tools.every((tool) => tool.inputSchema === undefined));
const querySchemas = await bridge.search({ query: "android", schemas: true });
assert.ok(querySchemas.tools.every((tool) => tool.inputSchema !== undefined));
const outputRequested = await bridge.search({
query: "android",
output_schemas: true,
});
assert.ok(
outputRequested.tools.every((tool) => tool.outputSchema !== undefined),
);
const missed = await bridge.search({
query: "android impossible_query_word",
});
assert.equal(missed.matched_tools, 0);
assert.ok(
missed.suggestions.some((tool) => tool.name === "inspect_android_package"),
);
assert.ok(missed.suggestions.every((tool) => tool.inputSchema === undefined));
});
test("raw original result and parsed result survive a real MCP call", async () => {
const result = await bridge.execute({
code: "const r = await tools.binary_session({}); return {raw:r, parsed:json(r)};",
});
assert.equal(result.bridge_error, undefined);
assert.deepEqual(json(result.value.raw), result.value.parsed);
assert.equal(result.calls[0].name, "binary_session");
assert.match(result.calls[0].result_sha256, /^[a-f0-9]{64}$/);
assert.equal(result.calls[0].is_error, false);
});
test("Promise.all calls settle in order without losing pending work", async () => {
const result = await bridge.execute({
code: "return await Promise.all([tools.binary_session({}), tools.binary_session({}), tools.binary_session({})]);",
});
assert.equal(result.bridge_error, undefined);
assert.equal(result.value.length, 3);
assert.equal(result.calls.length, 3);
assert.ok(result.calls.every((call) => call.result_sha256));
});
test("upstream invalid-input result remains an original MCP error envelope", async () => {
const args = {
input_path: "/nonexistent/rea-codemode-artifact",
detail: "summary",
};
const direct = await upstream.call("analyze_javascript_application", args);
const result = await bridge.execute({
code: `return await tools.analyze_javascript_application(${JSON.stringify(args)});`,
});
assert.equal(result.bridge_error, undefined);
assert.equal(result.value.isError, true);
assert.deepEqual(json(result.value).error, json(direct).error);
assert.equal(result.calls[0].is_error, true);
});
test("guest has no Node, filesystem, fetch or module-loading capabilities", async () => {
const result = await bridge.execute({
code: "return [typeof process,typeof require,typeof fetch,typeof Deno,Function('return typeof process')()];",
});
assert.deepEqual(result.value, Array(5).fill("undefined"));
const imported = await bridge.execute({
code: "return await import('node:fs');",
});
assert.ok(imported.bridge_error);
});
test("CPU deadline interrupts runaway code and the next execution works", async () => {
const result = await bridge.execute({
code: "while(true) {}",
timeout_ms: 20,
});
assert.ok(result.bridge_error);
assert.deepEqual(result.calls, []);
assert.equal((await bridge.execute({ code: "return 42;" })).value, 42);
});
test("guest allocation pressure fails within its heap budget and permits reuse", async () => {
const result = await bridge.execute({
code: "return new Array(1_000_000).fill('x');",
memory_bytes: 2 * 1024 * 1024,
});
assert.match(result.bridge_error.message, /memory/i);
assert.deepEqual(result.calls, []);
assert.equal((await bridge.execute({ code: "return 42;" })).value, 42);
assert.throws(() =>
bridge.execute({ code: "return 1;", timeout_ms: 2_147_483_648 }),
);
});
test("error after successful call preserves original Evidence reference", async () => {
const result = await bridge.execute({
code: `await tools.analyze_javascript_application(${JSON.stringify(analysisArgs)}); throw new Error('after-call');`,
});
assert.match(result.bridge_error.message, /after-call/);
assert.ok(result.calls[0].evidence_id);
assert.ok(result.calls[0].evidence_links.length > 0);
const readback = await upstream.call("get_evidence_bundle", {
detail: "summary",
});
assert.equal(readback.isError, undefined);
assert.ok(
JSON.stringify(json(readback)).includes(result.calls[0].evidence_id),
);
for (const evidence_id of result.calls[0].evidence_links) {
const view = json(
await upstream.call("inspect_analysis_view", {
source: { kind: "retained-evidence", evidence_id },
view: { kind: "summary" },
}),
);
assert.equal(view.normalized_result.parent_evidence_id, evidence_id);
}
});
test("provider timeout retains its actual partial Evidence reference", async () => {
const result = await bridge.execute({
code: `const reply = await tools.analyze_javascript_application(${JSON.stringify({ ...analysisArgs, analysis_timeout_ms: 1 })}); return json(reply);`,
});
const partial = result.value.error.details.partial_observation;
assert.equal(partial.kind, "retained-evidence");
assert.equal(result.calls[0].is_error, true);
assert.equal(result.calls[0].partial_evidence_id, partial.evidence_id);
const view = json(
await upstream.call("inspect_analysis_view", {
source: partial,
view: { kind: "summary" },
}),
);
assert.equal(view.normalized_result.parent_evidence_id, partial.evidence_id);
});
test("cancelling queued calls releases deferred handles and permits reuse", async () => {
let callStarted;
const started = new Promise((resolve) => {
callStarted = resolve;
});
const cancelled = new AbortController();
const controlled = new CodeModeBridge({
catalog: upstream.catalog,
async call(name, args, options) {
const reply = await upstream.call(name, args, options);
callStarted();
// A controlled delivery delay after a real result makes the queued
// cancellation deterministic, without simulating provider behavior.
await new Promise((resolve) => setTimeout(resolve, 50));
return reply;
},
});
const execution = controlled.execute(
{
code: "return await Promise.all([tools.binary_session({}), tools.binary_session({})]);",
},
{ signal: cancelled.signal },
);
await started;
cancelled.abort(new Error("controlled queued cancellation"));
const result = await execution;
assert.ok(result.bridge_error);
assert.equal(result.calls.length, 2);
assert.match(
result.calls[1].transport_error,
/controlled queued cancellation/,
);
assert.equal((await controlled.execute({ code: "return 42;" })).value, 42);
});
test("a guest promise without any producer fails without hanging", async () => {
const result = await bridge.execute({
code: "return await new Promise(() => {});",
});
assert.match(result.bridge_error.message, /cannot progress/);
});
test("bridge's two tools are usable through actual downstream stdio MCP", async () => {
const transport = new StdioClientTransport({
command: process.execPath,
args: [
fileURLToPath(new URL("./bridge.mjs", import.meta.url)),
process.execPath,
entrypoint,
"mcp",
],
env: { ...process.env, REA_LOG_LEVEL: "silent" },
stderr: "inherit",
});
const client = new Client({ name: "codemode-boundary-test", version: "1" });
try {
await client.connect(transport);
const catalog = await client.listTools();
assert.deepEqual(
catalog.tools.map((tool) => tool.name),
["rea_search", "rea_execute"],
);
const ajv = new Ajv2020({ strict: true });
const byName = new Map(catalog.tools.map((tool) => [tool.name, tool]));
for (const tool of catalog.tools) {
assert.equal(
tool.inputSchema.$schema ??
"https://json-schema.org/draft/2020-12/schema",
"https://json-schema.org/draft/2020-12/schema",
);
assert.equal(
ajv.validateSchema(tool.inputSchema),
true,
ajv.errorsText(),
);
}
const validate = ajv.compile(byName.get("rea_execute").inputSchema);
assert.equal(
validate({ code: "return 1;", timeout_ms: 2_147_483_647 }),
true,
);
assert.equal(
validate({ code: "return 1;", timeout_ms: 2_147_483_648 }),
false,
);
assert.equal(
validate({ code: "return 1;", memory_bytes: 128 * 1024 * 1024 + 1 }),
false,
);
const found = json(
await client.callTool({
name: "rea_search",
arguments: { names: ["binary_session"] },
}),
);
assert.equal(found.matched_tools, 1);
const result = json(
await client.callTool({
name: "rea_execute",
arguments: {
code: "return json(await tools.binary_session({}));",
},
}),
);
assert.equal(result.value.result.open, false);
const invalid = await client.callTool({
name: "rea_execute",
arguments: { code: 7 },
});
assert.equal(invalid.isError, true);
const oversized = await client.callTool({
name: "rea_execute",
arguments: { code: "return 1;", timeout_ms: 2_147_483_648 },
});
assert.equal(oversized.isError, true);
const oversizedMemory = await client.callTool({
name: "rea_execute",
arguments: { code: "return 1;", memory_bytes: 128 * 1024 * 1024 + 1 },
});
assert.equal(oversizedMemory.isError, true);
} finally {
await client.close();
}
});
+90
View File
@@ -0,0 +1,90 @@
{
"schema_version": 1,
"artifacts": [
{
"id": "sharex.dll",
"file": "ShareX.dll",
"bytes": 2162688,
"sha256": "191a191be964e434daf0f9d76d1e0d8ddce90d7e248cba2a6b5ac9577f288d53",
"provenance": {
"project": "ShareX",
"version": "19.0.2",
"upstreamFile": "ShareX-19.0.2-portable.zip",
"url": "https://github.com/ShareX/ShareX/releases/download/v19.0.2/ShareX-19.0.2-portable.zip",
"transport_sha256": "967b5d838df5ce25fb5fd7cbd16f1bd797427e2df16907b022b74a4bc0fb9d54",
"transport_bytes": 168796487,
"derivation": "selected regular ZIP member ShareX.dll"
}
},
{
"id": "sqlite.wasm",
"file": "sqlite3.wasm",
"bytes": 868907,
"sha256": "2ee8f3dab694532afc8840e07703127287662d08b74e6ff50491ce63f00d5752",
"provenance": {
"project": "SQLite Wasm",
"version": "3.53.4-build1",
"upstreamFile": "sqlite-wasm-3.53.4-build1.tgz",
"url": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.53.4-build1.tgz",
"transport_sha256": "24f46db4ce5248fa8f8f24b67e81909ab1a9c152f42a4796a32c6d385a6fb62b",
"transport_bytes": 977616,
"transport_integrity": "sha512-U8pvL0patYHMgieD8JxxYJTlh9m1LUX8+BDYb7MiKQzBI89f2qbdmdcG/PvnPaLm9wsBbv4VlVG453ixnxBOnA==",
"derivation": "selected regular tar member package/dist/sqlite3.wasm"
}
},
{
"id": "obsidian.asar",
"file": "obsidian-1.14.4.asar",
"bytes": 27477966,
"sha256": "146ef8470d8cbb4a6db209bdc19bf2bad13350444186c0fd93c31087b142b92f",
"provenance": {
"project": "Obsidian",
"version": "1.14.4",
"upstreamFile": "obsidian-1.14.4.asar",
"transport": {
"file": "obsidian-1.14.4.asar.gz",
"url": "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.14.4/obsidian-1.14.4.asar.gz",
"sha256": "d1ed428c363968774f0f3906e67d8a53a058ece0b6cdd924b07865977b2ada21",
"bytes": 9200670
},
"derivation": "gzip decompression"
}
},
{
"id": "newpipe.apk",
"file": "NewPipe_v0.29.1.apk",
"bytes": 11507122,
"sha256": "18447bfb1e06d113edc88df93f471827280de06f6f3d4dc42f56f28b9c1bab79",
"provenance": {
"project": "NewPipe",
"version": "0.29.1",
"upstreamFile": "NewPipe_v0.29.1.apk",
"url": "https://github.com/TeamNewPipe/NewPipe/releases/download/v0.29.1/NewPipe_v0.29.1.apk"
}
},
{
"id": "jq",
"file": "jq-linux-amd64",
"bytes": 2267912,
"sha256": "b1c22172dd303f3be49e935aa56aa48a8b7a46e0bc838b4997d3bb451495870f",
"provenance": {
"project": "jq",
"version": "1.8.2",
"upstreamFile": "jq-linux-amd64",
"url": "https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-amd64"
}
},
{
"id": "openwrt.bin",
"file": "openwrt-25.12.5-ath79-generic-tplink_archer-c7-v5-squashfs-sysupgrade.bin",
"bytes": 7405862,
"sha256": "f15b16b36df7fce8a5cf1302320fdb428c3bb6fbc2949a4858afa257f4f364a2",
"provenance": {
"project": "OpenWrt Archer C7 v5",
"version": "25.12.5",
"upstreamFile": "openwrt-25.12.5-ath79-generic-tplink_archer-c7-v5-squashfs-sysupgrade.bin",
"url": "https://downloads.openwrt.org/releases/25.12.5/targets/ath79/generic/openwrt-25.12.5-ath79-generic-tplink_archer-c7-v5-squashfs-sysupgrade.bin"
}
}
]
}
+87
View File
@@ -0,0 +1,87 @@
# Decision from the frozen Code Mode experiment
Keep REA's existing CLI/MCP contracts as the default. Improve Evidence-aware
workflow guidance and retain this two-tool bridge as an optional experiment.
The measured Codex profiles do not justify a broad API refactor or a default
switch to the external executor.
## What supports that choice
The [serial cohort](agent-results.json) contains sixteen real Codex CLI trials,
configured with `gpt-5.6-terra` high, across Android, managed PE/CLI, Electron ASAR
inventory, firmware and native Ghidra analysis. Twelve pass the strict requested
fact/reference checks. Two bridge managed answers omit the classification's
container field; two normal-MCP managed transcripts truncate a large producer
envelope, preventing complete-envelope verification of one cited ID. Their
remaining requested facts match the real-provider oracle. The complete-container
assertion is stronger than the question's general classification wording.
The bridge's Android repetitions take 48.231 and 134.555 seconds, compared with
67.329 and 71.624 for normal MCP. The faster bridge trial composes three original
operations once; the slower one performs seven original calls across five scripts.
The faster trial uses typed discovery; this does not make the model reliably
choose that workflow. Uncached input is lower in both bridge repetitions;
output and latency vary. This is not a stable overall efficiency win.
Managed bridge latency also varies, and its two answers omit the same field.
Firmware's one-operation question takes 81.944 seconds with the bridge versus
30.161 directly. Ghidra takes 334.642 versus 327.150 seconds, with sampled aggregate
CPU times of 271.096 and 263.738 seconds. The bridge performs three original
operations versus four directly, deriving containing identity from the analyzed
procedure. Native analysis cost remains dominant with unchanged default settings.
Obsidian inventory exposes a useful contract boundary: nested Evidence types leave
their normalized payload generic. The model initially returns the whole inventory
and repeats analysis. Giving both profiles the concrete manifest/occurrences
layout yields a single focused bridge workflow: 101994 total input tokens versus
263484 directly, but 40554 versus 41532 uncached tokens and 85.909 versus 67.540
seconds. Clear producer/layout guidance matters; total context compression alone
does not establish lower cost or latency. Cache pricing is not estimated here.
Deterministic replays demonstrate large projection savings across real providers.
They measure a known script, not the model's ability to discover and write it.
SQLite WASM fails the frozen WABT parser on an unpadded DataCount row; Obsidian's
full AST analysis times out with a retained partial reference. Inventory does not
replace AST analysis. Neither failure is counted as a Code Mode success.
## Migration scope
Current users retain original operation names, arguments, provider choices,
Evidence and session behavior. A client with equivalent execution support can use
the existing registration and focused workflows. The installed Codex transcript
does not expose its executor source, so its exact internal composition is unknown.
For clients that need the bridge, use a separate opt-in profile for an investigation.
The bridge owns one original REA connection and looks up live contracts by name.
Its session and Evidence ledger are separate from another REA registration; do
not mix target lifecycle calls or same-session IDs across those registrations.
Derived TypeScript assists code authoring; original JSON schemas remain available.
Original producer IDs, links, errors and partial-reference IDs survive auditing;
caller projections do not become new Evidence records.
The outer execution tool combines original effects and client requirements.
This prototype has not forwarded roots/elicitation/sampling or preserved a client's
per-original-operation approval flow. That capability boundary must be addressed
before offering it as a production replacement. The guest's lack of host IO does
not remove effects reachable through original REA tools.
An additive producer-description improvement explaining nested payload layout is
a smaller next candidate than changing names or inventing another workflow API.
Original inputs and output defaults should remain intact. Provider analysis
settings must be evaluated separately from discovery and projection improvements.
## Verification limits
These are descriptive samples with matching questions/provider settings per pair,
mode-specific instructions and model-selected arguments. They do not provide
confidence intervals, independent decompiler truth, Android/.NET runtime behavior,
full native-function coverage, complete firmware reconstruction or Windows/IDA
provider verification. Citations are checked against observed producer values and
links, not resolved individually after session exit.
Sixteen trials finish without sampled memory/task-limit events or resource aborts.
Their maximum sampled memory is 1659744256 bytes (about 1.55 GiB), with at most
126 tasks, under one CPU and a 4 GiB hard ceiling/3 GiB early stop. Copied profiles
are removed. Twelve actual stdio tests additionally cover cancellation, partial
Evidence readback, guest allocation failure/recovery, and advertised schema
validation. The earlier 2 GiB build-scope kill remains a documented failed build.
+249
View File
@@ -0,0 +1,249 @@
"""Check requested JSON facts and real Evidence references against a replay oracle."""
import argparse
import hashlib
import json
from pathlib import Path
def required_field(row, key):
return row[key] if key in row else {'missing_field': key}
def same_fact(actual, expected):
if isinstance(actual, bool) or isinstance(expected, bool):
return type(actual) is type(expected) and actual == expected
if isinstance(expected, dict):
return isinstance(actual, dict) and actual.keys() == expected.keys() and all(
same_fact(actual[key], value) for key, value in expected.items())
if isinstance(expected, list):
return isinstance(actual, list) and len(actual) == len(expected) and all(
same_fact(a, b) for a, b in zip(actual, expected))
return actual == expected
def evidence_ids(value):
if isinstance(value, str):
return {value} if value.startswith('ev_') and len(value) == 67 else set()
if isinstance(value, dict):
return set().union(*(evidence_ids(v) for v in value.values()))
if isinstance(value, list):
return set().union(*(evidence_ids(v) for v in value))
return set()
def read_answer(path):
source = path.read_text().strip()
lines = source.splitlines()
# Accept a single complete JSON fence, never repair prose or partial JSON.
if len(lines) >= 3 and lines[0] == '```json' and lines[-1] == '```':
source = '\n'.join(lines[1:-1])
answer_format = 'markdown_json'
else:
answer_format = 'json'
answer = json.loads(source)
if not isinstance(answer, dict):
raise ValueError('Answer is not a JSON object')
return answer, answer_format
def requested_facts(value, task):
if task == 'native':
facts = {field: value.get(field) for field in [
'artifact_sha256', 'entry_address', 'containing_procedure',
'procedure', 'pseudocode_prefix', 'caller_count', 'callee_count']}
containing = facts['containing_procedure']
if isinstance(containing, dict) and containing.get('found', True) is True and \
containing.get('query_address', facts['entry_address']) == facts['entry_address']:
identity = containing.get('procedure', containing)
if isinstance(identity, dict):
facts['containing_procedure'] = {key: identity.get(key) for key in ['address', 'name']}
return facts
if task == 'electron-inventory':
facts = {field: value.get(field) for field in [
'artifact_sha256', 'manifest', 'entry_kind_counts', 'requested_paths',
'integrity_contradictions', 'coverage', 'unexplored_branches']}
paths = facts['requested_paths']
if isinstance(paths, dict) and set(paths) == {'package.json', 'main.js', 'preload.js'}:
if all(isinstance(rows, list) and all(isinstance(row, dict) and
row.get('logical_path') == name for row in rows)
for name, rows in paths.items()):
paths = [row for rows in paths.values() for row in rows]
if isinstance(paths, list) and all(isinstance(row, dict) and
isinstance(row.get('logical_path'), str) for row in paths):
paths = sorted(paths, key=lambda row: row['logical_path'])
facts['requested_paths'] = paths
contradictions = facts['integrity_contradictions']
if isinstance(contradictions, dict) and set(contradictions) == {'inspection', 'inventory'}:
if all(rows == [] for rows in contradictions.values()):
facts['integrity_contradictions'] = []
branches = facts['unexplored_branches']
if isinstance(branches, list) and all(isinstance(row, dict) for row in branches):
# Branch identity includes the source Evidence identity. Compare its
# reported meaning here and verify its actual source reference below.
facts['unexplored_branches'] = [{key: row.get(key) for key in [
'reason', 'detail', 'next_probe']} for row in branches]
return facts
if task == 'firmware':
result = value.get('result')
if not isinstance(result, dict):
result = {}
engine = result.get('engine', result.get('provider'))
if isinstance(engine, dict):
engine = {'version': engine.get('version'),
'executable_sha256': engine.get('executable_sha256',
engine.get('engine_artifact_sha256'))}
regions = result.get('regions')
if isinstance(regions, list) and all(isinstance(row, dict) for row in regions):
# Binwalk's UUID is run-local; preserve it in the answer but do not
# compare it with the independent replay's different occurrence ID.
selected_regions = []
for row in regions:
selected = {key: row.get(key) for key in [
'offset', 'signature', 'description', 'reported_confidence']}
if 'reported_size' in row:
size = row['reported_size']
elif 'reported_extent_bytes' in row:
size = row['reported_extent_bytes']
else:
extent = row.get('reported_extent')
size = None
if isinstance(extent, dict) and extent.get('offset') == row.get('offset'):
length = extent.get('length')
offset = row.get('offset')
if isinstance(length, int) and isinstance(offset, int) and \
extent.get('end_exclusive') == offset + length:
size = length
selected['reported_size'] = size
selected_regions.append(selected)
regions = selected_regions
return {'artifact_sha256': value.get('artifact_sha256'),
'engine': engine, 'input_size': result.get('input_size', result.get('input_size_bytes')),
'regions': regions, 'coverage': result.get('coverage', result.get('examined_coverage'))}
if task == 'managed':
def selected(field, keys):
row = value.get(field)
return {key: required_field(row, key) for key in keys} if isinstance(row, dict) else row
coverage = value.get('coverage')
if isinstance(coverage, dict):
coverage = {'managed_artifact': coverage.get('managed_artifact'),
'native_boundaries': coverage.get('native_boundaries',
coverage.get('managed_native_boundaries'))}
coverage = {key: {field: row.get(field) for field in ['state', 'issues']}
if isinstance(row, dict) else row
for key, row in coverage.items() if key in ['managed_artifact', 'native_boundaries']}
return {
'artifact_sha256': value.get('artifact_sha256'),
'assembly': selected('assembly', ['name', 'version']),
'module': selected('module', ['name', 'mvid']),
'classification': value.get('classification'),
'target_frameworks': value.get('target_frameworks'),
'native_boundaries': selected('native_boundaries', ['module_refs', 'pinvoke_imports']),
'coverage': coverage,
}
facts = {field: value.get(field) for field in [
'artifact_sha256', 'package_name', 'version_name', 'version_code', 'matches', 'onCreate']}
methods = facts['onCreate']
if isinstance(methods, list) and all(isinstance(row, dict) for row in methods):
facts['onCreate'] = [{key: required_field(row, key) for key in [
'reported_signature', 'overload_index', 'dex_descriptor']} for row in methods]
return facts
def producer_ids(reply):
if not isinstance(reply, dict):
return set(), 0
ids = evidence_ids(reply.get('evidence_id'))
ids |= evidence_ids(reply.get('evidence_links'))
for call in reply.get('calls', []):
ids |= evidence_ids(call.get('evidence_id'))
ids |= evidence_ids(call.get('evidence_links'))
ids |= evidence_ids(call.get('partial_evidence_id'))
unreadable = 0
# SDK envelopes and Codex JSONL use distinct declared field spellings.
for field in ['structuredContent', 'structured_content']:
nested_ids, nested_unreadable = producer_ids(reply.get(field))
ids |= nested_ids
unreadable += nested_unreadable
for content in reply.get('content', []):
if content.get('type') != 'text':
continue
try:
value = json.loads(content['text'])
except ValueError:
unreadable += 1
continue
nested_ids, nested_unreadable = producer_ids(value)
ids |= nested_ids
unreadable += nested_unreadable
return ids, unreadable
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--trial', type=Path, required=True)
parser.add_argument('--oracle', type=Path, required=True)
parser.add_argument('--task', choices=[
'android', 'managed', 'native', 'firmware', 'electron-inventory'], default='android')
args = parser.parse_args()
oracle = json.loads(args.oracle.read_text())
if oracle.get('failure') or not oracle.get('projection'):
raise SystemExit('A failed replay is not a factual oracle')
projection = oracle['projection']
if args.task == 'managed':
projection = {**projection, 'coverage': {
'managed_artifact': projection['coverage'],
'native_boundaries': projection['native_boundaries']['coverage'],
}}
expected = requested_facts(projection, args.task)
# A task explicitly chooses these assertions; do not grade unrequested fields.
if any(value is None for value in expected.values()):
raise SystemExit('Replay does not contain the selected task facts')
failures = []
answer_format = None
answer_path = args.trial / 'answer.txt'
try:
answer, answer_format = read_answer(answer_path)
except (FileNotFoundError, ValueError) as error:
answer = {}
failures.append({'kind': 'answer_parse_failure', 'reason': str(error)})
actual_facts = requested_facts(answer, args.task)
for field, wanted in expected.items():
actual = actual_facts[field]
if not same_fact(actual, wanted):
failures.append({'kind': 'fact_mismatch', 'field': field,
'expected': wanted, 'actual': actual})
observed = set()
unreadable = 0
for line in (args.trial / 'events.jsonl').read_text().splitlines():
event = json.loads(line)
item = event.get('item', {})
if event.get('type') != 'item.completed' or item.get('type') != 'mcp_tool_call':
continue
# Only producer envelopes and bridge audit IDs establish retention.
ids, skipped = producer_ids(item.get('result') or {})
observed |= ids
unreadable += skipped
cited = evidence_ids(answer.get('evidence_ids'))
if args.task == 'electron-inventory':
for branch in answer.get('unexplored_branches', []):
if isinstance(branch, dict):
cited |= evidence_ids(branch.get('evidence_id'))
if not cited:
failures.append({'kind': 'missing_evidence_references'})
if cited - observed:
failures.append({'kind': 'unobserved_evidence_ids', 'ids': sorted(cited - observed)})
result = {'task': args.task,
'grader_sha256': hashlib.sha256(Path(__file__).read_bytes()).hexdigest(),
'scope': 'producer_fact_parity_and_reference_existence_not_runtime_accuracy',
'passed': not failures, 'fact_assertions': len(expected),
'answer_format': answer_format,
'unreadable_result_texts': unreadable,
'cited_evidence_ids': sorted(cited), 'failures': failures}
(args.trial / 'grade.json').write_text(json.dumps(result, indent=2) + '\n')
print(json.dumps(result))
raise SystemExit(0 if result['passed'] else 1)
if __name__ == '__main__':
main()
+518
View File
@@ -0,0 +1,518 @@
{
"name": "rea-codemode-experiment",
"version": "0.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rea-codemode-experiment",
"version": "0.0.0",
"dependencies": {
"@modelcontextprotocol/client": "2.3.1",
"@modelcontextprotocol/server": "2.3.1",
"js-tiktoken": "1.0.21",
"json-schema-to-typescript": "16.0.0",
"quickjs-emscripten": "0.32.0",
"zod": "4.3.6"
},
"devDependencies": {
"ajv": "8.20.0"
},
"engines": {
"node": "24.18.0"
}
},
"node_modules/@apidevtools/json-schema-ref-parser": {
"version": "11.9.3",
"resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.9.3.tgz",
"integrity": "sha512-60vepv88RwcJtSHrD6MjIL6Ta3SOYbgfnkHb+ppAVK+o9mXprRtulx7VlRl3lN3bbvysAfCS7WMVfhUYemB0IQ==",
"license": "MIT",
"dependencies": {
"@jsdevtools/ono": "^7.1.3",
"@types/json-schema": "^7.0.15",
"js-yaml": "^4.1.0"
},
"engines": {
"node": ">= 16"
},
"funding": {
"url": "https://github.com/sponsors/philsturgeon"
}
},
"node_modules/@apidevtools/json-schema-ref-parser/node_modules/js-yaml": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz",
"integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/nodeca"
}
],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/@jitl/quickjs-ffi-types": {
"version": "0.32.0",
"resolved": "https://registry.npmjs.org/@jitl/quickjs-ffi-types/-/quickjs-ffi-types-0.32.0.tgz",
"integrity": "sha512-v9T+GQpmk43VDJ7d72sf0Nexhk+ArvtUihW27dy7lqAl0zBObFKtSBBIm5RBjwIhE8VwsPPm9PNuvPvNqLWUEg==",
"license": "MIT"
},
"node_modules/@jitl/quickjs-wasmfile-debug-asyncify": {
"version": "0.32.0",
"resolved": "https://registry.npmjs.org/@jitl/quickjs-wasmfile-debug-asyncify/-/quickjs-wasmfile-debug-asyncify-0.32.0.tgz",
"integrity": "sha512-EX8zbXwGqCgAE764M+qvkHtyXDi/FUoMBea0JnES7vCM3P7a2+EOZOjGv85wtZ2sJhI1oJ+nekmqpOODFDY+hw==",
"license": "MIT",
"dependencies": {
"@jitl/quickjs-ffi-types": "0.32.0"
}
},
"node_modules/@jitl/quickjs-wasmfile-debug-sync": {
"version": "0.32.0",
"resolved": "https://registry.npmjs.org/@jitl/quickjs-wasmfile-debug-sync/-/quickjs-wasmfile-debug-sync-0.32.0.tgz",
"integrity": "sha512-LeYWrPGC1uNCTBWvibo3ZLJj0CSVNYUXvJpXMCmuQ5Sap2cCACc3uvGvYV4homHHBAzfw5akoTqMMS4YFRtw+Q==",
"license": "MIT",
"dependencies": {
"@jitl/quickjs-ffi-types": "0.32.0"
}
},
"node_modules/@jitl/quickjs-wasmfile-release-asyncify": {
"version": "0.32.0",
"resolved": "https://registry.npmjs.org/@jitl/quickjs-wasmfile-release-asyncify/-/quickjs-wasmfile-release-asyncify-0.32.0.tgz",
"integrity": "sha512-3oSwPfja12ICz4aIblB58cuY8JlEq5Txt8Cut4VLo+LH47QN+mzCnSgnbB03hWzg1LBcc+VyyI9UOag7a1NF+Q==",
"license": "MIT",
"dependencies": {
"@jitl/quickjs-ffi-types": "0.32.0"
}
},
"node_modules/@jitl/quickjs-wasmfile-release-sync": {
"version": "0.32.0",
"resolved": "https://registry.npmjs.org/@jitl/quickjs-wasmfile-release-sync/-/quickjs-wasmfile-release-sync-0.32.0.tgz",
"integrity": "sha512-BKNDI/TPBfGlLNGYpLrhcDGXmIk4xHm4MRAisOBnOzpXVn9HZWsfmMAc9WMBrAHjvvds6HOikKeaOBKdPdpVrg==",
"license": "MIT",
"dependencies": {
"@jitl/quickjs-ffi-types": "0.32.0"
}
},
"node_modules/@jsdevtools/ono": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz",
"integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==",
"license": "MIT"
},
"node_modules/@modelcontextprotocol/client": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.3.1.tgz",
"integrity": "sha512-mIGZXpHsjnZ6lD+gD/WCMpR5k8yVQQ8nNFH1N0Srf7AvnwTUMYD6pvTY8ng2+He5FfV7YMZLmrjL7cLa/cc3dQ==",
"license": "Apache-2.0",
"dependencies": {
"@modelcontextprotocol/core": "2.3.1",
"cross-spawn": "^7.0.5",
"eventsource": "^3.0.2",
"eventsource-parser": "^3.0.8",
"jose": "^6.1.3",
"pkce-challenge": "^5.0.0",
"zod": "^4.2.0"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@modelcontextprotocol/core": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.3.1.tgz",
"integrity": "sha512-laVmIhPGpWi7rG9q+0UigblRN0Hws/Yjlb6qLFtVqryXVLkc4h+yN8z731POD2LnAGQlFe7/tXhUm7Bi0YB91g==",
"license": "Apache-2.0",
"dependencies": {
"zod": "^4.2.0"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@modelcontextprotocol/server": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.3.1.tgz",
"integrity": "sha512-e59MfWuSssj6DoQ96JCTqdW1AXT5/XtnTl0WWd6MU1Ka434fFUGGosCLJbGNySDhHGvxQWoRWK137FXYFkYNWw==",
"license": "Apache-2.0",
"dependencies": {
"@modelcontextprotocol/core": "2.3.1",
"zod": "^4.2.0"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@types/json-schema": {
"version": "7.0.15",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"license": "MIT"
},
"node_modules/@types/lodash": {
"version": "4.17.26",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.26.tgz",
"integrity": "sha512-48NWfiY6oNcKOh47Z4h+sIvwcQR91h6KPhaYKgeMIrkT2jV82Gy90SErj60vW8jQbeMSOSbhIv3bZ7JoqPPVhA==",
"license": "MIT"
},
"node_modules/ajv": {
"version": "8.20.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
"integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
"dev": true,
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"license": "Python-2.0"
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"license": "MIT",
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/eventsource": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz",
"integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==",
"license": "MIT",
"dependencies": {
"eventsource-parser": "^3.0.1"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/eventsource-parser": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.1.tgz",
"integrity": "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==",
"license": "MIT",
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true,
"license": "MIT"
},
"node_modules/fast-uri": {
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz",
"integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "BSD-3-Clause"
},
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"picomatch": "^3 || ^4"
},
"peerDependenciesMeta": {
"picomatch": {
"optional": true
}
}
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"license": "ISC"
},
"node_modules/jose": {
"version": "6.2.12",
"resolved": "https://registry.npmjs.org/jose/-/jose-6.2.12.tgz",
"integrity": "sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/panva"
}
},
"node_modules/js-tiktoken": {
"version": "1.0.21",
"resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.21.tgz",
"integrity": "sha512-biOj/6M5qdgx5TKjDnFT1ymSpM5tbd3ylwDtrQvFQSu0Z7bBYko2dF+W/aUkXUPuk6IVpRxk/3Q2sHOzGlS36g==",
"license": "MIT",
"dependencies": {
"base64-js": "^1.5.1"
}
},
"node_modules/js-yaml": {
"version": "5.4.3",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.3.tgz",
"integrity": "sha512-yzzNtgczwgoVHNigCyKTXcQJU4Y8t/ikU4UxXW0BvrLfHTGWZhsNcOT2s/a7vn81/4KqVnNmHjaUEPlvWnNwVw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/nodeca"
}
],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.mjs"
}
},
"node_modules/json-schema-to-typescript": {
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-16.0.0.tgz",
"integrity": "sha512-Ah6kK4q6SjlMzWBH1eNOQkdRh5Qhr5T/RCFwfjQqWZA7UDW+N47A8wfyoiN0L884s4L4bAEI54IjIuN3/u0B/A==",
"license": "MIT",
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^11.9.3",
"@types/json-schema": "^7.0.15",
"@types/lodash": "^4.17.25",
"js-yaml": "^5.2.3",
"lodash": "^4.18.1",
"minimist": "^1.2.8",
"prettier": "^3.9.6",
"tinyglobby": "^0.2.17"
},
"bin": {
"json2ts": "dist/src/cli.js"
},
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"dev": true,
"license": "MIT"
},
"node_modules/lodash": {
"version": "4.18.1",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
"integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==",
"license": "MIT"
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/picomatch": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/pkce-challenge": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz",
"integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==",
"license": "MIT",
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/prettier": {
"version": "3.9.10",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.10.tgz",
"integrity": "sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==",
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/quickjs-emscripten": {
"version": "0.32.0",
"resolved": "https://registry.npmjs.org/quickjs-emscripten/-/quickjs-emscripten-0.32.0.tgz",
"integrity": "sha512-So0Sqw869y/S2oE3Nuc0uT3Dhqgvsj8FSrwBdsuTosVsG8ME5/OcudU1GxsrIFdFABgy17GHnTVO9TYV/bLQcA==",
"license": "MIT",
"dependencies": {
"@jitl/quickjs-wasmfile-debug-asyncify": "0.32.0",
"@jitl/quickjs-wasmfile-debug-sync": "0.32.0",
"@jitl/quickjs-wasmfile-release-asyncify": "0.32.0",
"@jitl/quickjs-wasmfile-release-sync": "0.32.0",
"quickjs-emscripten-core": "0.32.0"
},
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/quickjs-emscripten-core": {
"version": "0.32.0",
"resolved": "https://registry.npmjs.org/quickjs-emscripten-core/-/quickjs-emscripten-core-0.32.0.tgz",
"integrity": "sha512-QFnPfjFey8EqknSrSxe1hZrf1/8z7/6s1QzGOmKo6++02r7QRRX7ZoyNaZh7JuVjWsVW87KnQrbZqnHkOAzUyg==",
"license": "MIT",
"dependencies": {
"@jitl/quickjs-ffi-types": "0.32.0"
}
},
"node_modules/require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"license": "MIT",
"dependencies": {
"shebang-regex": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/tinyglobby": {
"version": "0.2.17",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
"integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
"license": "MIT",
"dependencies": {
"fdir": "^6.5.0",
"picomatch": "^4.0.4"
},
"engines": {
"node": ">=12.0.0"
},
"funding": {
"url": "https://github.com/sponsors/SuperchupuDev"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/zod": {
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",
"integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
}
}
}
+26
View File
@@ -0,0 +1,26 @@
{
"name": "rea-codemode-experiment",
"version": "0.0.0",
"private": true,
"type": "module",
"engines": {
"node": "24.18.0"
},
"packageManager": "npm@11.16.0",
"scripts": {
"test": "node --test bridge.test.mjs",
"start": "node bridge.mjs",
"bench": "node benchmark.mjs"
},
"dependencies": {
"@modelcontextprotocol/client": "2.3.1",
"@modelcontextprotocol/server": "2.3.1",
"js-tiktoken": "1.0.21",
"json-schema-to-typescript": "16.0.0",
"quickjs-emscripten": "0.32.0",
"zod": "4.3.6"
},
"devDependencies": {
"ajv": "8.20.0"
}
}
@@ -0,0 +1,3 @@
Statically investigate the actual shipped APK at {{artifact_path}} using only the registered REA tools. Report the exact artifact SHA-256, package name, version name/code, every class-name match for the case-sensitive substring MainActivity, and all onCreate method descriptors reported for org.schabi.newpipe.MainActivity. Preserve reported signatures and explicit unknowns. For each onCreate entry include reported_signature, overload_index and dex_descriptor exactly as reported, preserving null. Final answer must be JSON with artifact_sha256, package_name, version_name, version_code, matches, onCreate, evidence_ids, limitations. Include real Evidence IDs supporting each result. Do not execute the APK or use shell, host file tools, network or other agents. Stop once these facts are supported.
When a client JavaScript executor is available, compose the required REA calls in one execution and return only selected facts from normalized_result, real Evidence IDs, target identity from subject.digest.sha256 and limitations. Parse original MCP text content if necessary. Do not return raw_result, whole Evidence or unrelated inventories. All matching classes and onCreate overloads must still be included.
@@ -0,0 +1 @@
Statically inventory {{artifact_path}} using only the registered REA tools. Open this ASAR as an archive, inspect its artifact inventory, and close the session. Report exact target SHA-256, the complete inventory manifest, counts of every entry_kind across all occurrences, the original occurrence records for root paths package.json, main.js and preload.js if present, all integrity contradictions, inspection coverage, unexplored branches, real Evidence IDs and limitations. This question asks about package bytes and inventory, not AST interpretation or runtime behavior. Do not execute target code, analyze all JavaScript, extract files, launch a GUI, use shell/file tools/network or other agents. When a client JavaScript executor is available, compose original calls in dependency order and return only requested fields from normalized_result; the full inventory is the Evidence nested in the inspect_artifact inventory_artifact substep. Use Evidence.subject.digest.sha256 for the target identity and retain both inspection and inventory Evidence IDs. Final JSON fields: artifact_sha256, manifest, entry_kind_counts, requested_paths, integrity_contradictions, coverage, unexplored_branches, evidence_ids, limitations. Stop when these facts and cleanup are supported. Use the original open_binary, inspect_artifact and close_binary operations, with integrity_policy=fail. The inventory Evidence has normalized_result.manifest and normalized_result.occurrences; each occurrence has entry_kind and logical_path. Count the complete occurrences array and filter those three exact root logical_path values. Keep the complete inventory inside the executor when one is available; return the requested projection.
@@ -0,0 +1 @@
Statically inventory {{artifact_path}} using only the registered REA tools. Open this ASAR as an archive, inspect its artifact inventory, and close the session. Report exact target SHA-256, the complete inventory manifest, counts of every entry_kind across all occurrences, the original occurrence records for root paths package.json, main.js and preload.js if present, all integrity contradictions, inspection coverage, unexplored branches, real Evidence IDs and limitations. This question asks about package bytes and inventory, not AST interpretation or runtime behavior. Do not execute target code, analyze all JavaScript, extract files, launch a GUI, use shell/file tools/network or other agents. When a client JavaScript executor is available, compose original calls in dependency order and return only requested fields from normalized_result; the full inventory is the Evidence nested in the inspect_artifact inventory_artifact substep. Use Evidence.subject.digest.sha256 for the target identity and retain both inspection and inventory Evidence IDs. Final JSON fields: artifact_sha256, manifest, entry_kind_counts, requested_paths, integrity_contradictions, coverage, unexplored_branches, evidence_ids, limitations. Stop when these facts and cleanup are supported.
@@ -0,0 +1 @@
Statically inspect {{artifact_path}} using only the registered REA tools. Report exact target SHA-256 and every reported firmware region with offsets, signatures, reported extents, provider provenance and examined coverage. Preserve unknowns and limitations; a signature scan does not prove partition boundaries or boot/runtime validity. Do not execute target code, extract files, launch a GUI, use shell/file tools/network or other agents. When a client JavaScript executor is available, select the requested normalized_result fields, Evidence.subject.digest.sha256 and real Evidence IDs before returning output. Final JSON fields: artifact_sha256, result, evidence_ids, limitations. Stop when the requested facts are supported.
@@ -0,0 +1 @@
Statically inspect {{artifact_path}} using only the registered REA tools. Report exact target SHA-256, assembly name/version, module name/MVID, managed classification and architecture with its evidence, every reported target framework, and all declared native ModuleRef/PInvoke boundaries with coverage and limitations. Do not load or execute the assembly, launch a GUI, use shell/file tools/network or other agents. When a client JavaScript executor is available, compose the required original MCP calls and return only requested normalized_result fields, target identity from subject.digest.sha256 and real Evidence IDs. Do not return whole Evidence, raw_result or unrelated resources/custom-attribute inventories. Preserve dependency order for operations sharing the selected managed target. Final JSON fields: artifact_sha256, assembly, module, classification, target_frameworks, native_boundaries, coverage, evidence_ids, limitations. Stop when these facts are supported.
@@ -0,0 +1 @@
Statically inspect {{artifact_path}} using only the registered REA tools and Ghidra. The pinned ELF header was independently observed to report entry address 0x403a50; treat that address as the analyst's seed, not as a function-name assumption. Keep default auto-analysis enabled and allow at least 600 seconds for native analysis (including the script deadline if using a bridge). Open the target with provider_id ghidra, resolve the containing procedure for that address, analyze it, and close the ephemeral session in a finally block or a subsequent cleanup call. Report exact target SHA-256, the entry_address, containing_procedure, procedure metadata, the first 512 UTF-16 units of pseudocode, caller_count, callee_count, real Evidence IDs and limitations. Do not execute target code, launch a GUI, use shell/file tools/network or other agents. When a client JavaScript executor is available, compose the original calls in dependency order and select requested fields before returning output; use Evidence.subject.digest.sha256 for the target identity. Final JSON fields: artifact_sha256, entry_address, containing_procedure, procedure, pseudocode_prefix, caller_count, callee_count, evidence_ids, limitations. The address seed applies only to the pinned jq artifact in corpus.json. Stop when these facts and cleanup are supported.
+127
View File
@@ -0,0 +1,127 @@
"""Run one owned experiment in a bounded, transient Linux systemd scope."""
import json
import os
from pathlib import Path
import subprocess
import sys
import time
import uuid
def available_bytes():
for line in Path('/proc/meminfo').read_text().splitlines():
if line.startswith('MemAvailable:'):
return int(line.split()[1]) * 1024
raise RuntimeError('MemAvailable unavailable')
def scope_has_processes(group):
if group is None:
return False
try:
return bool((group / 'cgroup.procs').read_text().strip())
except FileNotFoundError:
return False
def stop_owned_scope(unit, process, group):
subprocess.run(['systemctl', '--user', 'stop', '--no-block', unit],
check=False, timeout=5)
for attempt in range(2):
deadline = time.monotonic() + 10
while process.poll() is None or scope_has_processes(group):
if time.monotonic() >= deadline:
break
time.sleep(0.1)
else:
return
if attempt == 1:
raise RuntimeError('Cleanup unverified; retain owned scope ' + unit)
subprocess.run(['systemctl', '--user', 'kill', '--kill-who=all',
'--signal=SIGKILL', unit], check=False, timeout=5)
def main():
args = sys.argv[1:]
if args and args[0] == '--':
args = args[1:]
if not args:
raise SystemExit('Usage: resource-run.py -- COMMAND ARGS...')
gib = 1024 ** 3
if available_bytes() < 8 * gib:
raise SystemExit('Refusing experiment: less than 8 GiB available')
unit = 'rea-codemode-' + uuid.uuid4().hex + '.scope'
cpu = max(os.sched_getaffinity(0))
command = [
'systemd-run', '--user', '--scope', '--unit=' + unit,
'-p', 'MemoryMax=4G', '-p', 'MemoryHigh=3G', '-p', 'MemorySwapMax=0',
'-p', 'CPUQuota=100%', '-p', 'TasksMax=192',
'taskset', '-c', str(cpu), *args,
]
process = subprocess.Popen(command)
peak = 0
peak_tasks = 0
events = {}
cpu_stats = {}
abort = None
started = time.monotonic()
try:
group = None
while process.poll() is None:
if group is None:
reply = subprocess.run(
['systemctl', '--user', 'show', unit, '--value',
'--property=ControlGroup'],
capture_output=True, text=True, check=False,
)
path = reply.stdout.strip()
if path:
group = Path('/sys/fs/cgroup') / path.lstrip('/')
current = group / 'memory.current' if group else None
if current and current.exists():
try:
peak = max(peak, int(current.read_text()))
peak_tasks = max(peak_tasks, int((group / 'pids.current').read_text()))
cpu_stats = dict((key, int(value)) for key, value in
(line.split() for line in (group / 'cpu.stat').read_text().splitlines()))
for event_file in ['memory.events', 'pids.events']:
events[event_file] = dict(
(key, int(value)) for key, value in
(line.split() for line in (group / event_file).read_text().splitlines())
)
except FileNotFoundError:
# A completed transient scope can disappear between reads.
pass
if peak > 3 * gib:
abort = 'scope_memory_early_stop'
elif available_bytes() < 4 * gib:
abort = 'host_available_memory_early_stop'
elif events.get('pids.events', {}).get('max', 0):
abort = 'scope_task_limit_observed'
if abort:
stop_owned_scope(unit, process, group)
break
time.sleep(0.1)
code = process.wait()
except BaseException:
stop_owned_scope(unit, process, group)
raise
finally:
if scope_has_processes(group):
stop_owned_scope(unit, process, group)
print(json.dumps({
'resource_scope': unit, 'peak_cgroup_bytes_sampled': peak,
'elapsed_seconds': round(time.monotonic() - started, 3),
'abort': abort, 'hard_memory_bytes': 4 * gib,
'early_stop_bytes': 3 * gib, 'cpu_quota_percent': 100,
'cpu_affinity': [cpu],
'task_ceiling': 192, 'peak_tasks_sampled': peak_tasks,
'resource_events_last_observed': events,
'cpu_stat_last_observed': cpu_stats,
}), file=sys.stderr)
raise SystemExit(125 if abort else code)
if __name__ == '__main__':
main()
+367
View File
@@ -0,0 +1,367 @@
# Preliminary measurements
These are real Codex CLI 0.161.0 trials on the frozen checkout, using
`gpt-5.6-terra`, high reasoning, one CPU and a guarded memory scope. The task
called `binary_session` once and requested open state and server identity. This
is a health probe, not an investigation benchmark. API input tokens are cumulative
across model steps; cached tokens are a subset, not an additional cost.
| Profile | Seconds | Input tokens | Cached input | Output tokens | Outcome |
| ---------------------------------- | ------: | -----------: | -----------: | ------------: | --------------------------------------------------------------- |
| Direct MCP | 47.635 | 103154 | 70656 | 940 | Correct closed state; identity omitted after preview truncation |
| Client Code Mode flag | 67.345 | 197315 | 157696 | 1458 | Correct closed state; extra failed resource lookup |
| Client Code Mode only flag | 54.276 | 126609 | 84992 | 939 | Correct closed state; identity omitted |
| Bridge, original prompt | 300.173 | unavailable | unavailable | unavailable | Timeout before any completed tool call |
| Bridge, explicit projection prompt | 84.790 | 209248 | 175616 | 2125 | Correct closed state/version; conflated catalog identities |
These prompts and flags do not establish a controlled comparison. The projection
trial used a more explicit prompt. The client trials expose nested original MCP
calls in their transcripts; the flags alone do not establish code composition or
intermediate-result filtering. The timeout is retained as a failed trial without
an attributed root cause.
The direct tool delivered the original session result, including package version
6.4.0 and REA's catalog digests. In the bridge projection trial the script selected
the nonexistent `server_identity.catalog.digest`, which JavaScript omitted. The
answer instead used the bridge's SDK catalog hash. That is not the requested REA
identity and must fail that factual check. No unsupported digest is used as an
oracle for subsequent trials.
Discovery was unnecessarily returning entire output schemas. For example, the
live `binary_session` output schema occupies 18039 compact JSON bytes, compared
with 859 for its input schema. `analyze_javascript_application` uses 41662 and
2863 bytes respectively. The complete SDK catalog contains 172 tools and 1986857
compact JSON bytes. The bridge now defaults to input schemas and makes unchanged
output schemas available explicitly. Actual model savings from this change remain
unmeasured.
The upstream/downstream stdio boundary suite passed all nine tests. The repository
typecheck and lint passed under a one-CPU resource scope with a sampled peak of
2934038528 bytes. A 2 GiB soft limit caused heavy reclaim during native TypeScript
checking; the wrapper's soft limit is now aligned with its 3 GiB early-stop
threshold. Its 4 GiB hard ceiling and host-available-memory checks remain in force.
An earlier cached-build attempt was killed inside its 2 GiB scope; that is a
failed build attempt, not evidence of a host OOM or a benchmark result.
## Real shipped artifacts
All acquired bytes match `corpus.json`; ShareX's archive also matches the GitHub
asset digest and SQLite's npm archive matches its published SHA-512 integrity.
No target was executed. These measurements use real REA providers and SDK stdio,
with the same analysis arguments in each compared profile.
NewPipe's direct, discovery-only replay and bridge replay produce equal selected
facts, including exact target digest, package/version, two MainActivity matches,
reported `onCreate` signature, overload index and unavailable DEX descriptor. The
bridge retains all three real producer IDs. Discovery-only here is a replay cost
decomposition, not an implemented new MCP client protocol.
| Replay delivery | Discovery estimate | Intermediate/final result estimate |
| -------------------------------------------------- | -----------------: | ---------------------------------: |
| Direct: input definitions only, text content once | 107076 | 94945 |
| On-demand input definitions, original text content | 877 | 94945 |
| On-demand definitions, one composed projection | 877 | 1057 |
The bridge also sends 290 estimated tokens of code. Estimates use `cl100k_base`;
they are not Terra API tokens, latency or model task success. The direct baseline
uses input definitions and single text content, avoiding an inflated comparison
against duplicated MCP envelopes or unused output schemas. The full SDK envelope
figures, where useful for local transport, are recorded separately.
ShareX's real PE/CLI metadata and native-boundary workflows agree across direct
and bridge: assembly ShareX 19.0.2.0, modern .NET, x86_64, framework
`.NETCoreApp,Version=v9.0`, declared native boundaries and explicit coverage.
Single text-content estimates are 204766 tokens for the two original results and
4148 for the bridge projection. No .NET runtime behavior was verified.
jq's original trial failed because the stripped shipped executable has no
`jq_compile` symbol. The corrected direct trial uses the observed ELF entry
`0x403a50`, resolves it to Ghidra's `entry` function and analyzes that function.
It succeeds with retained Evidence and a closed ephemeral provider session.
The corrected bridge returns identical selected facts and limitations. Its final
result estimate is 1544 tokens versus 10189 for direct single-text results, plus
1610 for discovery and 267 for code. This small entry function
does not establish large-function or complete native-analysis coverage.
OpenWrt's original direct trial returned `unreadable_output` without the expected
report. Twelve independent bounded Binwalk invocations produced reports. An
observer launcher and a subsequent unchanged real Binwalk bridge trial succeeded,
reporting uImage at offset 0 and SquashFS at 2741985 with `signature_scan` coverage.
The observer is a diagnostic with a different launcher identity, not a benchmark
baseline. The original failure remains unexplained. Subsequent direct and bridge
workflows agree on all region facts and coverage; random upstream region IDs vary
and are preserved. Single-text estimates are 1387 tokens direct and 827 projected,
so this one-operation task provides much less composition benefit than Android.
SQLite's actual WASM fails the frozen REA WABT output parser with `Unrecognized
WABT section row`. WABT 1.0.42 prints the nine-character DataCount label without
leading padding; the owning parser currently requires leading whitespace. No
downstream shim is used, and no successful WASM provider claim is made.
Obsidian's initial real-model analysis ended without Evidence after Codex's host
closed stdout. Its standalone SDK replay returns a real provider timeout with a
retained partial Evidence ID. This was observed before automatic partial-summary
recovery was added, so the transcript retains that reference but does not export
its payload. A source-fixture production-boundary test now verifies that provider
timeout IDs survive auditing and resolve through the retained-evidence view.
Neither failure is a Code Mode speedup.
## Real Android agents
After raising the task ceiling, a direct Terra trial completes in 107.478 seconds
with 348556 API input tokens (292608 cached), 1815 output tokens and five completed
MCP calls. All six strict producer-fact assertions and cited-ID checks pass. Its
sampled peak is 1349251072 bytes and 127 tasks, with zero observed limit events.
A client Code Mode trial passes the same assertions in 183.361 seconds with
414869 input tokens (372480 cached), 3618 output tokens. The transcript must still
be inspected before attributing native composition or filtering to that flag.
The bridge trial before explicit projection guidance takes 84.754 seconds,
292063 input tokens (244992 cached) and 1661 output tokens. It returns whole
Evidence instead of filtering most intermediates. Requested facts and IDs are
supported, but its stronger exact-projection check fails because overload index
was omitted. A clarified question explicitly requires that index in later trials.
The next bridge trial composes three calls and filters their results, but selects
`normalized_result.engine.artifact_sha256` as the target hash. This is the Jadx
bridge JAR identity, not the APK identity. The strict hash check fails. It takes
166.411 seconds and 324417 input tokens (279040 cached), 2362 output tokens.
This confirms a real provenance risk in model-written projections. Trial
instructions now identify `Evidence.subject.digest.sha256` explicitly. This
change has not yet established a reliable repeated model efficiency gain.
The following bridge trial passes all six assertions and cited-ID checks, using
one execution script for all three original operations. It takes 137.966 seconds,
190313 input tokens (156672 cached) and 1695 output tokens. Four discovery calls
precede the script. This is an encouraging token result, but its revised prompt,
instructions and concurrent host workload prevent a controlled speed comparison.
Instructions and prompt digests are now retained without authentication or an
ambient environment snapshot, so future equal-task repetitions can be audited.
The 6.1 sol diagnostic touched the 96-task limit; it is invalid as a comparison
and was interrupted, with its copied profile removed. The wrapper now allows 192
tasks, records task/memory limit events and rejects capacity-limited trials. A
real thread-creation probe hit exactly 192 tasks, was stopped with exit 125 and
retained its limit reason; it used about 12 MiB and caused no memory-limit event.
The nine actual stdio boundary tests pass after discovery changes.
Wall times above include contention on the same pinned CPU during exploratory
work and differing prompts/instructions. They cannot support a controlled speed
ratio. A reproducible efficiency conclusion requires successful equal-task trials
and serial repetitions with the strongest existing-client baseline.
The stronger client trial uses an explicit instruction to compose and project the
existing operations, and passes all six checks: 72.341 seconds, 161370 input
tokens (120576 cached), 1664 output tokens and three completed MCP calls. An
equivalent question with the bridge passes in 115.962 seconds, 321295 input tokens
(283648 cached), 2274 output tokens, five discovery calls and one execution. The
native transcript does not expose executor source, so exact internal composition
is unverified. Nevertheless, this measured client profile is a materially stronger
baseline than the original repeated-call trial. Total input, uncached input,
output and wall time must be considered separately; cached-token differences make
total input an incomplete cost metric.
This reverses the preliminary temptation to equate replay compression with the
best Codex experience. Existing client support with explicit Evidence-aware
recipes may be enough. An optional bridge needs to justify discovery overhead and
remains useful to test for clients without equivalent execution support.
Eleven actual SDK/stdio tests pass, including a controlled delivery delay after a
real upstream result to exercise queued cancellation. Both the delayed call and
its queued successor release deferred guest handles before runtime disposal.
This test does not simulate or establish new provider behavior.
The bridge remains an experiment and has not changed any published REA contract.
## Existing-client and managed follow-up
The same Android v3 question with normal MCP, without the experimental Code Mode
feature flags, passes all six fact assertions and reference checks: 75.117 seconds,
103471 API input tokens (73728 cached), 1538 output tokens and three original MCP
calls. This is the strongest measured Android baseline so far. Its wall time also
includes a short boundary-test overlap, so it is not a controlled latency ratio.
The installed model catalog requests code-mode-only tool delivery; flag settings
and nested MCP events alone cannot establish the internal executor's behavior.
The first real ShareX managed-agent comparison uses the same question with Terra
high and identical provider settings. Normal MCP takes 81.578 seconds, 217573 input
tokens (186368 cached), 2647 output tokens and two original calls. The bridge takes
96.930 seconds, 218089 input tokens (155904 cached), 3247 output tokens, four
searches and two executions. Its first script uses an expression instead of the
required async-body `return`, yielding no projection; it repeats both operations.
Query discovery now defaults to lightweight names/descriptions, while exact-name
discovery supplies input schemas. This run still requested full output schemas
individually and therefore does not establish an efficiency gain from that change.
Both answers match all seven requested managed fact groups, including exact target
SHA-256, assembly/module identities, classification evidence, framework, declared
ModuleRef/PInvoke arrays and coverage. Those empty arrays concern ShareX.dll only.
The bridge passes cited-reference verification. Codex truncated the original
managed-artifact response in its normal-MCP JSONL at roughly one MiB, leaving an
invalid JSON fragment; the automated grader cannot validate that one reference
from a complete producer envelope. Its reference-failure result is retained,
despite the matching ID being visible in the transcript prefix and replay. This
is a verification limitation, not a demonstrated fabricated ID.
The runner now handles SIGTERM so copied trial credentials are removed during a
resource abort. A controlled non-model launcher received owned-scope SIGTERM,
exited 143 and left no trial profile while preserving the dummy source auth file.
This verifies credential cleanup only. The eleven actual stdio tests pass after
the adaptive discovery change, with a sampled peak of 1365106688 bytes, 42 tasks
and zero observed memory/task limit events.
## Serial comparison and package inventory
A serial Android v3 pair, without concurrent provider/build work, passes every
fact and cited-reference check. Normal MCP uses 56.962 seconds, 105861 input
(75776 cached, 30085 uncached), 1106 output tokens and three original calls. The
adaptive-discovery bridge uses 106.134 seconds, 200537 input (175872 cached,
24665 uncached), 2177 output tokens, four searches and one execution. Its smaller
uncached input does not imply lower overall cost: output, cache rates and latency
also matter. It still requests original output schemas and mistakenly searches
for the already exposed bridge executor. Sampled memory peaks are 1333710848 and
1656098816 bytes respectively; neither run touches memory/task limits. One pair
is insufficient for a statistical latency or reliability claim.
A separate Obsidian package-inventory replay succeeds with existing REA tools.
Direct and bridge return byte-for-byte equal selected facts: 397 graph nodes and
occurrences, 369 files, 28 directories, root main.js/package.json occurrences,
no root preload.js, no observed integrity contradiction, complete-within-substeps
coverage and an explicit unexplored JavaScript analysis branch. Both original
Evidence IDs are preserved. Direct/bridge operations take 6.267/6.618 seconds;
original single-text results total 178958 estimated tokens versus a 1404-token
bridge result, 1305 for discovery and 322 for code. These are replay estimates,
not model latency or success. Inventory does not complete the timed-out AST task.
An output-type discovery probe compiles seven real SDK schemas successfully.
Derived TypeScript estimates are 784/719/751 tokens for Android package/search/
class, 1558/1420 for managed artifact/native boundaries, 1264 for artifact inventory
and 2289 for function analysis. Their original JSON schemas use 1666/1480/1576,
3524/2932, 2812 and 5091 respectively. These declarations describe code values;
they do not preserve every JSON Schema validation rule. Exact-name discovery now
includes them without replacing explicitly requested original JSON schemas. Real
model benefit from this addition remains to be tested. The audit also carries
original Evidence links; a real retained-view readback verifies linked IDs rather
than trusting references invented by a projection.
The output-declaration boundary suite first failed its type-name assertion because
the compiler preferred the schema's URN identity as a display name. The derived
compilation now supplies a descriptive title while returning the original schema
unchanged. All eleven tests then pass, including original-link readback, at a
sampled peak of 1399996416 bytes and zero observed limit events. Declarations are
cached per exact tool name for this immutable live-catalog connection; repeated
discovery does not regenerate them. No provider implementation or published
REA API has changed.
## Typed-discovery serial agent checkpoint
All rows below use real Codex CLI 0.161.0, Terra high, the same rendered question
within each pair, and the same provider settings. The bridge/runtime/runner source
fingerprints match commit `22326e819`; model-written original arguments can differ.
Comparisons include required mode-specific instructions and are not a controlled
causal decomposition of inference, caching and provider time.
| Case | Profile | Wall seconds | Input | Cached | Uncached | Output | MCP calls | Fact/reference check |
| ------------------ | ------- | -----------: | -----: | -----: | -------: | -----: | --------: | --------------------------------- |
| android | direct | 67.329 | 107007 | 83712 | 23295 | 1670 | 3 | pass |
| android | bridge | 48.231 | 113256 | 91648 | 21608 | 1456 | 3 | pass |
| managed | bridge | 73.145 | 116974 | 92672 | 24302 | 2065 | 3 | classification field omitted |
| managed | direct | 33.15 | 108096 | 75776 | 32320 | 2315 | 2 | facts match; reference unverified |
| electron-inventory | direct | 89.494 | 266121 | 238848 | 27273 | 3215 | 3 | pass |
| electron-inventory | bridge | 145.577 | 462809 | 407040 | 55769 | 5624 | 8 | pass |
| firmware | bridge | 81.944 | 152886 | 126976 | 25910 | 2192 | 3 | pass |
| firmware | direct | 30.161 | 103224 | 74752 | 28472 | 1761 | 1 | pass |
The managed bridge omits the producer classification container field (`pe`) while
preserving status/runtime/implementation/architecture and all classification
evidence. Its strict complete-classification assertion fails; this is an omission,
not an incorrect architecture claim. Normal MCP matches requested facts but its
large-result JSONL truncation again prevents automated verification of one ID.
The initial grader treated grouped path records, extra known coverage counts and
an empty per-source contradiction object as mismatches. Task-specific comparison
now accepts those lossless report forms. Firmware compares observed offset/length
facts, checks any supplied derived end arithmetically, and verifies engine version
and executable digest. Run-local UUIDs and differently named display fields are
not compared as if they were stable source identity. Original strict grades and
pre-equivalence grades remain outside Git, and new grades include a grader digest.
These report-format comparisons do not add aliases to any REA tool contract.
Obsidian bridge discovery takes six searches and two executions. The first returns
the entire nested inventory; the second repeats it and computes a focused answer.
The live nested Evidence schema describes normalized_result as generic JSON, so
derived types alone cannot teach its concrete manifest/occurrences layout. Its
recursive record walk happens to match this corpus, but format-specific field
selection is the stronger recipe. Both model profiles choose record-and-continue
for integrity; deterministic inventory replays used fail. No contradictions were
observed, and the exact caller-selected arguments are retained.
## Completed serial cohort
The final sixteen-row cohort, raw-event digests, exact runner/bridge/lockfile
fingerprints, prompt/instruction/provider digests and sampled resource stats are
in [agent-results.json](agent-results.json). The requested model configuration is
Terra high. Two managed bridge answers omit the classification container field
under the stronger full-object check; two normal-MCP managed logs have a truncated
producer envelope. The twelve other rows pass requested fact and observed-reference
checks. This is producer parity, not independent runtime truth or a per-fact
citation-association proof. Earlier stricter report-form grades remain retained.
| Trial | Wall seconds | Input | Cached | Uncached | Output | MCP calls | Check |
| ---------------------------------- | -----------: | -----: | -----: | -------: | -----: | --------: | --------------------------------- |
| android-direct-5 | 67.329 | 107007 | 83712 | 23295 | 1670 | 3 | pass |
| android-bridge-7 | 48.231 | 113256 | 91648 | 21608 | 1456 | 3 | pass |
| managed-bridge-2 | 73.145 | 116974 | 92672 | 24302 | 2065 | 3 | classification container omitted |
| managed-direct-2 | 33.150 | 108096 | 75776 | 32320 | 2315 | 2 | facts match; reference unverified |
| electron-inventory-direct-1 | 89.494 | 266121 | 238848 | 27273 | 3215 | 3 | pass |
| electron-inventory-bridge-1 | 145.577 | 462809 | 407040 | 55769 | 5624 | 8 | pass |
| firmware-bridge-1 | 81.944 | 152886 | 126976 | 25910 | 2192 | 3 | pass |
| firmware-direct-1 | 30.161 | 103224 | 74752 | 28472 | 1761 | 1 | pass |
| native-direct-1 | 327.150 | 151343 | 122368 | 28975 | 2458 | 4 | pass |
| native-bridge-1 | 334.642 | 285961 | 245504 | 40457 | 2129 | 4 | pass |
| android-bridge-8 | 134.555 | 159370 | 134400 | 24970 | 3250 | 7 | pass |
| android-direct-6 | 71.624 | 153031 | 117504 | 35527 | 1501 | 3 | pass |
| managed-direct-3 | 75.229 | 108593 | 75776 | 32817 | 2774 | 2 | facts match; reference unverified |
| managed-bridge-3 | 40.609 | 125519 | 96000 | 29519 | 2274 | 3 | classification container omitted |
| electron-inventory-guided-bridge-1 | 85.909 | 101994 | 61440 | 40554 | 2563 | 3 | pass |
| electron-inventory-guided-direct-1 | 67.540 | 263484 | 221952 | 41532 | 2499 | 4 | pass |
Ghidra's aggregate sampled CPU time is 263.738 seconds directly and 271.096 with
the bridge. The bridge uses three original operations versus four directly,
obtaining containing identity from the analyzed procedure. Both close the session
successfully. The native comparison uses the same default analysis settings;
these data do not establish a meaningful native speedup.
The second Android bridge repetition completes seven original calls across five
scripts, without tool errors, before its final composed answer. Its 134.555-second
result reverses the first repetition's latency advantage. The model did not
reliably choose one composed execution even with explicit guidance. Uncached
input is lower in both bridge repetitions, while output and latency vary.
The guided Electron question explicitly names the existing operations and the
nested inventory's manifest/occurrences layout for both profiles. Both pass, with
integrity_policy=fail. The bridge composes open/inspect/close once; the normal-MCP
profile repeats inspect_artifact. The total-input reduction from 263484 to 101994
is large, but uncached input differs by only 978 tokens and bridge latency is
higher. Earlier non-guided profiles are a different question and cannot support
a causal prompt-improvement ratio. Unknown nested payload types remain an observed
contract-discovery problem; caller-selected values and identities are preserved.
All sixteen runs stay below memory/task ceilings, with maximum sampled memory
1659744256 bytes and 126 tasks; no observed memory/task limit event or resource
abort occurs. Copied profile count is zero at completion. Runtime measurements
belong to the recorded source fingerprint at 22326e819; subsequent timer-range
validation and test-only Ajv installation are not new model measurements.
Final boundary verification passes twelve actual SDK/stdio tests. A 2 MiB guest
budget rejects allocation pressure and the next execution succeeds. This is a
guest-budget failure, not an OS OOM or provider behavior claim. A local pinned-Node
probe shows a 2147483648-ms timeout becomes 1 ms; the owning named execution
contract now rejects that range before allocation. After SDK conversion, both
advertised bridge input schemas validate under JSON Schema 2020-12, and the actual
stdio client rejects invalid code, oversized memory and timer values. Sampled
suite memory peaks at 1387433984 bytes, with zero observed memory/task limit events.
See [decision.md](decision.md) for the recommendation: keep current REA contracts,
improve focused Evidence-aware workflow guidance, and retain the bridge as an
opt-in candidate. A broad default switch is not justified by these samples.