Skip to content

feat: merge pristine.redb and changes.redb into atomic.redb - #230

Merged
geekgonecrazy merged 3 commits into
devfrom
feat/atomic-redb
Oct 6, 2026
Merged

geekgonecrazy merged 3 commits into
devfrom
feat/atomic-redb

Conversation

@vinceblock99

@vinceblock99 vinceblock99 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Merge pristine.redb and changes.redb into .atomic/atomic.redb so repository state uses one database file.

  • Verify legacy tables before publishing the merged database and archive the old files. Refuse recovery if an old database changed after migration.
  • Share database handles and release them between owner requests so CLI and agent operations can use the same file. Reject unsupported schemas and bound lock waits.

This PR covers database consolidation. Cross-table publication transactions and additional agent crash recovery are separate follow-up work. Protobuf/RPC contracts are unchanged.

Validated with the full workspace suite (9,116 passed), agent harness, real legacy repository migration and live Codex hook workflow; Clippy, rustdoc and formatting checks pass.

Before release, coordinate the matching atomic-storage update for its direct pristine.redb access and snapshot names.

Repositories kept graph state in .atomic/pristine.redb and the provenance
journal in .atomic/changes.redb. Both now live in one .atomic/atomic.redb.

- atomic-core: a registry of every table (pristine/schema.rs) with a schema
  version in the new atomic_meta table. LegacyDatabases::merge_into copies
  each table through its typed definition into a fresh file, verifies a
  per-table digest against the source, refuses unknown non-empty tables, and
  leaves retired tables (stacks, channels, file_mtimes) behind.
- atomic-repository: ensure_database merges a legacy layout on first open
  (atomic.redb.merging -> atomic.redb; old files kept in .atomic/legacy/<ts>/)
  and finishes an interrupted retirement. Concurrent openers serialize on the
  legacy file lock. open/open_existing/open_readonly wait up to 5s for a
  busy database. The change store can share the repository's redb handle
  (Repository::redb_change_store) or open an existing file without creating
  it.
- atomic agent database-owner: opens atomic.redb only while serving a store
  request. Startup, Ping and Shutdown never touch it, so the owner no longer
  locks other atomic processes out of the repository.
- hooks: close the repository before acknowledging a checkpoint, since the
  owner now opens the same file.
@vinceblock99
vinceblock99 marked this pull request as ready for review October 2, 2026 02:50
@geekgonecrazy
geekgonecrazy merged commit 301341f into dev Oct 6, 2026
8 checks passed
@geekgonecrazy
geekgonecrazy deleted the feat/atomic-redb branch October 6, 2026 18:12
geekgonecrazy added a commit that referenced this pull request Oct 6, 2026
- state.change_store: ensure_database (the legacy-layout merge) then
  open_existing on the merged atomic.redb — redb refuses a second
  concurrent handle, so the journal-port handlers keep the sequential
  open/use/drop discipline under the gate.
- DirectJournalSink holds NO handle: each journal operation opens the
  merged database, runs, and drops it (the orchestrator opens the same
  file; the two can no longer coexist as concurrent handles).
- atomic-repository: sync the #230 database module (pub database mod for
  the CLI's root-finder predicate) + the CandidateSet/BaggageEntry/
  Coverage Deserialize derives for the triage wire.
geekgonecrazy added a commit that referenced this pull request Oct 7, 2026
#230 merged pristine.redb and changes.redb into a single atomic.redb,
so a fresh init no longer writes pristine.redb — but the CLI's root
finder still required it and could not discover #230-created repos
at all. The finder now applies the same predicate
Repository::find_root uses (has_database: atomic.redb, or the legacy
pristine.redb before the merge), and the discovery integration test
asserts the merged database file.
geekgonecrazy added a commit that referenced this pull request Oct 7, 2026
- state.change_store: ensure_database (the legacy-layout merge) then
  open_existing on the merged atomic.redb — redb refuses a second
  concurrent handle, so the journal-port handlers keep the sequential
  open/use/drop discipline under the gate.
- DirectJournalSink holds NO handle: each journal operation opens the
  merged database, runs, and drops it (the orchestrator opens the same
  file; the two can no longer coexist as concurrent handles).
- atomic-repository: sync the #230 database module (pub database mod for
  the CLI's root-finder predicate) + the CandidateSet/BaggageEntry/
  Coverage Deserialize derives for the triage wire.
geekgonecrazy added a commit that referenced this pull request Oct 7, 2026
#230 merged pristine.redb and changes.redb into a single atomic.redb,
so a fresh init no longer writes pristine.redb — but the CLI's root
finder still required it and could not discover #230-created repos
at all. The finder now applies the same predicate
Repository::find_root uses (has_database: atomic.redb, or the legacy
pristine.redb before the merge), and the discovery integration test
asserts the merged database file.
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.

2 participants