Skip to content

fix(prepare-pr): bound green_age package-above-module import overlap to the direct parent - #14867

Merged
bolichen97 merged 1 commit into
mainfrom
fix/green-age-overlap-bound-12389
Sep 29, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/green-age-overlap-bound-12389

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: green_age.py stops calling a file an import-overlap just because it imports the shared root package.

_imports_touch treats an imported package as reaching every changed module below it, at any depth. Every file with from kiro_crew import X yields the bare token kiro_crew, so it "imports" every changed module in the repo. On PR #12178 this produced 85 false import overlaps and a STALE verdict (exit 30).

Why it matters

A false STALE tells the author to rebase and push again. On a fast-moving main that rebase goes stale within minutes, every new head re-rolls the review lanes, and on a PR carrying a commit-bound override it voids the override.

Not a goal

  • Changing the module-below-package direction (importing kiro_crew.ledger.store still reaches a changed kiro_crew/ledger/__init__.py, because importing a submodule runs its parents).
  • Changing the same-dir, test-stem or path overlap classes.

What changed (motivation → approach → change)

Root cause: the package-above-module match was changed.startswith(target + "."), which is true for every ancestor package, including kiro_crew itself.

Import of a package above the changed module Before After
bare root kiro_crew match no match
the module's own parent package match match
a deeper ancestor whose __init__.py imports toward it (a facade) match match
a deeper ancestor that does not match no match

A deeper package now counts only when its own __init__.py on the base, read through the same read_moved blob reader, imports toward the changed module. That keeps facades such as kiro_crew.subagent_manager re-exporting admission as real dependencies. A top-level token never reaches a module; its real names match exactly.

