@tangle-network/traces 0.11.0 → 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
@@ -15,6 +15,7 @@ import {
15
15
  CopilotAdapter,
16
16
  DEFAULT_HARNESS,
17
17
  EMPTY_SPAN_RUN_SNAPSHOT,
18
+ EXPORT_RULE,
18
19
  EmptySessionError,
19
20
  FactoryAdapter,
20
21
  ForgeAdapter,
@@ -31,6 +32,7 @@ import {
31
32
  RULE,
32
33
  SPAWN_JOURNAL_FILE,
33
34
  STATUS_MARK,
35
+ SandboxCounterfactualRunner,
34
36
  SessionWorkflowError,
35
37
  TRACES_REDACTION_RULES,
36
38
  ZERO_ROLL,
@@ -38,8 +40,10 @@ import {
38
40
  alreadyUploaded,
39
41
  analyzeAdoption,
40
42
  analyzeLiveBatch,
43
+ analyzeLoopConvergence,
41
44
  analyzeReactions,
42
45
  analyzeSpans,
46
+ analyzeSteeringChain,
43
47
  applyRedactor,
44
48
  buildPolicyEvidenceRecord,
45
49
  buildSessionIndex,
@@ -51,6 +55,7 @@ import {
51
55
  classifyLiveActions,
52
56
  classifyReaction,
53
57
  claudeActor,
58
+ cmdReplayVerify,
54
59
  codexActor,
55
60
  collectPolicyEvidence,
56
61
  collectSessionIndex,
@@ -58,10 +63,12 @@ import {
58
63
  collectSessionWorkflow,
59
64
  commandAnalyzer,
60
65
  commandRedactor,
66
+ conformanceOfSpans,
61
67
  connectors,
62
68
  countSkillRunsJsonl,
63
69
  cwdMatchesSelection,
64
70
  defaultTraceLiveAnalysts,
71
+ deriveFailureSignature,
65
72
  describeSessionRelationship,
66
73
  equivalentGitCwds,
67
74
  executeUpload,
@@ -74,8 +81,11 @@ import {
74
81
  haloAnalyzer,
75
82
  hodoscopeAnalyzer,
76
83
  importCodeTraceBench,
84
+ incompleteInputsNote,
77
85
  indexSessionIdsByTrace,
78
86
  inferRole,
87
+ inferSpanKind,
88
+ ingestCodeTraceBenchSteps,
79
89
  inspectSessionIndex,
80
90
  int,
81
91
  isChatTrajectory,
@@ -91,8 +101,12 @@ import {
91
101
  mergeTracesConfig,
92
102
  ms,
93
103
  normalizeRemote,
104
+ otlpRowToSpan,
94
105
  outboundHash,
95
106
  parseIsoToEpochMs,
107
+ parseObservationOutput,
108
+ parseRecordedReturncode,
109
+ parseReplayVerifyArgs,
96
110
  parseSession,
97
111
  parseSince,
98
112
  planTraceAgenticRoute,
@@ -101,6 +115,7 @@ import {
101
115
  readFileRunContext,
102
116
  readJsonFile,
103
117
  readJsonl,
118
+ readOtlpInput,
104
119
  readRunContextJournal,
105
120
  readRunContextSnapshot,
106
121
  readRunWatchSnapshot,
@@ -108,11 +123,16 @@ import {
108
123
  readSpanRunSnapshot,
109
124
  recordSessionCorruption,
110
125
  redactSpans,
126
+ renderConformance,
111
127
  renderInspectionReport,
112
128
  renderRunContextSnapshot,
113
129
  renderRunWatchSnapshot,
114
130
  renderSpanRunSnapshot,
131
+ renderValidation,
132
+ replayVerify,
133
+ replayVerifyUsage,
115
134
  resolveAdapter,
135
+ resolveOtlpInputFiles,
116
136
  resolveRepoAttrs,
117
137
  resolveRunContextDir,
118
138
  resolveRunWatchTarget,
@@ -124,6 +144,7 @@ import {
124
144
  runTraceImprovement,
125
145
  runTraceInvestigation,
126
146
  runTraceStoreInvestigation,
147
+ sandboxReplayBackend,
127
148
  saveReport,
128
149
  saveState,
129
150
  scanSessions,
@@ -136,6 +157,7 @@ import {
136
157
  sessionHash,
137
158
  sessionIdFromAttributes,
138
159
  sessionIntegrityAttributes,
160
+ skippedAnalyses,
139
161
  span,
140
162
  spanRunTotals,
141
163
  stampRepoAttrs,
@@ -145,6 +167,7 @@ import {
145
167
  streamSessions,
146
168
  summarizeOtlpExecution,
147
169
  summarizeSpanExecution,
170
+ summarizeSpanStructure,
148
171
  takeJsonl,
149
172
  textIsSynthetic,
150
173
  toOpenInferenceSpan,
@@ -154,13 +177,16 @@ import {
154
177
  totalAgenticFailureMessage,
155
178
  traceAgenticKinds,
156
179
  traceStreamEventsFromSpans,
180
+ unavailableCapabilities,
157
181
  uploadKey,
158
182
  usd,
159
183
  userPromptSpan,
160
184
  validateOtlpSpans,
185
+ validationExitCode,
161
186
  watchRunTarget,
162
187
  watchSessions,
163
188
  wrap,
189
+ wrapActionForExec,
164
190
  writeHodoscopeInput,
165
191
  writeInspectionReportFile,
166
192
  writeOtlpFile,
@@ -169,7 +195,7 @@ import {
169
195
  writeTraceEvidenceExportFile,
170
196
  writeTraceImprovementArtifacts,
171
197
  zeroPricedCost
172
- } from "./chunk-JCI5YXNT.js";
198
+ } from "./chunk-UY3M7XUF.js";
173
199
 
174
200
  // src/collect.ts
175
201
  async function collectSessions(opts = {}) {
@@ -212,6 +238,7 @@ export {
212
238
  DEFAULT_HARNESS,
213
239
  DEFAULT_REDACTION_RULES,
214
240
  EMPTY_SPAN_RUN_SNAPSHOT,
241
+ EXPORT_RULE,
215
242
  EmptySessionError,
216
243
  FactoryAdapter,
217
244
  ForgeAdapter,
@@ -228,6 +255,7 @@ export {
228
255
  RULE,
229
256
  SPAWN_JOURNAL_FILE,
230
257
  STATUS_MARK,
258
+ SandboxCounterfactualRunner,
231
259
  SessionWorkflowError,
232
260
  TRACES_REDACTION_RULES,
233
261
  ZERO_ROLL,
@@ -235,8 +263,10 @@ export {
235
263
  alreadyUploaded,
236
264
  analyzeAdoption,
237
265
  analyzeLiveBatch,
266
+ analyzeLoopConvergence,
238
267
  analyzeReactions,
239
268
  analyzeSpans,
269
+ analyzeSteeringChain,
240
270
  applyRedactor,
241
271
  buildDefaultAnalystRegistry,
242
272
  buildPolicyEvidenceRecord,
@@ -249,6 +279,7 @@ export {
249
279
  classifyLiveActions,
250
280
  classifyReaction,
251
281
  claudeActor,
282
+ cmdReplayVerify,
252
283
  codexActor,
253
284
  collectPolicyEvidence,
254
285
  collectSessionIndex,
@@ -257,11 +288,13 @@ export {
257
288
  collectSessions,
258
289
  commandAnalyzer,
259
290
  commandRedactor,
291
+ conformanceOfSpans,
260
292
  connectors,
261
293
  countSkillRunsJsonl,
262
294
  createHostedClient,
263
295
  cwdMatchesSelection,
264
296
  defaultTraceLiveAnalysts,
297
+ deriveFailureSignature,
265
298
  describeSessionRelationship,
266
299
  equivalentGitCwds,
267
300
  executeUpload,
@@ -275,8 +308,11 @@ export {
275
308
  hodoscopeAnalyzer,
276
309
  hostedClientFromEnv,
277
310
  importCodeTraceBench,
311
+ incompleteInputsNote,
278
312
  indexSessionIdsByTrace,
279
313
  inferRole,
314
+ inferSpanKind,
315
+ ingestCodeTraceBenchSteps,
280
316
  inspectSessionIndex,
281
317
  int,
282
318
  isChatTrajectory,
@@ -293,8 +329,12 @@ export {
293
329
  mergeTracesConfig,
294
330
  ms,
295
331
  normalizeRemote,
332
+ otlpRowToSpan,
296
333
  outboundHash,
297
334
  parseIsoToEpochMs,
335
+ parseObservationOutput,
336
+ parseRecordedReturncode,
337
+ parseReplayVerifyArgs,
298
338
  parseSession,
299
339
  parseSince,
300
340
  planTraceAgenticRoute,
@@ -303,6 +343,7 @@ export {
303
343
  readFileRunContext,
304
344
  readJsonFile,
305
345
  readJsonl,
346
+ readOtlpInput,
306
347
  readRunContextJournal,
307
348
  readRunContextSnapshot,
308
349
  readRunWatchSnapshot,
@@ -312,11 +353,16 @@ export {
312
353
  redactSpans,
313
354
  redactString,
314
355
  redactValue,
356
+ renderConformance,
315
357
  renderInspectionReport,
316
358
  renderRunContextSnapshot,
317
359
  renderRunWatchSnapshot,
318
360
  renderSpanRunSnapshot,
361
+ renderValidation,
362
+ replayVerify,
363
+ replayVerifyUsage,
319
364
  resolveAdapter,
365
+ resolveOtlpInputFiles,
320
366
  resolveRepoAttrs,
321
367
  resolveRunContextDir,
322
368
  resolveRunWatchTarget,
@@ -328,6 +374,7 @@ export {
328
374
  runTraceImprovement,
329
375
  runTraceInvestigation,
330
376
  runTraceStoreInvestigation,
377
+ sandboxReplayBackend,
331
378
  saveReport,
332
379
  saveState,
333
380
  scanSessions,
@@ -340,6 +387,7 @@ export {
340
387
  sessionHash,
341
388
  sessionIdFromAttributes,
342
389
  sessionIntegrityAttributes,
390
+ skippedAnalyses,
343
391
  span,
344
392
  spanRunTotals,
345
393
  stampRepoAttrs,
@@ -349,6 +397,7 @@ export {
349
397
  streamSessions,
350
398
  summarizeOtlpExecution,
351
399
  summarizeSpanExecution,
400
+ summarizeSpanStructure,
352
401
  takeJsonl,
353
402
  textIsSynthetic,
354
403
  toOpenInferenceSpan,
@@ -358,13 +407,16 @@ export {
358
407
  totalAgenticFailureMessage,
359
408
  traceAgenticKinds,
360
409
  traceStreamEventsFromSpans,
410
+ unavailableCapabilities,
361
411
  uploadKey,
362
412
  usd,
363
413
  userPromptSpan,
364
414
  validateOtlpSpans,
415
+ validationExitCode,
365
416
  watchRunTarget,
366
417
  watchSessions,
367
418
  wrap,
419
+ wrapActionForExec,
368
420
  writeHodoscopeInput,
369
421
  writeInspectionReportFile,
370
422
  writeOtlpFile,
@@ -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.11.0",
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,8 +47,9 @@
47
47
  "node": ">=22"
48
48
  },
49
49
  "dependencies": {
50
- "@tangle-network/agent-eval": "0.140.0",
51
- "@tangle-network/agent-runtime": "0.116.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",
52
53
  "@tangle-network/sandbox": "0.15.2"
53
54
  },
54
55
  "devDependencies": {
@@ -64,6 +65,7 @@
64
65
  "dev": "tsx src/cli.ts",
65
66
  "build": "tsup src/index.ts src/cli.ts --format esm --target node22 --clean --dts",
66
67
  "check:package": "node scripts/check-package-bin.mjs",
68
+ "check:source": "node scripts/check-source-text.mjs",
67
69
  "test": "vitest run",
68
70
  "test:watch": "vitest",
69
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.