Skip to content

feat(economy): add Y-band partition for leaf cells under --attribute - #5190

Merged
loom-fleet-dispatch[bot] merged 4 commits into
mainfrom
feature/issue-5189
Nov 9, 2026
Merged

loom-fleet-dispatch[bot] merged 4 commits into
mainfrom
feature/issue-5189

Conversation

@loom-fleet-dispatch

@loom-fleet-dispatch loom-fleet-dispatch Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

klt economy --attribute on a leaf cell (no child instances) now adds an additive attribution.bands[]: a Y-axis partition of the bbox into full-width bands keyed by which drawn layers occupy them.

Changes

  • src/klayout_tools/economy.py: new _leaf_bands helper, called from _attribution_block only when the top cell has no instances.
  • docs/cli/economy.md: documents bands[].
  • tests/test_economy.py: leaf bands, single-layer, and has-children cases.

Acceptance Criteria Verification

  • bands[] with bbox_um, area_um2, layers, drawn_area_um2 (tested).
  • Equal-set neighbours merged; areas sum to bbox in integer dbu² (tested).
  • Cells with children have no bands (tested); existing fields unchanged.
  • Annotation layers excluded (same annotation_pairs filter).
  • Docs updated.

Test Plan

TDD: tests written alongside the change; pytest tests/test_economy.py passes (all), ruff check/format clean. Empty-bbox cell returns no bands. Live CLI run on a real GDS not performed; covered via economy_report in tests.

Closes #5189

🤖 Generated with Claude Code

loom dashboard

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@loom-fleet-dispatch loom-fleet-dispatch Bot added the loom:review-requested PR ready for Judge to review. Applied by: Builder when opening PR. label Nov 9, 2026
@loom-fleet-dispatch

loom-fleet-dispatch Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

PR #5190's loom:reviewing claim is held by the judge of sweep step-judge-5190-1794254938 on host host-7ec0fa4c. This comment is a PR lease record (#9401): its liveness signal is its own forge-assigned updated_at, renewed while the judge works and released when it is done. Another judge that finds this lease live stands down before touching a worktree. See defaults/docs/lease-record.md § "PR-phase leases".

@loom-fleet-dispatch loom-fleet-dispatch Bot added the loom:reviewing Judge is reviewing this PR. Applied by: Judge only. Stale after LOOM_STALE_REVIEWING_MINUTES (30m). label Nov 9, 2026
@loom-fleet-dispatch

Copy link
Copy Markdown
Contributor Author

❌ Changes Requested — CI Lint (ruff) is red; I reproduced it locally (ruff check/format themselves pass; the ratchet steps in the same job fail).

Blocking (reproduced with scripts/check_complexity_baseline.py and scripts/check_file_size_baseline.py --comparison-rev $(git merge-base HEAD origin/main)):

  1. Complexity ratchet: src/klayout_tools/economy.py: _leaf_bands is too complex (16 > 10) and is not in complexity-baseline.json. The issue's guidance asked for a small helper to respect this ratchet. Split it, e.g. region collection, Y-edge collection, per-strip layer set, and strip merging as separate helpers.
  2. Per-file size ratchet: economy.py grew 922 → 993 lines (ceiling 922) and tests/test_economy.py grew 1062 → 1107 (ceiling 1062). The checker requires shrinking back to the trusted ceiling, so raising the baseline in the PR is not accepted. Moving the band logic into a new small module (e.g. economy_bands.py, classified in import-boundaries.json) and the new tests into a new test file would avoid growing either governed file. Check the import-boundaries policy for the new module.

Code review otherwise (not blocking): logic matches the acceptance criteria. Strips come from merged-polygon vertex Y edges, equal-set neighbours are merged, areas are integer dbu², annotation layers are excluded, bands is gated on child_instances() == 0, and the docs row is present. Tests cover the leaf case, a single layer and the has-children case. The empty-bbox case in the PR's Test Plan is not exercised by a test (not measured here beyond the early bbox.empty() return in the code). Tests (Python 3.x) were still pending when I reviewed; I did not run them locally.

Closes #5189 is present and correct. Spec reconciliation: reviewed against issue #5189's current body and Curator comment; no material differences found.

loom dashboard

@loom-fleet-dispatch loom-fleet-dispatch Bot added loom:changes-requested PR requires changes before re-review (Judge requested modifications). Applied by: Judge. and removed loom:review-requested PR ready for Judge to review. Applied by: Builder when opening PR. loom:reviewing Judge is reviewing this PR. Applied by: Judge only. Stale after LOOM_STALE_REVIEWING_MINUTES (30m). labels Nov 9, 2026
@loom-fleet-dispatch

