Repository navigation
refactor(tags): back user tags with assertions (#1842) - #2144
Conversation
Problem: #1842 cannot finish the user-overlay command cleanup while user tags remain a direct table-only mutation path. The root tags command also still exposed its own add/remove workflow instead of the query-first mark action that owns tag mutation. What changed: user tag writes now mirror active tag assertions and removals tombstone the mirrored assertion. The root tags command is read-only tag-count output; tag mutation is taught through polylogue find QUERY then mark --tag-add/--tag-remove. Storage, facade, CLI, generated help, and showcase baselines were updated together. Verification: devtools test affected storage/API/CLI selection -> 22 passed; devtools render all --check -> sync OK; devtools lab scenario verify-baselines -> 76 exercises, all baselines match; devtools verify --quick -> exit_code 0. Ref #1842
|
Warning Review limit reached
More reviews will be available in 39 minutes and 51 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 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 credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. 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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. 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)
📝 WalkthroughWalkthroughThe PR narrows the ChangesSession tag assertion mirroring and tags CLI simplification
Sequence Diagram(s)sequenceDiagram
participant WriteLayer as upsert_session_tag
participant Mirror as _mirror_session_tag_assertion_if_available
participant UserWrite as upsert_session_tag_assertion
participant Archive as remove_user_tags
participant AssertionStore as mark_assertion_status
WriteLayer->>Mirror: conn, session_id, tag, tag_source=user
Mirror->>Mirror: _table_exists(conn, assertions)
Mirror->>UserWrite: upsert TAG assertion with deterministic ID
UserWrite-->>Mirror: ArchiveAssertionEnvelope
Archive->>Archive: DELETE from session_tags, capture rowcount
Archive->>AssertionStore: assertion_id_for_session_tag, mark status=deleted
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
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/archive.py`:
- Around line 1226-1233: Add a table existence check before calling
mark_assertion_status to prevent crashes when the assertions table doesn't
exist. Wrap the mark_assertion_status call that updates the assertions table
with a guard condition using _table_exists(user_conn, "assertions"), similar to
the defensive check pattern already implemented in write.py. This ensures that
when user.db contains session_tags but not assertions, the code handles the
missing table gracefully instead of raising sqlite3.OperationalError.
🪄 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: f8c03d24-5ba1-4a4e-b794-06d7ae99f5aa
📒 Files selected for processing (11)
docs/cli-reference.mdpolylogue/cli/commands/tags.pypolylogue/storage/sqlite/archive_tiers/archive.pypolylogue/storage/sqlite/archive_tiers/user_write.pypolylogue/storage/sqlite/archive_tiers/write.pytests/baselines/showcase/help-tags.txttests/unit/api/test_facade_contracts.pytests/unit/cli/test_command_aux_runtime.pytests/unit/storage/test_archive_tiers_archive.pytests/unit/storage/test_archive_tiers_assertion_write_through.pytests/unit/storage/test_user_state_contracts.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc97b8a666
ℹ️ 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: CodeRabbit correctly noted that remove_user_tags could tombstone a mirrored assertion even when a legacy user.db still had session_tags but no assertions table. What changed: guard the assertion tombstone with the existing archive-tier table-existence helper and add a regression that drops assertions from user.db before removing a tag. Verification: devtools test tests/unit/storage/test_archive_tiers_archive.py::test_archive_tiers_archive_facade_adds_user_tags tests/unit/storage/test_archive_tiers_archive.py::test_archive_tiers_remove_user_tags_tolerates_legacy_user_db_without_assertions -> 2 passed; devtools verify --quick -> exit_code 0. Ref #1842
Problem: Codex correctly noted that adding an already-present user tag skipped the upsert helper, so archives with pre-existing table-only session_tags would not repair their missing assertion mirror. What changed: duplicate add_user_tags calls now still route through upsert_session_tag to backfill the mirrored assertion while preserving affected_count=0. A regression deletes the assertion row and proves the duplicate add restores an active mirror. Verification: devtools test tests/unit/storage/test_archive_tiers_archive.py::test_archive_tiers_archive_facade_adds_user_tags tests/unit/storage/test_archive_tiers_archive.py::test_archive_tiers_remove_user_tags_tolerates_legacy_user_db_without_assertions tests/unit/storage/test_archive_tiers_archive.py::test_archive_tiers_duplicate_user_tag_add_backfills_missing_assertion -> 3 passed; devtools verify --quick -> exit_code 0. Ref #1842
## Summary Move the user-overlay command families off the root `polylogue` surface and under the existing `polylogue user-state` owner. This removes root `blackboard` and `feedback`, keeps their behavior available as `polylogue user-state blackboard ...` and `polylogue user-state feedback ...`, renames the implementation modules away from root-command names, refreshes generated help/docs/baselines, and deletes the stale CLI audit document that contradicted the reopened #1842 scope. ## Problem #1842 was reopened because the public CLI still taught a flat command zoo after several earlier absorption slices landed. After #2144, user tags are assertion-backed and the next coherent overlay step is to make reader-user-state own the remaining blackboard/feedback surfaces instead of leaving them as root command families. The stale `docs/cli-audit.md` also preserved old conclusions such as root feedback/blackboard and old query verbs, making it more misleading than useful. ## Solution - Register `user-state` as a lazy Click group and attach `blackboard` and `feedback` beneath it, without hidden root aliases or compatibility shims. - Rename `polylogue/cli/commands/blackboard.py` and `feedback.py` to `user_state_blackboard.py` and `user_state_feedback.py`, and update examples/docstrings to the new command path. - Update archive route metadata, behavior tests, JSON command smoke coverage, completion tests, snapshots, generated help baselines, CLI reference, topology projection, and agent/docs surfaces. - Delete `docs/cli-audit.md`; the live reopened issue #1842 is now the durable command-floor spec. - Add per-exercise progress output to `devtools lab scenario verify-baselines` so the 96-command showcase help lane is observable instead of appearing hung. ## Verification - `devtools test tests/unit/cli/test_blackboard.py tests/unit/cli/test_json_output.py tests/unit/cli/test_click_app.py::TestCliMetadata::test_retained_command_owners_are_registered tests/unit/cli/test_completion_matrix.py tests/unit/cli/test_status.py::test_archive_cli_route_catalog_reports_user_tier_surfaces tests/unit/cli/test_status.py::TestNoArchiveStatus::test_direct_status_json_reads_archive_file_set_from_archive_tiers tests/unit/cli/test_help_snapshots.py tests/unit/cli/test_terminal_snapshots.py tests/unit/cli/test_plain_cli_snapshots.py tests/unit/showcase/test_exercise_catalog.py::TestExercisesByGroup::test_all_command_paths_have_generated_help_exercises tests/unit/showcase/test_exercise_catalog.py::TestExercisesByGroup::test_inventory_includes_nested_command_paths` -> `189 passed` - `devtools lab scenario verify-baselines --update` -> `Ran 96 exercises`, updated baselines - `devtools lab scenario verify-baselines` -> `Ran 96 exercises`, `All baselines match.` - `devtools render all --check` -> sync OK - `devtools verify --quick` -> `exit_code: 0` - `devtools verify` -> refused because this fresh worktree has no seeded testmon DB: `pytest-testmon is not seeded; run devtools verify --seed-testmon ...` Ref #1842
|
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
User tag writes now mirror into the assertion substrate, and the root
tagscommand is reduced to the live tag-count read surface. Tag mutation remains available through the query-firstfind ... then mark --tag-add/--tag-removepath, so #1842 can keep shrinking overlay roots without preserving a separatepolylogue tags SESSION --add-tagworkflow.Problem
#1842 explicitly blocks the user-overlay command cleanup on assertion-backed equivalence for
tags,blackboard,feedback, anduser-state. Before this change, user tags were table-only state:upsert_session_tagwrotesession_tags, removals deleted only that table row, and the roottagscommand exposed its own add/remove path alongside query-firstmarkmutation. That kept user tags outside the assertion substrate and left two CLI mutation homes.Solution
session_tagswrites into deterministickind=tagassertions when the active tier owns theassertionstable.deletedwhenArchiveStore.remove_user_tagsremoves the user tag.polylogue tagsas read-only live tag counts, with help/hints pointing tag mutation topolylogue find QUERY then mark --tag-add/--tag-remove.Polylogue.add_tag/remove_tag, and CLI read path.This does not delete the root
tagscommand yet: it remains the live user-tag count view until that read capability has an equivalent home.Verification
devtools test tests/unit/storage/test_archive_tiers_assertion_write_through.py tests/unit/storage/test_archive_tiers_archive.py::test_archive_tiers_archive_facade_adds_user_tags tests/unit/storage/test_user_state_contracts.py::test_tags_and_metadata_remain_table_backed_user_metadata tests/unit/api/test_facade_contracts.py::test_archive_tiers_api_user_mutations_write_user_tier tests/unit/cli/test_command_aux_runtime.py::test_tags_command_plain_paths_cover_empty_hint_and_tabular_counts tests/unit/cli/test_json_envelope_contract.py::TestTagsJsonEnvelope::test_tags_json_has_status_ok 'tests/unit/cli/test_json_envelope_contract.py::TestQueryShapedJsonMatrix::test_format_json_uses_success_envelope[args0-tags]' tests/unit/cli/test_deterministic_output.py::TestJsonOutputValidity::test_tags_json_is_valid tests/unit/cli/test_deterministic_output.py::TestJsonDeterminism::test_tags_json_deterministic 'tests/unit/cli/test_deterministic_output.py::TestJsonEnvelopeParametrized::test_json_only_commands_reject_other_formats[tags-yaml-rejected]'-> 22 passeddevtools render all --check-> sync OKdevtools lab scenario verify-baselines-> 76 exercises, all baselines matchdevtools verify --quick-> exit_code 0devtools verify --seed-testmon --skip-slow-> terminated after the broad seed lane emitted multiple failures and then ran for ~88 minutes without a final report; branch-specific focused tests andverify --quickare green, but the fresh-worktree seed baseline is not greenRef #1842
Summary by CodeRabbit
Release Notes
API Changes
polylogue tagscommand to list tags only; tag add/remove operations now usepolylogue find ... then mark --tag-add/--tag-removeworkflow.Documentation
Improvements