Trim controller.py prose, pass 2: 3723 → 3186 (−537)#633
Merged
Conversation
The first pass cut method-level docstrings but left the inline ``# explain what this line does`` paragraphs intact — which were the actual wall-of-text problem. This pass strips those (per CLAUDE.md's "don't explain WHAT the code does" rule) across the largest methods: * ``__init__`` attribute-explainer comments collapsed to one or two lines each — the well-named attributes already say what each is for. 208 → 110 lines. * ``start`` lost the 6-8 line preludes before every block. 183 → 78 lines. * ``stop`` lost the per-drain rationale paragraphs the ``_drain_tasks`` helper already encodes. 99 → 44 lines. * ``request_pair`` body: dropped the "APPROVED here means …" / "sweep stale entry …" / "re-pair against same pin …" / per-line PENDING-vs-APPROVED preludes. 140 → 97 lines. * ``unpair`` lost the per-clear-call rationale paragraphs. 89 → 24 lines. * ``_apply_pair_status_result`` lost the inline preludes on each terminal branch. 117 → 88 lines. * ``record_pair_request`` lost the receiver-side pair-request branch explainers + the 11-line PENDING-entry refresh explanation. 106 → 78 lines. * ``submit_job`` / ``register_peer_link_session`` / ``set_settings`` / ``rotate_identity`` / ``set_pairing_window`` / ``_run_cleanup_loop`` similarly trimmed. * Module-level constant explainers (the 8-line cleanup-sweep cadence comment, the 6-line debounce-window comment, the 10-line resolve-timeout comment, etc.) reduced to one or two lines each. Net: prose-to-code ratio drops to ~1:1 (was ~2:1 originally, 1.4:1 after pass 1). Kept the WHY-style notes (post-fix bug refs like the #568 cold-connect regression, hidden invariants like "fire AFTER the dict insert", surprising orderings like the snapshot-list-before-iterate guard). Behaviour preserving — no code lines changed; only comment and docstring lines removed. All 3117 tests pass.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR further reduces the “wall-of-text” in RemoteBuildController by trimming inline explanatory prose and condensing docstrings, aligning the file more closely with the comment style guidance in CLAUDE.md (focus on why and invariants vs. narrating what the code does).
Changes:
- Collapsed/removed large inline comment blocks and constant explainers across
controller.py. - Condensed several lifecycle and remote-build flow docstrings to shorter summaries while keeping key invariants/security rationale notes.
- Left runtime logic unchanged (documentation-only refactor).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #633 +/- ##
=======================================
Coverage 99.21% 99.21%
=======================================
Files 90 90
Lines 10757 10757
=======================================
Hits 10673 10673
Misses 84 84
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
16 tasks
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.
What does this implement/fix?
Pass 1 (#630) cut method-level docstrings but left the inline
# explain what this line doesparagraphs intact — which werethe actual wall-of-text problem. This pass strips those per
CLAUDE.md's "don't explain WHAT the code does, since
well-named identifiers already do that" rule.
controller.py: 3723 → 3186 lines (−537).Prose-to-code ratio: ~1.4:1 → ~1:1 (was ~2:1 in the
pre-trim original).
Concretely
__init__: attribute-explainer comments collapsed toone or two lines each — the well-named attributes already
say what each holds. 208 → 110 lines.
start: lost the 6-8 line preludes before every block.183 → 78 lines.
stop: lost the per-drain rationale paragraphs thatthe
_drain_taskshelper already encodes. 99 → 44 lines.request_pair: dropped the "APPROVED here means…","sweep stale entry…", "re-pair against same pin…" preludes
before each near-self-explanatory block. 140 → 97 lines.
unpair: lost the per-clear-call rationaleparagraphs. 89 → 24 lines.
_apply_pair_status_result: lost the inline preludeson each terminal branch. 117 → 88 lines.
record_pair_request: lost the receiver-side branchexplainers + the 11-line PENDING-entry refresh
explanation. 106 → 78 lines.
submit_job/register_peer_link_session/set_settings/rotate_identity/set_pairing_window/
_run_cleanup_loop: similarly trimmed.cleanup-sweep cadence comment, the 6-line debounce-window
comment, the 10-line resolve-timeout comment, etc.)
reduced to one or two lines each.
What was kept
The WHY-style notes per CLAUDE.md:
regression in
register_peer_link_session).subscriber lookups see the just-registered session").
iterating — each terminate mutates the dict").
caveat on
cleanup_ttl_seconds).same-dashboard_id-different-pubkey refusal in
record_pair_request).Behaviour preservation
No code lines changed; only comment and docstring lines
removed. All 3117 tests pass.
Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.jsonhas not been hand-edited (regenerate viascript/sync_components.pyif a sync is needed).docs/ARCHITECTURE.mdand/ordocs/API.md.