codeburn/packages/core
iamtoruk cff80ccdb1 fix(core): bound the model field at the observation boundary
`model` on a CallObservation was `z.string().min(1)` — unbounded free text
on a field that ships in the envelope. Bound it (and the optional
`pricingModel`) to the identifier charset real model slugs use,
`[A-Za-z0-9._:/@-]`, max 128, in both the zod schema and the published
schemas/observation-0.2.0.json.

Providers report display names ("Gemini 3.5 Flash (High)"), so a hard
reject would fail a whole multi-session batch over one call. Every
provider's toObservations now normalizes through
`normalizeModelIdentifier`: conforming values pass through untouched,
everything else collapses to 'unknown' — the same fallback the decoders
already use when no model resolves.

BOUNDARY ONLY. The normalizer is never called while building a dedup key:
a key is an identity, not an observation field, and collapsing two
distinct raw models to 'unknown' inside one would merge two real calls
and re-key every cached key for a partial win. The key's free-text
surface is schema-wide (every provider's key carries raw components) and
belongs to the dedup-key-hashing follow-up.

CLI output is unaffected — normalization happens at the observation
boundary only, so no terminal, dashboard, menubar or desktop number or
label moves.
2026-08-21 10:18:58 -07:00
..
schemas fix(core): bound the model field at the observation boundary 2026-08-21 10:18:58 -07:00
scripts build(core): stop shipping sourcemaps, expose schemas, tighten the barrel 2026-08-05 03:49:47 +03:00
src fix(core): bound the model field at the observation boundary 2026-08-21 10:18:58 -07:00
tests fix(core): bound the model field at the observation boundary 2026-08-21 10:18:58 -07:00
package.json build(core): stop shipping sourcemaps, expose schemas, tighten the barrel 2026-08-05 03:49:47 +03: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 build(core): stop shipping sourcemaps, expose schemas, tighten the barrel 2026-08-05 03:49:47 +03: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.