← Back to Pull requests

fix(architecture): restore the top-level module budget gate after #6703 #6734

Closed
unknown closed this pull request without merging on Oct 17, 2026 12:06 UTC
View on GitHub
unknown unknown commented on Oct 17, 2026 11:04 UTC
Author

Goal And Delivered Outcome

Impact: a required Python Tests merge-gate job is deterministically red on main, so every PR whose Python Tests run (30 open PRs at the time of writing) inherits an unrelated failure and maintainers cannot separate it from a real regression; this PR restores the gate with a one-line import change and a byte-identical relocation.

  • Outcome basis / optional anchor: issue #6728; the gate landed in #5191 and is anchored on docs/architecture/rfcs/monorepo-distribution-split-v0.md M0 / Section 9.

  • Goal/source and gap: main carries 146 top-level modules while tests/architecture/top_level_module_budget.json pins 145, because #6703 added loopx/chat_turn_release.py without moving another module below a package root. The required Python Tests pytest shard therefore fails deterministically on unmodified main, so merge-gate is red for every PR whose Python Tests run (30 open PRs at the time of writing; docs- or presentation-only PRs that skip the Python Tests workflow are unaffected) and maintainers cannot separate an inherited failure from a real regression in a PR.

  • Observable before → after, with the validation row that proves it: at f9bdae67596c185cebc81dc555dd6a3e0242e9c5, python -m pytest -q tests/architecture/test_top_level_module_budget.py → 1 failed, 5 passed with loopx/ grew from 145 to 146 top-level modules. At this head the same command → 6 passed, the top-level count is 145, and loopx canary premerge --from-git-diff --git-diff-base upstream/main → status: passed, manual_holds: 0.

  • Issue/task and intended base: Closes #6728. Intended base: loopx-project/loopx:main at f9bdae67596c185cebc81dc555dd6a3e0242e9c5.
  • Author Declaration

  • Written by: model_agent — DeepSeek Harness (DeepSeek Flash model) at JasonBuildAI's request, under their direction and constraints.
  • Implemented against

  • Specification and revision: issue #6728 plus the existing tests/architecture/top_level_module_budget.json (max_top_level_modules: 145, baseline_commit: a4483aaece5bc74ec3f969fd067229487022401b) and the module metric ceiling for loopx/chat_runtime.py in loopx/canary/module_metric_baseline.json, both at f9bdae67596c185cebc81dc555dd6a3e0242e9c5.
  • | Criterion (spec clause) | Disposition | Symbol / path | Test or command |
    | --- | --- | --- | --- |
    | Top-level loopx/.py count must equal the pinned 145 | implemented | loopx/capabilities/native_chat/turn_release.py; loopx/chat_turn_release.py removed | python -m pytest -q tests/architecture/test_top_level_module_budget.py → 6 passed |
    | loopx/chat_runtime.py must stay inside its reviewed module-size ceiling | implemented | loopx/chat_runtime.py (import-only change) | python examples/control_plane/control-plane-maintainability-ratchet-smoke.py → ok, unreviewed: 0 |
    | The Turn-release wakeup behavior must not change | implemented | TurnReleaseWakeup moved byte-identically; only the import line changed | python -m pytest -q tests/test_lark_delivery_wakeup.py tests/test_chat_turn_wait.py → 7 passed, 2 pre-existing host failures disclosed below |

  • Self-check before submission: read the final diff (100% rename plus one import line), ran the budget and import-boundary architecture tests (35 passed), the maintainability ratchet, ruff, the semantic inventory advisory, and the project premerge canary; did not run the hosted CI suite from this Windows host, and the full local pytest/mypy results are reported with their Windows host limitations below.
  • Scope And Continuation

  • Completed scope and remaining work: the helper is a 30-line in-process Event registry whose only importer is loopx/chat_runtime.py; it has no code, test, example, doc or external reference other than that import. It moves into the existing loopx/capabilities/native_chat/ package that chat_runtime.py already imports for its native-chat companions. The class body and its comments are byte-identical, so there is no behavior change and no compatibility shim is needed. No product behavior, CLI surface, schema or vocabulary changes.

  • Slice boundary / successor: complete within this scope. If maintainers prefer a different disposition for the 146th top-level slot (for example an accepted re-pin or the wider loopx/chat_ → loopx/chat/ M1 move), #6728 records that decision; this PR is the smallest change that restores the gate without weakening either ratchet.
  • Validation

  • Tested revision: d37839b29b18c42120da1795961e4c070e7dfcdb

  • Run state: finished

  • Input classes: synthetic
  • | Check kind | Result | Public-safe evidence / limitation |
    | --- | --- | --- |
    | regression_parity | passed | python -m pytest -q tests/architecture/test_top_level_module_budget.py: 1 failed, 5 passed on unmodified f9bdae675 (146 against the 145 pin); 6 passed at this head. git diff --stat for the change is a 100% rename plus one import line. |
    | unit | passed | python -m pytest -q tests/architecture/test_top_level_module_budget.py tests/architecture/test_control_plane_import_boundaries.py tests/architecture/test_package_kernel_import_ratchet.py → 35 passed in 37.22s. |
    | unit | passed with disclosed host failures | python -m pytest -q tests/test_lark_delivery_wakeup.py tests/test_chat_turn_wait.py → 7 passed, 2 failed. Both failures are the fake POSIX codex shim on native Windows (CodexChatAgentError: executable_not_found); the same two tests fail identically on the unmodified base f9bdae675 (2 failed, 4 passed for tests/test_lark_delivery_wakeup.py alone), and tests/test_chat_session_active_turn.py passes 52 passed. |
    | static | passed | python -m ruff check loopx/chat_runtime.py loopx/capabilities/native_chat/turn_release.py → clean. python -m mypy reports 6 pre-existing Windows-only errors about os.killpg/signal.SIGKILL/os.WNOHANG in loopx/extensions/process_runtime.py and loopx/control_plane/effect_runtime.py, which this diff does not touch; hosted CI runs Linux. |
    | static | passed | python scripts/generate_semantic_inventory.py --changed-from HEAD → changed sources: 1 paths, 1 snapshots; supported candidates: 0; git diff --check clean. |
    | integration | passed | loopx canary premerge --from-git-diff --git-diff-base upstream/main → status: passed, merge_gate_passed: true, direct checks 5/5 passed, catalog canaries 10/10 passed, manual_holds: 0. self_merge_allowed: false is the repository policy, not a check failure. |

  • Coverage and gaps: hosted CI has not run yet; the full local Python suite and mypy are not clean on this cp936 Windows host independently of this diff (the 4 remaining tests/architecture failures are gbk codec errors in test fixtures that do not import the changed module, and the mypy errors are POSIX-only attributes in untouched files). The changed behavior surface is the import graph only, which the 35 architecture tests plus the 7 passing wakeup/turn tests exercise; the two failing wakeup tests are host-only and reproduce on the base.
  • Frontend / Visual Evidence

  • UI impact: none

  • Before: N/A

  • After: N/A

  • States and viewports shown: N/A

  • Source data: none

  • Attention review: N/A — no visible surface changes.

  • Craft review: N/A — no visible surface changes.
  • Type of Change

  • Bug fix

  • Refactoring (no functional changes)
  • LoopX Area

  • Build, packaging, installer, or CI
  • Technical Direction

  • Direction / acceptance reference, when applicable: docs/architecture/rfcs/monorepo-distribution-split-v0.md M0 / Section 9; related #5685 (the earlier 150-vs-147 instance, no longer reproducible) and #6703 (the introducing change).
  • Shared-authority RFC fixture impact

  • N/A — this PR does not claim progress against the TypeScript control-plane migration or the shared Goal Authority RFC and touches no fixture, protocol or provider surface.
  • Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).

  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.

  • I kept the change scoped to the linked issue/task.

  • I completed the visual evidence section for UI changes, or marked UI impact none.

  • Every commit includes a DCO Signed-off-by trailer (git commit -s).
  • AI disclosure: this change was drafted with AI assistance at JasonBuildAI's request, under their direction and constraints. An independent reviewer agent audits the exact head before handoff and records its verdict on this PR; maintainer review is requested.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: JasonBuildAI Review duration: 61m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6734"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%