Skip to content

fix(memory): normalize readonly SQLite URI paths - #125

Merged
Grivn merged 2 commits into
masterfrom
codex/fix-readonly-uri-123
Aug 31, 2026
Merged

fix(memory): normalize readonly SQLite URI paths#125
Grivn merged 2 commits into
masterfrom
codex/fix-readonly-uri-123

Conversation

@Grivn

@Grivn Grivn commented Aug 31, 2026

Copy link
Copy Markdown
Member

What

  • Resolve the readonly database filename to an absolute filesystem path before constructing its SQLite file URI. Put Windows drive letters in the URI path (file:///C:/...), preserving URI escaping for spaces, Unicode, #, and %.
  • Keep mode=ro, immutable=1, and the existing readonly mutation guards. No fallback to a writable connection, schema migration, or file-format change.
  • Add real SQLite storage and recall regressions for absolute and relative paths, plus drive-relative paths on Windows. Verify successful queries, rejected direct SQL writes, unchanged database bytes (including recall counters/oplog), and absent WAL/SHM/journal files.
  • Extend native Windows CI to run the Memory command and storage tests. Add built-CLI E2E coverage and document filesystem-path handling in English and Chinese.

Why

Closes #123.

The readonly URI construction introduced by #119 passes a Windows filename such as C:/.../mnemon.db directly to url.URL.Path. It serializes as file://C:/..., turning the drive into an invalid SQLite URI authority. Relative directory paths produce the same problem on other platforms. The driver reports the open failure as SQL logic error: out of memory (1) even for a tiny database.

SQLite's URI rules require the Windows drive to be part of the absolute path and drive-relative filenames to be resolved before conversion.

Normalize the path and retain the readonly snapshot contract so downstream callers, including dsh-mnemon's browse/metadata paths, do not need to remove --readonly and allow incidental writes.

Validation

Local validation ran on macOS arm64 with Go 1.25.4.

  • Confirmed the new storage and recall relative-path regressions fail on unchanged master with the reported SQLite error and pass with this fix.
  • make test passes, including go vet ./... and all deterministic packages.
  • go test -race -shuffle=on ./internal/memory/store ./cmd/memory -count=3 passes.
  • bash scripts/e2e_test.sh passes all 167 assertions, using the built CLI and synthetic data with the optional embedding endpoint disabled.
  • CI run 33414798078 passes for commit 7bc609b5fbd609e68e88e3ea842307226af41c12:
    • Linux: the full deterministic suite.
    • Native Windows amd64 / Go 1.24.6: go build -o mnemon.exe . and go test ./cmd ./cmd/agency ./cmd/memory ./internal/memory/store -count=1, including the drive-letter and drive-relative regression cases.

The broader Agency daemon/process/Docker integration tier and paid-provider live tier were not run; those boundaries are unchanged.

Release-note impact

Release preparation includes the v0.2.7 entry in CHANGELOG.md.

Fix --readonly recall failing on Windows drive-letter paths and on relative --data-dir paths. Readonly recall continues to preserve the immutable snapshot without updating counters/oplog or creating sidecars. The existing limitation for databases actively changed by another process is unchanged.

Checklist

  • Deterministic tests pass (make test)
  • Relevant CLI E2E and Memory race boundaries pass (see validation above)
  • New/changed behavior is covered by tests
  • Documentation updated in English and Chinese
  • User-facing release-note impact described in this PR

@Grivn
Grivn merged commit aab97af into master Aug 31, 2026
2 checks passed
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.

--readonly recall fails with SQLite "out of memory (1)" on every query (v0.2.6, Windows)

1 participant