Skip to content

refactor(api): consolidate facade/sync/maintenance into subpackages (#426) - #535

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/426-root-facade-package-boundary
Apr 27, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/426-root-facade-package-boundary

Conversation

@Sinity

@Sinity Sinity commented Apr 27, 2026 •

Copy link
Copy Markdown
Owner

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

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.

…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]>
@coderabbitai

coderabbitai Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR consolidates the package-root facade surface by moving facade/sync exports into polylogue.api with sync subpackage, and restructures cross-ring modules (artifacts, surfaces, maintenance, publication, readiness) into dedicated packages, updating all related imports, devtools, topology definitions, and documentation accordingly.

Changes

Cohort / File(s) Summary
API Surface Reorganization
polylogue/__init__.py, polylogue/api/__init__.py, polylogue/api/sync/__init__.py, polylogue/api/sync/conversations.py, polylogue/api/sync/products.py
Updated lazy-export and import wiring to source ArchiveStats, Polylogue, SyncPolylogue, and sync mixins from new polylogue.api / polylogue.api.sync modules instead of legacy facade/sync modules.
CLI Module Refactoring
polylogue/cli/bulk_export.py, polylogue/cli/commands/export.py, polylogue/cli/commands/neighbors.py, polylogue/cli/commands/products.py, polylogue/cli/commands/resume.py, polylogue/cli/commands/run.py, polylogue/cli/commands/tags.py, polylogue/cli/helper_summary.py, polylogue/cli/machine_errors.py, polylogue/cli/query.py, polylogue/cli/query_output.py, polylogue/cli/run_workflow.py
Updated import paths for run_coroutine_sync from polylogue.sync_bridge to polylogue.api.sync.bridge, and surface payload types from polylogue.surface_payloads to polylogue.surfaces.payloads.
CLI Maintenance Support
polylogue/cli/check_maintenance.py, polylogue/cli/check_options.py, polylogue/cli/check_validation.py
Updated imports for maintenance-related symbols to use new polylogue.maintenance.targets and polylogue.maintenance.models module paths.
Artifacts & Graph Restructuring
polylogue/artifacts/graph.py, devtools/artifact_graph.py, devtools/scenario_coverage.py, polylogue/proof/subjects.py, polylogue/scenarios/metadata.py, tests/unit/core/test_artifact_graph.py
Updated imports for artifact graph construction from polylogue.artifact_graph to polylogue.artifacts.graph and maintenance references accordingly.
Surfaces & Payloads Reorganization
polylogue/mcp/payloads.py, polylogue/mcp/server_support.py, polylogue/rendering/formatting.py, tests/unit/proof/test_structural_error_evidence.py
Retargeted surface payload types from polylogue.surface_payloads to polylogue.surfaces.payloads.
Maintenance Module Restructuring
polylogue/maintenance/targets.py, polylogue/readiness/__init__.py, polylogue/storage/action_event_artifacts.py, polylogue/storage/derived_status.py, polylogue/storage/derived_status_products.py, polylogue/storage/repair.py, tests/unit/core/test_health_core.py, tests/unit/core/test_maintenance_targets.py, tests/unit/storage/test_repair.py
Updated imports for maintenance models and targets from legacy polylogue.maintenance_models / polylogue.maintenance_targets to new polylogue.maintenance.models / polylogue.maintenance.targets modules.
Operations & Products Imports
polylogue/operations/archive.py, polylogue/product_readiness.py, polylogue/products/registry.py, polylogue/storage/backends/queries/conversations_search.py, polylogue/storage/search_runtime.py, polylogue/scenarios/execution.py, polylogue/lib/embeddings/runtime.py, polylogue/showcase/qa_runner_workflow.py, polylogue/showcase/workspace.py, polylogue/site/builder.py, polylogue/pipeline/run_support.py
Updated imports for run_coroutine_sync and build_maintenance_target_catalog to reference new canonical module paths under polylogue.api.sync.bridge and polylogue.maintenance.targets.
Devtools Path-Based API Tagging
devtools/build_topology_projection.py, devtools/verify_cross_cuts.py
Enhanced cross_cut_tags() and expected_for() to accept module path parameter and infer API cross-cuts (async/sync) based on directory structure (polylogue/api/sync/ vs polylogue/api/) instead of filename heuristics.
Topology & Architecture Documentation
docs/architecture.md, docs/internals.md, docs/plans/topology-target.yaml, docs/topology-status.md
Updated topology target mappings and architecture documentation: replaced facade module entries with polylogue/api/ entries, restructured artifact/surface/maintenance/publication/readiness into package layouts, adjusted ownership from #426 to stable, and reflected updated metrics in topology-status dashboard.
Test Imports & xfail Removal
tests/infra/surfaces.py, tests/unit/architecture/test_topology_invariants.py, tests/unit/cli/test_check_support_runtime.py, tests/unit/cli/test_tail_query_runtime.py, tests/unit/core/test_facade_api.py, tests/unit/core/test_product_export_bundles.py, tests/unit/core/test_product_readiness.py, tests/unit/core/test_product_registry_runtime.py, tests/unit/core/test_resume.py, tests/unit/core/test_sync.py, tests/unit/core/test_sync_surface_runtime.py, tests/unit/devtools/test_verify_cross_cuts.py, tests/unit/storage/test_scale.py
Updated test imports to reference new module paths; removed xfail marker from facade/sync-at-root topology invariant test; updated devtools test to validate path-based API classification.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels

type:refactor, area:api, area:cli, area:storage, area:devtools, area:docs

Poem

