feat(store): verified migration and exclusive ownership (PR 1/9) #652
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/platform-store-safety"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Platform service-store startup could mark a failed redb import complete, silently ignore conflicting values, and let multiple runtimes share cached state without an exclusive owner. This PR adds verified offline migration and opt-in ownership fencing before any platform storage cutover. It implements PR 1/9 of the merged design in #651.
Changes
akh-store-migratewith private, byte-preserving redb manifests, plan-only Postgres import, atomic verified import receipts, exact-manifest retry reconciliation, current-Postgres export and no-clobber redb restore. Refuse corrupt/missing sources, partial/conflicting targets, legacy markers masquerading as receipts, and active exclusive owners. Apply requires explicit--apply --quiescent; credentials are read from a named environment variable and never printed.legacy,disabledandrequire_receiptimport policies plus configurable cache capacity. Existing config/backend defaults remain compatible. Legacy imports now fail closed on unreadable sources or unequal conflicts instead of committing a misleading marker, and count only actual inserts.(schema, kind)ownership on one physical PostgreSQL connection. Reads, cache hits, writes and commits use that owner; reconnect is refused. Database errors and five-second query deadlines fence the instance. Independent owners use separate workers and transaction locks.akh-session-services(akhrtd,akhsessd,akheventdand common startup) and the core operations API. Guard readiness/admission and dispatch, and cancel local service work on owner loss. Fix transaction rollback during caller unwind so it runs on the database worker.Validation
cargo test --locked -p akh-session-services --lib: 129 passed.cargo test --locked --lib --features server core_service::tests: 25 passed, rerun after rebasing on current main.cargo check --locked -p akh-session-services --all-targetsandcargo check --locked --lib --features server: passed.cargo clippy --locked -p akh-service-store --all-targets -- -D warnings: passed. The broader session-services strict-Clippy check reports 28 existing warnings in unchanged code (mostly collapsibleifstatements); it is not claimed green.cargo fmt --all -- --checkandgit diff --check: passed.postgres:latest; observed PostgreSQL 18.6 (Debian 18.6-1.pgdg13+2), digestsha256:74935e72241653ca55e0414067e6d8763aceb8a810eb51b452253ec3dcfc4336. This records the tested image, not a new pin. No provider image/tooling build or deployment was performed.Review fixes
tracing::error!at initialization and operation failures, including legacy mode. API faults stay generic; the connection URL is not logged. A corrupt-legacy-source process test verifies the specific cause appears without the URL, credential or source contents.Fault.messagein the CLI. Integration tests distinguish nonempty targets, destinations changed after import, uncertain database outcomes, and refused no-clobber restores, without printing fixture payloads or credentials.store_owner_lostafter cancellation requests, HTTP drain and telemetry cleanup. The real daemon test now requires exit code 1 and verifies the operation diagnostic and readiness loss.Fix validation: 178 tests passed (47 store tests, 2 daemon process tests, 129 session-service unit tests); strict store Clippy, formatting and diff checks passed. The core test/check evidence above is retained from the initial PR validation; these fixes do not change core code. Tests use disposable local PostgreSQL only; no deployment, production import or volume change. The operator retains merge authority.
Operational boundary
This does not activate any production option, import production data, touch Pending pods, read/extract the protected wk01 archive, or switch/remove volumes. Tests use synthetic records and disposable local PostgreSQL only. No Board use.
Legacy writers must be drained before an eventual import/exclusive-owner cutover: they do not honor the new owner lock. Database ownership cannot prove an orphan provider stopped or undo an external effect; uncertain jobs retain their identity and require same-request reconciliation. Generic raw-record tooling does not split the existing shared runtime namespace or establish the disposition ledger. Core cognitive residency remains separate.
PRs 7–9 remain gated on that ledger and a separate operator GO. PR 6 must reuse the Talos #208/#212 houses artifacts and stop if registry/placement conflicts arise. Nothing is deployed here; future runtime artifacts must come from merged main. Operator reviews and merges this PR; PR 2 starts only after that merge.