Repository navigation
fix(devtools): topology projection avoids __init__.py target collisions - #456
Conversation
Closes the projection-rule defect surfaced by the topology-status dashboard (PR #455). Previously, when a module's name equaled its subpackage prefix exactly (e.g. ``session_payload``, ``store_runtime``), the rule emitted a target of ``polylogue/<sub>/__init__.py`` — causing multiple modules to claim the same destination and producing 12 "conflicts" in the dashboard. The new resolver: - preserves the full module name as the target stem when stem-stripping would empty out (``session_payload`` -> ``lib/session/session_payload.py``, not ``lib/session/__init__.py``); - otherwise strips the trailing-underscore variant of the prefix (``query_runtime`` -> ``lib/query/runtime.py``). After regen: ``devtools verify-topology --json`` reports zero conflicts. Dashboard table will show 0 in the conflicts column once both this fix and #455 land. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 6 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex review |
There was a problem hiding this comment.
Pull request overview
Fixes a defect in the topology projection generation that previously mapped some prefix-matched modules to __init__.py, creating false target-collision “conflicts” in the topology-status dashboard and related tooling.
Changes:
- Introduces a shared
_resolve_target()helper to compute deterministic, non-colliding target paths forlib_target()andstorage_target(). - Regenerates
docs/plans/topology-target.yamlto replace several erroneous.../.pytargets with concrete module targets and updates someloccounts accordingly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| docs/plans/topology-target.yaml | Updates projection targets (and some LOC metadata) to reflect the new target resolution logic. |
| devtools/build_topology_projection.py | Adds _resolve_target() and routes lib/storage target computation through it to avoid __init__.py collisions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| stem = name[len(prefix) :] | ||
| if not stem: | ||
| # Module name == prefix; preserve the full name to avoid colliding | ||
| # at the subpackage __init__.py. | ||
| return f"polylogue/{sub}{name}" | ||
| if not stem.endswith(".py"): | ||
| stem = stem + ".py" | ||
| stem = stem.lstrip("_") | ||
| if not stem or stem == ".py": | ||
| return f"polylogue/{sub}{name}" | ||
| return f"polylogue/{sub}{stem}" |
There was a problem hiding this comment.
This resolver assumes sub is a directory prefix (ends with /). For exact-match rules where sub is a full file path (e.g. storage/repository/__init__.py for repository.py), returning f"polylogue/{sub}{name}" produces concatenated filenames like .../__init__.pyrepository.py (also visible in the regenerated topology-target.yaml). Consider special-casing sub values that already end with .py (treat as a complete target) or handling exact filename rewrites before calling _resolve_target.
| """Build a unique target path for a module that matches a given subpackage prefix. | ||
|
|
||
| When the module name equals the prefix exactly, keep the full name as the | ||
| target stem (so e.g. ``session_payload`` lands at | ||
| ``lib/session/session_payload.py``, not at the cluster's ``__init__.py`` | ||
| where it would collide with sibling modules). | ||
|
|
||
| When the prefix has a trailing underscore (``query_``, ``store_runtime_``), | ||
| strip it from the stem so ``query_runtime`` becomes ``runtime.py``. |
There was a problem hiding this comment.
Docstring examples here talk about module names without the .py suffix (e.g. session_payload), but _resolve_target is passed path.name values like session_payload.py. Clarifying the docstring to match the actual inputs would make the edge-case behavior (the .py stem) easier to reason about.
| """Build a unique target path for a module that matches a given subpackage prefix. | |
| When the module name equals the prefix exactly, keep the full name as the | |
| target stem (so e.g. ``session_payload`` lands at | |
| ``lib/session/session_payload.py``, not at the cluster's ``__init__.py`` | |
| where it would collide with sibling modules). | |
| When the prefix has a trailing underscore (``query_``, ``store_runtime_``), | |
| strip it from the stem so ``query_runtime`` becomes ``runtime.py``. | |
| """Build a unique target path for a filename matching a subpackage prefix. | |
| ``name`` is the source filename as returned by ``path.name`` (for example, | |
| ``session_payload.py``), not a module stem without the suffix. | |
| When the filename equals the prefix plus ``.py`` exactly, keep the full | |
| filename as the target stem (so e.g. ``session_payload.py`` lands at | |
| ``lib/session/session_payload.py``, not at the cluster's ``__init__.py`` | |
| where it would collide with sibling modules). | |
| When the prefix has a trailing underscore (``query_``, ``store_runtime_``), | |
| strip it from the remainder so ``query_runtime.py`` becomes ``runtime.py``. |
| - path: polylogue/storage/repository.py | ||
| loc: 102 | ||
| target: polylogue/storage/repository/__init__.pyinit__.py | ||
| target: polylogue/storage/repository/__init__.pyrepository.py |
There was a problem hiding this comment.
This target path looks like an accidental concatenation of two filenames (__init__.py + repository.py). If the intent is to move polylogue/storage/repository.py into the storage/repository/ package, the target should likely be polylogue/storage/repository/__init__.py (or polylogue/storage/repository/repository.py), not a combined name.
| target: polylogue/storage/repository/__init__.pyrepository.py | |
| target: polylogue/storage/repository/__init__.py |
| - path: polylogue/storage/search.py | ||
| loc: 50 | ||
| target: polylogue/storage/search/__init__.pyinit__.py | ||
| target: polylogue/storage/search/__init__.pysearch.py |
There was a problem hiding this comment.
This target path looks like an accidental concatenation (__init__.py + search.py). If polylogue/storage/search.py is intended to become the package entrypoint, the target should likely be polylogue/storage/search/__init__.py (or polylogue/storage/search/search.py), not __init__.pysearch.py.
| target: polylogue/storage/search/__init__.pysearch.py | |
| target: polylogue/storage/search/__init__.py |
| - path: polylogue/storage/store.py | ||
| loc: 86 | ||
| target: polylogue/storage/runtime/__init__.pyinit__.py | ||
| target: polylogue/storage/runtime/__init__.pystore.py |
There was a problem hiding this comment.
This target path looks like an accidental concatenation (__init__.py + store.py). If polylogue/storage/store.py is intended to become the package entrypoint for storage/runtime/, the target should likely be polylogue/storage/runtime/__init__.py (or polylogue/storage/runtime/store.py), not __init__.pystore.py.
| target: polylogue/storage/runtime/__init__.pystore.py | |
| target: polylogue/storage/runtime/store.py |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a43a42f70
ℹ️ 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".
…ns (#456) ## Summary Fixes a projection-rule defect surfaced by the topology-status dashboard (PR #455). The rule was emitting `__init__.py` for any module whose name equaled the subpackage prefix exactly, which caused multiple modules to claim the same destination — 12 false-conflict rows in the dashboard. ## Problem `build_topology_projection.py:lib_target()` and `storage_target()` use a strip-prefix-then-stem rule. When the stem strips empty (e.g. module `session_payload` matches prefix `session_payload`), the rule defaulted to `__init__.py`. Two such modules in the same cluster collide: - `lib/session/__init__.py` claimed by `session_payload`, `session_summaries`, `session_profile` - `storage/runtime/__init__.py` claimed by `store_runtime` (the catch-all prefix) `devtools verify-topology` reports `conflicts: 12` and the dashboard shows them in its conflicts column. ## Solution New resolver: ```python def _resolve_target(name: str, sub: str, prefix: str) -> str: stem = name[len(prefix):] if not stem: # Module name == prefix; preserve full name to avoid colliding at __init__.py. return f"polylogue/{sub}{name}" if not stem.endswith(".py"): stem = stem + ".py" stem = stem.lstrip("_") if not stem or stem == ".py": return f"polylogue/{sub}{name}" return f"polylogue/{sub}{stem}" ``` After regen: `verify-topology --json` reports `conflicts: 0`. Dashboard column will read 0 once this and #455 are both merged. ## Verification ``` $ devtools build-topology-projection $ devtools verify-topology --json | jq '.counts' {"orphans": 0, "missing": 0, "conflicts": 0, "kernel_rule": 0, "tbd": 39} $ devtools verify --quick verify: all checks passed (incl. all 8 lints) ``` ## Related - #429 — projection lint pattern. - #455 — topology drift dashboard (sibling PR; conflicts column will read 0 after both merge). - #424 / #425 — refactors that consume the projection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
|
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
Fixes a projection-rule defect surfaced by the topology-status dashboard (PR #455). The rule was emitting
__init__.pyfor any module whose name equaled the subpackage prefix exactly, which caused multiple modules to claim the same destination — 12 false-conflict rows in the dashboard.Problem
build_topology_projection.py:lib_target()andstorage_target()use a strip-prefix-then-stem rule. When the stem strips empty (e.g. modulesession_payloadmatches prefixsession_payload), the rule defaulted to__init__.py. Two such modules in the same cluster collide:lib/session/__init__.pyclaimed bysession_payload,session_summaries,session_profilestorage/runtime/__init__.pyclaimed bystore_runtime(the catch-all prefix)devtools verify-topologyreportsconflicts: 12and the dashboard shows them in its conflicts column.Solution
New resolver:
After regen:
verify-topology --jsonreportsconflicts: 0. Dashboard column will read 0 once this and #455 are both merged.Verification
Related
🤖 Generated with Claude Code