Repository navigation
feat(storage): mirror transform candidates as assertions (#1883) - #1973
Conversation
Problem: #1880 recovery digests extract decision/run-state candidates, but #1883 had no policy path to persist those candidates in the assertion substrate. Leaving them only in the digest meant future memory/promotion work had no evidence-bearing row shape to consume. What changed: add deterministic transform-candidate assertion ids and a bulk user-tier adapter that writes recovery digest candidates as private candidate-status AssertionKind.TRANSFORM_CANDIDATE rows. The adapter preserves transform id/version, source origin, body text, evidence refs, transform author identity, and an explicit non-injection context policy. Verification: uv run devtools test tests/unit/storage/test_archive_tiers_assertions.py tests/unit/insights/test_transforms.py -> 20 passed. uv run devtools verify --quick -> exit_code 0.
|
Warning Review limit reached
More reviews will be available in 52 minutes and 37 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds two new exported functions to ChangesTRANSFORM_CANDIDATE assertion upsert and tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 4d22355569
ℹ️ 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".
Problem: review caught that re-mirroring the same recovery digest could overwrite a transform candidate that had already moved out of candidate status, resetting accepted/deleted lifecycle state back to candidate. What changed: transform-candidate mirroring now returns an existing assertion unchanged when its status is no longer candidate, preserving user/promotion lifecycle state while keeping candidate rows refreshable before promotion. Verification: uv run devtools test tests/unit/storage/test_archive_tiers_assertions.py tests/unit/insights/test_transforms.py -> 20 passed. uv run devtools verify --quick -> exit_code 0.
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/storage/sqlite/archive_tiers/user_write.py`:
- Around line 155-174: The assertion_id_for_transform_candidate function does
not include the candidate occurrence index in its identifier generation, causing
multiple candidates with identical kind, text, and evidence references to
overwrite each other during upsert operations. Add a candidate occurrence or
index parameter to the assertion_id_for_transform_candidate function signature
and include this parameter in the _deterministic_id call to ensure each
candidate occurrence produces a unique assertion ID. Update all call sites that
invoke assertion_id_for_transform_candidate to pass the appropriate candidate
occurrence index.
🪄 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: 613864a2-0f00-468e-b269-c4151fbb1acf
📒 Files selected for processing (2)
polylogue/storage/sqlite/archive_tiers/user_write.pytests/unit/storage/test_archive_tiers_assertions.py
Problem: CodeRabbit caught that transform candidate identity included the candidate key index but not the assertion id index, so two identical candidate occurrences could collapse into one row. What changed: include candidate_index in transform-candidate assertion ids and metadata, pass the mirror loop index, and test duplicated candidate occurrences alongside lifecycle preservation. Verification: uv run devtools test tests/unit/storage/test_archive_tiers_assertions.py tests/unit/insights/test_transforms.py -> 20 passed. uv run devtools verify --quick -> exit_code 0.
Summary
Mirrors recovery digest decision/run-state candidates into the #1883 assertion substrate as private, evidence-linked
transform_candidaterows. This connects #1880 transform outputs to the user-tier assertion lifecycle without auto-promoting them into memory or context.Problem
#1880 already extracts deterministic decision and run-state candidates from raw coding-agent sessions, but those candidates only lived inside the recovery digest. #1883 already reserved
AssertionKind.TRANSFORM_CANDIDATE, but lacked the policy/write path that turns digest candidates into durable assertion rows with evidence refs, transform author identity, status, and context-injection policy.Solution
Added
assertion_id_for_transform_candidate(...)andupsert_transform_candidate_assertions(...)in the user-tier write helpers. The adapter writes each recovery digest candidate with:kind=transform_candidatestatus=candidatevisibility=privateauthor_kind=transformauthor_ref=transform:<id>@v<version>TransformRawRef.to_evidence_ref().format()context_policy={"inject": false, "promotion_required": true}The transform compiler stays storage-free; storage consumes the typed digest DTO at the assertion boundary.
Verification
uv run devtools test tests/unit/storage/test_archive_tiers_assertions.py -k 'transform_candidate or assertion_round_trip or list_assertions'->3 passed, 5 deselecteduv run devtools test tests/unit/storage/test_archive_tiers_assertions.py tests/unit/insights/test_transforms.py->20 passeduv run devtools verify --quick->exit_code: 0devtools verify --quick->exit_code: 0#1880 PR handoff checklist
Issue slice: #1883-backed transform-candidate promotion policy for #1880 recovery digest candidates.
Files inspected:
polylogue/insights/transforms.py,polylogue/storage/sqlite/archive_tiers/user_write.py,tests/unit/insights/test_transforms.py,tests/unit/storage/test_archive_tiers_assertions.py,docs/plans/layering.yaml, issue threads #1880 and #1883.Files changed:
polylogue/storage/sqlite/archive_tiers/user_write.py,tests/unit/storage/test_archive_tiers_assertions.py.Old surface removed or retained: retained. Recovery digests remain storage-free and no legacy assertion/overlay surface is removed.
Contracts/tests added: transform candidates are written as deterministic assertion rows with candidate status, private visibility, transform author refs, evidence refs, value metadata, and explicit non-injection context policy; re-upsert preserves identity and
created_at_mswhile updatingupdated_at_ms.Generated artifacts updated: none; no topology or generated doc drift.
Verification commands and results: see Verification section above.
Known caveats / SPEC_MISMATCH: none. This does not accept/promote candidates; it only records them as assertion candidates.
Follow-up intentionally not included: acceptance/promotion UI/API, persisted recovery-output tables, and broader #1886 primitive reconciliation.
Refs #1880
Refs #1883
Summary by CodeRabbit