Repository navigation
fix(storage): resolve managed archive index identity - #3055
Conversation
Problem: a configured archive root can share durable tiers with an\natomically promoted index elsewhere. Direct root/index.db access bypassed that\npointer, let reset create a shadow index, and caused diagnostics to derive\nmissing durable siblings from an index-generation directory.\n\nWhat changed: add ArchiveLocation as the configured-versus-active tier\nauthority; make active-index resolution follow the pointer; route reset,\nrebuild planning, and path diagnostics through it; and refuse destructive\nresets of managed active generations.\n\nCompatibility: legacy archives without an active-index pointer retain their\nexisting root/index.db layout. Co-Authored-By: Codex <[email protected]>
|
Warning Review limit reached
Next review available in: 28 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (14)
📝 WalkthroughWalkthroughThe change adds ChangesActive generation resolution
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant PathsCommand
participant ArchiveLocation
participant ActiveIndex
Operator->>PathsCommand: request archive paths
PathsCommand->>ArchiveLocation: resolve archive root
ArchiveLocation-->>PathsCommand: active tiers and pointer metadata
PathsCommand->>ActiveIndex: identify active index path
ActiveIndex-->>PathsCommand: resolved path
PathsCommand-->>Operator: render path information
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbcb1f7753
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if pointer.exists(): | ||
| target = Path(pointer.read_text(encoding="utf-8").strip()) | ||
| if not target.is_absolute() or target.name != "index.db": | ||
| raise RuntimeError(f"invalid active index pointer: {target}") | ||
| return target |
There was a problem hiding this comment.
Keep durable tiers rooted at the configured archive
When .index-active-pointer names an index outside the configured root—the split topology this change supports—returning that target globally also changes Config.db_path, while existing consumers still treat db_path.parent as the complete archive root. For example, archive_file_set_root_for_paths returns that parent, initialize_backend_state binds or bootstraps sibling source.db/user.db tiers there, and daemon/lifecycle.py derives ops.db there. If only the index is external and durable tiers remain under the configured root, runtime operations therefore read or create a second set of durable databases beside the index, silently forking archive state. Route only index access through the pointer while preserving the configured root for every other tier, or update these consumers to use ArchiveLocation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@polylogue/paths/_roots.py`:
- Around line 78-82: Update the active-index resolution logic around
archive_root() and the .index-active-pointer file so that an existing pointer is
validated and invalid contents raise an error instead of falling back to the
configured or anchor database. Preserve returning the target for valid absolute
paths whose filename is index.db, and align the failure behavior with
active_index_db_path and ArchiveLocation.resolve.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 12ea574a-8f3e-495d-b730-e4fbaa25ad52
📒 Files selected for processing (9)
polylogue/cli/commands/maintenance/_rebuild_index.pypolylogue/cli/commands/paths.pypolylogue/cli/commands/reset.pypolylogue/config.pypolylogue/paths/_roots.pypolylogue/storage/archive_identity.pytests/unit/cli/test_reset.pytests/unit/core/test_paths.pytests/unit/storage/test_archive_identity.py
Problem: A source-to-index rebuild materialized every raw id, discarded its batch contract, and deleted an inactive candidate after an interrupted run. Large archives therefore had no safe, resumable path to a replacement index. What changed: Persist source-order rebuild transactions alongside their owned inactive index generations. Each full-source invocation schedules one keyset page, checkpoints its cursor, and retains the candidate until terminal readiness can promote it. Source-snapshot drift marks the operation stale rather than promoting a mixed-evidence index. Compatibility: Unfiltered full rebuilds now return a paused operation id until a terminal resume. Partial explicit selections retain their existing no-promote behavior. Co-Authored-By: Claude <[email protected]>
Problem: full source-to-index rebuilds materialized every raw identifier before scheduling work and had no durable byte/deadline envelope. A source mutation could also leave terminal accounting ambiguous, while external active-index pointers were still used as durable-tier roots by several consumers. What changed: persist per-pass scheduling budgets and byte accounting with a keyset cursor; retain paused, deferred, stale, failed, ready, and promoted candidate lifecycle evidence. A budget defers remaining work but never excludes it, including an oversized first raw. Promotion follows an exact source snapshot and readiness check. Pointer-selected indexes are now kept separate from configured durable tiers, and malformed pointer resolution fails uniformly. Compatibility/migration: existing rebuild transaction records decode with the new optional fields; resumed operations retain their original budgets. Co-Authored-By: Codex <[email protected]>
Make source-to-index rebuilds daemon-owned when requested online, while retaining the offline break-glass command. ## Problem The rebuild command performed an exclusive generation replay only after polylogued stopped, despite the daemon already owning the archive writer boundary. ## Solution Extract the rebuild protocol into `polylogue.maintenance.rebuild_index` with typed request and receipt values. Add authenticated `POST /api/maintenance/rebuild-index`, execute it through the daemon writer bridge's `run_sync`, and add `rebuild-index --daemon` as the CLI adapter. The offline adapter keeps the same source-snapshot, readiness, and promotion protocol, including the resumable bounded-pass transaction fields (`--operation-id`, `--raw-batch-size`, `--pass-byte-budget-mb`, `--pass-deadline-seconds`) that master had independently landed inline via #3055 while this branch was in flight; both are now unified in the shared module. ## Verification - `devtools test tests/unit/cli/test_archive_maintenance_cli.py tests/unit/daemon/test_maintenance_endpoints.py tests/unit/daemon/test_http_write_coordination.py tests/unit/daemon/test_write_coordinator.py tests/unit/daemon/test_web_auth.py tests/unit/daemon/test_route_contracts.py` - 214 passed. - `devtools render topology-projection && devtools render topology-status` - `devtools render all --check` - no out-of-sync surfaces. - `devtools verify --quick` - format, lint, mypy, generated surfaces, topology, layering, schema roundtrip, docs gates all passed. Ref polylogue-ogn1 (follow-up: 8 CodeRabbit findings from the original review, deferred as tracked debt, not part of this rebase's scope). Co-Authored-By: Codex <[email protected]>
Summary
Make the configured archive root and its atomically selected index generation one explicit location contract.
Problem
A split-tier archive may keep durable tiers under its configured root while an active-index pointer selects a generation elsewhere. Direct
root/index.dbconsumers bypassed that pointer, allowed reset to create a shadow index, and made diagnostics infer missing durable siblings from the generation directory.Solution
Adds
ArchiveLocation, routes active-index configuration, reset, rebuild planning, and path diagnostics through it, and refuses destructive reset operations against a managed active generation. Legacy no-pointer layouts retain their prior behavior.Verification
devtools test tests/unit/storage/test_archive_identity.py tests/unit/storage/test_index_generation.py tests/unit/core/test_paths.py tests/unit/cli/test_reset.py tests/unit/cli/test_archive_maintenance_cli.py— 124 passed.ruff check …and strict mypy on changed production modules — clean.devtools verify --seed-testmon --skip-slow— all static/generated gates passed; seeded full pytest had 41 broad failures outside this path change (including existing fast-forward fixture and mockedArchiveStoresignature failures).Summary by CodeRabbit
New Features
pathsoutput with active index and shadow index details.Bug Fixes
Tests