imported_modules now reads a parenthesized from X import ( across lines to its close paren, so from kiro_crew import (\n model_registry,\n) binds kiro_crew.model_registry. Before, only the bare root token was bound, and the root token no longer matches. A trailing # comment on an import line no longer hides the name before it.

classify_overlap reads each blob at most once per run, so following a facade's __init__.py costs one git show per package, not one per changed module.

Backwards compatibility

Compatible: the script only reports fewer overlaps; the documented case (import kiro_crew.ledger, changed kiro_crew/ledger/store.py) still matches.

Tests

test/test_prepare_pr_green_age.py:

  • test_a_package_import_reaches_its_direct_child_module: importing a module's own package still overlaps.
  • test_an_ancestor_package_import_does_not_reach_a_grandchild_module: the root token and a grandparent no longer match.
  • test_the_root_package_token_does_not_reach_a_top_level_module: bare kiro_crew misses kiro_crew.security; the exact import still matches.
  • test_a_facade_package_reaches_the_deep_module_its_init_re_exports: a package whose __init__.py imports .admission reaches admission.gate; without that import it does not.
  • test_a_parenthesized_import_binds_every_name_across_lines: a multi-line import with a comment binds each name.
  • test_an_inline_comment_does_not_drop_the_imported_name: from kiro_crew import agent # ... still binds kiro_crew.agent.
  • test_each_blob_is_read_at_most_once_per_run: two moved callers of one facade read its __init__.py once.

Each new rule was mutation-checked: disabling the facade read, the multi-line read, the comment strip, the read-once cache, or the root guard turns exactly its own test red.

Manual verification

N/A — unit coverage sufficient; the change is one pure string predicate.

Related Issues

Closes #12389

Pattern harvest

Not generalizable: a one-off unbounded prefix match in one script's import matcher; the sibling same-dir class already has its own bound.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested a review from a team as a code owner September 28, 2026 23:42
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 85cc69579b839808ff4ecbbeb00ee73b2ac33123 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 85cc695

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 85cc69579b839808ff4ecbbeb00ee73b2ac33123: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 85cc69579b839808ff4ecbbeb00ee73b2ac33123 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify the reported repro: on PR #12178's file set the bounded matcher plus facade-follow should now yield FRESH without dropping the real overlaps.

What this change ships

Inventory (6 items) — 6 justified

Intent: stop the prepare-pr freshness gate calling every file an import-overlap for importing the shared root package — a FIX (repro on PR #12178, closes #12389).

  1. A bare kiro_crew import no longer overlaps any changed module — justified
  2. A deeper ancestor package import overlaps only the changed module's direct parent — justified
  3. A deeper package still overlaps when its __init__.py chain imports toward the changed module (3 such facade __init__.py files, 16 re-export imports counted under src/kiro_crew/*/__init__.py) — justified
  4. Multi-line parenthesized from X import (…) now binds each name, so real overlaps survive the root-token removal — justified
  5. An inline # comment no longer drops the imported name before it — justified
  6. Each base blob is read at most once per run — justified

[FIRST-PRINCIPLES-REVIEWED] 85cc695

Description read

[DESCRIPTION-READ] ba738f3e20c27747f614ce35e5c2255dd96e89fb50ea12fc945122c71a554bc4

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 85cc69579b839808ff4ecbbeb00ee73b2ac33123 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify the fix against PR #12178's actual file set — the 85-overlap repro is cited but only synthetic fixtures are tested.

[DESIGN-REVIEWED] 85cc695

Description read

[DESCRIPTION-READ] e408d770008acab0046956bed0912e804381e9394f8e407fa9d63ff13d90f476

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 85cc69579b839808ff4ecbbeb00ee73b2ac33123 — this comment is updated in place on each push.

Review details

Advisory only: no blocking defect — the new parenthesized-import scan locates the closing paren before stripping comments, so a ) inside a continuation-line comment truncates the name list in the false-FRESH direction.

FINDING — src/kiro_crew/builtin_skills/kirocrew-dev/prepare-pr/scripts/green_age.py:233 — close = text.find(")", m.end()) runs before the re.sub(r"#[^\n]*", "", …) that strips comments, so in a multi-name block like from kiro_crew import (\n sel, # circular import (see note)\n agent,\n) the search stops at the ) inside the comment and every name after that line is never bound; with the broad changed.startswith(target + ".") match removed in the same hunk, kiro_crew.agent no longer reaches a changed src/kiro_crew/agent.py, so classify_overlap emits no import row and main exits EXIT_FRESH → Fix: strip comments from the whole tail first, then cut at the paren — tail = re.sub(r"#[^\n]*", "", text[m.end():]); end = tail.find(")"); names += tail if end == -1 else tail[:end].

[OPUS-REVIEWED] 85cc695

Verdict parsed from the review's SHA-scoped output markers for commit 85cc69579b839808ff4ecbbeb00ee73b2ac33123.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 85cc69579b839808ff4ecbbeb00ee73b2ac33123: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 29, 2026
@iamwhatever
iamwhatever force-pushed the fix/green-age-overlap-bound-12389 branch from 8c09699 to 3d3ef90 Compare September 29, 2026 00:46
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 29, 2026
@iamwhatever
iamwhatever force-pushed the fix/green-age-overlap-bound-12389 branch from 3d3ef90 to 023b3f6 Compare September 29, 2026 01:10
@iamwhatever
iamwhatever force-pushed the fix/green-age-overlap-bound-12389 branch from 023b3f6 to 85cc695 Compare September 29, 2026 01:34
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 29, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed on behalf of the maintainers (readiness sweep 2026-09-29): readiness passed, the required PR Readiness check is green on this head, no live CHANGES_REQUESTED, no open blocking review threads; where the PR's files also moved on main since its merge-base, the PR's own tests were run on the main+PR merge tree and passed. Approving and squash-merging.

@bolichen97
bolichen97 merged commit 956dde4 into main Sep 29, 2026
101 of 109 checks passed
@bolichen97
bolichen97 deleted the fix/green-age-overlap-bound-12389 branch September 29, 2026 04:29
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(prepare-pr): green_age reports import-class overlap through a shared root package, so any module under src/kiro_crew matches 389 unrelated files

2 participants