@tangle-network/traces 0.8.0 → 0.8.11

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 CHANGED
@@ -17,6 +17,8 @@ It reads the transcripts your harness leaves on disk, reconstructs the run as sp
17
17
  - [What it finds](#what-it-finds)
18
18
  - [Supported harnesses](#supported-harnesses)
19
19
  - [CLI reference](#cli-reference)
20
+ - [Session index](#session-index)
21
+ - [Policy-mining evidence](#policy-mining-evidence)
20
22
  - [Upload to the Intelligence Platform](#upload-to-the-intelligence-platform)
21
23
  - [External engines (bring your own)](#external-engines-bring-your-own)
22
24
  - [Library (SDK)](#library-sdk)
@@ -85,6 +87,10 @@ traces list --harness claude-code --last 20 # discover sessions
85
87
  traces analyze --harness codex --last 1 # $0 deterministic report
86
88
  traces analyze --all --since 2026-06-18 --out report.md
87
89
  traces convert --harness claude-code --last 1 --otlp spans.jsonl # OTLP only
90
+ traces index --all --since 24h --out session-index.json
91
+ traces inspect session-index.json --out inspection-report.md
92
+ traces evidence --harness codex --last 20 --out policy-evidence.jsonl
93
+ traces export policy-evidence.jsonl --out spans.openinference.jsonl
88
94
  traces watch --all # live observer; notify on stuck loops
89
95
  traces upload --since 1h --dry-run # redact + dedup + preview, no network
90
96
  traces upload --since 24h # upload last day to the Intelligence Platform
@@ -99,13 +105,71 @@ traces upload --since 24h # upload last day to the Inte
99
105
  | `--cwd <dir>` | Filter by working directory |
100
106
  | `--since <t>` | `upload`: window — `30m`/`2h`/`7d` or ISO (default 24h); `analyze`: ISO cutoff |
101
107
  | `--out <path>` | Write the report to a file |
102
- | `--otlp <path>` | OTLP artifact path (also the dry-run upload preview) |
108
+ | `--otlp <path>` | OTLP artifact path (also evidence provenance / dry-run upload preview) |
109
+ | `--format <kind>` | `export`: `auto`, `policy-evidence`, `sandbox-events`, or `openinference` |
103
110
  | `--llm` / `--budget <usd>` | Enable agentic analysts (needs `OPENAI_API_KEY`) / cap their spend |
104
111
  | `--interval <s>` / `--window <m>` | `watch`: poll seconds (default 5) / active-session window minutes (default 30) |
105
112
  | `--min-loop <n>` | Identical repeated calls before flagging a loop (default 3) |
106
113
  | `--no-content` | `upload`: send metadata only — strip all prompt/response text |
107
114
  | `--dry-run` / `--yes` | `upload`: preview without sending / skip the confirm prompt |
108
115
 
116
+ ## Session index
117
+
118
+ `traces index` writes one general JSON catalog over the selected sessions.
119
+ It is meant for deeper investigation and joins with other local data, not for one specific workflow.
120
+
121
+ ```bash
122
+ traces index --all --since 24h --out session-index.json
123
+ traces inspect session-index.json --out inspection-report.md
124
+ ```
125
+
126
+ The index contains:
127
+
128
+ - selection metadata and aggregate totals
129
+ - one row per session with harness, session id, path, cwd, repo labels, and time bounds
130
+ - behavior metrics: spans, LLM turns, tool calls, tool errors, tokens, models, and tools
131
+ - signal summaries: stuck loops and tool error rate
132
+ - nearby context files for joins: `AGENTS.md`, `CLAUDE.md`, and `.evolve` JSONL / reflection artifacts, with markdown heading/ToC and JSONL key summaries
133
+
134
+ `traces inspect` reads that index back and prints ranked improvement findings over the sessions and nearby context.
135
+ It is intentionally read-only: it points to repeated-call loops, high tool-error sessions, missing repo attribution, long docs without Contents, invalid JSONL rows, and skill-run rows that cannot be joined back to a session.
136
+
137
+ ## Policy-mining evidence
138
+
139
+ `traces` does **not** emit benchmark campaign cells. It emits normalized coding-agent session evidence that another system can mine.
140
+
141
+ ```bash
142
+ traces evidence --all --since 24h --out policy-evidence.jsonl --otlp spans.otlp.jsonl
143
+ ```
144
+
145
+ Each JSONL row is one session:
146
+
147
+ - session provenance: harness, session id, cwd, path, mtime
148
+ - repo labels: `tangle.subject.key`, `git.repository`, branch, commit
149
+ - behavior metrics: span counts, LLM turns, tool calls, errored tool calls, tokens, models, tool histogram
150
+ - mining signals: stuck loops and tool error rate
151
+ - provenance marker: `notCampaignCell: true`
152
+
153
+ That boundary matters. `agent-lab` campaign `cells.jsonl` says "arm X beat arm Y on task Z." `traces evidence` says "this real agent session had this repo/model/tool/failure shape." A downstream policy compiler can cluster these rows, propose candidate policies, then validate those policies in a separate eval campaign.
154
+
155
+ ### Export existing evidence/events to OpenInference
156
+
157
+ If you already have compact evidence or Sandbox/OpenCode event captures on disk, convert them to the same OpenInference JSONL shape that `traces analyze --analyzer halo` uses:
158
+
159
+ ```bash
160
+ traces export policy-evidence.jsonl --out spans.openinference.jsonl
161
+ traces export sandbox-events.json --format sandbox-events --out spans.openinference.jsonl
162
+ halo spans.openinference.jsonl --prompt "Analyze this trace slice" --max-turns 1
163
+ ```
164
+
165
+ `traces export` accepts:
166
+
167
+ - compact `traces.policy_evidence.session` JSONL from `traces evidence`
168
+ - Sandbox/OpenCode JSON arrays with `start`, `raw`, `result`, `done`, and `error` events
169
+ - existing OpenInference JSONL, rewritten through the local redaction path
170
+
171
+ Run `traces export --help` for the full command reference.
172
+
109
173
  ## Upload to the Intelligence Platform
110
174
 
111
175
  `upload` **redacts locally before anything leaves the machine**, dedups against already-uploaded sessions, and tags each with metadata (harness, cwd, git branch, host).
@@ -155,6 +219,17 @@ In the SDK these are the `ExternalAnalyzer` and `Redactor` interfaces (`haloAnal
155
219
 
156
220
  > For the built-in agentic analysts (`--llm`), set `OPENAI_API_KEY` — or point at any OpenAI-compatible gateway with `OPENAI_BASE_URL` (e.g. an internal router) to use a non-OpenAI key.
157
221
 
222
+ ## Release automation
223
+
224
+ Merging to `main` publishes a patch release automatically:
225
+
226
+ 1. The Publish workflow bumps `package.json` from `X.Y.Z` to `X.Y.(Z+1)`.
227
+ 2. It commits `chore(release): vX.Y.(Z+1) [skip release]` back to `main`.
228
+ 3. It pushes the matching `vX.Y.(Z+1)` tag.
229
+ 4. The same workflow verifies the tag, builds, publishes to npm, and creates a GitHub release.
230
+
231
+ Minor releases are manual. Run the Publish workflow from GitHub Actions and choose `minor`; it publishes `X.(Y+1).0`. Use manual `patch` only when you need a patch release without merging a new code change.
232
+
158
233
  ## Library (SDK)
159
234
 
160
235
  The CLI is a thin consumer of these exports.
@@ -163,6 +238,11 @@ The CLI is a thin consumer of these exports.
163
238
  |---|---|---|
164
239
  | `analyzeSpans` | `(spans, { registry?, ai?, budgetUsd? }) → AnalyzeResult` | run analysts — built-in, or **your own** via `registry` |
165
240
  | `watchSessions` | `(ObserverOptions) → Promise<void>` | live observer; `onLoop` / `onReport` / `signal` / `adapters` |
241
+ | `collectSessionIndex` | `(ScanOptions) → TraceSessionIndex` | scan sessions and return a reusable JSON-ready catalog |
242
+ | `inspectSessionIndex` | `(TraceSessionIndex) → TraceInspectionReport` | rank improvement findings from an index without rescanning sessions |
243
+ | `buildPolicyEvidenceRecord` | `(ref, spans, opts?) → PolicyEvidenceRecord` | summarize one session for downstream policy mining |
244
+ | `collectPolicyEvidence` | `(ScanOptions) → PolicyEvidenceRecord[]` | scan harness sessions and emit policy-evidence rows |
245
+ | `exportTraceEvidenceFile` | `(path, opts?) → { format, spans, redactionCount }` | convert compact evidence/events/OpenInference files to redacted OpenInference spans |
166
246
  | `scanSessions` | `(ScanOptions) → AsyncIterable<ScannedSession>` | the shared locate→parse iterator |
167
247
  | `collectSessions` | `(CollectOptions) → SessionBatch[]` | redacted per-session batches for your own pipeline |
168
248
  | `redactSpans` | `(spans, rules?) → { spans, report }` | PII/secret redaction (`TRACES_REDACTION_RULES`) |