Repository navigation
feat(topology): persist unresolved provider-native parent edges + closed enum (#1258) - #1377
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 (17)
✨ 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 |
58f0692 to
25c0ce3
Compare
…sed enum (#1258) Bumps SCHEMA_VERSION 5→6 to add a `topology_edges` table that durably records every parent reference emitted by a parser, including references whose parent has not yet been ingested (out-of-order ingestion) or has been hard-deleted. Closes #1258. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
25c0ce3 to
5cafe6d
Compare
…#1392) ## Summary Slice B of #866 / closes #1259: when a late-arriving parent conversation lands, the topology resolver now backfills the child's `conversations.parent_conversation_id` and `branch_type` fast-path columns in addition to flipping the `topology_edges` row to `resolved`. This restores the ancestry-walk fast path for out-of-order ingest without requiring re-ingest of the child, and also closes the concurrent-ingest race between parent and child prepare cycles. ## Problem Slice A (#1258, PR #1377) persisted unresolved provider-native parent edges and added the resolver helper that flipped them to `resolved` when the parent arrived. But the original `conversations.parent_conversation_id` column was intentionally left NULL on a late-arriving repair — slice A's own test asserted this gap. Every downstream that walks `parent_conversation_id` (session-topology derivation, threads, web reader lineage view) therefore saw an orphan child until the next time the child itself was re-ingested. There was also a race: when parent and child were prepared concurrently, the parent's `PrepareCache` could miss the child's still-pending upsert and the child's cache could miss the parent's still-pending commit. The parent's resolver pass then found nothing to flip, and the child's later upsert wrote `status=unresolved` even though the parent was now in `conversations`. ## Solution `polylogue/storage/sqlite/queries/topology_edges.py`: - `resolve_topology_edges_for_conversation` (the parent-arrival path) now SELECTs the children it is about to flip and `UPDATE`s each child's `conversations.parent_conversation_id` / `branch_type` with `COALESCE` so existing fast-path state is preserved and the operation stays idempotent across re-ingest. `branch_type` is restricted to the closed `BranchType` vocabulary so future `RESUME`/`BRANCH`/`REPAIRED` edge kinds cannot violate the CHECK constraint on `conversations.branch_type`. - New `resolve_unresolved_edges_for_child` runs after the child's own upsert in `save_via_backend`. It joins the child's unresolved edges against `conversations` on `(provider_name, provider_conversation_id)` and flips any edge whose parent now exists — closes the concurrent ingest race. `polylogue/storage/repository/archive/writes/conversations.py`: - `save_via_backend` calls the new race-closure helper after the existing `upsert_topology_edges` + `resolve_topology_edges_for_conversation` pair. `tests/unit/storage/test_topology_edges.py`: - Updated the pre-existing slice A test that asserted the gap to assert the new repair behavior. - Added `TestTopologyLateParentRepair` covering: late-parent backfill, idempotency across parent re-ingest, no-op when parent never arrives, multiple pending children → single parent, parent-first preservation, and concurrent parent+child ingest via `asyncio.gather`. Hash boundary unchanged: topology edges are derived per ingest and stay outside `conversations.content_hash`, same as user_corrections (#1131). No schema change. ## Verification ``` nix develop -c devtools verify --quick # exit 0, 35.6 s nix develop -c pytest tests/unit/storage/test_topology_edges.py \ tests/unit/storage/test_dead_schema_sweep.py \ tests/unit/insights/ -q # 142 passed (insights + topology + dead-schema-sweep) # 13 passed (test_topology_edges, including the new concurrent ingest test) ``` The concurrent-ingest test (`test_concurrent_parent_and_child_ingest_resolves`) exercises both the parent-arrival resolver and the new child-side race-closure helper depending on which coroutine commits first. Ref #1259 #866. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Bumps SCHEMA_VERSION 5→6 to add a
topology_edgestable that durably recordsevery parent reference emitted by a parser, including references whose parent
has not yet been ingested (out-of-order ingestion) or has been hard-deleted.
Closes #1258.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]