@tangle-network/traces 0.10.3 → 0.11.2

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/dist/index.js CHANGED
@@ -2,8 +2,10 @@ import {
2
2
  ACTOR_ATTR,
3
3
  ATTR,
4
4
  AmpAdapter,
5
+ BLOBS_DIR,
5
6
  CODING_REDACTION_RULES,
6
7
  CONTENT_CAP,
8
+ COORDINATION_LOG_FILE,
7
9
  CORRECTIVE_REACTIONS,
8
10
  ClaudeAdapter,
9
11
  CodexAdapter,
@@ -12,6 +14,8 @@ import {
12
14
  CodexTaskScopeError,
13
15
  CopilotAdapter,
14
16
  DEFAULT_HARNESS,
17
+ EMPTY_SPAN_RUN_SNAPSHOT,
18
+ EXPORT_RULE,
15
19
  EmptySessionError,
16
20
  FactoryAdapter,
17
21
  ForgeAdapter,
@@ -24,23 +28,34 @@ import {
24
28
  PiAdapter,
25
29
  QwenAdapter,
26
30
  REACTIONS,
31
+ RESULT_FILE,
32
+ RULE,
33
+ SPAWN_JOURNAL_FILE,
34
+ STATUS_MARK,
35
+ SandboxCounterfactualRunner,
27
36
  SessionWorkflowError,
28
37
  TRACES_REDACTION_RULES,
38
+ ZERO_ROLL,
39
+ addSpend,
29
40
  alreadyUploaded,
30
41
  analyzeAdoption,
31
42
  analyzeLiveBatch,
43
+ analyzeLoopConvergence,
32
44
  analyzeReactions,
33
45
  analyzeSpans,
46
+ analyzeSteeringChain,
34
47
  applyRedactor,
35
48
  buildPolicyEvidenceRecord,
36
49
  buildSessionIndex,
37
50
  buildSessionIndexFromRows,
51
+ buildSpanRunTree,
38
52
  buildTraceFindingPacket,
39
53
  capText,
40
54
  chatTrajectoryToSpans,
41
55
  classifyLiveActions,
42
56
  classifyReaction,
43
57
  claudeActor,
58
+ cmdReplayVerify,
44
59
  codexActor,
45
60
  collectPolicyEvidence,
46
61
  collectSessionIndex,
@@ -48,51 +63,88 @@ import {
48
63
  collectSessionWorkflow,
49
64
  commandAnalyzer,
50
65
  commandRedactor,
66
+ conformanceOfSpans,
67
+ connectors,
51
68
  countSkillRunsJsonl,
52
69
  cwdMatchesSelection,
53
70
  defaultTraceLiveAnalysts,
71
+ deriveFailureSignature,
54
72
  describeSessionRelationship,
55
73
  equivalentGitCwds,
56
74
  executeUpload,
57
75
  exportTraceEvidenceFile,
58
76
  exportTraceEvidenceRows,
59
77
  exportTraceEvidenceText,
78
+ fileRunContextSupervisorRunReader,
79
+ findSpanSourceFiles,
80
+ forEachTreeNode,
60
81
  haloAnalyzer,
61
82
  hodoscopeAnalyzer,
62
83
  importCodeTraceBench,
84
+ incompleteInputsNote,
63
85
  indexSessionIdsByTrace,
86
+ inferRole,
87
+ inferSpanKind,
88
+ ingestCodeTraceBenchSteps,
64
89
  inspectSessionIndex,
90
+ int,
65
91
  isChatTrajectory,
66
92
  isChatTrajectoryMessage,
93
+ isFileRunContextDir,
67
94
  knownHarnesses,
68
95
  listAdapters,
69
96
  loadState,
70
97
  loadTracesConfig,
71
98
  locateSessions,
72
99
  looksLikeAgentPrompt,
100
+ mergeRolls,
73
101
  mergeTracesConfig,
102
+ ms,
74
103
  normalizeRemote,
104
+ otlpRowToSpan,
75
105
  outboundHash,
76
106
  parseIsoToEpochMs,
107
+ parseObservationOutput,
108
+ parseRecordedReturncode,
109
+ parseReplayVerifyArgs,
77
110
  parseSession,
78
111
  parseSince,
79
112
  planTraceAgenticRoute,
80
113
  planUpload,
114
+ readCoordinationLog,
115
+ readFileRunContext,
81
116
  readJsonFile,
82
117
  readJsonl,
118
+ readOtlpInput,
119
+ readRunContextJournal,
120
+ readRunContextSnapshot,
121
+ readRunWatchSnapshot,
83
122
  readSessionIndexFile,
123
+ readSpanRunSnapshot,
84
124
  recordSessionCorruption,
85
125
  redactSpans,
126
+ renderConformance,
86
127
  renderInspectionReport,
128
+ renderRunContextSnapshot,
129
+ renderRunWatchSnapshot,
130
+ renderSpanRunSnapshot,
131
+ renderValidation,
132
+ replayVerify,
133
+ replayVerifyUsage,
87
134
  resolveAdapter,
135
+ resolveOtlpInputFiles,
88
136
  resolveRepoAttrs,
137
+ resolveRunContextDir,
138
+ resolveRunWatchTarget,
89
139
  resolveSessionRepoAttrs,
90
140
  runCommand,
91
141
  runExternalAnalyzers,
92
142
  runPipelines,
143
+ runTotals,
93
144
  runTraceImprovement,
94
145
  runTraceInvestigation,
95
146
  runTraceStoreInvestigation,
147
+ sandboxReplayBackend,
96
148
  saveReport,
97
149
  saveState,
98
150
  scanSessions,
@@ -105,7 +157,9 @@ import {
105
157
  sessionHash,
106
158
  sessionIdFromAttributes,
107
159
  sessionIntegrityAttributes,
160
+ skippedAnalyses,
108
161
  span,
162
+ spanRunTotals,
109
163
  stampRepoAttrs,
110
164
  stampSessionIdentity,
111
165
  stampSessionIntegrity,
@@ -113,26 +167,35 @@ import {
113
167
  streamSessions,
114
168
  summarizeOtlpExecution,
115
169
  summarizeSpanExecution,
170
+ summarizeSpanStructure,
116
171
  takeJsonl,
117
172
  textIsSynthetic,
118
173
  toOpenInferenceSpan,
119
174
  toRuntimeStore,
120
175
  toTraceSpanEvents,
176
+ tokens,
121
177
  totalAgenticFailureMessage,
122
178
  traceAgenticKinds,
123
179
  traceStreamEventsFromSpans,
180
+ unavailableCapabilities,
124
181
  uploadKey,
182
+ usd,
125
183
  userPromptSpan,
126
184
  validateOtlpSpans,
185
+ validationExitCode,
186
+ watchRunTarget,
127
187
  watchSessions,
188
+ wrap,
189
+ wrapActionForExec,
128
190
  writeHodoscopeInput,
129
191
  writeInspectionReportFile,
130
192
  writeOtlpFile,
131
193
  writePolicyEvidenceFile,
132
194
  writeSessionIndexFile,
133
195
  writeTraceEvidenceExportFile,
134
- writeTraceImprovementArtifacts
135
- } from "./chunk-LC66I5TE.js";
196
+ writeTraceImprovementArtifacts,
197
+ zeroPricedCost
198
+ } from "./chunk-UY3M7XUF.js";
136
199
 
137
200
  // src/collect.ts
138
201
  async function collectSessions(opts = {}) {
@@ -161,8 +224,10 @@ export {
161
224
  ATTR,
162
225
  AmpAdapter,
163
226
  AnalystRegistry,
227
+ BLOBS_DIR,
164
228
  CODING_REDACTION_RULES,
165
229
  CONTENT_CAP,
230
+ COORDINATION_LOG_FILE,
166
231
  CORRECTIVE_REACTIONS,
167
232
  ClaudeAdapter,
168
233
  CodexAdapter,
@@ -172,6 +237,8 @@ export {
172
237
  CopilotAdapter,
173
238
  DEFAULT_HARNESS,
174
239
  DEFAULT_REDACTION_RULES,
240
+ EMPTY_SPAN_RUN_SNAPSHOT,
241
+ EXPORT_RULE,
175
242
  EmptySessionError,
176
243
  FactoryAdapter,
177
244
  ForgeAdapter,
@@ -184,24 +251,35 @@ export {
184
251
  PiAdapter,
185
252
  QwenAdapter,
186
253
  REACTIONS,
254
+ RESULT_FILE,
255
+ RULE,
256
+ SPAWN_JOURNAL_FILE,
257
+ STATUS_MARK,
258
+ SandboxCounterfactualRunner,
187
259
  SessionWorkflowError,
188
260
  TRACES_REDACTION_RULES,
261
+ ZERO_ROLL,
262
+ addSpend,
189
263
  alreadyUploaded,
190
264
  analyzeAdoption,
191
265
  analyzeLiveBatch,
266
+ analyzeLoopConvergence,
192
267
  analyzeReactions,
193
268
  analyzeSpans,
269
+ analyzeSteeringChain,
194
270
  applyRedactor,
195
271
  buildDefaultAnalystRegistry,
196
272
  buildPolicyEvidenceRecord,
197
273
  buildSessionIndex,
198
274
  buildSessionIndexFromRows,
275
+ buildSpanRunTree,
199
276
  buildTraceFindingPacket,
200
277
  capText,
201
278
  chatTrajectoryToSpans,
202
279
  classifyLiveActions,
203
280
  classifyReaction,
204
281
  claudeActor,
282
+ cmdReplayVerify,
205
283
  codexActor,
206
284
  collectPolicyEvidence,
207
285
  collectSessionIndex,
@@ -210,24 +288,36 @@ export {
210
288
  collectSessions,
211
289
  commandAnalyzer,
212
290
  commandRedactor,
291
+ conformanceOfSpans,
292
+ connectors,
213
293
  countSkillRunsJsonl,
214
294
  createHostedClient,
215
295
  cwdMatchesSelection,
216
296
  defaultTraceLiveAnalysts,
297
+ deriveFailureSignature,
217
298
  describeSessionRelationship,
218
299
  equivalentGitCwds,
219
300
  executeUpload,
220
301
  exportTraceEvidenceFile,
221
302
  exportTraceEvidenceRows,
222
303
  exportTraceEvidenceText,
304
+ fileRunContextSupervisorRunReader,
305
+ findSpanSourceFiles,
306
+ forEachTreeNode,
223
307
  haloAnalyzer,
224
308
  hodoscopeAnalyzer,
225
309
  hostedClientFromEnv,
226
310
  importCodeTraceBench,
311
+ incompleteInputsNote,
227
312
  indexSessionIdsByTrace,
313
+ inferRole,
314
+ inferSpanKind,
315
+ ingestCodeTraceBenchSteps,
228
316
  inspectSessionIndex,
317
+ int,
229
318
  isChatTrajectory,
230
319
  isChatTrajectoryMessage,
320
+ isFileRunContextDir,
231
321
  knownHarnesses,
232
322
  listAdapters,
233
323
  loadState,
@@ -235,31 +325,56 @@ export {
235
325
  locateSessions,
236
326
  looksLikeAgentPrompt,
237
327
  makeFinding,
328
+ mergeRolls,
238
329
  mergeTracesConfig,
330
+ ms,
239
331
  normalizeRemote,
332
+ otlpRowToSpan,
240
333
  outboundHash,
241
334
  parseIsoToEpochMs,
335
+ parseObservationOutput,
336
+ parseRecordedReturncode,
337
+ parseReplayVerifyArgs,
242
338
  parseSession,
243
339
  parseSince,
244
340
  planTraceAgenticRoute,
245
341
  planUpload,
342
+ readCoordinationLog,
343
+ readFileRunContext,
246
344
  readJsonFile,
247
345
  readJsonl,
346
+ readOtlpInput,
347
+ readRunContextJournal,
348
+ readRunContextSnapshot,
349
+ readRunWatchSnapshot,
248
350
  readSessionIndexFile,
351
+ readSpanRunSnapshot,
249
352
  recordSessionCorruption,
250
353
  redactSpans,
251
354
  redactString,
252
355
  redactValue,
356
+ renderConformance,
253
357
  renderInspectionReport,
358
+ renderRunContextSnapshot,
359
+ renderRunWatchSnapshot,
360
+ renderSpanRunSnapshot,
361
+ renderValidation,
362
+ replayVerify,
363
+ replayVerifyUsage,
254
364
  resolveAdapter,
365
+ resolveOtlpInputFiles,
255
366
  resolveRepoAttrs,
367
+ resolveRunContextDir,
368
+ resolveRunWatchTarget,
256
369
  resolveSessionRepoAttrs,
257
370
  runCommand,
258
371
  runExternalAnalyzers,
259
372
  runPipelines,
373
+ runTotals,
260
374
  runTraceImprovement,
261
375
  runTraceInvestigation,
262
376
  runTraceStoreInvestigation,
377
+ sandboxReplayBackend,
263
378
  saveReport,
264
379
  saveState,
265
380
  scanSessions,
@@ -272,7 +387,9 @@ export {
272
387
  sessionHash,
273
388
  sessionIdFromAttributes,
274
389
  sessionIntegrityAttributes,
390
+ skippedAnalyses,
275
391
  span,
392
+ spanRunTotals,
276
393
  stampRepoAttrs,
277
394
  stampSessionIdentity,
278
395
  stampSessionIntegrity,
@@ -280,23 +397,32 @@ export {
280
397
  streamSessions,
281
398
  summarizeOtlpExecution,
282
399
  summarizeSpanExecution,
400
+ summarizeSpanStructure,
283
401
  takeJsonl,
284
402
  textIsSynthetic,
285
403
  toOpenInferenceSpan,
286
404
  toRuntimeStore,
287
405
  toTraceSpanEvents,
406
+ tokens,
288
407
  totalAgenticFailureMessage,
289
408
  traceAgenticKinds,
290
409
  traceStreamEventsFromSpans,
410
+ unavailableCapabilities,
291
411
  uploadKey,
412
+ usd,
292
413
  userPromptSpan,
293
414
  validateOtlpSpans,
415
+ validationExitCode,
416
+ watchRunTarget,
294
417
  watchSessions,
418
+ wrap,
419
+ wrapActionForExec,
295
420
  writeHodoscopeInput,
296
421
  writeInspectionReportFile,
297
422
  writeOtlpFile,
298
423
  writePolicyEvidenceFile,
299
424
  writeSessionIndexFile,
300
425
  writeTraceEvidenceExportFile,
301
- writeTraceImprovementArtifacts
426
+ writeTraceImprovementArtifacts,
427
+ zeroPricedCost
302
428
  };
@@ -0,0 +1,55 @@
1
+ # replay-verify — executed proofs for trajectory findings
2
+
3
+ An analyst finding today is a cited claim: "step 37 is where the run went wrong."
4
+ `traces replay-verify` upgrades that claim to an executed proof: it replays the trajectory prefix inside a real sandbox on the trajectory's own docker image, then runs two counterfactual arms at the error-critical step k:
5
+
6
+ - **Arm A** re-executes the recorded step k and checks the recorded failure reproduces — same returncode plus a stable output substring (the failure signature).
7
+ - **Arm B** executes a corrected step k and checks the failure vanishes (exit 0 and the signature absent).
8
+
9
+ Each arm gets a fresh sandbox with its own prefix replay, so arm B is never contaminated by arm A's side effects.
10
+ Under the hood each arm is an agent-eval `runCounterfactual` meta-run (`layer='meta'`, `parentRunId` = the ingested trajectory run), with the sandbox-backed `CounterfactualRunner` from `src/replay-verify.ts` supplying the `executeFrom` callback that scaffold leaves to consumers.
11
+
12
+ ## Usage
13
+
14
+ ```sh
15
+ traces replay-verify \
16
+ --steps normalized/<traj_id>/steps.json \
17
+ --image <docker_config.base_image> \
18
+ --at 37 \
19
+ --cwd /home \
20
+ --fix-command "sed -i '145d' /home/zstd/programs/zstdcli.c && make -C /home/zstd zstd -j2 V=1" \
21
+ --signature 'undeclared (first use in this function)' \
22
+ --out ./replay-out \
23
+ --base-url http://127.0.0.1:4097 --api-key-env SANDBOX_API_KEY
24
+ ```
25
+
26
+ Outputs `replay-verdict.json` (machine-readable: prefix divergences, both arms, timings, run ids) and `report.md` (human-readable with real stdout/stderr excerpts).
27
+ `traces replay-verify --help` lists every flag.
28
+
29
+ ## Execution semantics
30
+
31
+ Every step runs the way mini-SWE ran it: a fresh `/bin/sh` subshell from a fixed workdir.
32
+ The action is base64-piped into `sh` after `cd`-ing to `--cwd`, so arbitrary quoting in recorded actions survives, and the reported exit code is the action's own.
33
+
34
+ Prefix divergences (recorded returncode ≠ replayed exit) are recorded per step, never abort the replay, and are surfaced in the verdict.
35
+ A high divergence rate is a finding about replayability, not a failure of the tool.
36
+
37
+ ## Honest limits
38
+
39
+ - **Only SWE-style trajectories are replayable.** The docker image comes from the raw trajectory's `info.docker_config.base_image`; terminal-bench-style tasks that need external compose peers (databases, services) cannot be replayed with a single image.
40
+ - **Commands never run as root.** The sandbox platform pins every customer command to the configured non-root subprocess identity (uid 1000 by default) — a deliberate security invariant with no override. Trajectories recorded as root (mini-SWE's default) will hit permission errors on root-owned trees. Fix by deriving a replay image that chowns the working tree to the sandbox uid:
41
+
42
+ ```dockerfile
43
+ FROM mswebench/facebook_m_zstd:pr-1733
44
+ RUN chown -R 1000:1000 /home
45
+ ```
46
+
47
+ This preserves the recorded failure semantics for build/edit workflows (they depend on writability, not on uid 0). The verdict records the image actually used.
48
+ - **Copy-on-write forks are firecracker-only.** `box.branch()` could replay the prefix once and fork at k; on the docker driver each arm replays the prefix in its own fresh sandbox instead. Wall-time cost is one extra prefix replay per arm.
49
+ - **Environment drift shows up as divergence.** The sandbox mounts a workspace at `/home/agent` and injects platform env; recorded observations that depend on exact `ls` output or env contents can differ while returncodes still match. Only returncodes drive the divergence count.
50
+ - **The failure signature is derived, not assumed.** Default: the first recorded-output line containing "error". Compiler quote glyphs vary with locale, so prefer an explicit `--signature` with an ASCII-stable substring.
51
+
52
+ ## Orchestrator prerequisites
53
+
54
+ replay-verify talks to a sandbox API (`--base-url`); in local development that is the sandbox SDK adapter in front of an orchestrator running the docker driver.
55
+ Arbitrary docker images need the platform control runtime (node injected from a mounted Nix profile) because sidecar-less images rarely ship node: the orchestrator needs `NIX_PROFILE_PATH` set, and this CLI passes the `SIDECAR_PLATFORM_CONTROL_RUNTIME` container-env marker on create (the production sandbox API derives the same marker from `agent: false`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/traces",
3
- "version": "0.10.3",
3
+ "version": "0.11.2",
4
4
  "description": "Point it at your coding-agent session traces (Claude Code, Codex, OpenCode, Gemini, Pi, …) and get failure-mode + efficiency findings. CLI + SDK over the @tangle-network/agent-eval analyst suite — observe live sessions, run your own analysts, redact, and upload to the Tangle Intelligence Platform.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -47,7 +47,10 @@
47
47
  "node": ">=22"
48
48
  },
49
49
  "dependencies": {
50
- "@tangle-network/agent-eval": "0.140.0"
50
+ "@tangle-network/agent-eval": "0.140.1",
51
+ "@tangle-network/agent-runtime": "0.120.0",
52
+ "@tangle-network/agent-trace-contract": "^1.0.2",
53
+ "@tangle-network/sandbox": "0.15.2"
51
54
  },
52
55
  "devDependencies": {
53
56
  "@types/node": "^22.0.0",
@@ -62,6 +65,7 @@
62
65
  "dev": "tsx src/cli.ts",
63
66
  "build": "tsup src/index.ts src/cli.ts --format esm --target node22 --clean --dts",
64
67
  "check:package": "node scripts/check-package-bin.mjs",
68
+ "check:source": "node scripts/check-source-text.mjs",
65
69
  "test": "vitest run",
66
70
  "test:watch": "vitest",
67
71
  "typecheck": "tsc --noEmit"
@@ -8,6 +8,34 @@ description: Inspect real agent workflows with the published Traces CLI and expo
8
8
  Use the deterministic CLI first.
9
9
  Keep inspection local and read-only.
10
10
 
11
+ ## Choose the way in
12
+
13
+ If the trace is already OTLP (a system that emits `@tangle-network/agent-trace-contract`
14
+ spans, or any conforming exporter), read it directly. No adapter is involved.
15
+
16
+ ```bash
17
+ traces validate spans.otlp.jsonl # what can this trace answer? exit 1 on error findings
18
+ traces analyze --otlp spans.otlp.jsonl --out .traces/current.md
19
+ traces analyze --otlp results/sessions --out .traces/all.md # a directory of exports
20
+ ```
21
+
22
+ Use `--harness` only for coding agents whose on-disk format we do not control.
23
+ Those adapters are the legacy edge, not the way to integrate a system you own.
24
+
25
+ A directory is a run directory: it holds the span export beside raw event, stream and
26
+ SDK logs that are also `*.jsonl`. Only the OTLP files are read, and the rest are listed
27
+ with what they actually hold. An `otlp/` subdirectory, when the producer made one, is
28
+ read on its own.
29
+
30
+ Any section headed `inputs incomplete`, or carrying an `Inputs incomplete` line above
31
+ its table, is computed from a field the trace does not carry everywhere. Report those
32
+ numbers as uncaptured, never as zero spend. The `trace conformance` section at the top
33
+ names every such capability once; the markers repeat it where the number actually is.
34
+
35
+ For a loop trace, read `round-over-round convergence` (did round N+1 improve on N) and
36
+ `steering chain` (which verdict caused which retry) before drawing any conclusion about
37
+ whether the agent was making progress.
38
+
11
39
  ## Select the workflow
12
40
 
13
41
  ```bash
@@ -32,7 +60,7 @@ Write normalized OpenInference spans for another tool:
32
60
 
33
61
  ```bash
34
62
  traces convert --harness codex --current --latest-turn --workflow \
35
- --otlp .traces/current.otlp.jsonl
63
+ --otlp-out .traces/current.otlp.jsonl
36
64
  ```
37
65
 
38
66
  Write the complete deterministic review packet:
@@ -47,7 +75,8 @@ It does not edit an agent, repository, memory store, or knowledge base.
47
75
 
48
76
  ## Report
49
77
 
50
- - State the harness, selected task boundary, session and span counts, and integrity warnings.
78
+ - State the source (`--otlp <path>` or the harness), selected task boundary, session and span counts, and integrity warnings.
79
+ - State which capabilities the trace could not support, and name the analyses that reported nothing because of it.
51
80
  - Cite each finding with its exact `trace://` reference.
52
81
  - Mark missing outcome, cost, token, skill, or relationship data as unknown.
53
82
  - Do not infer task success from a completion message.