Skip to content

feat(agent): add host-owned SQLCipher local storage - #1204

Merged
AnthonyRonning merged 1 commit into
masterfrom
codex-sqlite-store-maple
Oct 22, 2026
Merged

AnthonyRonning merged 1 commit into
masterfrom
codex-sqlite-store-maple

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem and resulting behavior

Agent history and privileged local state need durable ownership and bounded reads.
This adds a host-owned SQLite store in a fresh store-v1 namespace for history,
credentials, settings, attachments, project metadata and send receipts. Previous
application data is untouched: no import, migration, adoption or cleanup.
Project/workspace instruction Markdown remains files.

Plain SQLite is the release path. Optional SQLCipher password creation/change
and experimental salvage remain host-enforced debug-only pending their release
qualification. Existing encrypted stores can still unlock; confirmed reset and
password removal remain available.

Review guide

Paths below are relative to apps/maple-agent/.

  • Contracts: docs/local-store.md, docs/local-store-encryption.md, docs/local-host.md.
  • Store: crates/maple-agent/src/store/; durable source transactions, account and
    generation fencing, read-only integrity checks and crash-safe replacement.
  • Host/UI: app/src/host*, app/src/desktop*, app/src/ui/store_*; contextual
    validation/feedback, retry without automatic prompt replay, coordinated Quit
    and frontend-only window close.
  • ACP: crates/maple-agent/src/acp/; temporary encrypted canonical-row capture,
    immutable-source reconstruction, revision reconciliation and bounded independent
    session queues. Active appends do not invalidate an already captured replay.
  • Provider: dependencies/sqlcipher/README.md and the
    pinned rusqlite fork.
    One patch above the released base; no vendored dependency tree or Maple C changes.
  • Pi: crates/UPSTREAM.md. Existing emitted events retain their meaning. Generic
    adaptations cover bounded resume, persistence retry/flush and output directories;
    Maple adapter receipts bind source identities separately from commitment.
    EFF generation stays; typed assessment uses zxcvbn. Distribution notices are
    generated into build artifacts rather than checked-in bulk.

Review follow-up

The failure-path review is addressed in source and regression tests: lossless
malformed-image persistence, exact credential ownership, cancelled-runtime retry,
account/generation cache invalidation, durable damage quarantine, safe refusal of
incompatible stores, paging/navigation, remote event scoping, notification privacy,
bounded maintenance, unbuffered checker key input and compiled-provider attribution.
Post-dispatch receipt failures retain the original uncertain send identity rather
than inviting replay. Account-owned computer names restore through the local controller.

Confirmed Start fresh/Erase deletes the current damaged store. Maple does not
retain permanent damaged-original archives or offer in-place content repair.
Only qualified temporary swap state remains during an unfinished operation or crash
recovery; experimental salvage installs its verified replacement before removing
its source. Previous-version and unrelated copies are never swept.

Ambiguous server-account-deletion reconciliation remains explicitly outside this
pass: the pending intent/data are retained, and ordinary sign-in can remain blocked.

Validation and current state

One signed commit, rebased onto master a391ddfd:
52cf660626deb258df6ea7db5a481346b516ce0e.

The fully qualified checkpoint was 0a42093b. The Agent app/core/Pi sources,
Cargo manifests/lockfile and component Nix inputs are unchanged by this rebase.
The single conflict combined the updater's five new Nix setup steps and this
PR's two, making the workflow inventory 76.

  • Checkpoint full isolated MAPLE_HOOK_FULL=1 gate passed: all four strict feature
    Clippies, warning-denied workspace build/tests, 684 core, 781 desktop and
    217 headless tests
    , plus other workspace libraries and integration tests.
  • Checkpoint 88 packaging/support tests and current notice generation passed.
  • Native ACP and remote-control checks passed in plain and encrypted modes on
    checkpoint source/binary. ACP covered cold replay, persisted identities and
    context recall; remote covered same-machine loopback pairing, bounded
    pages/ranges, subscriptions and revocation. All qualification hosts stopped
    and released ownership.
  • Focused native GUI qualification passed host-RPC encryption/reset mutations,
    rendered runtime recovery, transcript preservation, confirmed store/key deletion
    without archives, fresh setup/login and a successful new chat. Rendered
    Save/cancellation routing has separate real-IPC GPUI regression coverage.
    A separate Local Pro instance remains open for user testing.
  • Checkpoint Agent CI
    passed Linux, macOS and Windows. Source verification, store-performance CI and
    unsigned packaging/downloaded Linux verification also passed. Signed macOS
    jobs were skipped; these results do not establish release publication.
  • Rebase integration passed all 15 local flake checks, the workflow inventory
    test and 31 packaging tests. Hosted CI on the rebased head was not awaited
    for merge. Older native/password/crash evidence retains its recorded scope.

