refactor(core): copilot decode into core (phase 8, sqlite batch 3) - #835
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 8 sqlite batch 3 (tracking #809): migrates copilot — the largest tail provider (2,432 lines, four parse paths) — into
@codeburn/corevia the bridge with tagged envelope records (jsonl | chatsession | jetbrains | otel). Driver, SQL, blobs,existsSyncgit-root probing, clock, and the sanctioned shutdown-sitecalculateCostresidual (cold/warm divergence, absentcostBasiskey) all stay host-side.durableSources: truepreserved 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:
TAILregex used a character class where the original used an alternation terminator — a|inside afile://path truncated the scan and silently degraded the project name tocopilot-jetbrains. Fixed; property test added asserting scanner coverage over the original's per-chunk walk.subagentTypesconditionally where the original always emits the key. Restored (invisible totoEqual; caught by key-presence comparison).Plus one output-identical perf fix (per-span-id map instead of O(n²)
findin 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 testboth 2362 passed, 5 skipped;copilot.test.ts(77) andcopilot-skills.test.tspass unchanged; no parse-version changes; shared wiring merged as add-only unions with batch 2.This completes the sqlite tier: 11/11.