@tangle-network/traces 0.15.4 → 0.15.5
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 +80 -12
- package/dist/{chunk-SKOW5V5U.js → chunk-RERVIGLH.js} +577 -283
- package/dist/cli.js +252 -31
- package/dist/index.d.ts +140 -32
- package/dist/index.js +27 -9
- package/docs/trace-analysts.md +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -32,10 +32,12 @@ Emitting the contract is the supported way to integrate a new system. The adapte
|
|
|
32
32
|
- [Improvement engine](#improvement-engine)
|
|
33
33
|
- [Ask questions](#ask-questions)
|
|
34
34
|
- [Session facts](#session-facts)
|
|
35
|
+
- [Diff two runs](#diff-two-runs)
|
|
36
|
+
- [MCP server](#mcp-server)
|
|
35
37
|
- [Session index](#session-index)
|
|
36
38
|
- [Session bundle](#session-bundle) · [Two views](#two-views-two-consumers)
|
|
37
39
|
- [Policy-mining evidence](#policy-mining-evidence)
|
|
38
|
-
- [Upload to the Intelligence Platform](#upload-to-the-intelligence-platform)
|
|
40
|
+
- [Upload to the Intelligence Platform](#upload-to-the-intelligence-platform) · [Check before sharing](#check-before-sharing)
|
|
39
41
|
- [Trace analysts](#trace-analysts)
|
|
40
42
|
- [Agent skills](#agent-skills)
|
|
41
43
|
- [Library (SDK)](#library-sdk)
|
|
@@ -125,9 +127,7 @@ files are read — every other JSONL is listed in the report with what it actual
|
|
|
125
127
|
holds, rather than counted as several hundred broken spans. Put the exports in an
|
|
126
128
|
`otlp/` subdirectory and that decides it outright.
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
DEPRECATED spelling of `--otlp-out`. It still works, with a warning, and is
|
|
130
|
-
removed in 0.12.
|
|
130
|
+
Writing commands (`convert`, `export`, `evidence`, `upload`) take `--otlp-out`; they refuse `--otlp`.
|
|
131
131
|
|
|
132
132
|
`parent_span_id` is CONTAINMENT — this span happened inside that one. `links` is
|
|
133
133
|
CAUSALITY — that verdict caused this retry. Encoding causality as a parent claims
|
|
@@ -168,9 +168,9 @@ trace through `traces` cannot produce a clean bill of health.
|
|
|
168
168
|
`analyze` prints the same section, plus an **analyses skipped, and why** list —
|
|
169
169
|
and, crucially, carries that verdict INTO the report. A section whose inputs are
|
|
170
170
|
incomplete says so in its own heading and again directly above its table, so a
|
|
171
|
-
number and the reason it is wrong can never end up forty lines apart.
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
number and the reason it is wrong can never end up forty lines apart. When the
|
|
172
|
+
trace supports `tree-comparison`, the table names the command that compares its
|
|
173
|
+
arms: `traces diff <file>#branch=<a> <file>#branch=<b>`.
|
|
174
174
|
|
|
175
175
|
Two of those analyses are why the loop shape exists at all:
|
|
176
176
|
|
|
@@ -250,6 +250,8 @@ traces investigate --all --last 10 --out report.md # explicit investigation ali
|
|
|
250
250
|
traces improve --all --last 10 --dir .traces/improvement
|
|
251
251
|
traces ask --harness codex --session <id> --question "Which commands failed?"
|
|
252
252
|
traces facts --harness codex --session <id> # the deterministic facts sheet, $0
|
|
253
|
+
traces diff run-a.otlp.jsonl run-b.otlp.jsonl # where two runs of one task first diverge
|
|
254
|
+
traces mcp --otlp spans.otlp.jsonl # read-only trace tools for an MCP client
|
|
253
255
|
traces analyze --all --since 2026-06-18 --out report.md
|
|
254
256
|
traces validate spans.otlp.jsonl # conformance; exit 1 only when it is not a trace
|
|
255
257
|
traces validate results/sessions --out conformance.md # a whole directory of exports
|
|
@@ -275,6 +277,7 @@ traces stream --all --mode agent # findings + deterministic re
|
|
|
275
277
|
traces stream spans.openinference.jsonl --format openinference --no-spans
|
|
276
278
|
traces upload --since 1h --dry-run # redact + dedup + preview, no network
|
|
277
279
|
traces upload --since 24h # upload last day to the Intelligence Platform
|
|
280
|
+
traces verify-safe bundle-dir # SAFE / SAFE_WITH_WARNINGS / UNSAFE (exit 1) / UNKNOWN (exit 2)
|
|
278
281
|
traces replay-verify --steps steps.json --image <docker-image> --at 37 --cwd /home --out ./replay-out \
|
|
279
282
|
--fix-command "<corrected step>" # executed proof: replay prefix, reproduce failure, show fix
|
|
280
283
|
traces verify-findings --findings findings.json --out ./receipts \
|
|
@@ -536,6 +539,7 @@ traces facts --otlp spans.otlp.jsonl --out facts.json
|
|
|
536
539
|
| `firstRecordAt` / `lastRecordAt` | the earliest span start and latest span end among this session's own records — a subagent that outlives the session does not stretch its window |
|
|
537
540
|
| `unreadRecords` | records the session reader could not parse, from the session's integrity receipt |
|
|
538
541
|
| `tokenTotal` | the harness's own cumulative token total, when a span carries `traces.session.total_tokens` |
|
|
542
|
+
| `firstFailure` | the first failure among this session's own records, ranked by agent-eval's fixed precedence: the innermost ERROR span that ended first, else a span whose `agent.outcome` is `fail`, else `none` — spans were observed and none of them failed. When every span is UNSET (a capture that failed before any status was written), or a session has no records of its own at all (every span is `traces.span.subagent` — spawned work folded into this trace, with nothing this agent recorded itself), the status is `unknown`, not `none`: the record does not say whether the run failed. Failures that ended at the same instant are `ambiguous` and list the candidates instead of picking one. `blame` separates machine and provider failures from the agent's own, and is `unknown` rather than `agent` when no evidence names the agent |
|
|
539
543
|
|
|
540
544
|
Three rules hold for every field:
|
|
541
545
|
|
|
@@ -547,6 +551,43 @@ Three rules hold for every field:
|
|
|
547
551
|
|
|
548
552
|
The same sheet reaches the model-backed analysts as prepared context, before their first model call — see [Trace analysts](docs/trace-analysts.md#session-facts-as-prepared-context).
|
|
549
553
|
|
|
554
|
+
## Diff two runs
|
|
555
|
+
|
|
556
|
+
`traces diff` pairs the steps of two runs of the same task and marks where they first stop agreeing.
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
traces diff runs/a/otlp runs/b/otlp # two OTLP exports
|
|
560
|
+
traces diff a.sdk-events.jsonl b.sdk-events.jsonl --kind TOOL # any file convert reads; tool calls only
|
|
561
|
+
traces diff spans.otlp.jsonl#<trace id> other.jsonl --format json
|
|
562
|
+
traces diff run.otlp.jsonl#branch=arm-a run.otlp.jsonl#branch=arm-b # two arms of one run
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
A side is a file or directory that holds one run, `file#<trace id>` for one run of several, or `file#branch=<id>` for one arm: the spans whose `agent.branch.id` or `agent.branch.arm` is `<id>` and have no matched ancestor (a root), and every span below them. Sibling arms can share a branch id or label; when `<id>` names more than one such root subtree, the command refuses (exit 2) and lists each root's span id, rather than silently comparing the union of both.
|
|
566
|
+
Steps pair by span id first, then by position with the same name and kind, then by name and kind anywhere.
|
|
567
|
+
One inserted step therefore does not mark every later step as changed.
|
|
568
|
+
Paired steps compare status, tool and model.
|
|
569
|
+
The first divergence is `changed`, `replaced`, `only-in-a`, `only-in-b` or `reordered`, with its reason, followed by every changed and unpaired step.
|
|
570
|
+
`--kind` keeps only steps of that span kind, so event noise in a raw stream does not decide the first divergence.
|
|
571
|
+
The diff is agent-eval's `diffSteps`; this command reads the runs and prints it.
|
|
572
|
+
It exits 0 when the runs agree on outcome, 1 when they diverge, 2 when a side cannot be read (including an ambiguous `#branch=` selector), and 3 when the steps line up with no divergence but there is no recorded outcome to call agreement: neither side has a step with a definitive OK/ERROR status (both are entirely UNSET, the common shape for a capture that failed before any status was written), or neither side has a TOOL step. That case's report and text output carry a `caveat` naming which reason applies; a CI or agent gate should treat exit 3 as unknown, not as a pass.
|
|
573
|
+
|
|
574
|
+
## MCP server
|
|
575
|
+
|
|
576
|
+
`traces mcp` serves the selected traces to an MCP client over stdio.
|
|
577
|
+
|
|
578
|
+
```bash
|
|
579
|
+
claude mcp add traces -- traces mcp --otlp ./spans.otlp.jsonl
|
|
580
|
+
claude mcp add traces -- traces mcp --harness claude-code --last 5
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
It serves agent-eval's seven trace tools: `getDatasetOverview`, `queryTraces`, `countTraces`, `viewTrace`, `viewSpans`, `searchTrace` and `searchSpan`.
|
|
584
|
+
Each tool declares `readOnlyHint` and `idempotentHint` in its MCP annotations, and its description says that returned trace text is untrusted.
|
|
585
|
+
|
|
586
|
+
- The spans are redacted before the store is built — every span's name, attributes, status message and causal links' attributes, every field the store reads — and each result is redacted again at the boundary. The server then reassesses the redacted spans and refuses to start when they are still UNSAFE or UNKNOWN, the same gate `upload` applies to what it sends.
|
|
587
|
+
- Each result carries an `untrusted` notice beside it.
|
|
588
|
+
- A result above 512 KiB is refused with an error rather than truncated.
|
|
589
|
+
- `readSpanSource` is not served. It reads original source bytes in windows the caller picks, and a secret split across two windows matches no redaction rule.
|
|
590
|
+
|
|
550
591
|
## Session index
|
|
551
592
|
|
|
552
593
|
`traces index` writes one general JSON catalog over the selected sessions.
|
|
@@ -689,6 +730,8 @@ Run `traces export --help` for the full command reference.
|
|
|
689
730
|
## Upload to the Intelligence Platform
|
|
690
731
|
|
|
691
732
|
`upload` **redacts locally before anything leaves the machine**, dedups against already-uploaded sessions, and tags each with metadata (harness, cwd, git branch, host).
|
|
733
|
+
It then checks the final events of each session, exactly as they would be sent, with the share-safety verdict.
|
|
734
|
+
A session that is UNSAFE or UNKNOWN is refused: it is not sent, not written to the dry-run preview, and not marked uploaded, and the command exits 1.
|
|
692
735
|
|
|
693
736
|
```bash
|
|
694
737
|
traces upload --since 24h --dry-run # see exactly what would be sent; no network
|
|
@@ -700,16 +743,40 @@ It needs `TANGLE_INGEST_URL` (or `TANGLE_ORCHESTRATOR_URL`), `TANGLE_INGEST_API_
|
|
|
700
743
|
|
|
701
744
|
### Redaction scope: read this before uploading prose
|
|
702
745
|
|
|
703
|
-
Redaction is
|
|
746
|
+
Redaction is agent-eval's redaction core ([docs/redaction.md](https://github.com/tangle-network/agent-eval/blob/main/docs/redaction.md)), `default` profile.
|
|
747
|
+
It finds credentials by field name (`apiKey`, `x-api-key`, `client.secret`, `refreshToken`) and by value shape (provider keys, GitHub, Slack, AWS and Google tokens, JWTs, bearer headers, private keys, `KEY=secret` assignments, credentials in URLs), and replaces the whole string.
|
|
748
|
+
It replaces email, card, SSN and phone values in place.
|
|
749
|
+
Token counts such as `input_tokens` and `max_tokens` are kept.
|
|
750
|
+
It runs over every span attribute, including the captured prompt/response text.
|
|
704
751
|
|
|
705
|
-
It does **not** catch
|
|
752
|
+
It does **not** catch names, postal addresses or account numbers written in prose. Those need a context-aware model. Three postures, strongest first:
|
|
706
753
|
|
|
707
754
|
1. **`--no-content`**: upload metadata only (tool calls, tokens, timing, loop signal); no prose leaves the machine.
|
|
708
|
-
2.
|
|
709
|
-
3. Default:
|
|
755
|
+
2. **`--redactor <cmd>`**: run an ML PII scrubber (e.g. [`openai/privacy-filter`](https://github.com/openai/privacy-filter)) after the redaction core.
|
|
756
|
+
3. Default: the redaction core.
|
|
710
757
|
|
|
711
758
|
Always `--dry-run` first to see exactly what would be sent.
|
|
712
759
|
|
|
760
|
+
### Check before sharing
|
|
761
|
+
|
|
762
|
+
`verify-safe` reads files and says whether they are safe to share. It never changes them.
|
|
763
|
+
|
|
764
|
+
```bash
|
|
765
|
+
traces verify-safe bundle-dir # share profile (default)
|
|
766
|
+
traces verify-safe session.jsonl --profile strict --format json
|
|
767
|
+
traces verify-safe out/ --known-secret-env TANGLE_API_KEY # also look for this exact key, in any encoding
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
| Status | Meaning | Exit |
|
|
771
|
+
|---|---|---|
|
|
772
|
+
| `SAFE` | Nothing found | 0 |
|
|
773
|
+
| `SAFE_WITH_WARNINGS` | Only warnings: raw content, identifiers, embedded media | 0 |
|
|
774
|
+
| `UNSAFE` | A credential remains, or personal data under `share` or `strict` | 1 |
|
|
775
|
+
| `UNKNOWN` | A file, line or byte range could not be read, so its safety is unknown | 2 |
|
|
776
|
+
|
|
777
|
+
`.json` files are parsed whole and `.jsonl` or `.ndjson` files line by line. Any other file is scanned as text.
|
|
778
|
+
Each finding names the file, line and JSON Pointer, never the matched value.
|
|
779
|
+
|
|
713
780
|
## Trace analysts
|
|
714
781
|
|
|
715
782
|
Use the local checks by default.
|
|
@@ -827,7 +894,8 @@ The CLI is a thin consumer of these exports.
|
|
|
827
894
|
| `exportTraceEvidenceFile` | `(path, opts?) → { format, spans, redactionCount }` | convert compact evidence/events/OpenInference files to redacted OpenInference spans |
|
|
828
895
|
| `scanSessions` | `(ScanOptions) → AsyncIterable<ScannedSession>` | the shared locate→parse iterator |
|
|
829
896
|
| `collectSessions` | `(CollectOptions) → SessionBatch[]` | redacted per-session batches for your own pipeline |
|
|
830
|
-
| `redactSpans` | `(spans,
|
|
897
|
+
| `redactSpans` | `(spans, { profile?, knownSecrets? }) → { spans, report }` | redact spans with agent-eval's redaction core |
|
|
898
|
+
| `assessSpans` / `verifySafe` | `(spans, profile?)` / `(path, { profile?, knownSecrets? })` → verdict | share-safety verdict for spans or files |
|
|
831
899
|
| `planUpload` / `executeUpload` | `(…, { backend? }) → …` | redact + dedup + send to any sink |
|
|
832
900
|
| `selectAdapters` / `listAdapters` / `resolveAdapter` | adapter selection + the harness registry |
|
|
833
901
|
| `PiAdapter` | `new PiAdapter({ sessionsRoot? })` | parse Pi's default session tree or an exact `PI_CODING_AGENT_SESSION_DIR` |
|