@tangle-network/traces 0.11.5 → 0.12.0

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
@@ -25,6 +25,7 @@ import {
25
25
  JsonSourceError,
26
26
  JsonlParseError,
27
27
  OpencodeAdapter,
28
+ POLICY_EVIDENCE_NOTE,
28
29
  PartialUploadError,
29
30
  PiAdapter,
30
31
  QwenAdapter,
@@ -47,6 +48,7 @@ import {
47
48
  analyzeSpans,
48
49
  analyzeSteeringChain,
49
50
  applyRedactor,
51
+ assembleSessionBundle,
50
52
  assertSandboxReachable,
51
53
  buildFixPrompt,
52
54
  buildPolicyEvidenceRecord,
@@ -57,6 +59,8 @@ import {
57
59
  buildTraceFindingPacket,
58
60
  capText,
59
61
  chatTrajectoryToSpans,
62
+ classifyEvidenceOnlyPath,
63
+ classifyFailureFollowUps,
60
64
  classifyLiveActions,
61
65
  classifyReaction,
62
66
  classifyVerdict,
@@ -77,12 +81,15 @@ import {
77
81
  countScriptCommands,
78
82
  countSkillRunsJsonl,
79
83
  cwdMatchesSelection,
84
+ cwdMatchesSelectionResolved,
80
85
  defaultTraceLiveAnalysts,
81
86
  deriveFailureSignature,
82
87
  derivedImageTag,
83
88
  describeSessionRelationship,
84
89
  dockerImagePreparer,
85
90
  enumerateReplayableCases,
91
+ environmentAttributes,
92
+ environmentFromSpanAttributes,
86
93
  equivalentGitCwds,
87
94
  executeUpload,
88
95
  exportTraceEvidenceFile,
@@ -90,6 +97,8 @@ import {
90
97
  exportTraceEvidenceText,
91
98
  extractFixCommand,
92
99
  fileRunContextSupervisorRunReader,
100
+ findContextRoot,
101
+ findSessionTextLeaks,
93
102
  findSpanSourceFiles,
94
103
  findingReplayStep,
95
104
  findingTrajectoryId,
@@ -97,7 +106,9 @@ import {
97
106
  generateFixCommand,
98
107
  goldIncorrectSteps,
99
108
  haloAnalyzer,
109
+ hashSessionBundleFiles,
100
110
  hodoscopeAnalyzer,
111
+ httpJsonTransport,
101
112
  importCodeTraceBench,
102
113
  incompleteInputsNote,
103
114
  indexSessionIdsByTrace,
@@ -112,6 +123,7 @@ import {
112
123
  isSubmitAction,
113
124
  knownHarnesses,
114
125
  listAdapters,
126
+ listSessionBundleFiles,
115
127
  loadState,
116
128
  loadTracesConfig,
117
129
  locateSessions,
@@ -134,6 +146,8 @@ import {
134
146
  parseVerifyFindingsArgs,
135
147
  planTraceAgenticRoute,
136
148
  planUpload,
149
+ primeAnalyzer,
150
+ projectSessionBundle,
137
151
  readCoordinationLog,
138
152
  readFileRunContext,
139
153
  readFindingsFile,
@@ -144,6 +158,7 @@ import {
144
158
  readRunContextJournal,
145
159
  readRunContextSnapshot,
146
160
  readRunWatchSnapshot,
161
+ readSessionBundleManifest,
147
162
  readSessionIndexFile,
148
163
  readSpanRunSnapshot,
149
164
  recordSessionCorruption,
@@ -192,9 +207,11 @@ import {
192
207
  sessionHash,
193
208
  sessionIdFromAttributes,
194
209
  sessionIntegrityAttributes,
210
+ sessionTextSignatures,
195
211
  skippedAnalyses,
196
212
  span,
197
213
  spanRunTotals,
214
+ stampEnvironmentAttrs,
198
215
  stampRepoAttrs,
199
216
  stampSessionIdentity,
200
217
  stampSessionIntegrity,
@@ -228,12 +245,13 @@ import {
228
245
  writeInspectionReportFile,
229
246
  writeOtlpFile,
230
247
  writePolicyEvidenceFile,
248
+ writeSessionBundleManifest,
231
249
  writeSessionIndexFile,
232
250
  writeTraceEvidenceExportFile,
233
251
  writeTraceImprovementArtifacts,
234
252
  zaiChatCaller,
235
253
  zeroPricedCost
236
- } from "./chunk-VTYOCFGF.js";
254
+ } from "./chunk-CV22VGCK.js";
237
255
 
238
256
  // src/collect.ts
239
257
  async function collectSessions(opts = {}) {
@@ -286,6 +304,7 @@ export {
286
304
  JsonSourceError,
287
305
  JsonlParseError,
288
306
  OpencodeAdapter,
307
+ POLICY_EVIDENCE_NOTE,
289
308
  PartialUploadError,
290
309
  PiAdapter,
291
310
  QwenAdapter,
@@ -308,6 +327,7 @@ export {
308
327
  analyzeSpans,
309
328
  analyzeSteeringChain,
310
329
  applyRedactor,
330
+ assembleSessionBundle,
311
331
  assertSandboxReachable,
312
332
  buildDefaultAnalystRegistry,
313
333
  buildFixPrompt,
@@ -319,6 +339,8 @@ export {
319
339
  buildTraceFindingPacket,
320
340
  capText,
321
341
  chatTrajectoryToSpans,
342
+ classifyEvidenceOnlyPath,
343
+ classifyFailureFollowUps,
322
344
  classifyLiveActions,
323
345
  classifyReaction,
324
346
  classifyVerdict,
@@ -341,12 +363,15 @@ export {
341
363
  countSkillRunsJsonl,
342
364
  createHostedClient,
343
365
  cwdMatchesSelection,
366
+ cwdMatchesSelectionResolved,
344
367
  defaultTraceLiveAnalysts,
345
368
  deriveFailureSignature,
346
369
  derivedImageTag,
347
370
  describeSessionRelationship,
348
371
  dockerImagePreparer,
349
372
  enumerateReplayableCases,
373
+ environmentAttributes,
374
+ environmentFromSpanAttributes,
350
375
  equivalentGitCwds,
351
376
  executeUpload,
352
377
  exportTraceEvidenceFile,
@@ -354,6 +379,8 @@ export {
354
379
  exportTraceEvidenceText,
355
380
  extractFixCommand,
356
381
  fileRunContextSupervisorRunReader,
382
+ findContextRoot,
383
+ findSessionTextLeaks,
357
384
  findSpanSourceFiles,
358
385
  findingReplayStep,
359
386
  findingTrajectoryId,
@@ -361,8 +388,10 @@ export {
361
388
  generateFixCommand,
362
389
  goldIncorrectSteps,
363
390
  haloAnalyzer,
391
+ hashSessionBundleFiles,
364
392
  hodoscopeAnalyzer,
365
393
  hostedClientFromEnv,
394
+ httpJsonTransport,
366
395
  importCodeTraceBench,
367
396
  incompleteInputsNote,
368
397
  indexSessionIdsByTrace,
@@ -377,6 +406,7 @@ export {
377
406
  isSubmitAction,
378
407
  knownHarnesses,
379
408
  listAdapters,
409
+ listSessionBundleFiles,
380
410
  loadState,
381
411
  loadTracesConfig,
382
412
  locateSessions,
@@ -400,6 +430,8 @@ export {
400
430
  parseVerifyFindingsArgs,
401
431
  planTraceAgenticRoute,
402
432
  planUpload,
433
+ primeAnalyzer,
434
+ projectSessionBundle,
403
435
  readCoordinationLog,
404
436
  readFileRunContext,
405
437
  readFindingsFile,
@@ -410,6 +442,7 @@ export {
410
442
  readRunContextJournal,
411
443
  readRunContextSnapshot,
412
444
  readRunWatchSnapshot,
445
+ readSessionBundleManifest,
413
446
  readSessionIndexFile,
414
447
  readSpanRunSnapshot,
415
448
  recordSessionCorruption,
@@ -460,9 +493,11 @@ export {
460
493
  sessionHash,
461
494
  sessionIdFromAttributes,
462
495
  sessionIntegrityAttributes,
496
+ sessionTextSignatures,
463
497
  skippedAnalyses,
464
498
  span,
465
499
  spanRunTotals,
500
+ stampEnvironmentAttrs,
466
501
  stampRepoAttrs,
467
502
  stampSessionIdentity,
468
503
  stampSessionIntegrity,
@@ -496,6 +531,7 @@ export {
496
531
  writeInspectionReportFile,
497
532
  writeOtlpFile,
498
533
  writePolicyEvidenceFile,
534
+ writeSessionBundleManifest,
499
535
  writeSessionIndexFile,
500
536
  writeTraceEvidenceExportFile,
501
537
  writeTraceImprovementArtifacts,
@@ -68,9 +68,12 @@ traces analyze --all --last 20 --analyzer hodoscope
68
68
 
69
69
  # Run any installed command that accepts an OpenInference file path.
70
70
  traces analyze --last 1 --analyzer my-trace-tool
71
+
72
+ # One-shot prime-RLM analysis through a local OpenAI-compatible bridge.
73
+ traces analyze --last 1 --analyzer prime --analyzer-prompt "find unsupported completion claims"
71
74
  ```
72
75
 
73
- `--model` is forwarded to the built-in model-assisted analysts, HALO, and Hodoscope.
76
+ `--model` is forwarded to the built-in model-assisted analysts, HALO, Hodoscope, and prime.
74
77
  HALO and Hodoscope use their own provider clients and credentials.
75
78
  The Hodoscope adapter pins version `0.2.4` and uses Python 3.11 through `uvx`.
76
79
 
@@ -87,6 +90,41 @@ Raw JSON is still a `report`.
87
90
  Only an adapter that validates the full finding shape may return `findings`.
88
91
  Hodoscope always returns `discovery`, and each candidate has `status: 'needs_review'` plus its source trace and span.
89
92
 
93
+ ### Prime engine
94
+
95
+ `--analyzer prime` runs a one-shot analyst over the emitted OTLP artifact through an OpenAI-compatible bridge, such as cli-bridge's prime backend.
96
+ Unlike the `--llm` analysts, which drill into the trace with paged tools, prime has no REPL and no trace tools: the full span projection is inlined into a single prompt as JSON.
97
+ Oversized projections are re-rendered with a per-attribute character cap; if the projection still exceeds the inline budget the engine fails loud instead of silently dropping spans.
98
+
99
+ Prerequisites:
100
+
101
+ - A running bridge that accepts `POST /v1/chat/completions` and routes the configured model to the prime backend.
102
+ - No key handling here: the bridge owns provider credentials.
103
+
104
+ Configuration (flags first, then environment, then defaults):
105
+
106
+ | Setting | Source | Default |
107
+ | --- | --- | --- |
108
+ | Bridge root URL | `TRACES_PRIME_BRIDGE_URL` | `http://localhost:4181` |
109
+ | Model | `--model`, then `TRACES_PRIME_MODEL` | `prime/zai/glm-5.2` |
110
+ | Per-call deadline | `TRACES_PRIME_TIMEOUT_MS` | `1200000` (20 min) |
111
+ | Question | `--analyzer-prompt` | a general diagnosis question |
112
+
113
+ ```bash
114
+ traces analyze --last 1 --analyzer prime
115
+ TRACES_PRIME_BRIDGE_URL=http://localhost:4181 traces analyze --last 1 --analyzer prime --analyzer-prompt "find unsupported completion claims"
116
+ ```
117
+
118
+ Output expectations:
119
+
120
+ - The reply contract is one fenced JSON block of short strings citing span ids verbatim; a structurally malformed reply gets exactly one bounded repair turn that carries the malformed reply and the contract, never the trajectory.
121
+ - A still-malformed reply after repair is a failed result (`ok: false`) with the raw reply preserved for inspection; one failed engine never discards the other results.
122
+ - Valid rows become full `findings` with `trace://` span evidence, validated against the artifact like every other findings-kind engine; rows citing unknown or ambiguous span ids are rejected with a recorded reason.
123
+ - Zero findings from a well-formed reply is an honest null, not a failure.
124
+ - Bridge-reported token usage and call counts are recorded in the result output; cost stays uncaptured because this adapter has no pricing table.
125
+
126
+ The scored prime-vs-dspy comparison — same trajectories, same scoring — lives in `@tangle-network/agent-eval`'s analyst benchmark (`runAnalystBenchmark`); this engine is the capture-side entry point, not the scoreboard.
127
+
90
128
  ## Write one analyst
91
129
 
92
130
  An analyst receives a paged trace store and returns typed findings.
@@ -10,6 +10,7 @@ import {
10
10
  commandRedactor,
11
11
  haloAnalyzer,
12
12
  hodoscopeAnalyzer,
13
+ primeAnalyzer,
13
14
  writeOtlpFile,
14
15
  } from '@tangle-network/traces'
15
16
 
@@ -41,7 +42,19 @@ console.log(
41
42
  : `hodoscope unavailable: ${discovery.error}`,
42
43
  )
43
44
 
44
- // 3) External REDACTOR: scrub prose with your own PII model before upload. The
45
+ // 3) PRIME ENGINE: one-shot RLM through an OpenAI-compatible bridge (run
46
+ // cli-bridge's prime backend locally, or set TRACES_PRIME_BRIDGE_URL).
47
+ // The full span projection travels inline; findings come back with
48
+ // validated trace:// span evidence.
49
+ const prime = primeAnalyzer({ defaultPrompt: 'find unsupported completion claims' })
50
+ const primeResult = await prime.analyze(otlp)
51
+ console.log(
52
+ primeResult.ok
53
+ ? `${primeResult.findings?.length ?? 0} prime finding(s)\n${primeResult.output}`
54
+ : `prime bridge unavailable: ${primeResult.error}`,
55
+ )
56
+
57
+ // 4) External REDACTOR: scrub prose with your own PII model before upload. The
45
58
  // command reads a JSON array of strings on stdin and writes the scrubbed array
46
59
  // on stdout (a 3-line wrapper adapts openai/privacy-filter's `opf`).
47
60
  const redactor = commandRedactor({ command: 'my-pii-scrubber' })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/traces",
3
- "version": "0.11.5",
3
+ "version": "0.12.0",
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",
@@ -44,13 +44,14 @@
44
44
  "README.md"
45
45
  ],
46
46
  "engines": {
47
- "node": ">=22"
47
+ "node": ">=22.13.0"
48
48
  },
49
49
  "dependencies": {
50
- "@tangle-network/agent-eval": "0.143.0",
51
- "@tangle-network/agent-runtime": "0.126.0",
50
+ "@tangle-network/agent-eval": "0.145.22",
51
+ "@tangle-network/agent-interface": "1.0.0",
52
+ "@tangle-network/agent-runtime": "0.137.0",
52
53
  "@tangle-network/agent-trace-contract": "^1.0.2",
53
- "@tangle-network/sandbox": "0.17.2"
54
+ "@tangle-network/sandbox": "0.27.1"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@types/node": "^22.0.0",
@@ -48,6 +48,19 @@ Use `runAnalystBenchmark` with `registryBenchmarkRunner` from `@tangle-network/a
48
48
  Use AgentRx or CodeTraceBench labels when they match the finding.
49
49
  Compare the candidate with a no-findings baseline and relevant maintained or external analysts on identical cases and limits.
50
50
 
51
+ Two shipped engines are available as comparison arms.
52
+ `--analyzer prime` inlines the whole span projection into one prompt and needs no REPL.
53
+ `--analyzer halo` and `--analyzer hodoscope` drill into the trace with paged tools.
54
+ Compare an inline arm with a paged arm to separate the prompt from the navigation.
55
+
56
+ ```bash
57
+ traces analyze --last 1 --analyzer prime
58
+ ```
59
+
60
+ Assert the served model, not the requested id.
61
+ A gateway can answer one id with another model, so a panel can report families it never ran.
62
+ Use `assertServedModel` and `assertCrossFamilyServed` from `@tangle-network/agent-eval` before you trust a per-model or cross-family number.
63
+
51
64
  Use at least 20 independent cases before comparative statistics.
52
65
  Retain every case row and report exact-step recall, precision, F1, root-step accuracy when labeled, citation coverage and validity, clean-case false positives, repeat agreement, failures, latency, calls, all token fields, and known or missing cost.
53
66
 
@@ -22,10 +22,9 @@ traces analyze --otlp results/sessions --out .traces/all.md # a directory of e
22
22
  Use `--harness` only for coding agents whose on-disk format we do not control.
23
23
  Those adapters are the legacy edge, not the way to integrate a system you own.
24
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.
25
+ A run directory holds the span export beside raw event, stream and SDK logs that are
26
+ also `*.jsonl`. Only the OTLP files are read; the rest are listed with what they hold.
27
+ An `otlp/` subdirectory, when present, is read on its own.
29
28
 
30
29
  Any section headed `inputs incomplete`, or carrying an `Inputs incomplete` line above
31
30
  its table, is computed from a field the trace does not carry everywhere. Report those
@@ -73,6 +72,33 @@ traces improve --harness codex --current --latest-turn --workflow \
73
72
  `improve` writes findings, evidence, a report, and spans.
74
73
  It does not edit an agent, repository, memory store, or knowledge base.
75
74
 
75
+ Write one session's durable evidence directory for a later reader:
76
+
77
+ ```bash
78
+ traces bundle --harness claude-code --session <id-or-path> --out .traces/bundle
79
+ ```
80
+
81
+ `bundle` copies the transcript, the derived report and spans, the `.evolve` ledger rows inside the session window, and a `manifest.json` with a SHA-256 per file.
82
+ It spends no model call.
83
+ A missing transcript stops the assembly.
84
+ An absent optional input is recorded in `manifest.absent` with the probed path.
85
+
86
+ ## Pick the view for the reader
87
+
88
+ That bundle is the FULL view (`manifest.view: "full"`), and it holds the whole session transcript.
89
+ Never give it to a writer that must not see an earlier conclusion: the transcript holds the text of every file the session wrote, so a check for the earlier report FILE passes while its CONTENT is still readable.
90
+
91
+ Project the writer's copy instead:
92
+
93
+ ```bash
94
+ traces bundle-view .traces/bundle --view evidence-only --out .traces/writer
95
+ ```
96
+
97
+ That view carries `derived/session-index.json`, `derived/evidence.jsonl`, and the structured `ledger/` records.
98
+ It excludes the transcripts, the report, the spans, and every prose ledger file by name, with rules and hashes in `manifest.excluded`.
99
+ Before writing, it compares each carried file against each excluded file for shared 8-word runs of prose, and drops any file that repeats one.
100
+ `manifest.view` names which copy you hold.
101
+
76
102
  ## Report
77
103
 
78
104
  - State the source (`--otlp <path>` or the harness), selected task boundary, session and span counts, and integrity warnings.