Skip to content

refactor(core): copilot decode into core (phase 8, sqlite batch 3) - #835

Merged
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase8/sqlite-copilot
Jul 27, 2026
Merged

refactor(core): copilot decode into core (phase 8, sqlite batch 3)#835
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase8/sqlite-copilot

Conversation

@iamtoruk

Copy link
Copy Markdown
Member

Phase 8 sqlite batch 3 (tracking #809): migrates copilot — the largest tail provider (2,432 lines, four parse paths) — into @codeburn/core via the bridge with tagged envelope records (jsonl | chatsession | jetbrains | otel). Driver, SQL, blobs, existsSync git-root probing, clock, and the sanctioned shutdown-site calculateCost residual (cold/warm divergence, absent costBasis key) all stay host-side. durableSources: true preserved through the bridge.

Three-stage flow: Opus guidance spec (90-row per-path checklist) → Kimi execution in two checkpointed phases (goldens G1–G8 captured from the unmodified provider and verified 8/8 before any source edit; then the migration) → Opus differential validation.

The validator ran an original-vs-bridged oracle over 27 scenarios comparing calls, sorted seenKeys, and a normalized key-presence shape, and found two real defects the goldens alone missed:

  • JetBrains superset scanner: TAIL regex used a character class where the original used an alternation terminator — a | inside a file:// path truncated the scan and silently degraded the project name to copilot-jetbrains. Fixed; property test added asserting scanner coverage over the original's per-chunk walk.
  • OTel arm emitted subagentTypes conditionally where the original always emits the key. Restored (invisible to toEqual; caught by key-presence comparison).

Plus one output-identical perf fix (per-span-id map instead of O(n²) find in the OTel chat loop). Oracle-proven edge scenarios promoted into the bridge test as G9–G17 (17 goldens total). JetBrains/OTel perf measured synthetically: typical-shape ≥1× (memoized dir probes), adversarial ~2× on ~10ms absolute, OTel 1.00× wall with comparable heap.

Gates: core 339/339; CLI suite from packages/cli and root npm test both 2362 passed, 5 skipped; copilot.test.ts (77) and copilot-skills.test.ts pass unchanged; no parse-version changes; shared wiring merged as add-only unions with batch 2.

This completes the sqlite tier: 11/11.

Bridged via a tagged envelope record across the four parse paths
(jsonl / chatsession / jetbrains / otel): readRecords shapes one envelope
per source kind and a single decodeCopilot dispatches on envelope.kind.

The sqlite driver, the three OTel queries, blob reads, git-root probing,
extractBashCommands / extractOtelBashCommands, and the sanctioned
shutdown-site calculateCost residual all stay host-side. The residual
keeps its exact argument order (model, input, 0, cacheWrite, cacheRead, 0),
emits costUSD + costIsEstimated: false with no costBasis key, and carries
its explanatory comment unchanged.

Validator fixes over the draft:
- collectJetBrainsRepoDirCandidates used a [\|"] character class instead
  of the original's (?:\\|") alternation, so a file:// path containing a
  pipe was truncated, its dir never resolved, and the JetBrains project
  fell back to the generic bucket. Restored the alternation.
- the otel arm dropped the subagentTypes key when undefined; the original
  always emits it. Restored so key presence matches byte for byte.
- otel chat-span attributes were looked up with a linear Array.find per
  chat span; replaced with a per-span-id map built in the same pass.

Verified by a differential harness running the pre-migration provider
against the migrated one over 27 scenarios (all eight goldens plus
edge cases), comparing calls, seenKeys, and key presence. The harness is
not committed; the scenarios it proved are now goldens G9-G17.
@iamtoruk
iamtoruk merged commit f984728 into feat/core-extraction Jul 27, 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