Files
reverse-engineering-anything/scripts/verify/analysis/flutter-budget-calibration/task.mjs
T
morluto cb4e5cfbff feat(analysis): make resource budgets recoverable across CLI and MCP (#9706)
* refactor(analysis): centralize resource budgets and recovery facts

* feat(analysis): expose ASAR and Ghidra runtime admission controls

* feat(artifacts): expose reader admission and preserve limited recognition

* feat(javascript): expose recoverable semantic precision budgets

* feat(web): add recoverable source-map budgets and compact retained views

* feat(web): make historical capture decoding budgets recoverable

* fix(desktop): enforce selected view policies across capture and export

* feat(runtime): make Frida and LLDB retention budgets selectable

* feat(native): expose diagnostic budgets and preserve exhaustion causes

* feat(managed): expose recoverable snapshot and representation budgets

* feat(metadata): make Go and Rust inspection budgets recoverable

* feat(wasm): expose representation and producer admissions

* feat(evm): expose per-call worker resource budgets

* feat(android): make resource and string-pool omissions recoverable

* feat(producers): expose command and recorded-capture budgets

* docs(analysis): record recovery contracts and integrated validation

* fix(docs): link calibration oracle from published verification pages

* fix(docs): restore desktop task anchors and receipt links

* test(analysis): align fixtures with selectable budget contracts

* fix(analysis): remove source-location projector dependency cycle

* test(analysis): refresh budget recovery and verifier regressions

* test(analysis): preserve format and publication recovery expectations

* test(windows): align conformance with owned runtime admission

* fix(desktop): preserve selected alias kinds in exported state

* test(analysis): align provider fixtures with recoverable budgets

* test(desktop): validate emitted alias metadata structurally

* fix(ghidra): classify bounded Windows endpoint refusals

* test(cli): assert selectable artifact admission recovery

* fix(cli): preserve capture provenance in environment builds
2026-11-10 05:11:20 -05:00

104 lines
3.8 KiB
JavaScript

import { readFile, writeFile } from "node:fs/promises";
import { pathToFileURL } from "node:url";
import { join } from "node:path";
import assert from "node:assert/strict";
const [repository, configPath] = process.argv.slice(2);
const config = JSON.parse(await readFile(configPath, "utf8"));
const { FlutterBuildAnalysisService } = await import(
pathToFileURL(
join(repository, "src/application/flutter/FlutterBuildAnalysisService.ts"),
)
);
const { createFlutterBuildAnalysisProvider } = await import(
pathToFileURL(join(repository, "src/composition/flutter.ts"))
);
const { estimateTokenCount } = await import(
pathToFileURL(join(repository, "node_modules/tokenx/dist/index.mjs"))
);
const oracle = JSON.parse(await readFile(config.oracle, "utf8"));
const calls = [];
const provider = createFlutterBuildAnalysisProvider();
const service = new FlutterBuildAnalysisService(provider);
try {
let uriLimit = config.first_uri_limit;
for (let attempt = 0; attempt < 5; attempt++) {
const input = {
path: config.artifact,
abi: "arm64-v8a",
pool_policy: {
...(uriLimit === undefined ? {} : { uri_limit: uriLimit }),
...(config.task === "package-inventory"
? { contains: "package:" }
: {}),
},
};
const request = { operation: "inspect_dart_aot", input };
const reply = await service.execute(request.operation, request.input);
calls.push({
request,
reply,
request_token_estimate: estimateTokenCount(JSON.stringify(request)),
reply_token_estimate: estimateTokenCount(JSON.stringify(reply)),
});
assert.equal(reply.ok, true, JSON.stringify(reply));
const result = reply.value.normalized_result;
assert.equal(result.target.sha256, oracle.artifact_sha256);
assert.equal(result.libapp.sha256, oracle.libapp_sha256);
assert.equal(result.abi, oracle.abi);
assert.equal(result.string_pool.policy.run_bytes, 1024);
assert.equal(result.string_pool.policy.token_bytes, 128);
assert.equal(result.string_pool.policy.token_limit, 2000);
if (config.task === "package-inventory") {
const expected = oracle.policies["1024"].package_uris;
if (
result.string_pool.package_uris.length <
result.string_pool.package_uri_count_at_least
) {
assert.equal(
config.recover,
true,
"Candidate failed inventory completeness",
);
uriLimit = config.recovery_uri_limit;
continue;
}
assert.deepEqual([...result.string_pool.package_uris].sort(), expected);
} else {
// Overview controls verify identity, ABI and snapshot section identities;
// they deliberately do not require any printable string values.
assert.ok(result.libapp.sections.length > 0);
}
const tokenEstimate = calls.reduce(
(n, call) => n + call.request_token_estimate + call.reply_token_estimate,
0,
);
const receipt = {
task: config.task,
boundary:
"shared application service; excludes CLI/MCP discovery, adapter delivery, retained resource overhead and model reasoning",
token_estimator:
"tokenx 1.3.0, estimate only; all logical requests and replies including retries",
token_estimate: tokenEstimate,
call_count: calls.length,
success: true,
pool_coverage: result.string_pool.coverage,
package_uris_delivered_final: result.string_pool.package_uris.length,
package_uri_count_at_least_final:
result.string_pool.package_uri_count_at_least,
config,
calls,
};
await writeFile(
config.reply_receipt,
JSON.stringify(receipt, null, 2) + "\n",
);
process.stdout.write(
JSON.stringify({ ...receipt, calls: undefined }) + "\n",
);
break;
}
assert.ok(calls.length < 5, "Recovery did not complete");
} finally {
await provider.close();
}