loom-fleet-dispatch Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

PR #5190's loom:treating claim is held by the doctor of sweep step-doctor-5190-1794255145 on host host-a6032f0c. This comment is a PR lease record (#9401): its liveness signal is its own forge-assigned updated_at, renewed while the doctor works and released when it is done. Another doctor that finds this lease live stands down before touching a worktree. See defaults/docs/lease-record.md § "PR-phase leases".

@loom-fleet-dispatch loom-fleet-dispatch Bot added the loom:treating Doctor is fixing this bug or PR. Applied by: Doctor. Stale after LOOM_STALE_TREATING_MINUTES (60m). label Nov 9, 2026
loom-fleet-dispatch Bot and others added 2 commits November 9, 2026 20:13
…#5189)

- Break _leaf_bands (complexity 16) into small helpers in new economy_bands.py
- Move gap-position helpers to economy_leaves.py so economy.py shrinks below its ceiling
- Move band tests to tests/test_economy_bands.py (test_economy.py back to main), add empty-bbox test
- Classify economy_bands in import-boundaries.json; tighten file-size baseline

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@loom-fleet-dispatch

Copy link
Copy Markdown
Contributor Author

🩺 Doctor handoff — per-finding status at 79eeda0 (Judge review on 2e550f3):

  • Complexity ratchet, _leaf_bands 16 > 10: fixed. Split into _layer_regions, _strip_edges, _strip_layers, _merge_strips and leaf_bands in new src/klayout_tools/economy_bands.py. check_complexity_baseline.py passes.
  • Per-file size ratchet, economy.py and tests/test_economy.py: fixed. economy.py is 870 lines (was 922; main is 914), and the ceiling in file-size-baseline.json is tightened to 870. tests/test_economy.py is identical to origin/main. The new tests live in tests/test_economy_bands.py. check_file_size_baseline.py --comparison-rev origin/main passes.
  • New module classification: economy_bands is added to the economy group in import-boundaries.json. check_import_boundaries.py passes.
  • Missing empty-bbox test: fixed at tests/test_economy_bands.py:69.
  • Extra instances beyond those cited: to get economy.py under its ceiling, I moved the three gap-position helpers (_margin_edges, _single_neighbour_position, _gap_position) to economy_leaves.py, with gap_position now public. They have no other callers.
  • Also merged origin/main (clean, no conflicts).

Local: ruff check/format are clean, and test_economy.py, test_economy_flatten.py and test_economy_bands.py pass. CI had not settled on the new head at hand-off. Judge decides independently. Ready for re-review.

loom dashboard

@loom-fleet-dispatch loom-fleet-dispatch Bot added loom:review-requested PR ready for Judge to review. Applied by: Builder when opening PR. and removed loom:treating Doctor is fixing this bug or PR. Applied by: Doctor. Stale after LOOM_STALE_TREATING_MINUTES (60m). loom:changes-requested PR requires changes before re-review (Judge requested modifications). Applied by: Judge. labels Nov 9, 2026
@loom-fleet-dispatch

loom-fleet-dispatch Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

PR #5190's loom:reviewing claim is held by the judge of sweep step-judge-5190-1794257406 on host host-7ec0fa4c. This comment is a PR lease record (#9401): its liveness signal is its own forge-assigned updated_at, renewed while the judge works and released when it is done. Another judge that finds this lease live stands down before touching a worktree. See defaults/docs/lease-record.md § "PR-phase leases".

@loom-fleet-dispatch loom-fleet-dispatch Bot added the loom:reviewing Judge is reviewing this PR. Applied by: Judge only. Stale after LOOM_STALE_REVIEWING_MINUTES (30m). label Nov 9, 2026
@loom-fleet-dispatch

Copy link
Copy Markdown
Contributor Author

Judge: merged origin/main into the branch to resolve a trivial additive conflict in import-boundaries.json (kept both economy_bands and economy_footprint). Re-reviewing at the new head.

@loom-fleet-dispatch

Copy link
Copy Markdown
Contributor Author

Judge: code review found no blockers at 981340f (merged origin/main to resolve an additive import-boundaries.json conflict; economy/footprint/flatten tests, ruff, import-boundary and file-size ratchets pass locally). The Python 3.11-3.14 test jobs had not settled after a bounded ~20 min wait, so I'm releasing without a verdict; a later pass will approve once CI is green.

@loom-fleet-dispatch loom-fleet-dispatch Bot removed the loom:reviewing Judge is reviewing this PR. Applied by: Judge only. Stale after LOOM_STALE_REVIEWING_MINUTES (30m). label Nov 9, 2026
@loom-fleet-dispatch

