@tangle-network/traces 0.15.0 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -2
- package/dist/{chunk-7DOBU7BJ.js → chunk-U4EB4HK7.js} +529 -2497
- package/dist/cli.js +49 -9
- package/dist/index.d.ts +76 -879
- package/dist/index.js +6 -91
- package/docs/replay-verify.md +6 -5
- package/package.json +13 -13
package/dist/cli.js
CHANGED
|
@@ -34,7 +34,6 @@ import {
|
|
|
34
34
|
locateSessions,
|
|
35
35
|
mergeTracesConfig,
|
|
36
36
|
normalizeTraceQuestions,
|
|
37
|
-
parseCorpusFlag,
|
|
38
37
|
parseSession,
|
|
39
38
|
parseSince,
|
|
40
39
|
planUpload,
|
|
@@ -45,7 +44,6 @@ import {
|
|
|
45
44
|
renderInspectionReport,
|
|
46
45
|
renderSessionFacts,
|
|
47
46
|
renderValidation,
|
|
48
|
-
renderVerifiedFindingsSection,
|
|
49
47
|
resolveAdapter,
|
|
50
48
|
resolveRunWatchTarget,
|
|
51
49
|
runTraceImprovement,
|
|
@@ -62,7 +60,8 @@ import {
|
|
|
62
60
|
totalAgenticFailureMessage,
|
|
63
61
|
traceStreamEventsFromSpans,
|
|
64
62
|
validationExitCode,
|
|
65
|
-
|
|
63
|
+
verifyFindingsInSandbox,
|
|
64
|
+
verifySessionBundle,
|
|
66
65
|
watchRunTarget,
|
|
67
66
|
watchSessions,
|
|
68
67
|
writeInspectionReportFile,
|
|
@@ -71,13 +70,17 @@ import {
|
|
|
71
70
|
writeSessionIndexFile,
|
|
72
71
|
writeTraceEvidenceExportFile,
|
|
73
72
|
writeTraceQuestionsArtifacts
|
|
74
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-U4EB4HK7.js";
|
|
75
74
|
|
|
76
75
|
// src/cli.ts
|
|
77
76
|
import { readFileSync } from "fs";
|
|
78
77
|
import { mkdir, mkdtemp, readFile, stat, writeFile } from "fs/promises";
|
|
79
78
|
import { tmpdir } from "os";
|
|
80
79
|
import { basename, join, resolve } from "path";
|
|
80
|
+
import {
|
|
81
|
+
parseCorpusFlag,
|
|
82
|
+
renderVerifiedFindingsSection
|
|
83
|
+
} from "@tangle-network/agent-eval/trajectory-replay";
|
|
81
84
|
import {
|
|
82
85
|
analyzeSupervisorRun,
|
|
83
86
|
findSupervisorRunDirs,
|
|
@@ -683,6 +686,34 @@ async function cmdBundle(args) {
|
|
|
683
686
|
`session bundle (${manifest.view} view) \u2192 ${result.directory} (${manifest.files.length} file(s), ${manifest.ledgerSlices.length} ledger slice(s), ${manifest.absent.length} recorded absent)`
|
|
684
687
|
);
|
|
685
688
|
}
|
|
689
|
+
async function cmdBundleVerify(argv) {
|
|
690
|
+
let dir;
|
|
691
|
+
let format = "text";
|
|
692
|
+
for (let i = 0; i < argv.length; i++) {
|
|
693
|
+
const arg = argv[i];
|
|
694
|
+
if (arg === "--format") format = argv[++i] ?? "";
|
|
695
|
+
else if (arg.startsWith("--")) throw new Error(`bundle verify: unknown flag ${arg}`);
|
|
696
|
+
else if (dir === void 0) dir = arg;
|
|
697
|
+
else throw new Error(`bundle verify: unexpected argument ${arg}`);
|
|
698
|
+
}
|
|
699
|
+
if (!dir) throw new Error("bundle verify needs the bundle directory: traces bundle verify <dir>");
|
|
700
|
+
if (format !== "json" && format !== "text") throw new Error(`bundle verify: --format must be json or text, got "${format}"`);
|
|
701
|
+
const result = await verifySessionBundle(dir);
|
|
702
|
+
if (format === "json") {
|
|
703
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
704
|
+
`);
|
|
705
|
+
} else {
|
|
706
|
+
const lines = [
|
|
707
|
+
`${result.ok ? "VERIFIED" : "FAILED"} ${result.view} bundle ${result.directory}`,
|
|
708
|
+
` ${result.matched}/${result.listed} listed file(s) match their recorded size and SHA-256`,
|
|
709
|
+
...result.issues.map((issue) => ` ${issue.kind.padEnd(11)} ${issue.path}: ${issue.detail}`)
|
|
710
|
+
];
|
|
711
|
+
if (result.source) lines.push(` source bundle manifest: ${result.source.status} (${result.source.directory})`);
|
|
712
|
+
process.stdout.write(`${lines.join("\n")}
|
|
713
|
+
`);
|
|
714
|
+
}
|
|
715
|
+
if (!result.ok) process.exitCode = 1;
|
|
716
|
+
}
|
|
686
717
|
var PROJECTABLE_VIEWS = ["evidence-only"];
|
|
687
718
|
async function cmdBundleView(args) {
|
|
688
719
|
if (!args.input) {
|
|
@@ -863,13 +894,13 @@ async function verifyAnalyzeFindings(args, result) {
|
|
|
863
894
|
throw new Error("analyze --verify-findings: the analysis produced no findings to verify");
|
|
864
895
|
}
|
|
865
896
|
const out = args.verifyOut ?? (args.out ? `${args.out}.verify` : "traces-verify-findings");
|
|
866
|
-
return
|
|
897
|
+
return verifyFindingsInSandbox(result.findings, {
|
|
867
898
|
source: { kind: "corpus", corpora: args.replayCorpora.map(parseCorpusFlag) },
|
|
868
899
|
out,
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
900
|
+
sandbox: {
|
|
901
|
+
apiKey: process.env.SANDBOX_API_KEY ?? "",
|
|
902
|
+
baseUrl: process.env.SANDBOX_API_URL ?? DEFAULT_SANDBOX_BASE_URL
|
|
903
|
+
}
|
|
873
904
|
});
|
|
874
905
|
}
|
|
875
906
|
async function cmdAnalyzeSupervisorRun(runDir, args) {
|
|
@@ -1427,6 +1458,11 @@ Commands:
|
|
|
1427
1458
|
ledger sliced to the session window, git log, and a sha256 manifest
|
|
1428
1459
|
(needs --session <id|path> and --out <new-dir>). This is the FULL
|
|
1429
1460
|
view: it holds the session's own words, for a reader who cites them
|
|
1461
|
+
bundle verify <bundle-dir>
|
|
1462
|
+
Check a bundle against its manifest: every listed file present with
|
|
1463
|
+
its recorded size and SHA-256, no unlisted or non-regular file beside
|
|
1464
|
+
them, and for a view, the source manifest it was projected from.
|
|
1465
|
+
Exit 1 on any difference (--format text|json)
|
|
1430
1466
|
bundle-view <bundle-dir>
|
|
1431
1467
|
Project an assembled bundle into a narrower view for a consumer that
|
|
1432
1468
|
must NOT read the session's own words. --view evidence-only carries
|
|
@@ -1564,6 +1600,10 @@ async function main() {
|
|
|
1564
1600
|
await cmdVerifyFindings(rawArgs.slice(1));
|
|
1565
1601
|
return;
|
|
1566
1602
|
}
|
|
1603
|
+
if (rawArgs[0] === "bundle" && rawArgs[1] === "verify") {
|
|
1604
|
+
await cmdBundleVerify(rawArgs.slice(2));
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1567
1607
|
const parsedArgs = parseArgs(rawArgs);
|
|
1568
1608
|
if (parsedArgs.help) {
|
|
1569
1609
|
if (parsedArgs.command === "import-codetracebench" || parsedArgs.command === "help" && parsedArgs.input === "import-codetracebench") usageImportCodeTraceBench();
|