Skip to content

Latest commit

Β 

History

History
77 lines (71 loc) Β· 20.8 KB

CORE-MIGRATION-LEDGER.md

File metadata and controls

77 lines (71 loc) Β· 20.8 KB

Core Migration Ledger

Tracks, per capability, where its authoritative implementation currently lives and what Wave moves it (if at all) into the renderer-neutral Rust Core. See docs/native/ROADMAP-QT-GPUI-DESKTOP.md Β§15 for wave definitions and docs/adr/0021-qt-gpui-native-desktop-strategy.md for the strategic decision this serves. First populated for Wave 2's first slice (2026-08-20); update this table as scope shifts β€” it is a living decision record, not a one-time snapshot.

# Capability Owner (lang/module) Renderer coupling Security sensitivity Data-integrity sensitivity Performance sensitivity Native-reuse value Migration priority Migration strategy Compatibility tests
1 Project schema TS, types.ts (916 lines) β€” StoryProject/Character/World/StorySection/Settings Medium β€” characters/worlds are typed Character[] | EntityState<Character, string>, a Redux Toolkit coupling at the type level Low High β€” canonical shape everything else depends on Low High β€” every renderer needs the same shape 1 β€” Wave 2 first slice Port the array-only member of the union to Rust structs (serde, camelCase); TS type left unchanged Golden-master JSON fixtures decode identically in Zod and Rust
2 Validation TS, services/projectImportSchema.ts (352 lines, Zod, import-only) + idbProjectStore.ts#validateAndFixState (hand-written repair-on-load, separate path) Low, but split across two divergent implementations today Low-medium (first line of defense against malformed/malicious import files) High Low High 1 β€” Wave 2 first slice Hand-rolled Rust validation mirroring the Zod ruleset for the modeled fields; does not reconcile the Zod-vs-hand-written TS divergence Same golden-master fixtures; accept/reject parity asserted per fixture
3 Storage β€” fs backend (plain load/save) TS, services/fs/ (7 files, 1,253 lines) High today (Tauri-fs-plugin coupled) Low today β€” fsCore.ts#encryptText/decryptText are dead code, zero call sites High (atomic-write semantics, compression) Medium (large-project I/O) High 2 β€” Wave 2 first slice, narrow New crate proves plain JSON load/save on its own format; does not replace projectFsStore.ts Round-trip identity tests inside the new crate only, not yet byte-compared against .wsproj
4 Logger / diagnostics TS, services/logger.ts (public API + in-memory cache) with services/diagnostics/logEntry.ts (portable model/redaction) and services/diagnostics/logSinks.ts (IDB ring buffer + Tauri JSONL + dev console), plus Rust Core proof in crates/worldscript-diagnostics Medium (dual-sink dispatch remains renderer-aware) Medium (redaction chokepoint) Low Low Medium-high β€” small, self-contained 3 β€” Wave 2 fast-follow In progress β€” Core model/redaction and TS/Rust parity are CI-proven; recursive redaction and the typed TS sink boundary are locally proven in #441 and CI merge-gated; no authority switch Shared JSON fixtures are exercised independently by Rust and TS for recursive redaction and LogEntry wire shape; browser/Tauri sink adapters now consume the portable TS LogEntry; sink parity and production wiring remain open
5 Task-orchestration expansion Rust, src-tauri/src/commands/task_supervisor.rs (bounded text.analyze/text.diff) + TS packages/worker-bus/ (5,130 lines, full orchestration surface) worker-bus TS side is Web-Worker-pool coupled; Rust side is renderer-neutral for the bounded proof Low-medium Low (task results, not persisted project state) Medium-high High long-term, existing Rust is a narrow stub 4 β€” Wave 2 fast-follow Bounded task proof CI-proven in #430; full extraction not started Rust tests cover structured failure, input bounds, deterministic analysis, diff parity, and the v1.0.0 request/result contract; no broad worker-bus authority switch
6 Storage β€” IDB backend (all encryption) TS, services/storage/ (18 files, 5,363 lines) β€” mature AES-256-GCM, ADR-0018 "Accepted and implemented" High β€” IndexedDB is browser-only, not portable to Qt/GPUI as-is High, mature High Medium Low as literally written; high as a design reference Deferred to Wave 3-4 None in Wave 2. ADR-0018's 6 invariants are required reading for Wave 3 crypto design None in Wave 2
7 features/project/ domain logic TS, features/project/ (24 files, 2,114 lines) β€” real logic concentrated in thunks/ + projectSelectors.ts (~450-500 lines); reducers/ (11 files) is CRUD bookkeeping High β€” Redux-store-shape/dispatch bound; reducers/ stays TS-side permanently Low Medium (import/restore orchestration) Low-medium Medium (only the thunks/selectors subset) Deferred Candidate after the schema crate is proven; only thunks/selectors, never reducers/ Not started
8 AI services TS, services/ai/ (44 files, 5,401 lines), mixed portability (retry/routing/error-taxonomy renderer-neutral vs. computeShaderFactory.ts/webGpuDetectorService.ts/.wgsl inherently WebGPU-coupled) Mixed Medium-high (API keys) Low-medium Medium Uncertain β€” too large/mixed to assess narrowly Out of scope for all of Wave 2 None proposed None
9 Project state-shape compatibility adapter TS, features/project/coreBoundaryAdapter.ts at the Core boundary + Rust, crates/worldscript-project schema High at the boundary β€” production Redux EntityState must be translated without importing Redux into Core Low High β€” ID/order preservation is part of project identity Medium High β€” every native renderer needs the same conversion contract 2 β€” Wave 2 prerequisite before G1 evaluation Current-production #553 closure complete; Rust Core authority switch not started (#836). IMPLEMENTATION_STARTED = YES. Every current-production Project path is canonical and no-loss according to backend semantics (#553, PRs #773–#849): textual raw carrier and lexical tokens on the filesystem, structured-value semantics in IndexedDB. Persistence and admission: shared TS/Rust classification including the raw-token grammar; LEGACY_TO_V1 admitted in memory and migrated durably on both backends (IndexedDB authority; filesystem under the project lock with a pre-migration snapshot, #849); the generation-fenced canonical IDB authority for web/PWA autosave, flush and manual save; the desktop filesystem writer as a preserve-first raw-carrier writeback under the project lock with a generation/incarnation fence. Egress: export and library backup (projects and snapshots), stripped to portable form. Snapshots: creation and restore, each admitted, with an exact restore carrier. Import: every modeled field admitted and projected, then an admitted-raw first save (#842, #848); a null tension score is admitted so the project remains loadable, omitted from the typed editor projection, and preserved in the canonical raw carrier. Export: every JSON surface, including Advanced import/export, through the canonical egress (#847). Replacement and authority: same-ID replacement writes a fresh canonical document, with carriers bound to target, epoch and authority; the desktop fails closed when filesystem storage is unavailable, with no IndexedDB fallback; an unloadable browser record is refused and kept. The closure guarantees no silent loss or replacement of stored data; it does not promise that every malformed shape boots into the editor (malformed manuscript-section hardening is #845). TypeScript remains the production Project authority; the renderer-neutral Rust Core authority switch is separate future work (#836). Normalizes array or Redux EntityState to renderer-neutral arrays and reconstructs the TS-side shape only at the integration boundary. The Rust verdict remains partial because unknown fields are not rejected (Rust is observation-only until #836); within the current TypeScript authority, every current-production ingress, writer, migration and egress preserves the authoritative canonical carrier according to backend semantics β€” the textual raw carrier and its lexical tokens where textual authority exists (filesystem), the stored structured value in IndexedDB (canonically serialized where text is needed, with no claim that original JSON text survives). Both required decisions (persisted version authority; a field-class-staged unknown-field policy, not one global policy) are resolved and maintainer-admitted in docs/native/PROJECT-CORE-COMPATIBILITY-CONTRACT.md, PROPOSED = YES / ADMITTED = YES. Issue #553's current-production implementation of that contract is complete; its terminal acceptance is QNB-99 (pending); the authority switch it gates is #836. tests/unit/features/project/coreBoundaryAdapter.test.ts covers array and EntityState inputs, round-trip ID/order preservation, and rejection of duplicate IDs, missing references, and orphaned entities for both characters and worlds; tests/unit/features/project/projectSchemaVersion.test.ts and crates/worldscript-project/tests/version_test.rs cover classification/parity; the IDB load observation is covered by tests/unit/services/storage/idbProjectStoreLoadStateObservation.test.ts; the canonical parser/import/admission foundation is covered by tests/unit/projectDocument.test.ts and tests/unit/projectImportSchema.test.ts; the writeback overlay/verify/fence primitive by tests/unit/services/projectDocumentWriteback.test.ts; the IDB canonical admission/durable-commit boundary (against real fake-indexeddb, including a generation-conflict rejection, a Β§2.7 downgrade-contradiction, and an encrypted round trip) by tests/unit/services/storage/idbProjectCanonicalAuthority.test.ts; production routing/refusal-success coverage by tests/unit/services/projectAutosavePersistence.test.ts, tests/unit/persistedStateFlush.test.ts, and the listener/shortcut tests; the envelope fixture is accepted by Rust after migration and validation; the #553 current-production closure (a1–a11) by tests/unit/services/projectCanonicalEgress.test.ts, tests/unit/libraryBackupService.test.ts, tests/unit/services/fs/fsStores.test.ts, tests/unit/services/projectAutosaveCanonicalWriter.test.ts, tests/unit/services/projectImportCarrier.test.ts, tests/unit/storageServiceDesktopAuthority.test.ts and tests/unit/malformedProjectBoot.test.ts
10 R-15 protected desktop storage contract Contract docs/native/R15-SECURE-STORAGE-CONTRACT.md + headless Rust implementation (Gates 1a/1b/2 and Gate 3 slices 3A, 3B and 3C parts 1–3c-2b) in crates/worldscript-secure-storage, not production authority; current desktop records remain TS/Tauri filesystem authority High β€” future Core must serve Tauri and Qt without renderer-private crypto semantics High High β€” durability, migration, and identity binding protect user data High Highest β€” cross-renderer security/durability contract 3 β€” S5-A, S5-B1, S5-B2, and S5-B3 all admitted; final cross-contract audit complete, S5_TERMINAL=YES (PR #584 merged c24aa645, post-merge CI/CD + CodeQL green); Gate 1a re-admitted by QNB-100 (2026-09-26) and implemented headless in crates/worldscript-secure-storage; Gate 1b decided 2026-09-26 (Option C: platform secure store primary, optional WSS_ARGON2ID_V1 passphrase recovery); 1b-core landed (#850); 1b-platform delivered as small sequential slices β€” Β§8.2.2 item layout (#854), durable authority (#855), runtime key handles (#914), anchor transitions + KeyProvider (#915), OS secure-store adapter (Β§8.2.5, #916; evidence Linux CI_ONLY/LOCAL_ONLY, macOS/Windows CI_ONLY, no packaged evidence); Gate 2 (typed identity registry, identity-bound record codec and Β§10.4.1 record-class disposition) admitted and implemented headless (Β§20, #920); legacy source-locator mapping belongs to Gate 5; #361's shipped-helper gap closes only with Gate 7; Gate 3 slice 3A (durable staging and promotion, Β§9 steps 3–8) and slice 3B (the record-commit marker codec, Β§5.4, and the marker commit protocol with startup reconciliation, Β§9/Β§9.2) and slice 3C parts 1–3c-2b (the authority-root digests, Β§5.4, the record-catalog descriptors and pages, Β§5.5/Β§5.5.1, the root slot, pointer and key-epoch record encodings, Β§5.3.4, and the two-phase root commit with crash recovery and the trusted cold start including the key-epoch set check, Β§5.3.1, the persisted, root-verified record catalog with list_records, Β§5.5/Β§5.5.1, and the protected write and read paths committing every marker transition through the root, Β§9) implemented headless, so Gate 3 is implemented headless (#921; closure evidence and residual owners β€” asset-pair β†’ Gate 5, key-epoch crash window and reclamation β†’ Gate 4, power loss β†’ Gate 6, deletion β†’ #948, #357's legacy path β†’ Gate 7 β€” in contract Β§20); Gate 4 slice 4A (the cross-process root_commit_mutex, Β§11.1) and the 4B kernel admission foundation admitted and implemented headless; 4B protected-operation/snapshot/lifecycle integration implemented headless in PR #954; Gate 4 slice 4C journal manifest and paged inventory codec implemented headless in PR #956 (pending final-head convergence); Gate 4D slice A execution-state helpers landed; durable journal I/O and remaining 4D/4E slices remain; Gates 5–7 not admitted S5_A_ADMITTED=YES / S5_B1_ADMITTED=YES / S5_B2_ADMITTED=YES / S5_B3_ADMITTED=YES / S5_IMPLEMENTATION_READY=NO / S5_TERMINAL=YES / R15_GATE1A=IMPLEMENTED_HEADLESS / R15_GATE1B=IMPLEMENTED_HEADLESS_AND_PLATFORM_ADAPTER / R15_GATE2=IMPLEMENTED_HEADLESS / R15_GATE3=IMPLEMENTED_HEADLESS / R15_GATE4=SLICE_4D_MIGRATION_STATE / PRODUCTION_AUTHORITY_SWITCH_ALLOWED=NO; inventory, identity/AAD envelope, key epochs, fail-closed reads, durable replacement, crash-resumable migration, unified admission, race-free AuthoritySnapshot acquisition/lifetime (docs/native/r15/AUTHORITY-SNAPSHOT-LIFETIME.md), canonical migration source/payload evidence (docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md), and the chunked large-object envelope (docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md) are all specified. No production authority switch or plaintext migration is claimed. Final S5 cross-contract consistency audit (mutual reference integrity across all four documents) is complete β€” two mechanical citation-drift notes (a stale disposition-count note in Β§10.4.1, and S5-B3's mis-citation of S5-B1's migration-time mechanism for its own ordinary-write staging debris) and three substantive gaps were corrected: S5-B3's chunk-locator carried no operation/generation identity, so recovery could not distinguish a superseded attempt's orphaned chunk from the current one; Β§10.4.1's atomic-write-temporary-files carve-out contradicted its own "exactly one of three groups" exhaustiveness claim; and fixing that carve-out into an explicit REFUSE_AUTHORITY_SWITCH group in turn made Gate 7's class-level rule permanently unsatisfiable for that one class, fixed by making Gate 7 instance-aware. S5_TERMINAL is YES: PR #584 merged and its post-merge main CI (incl. CodeQL) was green. Gate 1a's headless vectors (contract header fixture, fixed-key AEAD for absent/present project_id, rule-D boundary, malformed-input and substitution tests, cross-checked against an independent implementation) now exist; the Gate 1b platform secure-store adapter exists with CI/local per-platform evidence (#916, contract Β§8.2.5); packaged secure-store evidence, Gate 4 slice 4C journal codec is implemented headless; durable journal persistence, rekey, and enable/disable slices (4D–4E; root-commit serialization and operation admission/snapshot/lifecycle integration exist headlessly), per-record migration tests, packaged durability evidence, and explicit #357/#359/#360/#361 reconciliation are still required before the later implementation gates can close

Decisions this table records

  • Row 9 current implementation truth: #553's current-production no-loss closure is complete.
    • Every Project ingress, writer and egress path in the current TypeScript authority admits canonically and preserves the authoritative carrier by backend semantics (textual raw carrier on the filesystem, stored structured value in IndexedDB): filesystem load, IDB load and boot, import, snapshot create and restore, export, library backup, autosave, flush, manual save and replacement.
    • Local routing metadata is stripped at portable boundaries.
    • This is not a Rust Core authority switch. TypeScript remains the production Project authority, and the renderer-neutral switch is #836.
  • Row 9 desktop routing qualification: Tauri uses the filesystem store selected by storageService, whose writer is fenced by the project lock and a generation/incarnation check.
    • If fileSystemService.initialize() fails, startup records DesktopStorageAuthorityUnavailableError and fails closed: every storage access is refused and no IndexedDB store is selected (#843).
    • A failure of the best-effort legacy API-key cleanup after the filesystem is established is only a warning and cannot change the project store.
    • Browser/PWA uses the canonical IDB authority.
    • IndexedDB records written by packaged desktop before #843 may still exist on disk; R-15 migration discovery keeps them as sources (R15 Β§10.1.3).
  • Wave 2 first slice touches only rows 1-3, narrowly: project schema, validation, and a plaintext (no compression, no atomicity guarantee) fs load/save round-trip. This is deliberately the smallest slice that satisfies Wave 2's stated exit criterion ("representative project lifecycle executes without any GUI runtime") β€” see crates/worldscript-project/.
  • Row 6 (IDB encryption) is the mature reference design for Wave 3-4, not a Wave 2 target. It stays fully TS-side and untouched; only its design (ADR-0018's invariants, the journal/ checkpoint/lease saga) informs the future Rust crypto module.
  • Row 8 (AI services) is explicitly out of scope for all of Wave 2, not just this slice β€” it is too large (5,401 lines) and too mixed in portability (WebGPU-coupled pieces have no Rust path) for a clean narrow extraction. Revisit only once rows 1-5 are proven.
  • Row 9 is a required compatibility position before G1 is evaluated. The Core's deliberate Vec-based model is not the Redux EntityState shape; the adapter contract, its ID/order fixtures, and a first observation-only desktop caller are now proven at the boundary. This does not move Redux reducers or make EntityState part of Core, and it does not make the Rust verdict authoritative.
  • Row 9 boundary policy is deterministic for both characters and worlds and is now implemented in features/project/coreBoundaryAdapter.ts. Array-to-EntityState conversion rejects duplicate or missing stable IDs. EntityState-to-array conversion rejects an ids entry without a matching entity, an entity absent from ids, or duplicate IDs; it never silently drops, synthesizes, or last-write-wins. Valid input preserves the declared ids order and entity IDs in the boundary fixtures. The first caller observes a synthesized, partial envelope only; this proves the boundary integration, not complete validation or an authority switch.
  • Row 4 has a narrow CI-proven Core proof and a locally proven, CI-merge-gated typed sink boundary. crates/worldscript-diagnostics owns only the typed structured-log model and the recursive key-redaction semantics; PR #437 established the original parity contract and #441 extends it with recursive coverage. The browser/Tauri sink adapters now receive the portable TypeScript LogEntry from services/diagnostics/logSinks.ts; IDB, Tauri JSONL, and development-console ownership remains renderer-specific, and no production caller or authority switch is claimed.
  • Row 5 is already locally and CI-proven as a bounded Tauri supervisor proof (text.analyze and text.diff, with structured failure semantics); full worker-bus extraction and G1 completion remain open.

What Wave 2's first slice does NOT do

No encryption (design or implementation) β€” Wave 3-4 only. No touching services/storage/* (IDB) or reconciling it with fs storage. No packages/worker-bus subsumption or task_supervisor.rs task- registry expansion. No services/ai/* work. No changes to src-tauri/src/lora.rs or pandoc.rs. No Qt/GPUI code. No unifying src-tauri/Cargo.toml into one repo-root Cargo workspace (see crates/Cargo.toml's own scope note). No replacing projectFsStore.ts/storageService.ts's dispatch β€” any future Tauri-command wiring is additive-and-unused-by-default only. No Row-9 authority switch is included in this slice; the typed boundary contract, fixtures, and one observation-only desktop caller are proven independently. The caller's envelope is synthesized and partial, and unknown persisted fields are outside its verdict. No sink migration, Tauri adapter rewiring, or authority switch is included in the logger proof. No compression-format parity with the existing .wsproj files (open question, not solved here).