🐰 Old facades fade to memory's hall,
As packages nest and modules herd,
The api/sync boundary stands tall—
One coordinated move, cleanly inferred!
Now topology sings of stable ground,
Where orphan paths at last are found.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: consolidating facade/sync/maintenance modules into subpackages and closing issue #426.
Description check ✅ Passed The PR description includes all required sections: Summary (what changed), Problem (why needed), Solution (what was done), Verification (commands run), and Risks. It is well-structured and complete.
Linked Issues check ✅ Passed The PR fully addresses the requirements from #426: consolidates facade/sync modules into polylogue/api/, moves cross-ring files (artifacts, maintenance, readiness, surfaces, publication) into subpackages, updates cross-cut tagging to be path-based, converts test_no_facade_or_sync_modules_at_root from xfail to normal assertion, and all verification checks pass.
Out of Scope Changes check ✅ Passed All changes directly support the consolidation objective from #426. Import path updates across ~60 files are necessary follow-through; documentation updates reflect the new structure; and devtools updates implement the path-based cross-cut tagging requirement.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/426-root-facade-package-boundary

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between cf4890f and 5e4bff0.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (79)
  • devtools/artifact_graph.py
  • devtools/build_topology_projection.py
  • devtools/scenario_coverage.py
  • devtools/verify_cross_cuts.py
  • docs/architecture.md
  • docs/internals.md
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/__init__.py
  • polylogue/api/__init__.py
  • polylogue/api/archive.py
  • polylogue/api/ingest.py
  • polylogue/api/products.py
  • polylogue/api/sync/__init__.py
  • polylogue/api/sync/bridge.py
  • polylogue/api/sync/conversations.py
  • polylogue/api/sync/products.py
  • polylogue/artifacts/__init__.py
  • polylogue/artifacts/graph.py
  • polylogue/cli/bulk_export.py
  • polylogue/cli/check_maintenance.py
  • polylogue/cli/check_options.py
  • polylogue/cli/check_validation.py
  • polylogue/cli/commands/export.py
  • polylogue/cli/commands/neighbors.py
  • polylogue/cli/commands/products.py
  • polylogue/cli/commands/resume.py
  • polylogue/cli/commands/run.py
  • polylogue/cli/commands/tags.py
  • polylogue/cli/helper_summary.py
  • polylogue/cli/machine_errors.py
  • polylogue/cli/query.py
  • polylogue/cli/query_output.py
  • polylogue/cli/run_workflow.py
  • polylogue/lib/embeddings/runtime.py
  • polylogue/maintenance/__init__.py
  • polylogue/maintenance/models.py
  • polylogue/maintenance/targets.py
  • polylogue/mcp/payloads.py
  • polylogue/mcp/server_support.py
  • polylogue/operations/archive.py
  • polylogue/pipeline/run_support.py
  • polylogue/product_readiness.py
  • polylogue/products/registry.py
  • polylogue/proof/subjects.py
  • polylogue/publication/__init__.py
  • polylogue/readiness/__init__.py
  • polylogue/rendering/formatting.py
  • polylogue/scenarios/execution.py
  • polylogue/scenarios/metadata.py
  • polylogue/showcase/qa_runner_workflow.py
  • polylogue/showcase/workspace.py
  • polylogue/site/builder.py
  • polylogue/storage/action_event_artifacts.py
  • polylogue/storage/backends/queries/conversations_search.py
  • polylogue/storage/derived_status.py
  • polylogue/storage/derived_status_products.py
  • polylogue/storage/repair.py
  • polylogue/storage/search_runtime.py
  • polylogue/surfaces/__init__.py
  • polylogue/surfaces/payloads.py
  • tests/infra/surfaces.py
  • tests/unit/architecture/test_topology_invariants.py
  • tests/unit/cli/test_check_support_runtime.py
  • tests/unit/cli/test_tail_query_runtime.py
  • tests/unit/core/test_artifact_graph.py
  • tests/unit/core/test_facade_api.py
  • tests/unit/core/test_health_core.py
  • tests/unit/core/test_maintenance_targets.py
  • tests/unit/core/test_product_export_bundles.py
  • tests/unit/core/test_product_readiness.py
  • tests/unit/core/test_product_registry_runtime.py
  • tests/unit/core/test_resume.py
  • tests/unit/core/test_sync.py
  • tests/unit/core/test_sync_surface_runtime.py
  • tests/unit/devtools/test_verify_cross_cuts.py
  • tests/unit/proof/test_structural_error_evidence.py
  • tests/unit/storage/test_repair.py
  • tests/unit/storage/test_scale.py
💤 Files with no reviewable changes (1)
  • tests/unit/architecture/test_topology_invariants.py

Comment thread docs/architecture.md
Comment on lines +49 to 50
- Python API: `polylogue/api/__init__.py`
- MCP server: `polylogue/mcp/`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Comment on lines +144 to 145
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"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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.py

Repository: 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_sync

Patching 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().

@Sinity
Sinity merged commit a983de0 into master Apr 27, 2026
15 checks passed
@Sinity
Sinity deleted the feature/refactor/426-root-facade-package-boundary branch April 27, 2026 16:49
Sinity added a commit that referenced this pull request Apr 27, 2026
## 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]>
Sinity added a commit that referenced this pull request Apr 27, 2026
## 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]>
@Sinity

Sinity commented Apr 28, 2026

Copy link
Copy Markdown
Owner Author

🤖 Post-hoc audit note: this PR received bot review feedback verified against current HEAD as part of #544. 3 finding(s) confirmed still present → tracked in #550.

@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@Sinity
Sinity requested a review from Copilot May 1, 2026 00:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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".

@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

Sinity added a commit that referenced this pull request May 7, 2026
…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]>
Sinity added a commit that referenced this pull request May 7, 2026
## 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]>
Sinity added a commit that referenced this pull request May 7, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: rationalize package-root layout and consolidate facade surface

2 participants