Native Windows/Linux UI, ordinary Dock termination, low-end KDF costs and trusted
performance baselines remain release qualification. Unit tests and same-machine
loopback networking do not establish those properties. The staged encryption
release hold remains in place.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Maple Auth development preview: https://ac39bcf6.maple-auth-dev.pages.dev

Commit: 0a42093bf3edd35622bc2ee0081a724ea0d8ca1e

Uses development services. Cloudflare Access applies. Provider OAuth is not configured for PR URLs; use the stable Auth Dev host for OAuth rehearsal.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Maple development preview: https://b89b09c1.maple-ca8.pages.dev

Commit: 0a42093bf3edd35622bc2ee0081a724ea0d8ca1e

Uses development API, billing, flags and PCR configuration. Cloudflare Access applies.

@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

Published head 6a7716a70cd7ff5a926170cb4e9e5abac1826c51, tree 11270df742d66155ec09b02ae1487e440e8ab479, is one signed commit over master e20a5b78; GitHub verifies the signature. It differs from native checkpoint 33793030 by seven Python tooling files only: runtime Rust/Cargo/provider pins remain unchanged; the whole tree differs. Checks below are local evidence.

The provider build adaptation moved into the public revision-pinned rusqlite fork: one signed patch, no copied dependency tree in Maple and no SQLCipher/OpenSSL C modifications. The review entry is now apps/maple-agent/dependencies/sqlcipher/README.md.

Pi's ordinary events retain their upstream meaning; EntryAppended retains special-entry semantics. The three generic embedding adaptations in crates/UPSTREAM.md are bounded partial-history resume, explicit persistence flush/retry and an optional tool-output directory. Maple source receipts mean observation, not durable commitment, and remain distinct from durable host send-admission receipts.

The follow-up removes 126,524 extra dictionary lines, 33,489 generated-notice/associated-copy lines and 386 audit-helper lines. EFF's 7,776-line suggestion asset stays; notices are generated/shipped artifacts. Published scope against e20a5b78, including tests/docs:

Directory/group Files Added Deleted
Root CI/flake 7 276 13
apps/maple-agent/app/ 59 20,208 2,516
apps/maple-agent/crates/maple-agent/ 101 47,418 2,253
apps/maple-agent/crates/pi-*/ 10 1,415 44
apps/maple-agent/crates/store-bench/ 9 2,098 0
Other agent tooling/docs/assets 35 2,853 102
Total 221 74,268 4,928

The published 6a7716a full hook passed: 489 repository tests; four Clippy configurations; strict workspace build; 593 core, 687 desktop and 180 headless tests; other workspace/rustdoc suites. Compatible macOS Nix checks, 269 provider tests/65 doc tests, provenance/audit/hash checks and 82 Python packaging tests also passed. Declared ignores remain visible. These are local results, not hosted GitHub CI.

Checkpoint ACP/remote passes use two native processes on one Mac over loopback: 105-task paging, exact image/10 MiB replay, cold identities, owner-name events/search, isolation/revocation. Final-head app build/codesign/launch and fresh GUI/RPC smoke pass: selected new-chat completion, identity/Local routing and exact prior-row replay. The published UTF-8 fix passes locally and in the hosted Windows dependency-graph/verifier step; actual Windows build/tests and other CI remain in progress. Draft/unmerged; Dock callback, cross-platform release, packaging/hardening, low-end KDF and trusted baselines remain gates.

