refactor(core): antigravity decode into core, stitching and caches host-side (phase 8, stateful tier) - #839
Merged
Conversation
…st-side (phase 8, stateful tier) Moves every record-parsing arm into @codeburn/core/providers/antigravity: the protobuf wire reader, the gen_metadata row decode, the RPC generatorMetadata decode, the statusline JSONL run-collapse/delta decode, and model canonicalization. All five emit arms (statusline, cache-hit, sqlite, RPC, RPC-failure fallback) plus the snapshot write-path keep their host-side control flow byte-for-byte. Cache integrity: CACHE_VERSION stays 5 and antigravity-results.json keeps its shape. The cache is not re-derivable — the RPC-failure fallback arm replays cached.calls for cascades whose language server is gone — so no bump, and the cache-write-before-seenKeys-filter ordering is preserved in both the sqlite and RPC arms. Pricing stays host-side: normalizePricingModel / PRICING_ALIASES remain in the CLI, and every arm now emits through one shared toProviderCall carrying costBasis 'estimated' plus pricingModel, and no costUSD. parseStatusLinePayload's wall clock becomes an injected `at` parameter; the host passes new Date().toISOString() at each call site, once per payload. Validator fixes on top of the migration: - content-smuggling: the hostile statusline record used the hook-payload shape, so the decoder dropped it and the cwd/session_id assertions proved nothing; corrected to the recorded-event shape, with a call-count guard. - goldens: G14 maps through the exported host toProviderCall instead of a private copy, and a new G15 pins the emit loop's turnIndex-before-seenKeys and previousSnapshotUsage-before-skip ordering, which no golden could previously detect. - core: removed an unused type import and a dead CANONICAL_TOOL_NAME const; restored the statusline reasoningTokens rationale comment.
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 stateful tier (tracking #809), first of three: antigravity. All five parse arms' pure decode moves into
@codeburn/core(proto wire reader, gen_metadata row decode, RPC metadata decode, statusline decode + run-collapse + deltas, model canonicalization); everything stateful stays host-side by design — the results cache, memo Maps, project attribution, timestamp stabilization,normalizePricingModel, and all I/O (sqlite, RPC, process probing). Bespoke adapter preserved (per the recipe, stateful providers do not use the bridge). No state type needed: every arm is a whole-batch pure function.Cache integrity was the gating property: the version-5 results cache is NOT re-derivable (the RPC-failure fallback serves cascades whose only surviving usage record is the cache). Verified by byte-diff, not inspection:
loadCache/flushCacheidentical, cache-write-BEFORE-dedup-filter ordering preserved in both arms, both fallback arms byte-exact,CACHE_VERSIONandPROVIDER_PARSE_VERSIONSuntouched.Flow: Opus spec (8-source store map, 14-golden plan) → Kimi two-phase (goldens 14/14 pre-verified with only a sanctioned temporary export; then the migration) → Opus validation with an in-place oracle restoration (51/51 against pre-migration source) and a mutation battery on the six-operation statusline emit loop (one mutation proven unobservable by value analysis; two real detection gaps closed with a new golden G15). Validator fixes:
[], so planted secrets never entered the pipeline. Corrected + non-vacuousness guard.toProviderCall, making the RPC arm's emitted shape a real oracle.costBasis: 'estimated'+pricingModel, nocostUSD) is now emitted by ONE sharedtoProviderCallwith key-presence gates on every golden.Gates: core 436/436; CLI suite and root
npm testboth 2428 passed, 5 skipped (delta vs base exactly the +15 new goldens);tsc --noEmitclean; the injected wall clock is the sole semantic edit (host passesatonce per payload, matching the original).Known residual (pre-existing): the RPC arms have no end-to-end execution coverage anywhere (require a live language server) — covered by byte-diff + decoder-level goldens, as before.