Skip to content

refactor(core): carve Claude decode into @codeburn/core, CLI parser becomes adapter (phase 3) - #822

Merged
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase3/claude-carveout
Jul 26, 2026
Merged

iamtoruk merged 1 commit into
feat/core-extractionfrom
phase3/claude-carveout

Conversation

@iamtoruk

Copy link
Copy Markdown
Member

Phase 3 of #809 — the summit. The pure Claude decode family (scanner, parseJsonlLine/compactEntry, decodeAssistantCall/decodeAdvisorCalls, groupIntoTurns, streaming dedup, rich-capture collectors) moves to packages/core/src/providers/claude as the rich pure layer, plus toObservations mapping into the strict envelope (fingerprint refs + numerics only; smuggling test extended with a real claude-decode path). parser.ts shrinks ~1335 lines into an adapter keeping all I/O, incremental-append orchestration, caching, classification, and pricing (cost-free DecodedCall priced host-side via the established seam; byte-safe since Claude cost is never cached). strip-ansi bash splitting stays host-side (core remains zod-only). Every moved symbol re-exported: zero consumer churn.

Gates, all independently re-verified in review:

  • Byte-parity: root suite exactly 2252; synthetic corpus byte-identical incl. >32KB buffer-scanner and incremental-append paths; and a FROZEN 5.1GB copy of a real corpus — month/lifetime/all parity confirmed under float tolerance, with the baseline first proven self-consistent. (Review methodology finding: live-corpus comparisons are invalid — the measuring session's own spend lands mid-comparison, and parallel parse order produces last-ulp float jitter in the OLD build too. Frozen corpus + 1e-9 tolerance is the parity standard from here.)
  • Perf: synthetic medians cold −0.5% / warm +0.2%; real frozen corpus warm dead-even (4.74s vs 4.73s). Scanner and incremental machinery intact.
  • Core 99 tests (incl. claude smuggling case), import-smoke covers the new subpath, tsc clean both, no parse-version bumps.

…ecomes adapter (phase 3)

Move the pure Claude JSONL decode out of packages/cli/src/parser.ts into
packages/core/src/providers/claude/: the large-line buffer scanner, line
parsing, compaction, per-call/turn extraction, rich-capture meta collectors,
turn grouping, and streaming dedup. These are pure over supplied records/lines
(no fs/env/clock/pricing) and carry content in-memory only at this host-facing
layer.

Add the minimizing transform toObservations(richDecode, {privacyKey,...}) that
maps the rich decode into the strict Phase-2 observation envelope: only
fingerprints, enums, numbers, timestamps, dedup keys, and canonical tool names
cross the boundary. Extend the content-smuggling guardrail with a real claude
decode -> toObservations case planting secrets in every captured free-text
field and asserting the serialized envelope surfaces none.

The CLI parser is now the adapter: it keeps all I/O, discovery, incremental
append, cache shapes, classification, and host-side pricing. parseApiCall /
parseAdvisorCalls / groupIntoTurns become thin wrappers that price the cost-free
core decode (calculateCost + local-model savings) and split raw bash commands
(strip-ansi stays out of the zod-only core), then map into ParsedApiCall /
ParsedTurn. Shared record + tool-vocab definitions move to core; the CLI
re-exports them so every existing import path is unchanged.

No parse-version bump; CachedCall/CachedTurn shapes and values byte-identical.
Core runtime deps stay zod-only.
@iamtoruk
iamtoruk merged commit 698a58c into feat/core-extraction Jul 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant