refactor(core): mistral-vibe decode into core with host-side cost resolution (phase 8, judgment tier) - #838
Merged
Conversation
…olution (phase 8, judgment tier) Moves the Mistral Vibe rich decode into @codeburn/core behind the bridge: discovery, file I/O and pricing stay CLI-side, the pure record decode (including the even allocation of the session dollar figure and the session token totals across assistant messages) moves byte-exact into core. Seam adjudication: the draft brief said the `session_cost > 0` gate should move into core. It cannot — that gate is the first arm of a three-arm cost resolution whose last arm consults the generic price table, which is forbidden in core. The whole resolution therefore stays host-side in `calculateSessionCost` and core receives a pre-resolved `sessionCost`; core keeps only the pure allocation arithmetic (allocateInteger / allocateCost, allocationIndex / assistantOrdinal), unchanged in rounding, remainder distribution and float operation order. The move is observationally equivalent: the original resolved the cost once per session during parse, with no per-call state. Validator fixes on the draft: - core dropped the `metadata.session_id || basename(sessionDir)` fallback, emitting sessionId '' (and colliding dedup keys `mistral-vibe::<msg>`) for sessions whose meta.json omits session_id. The host now passes `sessionIdFallback`. - `toProviderCall` set `turnId: undefined` unconditionally, adding a key the original omits entirely on the no-assistant session-level arm. - the moved comment block described a seam that no longer exists; adjusted minimally to describe where the resolution actually lives. Parity was verified arm-by-arm against the pre-migration decode checked out in place over a 28-session adversarial fixture matrix (strict equality plus per-call key-presence), and the adversarial allocation arms (7 over 3, 1 over 3, terminal zero-cost, idx-N keys, basename fallback, float-op order) are promoted into the bridge and core decode tests with values captured from the original.
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 judgment tier (tracking #809): migrates mistral-vibe — the Phase 0 pricing misfit — completing the simple tier at 15/15. Seam adjudicated during validation: the three-arm session-cost resolution (measured
session_cost→ Vibe per-million prices →calculateCosttable fallback) stays host-side inreadRecords(its last arm needs the price table, forbidden in core); the pure allocation arithmetic (allocateInteger/allocateCost, remainder-to-first, exact float operation order) moves into core verbatim. Observational equivalence proven: same once-per-session resolution, same gates, same inputs.Kimi two-phase (4 goldens with allocation-remainder fixtures and a measured-cost identity pin through the pricing pass, verified pre-migration) → Opus validation, which found and fixed 3 defects, one critical:
|| basename(source.path)session-id fallback — sessions lackingsession_idin meta emitted collidingmistral-vibe::<msg>keys on the shared seenKeys set (silent data loss). Fixed via asessionIdFallbackon the envelope.turnIdspread put aturnId: undefinedkey on the session-level arm the original omits. Fixed (same pre-existing pattern in gemini.ts flagged, untouched).Oracle: original run in-place against a 28-session adversarial matrix (52 calls) — 5/5 strict-equal including sorted key sets and second-pass seenKeys. Mutation: 8/8 mutants killed by the permanent suite (remainder-to-last, reciprocal multiply, floor→round, ordinal-after-increment, precedence swaps, unconditional turnId), with float order pinned to last-bit values.
Gates: core 420/420; CLI suite and root
npm testboth 2413 passed, 5 skipped;tsc --noEmitclean; discovery byte-identical; no parse-version changes; no pricing imports in core (arch gate green).