Repository navigation
feat: persist structured usage telemetry - #2063
Conversation
Add a backend-aware JSONL ledger for turn attempts and runtime usage, then make squad cost report structured totals and telemetry coverage before using the legacy Markdown fallback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c8ae7013-1eb9-4f99-8762-ea407e3633f3
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 3 commits — consider squashing before review |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | No Copilot review threads |
| ❌ | CI passing | 10 check(s) still running |
Files Changed (8 files, +777 −61)
| File | +/− |
|---|---|
.changeset/1716-structured-usage-ledger.md |
+6 −0 |
packages/squad-cli/src/cli/commands/cost.ts |
+189 −53 |
packages/squad-cli/src/cli/shell/index.ts |
+45 −3 |
packages/squad-sdk/src/index.ts |
+1 −0 |
packages/squad-sdk/src/runtime/streaming.ts |
+2 −0 |
packages/squad-sdk/src/runtime/usage-ledger.ts |
+176 −0 |
test/cli/cost.test.ts |
+229 −5 |
test/usage-ledger.test.ts |
+129 −0 |
Total: +777 −61
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
🏗️ Architectural Review
Automated architectural review — informational only. |
🟡 Impact Analysis — PR #2063Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (1 file)
squad-cli (2 files)
squad-sdk (3 files)
tests (2 files)
|
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
What
Persist structured runtime usage telemetry in a versioned JSONL ledger and make
squad costprefer that ledger over regex parsing of agent-authored Markdown.Why
The existing cost report derives spend from unstructured Markdown, so it cannot reliably measure coverage or correlate runtime attempts with completed usage. This change provides a trustworthy data source for evaluating model-routing efficiency.
Closes #1716
How
.squad/log/usage.jsonlpersistence with versioned attempt and completed-usage records.squad cost, with clearly labelled Markdown fallback.Validation
npm run build -w @bradygaster/squad-sdknpm run build -w @bradygaster/squad-clinpm run lintnpx vitest run test/usage-ledger.test.ts test/cli/cost.test.ts— 15 passedQuick Check
.changeset/1716-structured-usage-ledger.mdPR Readiness Checklist
Branch & Commit
devBuild & Test
npm run lintpassesnpm run lint:eslintpassesChangeset
Breaking Changes
None.
Waivers
None.