codeburn/packages/core
ozymandiashh 70be320af9 test(qwen): pin the orphaned-record dedup key shape
The pre-extraction decoder built dedup keys with template interpolation, so
a record missing sessionId or uuid produced the literal `qwen:undefined:<uuid>`.
Phase 8.1 changed the spelling to `qwen::<uuid>` by coalescing both fields to
an empty string. The intent was right — a missing identifier should contribute
nothing rather than a fake value — but the change shipped with nothing behind
it: no test, fixture or golden pinned either spelling, and the CLI parity
golden only exercises fully-formed records, where the two are byte-identical.
Nobody could tell the change from a defect.

This makes the corrected shape a tested contract. The test pins the orphan
spellings, asserts the collapsed key still dedups identical records, and fails
against the pre-migration spelling. The decode-site comment records why, so
nobody "restores" the old one.

Two caveats worth knowing rather than discovering. Records with an explicit
null coalesce the same way as missing ones, so two previously-distinct keys
now collapse into one. And keys persisted by pre-8.1 builds for orphaned
records will not match the new spelling, so such a record can be counted once
more across the upgrade — the qwen corpus is not in the frozen golden set, so
no shipped fixture moves.
2026-08-05 12:51:00 +03:00
..
schemas feat(core): duplicate-reads, junk-reads, context-bloat detectors over fingerprints (phase 5) 2026-07-26 13:31:26 -07:00
scripts fix: guard publish against a half-built dist 2026-07-27 15:12:13 -07:00
src test(qwen): pin the orphaned-record dedup key shape 2026-08-05 12:51:00 +03:00
tests test(qwen): pin the orphaned-record dedup key shape 2026-08-05 12:51:00 +03:00
package.json fix: guard publish against a half-built dist 2026-07-27 15:12:13 -07:00
README.md docs(core): replace Phase 1 skeleton README; bump core to 0.9.20 for republish 2026-07-27 10:52:38 -07:00
tsconfig.build.json chore: stop emitting declaration maps 2026-07-27 15:22:15 -07:00
tsconfig.json feat(core): observation schema, contracts, fingerprints, guardrail harnesses (phase 2) 2026-07-26 10:43:21 -07:00
tsup.config.ts fix: emit core declarations with TypeScript 2026-07-27 11:57:05 -07:00
vitest.config.ts feat(core): observation schema, contracts, fingerprints, guardrail harnesses (phase 2) 2026-07-26 10:43:21 -07:00

@codeburn/core

The pure decode/detect engine behind CodeBurn: provider session-log decoding for 36 AI coding tools, content-minimized observation envelopes, and detector contracts.

Status: 0.x. The engine is complete and battle-tested (it is the same code the CodeBurn CLI runs, proven byte-identical to the pre-extraction implementation on a frozen real-world corpus), but the public API may still change between 0.x minor versions. Pin accordingly.

What it does

  • Decode: each provider module (@codeburn/core/providers/<name>) turns that tool's raw session records into structured call data — tokens, models, timing, tool usage — with the provider's exact dedup and skip semantics.
  • Observations: toObservations maps rich decode output into a strict, content-minimized envelope: only fingerprints, enums, numbers, timestamps, dedup keys, and canonical tool names cross the boundary. Enforced by an architecture gate and per-provider content-smuggling tests.
  • Detectors: contracts for waste/optimization findings over fingerprinted data.

What it deliberately does NOT do

No file or network I/O, no environment access, no clock reads, no pricing. Hosts (the CodeBurn CLI, apps, or your own tooling) supply the records and apply their own pricing. The only runtime dependency is zod.

Usage

import { decodeQwen } from '@codeburn/core/providers/qwen'
import { toObservations } from '@codeburn/core/providers/qwen'
import { OBSERVATION_SCHEMA_VERSION } from '@codeburn/core/schema'

const { calls, diagnostics } = decodeQwen({ records, seenKeys })

Each provider is its own subpath export; see package.json#exports for the full list. JSON Schemas for the observation envelope ship under schemas/.

Part of the CodeBurn core extraction (RFC #796, tracking #809). MIT.