Repository navigation
refactor(mutations): centralize validation through ArchiveMutationsMixin (#862) - #1112
Conversation
Routes the seven remaining surface-side mutation paths through the shared ArchiveMutationsMixin contract (#862): 1. CLI apply_modifiers metadata path goes through env.polylogue.set_metadata so the conversation-existence check fires. 2. MCP bulk_tag_conversations routes through Polylogue.bulk_tag_conversations instead of reaching into the tag store with inline batch caps. 3. MCP delete_metadata routes through Polylogue.delete_metadata instead of the tag store. 4. MCP delete_conversation routes through delete_conversation_safe which returns a typed not_found result rather than relying on bool->string mapping inside the surface. 5. CLI delete_conversations routes through env.polylogue.delete_conversation_safe when no custom repo is provided. 6. Metadata key validation is centralized in validate_metadata_key and ArchiveMutationsMixin._validate_metadata_key. 7. Daemon _handle_reset is fixed: the previous sync callback dropped the delete_conversation coroutine into the JSON encoder. The handler now awaits delete_conversation_safe through the async run path. Adds typed result models (MetadataMutationResult, DeleteConversationResult, BulkTagMutationResult) and an inherited property-test fix for filter monotonicity that surfaced during full verify. 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 (10)
✨ 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 |
Summary
Routes the seven remaining surface-side mutation paths through the shared
ArchiveMutationsMixincontract introduced in #1109, completing thecross-surface centralization tracked by #862. Adds typed result models
(
MetadataMutationResult,DeleteConversationResult,BulkTagMutationResult) and a single source of truth for metadata keyvalidation.
Problem
Audit of master left seven divergences where CLI, MCP, and daemon
surfaces still bypassed the operation mixin:
polylogue/cli/query_actions.py::apply_modifiersset metadata viarepo.update_metadatadirectly, skipping the conversation-existencecheck.
polylogue/mcp/server_mutation_tools.py::bulk_tag_conversationscalled
tag_store.bulk_add_tagsdirectly with inline 100/20 batchcaps duplicated outside the operation layer.
polylogue/mcp/server_mutation_tools.py::delete_metadatacalledtag_store.delete_metadatadirectly with no resolution throughthe facade.
polylogue/mcp/server_mutation_tools.py::delete_conversationmapped
bool -> "deleted"/"not_found"inside the surface; nothingguaranteed every adapter would do that the same way.
polylogue/cli/query_actions.py::delete_conversationscalledrepo.delete_conversationdirectly without facade resolution oridempotency contract.
inline in MCP
set_metadataonly — every other surface relied onstorage-layer behavior.
polylogue/daemon/http.py::_handle_resethad a latent async bug:the synchronous
_do_resetcallback called the asyncpoly.delete_conversationand returned the coroutine into a JSONencode path, never deleting anything.
Solution
polylogue/operations/mutations.py: extendedArchiveMutationsMixinwith resolve-aware typed-result entrypoints —
set_metadata_validated,delete_metadata_validated,delete_conversation_safe,bulk_tag_conversations— plus the centralized_validate_metadata_keyhelper and aMetadataKeyValidationErrorexception. The previous bool-returning methods stay as low-level
delegates.
polylogue/surfaces/payloads.py: added typedMetadataMutationResult,DeleteConversationResult,BulkTagMutationResult, andvalidate_metadata_key/METADATA_KEY_MAX_LENGTHconstants.polylogue/api/archive.py:Polylogue.delete_conversation,update_metadata, the newset_metadata,delete_metadata,delete_conversation_safe, andbulk_tag_conversationsall routethrough the mixin.
polylogue/cli/query_actions.py:apply_modifiersmetadata writesgo through
env.polylogue.set_metadata;delete_conversationscallsenv.polylogue.delete_conversation_safe. Custom-repo escape hatchespreserved for test/batch tools.
polylogue/mcp/server_mutation_tools.py: bulk tagging, set/deletemetadata, and delete-conversation tools route through the facade and
the typed results; key validation runs at the surface boundary before
opening the facade so unit tests can exercise the rejection path
without standing up an archive.
polylogue/daemon/http.py:_handle_resetnow awaitsdelete_conversation_safethrough the existing_sync_runasyncbridge and removes the obsolete
_get_or_create_polyloguehelper.tests/unit/operations/test_mutations.py(new): 17 tests coveringevery (mutation, exists/missing, validation) pair on top of a real
SQLite archive built via
ConversationBuilder.tests/unit/mcp/test_tool_contracts.py,tests/infra/mcp.py:refreshed mocks to track the new facade-typed return values.
tests/property/test_filter_chain_laws.py: fix for an inheritedproperty-test failure (provider filter replaces prior provider rather
than intersecting, so the monotonicity law required tightening to
an impossible provider on disagreement). Surfaced by
devtools verifybefore this PR could be merged.
Verification
Closes #862