Repository navigation
refactor: renew storage runtime query contracts - #247
Conversation
📝 WalkthroughWalkthroughThis PR reorganizes storage type definitions across dedicated modules and establishes new protocol boundaries for repository capabilities. It moves types like Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels
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 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.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
polylogue/cli/query_semantic.py (1)
239-244:⚠️ Potential issue | 🟠 MajorUse row readiness for batch action-event stats.
Line 239 requires
.ready, which also requires FTS readiness. This path only callsget_action_events_batch()on Line 244, so materialized rows are sufficient; stale/pending FTS will unnecessarily force the expensive hydration fallback.🐛 Proposed fix
- action_read_model_ready = (await repo.get_action_event_artifact_state()).ready + action_event_rows_ready = (await repo.get_action_event_artifact_state()).rows_ready for offset in range(0, len(conversation_ids), batch_size): batch_ids = conversation_ids[offset : offset + batch_size] - if action_read_model_ready: + if action_event_rows_ready: action_events_by_conversation = await repo.get_action_events_batch(batch_ids)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@polylogue/cli/query_semantic.py` around lines 239 - 244, The code is checking artifact readiness via action_read_model_ready = (await repo.get_action_event_artifact_state()).ready which forces full FTS hydration; instead check the artifact's materialized/row-level readiness before calling get_action_events_batch so we don't trigger the expensive FTS fallback. Replace the .ready check with the row/materialized readiness flag returned by get_action_event_artifact_state (e.g., use the property named rows_materialized, materialized, or rows_ready on that result) and only call repo.get_action_events_batch(batch_ids) when that row-level flag is true; keep the single call to get_action_event_artifact_state and reuse its row-readiness result for the loop over conversation_ids/batch_size.polylogue/storage/action_event_status.py (1)
99-155:⚠️ Potential issue | 🟡 Minor
ActionEventArtifactState.readybecomes unconditionally truthy whenverify_source_alignment=False.In both the sync (Lines 99–101) and async (Lines 143–145) branches,
valid_source_conversation_countis aliased tomaterialized_conversation_countand orphan/stale counts are zeroed. Combined withstale_count = 0andmatches_version = True, the resultingActionEventArtifactStatewill always reportrows_ready=Trueand (assuming the FTS row count matches)ready=True, regardless of actual source alignment. This matches the prior dict-based behavior, but the typed.readyproperty reads as an unconditional guarantee, which is easy to misuse from callers that aren’t aware of the flag. Consider either:
- documenting on
ActionEventArtifactStatethatreadyis relative to the verification mode used to construct it, or- having
action_event_artifact_state_{sync,async}return a sentinel (e.g., leavesource_conversations=0and flag it) when alignment wasn’t verified sorows_readyreflects that explicitly.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@polylogue/storage/action_event_status.py` around lines 99 - 155, When verify_source_alignment is False in action_event_artifact_state_sync and action_event_artifact_state_async, the returned ActionEventArtifactState currently reports matches_version=True and thus rows_ready may be misleading; update both functions so that when verify_source_alignment=False they return a clearly "unverified" state (e.g., set matches_version=False and/or use a sentinel for source_conversations like None or 0 plus set stale_rows to a sentinel) so callers can distinguish unverified vs verified readiness, and ensure the change is applied in the return construction of ActionEventArtifactState in both functions (refer to action_event_artifact_state_sync, action_event_artifact_state_async and the verify_source_alignment parameter).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@polylogue/lib/query_retrieval_candidates.py`:
- Around line 42-64: Multiple helpers repeatedly call
repository.get_action_event_artifact_state() causing redundant work; fetch the
ActionEventArtifactState once per query execution and thread it into the helpers
instead of always awaiting the repository. Concretely: change
action_event_rows_ready, action_search_ready, and
can_use_action_event_stats_with to accept an optional artifact_state parameter
(or accept a pre-fetched ActionEventArtifactState) and only call
repository.get_action_event_artifact_state() when that parameter is None; update
callers along the search/hybrid path (e.g., candidate_record_query_for and the
call site that invokes action_search_ready) to fetch
repository.get_action_event_artifact_state() once and pass it to these
functions. This ensures the frozen ActionEventArtifactState is reused for the
duration of the plan execution.
In `@polylogue/protocols.py`:
- Around line 213-329: The protocol types mix bare list[...] and
builtins.list[...] causing inconsistency; standardize to builtins.list[...]
across the protocol surfaces in this file. Update return/arg annotations in
ConversationQueryRuntimeStore (list_summaries_by_query, list_by_query,
search_actions providers already uses builtins.list), ArchiveMessageQueryStore
(get_messages, get_message_counts_batch, get_conversation_stats signatures),
SemanticArchiveQueryStore (get_conversations_batch, get_messages_batch,
get_attachments_batch), and any other protocol methods using bare list[...] to
use builtins.list[...] for uniformity.
In `@polylogue/storage/repository_archive_queries.py`:
- Line 10: The import of ConversationQueryRuntimeStore is only needed for typing
in the cast on line where typing.cast(...) is used (around the cast at/near line
212); move the ConversationQueryRuntimeStore import into a TYPE_CHECKING block
(from typing import TYPE_CHECKING) and change the cast to use a string literal
type name (e.g., typing.cast("ConversationQueryRuntimeStore", ...)) so the
symbol is not imported at runtime and removes the runtime coupling.
In `@tests/unit/pipeline/test_run_sources.py`:
- Line 338: Remove the redundant inner import of RunResult: delete the local
"from polylogue.storage.run_state import RunResult" found inside the test (it is
already imported at module scope), leaving references to RunResult to use the
existing module-level import; run tests to verify no unresolved references
remain.
---
Outside diff comments:
In `@polylogue/cli/query_semantic.py`:
- Around line 239-244: The code is checking artifact readiness via
action_read_model_ready = (await repo.get_action_event_artifact_state()).ready
which forces full FTS hydration; instead check the artifact's
materialized/row-level readiness before calling get_action_events_batch so we
don't trigger the expensive FTS fallback. Replace the .ready check with the
row/materialized readiness flag returned by get_action_event_artifact_state
(e.g., use the property named rows_materialized, materialized, or rows_ready on
that result) and only call repo.get_action_events_batch(batch_ids) when that
row-level flag is true; keep the single call to get_action_event_artifact_state
and reuse its row-readiness result for the loop over
conversation_ids/batch_size.
In `@polylogue/storage/action_event_status.py`:
- Around line 99-155: When verify_source_alignment is False in
action_event_artifact_state_sync and action_event_artifact_state_async, the
returned ActionEventArtifactState currently reports matches_version=True and
thus rows_ready may be misleading; update both functions so that when
verify_source_alignment=False they return a clearly "unverified" state (e.g.,
set matches_version=False and/or use a sentinel for source_conversations like
None or 0 plus set stale_rows to a sentinel) so callers can distinguish
unverified vs verified readiness, and ensure the change is applied in the return
construction of ActionEventArtifactState in both functions (refer to
action_event_artifact_state_sync, action_event_artifact_state_async and the
verify_source_alignment parameter).
🪄 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: 79632740-d461-4415-a8de-a63cff984b56
📒 Files selected for processing (79)
devtools/pipeline_probe.pypolylogue/cli/commands/run.pypolylogue/cli/formatting.pypolylogue/cli/query_actions.pypolylogue/cli/query_output.pypolylogue/cli/query_semantic.pypolylogue/cli/query_stats.pypolylogue/cli/run_display_workflow.pypolylogue/cli/run_observers.pypolylogue/cli/run_workflow.pypolylogue/lib/filters.pypolylogue/lib/query_plan.pypolylogue/lib/query_plan_execution.pypolylogue/lib/query_retrieval_candidates.pypolylogue/lib/query_retrieval_search.pypolylogue/lib/query_spec.pypolylogue/lib/run_activity.pypolylogue/pipeline/observers.pypolylogue/pipeline/prepare_enrichment.pypolylogue/pipeline/prepare_models.pypolylogue/pipeline/run_execution.pypolylogue/pipeline/run_finalization.pypolylogue/pipeline/run_planning.pypolylogue/pipeline/run_stages.pypolylogue/pipeline/run_state.pypolylogue/pipeline/services/acquisition.pypolylogue/pipeline/services/acquisition_records.pypolylogue/pipeline/services/acquisition_streams.pypolylogue/pipeline/services/ingest_batch.pypolylogue/pipeline/services/planning_models.pypolylogue/pipeline/services/planning_runtime.pypolylogue/pipeline/services/rendering.pypolylogue/pipeline/watch.pypolylogue/protocols.pypolylogue/rendering/core_formatter.pypolylogue/rendering/core_markdown.pypolylogue/rendering/renderers/html.pypolylogue/rendering/renderers/html_messages.pypolylogue/schemas/operator_models.pypolylogue/schemas/verification_artifacts.pypolylogue/showcase/workspace.pypolylogue/sources/cursor.pypolylogue/sources/decoder_zip.pypolylogue/sources/drive.pypolylogue/sources/source_acquisition.pypolylogue/sources/source_parsing.pypolylogue/sources/source_walk.pypolylogue/storage/action_event_status.pypolylogue/storage/archive_views.pypolylogue/storage/artifact_queries.pypolylogue/storage/artifact_views.pypolylogue/storage/backends/async_sqlite_raw.pypolylogue/storage/backends/queries/raw_reads.pypolylogue/storage/backends/queries/raw_state.pypolylogue/storage/backends/query_store.pypolylogue/storage/cursor_state.pypolylogue/storage/raw_ingest_artifacts.pypolylogue/storage/raw_state_models.pypolylogue/storage/repository_action_reads.pypolylogue/storage/repository_archive_conversations.pypolylogue/storage/repository_archive_queries.pypolylogue/storage/repository_raw.pypolylogue/storage/run_state.pytests/integration/test_security.pytests/unit/cli/test_check.pytests/unit/cli/test_query_exec.pytests/unit/cli/test_query_exec_laws.pytests/unit/cli/test_run.pytests/unit/cli/test_run_int.pytests/unit/cli/test_run_laws.pytests/unit/core/test_semantic_facts.pytests/unit/pipeline/test_ingest_batch.pytests/unit/pipeline/test_quarantine_fixtures.pytests/unit/pipeline/test_run_sources.pytests/unit/sources/test_acquisition_encoding.pytests/unit/sources/test_decoders.pytests/unit/sources/test_drive_ops.pytests/unit/sources/test_source_laws.pytests/unit/storage/test_parse_tracking.py
| async def action_event_rows_ready( | ||
| plan: ConversationQueryPlan, | ||
| repository: ConversationRepository, | ||
| repository: ConversationQueryRuntimeStore, | ||
| ) -> bool: | ||
| if not uses_action_read_model(plan): | ||
| return True | ||
| status_reader = getattr(repository, "get_action_event_read_model_status", None) | ||
| if status_reader is None: | ||
| return True | ||
| status = status_reader() | ||
| if inspect.isawaitable(status): | ||
| status = await status | ||
| if not isinstance(status, dict): | ||
| return True | ||
| return bool(status.get("rows_ready", status.get("ready", False))) | ||
| return (await repository.get_action_event_artifact_state()).rows_ready | ||
|
|
||
|
|
||
| async def action_search_ready( | ||
| plan: ConversationQueryPlan, | ||
| repository: ConversationRepository, | ||
| repository: ConversationQueryRuntimeStore, | ||
| ) -> bool: | ||
| if not uses_action_read_model(plan): | ||
| return True | ||
| status_reader = getattr(repository, "get_action_event_read_model_status", None) | ||
| if status_reader is None: | ||
| return True | ||
| status = status_reader() | ||
| if inspect.isawaitable(status): | ||
| status = await status | ||
| if not isinstance(status, dict): | ||
| return True | ||
| return bool(status.get("ready", False)) | ||
| return (await repository.get_action_event_artifact_state()).ready | ||
|
|
||
|
|
||
| async def can_use_action_event_stats_with( | ||
| plan: ConversationQueryPlan, | ||
| repository: ConversationRepository, | ||
| repository: ConversationQueryRuntimeStore, | ||
| ) -> bool: | ||
| return plan.can_use_action_event_stats() and await action_event_rows_ready(plan, repository) |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Consider memoizing get_action_event_artifact_state() for the duration of a single query execution.
action_event_rows_ready, action_search_ready, and can_use_action_event_stats_with each issue an independent await repository.get_action_event_artifact_state(). On the search/hybrid path we typically hit action_search_ready (Line 57), then candidate_record_query_for (Line 25 → action_event_rows_ready at Line 48) within the same plan execution, re-running the full artifact-state aggregation query each time. The previous status-probe path had the same shape, so this isn't a regression, but since the new ActionEventArtifactState is a frozen dataclass that composes rows_ready/ready, a single fetch threaded through these helpers would be a cheap win.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@polylogue/lib/query_retrieval_candidates.py` around lines 42 - 64, Multiple
helpers repeatedly call repository.get_action_event_artifact_state() causing
redundant work; fetch the ActionEventArtifactState once per query execution and
thread it into the helpers instead of always awaiting the repository.
Concretely: change action_event_rows_ready, action_search_ready, and
can_use_action_event_stats_with to accept an optional artifact_state parameter
(or accept a pre-fetched ActionEventArtifactState) and only call
repository.get_action_event_artifact_state() when that parameter is None; update
callers along the search/hybrid path (e.g., candidate_record_query_for and the
call site that invokes action_search_ready) to fetch
repository.get_action_event_artifact_state() once and pass it to these
functions. This ensures the frozen ActionEventArtifactState is reused for the
duration of the plan execution.
| @runtime_checkable | ||
| class ActionEventArtifactReader(Protocol): | ||
| """Read-only action-event artifact readiness surface.""" | ||
|
|
||
| async def get_action_event_artifact_state(self) -> ActionEventArtifactState: ... | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class ConversationQueryRuntimeStore( | ||
| ConversationReader, | ||
| SearchStore, | ||
| ActionEventArtifactReader, | ||
| Protocol, | ||
| ): | ||
| """Repository/query runtime surface consumed by canonical query execution.""" | ||
|
|
||
| async def list_summaries_by_query( | ||
| self, | ||
| query: ConversationRecordQuery, | ||
| ) -> list[ConversationSummary]: ... | ||
|
|
||
| async def list_by_query( | ||
| self, | ||
| query: ConversationRecordQuery, | ||
| ) -> list[Conversation]: ... | ||
|
|
||
| async def count_by_query(self, query: ConversationRecordQuery) -> int: ... | ||
|
|
||
| async def delete_conversation(self, conversation_id: str) -> bool: ... | ||
|
|
||
| async def search_actions( | ||
| self, | ||
| query: str, | ||
| limit: int = 20, | ||
| providers: builtins.list[str] | None = None, | ||
| ) -> list[Conversation]: ... | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class ArchiveMessageQueryStore(Protocol): | ||
| """Low-level archive/message query band used by CLI output and stats helpers.""" | ||
|
|
||
| async def get_conversation(self, conversation_id: str) -> ConversationRecord | None: ... | ||
|
|
||
| async def get_messages(self, conversation_id: str) -> list[MessageRecord]: ... | ||
|
|
||
| async def get_conversation_stats(self, conversation_id: str) -> dict[str, int]: ... | ||
|
|
||
| async def get_message_counts_batch(self, conversation_ids: list[str]) -> dict[str, int]: ... | ||
|
|
||
| async def aggregate_message_stats( | ||
| self, | ||
| conversation_ids: list[str] | None = None, | ||
| ) -> AggregateMessageStats: ... | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class SemanticArchiveQueryStore(ArchiveMessageQueryStore, Protocol): | ||
| """Archive query band needed to hydrate semantic facts in batch.""" | ||
|
|
||
| async def get_conversations_batch(self, ids: list[str]) -> list[ConversationRecord]: ... | ||
|
|
||
| async def get_messages_batch( | ||
| self, | ||
| conversation_ids: list[str], | ||
| ) -> dict[str, list[MessageRecord]]: ... | ||
|
|
||
| async def get_attachments_batch( | ||
| self, | ||
| conversation_ids: list[str], | ||
| ) -> dict[str, list[AttachmentRecord]]: ... | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class ConversationOutputStore(ConversationReader, Protocol): | ||
| """Conversation output surface used by streaming and summary display helpers.""" | ||
|
|
||
| @property | ||
| def queries(self) -> SemanticArchiveQueryStore: ... | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class ConversationSemanticStatsStore(ActionEventArtifactReader, Protocol): | ||
| """Semantic stats surface for action-event-backed grouped output.""" | ||
|
|
||
| @property | ||
| def queries(self) -> SemanticArchiveQueryStore: ... | ||
|
|
||
| async def get_action_events_batch( | ||
| self, | ||
| conversation_ids: list[str], | ||
| ) -> dict[str, tuple[ActionEvent, ...]]: ... | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class ConversationArchiveStatsStore( | ||
| ConversationOutputStore, | ||
| ConversationSemanticStatsStore, | ||
| Protocol, | ||
| ): | ||
| """Archive stats/profile surface consumed by grouped CLI output helpers.""" | ||
|
|
||
| @property | ||
| def backend(self) -> RepositoryBackendProtocol: ... | ||
|
|
||
| async def get_archive_stats( | ||
| self, | ||
| *, | ||
| conn: aiosqlite.Connection | None = None, | ||
| ) -> ArchiveStats: ... | ||
|
|
||
| async def get_session_profiles_batch( | ||
| self, | ||
| conversation_ids: list[str], | ||
| ) -> dict[str, SessionProfile]: ... | ||
|
|
||
| async def get_many(self, conversation_ids: list[str]) -> list[Conversation]: ... |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm ConversationRepository exposes the full ConversationArchiveStatsStore surface.
rg -nP --type=py -C2 '\b(get_archive_stats|get_session_profiles_batch|get_action_events_batch|get_many|get_message_counts_batch|aggregate_message_stats|get_conversations_batch|get_messages_batch|get_attachments_batch)\s*\('
rg -nP --type=py -C3 '\bdef\s+backend\b|\bbackend\s*:\s*RepositoryBackendProtocol'Repository: Sinity/polylogue
Length of output: 47918
Protocol surface is coherent with correct structural satisfaction.
The hierarchy cleanly narrows the surfaces, and the queries property return type is consistent across both parents of ConversationArchiveStatsStore — diamond inheritance resolves without conflict.
ConversationRepository structurally satisfies ConversationArchiveStatsStore through its mixins: it exposes backend, get_archive_stats(*, conn=None), get_session_profiles_batch(), get_action_events_batch(), get_many(), and all inherited query methods. Since these are @runtime_checkable protocols, structural satisfaction is verified at the isinstance call sites.
Optional refinement: For consistency, consider using builtins.list uniformly across all protocols, or leave bare list[...] as-is (current approach is acceptable since none of the new methods are named list). ConversationReader uses builtins.list due to list() method shadowing, but that constraint doesn't apply here—this is purely a style preference.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@polylogue/protocols.py` around lines 213 - 329, The protocol types mix bare
list[...] and builtins.list[...] causing inconsistency; standardize to
builtins.list[...] across the protocol surfaces in this file. Update return/arg
annotations in ConversationQueryRuntimeStore (list_summaries_by_query,
list_by_query, search_actions providers already uses builtins.list),
ArchiveMessageQueryStore (get_messages, get_message_counts_batch,
get_conversation_stats signatures), SemanticArchiveQueryStore
(get_conversations_batch, get_messages_batch, get_attachments_batch), and any
other protocol methods using bare list[...] to use builtins.list[...] for
uniformity.
| from typing import TYPE_CHECKING, cast | ||
|
|
||
| from polylogue.lib.conversation_models import Conversation, ConversationSummary | ||
| from polylogue.protocols import ConversationQueryRuntimeStore |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Inspect relevant import edges around protocols, filters, and repository archive queries.
python - <<'PY'
import ast
from pathlib import Path
for path in [
Path("polylogue/protocols.py"),
Path("polylogue/lib/filters.py"),
Path("polylogue/storage/repository_archive_queries.py"),
]:
print(f"\n== {path} ==")
tree = ast.parse(path.read_text(encoding="utf-8"))
for node in ast.walk(tree):
if isinstance(node, ast.Import):
print("import", ", ".join(alias.name for alias in node.names))
elif isinstance(node, ast.ImportFrom):
module = node.module or ""
names = ", ".join(alias.name for alias in node.names)
print(f"from {module} import {names}")
PYRepository: Sinity/polylogue
Length of output: 2288
🏁 Script executed:
# Check the actual usage of ConversationQueryRuntimeStore in repository_archive_queries.py
cat -n polylogue/storage/repository_archive_queries.py | head -30Repository: Sinity/polylogue
Length of output: 1191
🏁 Script executed:
# Search for all occurrences of ConversationQueryRuntimeStore in the file
rg "ConversationQueryRuntimeStore" polylogue/storage/repository_archive_queries.py -n -B2 -A2Repository: Sinity/polylogue
Length of output: 436
🏁 Script executed:
# Check the line count to determine file size
wc -l polylogue/storage/repository_archive_queries.pyRepository: Sinity/polylogue
Length of output: 111
🏁 Script executed:
# Check the full context around line 212
sed -n '200,215p' polylogue/storage/repository_archive_queries.pyRepository: Sinity/polylogue
Length of output: 579
Keep the protocol import type-only.
ConversationQueryRuntimeStore is only used in typing.cast() on line 212, where the first argument is discarded at runtime. Moving this to the TYPE_CHECKING block and using a string literal removes unnecessary runtime coupling.
♻️ Proposed cleanup
from polylogue.lib.conversation_models import Conversation, ConversationSummary
-from polylogue.protocols import ConversationQueryRuntimeStore
from polylogue.storage.query_models import ConversationRecordQuery
if TYPE_CHECKING:
+ from polylogue.protocols import ConversationQueryRuntimeStore
from polylogue.lib.filters import ConversationFilter
from polylogue.storage.backends.query_store import SQLiteQueryStore- return filters.ConversationFilter(cast(ConversationQueryRuntimeStore, self))
+ return filters.ConversationFilter(cast("ConversationQueryRuntimeStore", self))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@polylogue/storage/repository_archive_queries.py` at line 10, The import of
ConversationQueryRuntimeStore is only needed for typing in the cast on line
where typing.cast(...) is used (around the cast at/near line 212); move the
ConversationQueryRuntimeStore import into a TYPE_CHECKING block (from typing
import TYPE_CHECKING) and change the cast to use a string literal type name
(e.g., typing.cast("ConversationQueryRuntimeStore", ...)) so the symbol is not
imported at runtime and removes the runtime coupling.
| class TestRunSourcesRenderFailures: | ||
| def test_render_failure_tracked_in_result(self, workspace_env: WorkspaceEnv) -> None: | ||
| from polylogue.storage.state_views import RunResult | ||
| from polylogue.storage.run_state import RunResult |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Remove the redundant local RunResult import.
RunResult is already imported at module scope on Line 28, so this inner import can be dropped.
♻️ Proposed cleanup
- from polylogue.storage.run_state import RunResult
-
archive_root = workspace_env["archive_root"]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| from polylogue.storage.run_state import RunResult | |
| archive_root = workspace_env["archive_root"] |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/unit/pipeline/test_run_sources.py` at line 338, Remove the redundant
inner import of RunResult: delete the local "from polylogue.storage.run_state
import RunResult" found inside the test (it is already imported at module
scope), leaving references to RunResult to use the existing module-level import;
run tests to verify no unresolved references remain.
Closes #225 ## Summary - type the canonical query runtime against explicit repository protocols - split transient storage runtime views into focused modules and remove the aggregate shim - tighten CLI query/stat/semantic helpers onto narrower read/query contracts ## Problem The storage/lib runtime tranche still had two path-dependent seams: - canonical query execution and grouped CLI helpers depended on the concrete `ConversationRepository` more often than their semantics required - transient runtime/result shapes were funneled through `polylogue/storage/state_views.py`, a grab-bag aggregate that obscured ownership and kept broad container-style plumbing in place ## Solution - added explicit query/runtime protocols in `polylogue/protocols.py`, including `ConversationQueryRuntimeStore` and narrower CLI-facing output/stats/semantic surfaces - replaced action-readiness probing with direct `ActionEventArtifactState` accessors and propagated that through query runtime helpers - split `state_views.py` into `cursor_state.py`, `raw_state_models.py`, `artifact_views.py`, `archive_views.py`, and `run_state.py` - fanned imports out across pipeline, storage, CLI run surfaces, rendering, sources, showcase, devtools, and tests, then deleted the aggregate module entirely ## Verification - `ruff check polylogue/storage/cursor_state.py polylogue/storage/raw_state_models.py polylogue/storage/artifact_views.py polylogue/storage/archive_views.py polylogue/storage/run_state.py polylogue/storage/state_views.py polylogue/cli/query_actions.py` - `mypy polylogue/storage/cursor_state.py polylogue/storage/raw_state_models.py polylogue/storage/artifact_views.py polylogue/storage/archive_views.py polylogue/storage/run_state.py polylogue/storage/state_views.py polylogue/cli/query_actions.py` - `pytest -q tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.py` - `pytest -q tests/unit/storage/test_action_event_artifacts.py tests/unit/storage/test_fts5.py tests/unit/storage/test_embedding_stats.py tests/unit/storage/test_derived_status.py` - `pytest -q tests/unit/cli/test_check.py tests/unit/cli/test_run.py tests/unit/cli/test_run_int.py tests/unit/cli/test_run_laws.py tests/unit/core/test_semantic_facts.py tests/unit/pipeline/test_ingest_batch.py tests/unit/pipeline/test_quarantine_fixtures.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_acquisition_encoding.py tests/unit/sources/test_decoders.py tests/unit/sources/test_drive_ops.py tests/unit/sources/test_source_laws.py tests/unit/storage/test_parse_tracking.py tests/integration/test_security.py` - `devtools verify`
The storage/lib runtime had two path-dependent seams. Canonical query execution and grouped CLI helpers depended on the concrete `ConversationRepository` more often than their semantics required. Transient runtime/result shapes funneled through `storage/state_views.py`, a grab-bag aggregate that obscured ownership and kept broad container-style plumbing in place. Adds explicit query/runtime protocols in `protocols.py` including `ConversationQueryRuntimeStore` and narrower CLI-facing output / stats / semantic surfaces. Replaces action-readiness probing with direct `ActionEventArtifactState` accessors; propagates through query runtime helpers. Splits `state_views.py` into `cursor_state.py`, `raw_state_models.py`, `artifact_views.py`, `archive_views.py`, and `run_state.py`. Fans imports out across pipeline, storage, CLI run surfaces, rendering, sources, showcase, devtools, and tests, then deletes the aggregate module entirely. Verification: ruff + mypy over touched modules; focused pytest over query-exec, action-event-artifact, FTS, embedding-stats, check, run, semantic-facts, ingest, quarantine, and security suites; devtools verify green. Closes #225
The storage/lib runtime had two path-dependent seams. Canonical query execution and grouped CLI helpers depended on the concrete `ConversationRepository` more often than their semantics required. Transient runtime/result shapes funneled through `storage/state_views.py`, a grab-bag aggregate that obscured ownership and kept broad container-style plumbing in place. Adds explicit query/runtime protocols in `protocols.py` including `ConversationQueryRuntimeStore` and narrower CLI-facing output / stats / semantic surfaces. Replaces action-readiness probing with direct `ActionEventArtifactState` accessors; propagates through query runtime helpers. Splits `state_views.py` into `cursor_state.py`, `raw_state_models.py`, `artifact_views.py`, `archive_views.py`, and `run_state.py`. Fans imports out across pipeline, storage, CLI run surfaces, rendering, sources, showcase, devtools, and tests, then deletes the aggregate module entirely. Verification: ruff + mypy over touched modules; focused pytest over query-exec, action-event-artifact, FTS, embedding-stats, check, run, semantic-facts, ingest, quarantine, and security suites; devtools verify green. Closes #225
The storage/lib runtime had two path-dependent seams. Canonical query execution and grouped CLI helpers depended on the concrete `ConversationRepository` more often than their semantics required. Transient runtime/result shapes funneled through `storage/state_views.py`, a grab-bag aggregate that obscured ownership and kept broad container-style plumbing in place. Adds explicit query/runtime protocols in `protocols.py` including `ConversationQueryRuntimeStore` and narrower CLI-facing output / stats / semantic surfaces. Replaces action-readiness probing with direct `ActionEventArtifactState` accessors; propagates through query runtime helpers. Splits `state_views.py` into `cursor_state.py`, `raw_state_models.py`, `artifact_views.py`, `archive_views.py`, and `run_state.py`. Fans imports out across pipeline, storage, CLI run surfaces, rendering, sources, showcase, devtools, and tests, then deletes the aggregate module entirely. Verification: ruff + mypy over touched modules; focused pytest over query-exec, action-event-artifact, FTS, embedding-stats, check, run, semantic-facts, ingest, quarantine, and security suites; devtools verify green. Closes #225
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Closes #225
Summary
Problem
The storage/lib runtime tranche still had two path-dependent seams:
ConversationRepositorymore often than their semantics requiredpolylogue/storage/state_views.py, a grab-bag aggregate that obscured ownership and kept broad container-style plumbing in placeSolution
polylogue/protocols.py, includingConversationQueryRuntimeStoreand narrower CLI-facing output/stats/semantic surfacesActionEventArtifactStateaccessors and propagated that through query runtime helpersstate_views.pyintocursor_state.py,raw_state_models.py,artifact_views.py,archive_views.py, andrun_state.pyVerification
ruff check polylogue/storage/cursor_state.py polylogue/storage/raw_state_models.py polylogue/storage/artifact_views.py polylogue/storage/archive_views.py polylogue/storage/run_state.py polylogue/storage/state_views.py polylogue/cli/query_actions.pymypy polylogue/storage/cursor_state.py polylogue/storage/raw_state_models.py polylogue/storage/artifact_views.py polylogue/storage/archive_views.py polylogue/storage/run_state.py polylogue/storage/state_views.py polylogue/cli/query_actions.pypytest -q tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.pypytest -q tests/unit/storage/test_action_event_artifacts.py tests/unit/storage/test_fts5.py tests/unit/storage/test_embedding_stats.py tests/unit/storage/test_derived_status.pypytest -q tests/unit/cli/test_check.py tests/unit/cli/test_run.py tests/unit/cli/test_run_int.py tests/unit/cli/test_run_laws.py tests/unit/core/test_semantic_facts.py tests/unit/pipeline/test_ingest_batch.py tests/unit/pipeline/test_quarantine_fixtures.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_acquisition_encoding.py tests/unit/sources/test_decoders.py tests/unit/sources/test_drive_ops.py tests/unit/sources/test_source_laws.py tests/unit/storage/test_parse_tracking.py tests/integration/test_security.pydevtools verify