feat(evm): add retained interface summary delivery (#2308)
Add opt-in EVM MCP summary delivery and retained/portable function and text views. Keep existing complete defaults, provider arguments and original full Evidence identities and records usable. Require retention before selected analysis; preserve inferred candidates, nulls, diagnostics, provenance and explicit unknowns. Verify old schemas, historical Evidence migration, 64 focused feature checks, 30 affected MCP checks after latest-main rebase, 59 real EVM CLI/MCP cases and six shared-domain artifact workflows. Repeated SDK delivery is smaller; all real model trials and mixed token/time outcomes, limitation failures and resource qualification gaps remain documented without a uniform performance claim. Refs #2016 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent
bb26622670
commit
f76163c246
@@ -15,6 +15,10 @@ Follow-up: [EVM descriptor and real-template controls](evm-descriptor.md) extend
|
||||
the offline corpus with digest-pinned Uniswap runtime templates and an independent
|
||||
published ABI selector oracle, preserving unknown deployment/immutable metadata.
|
||||
|
||||
Follow-up: [EVM interface summary delivery](evm-interface-summary.md) records
|
||||
the opt-in retained view, old-client/Evidence migration checks and repeated SDK
|
||||
and real-model pairs, including mixed token/time results and strict-answer limits.
|
||||
|
||||
The 12 detailed checkpoint receipts were archived byte-for-byte before removal
|
||||
from the final PR tree. The archive `review-receipts-00d51e0fc-20261012` is in the
|
||||
private experiment lab outside the checkout; its `archive-index.json` records
|
||||
|
||||
@@ -24,6 +24,7 @@ const sameSettings = [
|
||||
"artifact",
|
||||
"artifact_sha256",
|
||||
"artifact_sha256_after",
|
||||
"retained_verification",
|
||||
"native_question",
|
||||
"javascript_question",
|
||||
"provider_settings_sha256",
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
# EVM interface delivery and migration checkpoint
|
||||
|
||||
Continues [#2016](https://github.com/morluto/rea/issues/2016) after the static
|
||||
descriptor merged in [#2261](https://github.com/morluto/rea/pull/2261). Opt-in
|
||||
`inspect_evm_interface` MCP `detail: "summary"` returns every inferred interface
|
||||
candidate without bytecode hex or duplicate stdout. Complete Evidence remains
|
||||
retained under its original identity. Delivery bytes fall; the measured model
|
||||
cohort does **not** establish a stable token or task-time improvement.
|
||||
|
||||
## Frozen scope
|
||||
|
||||
Control production is `ad08510a113d7a9b8d92fb1e385757880e469869`; candidate
|
||||
production is `32c7548b9ae5c8cda348653d177b1747127c74ba`. Their compiled file-table
|
||||
SHA-256 values are respectively
|
||||
`f68e85030cb05082520ea9f0d7650298ae316ce7bba59a8942e0cc1318ae9850` and
|
||||
`978b3a014e3b2a1e1c6620364dcd793fa7cb40f19892d44cfb0312739a8c14a3`.
|
||||
The SDK driver SHA-256 is
|
||||
`a95d8d8e9f72c0b2b885c61907ed13054ebf7d1642f6f13b0126163840b1221a`.
|
||||
Driver commit `03bff83e70e09a917341c1fe3ebffbfdc67785c5` fixes only reading the
|
||||
public `get_evidence_bundle.result.records` envelope; production is unchanged.
|
||||
Both runtimes use Node 24.18.0, matching locked dependencies, SDK client/server
|
||||
2.3.1 and unchanged bundled EVMole 0.9.3.
|
||||
|
||||
Inputs are the digest-pinned WETH historical hex carrier and Uniswap v3-core
|
||||
1.0.1 Factory/Pool compiler runtime templates in [corpus.json](corpus.json).
|
||||
Original carrier and decoded-byte identities remain distinct. Templates are
|
||||
not authenticated deployed instances; constructor-dependent values and absent
|
||||
immutable-reference metadata stay unknown. No chain, target execution or
|
||||
signature lookup is introduced.
|
||||
|
||||
## Public SDK pairs
|
||||
|
||||
Two pairs per artifact run serially: complete control then selected candidate,
|
||||
followed by candidate then control. Each starts a fresh MCP process, discovers
|
||||
the catalog and validates the actual named advertised schema. Host caches are
|
||||
not independently controlled. All six fact/settings comparisons pass. Both
|
||||
answer projections omit unrequested hex; original complete replies remain intact.
|
||||
|
||||
| Input | Complete / summary result bytes | Reduction | Control seconds, 1 / 2 | Candidate seconds, 1 / 2 |
|
||||
| ------- | ------------------------------: | --------: | ---------------------: | -----------------------: |
|
||||
| Factory | 110,424 / 14,442 | 86.92% | 3.670 / 3.766 | 3.664 / 3.867 |
|
||||
| Pool | 110,998 / 19,922 | 82.05% | 4.110 / 3.740 | 3.977 / 3.870 |
|
||||
| WETH | 26,760 / 15,378 | 42.53% | 3.671 / 3.710 | 3.930 / 3.673 |
|
||||
|
||||
These measurements support smaller delivery, not faster interpretation. Analysis
|
||||
still runs and the full parent still incurs producer/retention costs. Catalog
|
||||
count and order stay at 184 tools. The complete catalog grows from 2,422,229 to
|
||||
2,429,938 compact JSON bytes (+7,709); all name/description/input definitions
|
||||
grow from 512,655 to 514,074 bytes. The EVM input definition grows from 1,443 to
|
||||
2,029 bytes. Only `inspect_analysis_view` and `inspect_evm_interface` definitions
|
||||
change. These discovery costs are visible and are not converted into token counts.
|
||||
|
||||
Nine separate measurements verify new-server complete defaults, old-server
|
||||
summary fallback and retained reads for all three inputs. The four-call retained
|
||||
proofs retrieve the complete canonical parent plus pages and cost 160,110,
|
||||
177,106 and 79,160 bytes for Factory, Pool and WETH respectively. They are
|
||||
verification workflows, not examples of one-call delivery savings.
|
||||
|
||||
## Real Codex pairs and answer qualification
|
||||
|
||||
Twelve serial Codex CLI 0.161.0 trials use the existing identical questions for
|
||||
each pair, the same artifact path, one enabled EVM tool, temporary MCP profiles
|
||||
and requested `gpt-5.6-terra` high. The requested alias is not proof of the
|
||||
resolved model identity. Trials include schema discovery, reasoning, one actual
|
||||
successful EVM call and final answer. No call fails or retries. Profiles are
|
||||
removed and input bytes remain unchanged. This fixed one-tool profile does not
|
||||
test selection from the full catalog.
|
||||
|
||||
| Input / repetition | Uncached input, control → candidate | Seconds, control → candidate | Candidate delivery |
|
||||
| ------------------ | ----------------------------------: | ---------------------------: | ------------------ |
|
||||
| Factory / 1 | 22,901 → 25,668 | 52.485 → 48.768 | summary |
|
||||
| Factory / 2 | 37,181 → 15,270 | 53.404 → 45.345 | summary |
|
||||
| Pool / 1 | 36,652 → 26,657 | 57.764 → 66.642 | summary |
|
||||
| Pool / 2 | 28,305 → 36,259 | 62.068 → 71.756 | complete |
|
||||
| WETH / 1 | 21,128 → 25,187 | 44.869 → 46.809 | summary |
|
||||
| WETH / 2 | 17,417 → 17,529 | 30.364 → 39.943 | summary |
|
||||
|
||||
Keep all trials, including the candidate that explicitly chose complete delivery.
|
||||
Five of six candidates select summary, but uncached input improves in only two
|
||||
pairs and time improves in only two. Aggregate control → candidate observations
|
||||
are 362,496 → 357,770 total input; 198,912 → 211,200 cached input;
|
||||
163,584 → 146,570 uncached input; 8,953 → 10,397 output; and
|
||||
300.954 → 319.263 seconds. Cache state and model/service variation are not
|
||||
separated; the aggregate does not establish a repeatable saving for an individual
|
||||
question or a qualified performance recommendation.
|
||||
|
||||
Every answer passes exact core-field checks: both identities/byte counts, every
|
||||
function selector/offset/dispatch/argument/mutability including null, inference,
|
||||
unknown completeness/kind/hardfork/authenticity, and absent runtime execution.
|
||||
All reported IDs occur in actual responses. However, the existing grader requires
|
||||
the final limitation list to equal the producer list verbatim and in order.
|
||||
Only three trials pass that additional check; nine fail. The questions request
|
||||
preserving limitations but do not explicitly request a verbatim ordered list.
|
||||
Four failures contain all original strings with extra correct scope statements
|
||||
or different ordering. The other five paraphrase or omit source caveats, including
|
||||
worker or upstream-metadata limitations. Do not silently waive those omissions
|
||||
or turn these into twelve fully acceptable answers. The strict reports and
|
||||
original transcripts remain intact; core-field success is a narrower result.
|
||||
|
||||
Model scope sampled peaks range from 562.5 to 710.5 MiB, with last-observed CPU
|
||||
5.945–6.878 seconds. CPU includes the local process family, not remote model
|
||||
computation. All heavy jobs use one CPU, a 4 GiB hard limit, 3 GiB early-stop,
|
||||
no swap and 192 tasks. No scope abort occurs in this cohort. Final cgroup
|
||||
counters are unavailable after teardown: final OOM/task/limit-event assertions
|
||||
remain **unverified**. Last-observed counters are not substituted for final ones.
|
||||
Consequently neither strict answer acceptance nor resource-qualified performance
|
||||
success is claimed for the whole cohort.
|
||||
|
||||
## Existing-user compatibility
|
||||
|
||||
Omitted and explicit-complete MCP requests, the existing CLI and provider inputs
|
||||
preserve their full behavior. `detail` is removed before the unchanged provider
|
||||
input; original full Evidence parameters, raw result and identity are retained.
|
||||
Summary receives its own identity linked to that parent. All candidate facts,
|
||||
original report limitations, stderr/truncation and explicit unknowns stay inline.
|
||||
Complete-within-view candidate coverage is not global discovery completeness.
|
||||
Function pages retain original order; text pages use UTF-16 code units, with
|
||||
hex characters distinguished from decoded-byte function offsets.
|
||||
|
||||
Actual new default replies for all three artifacts validate against the frozen
|
||||
old advertised input/output schemas, and structured/text payloads agree. Older
|
||||
servers reject neither request nor unsupported fields because the experimental
|
||||
client discovers support before selecting summary and otherwise calls complete.
|
||||
This is an explicit client fallback, not universal server forward compatibility.
|
||||
|
||||
Three authentic old-runtime records and old-created canonical bundles pass new
|
||||
MCP import, retained summary, CLI inline summary and export. Original records,
|
||||
IDs and bundle source bytes stay deeply equal. The reproducible verifier below
|
||||
also checks function/hex pages with the analysis limiter explicitly unavailable,
|
||||
so retained reads cannot silently start successful producer analysis. This
|
||||
proves the pinned old/new Linux workflows, not every historical client release.
|
||||
|
||||
The initial retained experiment failed because its driver read the bundle's
|
||||
wrong envelope. Correcting that consumer produced passing retained proofs; the
|
||||
failed receipt stays archived and is not recorded as a REA defect. Separately,
|
||||
one static-check attempt hit the unchanged 3 GiB early-stop. The bounded retry
|
||||
passes with Node heap 512 MiB/native checker memory controls; its roughly 3 GiB
|
||||
peak and soft-limit events are excluded from efficiency comparisons.
|
||||
|
||||
## Reproduction and checks
|
||||
|
||||
Use [the shared instructions](README.md), explicit frozen revisions/runtimes and
|
||||
fresh private output directories. Run `measure.mjs` for `weth.hex`,
|
||||
`uniswap-v3.factory.hex` and `uniswap-v3.pool.hex`, with `--schemas selected` and
|
||||
paired `--delivery complete` / `summary`; run `compare.mjs` on equivalent pairs.
|
||||
Add `--verify-retained` only for the separate four-call proof. Use the unchanged
|
||||
[WETH](questions/evm.txt) or [template](questions/evm-uniswap.txt) question and the
|
||||
same one-tool profile for `agent-trial.py`, preserving all usage and grader results.
|
||||
|
||||
Export complete Evidence with the old runtime's public ledger workflow, then run:
|
||||
|
||||
```sh
|
||||
node experiments/analysis-efficiency/verify-evm-retention.mjs \
|
||||
--runtime-root ABS_FROZEN_NEW_RUNTIME --revision NEW_SHA \
|
||||
--bundle ABS_OLD_BUNDLE_JSON --output NEW_PRIVATE_ABS_DIR
|
||||
```
|
||||
|
||||
The script acquires no dependencies and preserves the old bundle. Revision is
|
||||
caller-supplied; retain the frozen file-table receipt alongside it. Raw JSON,
|
||||
transcripts, profiles, bytecode, compiler inputs and generated artifacts stay
|
||||
outside Git. This checkpoint adds source verification and curated observations.
|
||||
|
||||
The production change passes 64 focused EVM/WASM/generic-view/domain/service
|
||||
checks and full static/docs gates. Recording provider seams establish exact
|
||||
schemas, old defaults, inference/null preservation, historical identity failures,
|
||||
peer availability, cancellation and cleanup retry; they are not real-provider
|
||||
claims. Real-provider and shared-domain checks are recorded separately.
|
||||
|
||||
The same frozen candidate also passes six actual public MCP artifact workflows:
|
||||
SQLite WASM with WABT summary, ShareX managed metadata, Obsidian inventory,
|
||||
NewPipe with JADX, an OpenWrt region inspection, and jq entry analysis with
|
||||
Ghidra. These are shared-contract regressions; they do not establish AST analysis
|
||||
of all Obsidian code, full firmware reconstruction, browser coverage, or new token
|
||||
savings in those domains. Native Windows PE and DOS coverage remains at the
|
||||
[earlier native checkpoint](native-entry-views.md), not a new Ghidra/Windows claim.
|
||||
The source retention verifier passes for all three authentic old EVM bundles,
|
||||
including exact summaries, function/hex pages, CLI inline views and unchanged
|
||||
exported originals with the limiter explicitly unavailable.
|
||||
|
||||
The frozen candidate passes all 59 existing real EVM CLI/MCP verifier cases with
|
||||
caller-supplied solc 0.8.30 and strace 6.1, including malformed/unsupported
|
||||
carriers, unavailable limiter and capacity failures. Its scope takes 96.076
|
||||
seconds with 1,345,052,672 sampled peak bytes and 95.130 last-observed CPU seconds.
|
||||
This is regression evidence, not an interpreter speedup comparison; final
|
||||
resource counters remain unverified. Fresh fast static and generated-document
|
||||
checks also pass after adding the migration verifier and this report.
|
||||
|
||||
## Latest-main integration
|
||||
|
||||
The branch rebases without conflict onto main
|
||||
`0043d9b134c0a353e8bf85c0bde4492275f1f720`. Production integration commit
|
||||
`3766749316c345ccb594b1b748747b1af9582b34` preserves the same EVM projection,
|
||||
provider and delivery semantics; intervening main adds unrelated capabilities.
|
||||
The above performance cohort stays pinned to its original frozen runtimes and
|
||||
is not relabeled as a measurement of the larger integrated catalog.
|
||||
|
||||
At `cda794fb9d4a5ca2bd661853a899d579fb8a47b2`, all 30 affected EVM/WASM/generic-view
|
||||
MCP tests pass again, as do full `npm run check` and `npm run docs:check`. A fresh
|
||||
real Factory SDK selected-summary/retained-parent/page workflow and the original
|
||||
Pool bundle's SDK/CLI migration verifier also pass against the rebuilt integrated
|
||||
runtime. The latter still has an explicitly unavailable analysis limiter.
|
||||
|
||||
The initial integrated static-check scope stops at 3,221,446,656 sampled bytes,
|
||||
just above the unchanged 3 GiB early-stop. Running the same typecheck through
|
||||
its single Turbo task with less launcher overhead passes at 3,219,353,600 sampled
|
||||
bytes; the subsequent full gate uses that valid cached typecheck and passes.
|
||||
No memory threshold or check requirement is relaxed. Preserve both receipts;
|
||||
these near-limit validation jobs are excluded from efficiency conclusions.
|
||||
@@ -3,7 +3,7 @@ import { createReadStream } from "node:fs";
|
||||
import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
||||
import { dirname, isAbsolute, resolve } from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { parseArgs } from "node:util";
|
||||
import { isDeepStrictEqual, parseArgs } from "node:util";
|
||||
import {
|
||||
NATIVE_ARTIFACTS,
|
||||
measureNativeEntry,
|
||||
@@ -23,6 +23,7 @@ const { values } = parseArgs({
|
||||
providers: { type: "string" },
|
||||
output: { type: "string" },
|
||||
delivery: { type: "string", default: "complete" },
|
||||
"verify-retained": { type: "boolean", default: false },
|
||||
"native-question": { type: "string", default: "entry" },
|
||||
"javascript-question": { type: "string", default: "inventory" },
|
||||
schemas: { type: "string", default: "default" },
|
||||
@@ -41,6 +42,10 @@ if (
|
||||
) ||
|
||||
!["inventory", "selected"].includes(values["javascript-question"]) ||
|
||||
!["default", "selected"].includes(values.schemas) ||
|
||||
(values["verify-retained"] &&
|
||||
!["weth.hex", "uniswap-v3.factory.hex", "uniswap-v3.pool.hex"].includes(
|
||||
values.artifact,
|
||||
)) ||
|
||||
(!NATIVE_ARTIFACTS.includes(values.artifact) &&
|
||||
values["native-question"] !== "entry") ||
|
||||
(values.artifact !== "jq" &&
|
||||
@@ -350,15 +355,44 @@ const inspectWasmTarget = async () => {
|
||||
};
|
||||
};
|
||||
|
||||
/** Identical complete interface question for pinned offline EVM carriers. */
|
||||
/** Identical interface facts for complete delivery, selected summary or old-server fallback. */
|
||||
const inspectEvmTarget = async () => {
|
||||
const definition = catalogDefinitions.get("inspect_evm_interface");
|
||||
if (!definition) throw new Error("Missing advertised EVM definition");
|
||||
const input = { path: values.path, encoding: "hex" };
|
||||
const supportsSummary = new Ajv2020({
|
||||
strict: false,
|
||||
validateFormats: false,
|
||||
}).compile(definition.inputSchema)({ ...input, detail: "summary" });
|
||||
const info = await call("inspect_evm_interface", {
|
||||
path: values.path,
|
||||
encoding: "hex",
|
||||
...input,
|
||||
...(values.delivery === "summary" && supportsSummary
|
||||
? { detail: "summary" }
|
||||
: {}),
|
||||
});
|
||||
const n = normalized(info);
|
||||
const result = normalized(info);
|
||||
const projected = result.kind === "summary";
|
||||
const n = projected ? result.summary : result;
|
||||
const references = [info.evidence_id];
|
||||
if (projected) {
|
||||
if (
|
||||
result.parent_operation !== "inspect_evm_interface" ||
|
||||
result.parent_evidence_id === info.evidence_id ||
|
||||
!info.evidence_links.includes(result.parent_evidence_id) ||
|
||||
"hex" in n.bytecode ||
|
||||
"stdout" in n.diagnostics
|
||||
)
|
||||
throw new Error(
|
||||
"EVM summary changed source provenance or precise delivery",
|
||||
);
|
||||
references.push(result.parent_evidence_id);
|
||||
}
|
||||
if (
|
||||
n.evidence_kind !== "inferred" ||
|
||||
n.artifact.path !== values.path ||
|
||||
n.artifact.sha256 !== inputSha ||
|
||||
n.artifact.bytes !== artifact.bytes ||
|
||||
n.artifact.encoding !== "hex" ||
|
||||
n.discovery_completeness !== "unknown" ||
|
||||
n.runtime_execution !== "not-performed" ||
|
||||
["kind", "hardfork", "deployment_authenticity"].some(
|
||||
@@ -370,15 +404,69 @@ const inspectEvmTarget = async () => {
|
||||
n.bytecode.bytes !== artifact.decoded_bytes)
|
||||
)
|
||||
throw new Error("EVM interface identity or uncertainty changed");
|
||||
if (values["verify-retained"]) {
|
||||
if (!projected)
|
||||
throw new Error(
|
||||
"Retained verification requires supported selected summary",
|
||||
);
|
||||
const bundle = (await call("get_evidence_bundle", {})).result;
|
||||
const parent = bundle.records.find(
|
||||
(record) => record.evidence_id === result.parent_evidence_id,
|
||||
);
|
||||
if (
|
||||
!parent ||
|
||||
parent.operation !== "inspect_evm_interface" ||
|
||||
parent.subject?.digest.sha256 !== inputSha ||
|
||||
parent.parameters.path !== values.path ||
|
||||
parent.parameters.encoding !== "hex" ||
|
||||
"detail" in parent.parameters
|
||||
)
|
||||
throw new Error(
|
||||
"Complete original EVM source was not retained unchanged",
|
||||
);
|
||||
const original = normalized(parent);
|
||||
const { hex: _hex, ...identity } = original.bytecode;
|
||||
const { stdout, ...diagnostics } = original.diagnostics;
|
||||
const expected = {
|
||||
...original,
|
||||
bytecode: identity,
|
||||
diagnostics: { ...diagnostics, stdout_code_units: stdout.length },
|
||||
};
|
||||
if (!isDeepStrictEqual(expected, n))
|
||||
throw new Error("EVM summary changed selected original facts");
|
||||
for (const [facet, item] of [
|
||||
["functions", original.functions.slice(0, 64)],
|
||||
[
|
||||
"bytecode_hex",
|
||||
{ text: original.bytecode.hex.slice(0, 64), unit: "utf16-code-units" },
|
||||
],
|
||||
]) {
|
||||
const page = await call("inspect_analysis_view", {
|
||||
source: { kind: "retained-evidence", evidence_id: parent.evidence_id },
|
||||
view: { kind: "evm", facet, offset: 0, limit: 64 },
|
||||
});
|
||||
const v = normalized(page);
|
||||
if (
|
||||
!isDeepStrictEqual(v.item, item) ||
|
||||
v.parent_evidence_id !== parent.evidence_id ||
|
||||
v.artifact.sha256 !== inputSha
|
||||
)
|
||||
throw new Error("EVM retained read changed source facts or identity");
|
||||
if (references.includes(page.evidence_id))
|
||||
throw new Error("EVM retained read reused an Evidence identity");
|
||||
references.push(page.evidence_id);
|
||||
}
|
||||
}
|
||||
const { hex: _hex, ...bytecode } = n.bytecode;
|
||||
return {
|
||||
artifact_sha256: targetSha(info),
|
||||
artifact: n.artifact,
|
||||
bytecode: n.bytecode,
|
||||
bytecode,
|
||||
functions: n.functions,
|
||||
discovery_completeness: n.discovery_completeness,
|
||||
runtime_execution: n.runtime_execution,
|
||||
limitations: n.limitations,
|
||||
evidence_ids: [info.evidence_id],
|
||||
evidence_ids: references,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -672,6 +760,7 @@ const report = {
|
||||
artifact_sha256_after: finalInputSha,
|
||||
delivery: values.delivery,
|
||||
sdk_schema_mode: values.schemas,
|
||||
retained_verification: values["verify-retained"],
|
||||
native_question: NATIVE_ARTIFACTS.includes(values.artifact)
|
||||
? values["native-question"]
|
||||
: null,
|
||||
|
||||
@@ -98,8 +98,13 @@ def main():
|
||||
check('wabt_' + key, answer.get('wabt_' + key), reference['tool_profile'][key])
|
||||
elif domain == 'evm':
|
||||
n = producer_results['inspect_evm_interface'][-1]['normalized_result']
|
||||
if n.get('kind') == 'summary':
|
||||
check('evm_summary.parent_operation', n.get('parent_operation'), 'inspect_evm_interface')
|
||||
checks['evm_summary.parent_reference_observed'] = n.get('parent_evidence_id') in observed_ids
|
||||
n = n['summary']
|
||||
for key, expected in {'artifact_bytes': n['artifact']['bytes'], 'bytecode_sha256': n['bytecode']['sha256'], 'bytecode_bytes': n['bytecode']['bytes'], 'functions': n['functions'], 'evidence_kind': n['evidence_kind'], 'discovery_completeness': n['discovery_completeness'], 'runtime_execution': n['runtime_execution'], 'bytecode_kind': n['bytecode']['kind'], 'hardfork': n['bytecode']['hardfork'], 'deployment_authenticity': n['bytecode']['deployment_authenticity']}.items():
|
||||
check(key, answer.get(key), expected)
|
||||
check('evm_original_limitations', answer.get('limitations'), n['limitations'])
|
||||
elif domain == 'android':
|
||||
for key in ['package_name', 'version_name', 'version_code', 'matches']:
|
||||
check(key, answer.get(key), reference[key])
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { execFile } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { isAbsolute, resolve } from "node:path";
|
||||
import { parseArgs, promisify } from "node:util";
|
||||
import { Client } from "@modelcontextprotocol/client";
|
||||
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
||||
|
||||
const { values } = parseArgs({
|
||||
options: {
|
||||
"runtime-root": { type: "string" },
|
||||
revision: { type: "string" },
|
||||
bundle: { type: "string" },
|
||||
output: { type: "string" },
|
||||
},
|
||||
});
|
||||
for (const key of ["runtime-root", "bundle", "output"])
|
||||
assert.ok(values[key] && isAbsolute(values[key]), `Supply --${key} ABS`);
|
||||
assert.ok(values.revision);
|
||||
await mkdir(values.output, { mode: 0o700 });
|
||||
const sha = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
||||
const bytes = await readFile(values.bundle);
|
||||
const original = JSON.parse(bytes.toString("utf8"));
|
||||
const parents = original.records.filter(
|
||||
(record) => record.operation === "inspect_evm_interface",
|
||||
);
|
||||
assert.ok(parents.length > 0, "Select a bundle containing old EVM Evidence");
|
||||
const entrypoint = resolve(values["runtime-root"], "scripts/rea.mjs");
|
||||
const environment = {
|
||||
...process.env,
|
||||
REA_LOG_LEVEL: "silent",
|
||||
NODE_OPTIONS: "--max-old-space-size=512",
|
||||
// If a view accidentally starts analysis, its required limiter is unavailable.
|
||||
REA_EVM_PRLIMIT_COMMAND: resolve(values.output, "absent-prlimit"),
|
||||
};
|
||||
const client = new Client({ name: "rea-old-evm-retention", version: "1" });
|
||||
const transport = new StdioClientTransport({
|
||||
command: process.execPath,
|
||||
args: [entrypoint, "mcp"],
|
||||
env: environment,
|
||||
stderr: "pipe",
|
||||
});
|
||||
const definitions = new Map();
|
||||
const calls = [];
|
||||
const call = async (name, args) => {
|
||||
const definition = definitions.get(name);
|
||||
assert.ok(definition, `Missing named contract ${name}`);
|
||||
const reply = await client.callTool(
|
||||
{ name, arguments: args },
|
||||
{ toolDefinition: definition, timeout: 60_000 },
|
||||
);
|
||||
await writeFile(
|
||||
resolve(values.output, `call-${calls.length + 1}.json`),
|
||||
JSON.stringify(reply),
|
||||
{ flag: "wx", mode: 0o600 },
|
||||
);
|
||||
assert.notEqual(reply.isError, true, JSON.stringify(reply));
|
||||
const text = JSON.parse(reply.content.find((x) => x.type === "text").text);
|
||||
assert.deepEqual(reply.structuredContent, text);
|
||||
calls.push({ name, arguments: args, evidence_id: text.evidence_id ?? null });
|
||||
return text;
|
||||
};
|
||||
const checked = [];
|
||||
try {
|
||||
await client.connect(transport);
|
||||
transport.stderr?.resume();
|
||||
for (const definition of (await client.listTools()).tools)
|
||||
definitions.set(definition.name, definition);
|
||||
await call("import_evidence_bundle", { path: values.bundle });
|
||||
const imported = (await call("get_evidence_bundle", {})).result.records;
|
||||
for (const parent of parents) {
|
||||
assert.deepEqual(
|
||||
imported.find((record) => record.evidence_id === parent.evidence_id),
|
||||
parent,
|
||||
);
|
||||
const source = {
|
||||
kind: "retained-evidence",
|
||||
evidence_id: parent.evidence_id,
|
||||
};
|
||||
const view = await call("inspect_analysis_view", {
|
||||
source,
|
||||
view: { kind: "summary" },
|
||||
});
|
||||
const { hex, ...bytecode } = parent.normalized_result.bytecode;
|
||||
const { stdout, ...diagnostics } = parent.normalized_result.diagnostics;
|
||||
assert.deepEqual(view.normalized_result.summary, {
|
||||
...parent.normalized_result,
|
||||
bytecode,
|
||||
diagnostics: { ...diagnostics, stdout_code_units: stdout.length },
|
||||
});
|
||||
assert.equal(view.normalized_result.parent_evidence_id, parent.evidence_id);
|
||||
assert.notEqual(view.evidence_id, parent.evidence_id);
|
||||
assert.deepEqual(view.evidence_links, [parent.evidence_id]);
|
||||
for (const [facet, expected] of [
|
||||
["functions", parent.normalized_result.functions.slice(0, 2)],
|
||||
["bytecode_hex", { text: hex.slice(0, 64), unit: "utf16-code-units" }],
|
||||
]) {
|
||||
const page = await call("inspect_analysis_view", {
|
||||
source,
|
||||
view: {
|
||||
kind: "evm",
|
||||
facet,
|
||||
offset: 0,
|
||||
limit: facet === "functions" ? 2 : 64,
|
||||
},
|
||||
});
|
||||
assert.deepEqual(page.normalized_result.item, expected);
|
||||
assert.equal(
|
||||
page.normalized_result.parent_evidence_id,
|
||||
parent.evidence_id,
|
||||
);
|
||||
assert.deepEqual(page.evidence_links, [parent.evidence_id]);
|
||||
}
|
||||
const inlinePath = resolve(values.output, `inline-${checked.length}.json`);
|
||||
await writeFile(
|
||||
inlinePath,
|
||||
JSON.stringify({
|
||||
source: { kind: "inline", evidence: parent },
|
||||
view: { kind: "summary" },
|
||||
}),
|
||||
{ flag: "wx", mode: 0o600 },
|
||||
);
|
||||
const result = await promisify(execFile)(
|
||||
process.execPath,
|
||||
[entrypoint, "inspect-analysis-view", inlinePath, "--json"],
|
||||
{ env: environment, timeout: 60_000, maxBuffer: 16 * 1024 * 1024 },
|
||||
);
|
||||
const inline = JSON.parse(result.stdout);
|
||||
assert.equal(
|
||||
inline.normalized_result.parent_evidence_id,
|
||||
parent.evidence_id,
|
||||
);
|
||||
assert.deepEqual(
|
||||
inline.normalized_result.summary,
|
||||
view.normalized_result.summary,
|
||||
);
|
||||
checked.push(parent.evidence_id);
|
||||
}
|
||||
const path = resolve(values.output, "exported.json");
|
||||
await call("export_evidence_bundle", { path });
|
||||
const exported = JSON.parse(await readFile(path, "utf8"));
|
||||
for (const record of original.records)
|
||||
assert.deepEqual(
|
||||
exported.records.find((x) => x.evidence_id === record.evidence_id),
|
||||
record,
|
||||
);
|
||||
assert.deepEqual(await readFile(values.bundle), bytes);
|
||||
} finally {
|
||||
await client.close();
|
||||
}
|
||||
const report = {
|
||||
runtime_revision: values.revision,
|
||||
original_bundle_sha256: sha(bytes),
|
||||
checked_original_evidence_ids: checked,
|
||||
original_records_and_source_bytes_unchanged: true,
|
||||
exact_summaries_pages_and_cli_inline_pass: true,
|
||||
calls,
|
||||
scope:
|
||||
"Old EVM Evidence through actual public SDK/CLI with an unavailable analysis limiter; original inferred facts, explicit unknowns, parent identities and export records preserved. Caller supplies the frozen runtime revision; this is migration verification, not a performance pair.",
|
||||
};
|
||||
await writeFile(
|
||||
resolve(values.output, "summary.json"),
|
||||
JSON.stringify(report, null, 2),
|
||||
{ flag: "wx", mode: 0o600 },
|
||||
);
|
||||
process.stdout.write(JSON.stringify(report) + "\n");
|
||||
Reference in New Issue
Block a user