@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

The encryption Settings follow-up is implemented in d03101c, with the PR kept as one signed commit and still draft.

  • Password forms start empty with typed input; generating a passphrase is explicit. A compact card, persistent labels and framed fields make current/new/confirmation entry clear.
  • Save now shows specific feedback for missing values, mismatches and password-policy failures. Local validation retains the fields. Key rotation is an optional checkbox, off by default.
  • Normal successful changes stay in Settings with inline feedback. Exact operation/notice receipts prevent duplicate routine global banners while errors and recovery warnings remain visible.

Validation passed: the final full Agent gate (593 core, 705 desktop and 183 headless tests, plus other workspace/doc suites), all compatible macOS root Nix checks, and 22 disposable native password-lifecycle checks on runtime-equivalent source. Native visual checks cover the empty forms, Save feedback and checkbox; no password was entered through GUI automation. Declared test ignores remain ignored.

The runtime-equivalent Local build from a62f5b4b was rebuilt, codesign/launch/IPC checked and reopened on the preserved encrypted profile. It is waiting for the existing unlock password. No reset or password change was performed on that profile.

The final test-only amendment repairs portable fixture interpreters and exposes child errors; the updated Linux CI rerun is pending. The body also documents narrow fixes for the old hosted packaging/Windows failures and the small-pipe validation-tool issues found locally. Final-head hosted CI remains a separate qualification; this report does not claim those remote builds or a release passed.

@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

Removed the shared page-top store feedback pattern in c664249. The PR remains draft and contains one verified signed commit.

  • Deleted all three global store notice rows. Setup, reset, repair and ordinary encryption success no longer prepend messages above the active page.
  • Forms and Privacy & Security own relevant feedback. Durable mode notices and exact dismissal live inside Settings. Critical results without a live form use a focused dialog, including when delivery must wait for a window.
  • Save failures retain Retry beside both chat composers and in Settings. Actual desktop service events now reach that local/parked chat control. Independent operation/save warnings cannot overwrite each other.

The final mandatory gate passes 593 core, 720 desktop and 187 headless tests, four Clippy configurations, strict workspace build/tests and other suites. Declared ignores remain ignored. Native plain-mode setup and reset/setup on a fresh disposable Local profile both return to the normal login form without a top notice or Dismiss row. Reset changed generation; the fixture was closed and released its lock. Its first stale-connection status query was recovered through read-only reconnection, without repeating reset.

The exact final revision was rebuilt, packaged, codesign/launch checked and reopened as the Local app. Read-only IPC checks confirm the main store generation and identity presence were preserved; no reset or credential changes were performed there.

The existing Windows run progressed beyond its old Perl/OpenSSL failure and exposed three platform guards, now corrected. Final-head hosted CI remains a separate qualification and is still running; no merge or release is requested.

@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

Fixed the post-encryption “Agent runtime is not running” failure. Password maintenance now blocks sends while the local store is busy, then reconciles the preserved local chat after verified Open for the same store/account and starts the runtime if needed. The path handles successful changes, rejected passwords and cancellation without automatically resending drafts. A runtime startup error remains separate from the completed password operation.

Added seven real-IPC GPUI regression tests plus an unsent-draft barrier regression, including explicit successful sends after recovery, a surviving runtime, locked-store invalidation and local recovery while a remote chat is selected. Password/database work and inference in the IPC fixtures are synthetic.

The full mandatory Agent gate passed: 593 core, 728 desktop and 187 headless tests, four Clippy configurations, strict workspace builds/tests and the remaining workspace suites; declared ignores remain ignored. The exact signed-commit Local build was packaged, verified and reopened on the same encrypted store generation at its normal unlock screen.

The draft remains one signed commit: d32d113914d84c533a2a3b9172311df71310033c.

@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

