Skip to content

refactor(core): mistral-vibe decode into core with host-side cost resolution (phase 8, judgment tier) - #838

Merged
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase8/judgment-mistral-vibe
Jul 27, 2026
Merged

refactor(core): mistral-vibe decode into core with host-side cost resolution (phase 8, judgment tier)#838
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase8/judgment-mistral-vibe

Conversation

@iamtoruk

Copy link
Copy Markdown
Member

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 → calculateCost table fallback) stays host-side in readRecords (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:

  • Dedup-key collision (critical): core dropped the original's || basename(source.path) session-id fallback — sessions lacking session_id in meta emitted colliding mistral-vibe::<msg> keys on the shared seenKeys set (silent data loss). Fixed via a sessionIdFallback on the envelope.
  • Key-shape: unconditional turnId spread put a turnId: undefined key on the session-level arm the original omits. Fixed (same pre-existing pattern in gemini.ts flagged, untouched).
  • The moved cost-resolution comment adjusted minimally where the seam change made two clauses false; substance verbatim.

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 test both 2413 passed, 5 skipped; tsc --noEmit clean; discovery byte-identical; no parse-version changes; no pricing imports in core (arch gate green).

…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.
@iamtoruk
iamtoruk merged commit 87b72d7 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