Skip to content

refactor(core): kiro decode into core, stores and companions host-side (phase 8, stateful tier) - #841

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

refactor(core): kiro decode into core, stores and companions host-side (phase 8, stateful tier)#841
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase8/stateful-kiro

Conversation

@iamtoruk

Copy link
Copy Markdown
Member

Phase 8 stateful tier (tracking #809), last of three — this completes the Phase 8 tail: 35/35 provider identities migrated. Kiro's five parse arms (chat / modern / ws-session / cli / v2, four dedup namespaces) move their pure decode into @codeburn/core; companion-file reads, stat(), env/fs, and the credits→USD conversion (USD_PER_KIRO_CREDIT) stay host-side. Core emits credits; no state type, no cache or parse-version changes.

Checkpointed flow (Opus spec → Kimi M1 goldens+core / M2 CLI conversion → Opus validation). Validation found and fixed 2 real defects plus a coverage hole:

  • Parity break: A1's dedup key gained a || fallbackExecutionId the original never had — files with missing/empty executionId produced different keys. Caught by a 60-fixture differential harness against the restored original (5 divergences, all this arm); pinned by new golden G1b.
  • Vacuous smuggling guards: the claimed per-vector call-count guards were one aggregate comparing the fixtures to themselves — emptying a fixture in both copies left it green. Replaced with real per-vector counts; re-verified by independently breaking two vectors.
  • A silent mutation: "bad-timestamp turn does not advance turnIndex" survived kiro.test.ts, all 13 goldens, and the core suite — the fixture space couldn't see it. New three-turn fixtures (core + golden G6b) now kill it, alongside the other two turnIndex mutations.

Preserved verbatim and pinned: the asymmetric turnIndex semantics (zero-output turns don't advance; dedup-hit and bad-timestamp do), the A1 truncated-500-char inputTokens quirk (pinned at exact values), the three-way ws-session prepare/finish split with stat() behind both content gates, toolSequence's present-with-undefined key (key-set gated, mutation-proven). Deterministic fractional-credit pricing pinned exactly (G4b); estimated-basis assertions deliberately not pinned to vendored snapshot data.

Oracle: 16 goldens + 59 kiro.test.ts cases + 3 cache-invalidation cases pass identically against the restored pre-migration original and the migrated code, before and after merge-up (74741a8, shared files add-only unions).

Gates: core 497/497; root npm test 2456 passed, 5 skipped; kiro.test.ts byte-identical; tsc --noEmit clean both packages.

…e (phase 8, stateful tier)

Move all five kiro parse arms (legacy .chat, v1 modern execution,
workspace-session, CLI .jsonl, v2 IDE event log) into
@codeburn/core/providers/kiro as pure decode. The host keeps discovery,
every file read, the companion-file reads (CLI .json, v2 session.json),
the workspace-session mtime stat, project attribution, model display
names, and all pricing.

Behaviour is byte-identical to the pre-move provider; the four dedup-key
namespaces (kiro:, kiro:ws-session:, kiro-cli:, kiro-v2:) and the five
per-arm ParsedProviderCall key sets are unchanged.

Preserved verbatim, with tests that discriminate against plausible
refactors:
- A4's asymmetric turnIndex: a zero-output turn does NOT consume a
  user_turn_metadatas slot, while the dedup-hit and bad-timestamp skip
  arms DO. Every later turn's timestamp and metered credits depend on
  this. All three arms are mutation-tested.
- A1's toolSequence key stays present-with-undefined for single-entry
  sequences, gated by an Object.keys() assertion (toEqual cannot see it).
- A1's input tokens still derive from the already-truncated 500-char
  prompt, unlike every other arm.
- A5's dedup fallback stays `execId || String(calls.length)`, evaluated
  at flush time.
- The three-way workspace-session prepare/finish split keeps the mtime
  stat behind both content gates rather than hoisting it.

Credits seam: core emits `credits: number` and never prices. The host
multiplies by USD_PER_KIRO_CREDIT and builds costUSD/costBasis, matching
the codebuff precedent.

Validator fixes on top of the migration:
- A1's dedup key regained the raw `data.executionId` field; a fallback to
  basename(path) had been introduced, changing keys for chat files with a
  missing, empty, or non-string executionId.
- The content-smuggling non-vacuousness guard was vacuous per vector (an
  aggregate re-decode compared against itself); it now asserts per-vector
  call counts, verified by breaking two fixtures.
- Restored a mangled comment on the load-bearing v2-root derivation and
  several explanatory comments dropped during the move.
- Added goldens G1b (raw executionId), G4b (exact credit products) and
  G6b (turnIndex advances across a bad-timestamp turn), plus a core test
  for the same; all reproduce against the pre-move provider.

PROVIDER_PARSE_VERSIONS['kiro'] and CACHE_VERSION are unchanged. The
companion-file fingerprint blind spot (session-cache.ts) and the dead
project parameter on the old parseChatFile are left as-is.

This completes the Phase 8 tail.
@iamtoruk
iamtoruk merged commit 024f506 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