Follow-up qualification on source d32d113914d84c533a2a3b9172311df71310033c, unpackaged Local macOS binary SHA-256 b8db1c6e96de264bfeda5c7d5a3dc691c86191592eeac1819b88a12b9c211e6e:

  • Actual ACP subprocesses passed in both plain SQLite and SQLCipher modes: tool/image turns, cold resume, stable persisted history identities, paged image recovery, locked refusal and local unlock. Additional native probes passed cancellation at a pending permission, steering, overlap rejection, active conversion refusal, idle conversion with an attached client, reconnect/history continuity and a new prompt.
  • Actual Iroh remote control passed plain/plain, encrypted/encrypted, and both mixed-mode directions. Coverage included enrollment/pairing, 105-task navigation, history paging, a 10 MiB ranged attachment, real tool turns, account isolation, subscriptions, both-host cold restart/unlock, and revocation. Original-send receipt recovery produced one user message and one side effect without resending; revocation survived encrypted restart.
  • Seven bounded authoritative-host SIGKILL/reopen cases preserved the fixture account/store/task identities, all three transcript rows and their host-visible row identities, and 512 acknowledged dictionary words. Interrupted export/rotation were proven precommit from stopped filesystem artifacts. This is process-crash evidence, not physical power-loss or exact rename-instruction coverage.
  • Native empty-password setup/change feedback and Cancel were checked. Native app-menu Quit terminated both GUI and host; encrypted reopen was locked. Dock was unavailable through the enabled automation surface, so this is not Dock Quit proof.

These runs used disposable isolated profiles, left the user's running profile untouched, and keep one-off helpers/reports outside Git. Remote topology was direct loopback between independent native hosts on one Mac; no physical-device, LAN/NAT, relay or rendered computer-picker claim. More disk-full and backup-restore testing was intentionally excluded from this pass.

Windows Agent remains under investigation. Diagnostic checkpoint d129db3c77560d292ff68c4d78b9ae70a16b3419 adds a canonical-path, plain/keyed read-only WAL regression and redacted report assertions. Its full local Agent gate passed (594 core, 728 desktop, 187 headless tests; existing declared ignores remain); Windows runner evidence is pending. A separate correction under review prevents operational checker failures from falsely reporting database damage while continuing to reject incomplete replacement verification. This PR remains draft; no merge or release is requested. Final follow-up changes will be squashed back into one commit after validation.

@AnthonyRonning
AnthonyRonning force-pushed the codex-sqlite-store-maple branch from d129db3 to 3fb7aa2 Compare October 22, 2026 04:56
@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

The signed qualification checkpoint is now 3fb7aa240a7c4a81419705d7ee308f2178897ff3, rebased onto master 351ad943. The full local just ci gate passed with isolated Cargo intermediates: all four Clippy configurations, strict workspace build, 606 core tests, 732 desktop tests, supporting crates/docs, and 187 headless tests. Declared ignored helper/qualification tests remain ignored; no failing test was skipped to obtain this result.

This checkpoint fixes two independently reproduced integrity-check defects: operational errors were being classified as corruption, and SQLite omits CHECK expression trees when parsing a truly read-only database. The checker remains read-only, supplements the engine with the fixed application-owned CHECK predicates for each supported schema, and cannot issue a clean receipt for an incomplete check. Regression coverage includes plain/keyed invalid JSON, integer constraints, foreign-key orphans, cancellation/budgets, and additive redacted startup diagnostics.

The Windows problem is still under investigation. The previous runner narrowed it to checker-child initialization while the same-process read-only WAL test passes. The new exact-checkpoint Windows job is comparing minimal native OS/private-temp environments and recording only startup stages and numeric SQLite codes. That temporary diagnostic is not a production fix and will be removed after the cause is established.

The completed native ACP, remote plain/encrypted/mixed, seven process-crash/reopen, and limited UI/menu-Quit results remain scoped to the earlier d32d113 artifacts. A new Local validation build is being prepared without replacing the user's running bundle or touching that profile. The PR remains draft; final cleanup and the requested one-commit squash will follow validation. Nothing has been merged.

@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

