Scaffold the package, the Kit and the encrypted store #23

Merged
svc-agent-writer merged 2 commits from issue-7-scaffold-store into main 2026-11-12 22:35:51 +00:00

Closes #7.

What this adds

  • Package. Python 3.12, FastMCP pinned, mypy --strict, ruff with the S rules, and a lock file with a hash for every package.
  • Config. One TOML file parsed into typed models. Every secret is a path to an owner-only file. The service refuses to start when the config names a write token, when a write token file lies beside a secret file, or when it cannot list a secrets directory.
  • The Kit (ADR 0003). Token scopes with evidence within read, the row format, the page footer, cursors and the change-feed primitives. A test fails when a Kit module imports from the rest of the service.
  • The store (ADR 0007). One SQLCipher file in WAL mode with full-text search, and a separate Tombstone store. The sync worker opens the writer. The api opens a reader that writes nothing, and a positions connection that writes Consumer positions and nothing else.
  • CLI. messagesmind check validates the config, the secret files and the store, offline. Its output holds counts and codes only.
  • Validation pipeline. make check runs ruff, the format check, mypy and the tests on Linux for every pull request and every push to main.

The gate in ADR 0007

This pull request is the first run of the pipeline. The SQLCipher wheel and full-text search must pass on Linux amd64 here. If the run fails on either, the fallback in ADR 0007 is the owner's call and this pull request does not merge.

How it was checked

  • make check passes locally: ruff, the format check, mypy --strict and 87 tests.
  • The first commit also passed in the pinned Python image on Linux arm64.
  • A two-axis review (standards and spec) ran on the first commit. The second commit closes its findings, and each fix has a test that failed on the old source.

Notes for the reviewer

  • The guard on the api's connections is a SQLite authorizer. The shared connection type has no method to remove it, and a test holds that only store.py names that method or imports sqlcipher3. A test holds this rule; the language does not enforce it.
  • The positions connection accepts any update to a Consumer's position. Only the Kit's SQL keeps a position from moving backwards.
  • All test fixtures are synthetic.

🤖 Generated with Claude Code

Closes #7. ## What this adds - **Package.** Python 3.12, FastMCP pinned, `mypy --strict`, ruff with the `S` rules, and a lock file with a hash for every package. - **Config.** One TOML file parsed into typed models. Every secret is a path to an owner-only file. The service refuses to start when the config names a write token, when a write token file lies beside a secret file, or when it cannot list a secrets directory. - **The Kit** (ADR 0003). Token scopes with `evidence` within `read`, the row format, the page footer, cursors and the change-feed primitives. A test fails when a Kit module imports from the rest of the service. - **The store** (ADR 0007). One SQLCipher file in WAL mode with full-text search, and a separate Tombstone store. The sync worker opens the writer. The api opens a reader that writes nothing, and a positions connection that writes Consumer positions and nothing else. - **CLI.** `messagesmind check` validates the config, the secret files and the store, offline. Its output holds counts and codes only. - **Validation pipeline.** `make check` runs ruff, the format check, mypy and the tests on Linux for every pull request and every push to `main`. ## The gate in ADR 0007 This pull request is the first run of the pipeline. The SQLCipher wheel and full-text search must pass on Linux amd64 here. If the run fails on either, the fallback in ADR 0007 is the owner's call and this pull request does not merge. ## How it was checked - `make check` passes locally: ruff, the format check, `mypy --strict` and 87 tests. - The first commit also passed in the pinned Python image on Linux arm64. - A two-axis review (standards and spec) ran on the first commit. The second commit closes its findings, and each fix has a test that failed on the old source. ## Notes for the reviewer - The guard on the api's connections is a SQLite authorizer. The shared connection type has no method to remove it, and a test holds that only `store.py` names that method or imports `sqlcipher3`. A test holds this rule; the language does not enforce it. - The positions connection accepts any update to a Consumer's position. Only the Kit's SQL keeps a position from moving backwards. - All test fixtures are synthetic. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The foundation for the service slices of Phase A.

- Config: one TOML file parsed into typed models. Every secret is a file
  path. A config that names a write token is refused, and so is a file with
  "write" in its name beside a secret file (ADR 0001).
- The Kit (ADR 0003): token scopes with evidence nested in read, secret
  files, the row format, the page footer, keyset cursors bound to an epoch,
  and Consumer positions. A test fails when a Kit module imports from the
  rest of the service.
- The store (ADR 0007): one SQLCipher file in WAL mode with full-text
  search. The writer is for the sync worker. The api gets a reader that
  writes nothing and a positions connection that writes Consumer positions
  and nothing else; an authorizer holds both. The Tombstone store is a
  separate plain file of salted hashes.
- `messagesmind check`: validates the config, the secret files and the
  store, offline. Output holds counts and codes only.
- `make check` and a validation pipeline for pull requests and pushes to
  main. The README documents the checks.

Proven on Linux arm64 in the pipeline's pinned image: 72 tests, SQLCipher
4.12.0 with FTS5. The amd64 run is the pipeline's and has not run yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Close the review findings on the scaffold (#7)
Some checks are pending
ci/woodpecker/pr/validation Pipeline was successful
ci/woodpecker/push/validation Pipeline is pending
9daa7e0009
Startup
- A secrets directory that cannot be listed stops the service
  (secret-dir-unlistable). The write-token check passed on it before.
- The write-token file rule matches a write token name, not any name
  that holds "write".
- A refused config key reports its table. The key name is user input and
  no longer reaches the output.
- Secrets and Tokens keep the key, the salt and the tokens out of repr.

Store
- The shared connection type has no set_authorizer. Only store.py names
  it or imports sqlcipher3, and a test holds that.
- The key is checked where it enters the PRAGMA statement, before any
  file is made (store-key).
- check reports a store without its tables, and a store directory with
  no access, as store-unavailable in place of a traceback.
- The Tombstone store makes its table and sets its version in one
  transaction.

Also: Tokens.match returns a named Grant, the Kit boundary test flags
__import__, make check removes its temp directory, and the pipeline
header carries the trigger-posture block.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
svc-agent-writer deleted branch issue-7-scaffold-store 2026-11-12 22:35:51 +00:00
Sign in to join this conversation.
No description provided.