test(experiments): expand real-provider corpus and grade Codex projections
This commit is contained in:
@@ -69,6 +69,22 @@ 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).
|
||||
|
||||
`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 every
|
||||
exit, and retains JSONL events, the answer and measured API usage outside the repo.
|
||||
@@ -87,6 +103,12 @@ provider settings. No ambient environment snapshot is retained. A configured fla
|
||||
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` currently checks the Android task against a successful real-provider
|
||||
replay and verifies that cited IDs appeared as producer or bridge audit IDs. This
|
||||
checks producer parity and reference existence; it does not prove Android runtime
|
||||
behavior or independent correctness of the decompiler. Its strict projection also
|
||||
checks the provider's overload index, so an otherwise supported method signature
|
||||
with that field omitted fails this stronger assertion.
|
||||
|
||||
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
|
||||
@@ -101,3 +123,6 @@ 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.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Evaluate one real Codex CLI task with an isolated REA MCP registration."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -57,6 +58,11 @@ def main():
|
||||
'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.'
|
||||
)
|
||||
@@ -67,8 +73,17 @@ def main():
|
||||
'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"',
|
||||
@@ -103,6 +118,17 @@ def main():
|
||||
(trial_codex_home / 'config.toml').chmod(0o600)
|
||||
prompt = args.prompt.read_text()
|
||||
(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,
|
||||
'developer_instructions': instruction,
|
||||
'developer_instructions_sha256': hashlib.sha256(instruction.encode()).hexdigest(),
|
||||
'prompt_sha256': hashlib.sha256(prompt.encode()).hexdigest(),
|
||||
'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),
|
||||
|
||||
@@ -8,6 +8,33 @@ 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:
|
||||
@@ -65,20 +92,20 @@ return {artifact_sha256: inspected.subject?.digest.sha256,
|
||||
jq: {
|
||||
tools: [
|
||||
"open_binary",
|
||||
"search_procedures",
|
||||
"resolve_containing_procedure",
|
||||
"analyze_function",
|
||||
"close_binary",
|
||||
],
|
||||
question:
|
||||
"Find jq_compile, analyze it and report its first 512 pseudocode units and caller/callee counts.",
|
||||
"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("search_procedures", {pattern: "jq_compile", mode: "literal", case_sensitive: true});
|
||||
const fn = await call("analyze_function", {procedure: "jq_compile"});
|
||||
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,
|
||||
matches: found.normalized_result, procedure: n.procedure,
|
||||
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],
|
||||
@@ -125,6 +152,11 @@ const measure = (value) => {
|
||||
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"))
|
||||
: {};
|
||||
@@ -149,6 +181,7 @@ upstream.call = async (name, args, options) => {
|
||||
is_error: reply.isError === true,
|
||||
input: measure(args),
|
||||
output: measure(reply),
|
||||
text_output: measure(modelText(reply)),
|
||||
evidence_id: parsed.evidence_id,
|
||||
reply,
|
||||
});
|
||||
@@ -167,6 +200,11 @@ upstream.call = async (name, args, options) => {
|
||||
const bridge = new CodeModeBridge(upstream);
|
||||
const workflow = workflows[values.artifact];
|
||||
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);
|
||||
@@ -216,11 +254,22 @@ const summary = {
|
||||
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,
|
||||
correctness: failure
|
||||
@@ -242,7 +291,13 @@ console.log(
|
||||
calls: records.length,
|
||||
startup_ms: summary.startup_ms,
|
||||
operation_ms: summary.operation_ms,
|
||||
failure: summary.failure,
|
||||
failure: summary.failure
|
||||
? String(
|
||||
typeof summary.failure === "object"
|
||||
? summary.failure.message
|
||||
: summary.failure,
|
||||
).slice(0, 1000)
|
||||
: null,
|
||||
}),
|
||||
);
|
||||
if (failure) process.exitCode = 1;
|
||||
|
||||
@@ -79,6 +79,23 @@ export class CodeModeBridge {
|
||||
.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 = schemas
|
||||
@@ -107,6 +124,7 @@ export class CodeModeBridge {
|
||||
total_tools: this.byName.size,
|
||||
matched_tools: tools.length,
|
||||
tools,
|
||||
...(suggestions.length ? { suggestions } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -321,7 +339,7 @@ export function createBridgeServer(bridge) {
|
||||
"rea_execute",
|
||||
{
|
||||
description:
|
||||
"Run a JavaScript async function body with tools.<original_REA_name>(original_arguments), json(reply) and return. Await every call. One upstream session persists across executions. Calls run in order, including Promise.all. All original REA effects, validation and Evidence retention apply; returned 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.",
|
||||
"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: z.strictObject({
|
||||
code: z.string(),
|
||||
timeout_ms: z.number().int().positive().optional(),
|
||||
|
||||
@@ -50,6 +50,14 @@ test("discovery preserves exact current REA schemas and names", async () => {
|
||||
all.tools.map((tool) => tool.name),
|
||||
upstream.catalog.map((tool) => tool.name),
|
||||
);
|
||||
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 () => {
|
||||
|
||||
@@ -1,6 +1,37 @@
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
"""Check requested JSON facts and real Evidence references against a replay oracle."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
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 main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--trial', type=Path, required=True)
|
||||
parser.add_argument('--oracle', type=Path, required=True)
|
||||
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')
|
||||
expected = oracle['projection']
|
||||
# A task explicitly chooses these assertions; do not grade unrequested fields.
|
||||
fields = ['artifact_sha256', 'package_name', 'version_name', 'version_code',
|
||||
'matches', 'onCreate']
|
||||
if not all(field in expected for field in fields):
|
||||
raise SystemExit('This grader currently supports the Android question only')
|
||||
failures = []
|
||||
answer_path = args.trial / 'answer.txt'
|
||||
try:
|
||||
answer = json.loads(answer_path.read_text())
|
||||
if not isinstance(answer, dict):
|
||||
raise ValueError('Answer is not a JSON object')
|
||||
except (FileNotFoundError, ValueError) as error:
|
||||
answer = {}
|
||||
failures.append({'kind': 'answer_parse_failure', 'reason': str(error)})
|
||||
for field in fields:
|
||||
wanted = expected[field]
|
||||
actual = answer.get(field)
|
||||
if field == 'onCreate':
|
||||
selected = ['reported_signature', 'overload_index', 'dex_descriptor']
|
||||
wanted = [{k: row[k] for k in selected} for row in wanted]
|
||||
if isinstance(actual, list) and all(isinstance(row, dict) for row in actual):
|
||||
actual = [{k: row.get(k) for k in selected} for row in actual]
|
||||
if actual != wanted:
|
||||
failures.append({'kind': 'fact_mismatch', 'field': field,
|
||||
'expected': wanted, 'actual': actual})
|
||||
observed = set()
|
||||
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
|
||||
result = item.get('result') or {}
|
||||
for content in result.get('content', []):
|
||||
if content.get('type') == 'text':
|
||||
try:
|
||||
reply = json.loads(content['text'])
|
||||
except ValueError:
|
||||
continue
|
||||
# Only producer IDs and bridge audit IDs establish retention.
|
||||
if isinstance(reply, dict):
|
||||
observed |= evidence_ids(reply.get('evidence_id'))
|
||||
for call in reply.get('calls', []):
|
||||
observed |= evidence_ids(call.get('evidence_id'))
|
||||
cited = evidence_ids(answer.get('evidence_ids'))
|
||||
if not cited:
|
||||
failures.append({'kind': 'missing_evidence_references'})
|
||||
if cited - observed:
|
||||
failures.append({'kind': 'unobserved_evidence_ids', 'ids': sorted(cited - observed)})
|
||||
result = {'task': 'newpipe_package_and_MainActivity',
|
||||
'scope': 'producer_fact_parity_and_reference_existence_not_runtime_accuracy',
|
||||
'passed': not failures, 'fact_assertions': len(fields),
|
||||
'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()
|
||||
@@ -16,6 +16,32 @@ def available_bytes():
|
||||
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] == '--':
|
||||
@@ -30,11 +56,13 @@ def main():
|
||||
command = [
|
||||
'systemd-run', '--user', '--scope', '--unit=' + unit,
|
||||
'-p', 'MemoryMax=4G', '-p', 'MemoryHigh=3G', '-p', 'MemorySwapMax=0',
|
||||
'-p', 'CPUQuota=100%', '-p', 'TasksMax=96',
|
||||
'-p', 'CPUQuota=100%', '-p', 'TasksMax=192',
|
||||
'taskset', '-c', str(cpu), *args,
|
||||
]
|
||||
process = subprocess.Popen(command)
|
||||
peak = 0
|
||||
peak_tasks = 0
|
||||
events = {}
|
||||
abort = None
|
||||
started = time.monotonic()
|
||||
try:
|
||||
@@ -51,27 +79,42 @@ def main():
|
||||
group = Path('/sys/fs/cgroup') / path.lstrip('/')
|
||||
current = group / 'memory.current' if group else None
|
||||
if current and current.exists():
|
||||
peak = max(peak, int(current.read_text()))
|
||||
try:
|
||||
peak = max(peak, int(current.read_text()))
|
||||
peak_tasks = max(peak_tasks, int((group / 'pids.current').read_text()))
|
||||
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:
|
||||
subprocess.run(['systemctl', '--user', 'stop', unit], check=False)
|
||||
stop_owned_scope(unit, process, group)
|
||||
break
|
||||
time.sleep(0.1)
|
||||
code = process.wait()
|
||||
except BaseException:
|
||||
subprocess.run(['systemctl', '--user', 'stop', unit], check=False)
|
||||
process.wait()
|
||||
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,
|
||||
}), file=sys.stderr)
|
||||
raise SystemExit(125 if abort else code)
|
||||
|
||||
|
||||
@@ -43,5 +43,102 @@ threshold. Its 4 GiB hard ceiling and host-available-memory checks remain in for
|
||||
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-artifact investigations and provider parity are still unverified.
|
||||
The bridge is an experiment and has not changed any published REA contract.
|
||||
## 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.
|
||||
Bridge parity for the corrected workflow is pending. 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; direct parity is pending.
|
||||
|
||||
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; a standalone SDK replay is pending. 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 bridge remains an experiment and has not changed any published REA contract.
|
||||
|
||||
Reference in New Issue
Block a user