Repository navigation
feat(topology): cycle rejection and quarantine (#1260) - #1395
Conversation
Both resolver paths (resolve_topology_edges_for_conversation and resolve_unresolved_edges_for_child) now check whether backfilling conversations.parent_conversation_id would create a cycle in the fast-path ancestry graph. On detection the edge is moved to status='quarantined' with raw_evidence JSON recording the cycle path; the conversations row is left untouched so the ancestry walk never enters the cycle. Add count_quarantined_topology_edges helper and surface topology_quarantine_state in the daemon workload probe so operators see cycle rejections. Bump SCHEMA_VERSION to 7 for the extended TopologyEdgeStatus CHECK and topology_edges in the boundary table set. Ref #1260 (slice C of #866). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- frozen_clock.fixed_now() for test timestamps (verify-test-clock-hygiene). - mypy: explicit ConversationId() construction, generic tuple param annotation, intermediate typed binding for fetchone() return. - Update test_dead_schema_sweep pin: SCHEMA_VERSION 6 → 7 (#1260 quarantine status). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
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 (7)
✨ 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: 1637fd0cdb
ℹ️ 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
When resolving a topology edge would create a cycle in the
conversations.parent_conversation_idfast-path graph, the resolvernow refuses to backfill the cycle-creating edge. The offending edge is
left in
topology_edgeswithstatus='quarantined'and a structuredraw_evidenceJSON document recording the detected cycle path so theoperator can audit what was rejected. Surfaces the quarantine state in
the daemon workload probe.
Closes #1260. Ref #866 (slice C).
Problem
#1258 (slice A) made
topology_edgesdurable for unresolved parentreferences; #1259 (slice B) added the late-parent repair that, on
parent arrival, flips
unresolvededges toresolvedand backfillsthe child's
parent_conversation_id. Neither slice protected againstthe case where the parent backfill would close a cycle (A → B → A,
longer cycles, self-cycle A → A). Without rejection, the fast-path
ancestry walk used by
derive_session_topology_async,thread_root_idand other downstream readers could enter an infiniteloop (or terminate only via the existing cycle-safe guards, but with
nonsensical lineage). The #866 / #1260 acceptance criteria require
explicit rejection with structured evidence — no silent drop.
Solution
polylogue/archive/topology/edge.py—TopologyEdgeStatusgains aQUARANTINEDvalue.polylogue/storage/sqlite/schema_ddl_archive.py—topology_edgesCHECK constraint extended to allow
quarantined.SCHEMA_VERSIONisbumped 6 → 7 (no migration chain; per the existing policy, mismatch
triggers re-ingest from source).
polylogue/storage/sqlite/queries/topology_edges.py— both resolverentry points (
resolve_topology_edges_for_conversationandresolve_unresolved_edges_for_child) now invoke_would_create_cyclebefore any UPDATE. The helper walks theproposed parent's existing ancestry via
parent_conversation_id,detects self-cycle and budget-exceeded as cycles, and returns the
full path so the rejection record is auditable. On cycle:
_quarantine_edgewritesstatus='quarantined'plus a JSON{reason, cycle_path, detected_at}toraw_evidence; theconversations row is NOT touched. A new helper
count_quarantined_topology_edgesis exported for diagnostics.devtools/daemon_workload_probe.py— addstopology_quarantine_state(unresolved/resolved/quarantined countstopology_edgesinto theboundary table set.
REPORT_VERSIONbumped 2 → 3.tests/unit/insights/test_topology_cycle_rejection.py— newevidence-bearing tests covering 2-node, 3-node, and self-cycle
rejection through both resolver entry points; the diamond-DAG
no-false-positive case (B→D, C→D both legit); the sibling-isolation
case (cycle on one child must not quarantine a clean sibling sharing
the parent batch); two idempotency assertions; and the
count_quarantined_topology_edgesdiagnostic.tests/unit/storage/test_dead_schema_sweep.py— pin updated forSCHEMA_VERSION 7.
Re-ingest plan
This PR bumps
SCHEMA_VERSION6 → 7 by widening thetopology_edges.statusCHECK to includequarantined. Per theexisting schema policy (docs/internals.md § Schema Versioning Model):
polylogue reset --database && polylogued runre-acquires from source.
the normal convergence pass; the blob store is unaffected.
catch-up; no extra disk usage.
No existing data needs format conversion — the change is purely an
expansion of the allowed status vocabulary.
Verification
nix develop -c pytest tests/unit/insights/test_topology_cycle_rejection.py -x— 9 passednix develop -c pytest tests/unit/insights/ tests/unit/storage/test_topology_edges.py -x— 151 passed (no regressions on the existing slice A/B suite)nix develop -c devtools verify --quick— exit_code 0 (lint, format, mypy, render-all, manifest gates, verify-test-clock-hygiene)Two pre-existing failures observed in broader runs (
cli() got an unexpected keyword argument 'cursor'in CLI tests, and theSimpleNamespace
topology_edgesattribute error intest_prepare_runtime) are present on master and unrelated to this PR.🤖 Generated with Claude Code