Skip to content

[DEBT]: Migrate repositories to durable transaction kernel#110

Merged
anantham merged 3 commits into
mainfrom
debt/codex-db-repository-migration
Jul 16, 2026
Merged

[DEBT]: Migrate repositories to durable transaction kernel#110
anantham merged 3 commits into
mainfrom
debt/codex-db-repository-migration

Conversation

@anantham

Copy link
Copy Markdown
Owner

Summary

Migrate Settings, Feedback, Prompt Templates, and Chapter repository transactions onto the durable terminal-event kernel introduced by PR #109. This removes divergent request-success lifecycles, consolidates Chapter stable-ID lookup, and preserves injected database/public repository contracts.

This PR is intentionally stacked on debt/codex-db-transaction-kernel; review only the delta above #109.

Root Cause

The repositories opened IndexedDB transactions independently and several resolved their public promises from request success. A request can succeed in memory and still be rolled back by a terminal transaction abort, so callers could observe false success. Chapter also duplicated its stable-ID index/cursor fallback between read and update paths.

Changes

  • SettingsRepository.ts: delegate reads/writes to runTransaction and promisifyRequest
  • FeedbackRepository.ts: migrate CRUD, normalize helper naming, remove two legacy any casts
  • PromptTemplatesRepository.ts: migrate CRUD while preserving numeric default-index and legacy scan behavior
  • ChapterRepository.ts: migrate all paths and share one stable-ID lookup helper
  • RepositoryDurability.test.ts: post-request quota-abort contract for every migrated repository
  • Legacy index-fallback and typed missing-chapter tests
  • DB-002 implementation notes, WORKLOG metrics, and Node 26 test-environment debt receipt

Refactoring Metrics

  • Direct repository transaction lifecycle implementations: 4 -> 0
  • Chapter stable-ID lookup paths: 2 -> 1
  • Production LOC: 543 -> 480 (-11.6%)
  • Cyclomatic branch proxy: 59 -> 49 (-16.9%)
  • Targeted coverage: statements 74.73% -> 92.70%; branches 53.91% -> 66.31%; functions 73.01% -> 96.77%; lines 82.35% -> 93.93%
  • Main chunk: 4,146.71 -> 4,144.57 kB minified; 993.16 -> 992.97 kB gzip
  • Type safety: 2 any casts removed; no any added; interfaces unchanged
  • Performance signal: unchanged 14-case behavior suite 28 ms -> 22 ms locally; transaction/request counts unchanged

Testing

  • 35 focused transaction/repository tests pass
  • 62 complete DB tests pass
  • Full Vitest: 8,797 passed, 356 skipped
  • Production build passes
  • Targeted coverage captured before/after
  • tsc --noEmit is globally clean (unchanged repository baseline errors remain; no modified file is named)

Node 26 requires NODE_OPTIONS=--no-experimental-webstorage for the full suite because its experimental global Web Storage accessor shadows jsdom localStorage; the isolated diagnosis and debt receipt are in the commit.

Review Checklist

External Review

The attempted Grok review was denied by the approval layer because it would transmit private repository context to xAI. No Grok output was obtained and no external-review claim is made.

Context: Settings, Feedback, Prompt Templates, and Chapter repositories maintained divergent request-success transaction paths after the shared kernel was introduced.

Changes: Delegate repository transactions to runTransaction, consolidate Chapter stableId lookup, preserve legacy index fallbacks, and add table-driven commit-abort coverage.

Impact: Public repository interfaces and IndexedDB request counts are unchanged; write success now means terminal commit and typed errors retain repository context.

Tests: 35 focused transaction/repository tests; 62 DB tests; 8,797 full-suite tests passed with 356 skipped; production build passed.

Docs: Update WORKLOG and tech-debt inbox with metrics and the Node 26 test-environment receipt.

ADR: DB-002 repository migration implementation notes.
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexicon-forge Ready Ready Preview, Comment Jul 16, 2026 6:24am

Context: The required completion WORKLOG entry was written before the stacked PR had a number.

Changes: Record PR #110 and update the next-step state.

Impact: Documentation only.

Tests: git diff --cached --check.

ADR: DB-002 unchanged.
@anantham
anantham changed the base branch from debt/codex-db-transaction-kernel to main July 16, 2026 06:16
@anantham
anantham marked this pull request as ready for review July 16, 2026 06:23
@anantham
anantham merged commit 3d75ba8 into main Jul 16, 2026
4 of 5 checks passed
@anantham
anantham deleted the debt/codex-db-repository-migration branch July 16, 2026 06:23
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