refactor: move lead-scoring compute core under schemes/lead_scoring/ [LTV-Pf.1]#109
Open
shaypal5 wants to merge 2 commits into
Open
refactor: move lead-scoring compute core under schemes/lead_scoring/ [LTV-Pf.1]#109shaypal5 wants to merge 2 commits into
shaypal5 wants to merge 2 commits into
Conversation
…[LTV-Pf.1]
First half of the physical reorg (LTV-Pf). Relocates the lead-scoring
hidden-world compute core — simulation/, mechanisms/, structure/ — as whole
directories under leadforge/schemes/lead_scoring/, so the scheme owns its
internals. Hard break, no shims (decision D12): old import paths are removed
and every in-repo caller updated.
- git mv of the three directories (21 file renames; history preserved).
- Repo-wide rewrite of the three absolute import prefixes
(leadforge.{simulation,mechanisms,structure} →
leadforge.schemes.lead_scoring.{...}) across package, tests, and scripts;
no residual bare references remain.
- Public API (leadforge.api, CLI) unchanged; package stays 1.x.
- CHANGELOG "Moved" note with the old→new path table; CLAUDE.md Repository Map
updated; docs/ltv/roadmap.md + .agent-plan.md updated (Pf split into Pf.1
compute core / Pf.2 render).
Scope: render/{snapshots,relational,tasks} and the lead-scoring schema specs
are NOT moved here — render relocation (with the relational.py split) is Pf.2;
the schema split lands with LTV-Pg. core.models / render.relational TYPE_CHECKING
hints now reference the new structure/simulation paths (a known core→scheme
type-only reference; layering cleanup tracked for M6).
Verified byte-identical to main (14/14 files of a pinned-timestamp bundle);
full suite 1508 passed / 51 skipped; ruff + mypy clean; scripts compile.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Link PR #109, advance status. Next: LTV-Pf.2 (render move). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
pr-agent-context report: No unresolved review comments, failing checks, or actionable patch coverage gaps were found on PR #109 in repository https://github.com/leadforge-dev/leadforge. Treat this PR as all clear unless new signals appear.Run metadata: |
There was a problem hiding this comment.
Pull request overview
Refactors the lead-scoring scheme by physically relocating its compute core (simulation/, mechanisms/, structure/) under leadforge/schemes/lead_scoring/ and rewriting all in-repo import paths accordingly, while keeping the public API unchanged.
Changes:
- Moved lead-scoring internal modules to
leadforge.schemes.lead_scoring.{simulation,mechanisms,structure}and updated call sites across package code, tests, and scripts. - Updated scheme and project documentation (roadmap, changelog, repo layout docs) to reflect the new module locations and the intentional hard-break.
- Adjusted Sphinx references / TYPE_CHECKING imports to point at the new module paths.
Reviewed changes
Copilot reviewed 39 out of 46 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_difficulty_modulation.py | Updates mechanism-policy import to new scheme-owned path. |
| tests/structure/test_sampler.py | Updates structure imports + module-path docstring. |
| tests/structure/test_rewiring.py | Updates structure imports, including local imports inside tests. |
| tests/structure/test_node_types.py | Updates node_types import path + module-path docstring. |
| tests/structure/test_motifs.py | Updates motifs/node_types/graph imports + module-path docstring. |
| tests/structure/test_graph.py | Updates graph/node_types imports + module-path docstring. |
| tests/simulation/test_population.py | Updates simulation/structure imports, including a private helper import. |
| tests/simulation/test_engine.py | Updates simulation/structure imports (multi-line import formatting). |
| tests/render/test_snapshot_windowed.py | Updates render test imports to new scheme-owned simulation/structure paths. |
| tests/render/test_render.py | Updates render test imports to new scheme-owned simulation/structure paths. |
| tests/mechanisms/test_mechanisms.py | Updates mechanism imports to scheme-owned mechanisms package. |
| scripts/spike_category_signal.py | Updates script imports to new scheme-owned simulation/structure paths. |
| leadforge/schemes/lead_scoring/structure/sampler.py | Updates structure sampler imports and Sphinx references to new paths. |
| leadforge/schemes/lead_scoring/structure/rewiring.py | Updates rewiring imports and Sphinx references to new paths. |
| leadforge/schemes/lead_scoring/structure/node_types.py | Introduces scheme-owned NodeType definitions (StrEnum) and related sets. |
| leadforge/schemes/lead_scoring/structure/motifs.py | Updates motifs’ imports and Sphinx references to new structure package. |
| leadforge/schemes/lead_scoring/structure/graph.py | Updates node_types import to new scheme-owned location. |
| leadforge/schemes/lead_scoring/structure/init.py | Package marker for relocated structure modules. |
| leadforge/schemes/lead_scoring/simulation/state.py | Updates docstring Sphinx reference to new engine path. |
| leadforge/schemes/lead_scoring/simulation/population.py | Updates TYPE_CHECKING WorldGraph import to new structure path. |
| leadforge/schemes/lead_scoring/simulation/engine.py | Updates mechanisms/simulation/structure imports and doc references to new paths. |
| leadforge/schemes/lead_scoring/simulation/init.py | Package marker for relocated simulation modules. |
| leadforge/schemes/lead_scoring/mechanisms/transitions.py | Updates mechanisms imports and Sphinx references to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/static.py | Updates base mechanism imports to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/scores.py | Updates base mechanism imports and Sphinx references to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/policies.py | Updates mechanisms imports and Sphinx references to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/measurement.py | Updates base mechanism imports to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/influence.py | Updates base mechanism imports to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/hazards.py | Updates mechanism imports and Sphinx references to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/counts.py | Updates base mechanism imports to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/categorical.py | Updates base mechanism imports to new paths. |
| leadforge/schemes/lead_scoring/mechanisms/base.py | Updates Sphinx reference to policy entry point under new path. |
| leadforge/schemes/lead_scoring/mechanisms/init.py | Package marker for relocated mechanisms modules. |
| leadforge/schemes/lead_scoring/init.py | Updates scheme docstring + imports used by build_world to new internal locations. |
| leadforge/render/snapshots.py | Updates imports/TYPE_CHECKING references to new scheme-owned simulation paths. |
| leadforge/render/relational.py | Updates TYPE_CHECKING references to new scheme-owned simulation paths. |
| leadforge/render/manifests.py | Updates TYPE_CHECKING WorldGraph reference to new structure path. |
| leadforge/exposure/metadata.py | Updates internal assign_mechanisms import to new scheme-owned path. |
| leadforge/core/models.py | Updates TYPE_CHECKING references to scheme-owned simulation/structure paths. |
| docs/ltv/roadmap.md | Updates roadmap narrative/split for Pf.1/Pf.2 and hard-break decision. |
| CLAUDE.md | Updates repo layout documentation to reflect the new schemes/lead_scoring internal structure. |
| CHANGELOG.md | Documents the internal-path breaking move and provides old→new import path mapping. |
| .agent-plan.md | Updates project tracker text to reflect Pf split and hard-break decision. |
Comments suppressed due to low confidence (11)
leadforge/schemes/lead_scoring/mechanisms/policies.py:34
- The
if TYPE_CHECKING:block is currently interleaved within the runtime import section, with additional imports following it. This breaks the import-block pattern used elsewhere in the repo and is likely to trip Ruff's import-sorting (I*) rules; it also makes it less clear which imports are type-only vs required at runtime.
leadforge/schemes/lead_scoring/structure/rewiring.py:7 - This docstring line exceeds the repo's 100-character line limit (Ruff E501). The longer module path after the refactor pushes it over; wrapping keeps lint green.
leadforge/schemes/lead_scoring/simulation/engine.py:7 - Several docstring lines here exceed the configured 100-character limit (Ruff E501) after the longer module paths were introduced. Wrapping these references keeps linting green.
leadforge/schemes/lead_scoring/structure/rewiring.py:4 - This docstring line is now over the 100-character limit (Ruff E501) due to the longer fully-qualified path. Please wrap the Sphinx reference onto its own line.
leadforge/schemes/lead_scoring/structure/motifs.py:6 - The new longer module path makes these docstring lines exceed the 100-character limit (Ruff E501). Wrapping avoids lint failures without changing meaning.
leadforge/schemes/lead_scoring/mechanisms/scores.py:6 - These docstring lines exceed the 100-character limit (Ruff E501) with the longer fully-qualified mechanism paths. Splitting the Sphinx references across lines keeps formatting/lint consistent.
leadforge/schemes/lead_scoring/mechanisms/hazards.py:27 - This docstring argument line is now long enough to violate the 100-character limit (Ruff E501). Wrapping the Sphinx reference onto its own indented line keeps the docstring readable and lint-clean.
leadforge/schemes/lead_scoring/mechanisms/transitions.py:99 - This docstring line likely exceeds the configured 100-character limit (Ruff E501) after expanding the fully-qualified path. Wrapping the Sphinx reference avoids lint failures.
leadforge/schemes/lead_scoring/mechanisms/policies.py:244 - This docstring summary line exceeds the 100-character limit (Ruff E501) with the longer fully-qualified class path. Splitting the description across lines keeps linting green.
leadforge/schemes/lead_scoring/mechanisms/policies.py:258 - These docstring lines are now long enough to violate the 100-character limit (Ruff E501) due to the expanded module paths. Wrapping the class references onto separate lines will keep linting green.
leadforge/schemes/lead_scoring/simulation/state.py:5 - This docstring line exceeds the 100-character limit (Ruff E501) after expanding the fully-qualified
simulate_worldpath. Wrapping keeps linting green.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+125
to
+127
| - [x] **`LTV-Pf.1`** — compute core: `simulation/` + `mechanisms/` + | ||
| `structure/` moved as whole directories (21 file renames, all callers | ||
| rewritten). Verified byte-identical; full suite green. (**PR #NNN**) |
Comment on lines
+44
to
+47
| and `LTV-Pe` (#108) merged (scheme protocol + render seam). `LTV-Pf` (physical | ||
| move, **hard break / no shims** per D12) split into Pf.1 (compute core — | ||
| simulation/mechanisms/structure moved) opened as **#NNN**, and Pf.2 (render | ||
| move, pending). Verified byte-identical. Sibling `leadforge-datasets-private` |
Comment on lines
78
to
+81
| Args: | ||
| result: Output of :func:`~leadforge.simulation.engine.simulate_world`. | ||
| result: Output of :func:`~leadforge.schemes.lead_scoring.simulation.engine.simulate_world`. | ||
| population: Output of | ||
| :func:`~leadforge.simulation.population.build_population`. | ||
| :func:`~leadforge.schemes.lead_scoring.simulation.population.build_population`. |
Comment on lines
65
to
+68
| Args: | ||
| result: Output of :func:`~leadforge.simulation.engine.simulate_world`. | ||
| result: Output of :func:`~leadforge.schemes.lead_scoring.simulation.engine.simulate_world`. | ||
| population: Output of | ||
| :func:`~leadforge.simulation.population.build_population`. | ||
| :func:`~leadforge.schemes.lead_scoring.simulation.population.build_population`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First half of the physical reorg (
LTV-Pf.1, milestoneLTV-M2).Relocates the lead-scoring hidden-world compute core —
simulation/,mechanisms/,structure/— as whole directories underleadforge/schemes/lead_scoring/, so the scheme owns its internals.Hard break, no shims (decision D12): old import paths are removed and every
in-repo caller updated. Public API (
leadforge.api, CLI) is unchanged andgenerated bundles are byte-identical — only direct imports of these internal
modules break.
Mechanics
git mvof the three directories — 21 file renames, history preserved.tests + scripts; no residual bare references:
leadforge.simulation.*leadforge.schemes.lead_scoring.simulation.*leadforge.mechanisms.*leadforge.schemes.lead_scoring.mechanisms.*leadforge.structure.*leadforge.schemes.lead_scoring.structure.*Scope (and what's deferred)
render/{snapshots,relational,tasks}(that'sLTV-Pf.2,which also splits
render/relational.pyso the sharedwrite_relational_tablesstays in the envelope), and the lead-scoring
schemaspecs (split lands withLTV-Pg). SplittingLTV-Pfkeeps each PR reviewable and byte-identical.core.models/render.relationalcarry TYPE_CHECKING-onlyreferences to the moved
structure/simulationpaths (a core→scheme type-onlyreference); the layering cleanup is tracked for M6.
Downstream consumer
The
leadforge-datasets-privatebuild scripts import these internals and mustupdate to the new paths — a breakage issue is being filed there. The package
stays on the
1.xline with a CHANGELOG "Moved" note (the public contract isunchanged).
Verification
ruff+mypyclean;compileallclean for
scripts/+leadforge/.BUNDLE_SCHEMA_VERSIONunchanged.🤖 Generated with Claude Code