Repository navigation
refactor(storage): make source filters origin-native - #2820
Conversation
📝 WalkthroughWalkthroughThe pull request migrates session, archive, insight, search, raw-storage, CLI, and MCP filtering from ChangesOrigin filter migration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 6ec2ca4bf9
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 10
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (18)
polylogue/insights/tool_usage.py (1)
106-110: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
ToolUsageInsightpublic fields still useproviderterminology.
provider_coverage(line 106),providers_with_data(line 109), andproviders_without_data(line 110) are public fields onToolUsageInsight, which is returned bylist_tool_usage_insights. Per coding guidelines, public source-origin surfaces must useoriginvocabulary. If these are considered "internal provider metadata" exposed publicly, that exception should be documented. Otherwise, consider renaming toorigin_coverage,origins_with_data,origins_without_data.As per coding guidelines:
**/*.{py,sql}: Public source-origin surfaces must useorigin, not the olderprovidervocabulary; provider terminology remains restricted to wire boundaries and internal provider metadata.🤖 Prompt for 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. In `@polylogue/insights/tool_usage.py` around lines 106 - 110, Rename the public ToolUsageInsight fields provider_coverage, providers_with_data, and providers_without_data to origin_coverage, origins_with_data, and origins_without_data, and update list_tool_usage_insights plus all related references to use the new origin terminology. Preserve the existing values and behavior.Source: Coding guidelines
polylogue/insights/tag_rollups.py (1)
28-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
originparameter receives provider values; function name still usesproviderterminology.The parameter is named
origin(line 31) but line 63 treats it as a provider value:origin_from_provider(Provider.from_string(origin)).value. The function namesynthesize_provider_tag_rollupsand the caller variableprovider_rollups(inpolylogue/api/insights.py) also retainprovidervocabulary, while the function generatesorigin:<name>rollups.This is consistent with the transitional design but the naming is semantically misleading — callers may assume
originaccepts canonical origin values (e.g.,"chatgpt-export") when it actually expects provider tokens (e.g.,"chatgpt"). Consider renaming the function tosynthesize_origin_tag_rollupsand documenting that theoriginparameter accepts provider/source-name tokens during the transition.🤖 Prompt for 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. In `@polylogue/insights/tag_rollups.py` around lines 28 - 63, Rename synthesize_provider_tag_rollups to synthesize_origin_tag_rollups and update its callers, including the provider_rollups variable in the insights API, to use origin terminology. Document in the function’s parameter or docstring that origin currently accepts provider/source-name tokens and maps them to canonical origins, preserving the existing rollup behavior.tests/unit/api/test_session_analytics_facade.py (1)
74-83: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winStale assertion:
query.providershould bequery.origin.Line 79 was updated to call
poly.aggregate_sessions(group_by="workflow_shape", origin="claude-code"), but the assertion on line 83 still readsassert query.provider == "claude-code". Given this PR's migration removes theproviderfield from these query DTOs in favor oforigin(per the PR objective "No internal compatibility aliases were added"),query.providerwill likely raiseAttributeErrorrather than compare correctly, breaking this test.🐛 Proposed fix
await poly.aggregate_sessions(group_by="workflow_shape", origin="claude-code") assert fetch_mock.await_args is not None query = fetch_mock.await_args.args[0] - assert query.provider == "claude-code" + assert query.origin == "claude-code"🤖 Prompt for 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. In `@tests/unit/api/test_session_analytics_facade.py` around lines 74 - 83, Update test_aggregate_sessions_maps_provider_filter_through to assert query.origin equals "claude-code" instead of accessing the removed query.provider field, preserving the existing aggregate_sessions invocation and fetch_mock verification.polylogue/storage/sqlite/archive_tiers/archive.py (1)
4946-4980: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
group_by == "provider"sentinel wasn't renamed, sogroup_by="origin"raisesValueError.The
originfilter parameter was correctly renamed fromprovider, but the group-by dimension selector string literal was not: the method still defaultsgroup_by: str = "provider"and branches onif group_by == "provider":, raisingValueError("... must be one of: provider, day, week")otherwise. However, callers now passgroup_by="origin"— confirmed bytests/unit/api/test_facade_contracts.py:3622(ArchiveCoverageInsightQuery(group_by="origin", origin="codex-session")) and bypolylogue/api/archive.py's_ArchiveInsightExportOperations.list_archive_coverage_insights, which defaults togroup_by=str(getattr(query, "group_by", "origin")). Both the explicit test and the default (nogroup_bysupplied) export-bundle path will now raise instead of returning per-origin coverage rows.🐛 Proposed fix
def list_archive_coverage_insights( self, *, - group_by: str = "provider", + group_by: str = "origin", origin: str | None = None, since_ms: int | None = None, until_ms: int | None = None, limit: int | None = None, offset: int = 0, ) -> list[ArchiveCoverageInsight]: """Aggregate archive coverage from index tables.""" origin = _origin_value(origin) - if group_by == "provider": + if group_by == "origin": return self._provider_coverage_insights(origin=origin, limit=limit, offset=offset) if group_by == "day": ... - raise ValueError("archive coverage group_by must be one of: provider, day, week") + raise ValueError("archive coverage group_by must be one of: origin, day, week")🤖 Prompt for 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. In `@polylogue/storage/sqlite/archive_tiers/archive.py` around lines 4946 - 4980, Update list_archive_coverage_insights and its provider branch to use the renamed group-by sentinel "origin" instead of "provider", including the default value and ValueError message. Preserve the existing day/week handling and pass the origin filter unchanged to _provider_coverage_insights.polylogue/api/archive.py (2)
1422-1432: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winCoverage insight
group_by="origin"will raiseValueErrorat the storage layer.This adapter defaults/forwards
group_by=str(getattr(query, "group_by", "origin")), andtests/unit/api/test_facade_contracts.pyexplicitly callsArchiveCoverageInsightQuery(group_by="origin", origin="codex-session"). ButArchiveStore.list_archive_coverage_insights(polylogue/storage/sqlite/archive_tiers/archive.py) still branches onif group_by == "provider":and raisesValueError("archive coverage group_by must be one of: provider, day, week")for anything else. Passinggroup_by="origin"(the new default here) falls through to thatValueError, breaking both the explicit test and the implicit default path for export-bundle coverage insights.See the companion comment in
polylogue/storage/sqlite/archive_tiers/archive.pyfor the root-cause fix (rename thegroup_bysentinel from"provider"to"origin").Also applies to: 4947-4980
🤖 Prompt for 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. In `@polylogue/api/archive.py` around lines 1422 - 1432, Update the storage implementation `ArchiveStore.list_archive_coverage_insights` to recognize `group_by="origin"` instead of the obsolete `"provider"` sentinel, while preserving the existing provider-based grouping behavior and validation for `"day"` and `"week"`. Ensure the adapter method `list_archive_coverage_insights` continues forwarding its `"origin"` default unchanged.
4517-4571: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
neighbor_candidates/neighbor_candidate_payloadsstill exposeprovider=, breaking the origin-vocabulary migration.Every other session-filtering method in this file (
list,list_summaries,count,search,search_summaries,list_session_profile_insights, etc.) was renamed to acceptorigin/origins, butneighbor_candidates(andneighbor_candidate_payloads) still take a publicprovider: str | None = Noneparameter, only mapping it internally toNeighborDiscoveryRequest.origin. This leaves an inconsistent public API surface for a PR whose stated goal is a breaking rename toorigin=/origins=at every public source-filter site.tests/unit/api/test_facade_contracts.py:3181-3185confirms callers still must passprovider=.Based on learnings, coding guidelines state: "Public source-origin surfaces must use `origin`, not the older `provider` vocabulary; provider terminology remains restricted to wire boundaries and internal provider metadata."♻️ Proposed rename
async def neighbor_candidates( self, *, session_id: str | None = None, query: str | None = None, - provider: str | None = None, + origin: str | None = None, limit: int = 10, window_hours: int = 24, ) -> list[SessionNeighborCandidate]: ... return await discover_neighbor_candidates( cast("SessionQueryRuntimeStore", _ArchiveNeighborRuntime(archive)), NeighborDiscoveryRequest( session_id=session_id, query=query, - origin=provider, + origin=origin, limit=limit, window_hours=window_hours, ), )Apply the analogous rename to
neighbor_candidate_payloads.🤖 Prompt for 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. In `@polylogue/api/archive.py` around lines 4517 - 4571, Rename the public provider parameter to origin in both neighbor_candidates and neighbor_candidate_payloads, and pass origin through to NeighborDiscoveryRequest.origin. Remove the provider keyword from these facade method signatures and calls while preserving all existing candidate discovery behavior.Source: Coding guidelines
polylogue/archive/session/neighbor_candidates.py (1)
98-131: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse
Origincanonicalization for neighbor filtering
NeighborDiscoveryRequest.originis still normalized withProvider.from_string, so canonical origin tokens likecodex-sessioncollapse tounknownand never match thes.originfilter used by the ranked search query. Rename these helpers toOrigin-based normalization and pass origin tokens through unchanged.🤖 Prompt for 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. In `@polylogue/archive/session/neighbor_candidates.py` around lines 98 - 131, Update _canonical_provider and _provider_list to use Origin canonicalization instead of Provider.from_string, renaming them to reflect Origin-based normalization. Preserve valid canonical origin tokens such as codex-session unchanged so the resulting filter matches s.origin in the ranked search query.Source: Coding guidelines
tests/unit/storage/test_raw.py (1)
288-308: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStale "provider" naming in test names/docstrings.
test_iter_raw_sessions_by_providerandtest_raw_provider_filters_prefer_payload_provider_when_present(and their docstrings, e.g. "Filter iteration by provider name.") still use provider terminology even though the assertions now filter byorigin=. Assertions themselves are correct; this is purely a naming/documentation nit.Also applies to: 387-406
🤖 Prompt for 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. In `@tests/unit/storage/test_raw.py` around lines 288 - 308, Rename the affected tests and their docstrings from provider terminology to origin terminology, including test_iter_raw_sessions_by_provider and test_raw_provider_filters_prefer_payload_provider_when_present. Keep the existing origin= arguments and assertions unchanged.polylogue/api/insights.py (1)
311-348: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStale "provider" naming next to the new origin comment/keyword.
synthesize_provider_tag_rollupsand the localprovider_rollupsvariable still carry the older provider vocabulary even though this same hunk switches toorigin=request.originand rewrites the surrounding comment to describe origin semantics. As per coding guidelines, "Public source-origin surfaces must useorigin, not the olderprovidervocabulary; provider terminology remains restricted to wire boundaries and internal provider metadata." Consider renaming the local variable (and, at its definition site, the helper function) for consistency.♻️ Local rename
- provider_rollups = synthesize_provider_tag_rollups( + origin_rollups = synthesize_provider_tag_rollups( archive, origin=request.origin, query=request.query, since_ms=since_ms, until_ms=until_ms, materialized_at=datetime.now(UTC).isoformat(), ) rollups = sorted( - [*materialized, *provider_rollups], + [*materialized, *origin_rollups],🤖 Prompt for 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. In `@polylogue/api/insights.py` around lines 311 - 348, Rename synthesize_provider_tag_rollups and the local provider_rollups variable in list_session_tag_rollup_insights to use origin terminology consistently, updating all references and the helper’s definition site while preserving behavior.Source: Coding guidelines
polylogue/storage/sqlite/queries/filter_builder.py (1)
75-84: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
sourceandoriginboth emit identicalorigin = ?clauses.When both
sourceandoriginare provided with different values, the WHERE clause becomesorigin = ? AND origin = ?with different params — a contradiction that returns zero rows. This is pre-existing (thesourceparameter was already there), but the migration tooriginterminology makes the redundancy more visible. Consider documenting thatsourceandoriginare mutually exclusive, or deprecatingsourcein favor oforigin.🤖 Prompt for 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. In `@polylogue/storage/sqlite/queries/filter_builder.py` around lines 75 - 84, Document that the source and origin filters are mutually exclusive in the filter-building flow around the origin clause, and ensure callers do not provide both with different values; retain the existing origin filtering behavior while directing users toward origin instead of source.tests/unit/storage/test_repository_insight_runtime.py (7)
341-341: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winMock assertion not migrated: expects
provider=but production passesorigin=.The test calls
repo.get_raw_session_count("chatgpt")at Line 305, and the production code forwardsorigin=origintoraw_queries.get_raw_session_count(conn, origin=origin). The mock assertion should expectorigin="chatgpt", notprovider="chatgpt".🐛 Proposed fix
- mock_count.assert_awaited_once_with(conn, provider="chatgpt") + mock_count.assert_awaited_once_with(conn, origin="chatgpt")🤖 Prompt for 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. In `@tests/unit/storage/test_repository_insight_runtime.py` at line 341, Update the mock assertion for repo.get_raw_session_count in the relevant test to expect origin="chatgpt" instead of provider="chatgpt", matching the production call to raw_queries.get_raw_session_count.
69-70: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winTest assertion not migrated: checks
.providerinstead of.originwith wrong value.The test calls
repo.list_session_profiles(origin="claude-code-session", ...)at Line 48, but the assertion at Line 70 checkslist_query.provider == "claude-code". The production code constructsSessionProfileListQuery(origin=origin), so the assertion should checklist_query.origin == "claude-code-session". Both the attribute name and expected value are wrong.🐛 Proposed fix
- assert list_query.provider == "claude-code" + assert list_query.origin == "claude-code-session"🤖 Prompt for 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. In `@tests/unit/storage/test_repository_insight_runtime.py` around lines 69 - 70, Update the assertion for the captured query in the session-profile listing test to validate list_query.origin against the "claude-code-session" argument passed to repo.list_session_profiles, replacing the incorrect provider attribute and value.
379-379: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winMock assertion not migrated: expects
provider=but production passesorigin=.The test calls
repo.iter_raw_sessions(origin="chatgpt", limit=2)at Line 364, and the production code forwardsorigin=origintoraw_queries.iter_raw_sessions(conn, origin=origin, limit=limit). The mock assertion should expectorigin="chatgpt", notprovider="chatgpt".🐛 Proposed fix
- mock_iter_raw.assert_called_once_with(conn, provider="chatgpt", limit=2) + mock_iter_raw.assert_called_once_with(conn, origin="chatgpt", limit=2)🤖 Prompt for 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. In `@tests/unit/storage/test_repository_insight_runtime.py` at line 379, Update the mock_iter_raw assertion in the iter_raw_sessions test to expect origin="chatgpt" instead of provider="chatgpt", matching the production call’s keyword forwarded by repo.iter_raw_sessions.
187-188: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winTest assertion not migrated: checks
.providerinstead of.originwith wrong value.The test calls
repo.list_session_tag_rollup_records(origin="claude-code-session", ...)at Line 181, but the assertion at Line 188 checkstag_query.provider == "claude-code". Should betag_query.origin == "claude-code-session".🐛 Proposed fix
- assert tag_query.provider == "claude-code" + assert tag_query.origin == "claude-code-session"🤖 Prompt for 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. In `@tests/unit/storage/test_repository_insight_runtime.py` around lines 187 - 188, Update the assertion on the query captured from _list_session_tag_rollup_rows_query in the repository runtime test to check tag_query.origin equals "claude-code-session", matching the origin passed to list_session_tag_rollup_records, instead of checking provider.
159-161: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winTest assertion not migrated: checks
.providerinstead of.originwith wrong value.The test calls
repo.list_session_work_events(origin="claude-code-session", ...)at Line 132, but the assertion at Line 161 checkstimeline_query.provider == "claude-code". Should betimeline_query.origin == "claude-code-session".🐛 Proposed fix
- assert timeline_query.provider == "claude-code" + assert timeline_query.origin == "claude-code-session"🤖 Prompt for 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. In `@tests/unit/storage/test_repository_insight_runtime.py` around lines 159 - 161, Update the assertion for the captured query in the list_session_work_events test to check timeline_query.origin equals "claude-code-session" instead of checking timeline_query.provider and the outdated value; leave the session_id assertion unchanged.
331-337: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winMock assertions not migrated: expect
provider=but production passesorigin=.The test calls
repo.reset_parse_status(origin="chatgpt", ...)andrepo.reset_validation_status(origin="chatgpt", ...)at Lines 300-301, but the mock assertions at Lines 331 and 332-337 expectprovider="chatgpt". The production code inrepository_raw.pyforwardsorigin=origintoraw_queries.reset_parse_status/reset_validation_status, so the mocks are called withorigin=, notprovider=.🐛 Proposed fix
- mock_reset_parse.assert_awaited_once_with(conn, provider="chatgpt", source_names=["inbox"], transaction_depth=7) + mock_reset_parse.assert_awaited_once_with(conn, origin="chatgpt", source_names=["inbox"], transaction_depth=7) mock_reset_validation.assert_awaited_once_with( conn, - provider="chatgpt", + origin="chatgpt", source_names=["inbox"], transaction_depth=7, )🤖 Prompt for 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. In `@tests/unit/storage/test_repository_insight_runtime.py` around lines 331 - 337, Update the mock assertions for reset_parse_status and reset_validation_status to expect origin="chatgpt" instead of provider="chatgpt", preserving the existing conn, source_names, and transaction_depth arguments.
69-70: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winSwitch these assertions to
.origin
SessionProfileListQuery,SessionTimelineListQuery, andSessionTagRollupListQueryonly exposeoriginnow, so the current.providerassertions will fail withAttributeErrorat the listed sites.🤖 Prompt for 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. In `@tests/unit/storage/test_repository_insight_runtime.py` around lines 69 - 70, Update the affected assertions in the session profile, timeline, and tag rollup query tests to inspect the query’s `.origin` attribute instead of `.provider`. Apply this consistently to the relevant assertions around `_list_session_profiles_query` and the corresponding `SessionTimelineListQuery` and `SessionTagRollupListQuery` calls, preserving the expected value.tests/benchmarks/test_reader_api.py (1)
56-64: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUpdate stale function name and docstring to reference
origin.The call site correctly uses
origin="claude-code", but the function nametest_bench_reader_list_with_providerand docstring "Benchmark listing sessions filtered by provider" still reference the oldprovidervocabulary.♻️ Proposed rename
-def test_bench_reader_list_with_provider( +def test_bench_reader_list_with_origin( benchmark: BenchmarkFixture, bench_db_5k: Path, ) -> None: - """Benchmark listing sessions filtered by provider.""" + """Benchmark listing sessions filtered by origin.""" benchmark_store_call( benchmark, bench_db_5k, lambda store: store.repository.list_summaries(origin="claude-code"), )🤖 Prompt for 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. In `@tests/benchmarks/test_reader_api.py` around lines 56 - 64, Rename test_bench_reader_list_with_provider to use origin terminology and update its docstring to describe sessions filtered by origin, while preserving the existing benchmark call and origin="claude-code" argument.
🤖 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 `@devtools/synthetic_benchmark_runtime.py`:
- Around line 191-195: Rename the metrics assigned after the list_sessions call
from filter_provider_wall_s and filter_provider_count to filter_origin_wall_s
and filter_origin_count to match the migrated origin terminology, unless these
keys are an intentional stable downstream contract; in that case, document their
stability instead.
In `@polylogue/archive/query/fields.py`:
- Around line 893-922: Keep provider_scope_for_plan returning canonical
Origin.value strings rather than converting them through provider_from_origin,
so SessionRecordQuery.origin/origins and SqlPushdownParams use values matching
sessions.origin. Update the adjacent comment to describe the canonical
origin-column behavior, while preserving the existing single-value and
grouped-value branching.
In `@polylogue/archive/query/retrieval_candidates.py`:
- Around line 179-196: The comment above
`_origins_as_provider_tokens(plan.origins)` incorrectly says origin tokens are
projected back to origin tokens; update it to state that the plan’s origin
tokens are projected to provider tokens for this legacy search leg, without
changing the surrounding code or behavior.
In `@polylogue/cli/commands/insights.py`:
- Around line 120-122: Remove the redundant conditional expression in the
accepted_root_keys construction, and check each key from _ROOT_FILTER_KEYS
directly against accepted_query_fields. Preserve the existing tuple filtering
behavior now that _ROOT_FILTER_KEYS already uses origin.
In `@polylogue/insights/readiness.py`:
- Around line 348-351: Rename _provider_filter_origin to a name reflecting
origin normalization for SQL filtering, such as _normalize_origin_filter, and
update every call site including the usage near line 366. Preserve the existing
handling of empty origins and _origin_value normalization.
In `@polylogue/storage/sqlite/queries/filter_builder.py`:
- Around line 32-33: Update _origin_value to parse origins through
Origin.from_string(value) instead of directly constructing Origin(value), so
empty or invalid strings resolve to the existing unknown-export fallback rather
than raising. Preserve returning the resolved enum value for valid origins.
In `@tests/unit/insights/test_cost_rollup_summary_path.py`:
- Line 104: Update the CostRollupInsightQuery construction in the test to use
the canonical origin token “claude-code-session” instead of “claude-code”,
matching the value produced by SessionBuilder.provider and accepted by
list_cost_rollup_insights.
In `@tests/unit/insights/test_tag_rollups.py`:
- Around line 9-10: Consolidate the redundant tests around
synthesize_provider_tag_rollups into one test that verifies filtering with
origin="aistudio-drive". Rename the test and update its docstring to describe
only the origin-filtering behavior, removing references to Provider.GEMINI,
Provider.DRIVE, origin_from_provider, and comparisons of identical calls; leave
provider-to-origin mapping coverage to origin_from_provider tests.
In `@tests/unit/storage/test_parse_tracking.py`:
- Line 363: Update the mock assertions for mock_reset_parse and
mock_reset_validation to expect origin="chatgpt" instead of provider="chatgpt",
matching RepositoryRawMixin’s origin= arguments forwarded to
raw_queries.reset_parse_status and reset_validation_status.
In `@tests/unit/storage/test_schema_safety.py`:
- Line 384: Update the test around _build_session_filters so it does not pass an
empty origin that causes Origin(value) to raise before reaching the SQL path;
use a valid origin token for this test, unless _origin_value is explicitly
intended to support empty input, in which case handle that input before
constructing Origin.
---
Outside diff comments:
In `@polylogue/api/archive.py`:
- Around line 1422-1432: Update the storage implementation
`ArchiveStore.list_archive_coverage_insights` to recognize `group_by="origin"`
instead of the obsolete `"provider"` sentinel, while preserving the existing
provider-based grouping behavior and validation for `"day"` and `"week"`. Ensure
the adapter method `list_archive_coverage_insights` continues forwarding its
`"origin"` default unchanged.
- Around line 4517-4571: Rename the public provider parameter to origin in both
neighbor_candidates and neighbor_candidate_payloads, and pass origin through to
NeighborDiscoveryRequest.origin. Remove the provider keyword from these facade
method signatures and calls while preserving all existing candidate discovery
behavior.
In `@polylogue/api/insights.py`:
- Around line 311-348: Rename synthesize_provider_tag_rollups and the local
provider_rollups variable in list_session_tag_rollup_insights to use origin
terminology consistently, updating all references and the helper’s definition
site while preserving behavior.
In `@polylogue/archive/session/neighbor_candidates.py`:
- Around line 98-131: Update _canonical_provider and _provider_list to use
Origin canonicalization instead of Provider.from_string, renaming them to
reflect Origin-based normalization. Preserve valid canonical origin tokens such
as codex-session unchanged so the resulting filter matches s.origin in the
ranked search query.
In `@polylogue/insights/tag_rollups.py`:
- Around line 28-63: Rename synthesize_provider_tag_rollups to
synthesize_origin_tag_rollups and update its callers, including the
provider_rollups variable in the insights API, to use origin terminology.
Document in the function’s parameter or docstring that origin currently accepts
provider/source-name tokens and maps them to canonical origins, preserving the
existing rollup behavior.
In `@polylogue/insights/tool_usage.py`:
- Around line 106-110: Rename the public ToolUsageInsight fields
provider_coverage, providers_with_data, and providers_without_data to
origin_coverage, origins_with_data, and origins_without_data, and update
list_tool_usage_insights plus all related references to use the new origin
terminology. Preserve the existing values and behavior.
In `@polylogue/storage/sqlite/archive_tiers/archive.py`:
- Around line 4946-4980: Update list_archive_coverage_insights and its provider
branch to use the renamed group-by sentinel "origin" instead of "provider",
including the default value and ValueError message. Preserve the existing
day/week handling and pass the origin filter unchanged to
_provider_coverage_insights.
In `@polylogue/storage/sqlite/queries/filter_builder.py`:
- Around line 75-84: Document that the source and origin filters are mutually
exclusive in the filter-building flow around the origin clause, and ensure
callers do not provide both with different values; retain the existing origin
filtering behavior while directing users toward origin instead of source.
In `@tests/benchmarks/test_reader_api.py`:
- Around line 56-64: Rename test_bench_reader_list_with_provider to use origin
terminology and update its docstring to describe sessions filtered by origin,
while preserving the existing benchmark call and origin="claude-code" argument.
In `@tests/unit/api/test_session_analytics_facade.py`:
- Around line 74-83: Update test_aggregate_sessions_maps_provider_filter_through
to assert query.origin equals "claude-code" instead of accessing the removed
query.provider field, preserving the existing aggregate_sessions invocation and
fetch_mock verification.
In `@tests/unit/storage/test_raw.py`:
- Around line 288-308: Rename the affected tests and their docstrings from
provider terminology to origin terminology, including
test_iter_raw_sessions_by_provider and
test_raw_provider_filters_prefer_payload_provider_when_present. Keep the
existing origin= arguments and assertions unchanged.
In `@tests/unit/storage/test_repository_insight_runtime.py`:
- Line 341: Update the mock assertion for repo.get_raw_session_count in the
relevant test to expect origin="chatgpt" instead of provider="chatgpt", matching
the production call to raw_queries.get_raw_session_count.
- Around line 69-70: Update the assertion for the captured query in the
session-profile listing test to validate list_query.origin against the
"claude-code-session" argument passed to repo.list_session_profiles, replacing
the incorrect provider attribute and value.
- Line 379: Update the mock_iter_raw assertion in the iter_raw_sessions test to
expect origin="chatgpt" instead of provider="chatgpt", matching the production
call’s keyword forwarded by repo.iter_raw_sessions.
- Around line 187-188: Update the assertion on the query captured from
_list_session_tag_rollup_rows_query in the repository runtime test to check
tag_query.origin equals "claude-code-session", matching the origin passed to
list_session_tag_rollup_records, instead of checking provider.
- Around line 159-161: Update the assertion for the captured query in the
list_session_work_events test to check timeline_query.origin equals
"claude-code-session" instead of checking timeline_query.provider and the
outdated value; leave the session_id assertion unchanged.
- Around line 331-337: Update the mock assertions for reset_parse_status and
reset_validation_status to expect origin="chatgpt" instead of
provider="chatgpt", preserving the existing conn, source_names, and
transaction_depth arguments.
- Around line 69-70: Update the affected assertions in the session profile,
timeline, and tag rollup query tests to inspect the query’s `.origin` attribute
instead of `.provider`. Apply this consistently to the relevant assertions
around `_list_session_profiles_query` and the corresponding
`SessionTimelineListQuery` and `SessionTagRollupListQuery` calls, preserving the
expected value.
🪄 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: 2929f4b7-1d8a-4c10-a501-8aae38a89a48
📒 Files selected for processing (64)
devtools/synthetic_benchmark_runtime.pypolylogue/api/archive.pypolylogue/api/insights.pypolylogue/archive/query/fields.pypolylogue/archive/query/retrieval_candidates.pypolylogue/archive/query/retrieval_search.pypolylogue/archive/session/neighbor_candidates.pypolylogue/cli/commands/diagnostics.pypolylogue/cli/commands/insights.pypolylogue/insights/archive.pypolylogue/insights/export_bundles.pypolylogue/insights/readiness.pypolylogue/insights/tag_rollups.pypolylogue/insights/tool_usage.pypolylogue/mcp/server_insight_tools.pypolylogue/protocols.pypolylogue/storage/query_models.pypolylogue/storage/repository/archive/queries.pypolylogue/storage/repository/archive/search.pypolylogue/storage/repository/insight/profile_reads.pypolylogue/storage/repository/insight/summary_reads.pypolylogue/storage/repository/insight/timeline_reads.pypolylogue/storage/repository/raw/repository_raw.pypolylogue/storage/sqlite/archive_tiers/archive.pypolylogue/storage/sqlite/async_sqlite_archive.pypolylogue/storage/sqlite/async_sqlite_raw.pypolylogue/storage/sqlite/queries/attachment_records.pypolylogue/storage/sqlite/queries/filter_builder.pypolylogue/storage/sqlite/queries/raw_reads.pypolylogue/storage/sqlite/queries/raw_state.pypolylogue/storage/sqlite/queries/session_insight_profile_reads.pypolylogue/storage/sqlite/queries/session_insight_summary_queries.pypolylogue/storage/sqlite/queries/session_insight_timeline_reads.pypolylogue/storage/sqlite/queries/session_latency_profile_reads.pypolylogue/storage/sqlite/queries/sessions_reads.pypolylogue/storage/sqlite/queries/sessions_search.pypolylogue/storage/sqlite/queries/tool_usage.pypolylogue/storage/sqlite/query_store.pypolylogue/storage/sqlite/query_store_archive.pypolylogue/storage/sqlite/query_store_insight_profiles.pypolylogue/storage/sqlite/query_store_insight_timelines.pytests/benchmarks/test_reader_api.pytests/benchmarks/test_search_filters.pytests/benchmarks/test_storage.pytests/unit/api/test_facade_contracts.pytests/unit/api/test_session_analytics_facade.pytests/unit/cli/test_diagnostics.pytests/unit/cli/test_insights.pytests/unit/core/test_cwd_prefix_filter.pytests/unit/core/test_facade_api.pytests/unit/core/test_insight_export_bundles.pytests/unit/core/test_neighbor_candidates.pytests/unit/core/test_query_fields.pytests/unit/core/test_repo_filter.pytests/unit/insights/test_cost_rollup_summary_path.pytests/unit/insights/test_tag_rollups.pytests/unit/insights/test_tool_usage.pytests/unit/storage/test_archive_search_contracts.pytests/unit/storage/test_parse_tracking.pytests/unit/storage/test_query_security.pytests/unit/storage/test_raw.pytests/unit/storage/test_repository_insight_runtime.pytests/unit/storage/test_schema_safety.pytests/unit/storage/test_store_ops.py
| def _origin_value(value: str) -> str: | ||
| return origin_from_provider(Provider.from_string(value)).value | ||
| return Origin(value).value |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check PolylogueStrEnum definition for custom __new__ behavior
ast-grep outline polylogue/core/enums.py --match 'PolylogueStrEnum' --view expanded
# Then inspect the class definition
rg -n -A 20 'class PolylogueStrEnum' polylogue/core/enums.pyRepository: Sinity/polylogue
Length of output: 8273
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== polylogue/core/enums.py excerpts =="
sed -n '1,90p' polylogue/core/enums.py
echo
echo "== polylogue/storage/sqlite/queries/filter_builder.py excerpts =="
sed -n '1,120p' polylogue/storage/sqlite/queries/filter_builder.py
echo
echo "== tests/unit/storage/test_schema_safety.py excerpt =="
sed -n '350,420p' tests/unit/storage/test_schema_safety.py
echo
echo "== runtime probe =="
python3 - <<'PY'
from polylogue.core.enums import Origin
for value in ["", "unknown-export", "claude-code-session"]:
for expr in ["Origin(value)", "Origin.from_string(value)"]:
try:
result = eval(expr, {"Origin": Origin, "value": value})
print(value!r, expr, "=>", result, repr(result.value))
except Exception as e:
print(value!r, expr, "=>", type(e).__name__, e)
PYRepository: Sinity/polylogue
Length of output: 11726
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from polylogue.core.enums import Origin
for value in ["", "unknown-export", "claude-code-session"]:
for expr, fn in [
("Origin(value)", lambda v: Origin(v)),
("Origin.from_string(value)", lambda v: Origin.from_string(v)),
]:
try:
result = fn(value)
print(repr(value), expr, "=>", result, repr(result.value))
except Exception as e:
print(repr(value), expr, "=>", type(e).__name__, e)
PYRepository: Sinity/polylogue
Length of output: 592
Empty origin still raises in _origin_value
Origin(value).value rejects "", so _build_session_filters(origin="") will throw before producing SQL. Origin.from_string(value).value already falls back to unknown-export; use that here if empty/invalid origin strings are allowed.
🤖 Prompt for 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.
In `@polylogue/storage/sqlite/queries/filter_builder.py` around lines 32 - 33,
Update _origin_value to parse origins through Origin.from_string(value) instead
of directly constructing Origin(value), so empty or invalid strings resolve to
the existing unknown-export fallback rather than raising. Preserve returning the
resolved enum value for valid origins.
| from polylogue.storage.sqlite.queries.filter_builder import _build_session_filters | ||
|
|
||
| where_clause, params = _build_session_filters(provider="") | ||
| where_clause, params = _build_session_filters(origin="") |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify PolylogueStrEnum behavior with empty string
rg -n -A 30 'class PolylogueStrEnum' polylogue/core/enums.py
# Check if Origin has custom __new__ or __missing__
rg -n '__new__\|__missing__\|_missing_' polylogue/core/enums.pyRepository: Sinity/polylogue
Length of output: 1334
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the enum and filter builder implementations
ast-grep outline polylogue/core/enums.py --view expanded
ast-grep outline polylogue/storage/sqlite/queries/filter_builder.py --view expanded
ast-grep outline tests/unit/storage/test_schema_safety.py --view expanded
# Show the relevant line ranges
sed -n '1,120p' polylogue/core/enums.py
printf '\n--- filter_builder ---\n'
sed -n '1,140p' polylogue/storage/sqlite/queries/filter_builder.py
printf '\n--- test ---\n'
sed -n '360,410p' tests/unit/storage/test_schema_safety.py
# Sanity-check stdlib StrEnum behavior for empty-string construction
python3 - <<'PY'
from enum import StrEnum
class Origin(StrEnum):
A = "a"
for value in ["", "a"]:
try:
print(value, "=>", Origin(value))
except Exception as e:
print(value, "=>", type(e).__name__, e)
PYRepository: Sinity/polylogue
Length of output: 22498
Handle empty origin tokens before calling Origin(value) _build_session_filters(origin="") hits Origin("") and raises ValueError immediately, so this test never reaches the SQL path; either use a real origin token here or make _origin_value accept empty input if that’s intended.
🤖 Prompt for 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.
In `@tests/unit/storage/test_schema_safety.py` at line 384, Update the test around
_build_session_filters so it does not pass an empty origin that causes
Origin(value) to raise before reaching the SQL path; use a valid origin token
for this test, unless _origin_value is explicitly intended to support empty
input, in which case handle that input before constructing Origin.
Merge-conductor verification: found a real regression, holding this PRRan the focused test set this PR's own description implies as scope (23 files across API/CLI/core/insights/storage/benchmarks). Result: 56 failed, 588 passed (full run: Root cause ( def origin_filter_value(token: str) -> str:
"""Translate a provider-wire token into its canonical ``origin`` value."""
return origin_from_provider(Provider.from_string(token)).valueto def origin_filter_value(token: str) -> str:
"""Validate and return a canonical ``origin`` value."""
return Origin(token).valueThis is strictly less permissive: it now raises Per the project's own provider/origin vocabulary doc, Holding this PR unmerged pending a fix — either restore provider-token tolerance in |
|
Follow-up commit 576d53a addresses the held regression and the remaining real origin callers.
Verification:
Anti-vacuity: the raw test invokes real SQLite raw-session reads/counts using a Provider-wire token; removing the fallback makes it raise. The tool-usage test writes actual tool blocks through AC matrix: |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
polylogue/storage/sqlite/archive_tiers/archive.py (2)
4512-4521: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMissing null-fallback for
source_name— inconsistent with sibling functions.
list_tool_call_count_rows,list_tool_observed_event_count_rows, and_list_tool_action_detail_evidence_count_rowsall set"source_name": str(row["origin"])without theor "unknown-export"fallback that the adjacent"origin"field (and the sibling functions_tool_usage_rowsat line 4901,_tool_usage_provider_coverage_rowsat line 4934, and the asyncget_tool_usage_rowsinqueries/tool_usage.py) all use. Ifrow["origin"]is everNULL/empty,source_namewould render the literal string"None"instead of"unknown-export".Risk is low if
sessions.originis aNOT NULLcolumn, but the inconsistency across otherwise-identical mapping blocks in the same migration is worth closing.🐛 Proposed fix (apply to all three locations)
- "source_name": str(row["origin"]), + "source_name": str(row["origin"] or "unknown-export"),Also applies to: 4596-4606, 4824-4838
🤖 Prompt for 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. In `@polylogue/storage/sqlite/archive_tiers/archive.py` around lines 4512 - 4521, Update the result-mapping comprehensions in list_tool_call_count_rows, list_tool_observed_event_count_rows, and _list_tool_action_detail_evidence_count_rows so source_name uses the same "unknown-export" null/empty fallback as origin. Preserve the existing string conversion and all other mapped fields.
4704-4737: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winUse origin-native
source_namehere
list_tool_action_evidence_count_rowsshould match_list_tool_action_detail_evidence_count_rowsand setsource_namefromrow["origin"], not_provider_for_origin(...). The current row mixes origin and provider vocabularies on a public surface.🤖 Prompt for 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. In `@polylogue/storage/sqlite/archive_tiers/archive.py` around lines 4704 - 4737, Update list_tool_action_evidence_count_rows to derive source_name directly from row["origin"], matching _list_tool_action_detail_evidence_count_rows, and remove the _provider_for_origin(...).value conversion so the public row consistently uses origin-native vocabulary.Source: Coding guidelines
polylogue/api/archive.py (1)
1747-1755: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winNormalize origin filters with
Origin.from_string(...)
polylogue/api/archive.py:1747-1755still uses the strict enum constructor. This public facade receives raw--origin/ query values in a few paths, so a typo or legacy provider token can raiseValueErrorinlist,count,search_summary_hits, and_query_kwargs. UseOrigin.from_string(...)for bothoriginandoriginshere to match the rest of the origin normalization flow.🤖 Prompt for 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. In `@polylogue/api/archive.py` around lines 1747 - 1755, Update _origin_filters to normalize both origin and each value in origins with Origin.from_string(...) instead of the strict Origin constructor, preserving the existing None handling and tuple return shape so raw or legacy provider tokens do not raise ValueError.
🤖 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 `@tests/unit/core/test_insight_registry_runtime.py`:
- Around line 29-31: Update the archive coverage tests to use origin
consistently instead of provider in the sync and async dispatch stubs and all
fetch_insights*() calls. Keep the existing fixture values and ensure every query
argument matches the model’s origin field.
---
Outside diff comments:
In `@polylogue/api/archive.py`:
- Around line 1747-1755: Update _origin_filters to normalize both origin and
each value in origins with Origin.from_string(...) instead of the strict Origin
constructor, preserving the existing None handling and tuple return shape so raw
or legacy provider tokens do not raise ValueError.
In `@polylogue/storage/sqlite/archive_tiers/archive.py`:
- Around line 4512-4521: Update the result-mapping comprehensions in
list_tool_call_count_rows, list_tool_observed_event_count_rows, and
_list_tool_action_detail_evidence_count_rows so source_name uses the same
"unknown-export" null/empty fallback as origin. Preserve the existing string
conversion and all other mapped fields.
- Around line 4704-4737: Update list_tool_action_evidence_count_rows to derive
source_name directly from row["origin"], matching
_list_tool_action_detail_evidence_count_rows, and remove the
_provider_for_origin(...).value conversion so the public row consistently uses
origin-native vocabulary.
🪄 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: ec5c52c6-3c6c-4f3b-a8e7-281d26ffbbaa
📒 Files selected for processing (32)
polylogue/api/archive.pypolylogue/api/insights.pypolylogue/api/sync/sessions.pypolylogue/archive/query/fields.pypolylogue/archive/session/neighbor_candidates.pypolylogue/cli/read_views/neighbors.pypolylogue/insights/registry.pypolylogue/insights/rigor.pypolylogue/insights/tag_rollups.pypolylogue/insights/tool_usage.pypolylogue/mcp/insight_tool_contracts.pypolylogue/mcp/server_insight_tools.pypolylogue/mcp/server_tools.pypolylogue/protocols.pypolylogue/storage/repository/archive/queries.pypolylogue/storage/sqlite/archive_tiers/archive.pypolylogue/storage/sqlite/async_sqlite_archive.pypolylogue/storage/sqlite/queries/raw_state.pypolylogue/storage/sqlite/queries/stats.pypolylogue/storage/sqlite/queries/tool_usage.pytests/unit/api/test_facade_contracts.pytests/unit/api/test_session_analytics_facade.pytests/unit/cli/test_analytics.pytests/unit/cli/test_insights.pytests/unit/core/test_insight_registry_runtime.pytests/unit/core/test_neighbor_candidates.pytests/unit/core/test_provider_origin_dedup.pytests/unit/insights/test_tag_rollups.pytests/unit/insights/test_tool_usage.pytests/unit/mcp/test_tool_contracts.pytests/unit/storage/test_archive_tiers_archive.pytests/unit/storage/test_repository_insight_runtime.py
Problem: SQL query surfaces accepted provider-wire tokens and converted them back to origins before issuing origin-column filters. What changed: rename the typed query DTO and SQLite filter keywords to origin/origins and validate canonical Origin values directly. Raw parsing and validation provenance retain their Provider wire types. Ref polylogue-9e5.8.5
Problem: repository mixins still exposed provider-named source filters after the SQLite layer accepted canonical origins. What changed: rename repository query and search keywords to origin/origins and forward canonical origin values without compatibility aliases. Ref polylogue-9e5.8.8
Problem: protocol and API query surfaces retained provider-named filter keywords and translated their values before reaching origin-native storage. What changed: make the public Python contract origin/origins, update its request DTOs and direct runtime callers, and validate canonical origin values at the API boundary. Raw parser provenance remains Provider-typed. Compatibility: Python filter keyword names changed before 1.0. Ref polylogue-9e5.8.6
Update affected tests and benchmark fixtures to use the renamed canonical origin/origins filter keywords. Ref polylogue-9e5.8.5 Ref polylogue-9e5.8.8 Ref polylogue-9e5.8.6
Problem: raw-state filtering rejected provider-wire tokens, while several\nquery routes still translated canonical origins back to provider values.\n\nWhat changed: normalize only raw-wire filters through the Provider mapping;\nkeep SQL, DTO, sync API, MCP, coverage, and tool-usage routes on canonical\norigin tokens.\n\nCompatibility: Python keyword renames remain breaking before 1.0; CLI aliases\nare the only supported compatibility layer.\n\nRef polylogue-9e5.8.5\nRef polylogue-9e5.8.8\nRef polylogue-9e5.8.6
Ref polylogue-9e5.8.5
ac1541d to
de690f8
Compare
Problem: the origin/provider seam regressions caught in #2820 review had no mutation-killing coverage — the only real-SQL search test seeded one origin, so a dropped or token-mismatched filter still passed; and the facade tool-usage contract still queried with a provider token, which the fail-closed Origin validation now rejects. What changed: a two-origin FTS regression asserts an origin filter selects exactly its origin (and unfiltered returns both) against a real seeded index.db; the tool-usage facade contract now queries and asserts origin tokens end-to-end. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013v95mgEuw3uo9AsnpvhDbm
|
Iteration summary (coordinator-finished after the lane session hit its context ceiling at 2.35M tokens): All six review findings resolved:
New regression coverage (269e97e): Census re-run at 269e97e: 239 → 108 sites (params 46, fields 26, keys 23, literals 13); PR body updated. Remaining sites are wire/billing/raw-parsing exclusions per the phase scope. Verification: |
## Summary Normalize an empty public origin filter to the explicit `unknown-export` scope. ## Problem The source-filter migration PR #2820 merged while its final review gate was running. That review exposed a surviving edge case: the documented empty-origin path called strict `Origin("")` conversion and raised before either storage route could run. The merged branch was deleted, so this correction is isolated as a follow-up. ## Solution - Normalize `origin=""` to `unknown-export` in both archive-tier and SQL filter-builder entry points. - Keep non-empty public filters strict canonical Origin tokens. - Assert the SQL predicate and exercise real tool-usage and coverage reads, proving an empty filter is scoped to unknown provenance rather than becoming an unfiltered query. ## Verification - `devtools test tests/unit/storage/test_schema_safety.py::TestSessionFilterSQL::test_build_filters_with_empty_origin tests/unit/insights/test_tool_usage.py::TestListToolUsageInsightsEndToEnd::test_empty_origin_selects_unknown_export_in_tool_and_coverage_routes` → 2 passed. - `devtools verify --quick` → passed all 15 steps, including ruff, mypy, generated-surface checks, topology, layering, and schema roundtrip. Co-authored-by: Codex <[email protected]>
…ce-reverted writes Close 9e5.8.5/.8/.6 (steps 3c/3b/3a shipped via cc0999b). Re-apply four writes reverted by the multi-server auto-import race while the gxjh repro/fix session was live (9e5.8.8/.6 closes, jnj.13 and rxdo.5 merge notes), each verified against the exported jsonl. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013v95mgEuw3uo9AsnpvhDbm
|
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. |
|
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. |
|
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
Renames the internal source-filter contract from
provider/providerstoorigin/originsthrough SQLite queries, repository mixins, protocols, andPython API adapters. The sweep is one atomic branch with review-waypoint
commits for 3c, 3b, and 3a.
Problem
Source-origin reads accepted provider-wire tokens and repeatedly converted
them back to an origin before querying origin columns. This leaked obsolete
vocabulary through the closed internal caller graph.
Solution
Origin(value)at the SQL boundary.to
origin/origins; no internal compatibility aliases were added.Provideronly for raw parsing/validation and other wire provenance.This is a breaking pre-1.0 Python API keyword rename: callers must use
origin=/origins=rather thanprovider=/providers=for sourcefilters.
Census: 239 sites before → 108 after (re-run at 269e97e); params
156 → 46, fields 40 → 26, keys 28 → 23, literals 15 → 13. Remaining terms
are outside this phase's wire/billing/public-CLI exclusions (raw parsing,
provider wire schemas, billing keys).
Verification
devtools verify --quick— passed (including strict mypy and render gates).devtools verify --seed-testmon --skip-slow— seeded the affected-testharness and completed the static/render path.
devtools lab census provider-vocabulary --json— recorded the counts above.Ref polylogue-9e5.8.5
Ref polylogue-9e5.8.8
Ref polylogue-9e5.8.6
Acceptance criteria
Summary by CodeRabbit