WIP: Persist thinking checkpoints and recover after cold wake (WI-406) #512

Draft
toasterson wants to merge 2 commits from claude/wi-01a08262-thinking-persistence into main
Owner

Work item: WI-406 (01a08262-3f5d-7bb0-b621-d5dc4a7c9092).

PostgreSQL-backed thinking previously used the in-memory persistence seam, losing interrupted traces at process exit. This adds Akh/workspace-scoped trace and step tables, stable durable IDs, ordered duplicate-idempotent writes, and atomic versioned checkpoints under the existing pinned residency owner and snapshot fence. Engine thinking now uses that backend and exposes interrupted listing plus explicit resume after cold wake; memory/null backends remain available.

Before acknowledging each boundary, the exact installed graph WAL drains with failure/overflow refusal. The checkpoint's symbol metadata closure is committed in the same WAL transaction and validated during cold restore, so a newly created goal or first-use predicate survives a crash even when it postdates the snapshot. Canonical checkpoint encoding, predicate identity validation, and stale-owner/current-thread refusal prevent ambiguous recovery.

Validation: 67 executed tests passed: store19, SQLite4, store PostgreSQL1, thinking/snapshot41, cold-wake PostgreSQL1, daemon disconnected-backend1 (one existing root test ignored). No-default lib and server lib/bin checks pass. Ordinary Clippy passes with baseline warnings; strict Clippy fails seven unchanged grug-data findings. Two independent source reviews approved tested source bd8c34bff49e5490028fbbc30fad97e2b4c957b3; final head adds only the committed validation receipt. The real PostgreSQL tests used an owned disposable local container and simulated loss after a committed boundary; this is not a deployment/runtime outage witness.

Design and exact local validation. The pending WI-293 dependency witness, draft phase, parent hold and canonical exact-head review/native CI remain unchanged. Envelope foreign-key integration remains in parent WI-50 as scoped by the brief. No deployment or production database action.

Work item: WI-406 (`01a08262-3f5d-7bb0-b621-d5dc4a7c9092`). PostgreSQL-backed thinking previously used the in-memory persistence seam, losing interrupted traces at process exit. This adds Akh/workspace-scoped trace and step tables, stable durable IDs, ordered duplicate-idempotent writes, and atomic versioned checkpoints under the existing pinned residency owner and snapshot fence. Engine thinking now uses that backend and exposes interrupted listing plus explicit resume after cold wake; memory/null backends remain available. Before acknowledging each boundary, the exact installed graph WAL drains with failure/overflow refusal. The checkpoint's symbol metadata closure is committed in the same WAL transaction and validated during cold restore, so a newly created goal or first-use predicate survives a crash even when it postdates the snapshot. Canonical checkpoint encoding, predicate identity validation, and stale-owner/current-thread refusal prevent ambiguous recovery. Validation: 67 executed tests passed: store19, SQLite4, store PostgreSQL1, thinking/snapshot41, cold-wake PostgreSQL1, daemon disconnected-backend1 (one existing root test ignored). No-default lib and server lib/bin checks pass. Ordinary Clippy passes with baseline warnings; strict Clippy fails seven unchanged grug-data findings. Two independent source reviews approved tested source `bd8c34bff49e5490028fbbc30fad97e2b4c957b3`; final head adds only the committed validation receipt. The real PostgreSQL tests used an owned disposable local container and simulated loss after a committed boundary; this is not a deployment/runtime outage witness. [Design and exact local validation](docs/ai/plans/2026-10-02-phase41d-thinking-persistence.md). The pending WI-293 dependency witness, draft phase, parent hold and canonical exact-head review/native CI remain unchanged. Envelope foreign-key integration remains in parent WI-50 as scoped by the brief. No deployment or production database action.
docs(thinking): record tested checkpoint recovery evidence
All checks were successful
CI / test-sokar (pull_request) Successful in 14m29s
CI / check-akh-medu (pull_request) Successful in 21m43s
CI / publish-chart (pull_request) Successful in 10m12s
CI / docker-akh-transcripts (pull_request) Successful in 17m15s
CI / docker-sokard (pull_request) Successful in 35m46s
CI / check-seshat (pull_request) Successful in 1h6m25s
CI / docker-seshd (pull_request) Successful in 1h2m43s
CI / test-session-platform (pull_request) Successful in 1h44m48s
CI / test-akh-medu (pull_request) Successful in 1h50m53s
CI / platform-images-home (pull_request) Successful in 50m21s
CI / platform-images-core (pull_request) Successful in 1h1m39s
CI / platform-images-daemons (pull_request) Successful in 1h9m35s
CI / platform-images-fleet (pull_request) Successful in 5m16s
CI / platform-images-collect (pull_request) Successful in 4m40s
28b6d4f94d
All checks were successful
CI / test-sokar (pull_request) Successful in 14m29s
CI / check-akh-medu (pull_request) Successful in 21m43s
CI / publish-chart (pull_request) Successful in 10m12s
CI / docker-akh-transcripts (pull_request) Successful in 17m15s
CI / docker-sokard (pull_request) Successful in 35m46s
CI / check-seshat (pull_request) Successful in 1h6m25s
CI / docker-seshd (pull_request) Successful in 1h2m43s
CI / test-session-platform (pull_request) Successful in 1h44m48s
CI / test-akh-medu (pull_request) Successful in 1h50m53s
CI / platform-images-home (pull_request) Successful in 50m21s
CI / platform-images-core (pull_request) Successful in 1h1m39s
CI / platform-images-daemons (pull_request) Successful in 1h9m35s
CI / platform-images-fleet (pull_request) Successful in 5m16s
CI / platform-images-collect (pull_request) Successful in 4m40s
This pull request has changes conflicting with the target branch.
  • crates/akhomed-store/src/entity/mod.rs
  • crates/akhomed-store/src/migration/mod.rs
  • docs/ai/architecture.md
  • src/engine.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin claude/wi-01a08262-thinking-persistence:claude/wi-01a08262-thinking-persistence
git switch claude/wi-01a08262-thinking-persistence

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff claude/wi-01a08262-thinking-persistence
git switch claude/wi-01a08262-thinking-persistence
git rebase main
git switch main
git merge --ff-only claude/wi-01a08262-thinking-persistence
git switch claude/wi-01a08262-thinking-persistence
git rebase main
git switch main
git merge --no-ff claude/wi-01a08262-thinking-persistence
git switch main
git merge --squash claude/wi-01a08262-thinking-persistence
git switch main
git merge --ff-only claude/wi-01a08262-thinking-persistence
git switch main
git merge claude/wi-01a08262-thinking-persistence
git push origin main
Sign in to join this conversation.
No reviewers
No labels
follow-up
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
toasterson/akh-medu!512
No description provided.