Repository navigation
feat(maintenance): staleness inventory preview (#1145) - #1154
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
✨ 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 |
Add `polylogue/maintenance/preview.py` exposing `staleness_inventory()` which enumerates stale/missing/orphan derived artifacts per model with typed `InvalidationReason` tags (MISSING, STALE, ORPHAN, MISSING_PROVENANCE, VERSION_MISMATCH, ORPHAN_ARCHIVE_ROW). Wire the inventory through a new `polylogue maintenance preview` subcommand that renders plain and JSON output, with `--scope` filtering across derived/retrieval/archive_cleanup/backfill. Models with nothing stale emit explicit zero rows (not absence) so consumers can render a complete inventory without distinguishing "absent" from "zero". The preview is read-only: tests assert no row counts change across the call and the new subcommand never opens a write connection. Ref #1145 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
5a816e8 to
3dd7d84
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a816e8bf0
ℹ️ 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".
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Adds the preview half of the maintenance backfill planner: a typed, read-only
staleness inventory exposed as a Python API (
staleness_inventory()) and asthe
polylogue maintenance previewCLI subcommand. Operators can now answer"what will be rebuilt and why" before triggering any mutating maintenance.
Problem
Before this PR,
polylogue maintenance planreturned an aggregateaffected_rowscount and a per-target debt dict, but operators had no way tosee why a row was considered stale — every "needs work" item rolled up into
one bucket. Issue #1145 specifies a per-model, per-scope inventory tagged with
typed invalidation reasons so operators (and downstream automation) can
distinguish "never built", "older than its source", "version mismatch", and
"orphaned" without grepping debt strings.
Solution
polylogue/maintenance/preview.py(new):staleness_inventory(db_path, scopes=..., verify_full=...)returns aStalenessInventoryofStalenessItem(model, scope, reason, count, source_total, materialized_total, detail, sample_ids, truncated)rows.InvalidationReasonis a 6-variant enum (
MISSING,STALE,ORPHAN,MISSING_PROVENANCE,VERSION_MISMATCH,ORPHAN_ARCHIVE_ROW). Sources counts from the existingcollect_derived_model_statuses_sync()and the four orphan-row counters instorage/repair.py.derived— 12 read models (FTS, action events, session insights,threads, tag rollups, day/week summaries).
retrieval— 4 retrieval-layer models (embeddings + RRF lanes).archive_cleanup— 4 orphan-row scopes (orphaned_messages,orphaned_content_blocks,empty_conversations,orphaned_attachments).backfill—message_type_backfill.polylogue/cli/commands/maintenance.py: newpreviewsubcommand with--scope,--output-format {plain,json},--shallow.consumers don't have to distinguish "absent" from "zero".
docs/plans/topology-target.yamlupdated to declare the new module.Non-goals deferred to the planner contract (#1144 / #996): mapping the
per-model inventory back to
MaintenanceTargetSpecgroupings, surfacingsample ids beyond
truncatedplumbing, and execution (covered by theresume/idempotency child).
Verification
nix develop -c pytest tests/unit/maintenance/test_preview.py— 11 testspass in 10s, including a row-count-snapshot assertion that no table row
count changes across a
staleness_inventory()call (read-only invariant).nix develop -c pytest tests/unit/maintenance/ tests/unit/core/test_maintenance_targets.py tests/unit/storage/test_derived_status.py tests/unit/cli/test_maintenance_registration.py tests/unit/daemon/test_maintenance_endpoints.py— 33 passed, 0 failed.nix develop -c devtools verify --quick— exit 0.polylogue maintenance preview --output-format jsonagainst an emptyarchive emits 51 zero-count items across all 4 scopes; JSON validates and
contains
captured_at,db_path,total_stale, per-itemfraction.Ref #1145