loom-fleet-dispatch Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

PR #5190's loom:reviewing claim is held by the judge of sweep step-judge-5190-1794259566 on host host-7ec0fa4c. This comment is a PR lease record (#9401): its liveness signal is its own forge-assigned updated_at, renewed while the judge works and released when it is done. Another judge that finds this lease live stands down before touching a worktree. See defaults/docs/lease-record.md § "PR-phase leases".

@loom-fleet-dispatch loom-fleet-dispatch Bot added the loom:reviewing Judge is reviewing this PR. Applied by: Judge only. Stale after LOOM_STALE_REVIEWING_MINUTES (30m). label Nov 9, 2026
@loom-fleet-dispatch

Copy link
Copy Markdown
Contributor Author

✅ Approved!

Spec reconciliation: reviewed against current issue #5189 body (no material differences from the PR scope; Y bands only, no new flag, as the issue specifies). Linked via Closes #5189.

  • leaf_bands (src/klayout_tools/economy_bands.py) builds per-layer merged regions, cuts strips at merged-polygon vertex Y edges, merges equal-layer-set neighbours; integer dbu² so bands sum to the bbox. Annotation pairs excluded; bands only added when child_instances() == 0; empty bbox returns [].
  • The gap-position helpers moved verbatim to economy_leaves.py (gap_position), behaviour unchanged.
  • Tests (tests/test_economy_bands.py): I ran it locally in the PR worktree, 4 passed; exact-head CI is green. Covers two-row layout with empty channel, single layer, children-absent, empty bbox.
  • Test Plan: live CLI run on a real GDS was not performed (disclosed by the Builder, not re-run by me). No TDD: yes path claimed, so no merge-base run was done.
  • Minor note (non-blocking): the PR body still says changes are in economy.py::_leaf_bands and tests/test_economy.py; the code actually lives in the new economy_bands.py and tests/test_economy_bands.py.

Formal review reconciliation (#7647) — check-review-feedback.sh reported NEEDS_RECONCILIATION: 1 formal review(s) and comment verdict(s), 0 outstanding at this head, 1 at an older head, 0 unresolved inline thread(s) (resolution source: graphql).

Review/verdict 6750275827 (changes-requested at 2e550f3: Lint ratchet steps red) is fixed: leaf-band code moved to src/klayout_tools/economy_bands.py, file-size-baseline.json:284 lowered to 870 and import-boundaries.json:153 lists economy_bands; exact-head CI is now green. Nothing remains open.

loom dashboard

@loom-fleet-dispatch loom-fleet-dispatch Bot added loom:pr PR approved by Judge, ready for Champion auto-merge. Applied by: Judge. and removed loom:review-requested PR ready for Judge to review. Applied by: Builder when opening PR. loom:reviewing Judge is reviewing this PR. Applied by: Judge only. Stale after LOOM_STALE_REVIEWING_MINUTES (30m). labels Nov 9, 2026
@loom-fleet-dispatch

loom-fleet-dispatch Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

PR #5190's (no label: the lease is the claim) claim is held by the champion of sweep step-champion_merge-5190-1794259704 on host host-a6032f0c. This comment is a PR lease record (#9401): its liveness signal is its own forge-assigned updated_at, renewed while the champion works and released when it is done. Another champion that finds this lease live stands down before touching a worktree. See defaults/docs/lease-record.md § "PR-phase leases".

@loom-fleet-dispatch

Copy link
Copy Markdown
Contributor Author

Champion Auto-Merge

This PR meets all safety criteria for automatic merging:

  • Judge approved (loom:pr label, verdict anchored to head 981340f)
  • Merge-risk judgment passed: additive, read-only analysis feature (new bands[] field under --attribute for leaf cells), a verbatim helper move, and ratchet-baseline updates; covered by new tests; fully revertable
  • Diff size: 283 lines (+230/-53) — informational, not a gate
  • No critical files modified
  • No merge conflicts
  • Updated recently (0 hours ago)
  • All CI checks passing

Proceeding with merge... If this was merged in error, you can revert with:
git revert -m 1 <merge-sha>


Automated by Champion role

loom dashboard

@loom-fleet-dispatch
loom-fleet-dispatch Bot merged commit 0c82bc5 into main Nov 9, 2026
24 checks passed
@loom-fleet-dispatch
loom-fleet-dispatch Bot deleted the feature/issue-5189 branch November 9, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

loom:pr PR approved by Judge, ready for Champion auto-merge. Applied by: Judge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

klt economy --attribute: no decomposition for a leaf cell (no child instances)

0 participants