Windows qualification update on signed checkpoint 273d77b6:

  • The preceding Windows run confirmed plain/keyed checker startup and numeric page-size diagnostics. It finished with 538 core tests passing and 29 permission-denied failures in setup/reset/conversion/salvage.
  • Source review isolated a second bug: staged files were reopened read-only before FlushFileBuffers, which requires write access. The correction adds Windows-only write access to existing staged files; synchronization remains required.
  • Added a regression for repeated flushes, exact DB/metadata/key-file bytes, exclusive handle reopening on Windows, and subsequent durable rename. Removed the temporary environment matrix after preserving its results outside Git.
  • The complete isolated local gate passes: 608 core, 732 desktop and 187 headless tests, all feature-set Clippy checks and workspace build.

The new Windows run is pending. The preceding checkpoint passed macOS/Linux Agent CI and unsigned desktop packaging checks. The draft stays open; final rebase/squash follows qualification. No merge or release.

@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

The first independent-review fix checkpoint is now pushed as signed commit d69d41f.

It addresses malformed tool-image persistence, credential ownership and account-cache isolation, cancelled-runtime retry, reset preflight and corruption-journal races, pending-history deletion/GC protection, paging and controller ownership, account-scoped remote events, notification privacy, bounded idle maintenance, unbuffered checker key input, and compiled-provider attribution. Pi event semantics remain unchanged.

Validation on that checkpoint: the full isolated pre-commit gate passed (639 core, 749 desktop, 198 headless tests and all four Clippy configurations). The pinned packaging fixtures and real license-notice generation also passed. Supply-chain CI passed; cross-platform Agent CI is still running. This is not new native UI or Windows manual qualification.

The next local batch removes automatic permanent recovery archives and unsafe in-place repair, adds non-destructive refusal for incompatible stores, and fixes password retry/progress/keyboard paths. Explicit destructive reset remains available for actual damaged stores; password creation/change and experimental recovery stay gated in release builds. These next changes are not yet a validated checkpoint. ACP active replay and further host lifecycle regressions remain in progress, so this PR stays draft and final squash is held.

@AnthonyRonning

AnthonyRonning commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

The agreed review follow-up is complete on 0a42093bf3edd35622bc2ee0081a724ea0d8ca1e, rebased onto master 4984a12f and squashed to one signed commit. The PR description now reflects the final implementation and validation.

  • Full isolated gate passed: four strict feature Clippies, warning-denied workspace build/tests, including 684 core, 781 desktop and 217 headless tests. All 88 packaging/support tests and current notice generation passed.
  • Exact-source native ACP and remote checks passed in both plain and encrypted modes. Remote qualification uses two Local hosts over same-machine loopback Iroh, not two physical devices/public relay. Qualification hosts stopped and released ownership.
  • Focused native GUI qualification passed encryption/reset mutations through host RPC plus rendered runtime recovery, transcript preservation, confirmed store/key deletion without archives, fresh login and a real new chat. Rendered Save/cancellation behavior has separate real-IPC GPUI regression coverage. A separate Local Pro/sqlite instance is open for user testing.
  • SQLCipher source verification and store-performance CI passed. Final-head Agent CI is still running on Linux, macOS and Windows; no completed platform result is claimed yet.

Confirmed reset now deletes only the current store; there are no automatic permanent damaged-original archives or in-place content repair. The approved release hold remains: plain SQLite ships by default; password creation/change and experimental salvage stay host-enforced debug-only. Ambiguous account-deletion reconciliation remains deferred as agreed. No merge or release performed.

Add durable SQLite history and privileged local state in a fresh namespace,
with optional SQLCipher password protection and bounded desktop, ACP and remote
history access. Keep previous application data untouched.

Preserve Pi event contracts, recover failed saves without replaying prompts,
enforce account and generation ownership, and require explicit destructive reset
instead of retaining permanent damaged-store copies. Keep password creation and
change plus experimental salvage behind the release validation gate.
@AnthonyRonning
AnthonyRonning force-pushed the codex-sqlite-store-maple branch from 0a42093 to 52cf660 Compare October 22, 2026 19:44
@AnthonyRonning
AnthonyRonning marked this pull request as ready for review October 22, 2026 19:44
@AnthonyRonning
AnthonyRonning merged commit 5e3793a into master Oct 22, 2026
46 checks passed
@AnthonyRonning
AnthonyRonning deleted the codex-sqlite-store-maple branch October 22, 2026 23:26
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