Skip to content

feat(core): duplicate-reads, junk-reads, context-bloat detectors over fingerprints (phase 5) - #824

Merged
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase5/detectors
Jul 26, 2026
Merged

iamtoruk merged 1 commit into
feat/core-extractionfrom
phase5/detectors

Conversation

@iamtoruk

Copy link
Copy Markdown
Member

Phase 5 of #809. Three detectors REDESIGNED (not moved) into packages/core/src/detectors, consuming the minimized envelope via resource fingerprints — raw paths never enter core; the CLI maps Findings to its display shapes and derives fix payloads from a host-side resourceId→path reverse map (D5-A). Every Finding carries machine evidence, confidence-with-basis, algorithmVersion 1.0.0.

Schema 0.2.0: CallObservation gains resourceReads/resourceEdits (16-hex refs + class), 0.1.0 kept frozen with drift tests for both. D1 keystore materialized: per-install random key at the config dir, 0600, never printed. Smuggling tests extended: paths planted in tool sequences emerge only as refs.

Numbers parity HELD — no re-baseline needed: all 145 optimize tests unchanged; frozen-corpus optimize output byte-identical (13,186 bytes; read-edit-ratio 7630/5619, redundant-rereads 2239 — real findings, exact match; independently re-verified in review). The junk-reads predicate was redesigned from path-regex to resource classes and, after review feedback, the classifier was extended so the class set is a PROVEN strict superset of the legacy regex (every legacy token programmatically classified; sole exception shown unrealizable). Core suite 135, root 2254, tsc clean, import-smoke covers ./detectors (purity: zero I/O).

… fingerprints (phase 5)

Redesign the three token-waste detectors as pure @codeburn/core detectors that
consume an ObservationEnvelope of fingerprinted resource refs (never raw paths):

- Envelope schema 0.2.0: CallObservation gains optional resourceReads /
  resourceEdits (ResourceRef = {resourceId 16-hex, resourceClass}). claude/codex
  toObservations fingerprint toolSequence file paths into these; raw paths never
  cross the boundary. Keep observation-0.1.0.json frozen; emit 0.2.0.
- Host privacy key (D1): sync keystore under the codeburn config dir, random
  32-byte key generated on first use, stable across runs, never emitted.
- core/detectors: junk-reads, duplicate-reads, context-bloat — pure, zero
  fs/env, each emitting Finding[] with confidence(basis), machine-readable
  evidence, algorithmVersion.
- optimize.ts delegates the three to core, mapping Finding -> WasteFinding;
  display strings, fix payloads and trend stay host-derived.

Numbers parity: all optimize tests pass unchanged; frozen-corpus optimize JSON
(3552 sessions) is byte-identical PRE vs POST.
@iamtoruk
iamtoruk merged commit ae624c4 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