Repository navigation
feat: add target-aware reader user state - #1053
Conversation
Problem: #867 still had durable reader state gaps after marks and saved views reached daemon, reader, and MCP surfaces. Marks were conversation-only, annotations were explicitly unavailable, and the schema could not represent message-target user state. What changed: bump the archive schema to v13, migrate legacy conversation marks into target-aware rows, add durable annotation storage, expose conversation/message targets through Polylogue, daemon HTTP, and MCP, and update focused storage/daemon/MCP/visual evidence. Verification: pytest -q tests/unit/storage/test_user_state_contracts.py tests/unit/storage/test_schema_upgrades.py::test_ensure_schema_upgrades_v12_marks_to_target_aware_user_state tests/unit/storage/test_schema_upgrades.py::test_v12_to_v13_upgrade_plan_migrates_legacy_mark_table tests/unit/daemon/test_web_reader.py tests/unit/mcp/test_user_state_tools.py tests/unit/mcp/test_envelope_contracts.py tests/unit/mcp/test_tool_schema_witness.py tests/visual/test_reader_dom_smoke.py -> 89 passed. ruff format --check/ruff check/python -m mypy on changed files passed. Ref #867
Problem: #867 durable reader state had daemon, reader, and MCP access, but operators still lacked CLI parity for marks, annotations, and saved views. What changed: add a lazy user-state root command with mark, annotation, and saved-view subcommands; validate saved-view query JSON through ConversationQuerySpec; render the new CLI reference section; and add focused CLI registration/behavior tests. Verification: pytest -q tests/unit/cli/test_user_state_command.py tests/unit/cli/test_click_app.py::TestCliMetadata::test_all_subcommands_registered -> 5 passed. ruff check and python -m mypy on changed CLI files passed. Ref #867
Problem: adding the user-state CLI command changes generated command/proof/topology projections, so render-all --check required the committed surfaces to be refreshed. What changed: update generated quality workflow, topology status, and verification catalog counts for the new user-state command. Verification: devtools render-all --check -> sync OK. Ref #867
Problem: the user-state branch added routes and a CLI module that made verify-topology and verify-file-budgets fail. What changed: register the CLI module in the topology projection, refresh topology status, move user-state HTTP route dispatch into the user-state handler module to keep daemon/http.py under budget, and update the explicit schema-bootstrap file budget for the v13 migration branch. Verification: devtools verify-topology, devtools verify-file-budgets, python -m mypy polylogue/daemon/http.py polylogue/daemon/user_state_http.py, pytest -q tests/unit/daemon/test_web_reader.py::TestReaderUserState, devtools render-all --check. Ref #867
Problem: affected pytest showed that extending older schema upgrade paths to current made v11->v12 cost-column SQL run against minimal historical fixtures without messages/session_profiles, and the new user-state root command changed terminal help snapshots. What changed: make v11->v12 cost-column statements conditional on the target tables, avoid attachment index promotion when the referenced attachments table is absent, and refresh terminal snapshots for the user-state command. Verification: focused failed migration tests -> 8 passed; pytest -q tests/unit/cli/test_terminal_snapshots.py --snapshot-update -> 9 passed; ruff check and mypy for schema_bootstrap passed. Ref #867
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (34)
📝 WalkthroughWalkthroughThis PR implements comprehensive durable user-state management (marks, annotations, saved-views) across the polylogue system. It introduces a new ChangesUser-State Feature Implementation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 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: 4de162d0d0
ℹ️ 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. |
|
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
Add the next #867 durable reader-state slice: target-aware marks, first-class annotations, CLI parity, daemon HTTP/MCP exposure, and the schema upgrade needed to preserve existing conversation marks while supporting message targets.
Problem
The reader/user-state work merged so far exposed conversation-level marks and saved views through daemon, reader, and MCP surfaces, but #867 still required message targets, annotations, CLI parity, and proof that user metadata remains outside archive content hashes. The old
user_marksprimary key could not represent message-level marks, and annotations were still advertised as unavailable in reader action payloads.Solution
user_marksinto target-aware(target_type, target_id, mark_type)rows.user_annotationsstorage for conversation/message targets.Polyloguefacade for target-aware marks and annotation CRUD./api/user/annotationsroutes and widen/api/user/marksto conversation/message targets.polylogue user-stateCLI commands for marks, annotations, and saved views.Remaining #867 scope after this PR: recall-pack export/read model that cites marks/annotations/messages with explicit degraded-target states, plus fuller reader UI workflows for editing annotations inline.
Ref #867
Verification
pytest -q tests/unit/storage/test_user_state_contracts.py tests/unit/storage/test_schema_upgrades.py::test_ensure_schema_upgrades_v12_marks_to_target_aware_user_state tests/unit/storage/test_schema_upgrades.py::test_v12_to_v13_upgrade_plan_migrates_legacy_mark_table tests/unit/daemon/test_web_reader.py tests/unit/mcp/test_user_state_tools.py tests/unit/mcp/test_envelope_contracts.py tests/unit/mcp/test_tool_schema_witness.py tests/visual/test_reader_dom_smoke.py-> 89 passedpytest -q tests/unit/cli/test_user_state_command.py tests/unit/cli/test_click_app.py::TestCliMetadata::test_all_subcommands_registered-> 5 passedpytest -q tests/unit/storage/test_backend.py::test_ensure_schema_upgrades_v2_message_types_without_reimport tests/unit/storage/test_backend.py::test_ensure_schema_upgrades_v7_by_dropping_run_ledger tests/unit/storage/test_backend.py::test_ensure_schema_upgrades_v2_already_extended_without_overwriting tests/unit/storage/test_backend.py::test_async_backend_upgrades_v2_message_types_without_reimport tests/unit/storage/test_provider_events_schema.py::test_ensure_schema_upgrades_v6_provider_meta_compactions_to_provider_events tests/unit/storage/test_schema_safety.py::TestMigrationRollbackSafety::test_v2_to_v3_upgrade_rolls_back_on_failure tests/unit/storage/test_schema_upgrades.py::test_ensure_schema_upgrades_v8_by_indexing_message_foreign_keys tests/unit/storage/test_action_fts_schema_upgrade.py::test_ensure_schema_upgrades_v3_action_fts_rowids_without_reimport-> 8 passedpytest -q tests/unit/cli/test_terminal_snapshots.py --snapshot-update-> 9 passeddevtools verify --quick-> exit_code 0devtools verify --affected --skip-slow-> structural gates passed; pytest ran 6,384 tests with one daemon timeout intest_search_with_bad_date_returns_query_error; exact rerun passed:pytest -q tests/unit/daemon/test_web_reader.py::TestQueryNoResultsDiagnosticPath::test_search_with_bad_date_returns_query_error-> 1 passedSummary by CodeRabbit
Release Notes
user-stateCLI command for managing marks, annotations, and saved views across conversations and individual messages.