Repository navigation
refactor(api): consolidate facade/sync/maintenance into subpackages (#426) - #535
Conversation
…es (#426) Problem: 15 facade*/sync*/maintenance_*/artifact_graph/publication/ readiness/surface_payloads modules sat at polylogue/ root, with the async/sync API split conveyed only by filename prefix and no enforced kernel rule. Solution: move per docs/plans/topology-target.yaml. facade*.py -> polylogue/api/{__init__,archive,ingest,products}.py sync*.py -> polylogue/api/sync/{__init__,bridge,conversations,products}.py artifact{s,_graph}.py -> polylogue/artifacts/{__init__,graph}.py maintenance_*.py -> polylogue/maintenance/{models,targets}.py publication.py -> polylogue/publication/__init__.py readiness.py -> polylogue/readiness/__init__.py surface_payloads.py -> polylogue/surfaces/payloads.py - cross_cut tagging is now path-based: polylogue/api/sync/* -> api:sync, polylogue/api/* -> api:async. build_topology_projection.cross_cut_tags and verify_cross_cuts.expected_for take the relative path. - test_no_facade_or_sync_modules_at_root flips from xfail to a normal assertion (issue #426 acceptance: xfail-strict tests flip in same PR). Verification: devtools build-topology-projection # 644 rows; #426 cells absorbed into 'stable' devtools verify-topology # realized=644 declared=644 blocking=False devtools verify-cross-cuts # cross-cut tags: clean devtools verify-cluster-cohesion # 43 cycles (= master baseline; no new cycles) devtools render-all --check # sync OK mypy polylogue # Success: no issues found in 644 source files pytest -q --ignore=tests/integration # 5612 passed, 9 xfailed Closes #426 Co-Authored-By: Claude <[email protected]>
📝 WalkthroughWalkthroughThis PR consolidates the package-root facade surface by moving facade/sync exports into Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/architecture.md`:
- Around line 49-50: Update the Key Abstractions table entry that still
references Polylogue at facade.py to instead document the Python API entry point
at polylogue/api/__init__.py; find the table row mentioning "Polylogue" and
"facade.py" and change the file/path and any descriptive text to point to
polylogue/api/__init__.py so the architecture doc consistently documents the API
entry point.
In `@docs/plans/topology-target.yaml`:
- Line 19: The YAML uses inline mapping with extra inner spaces for the key
`cross_cut` (e.g., "cross_cut: { api: async }") which violates yamllint `braces`
rule; update the generator/emitter to produce compact inline maps without inner
spaces (e.g., "cross_cut: {api: async}") for all occurrences of the `cross_cut`
entries so the produced lines at the `cross_cut` keys (and any similar inline
maps) conform to yamllint; modify the emitter formatting routine that renders
inline maps (the function responsible for serializing inline mappings) to omit
spaces after "{" and before "}" while keeping a single space after commas if
present.
In `@tests/unit/core/test_product_registry_runtime.py`:
- Around line 144-145: The test is patching the wrong symbol so the local import
in fetch_products isn't intercepted; update the patch target from
"polylogue.api.sync.bridge.run_coroutine_sync" to
"polylogue.products.registry.run_coroutine_sync" in the test so the locally
imported run_coroutine_sync used by fetch_products is mocked; keep the same
side_effect lambda and assertion, only change the patch target string where
patch(...) is called around fetch_products and _Operations().
🪄 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: 30eb6388-e779-456b-9905-ec3b9d8a708b
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock,!**/*.lock
📒 Files selected for processing (79)
devtools/artifact_graph.pydevtools/build_topology_projection.pydevtools/scenario_coverage.pydevtools/verify_cross_cuts.pydocs/architecture.mddocs/internals.mddocs/plans/topology-target.yamldocs/topology-status.mdpolylogue/__init__.pypolylogue/api/__init__.pypolylogue/api/archive.pypolylogue/api/ingest.pypolylogue/api/products.pypolylogue/api/sync/__init__.pypolylogue/api/sync/bridge.pypolylogue/api/sync/conversations.pypolylogue/api/sync/products.pypolylogue/artifacts/__init__.pypolylogue/artifacts/graph.pypolylogue/cli/bulk_export.pypolylogue/cli/check_maintenance.pypolylogue/cli/check_options.pypolylogue/cli/check_validation.pypolylogue/cli/commands/export.pypolylogue/cli/commands/neighbors.pypolylogue/cli/commands/products.pypolylogue/cli/commands/resume.pypolylogue/cli/commands/run.pypolylogue/cli/commands/tags.pypolylogue/cli/helper_summary.pypolylogue/cli/machine_errors.pypolylogue/cli/query.pypolylogue/cli/query_output.pypolylogue/cli/run_workflow.pypolylogue/lib/embeddings/runtime.pypolylogue/maintenance/__init__.pypolylogue/maintenance/models.pypolylogue/maintenance/targets.pypolylogue/mcp/payloads.pypolylogue/mcp/server_support.pypolylogue/operations/archive.pypolylogue/pipeline/run_support.pypolylogue/product_readiness.pypolylogue/products/registry.pypolylogue/proof/subjects.pypolylogue/publication/__init__.pypolylogue/readiness/__init__.pypolylogue/rendering/formatting.pypolylogue/scenarios/execution.pypolylogue/scenarios/metadata.pypolylogue/showcase/qa_runner_workflow.pypolylogue/showcase/workspace.pypolylogue/site/builder.pypolylogue/storage/action_event_artifacts.pypolylogue/storage/backends/queries/conversations_search.pypolylogue/storage/derived_status.pypolylogue/storage/derived_status_products.pypolylogue/storage/repair.pypolylogue/storage/search_runtime.pypolylogue/surfaces/__init__.pypolylogue/surfaces/payloads.pytests/infra/surfaces.pytests/unit/architecture/test_topology_invariants.pytests/unit/cli/test_check_support_runtime.pytests/unit/cli/test_tail_query_runtime.pytests/unit/core/test_artifact_graph.pytests/unit/core/test_facade_api.pytests/unit/core/test_health_core.pytests/unit/core/test_maintenance_targets.pytests/unit/core/test_product_export_bundles.pytests/unit/core/test_product_readiness.pytests/unit/core/test_product_registry_runtime.pytests/unit/core/test_resume.pytests/unit/core/test_sync.pytests/unit/core/test_sync_surface_runtime.pytests/unit/devtools/test_verify_cross_cuts.pytests/unit/proof/test_structural_error_evidence.pytests/unit/storage/test_repair.pytests/unit/storage/test_scale.py
💤 Files with no reviewable changes (1)
- tests/unit/architecture/test_topology_invariants.py
| - Python API: `polylogue/api/__init__.py` | ||
| - MCP server: `polylogue/mcp/` |
There was a problem hiding this comment.
Resolve remaining architecture doc contradiction for API entry point.
Line 49 correctly points to polylogue/api/__init__.py, but Line 106 still documents Polylogue at facade.py. Please align the Key Abstractions table to the new package location to keep this doc internally consistent.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/architecture.md` around lines 49 - 50, Update the Key Abstractions table
entry that still references Polylogue at facade.py to instead document the
Python API entry point at polylogue/api/__init__.py; find the table row
mentioning "Polylogue" and "facade.py" and change the file/path and any
descriptive text to point to polylogue/api/__init__.py so the architecture doc
consistently documents the API entry point.
| loc: 76 | ||
| target: polylogue/api/__init__.py | ||
| owner: stable | ||
| cross_cut: { api: async } |
There was a problem hiding this comment.
Fix inline map spacing to satisfy yamllint (braces).
Changed cross_cut entries at Line 19/24/29/34/39/44/49/54 use extra inner spaces and trigger lint errors. Since this file is generated, fix the emitter to prevent repeated failures.
🔧 Proposed generator fix
--- a/devtools/build_topology_projection.py
+++ b/devtools/build_topology_projection.py
@@
- if row["cross_cut"]:
- tags = ", ".join(f"{k}: {v}" for k, v in sorted(row["cross_cut"].items()))
- lines.append(f" cross_cut: {{ {tags} }}")
+ if row["cross_cut"]:
+ tags = ", ".join(f"{k}: {v}" for k, v in sorted(row["cross_cut"].items()))
+ lines.append(f" cross_cut: {{{tags}}}")Also applies to: 24-24, 29-29, 34-34, 39-39, 44-44, 49-49, 54-54
🧰 Tools
🪛 YAMLlint (1.38.0)
[error] 19-19: too many spaces inside braces
(braces)
[error] 19-19: too many spaces inside braces
(braces)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/plans/topology-target.yaml` at line 19, The YAML uses inline mapping
with extra inner spaces for the key `cross_cut` (e.g., "cross_cut: { api: async
}") which violates yamllint `braces` rule; update the generator/emitter to
produce compact inline maps without inner spaces (e.g., "cross_cut: {api:
async}") for all occurrences of the `cross_cut` entries so the produced lines at
the `cross_cut` keys (and any similar inline maps) conform to yamllint; modify
the emitter formatting routine that renders inline maps (the function
responsible for serializing inline mappings) to omit spaces after "{" and before
"}" while keeping a single space after commas if present.
| with patch("polylogue.api.sync.bridge.run_coroutine_sync", side_effect=lambda value: [value]): | ||
| assert fetch_products(product_type, _Operations(), provider="claude-code") == ["sync:claude-code"] |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n 'run_coroutine_sync|fetch_products' polylogue/products/registry.py tests/unit/core/test_product_registry_runtime.pyRepository: Sinity/polylogue
Length of output: 1443
Patch target is incorrect; test will not intercept the call.
The fetch_products function imports run_coroutine_sync directly at line 633 of polylogue/products/registry.py:
from polylogue.api.sync.bridge import run_coroutine_syncPatching polylogue.api.sync.bridge.run_coroutine_sync will not intercept the locally bound reference. Change the patch target to polylogue.products.registry.run_coroutine_sync instead.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/unit/core/test_product_registry_runtime.py` around lines 144 - 145, The
test is patching the wrong symbol so the local import in fetch_products isn't
intercepted; update the patch target from
"polylogue.api.sync.bridge.run_coroutine_sync" to
"polylogue.products.registry.run_coroutine_sync" in the test so the locally
imported run_coroutine_sync used by fetch_products is mocked; keep the same
side_effect lambda and assertion, only change the patch target string where
patch(...) is called around fetch_products and _Operations().
## Summary - Regroup `polylogue/storage/` modules by ownership domain (archive/products/sessions/repository) per topology projection (#425). ## Problem `polylogue/storage/` had grown to ~80 flat-laid modules — repository/products/backends/sessions intermingled. Topology projection (`docs/plans/topology-target.yaml`) declares ownership-domain clusters; the realized tree didn't match. ## Solution 63 file moves grouping by domain. Imports rewritten via topology-driven AST renamer. Verified via `verify-topology`, `verify-cluster-cohesion`, `verify-test-ownership`. ## Verification - `devtools verify --quick` — green (format, lint, mypy, render-all, all 5 topology lints). - Local `pytest -q --ignore=tests/integration` — all green prior to push. Stacked on #535 (merged). Replaces closed #536 after `--delete-branch` cascade closed it. Closes #425 Co-authored-by: Claude <[email protected]>
## Summary 64 moves grouping `polylogue/lib/` into domain subpackages (query, session, viewport, conversation, message, raw_payload, artifact_taxonomy, action_event, semantic, filter, projection, phase, provider, attachment) per `docs/plans/topology-target.yaml`, plus two package-init merges. **Stacked on #536 (which is stacked on #535).** Merge that train bottom-up; rebase between if needed. ## Problem Per #424: `polylogue/lib/` was a flat catch-all of 80+ modules with domain logic, infrastructure primitives, model carriers, and runtime adapters all coexisting at one level. The substrate ring rule didn't survive the package; manifest declared targets but moves had not landed. ## Solution ``` query_*.py -> lib/query/ session_profile_*.py -> lib/session/ viewport_*.py -> lib/viewport/ conversation_*.py -> lib/conversation/ message_*.py -> lib/message/ raw_payload_*.py -> lib/raw_payload/{decode,streams,sampling_*}.py artifact_taxonomy_*.py -> lib/artifact_taxonomy/{models,runtime,support}.py action_event_*.py -> lib/action_event/ semantic_fact_*.py -> lib/semantic/{models,support}.py semantic_facts.py -> lib/semantic/facts.py filter_*.py, filters -> lib/filter/ projection_*.py -> lib/projection/ phase_extraction.py -> lib/phase/extraction.py provider_*.py -> lib/provider/ attachment_models.py -> lib/attachment/models.py ``` Notes: - `lib/raw_payload.py` and `lib/artifact_taxonomy.py` were merged into their packages' `__init__.py` so the public API surface stays at `polylogue.lib.<pkg>.X` rather than the awkward `polylogue.lib.<pkg>.<pkg>.X`. - Fixed two `build_topology_projection` bugs: 1. The exact-filename rule now triggers on `prefix == name` OR `prefix == name.removesuffix(".py")`, so rules like `"semantic_facts": "lib/semantic/facts.py"` work. 2. Added explicit `semantic_facts -> lib/semantic/facts.py` rule; the broad `semantic_fact` prefix had been incorrectly catching `semantic_facts.py` and chopping it to `s.py`. - Two `#424` xfail-strict invariants flip to normal asserts. ## Verification ``` devtools build-topology-projection # 675 rows; #424 cells absorbed into 'stable' devtools verify-topology # realized=675 declared=675 blocking=False devtools verify-cross-cuts # cross-cut tags: clean devtools verify-cluster-cohesion # 42 cycles (= master baseline 43; no new cycles) devtools render-all --check # sync OK mypy polylogue # Success: no issues found in 675 source files pytest -q --ignore=tests/integration # 5618 passed, 5 xfailed devtools verify --quick # all checks passed ``` Closes #424 Co-authored-by: Claude <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ 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. 👍 ℹ️ 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". |
…426) (#535) ## Summary 15 root-level modules (`facade*.py`, `sync*.py`, `maintenance_*.py`, `artifact_graph.py`, `artifacts.py`, `publication.py`, `readiness.py`, `surface_payloads.py`) consolidate into the subpackages declared in `docs/plans/topology-target.yaml`. ## Problem Per #426: the polylogue/ root mixed kernel modules with the async/sync API surface, with the split conveyed only by filename prefix and no enforced kernel rule. The `verify-topology` lint declared targets but the realized tree had not moved yet. ## Solution Moves performed (15 files; `docs/plans/topology-target.yaml` was the source of truth): ``` facade*.py -> polylogue/api/{__init__,archive,ingest,products}.py sync*.py -> polylogue/api/sync/{__init__,bridge,conversations,products}.py artifact{s,_graph}.py -> polylogue/artifacts/{__init__,graph}.py maintenance_*.py -> polylogue/maintenance/{models,targets}.py publication.py -> polylogue/publication/__init__.py readiness.py -> polylogue/readiness/__init__.py surface_payloads.py -> polylogue/surfaces/payloads.py ``` Cross-cut tagging is now path-based (`polylogue/api/sync/*` → `api:sync`, `polylogue/api/*` → `api:async`); `build_topology_projection.cross_cut_tags` and `verify_cross_cuts.expected_for` were updated to take the relative path. `test_no_facade_or_sync_modules_at_root` flips from `xfail(strict)` to a normal assertion as the issue's executable acceptance criterion requires; the other xfail topology invariants stay (waiting on #424, #425, #413, #414, #427). ## Verification ``` devtools build-topology-projection # 644 rows; #426 cells absorbed into 'stable' devtools verify-topology # realized=644 declared=644 blocking=False devtools verify-cross-cuts # cross-cut tags: clean devtools verify-cluster-cohesion # 43 cycles (= master baseline; no new cycles) devtools render-all --check # sync OK mypy polylogue # Success: no issues found in 644 source files pytest -q --ignore=tests/integration # 5612 passed, 9 xfailed devtools verify --quick # all checks passed ``` Closes #426 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Refactor** * Reorganized internal module structure for improved code organization. Key modules have been consolidated into packages: API functionality is now under `polylogue/api/`, artifact handling under `polylogue/artifacts/`, and maintenance utilities under `polylogue/maintenance/`. All public exports and functionality remain unchanged—this is a structural improvement with no impact on user-facing behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude <[email protected]>
## Summary - Regroup `polylogue/storage/` modules by ownership domain (archive/products/sessions/repository) per topology projection (#425). ## Problem `polylogue/storage/` had grown to ~80 flat-laid modules — repository/products/backends/sessions intermingled. Topology projection (`docs/plans/topology-target.yaml`) declares ownership-domain clusters; the realized tree didn't match. ## Solution 63 file moves grouping by domain. Imports rewritten via topology-driven AST renamer. Verified via `verify-topology`, `verify-cluster-cohesion`, `verify-test-ownership`. ## Verification - `devtools verify --quick` — green (format, lint, mypy, render-all, all 5 topology lints). - Local `pytest -q --ignore=tests/integration` — all green prior to push. Stacked on #535 (merged). Replaces closed #536 after `--delete-branch` cascade closed it. Closes #425 Co-authored-by: Claude <[email protected]>
## Summary 64 moves grouping `polylogue/lib/` into domain subpackages (query, session, viewport, conversation, message, raw_payload, artifact_taxonomy, action_event, semantic, filter, projection, phase, provider, attachment) per `docs/plans/topology-target.yaml`, plus two package-init merges. **Stacked on #536 (which is stacked on #535).** Merge that train bottom-up; rebase between if needed. ## Problem Per #424: `polylogue/lib/` was a flat catch-all of 80+ modules with domain logic, infrastructure primitives, model carriers, and runtime adapters all coexisting at one level. The substrate ring rule didn't survive the package; manifest declared targets but moves had not landed. ## Solution ``` query_*.py -> lib/query/ session_profile_*.py -> lib/session/ viewport_*.py -> lib/viewport/ conversation_*.py -> lib/conversation/ message_*.py -> lib/message/ raw_payload_*.py -> lib/raw_payload/{decode,streams,sampling_*}.py artifact_taxonomy_*.py -> lib/artifact_taxonomy/{models,runtime,support}.py action_event_*.py -> lib/action_event/ semantic_fact_*.py -> lib/semantic/{models,support}.py semantic_facts.py -> lib/semantic/facts.py filter_*.py, filters -> lib/filter/ projection_*.py -> lib/projection/ phase_extraction.py -> lib/phase/extraction.py provider_*.py -> lib/provider/ attachment_models.py -> lib/attachment/models.py ``` Notes: - `lib/raw_payload.py` and `lib/artifact_taxonomy.py` were merged into their packages' `__init__.py` so the public API surface stays at `polylogue.lib.<pkg>.X` rather than the awkward `polylogue.lib.<pkg>.<pkg>.X`. - Fixed two `build_topology_projection` bugs: 1. The exact-filename rule now triggers on `prefix == name` OR `prefix == name.removesuffix(".py")`, so rules like `"semantic_facts": "lib/semantic/facts.py"` work. 2. Added explicit `semantic_facts -> lib/semantic/facts.py` rule; the broad `semantic_fact` prefix had been incorrectly catching `semantic_facts.py` and chopping it to `s.py`. - Two `#424` xfail-strict invariants flip to normal asserts. ## Verification ``` devtools build-topology-projection # 675 rows; #424 cells absorbed into 'stable' devtools verify-topology # realized=675 declared=675 blocking=False devtools verify-cross-cuts # cross-cut tags: clean devtools verify-cluster-cohesion # 42 cycles (= master baseline 43; no new cycles) devtools render-all --check # sync OK mypy polylogue # Success: no issues found in 675 source files pytest -q --ignore=tests/integration # 5618 passed, 5 xfailed devtools verify --quick # all checks passed ``` Closes #424 Co-authored-by: Claude <[email protected]>
Summary
15 root-level modules (
facade*.py,sync*.py,maintenance_*.py,artifact_graph.py,artifacts.py,publication.py,readiness.py,surface_payloads.py) consolidate into the subpackages declared indocs/plans/topology-target.yaml.Problem
Per #426: the polylogue/ root mixed kernel modules with the async/sync
API surface, with the split conveyed only by filename prefix and no
enforced kernel rule. The
verify-topologylint declared targets butthe realized tree had not moved yet.
Solution
Moves performed (15 files;
docs/plans/topology-target.yamlwas thesource of truth):
Cross-cut tagging is now path-based (
polylogue/api/sync/*→api:sync,polylogue/api/*→api:async);build_topology_projection.cross_cut_tagsand
verify_cross_cuts.expected_forwere updated to take the relativepath.
test_no_facade_or_sync_modules_at_rootflips fromxfail(strict)to a normal assertion as the issue's executable acceptance criterion
requires; the other xfail topology invariants stay (waiting on #424,
#425, #413, #414, #427).
Verification
Closes #426
Summary by CodeRabbit
Release Notes
polylogue/api/, artifact handling underpolylogue/artifacts/, and maintenance utilities underpolylogue/maintenance/. All public exports and functionality remain unchanged—this is a structural improvement with no impact on user-facing behavior.