Skip to content

v1.91.131.0 feat(pregate): Python import lanes (#3201) and a missing-dependencies regen diagnostic - #3252

Merged
capy-ai[bot] merged 12 commits into
mainfrom
w5-pregate-python-regen-deps
Oct 18, 2026
Merged

capy-ai[bot] merged 12 commits into
mainfrom
w5-pregate-python-regen-deps

Conversation

@garrytan

@garrytan garrytan commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Lands community PR #3201 by @scottgigante-hubflow (Python imports in the pregate import graph) on current main, and adds a missing-dependencies diagnostic to regen. Fix wave lane W5 (triage 2026-10-17).

Pregate: lanes follows Python imports (from #3201, authorship kept)

Scott's commit is cherry-picked as-is with his authorship. Main had since reworked referencesIn around resolveRefs and tsconfig path aliases, so the conflict in lib/pregate/import-graph.ts is resolved by keeping both: the Python helpers sit after main's resolvers, and a quoted literal in a Python test falls back to the dotted mock.patch target lookup only when resolveRefs finds no repo path. The test conflict keeps main's markdown case and adds the Python case.

What it adds, for .py sources:

  • import a.b, from a.b import c (also tried as the submodule a.b.c), parenthesised lists and relative from . import x / from ..pkg import y, resolved from the repo root to a/b.py or a/b/__init__.py, plus the package __init__.py files Python runs on the way in. Stdlib and site-packages modules resolve to nothing.
  • In test files, dotted literals such as 'pkg.mod.Class.method' map to the longest dotted prefix that is a repo module.
  • Strings and comments are blanked before imports are matched, so a docstring or comment that mentions an import adds no edge.

Reviewed as untrusted input: two files, a dependency-free scanner, no subprocess, no egress, no CI or dependency changes. An adversarial review (GPT-6.1 Sol, two rounds) found ways a Python file up to the 2 MB scan cap could stall graph building, and ways a test could be left unselected. Two follow-up commits fix them:

  • Strings and comments are blanked by one linear scanner that honours escapes, so an escaped triple quote no longer swallows later imports.
  • The from-import spec can no longer backtrack quadratically on long runs of dots or spaces.
  • Dotted names are bounded by the repo's deepest path, so resolution stays linear and no real module is dropped.
  • A literal that names a repo file still gets its mock.patch reading.
  • A package and a same-named module both map.
  • Imports after ; or a compound statement's : count.

Each fix has a case in test/pregate-selection.test.ts, and that case fails on the pre-fix code.

#3201 can be closed with credit once this merges.

Regen: missing dependencies are not "stale"

When package.json declares dependencies and node_modules is missing, the scratch worktree runs a generator without them. A generator that degrades and still exits 0 was reported as REGEN_STALE with "run the generator and commit", which sends people the wrong way (GSTA-31 hit this in gbrain).

gstack-regen check and the pregate regen check now report the entry as deps-missing with a new result code, REGEN_DEPS_MISSING:

regen digest: deps-missing (41 ms) — dependencies missing (no node_modules); run bun install, then rerun the check — differs without them: generated/digest.md (REGEN_DEPS_MISSING)
  • The install command follows the lockfile (bun.lock/bun.lockb → bun install, pnpm-lock.yaml, yarn.lock, package-lock.json), with bun install as the default.
  • The pregate check is incomplete (the outputs were not verified), never pass. gstack-regen exits 1 with status=incomplete.
  • A repo with no declared dependencies, or with node_modules present, behaves exactly as before, so a genuinely stale output is still REGEN_STALE.
  • The code lives in lib/result-codes-release.ts because lib/result-codes.ts is at the 800-line module ratchet. It has a docs/troubleshooting.md anchor and a note in docs/pregate.md. bin/gstack-doctor-components.sh is regenerated.

Tests

  • test/pregate-selection.test.ts: Scott's Python import-graph case, and a pregate regen case asserting REGEN_DEPS_MISSING and no REGEN_STALE (it fails on main with the stale message).
  • test/gstack-regen.test.ts: a gbrain-shaped fixture (the generator falls back without fixture-dep and exits 0) that is deps-missing, turns fresh once node_modules exists, and is still stale on a real input change with deps installed. Also covers the lockfile choice.

VERSION and CHANGELOG are not stamped; that waits for the release slot.

Open in Capy

scottgigante-hubflow and others added 2 commits October 17, 2026 16:52
The import graph only parsed JS/TS imports, so in a Python repo every
touched module failed `lanes` with PREGATE_NO_LANE even though
SOURCE_EXT, TEST_FILE_RE and the pytest runner/summary already
understood Python.

Python sources now contribute `import a.b`, `from a.b import c`
(c may be a submodule), parenthesised multi-line lists and relative
`from ..pkg import x` edges, resolved to `a/b.py` or `a/b/__init__.py`
from the repository root. Package `__init__.py` files on the path get
edges too, since Python executes them on import. Modules outside the
repo resolve to nothing. In test files, dotted string literals such as
`'pkg.mod.Class.method'` (mock.patch targets) resolve to the longest
dotted prefix that is a repo module.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…GEN_STALE

When package.json declares dependencies and node_modules is missing, the
scratch worktree runs the generator without them. A generator that degrades
and still exits 0 then looked stale, and the fix line sent people to rerun
the generator. gstack-regen check and the pregate regen check now report
"dependencies missing; run <install>" with its own result code and
troubleshooting anchor; the install command follows the lockfile. The
fixture reproduces the shape GSTA-31 saw in gbrain.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 2 commits October 17, 2026 17:15
Review of #3201 on the integrated tree found two quadratic paths on
untrusted Python source and three ways a test could be left unselected:

- The from-import module spec let two repetitions share a dot, so a
  failed match on a long run of dots backtracked quadratically. The spec
  is now dots followed by an optional word-led name.
- Dotted literals and imports resolved every prefix with repeated
  split/join. Names are capped at 32 segments, deeper than any module path.
- A literal that also named a repo file skipped its mock.patch reading;
  both readings now add edges.
- A package and a same-named module both map (Python loads the package).
- Imports after `;` or a compound statement's `:` are recognised.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…o-bounded depth

Second review round on the Python import scanner:

- An empty from-spec let the whitespace on both sides of it compete, so
  `from` followed by a long run of spaces backtracked quadratically. The
  spec now starts with a dot or a word character.
- Strings and comments are blanked by a single linear scanner that honours
  backslash escapes, so an escaped triple quote no longer ends a docstring
  early and swallows the imports after it.
- The fixed 32-segment cap dropped real deep modules. Dotted names are now
  bounded by the repo's deepest path, which no module can exceed.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

E2E Evals: ✅ PASS

[test:paid] VERDICT GREEN — lane gate/pr, attempt 1
  rule 108/108 · behavior 0/0 · judge 24/24 · quarantined 0 (0 failing the lane)
  SKIPPED 0 · INFRA 0 · INCOMPLETE 0 · unattributed 0 · ACTION REQUIRED 0
  wall 9m55s · cost $93.83 known + 54 of 132 trial(s) cost unknown

121 executed, 0 reused rule/judge records | 0 manual accepted (unscored; no score-cache credit) | $93.83 rule/judge cost | reconcile exit: 0

Profile: pr / mode dependents; selected behaviors: 108, judges: 24. Deferred to scheduled/release coverage: 139 behaviors and 0 changed prompt files. Deferred checks did not run and receive no PR-pass credit.

Derived dependents (scripts/pr-dependencies.ts):

  • bin/gstack-doctor-components.sh: 246 case(s), 24 judge(s)
  • bin/gstack-regen: 246 case(s), 24 judge(s)
  • lib/pregate/checks/regen.ts: 246 case(s), 24 judge(s)
  • lib/pregate/import-graph.ts: 246 case(s), 24 judge(s)
  • lib/regen.ts: 246 case(s), 24 judge(s)
  • lib/result-codes-release.ts: 247 case(s), 24 judge(s)
Rule and judge shards
Shard Automated result Manual/unscored Executed Reused Status Cost
e2e/skill-e2e-workflow 4/4 0 4 0 ✅ $3.3
e2e-deploy/skill-e2e-deploy--land-and-deploy-workflow 1/1 0 1 0 ✅ $1.9
e2e-safety-codex-consult/skill-e2e-safety-codex-consult 1/1 0 1 0 ✅ $0.94
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-stale-before 1/1 0 1 0 ✅ $1.17
e2e-review-attribution/skill-e2e-review-attribution 3/3 0 3 0 ✅ $0.96
e2e/skill-e2e-shared-libs--shared-libs-review-lifecycle 1/1 0 1 0 ✅ $2.49
e2e-qa-workflow/skill-e2e-qa-workflow--qa-quick 1/1 0 1 0 ✅ $1.72
e2e/skill-e2e-shared-libs-paths--shared-libs-review-prior-coverage 1/1 0 1 0 ✅ $2.54
e2e/skill-e2e-ship-skip 1/1 0 1 0 ✅ $0.66
e2e-qa-callers/skill-e2e-qa-callers--review-exploratory-small-cli 1/1 0 1 0 ✅ $1.81
e2e/skill-e2e-test-value 3/3 0 3 0 ✅ $2.45
e2e-qa-workflow/skill-e2e-qa-workflow--qa-only-no-fix 1/1 0 1 0 ✅ $1.63
e2e-qa-callers/skill-e2e-qa-callers--ship-exploratory-plan-checks 1/1 0 1 0 ✅ $1.85
e2e/skill-e2e-shared-libs--shared-libs-review-revalidation 1/1 0 1 0 ✅ $5.13
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-recovery 1/1 0 1 0 ✅ $0.93
e2e-review/skill-e2e-review 2/2 0 2 0 ✅ $1.28
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-failure 1/1 0 1 0 ✅ $1.98
e2e-skillify/skill-e2e-skillify 3/3 0 3 0 ✅ $2.07
e2e/skill-e2e-shared-libs-paths--shared-libs-review-path-eligibility 1/1 0 1 0 ✅ $3.98
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-current 1/1 0 1 0 ✅ $3.34
llm-judge/skill-llm-eval 24/24 0 24 0 ✅ $1.44
e2e/skill-e2e-coverage-audit 2/2 0 2 0 ✅ $0.77
e2e-deploy/skill-e2e-deploy--setup-deploy-workflow 1/1 0 1 0 ✅ $0.38
e2e-review-army/skill-e2e-review-army--review-army-perf-n-plus-one 1/1 0 1 0 ✅ $1.1
e2e/skill-e2e-shared-libs-paths--shared-libs-review-index-flags 1/1 0 1 0 ✅ $2.75
e2e/skill-e2e-investigate-owned-completion 1/1 0 1 0 ✅ $0.21
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-late-result 1/1 0 1 0 ✅ $0.92
e2e-review-army/skill-e2e-review-army--review-army-json-findings 1/1 0 1 0 ✅ $0.23
e2e-deploy/skill-e2e-deploy--benchmark-workflow 1/1 0 1 0 ✅ $0.63
e2e-qa-callers/skill-e2e-qa-callers--ship-exploratory-small-cli 1/1 0 1 0 ✅ $2.02
e2e-learnings/skill-e2e-learnings 1/1 0 1 0 ✅ $0.25
e2e-deploy/skill-e2e-deploy--land-and-deploy-review-gate 1/1 0 1 0 ✅ $1.4
e2e-review-army/skill-e2e-review-army--review-army-migration-safety 1/1 0 1 0 ✅ $1.16
e2e/skill-e2e-shared-libs--shared-libs-read-only 1/1 0 1 0 ✅ $0.7
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-stale-after 1/1 0 1 0 ✅ $0.98
e2e-deploy/skill-e2e-deploy--land-and-deploy-first-run 1/1 0 1 0 ✅ $1.1
e2e-docsync-spawned/skill-e2e-docsync-spawned 1/1 0 1 0 ✅ $1.2
e2e-qa-functional-fix/skill-e2e-qa-functional-fix 2/2 0 2 0 ✅ $3.35
e2e/skill-e2e-plan--plan-review-report 1/1 0 1 0 ✅ $1.13
e2e-qa-callers/skill-e2e-qa-callers--ship-exploratory-unavailable 1/1 0 1 0 ✅ $1.87
e2e-retro/skill-e2e-retro 1/1 0 1 0 ✅ $1.33
e2e-qa-functional/skill-e2e-qa-functional 2/2 0 2 0 ✅ $2.48
e2e-qa-callers/skill-e2e-qa-callers--ship-exploratory-late-input 1/1 0 1 0 ✅ $2.36
e2e-cso/skill-e2e-cso 1/1 0 1 0 ✅ $1.49
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-store 1/1 0 1 0 ✅ $3.87
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-completion 1/1 0 1 0 ✅ $3.82
e2e-design/skill-e2e-design--design-review-detector-shim-dom 1/1 0 1 0 ✅ $0.75
e2e/skill-e2e-shared-libs--shared-libs-unsupported-git 1/1 0 1 0 ✅ $0.46
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-missing-asset 1/1 0 1 0 ✅ $1.23
e2e-review-army/skill-e2e-review-army--review-army-quality-score 1/1 0 1 0 ✅ $0.42
e2e-safety-ship-evidence/skill-e2e-safety-ship-evidence 1/1 0 1 0 ✅ $0.75
e2e-hermetic/skill-e2e-hermetic-canary 2/2 0 2 0 ✅ $0.03
e2e-design/skill-e2e-design--design-review-plugin-handoff 1/1 0 1 0 ✅ $0.45
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-missing-marker 1/1 0 1 0 ✅ $0.48
e2e-browse/skill-e2e-bws 6/6 0 6 0 ✅ $0.85
e2e-third-party-actions/skill-e2e-third-party-actions 5/5 0 5 0 ✅ $1.19
e2e-plan-tune/skill-e2e-plan-tune 1/1 0 1 0 ✅ $0.49
e2e-session-intelligence/skill-e2e-session-intelligence 4/4 0 4 0 ✅ $0.78
e2e-safety-pair-agent/skill-e2e-safety-pair-agent 1/1 0 1 0 ✅ $0.3
e2e-design/skill-e2e-design--design-review-detector-shim 1/1 0 1 0 ✅ $0.35
e2e-qa-workflow/skill-e2e-qa-workflow--qa-bootstrap 1/1 0 1 0 ✅ $0.21
e2e-triage/skill-e2e-triage 1/1 0 1 0 ✅ $0.47
e2e/skill-e2e-ship-hook-consent 2/2 0 2 0 ✅ $0.68
e2e-review-army/skill-e2e-review-army--review-army-delivery-audit 1/1 0 1 0 ✅ $0.37
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-timeout-unsettled 1/1 0 1 0 ✅ $0.56
e2e/skill-e2e-ship-hook-refresh 1/1 0 1 0 ✅ $0.27
e2e/skill-e2e-investigate-owned-termination 2/2 0 2 0 ✅ $0.49
e2e-ship-docsync/skill-e2e-ship-docsync--ship-docsync-launch-failure 1/1 0 1 0 ✅ $0.47
e2e-deploy/skill-e2e-deploy--canary-workflow 1/1 0 1 0 ✅ $0.37
e2e-design/skill-e2e-design--plan-design-review-no-ui-scope 1/1 0 1 0 ✅ $0.34
Fail-closed reconciliation
shared-libs-unsupported-git
  slice 13  passed             69s  test/skill-e2e-office-hours-auto-mode.test.ts
  slice 13  passed             66s  test/skill-e2e-design.test.ts#design-review-plugin-handoff
  slice 13  passed             64s  test/skill-e2e-bws.test.ts
  slice 13  passed             57s  test/skill-e2e-ship-docsync.test.ts#ship-docsync-missing-marker
  slice 13  passed             62s  test/skill-e2e-review-army.test.ts#review-army-quality-score
  slice 13  passed              7s  test/skill-e2e-hermetic-canary.test.ts
  slice 14  passed             67s  test/skill-e2e-third-party-actions.test.ts
  slice 14  passed             63s  test/skill-e2e-plan-tune.test.ts
  slice 14  passed             51s  test/skill-e2e-triage.test.ts
  slice 14  passed             73s  test/skill-e2e-ship-docsync.test.ts#ship-docsync-timeout-unsettled
  slice 14  passed             42s  test/skill-e2e-ask-user-question-format-compliance.test.ts
  slice 14  passed             46s  test/skill-e2e-ship-docsync.test.ts#ship-docsync-launch-failure
  slice 14  passed             51s  test/skill-e2e-session-intelligence.test.ts
  slice 14  passed             50s  test/skill-e2e-ship-hook-consent.test.ts
  slice 14  passed             28s  test/skill-e2e-investigate-owned-termination.test.ts
  slice 14  passed             40s  test/skill-e2e-design.test.ts#design-review-detector-shim
  slice 14  passed             45s  test/skill-e2e-deploy.test.ts#canary-workflow
  slice 14  passed             41s  test/skill-e2e-ship-hook-refresh.test.ts
  slice 14  passed             45s  test/skill-e2e-design.test.ts#plan-design-review-no-ui-scope
  slice 14  passed             37s  test/skill-e2e-review-army.test.ts#review-army-delivery-audit
  slice 14  passed             40s  test/skill-e2e-safety-pair-agent.test.ts
  slice 14  passed             26s  test/skill-e2e-qa-workflow.test.ts#qa-bootstrap
  slice 15  passed             32s  test/skill-e2e-learnings.test.ts
  slice 15  passed             30s  test/skill-e2e-diagram.test.ts
[test:paid] collector final outcomes: 121 executed, 0 reused; 121 passed, 0 failed, 0 manual accepted (unscored; no score-cache credit) (121 attempt records from 70 collectors; every record counts)
[test:paid] deselected testcases, zero credit (312):
[test:paid]    298  sibling case of a case shard (its own shard runs it)
[test:paid]      8  periodic-tier case (this lane runs gate)
[test:paid]      6  Bun hook placeholder of a skipped describe block (not a test)
[test:paid] VERDICT GREEN — lane gate/pr, attempt 1
  rule 108/108 · behavior 0/0 · judge 24/24 · quarantined 0 (0 failing the lane)
  SKIPPED 0 · INFRA 0 · INCOMPLETE 0 · unattributed 0 · ACTION REQUIRED 0
  wall 9m55s · cost $93.83 known + 54 of 132 trial(s) cost unknown
[test:paid] exercised-path map (shadow, non-blocking): 6 MAP_GAP line(s) over 100 executed case(s) with recorded commands
  MAP_GAP document-release bin/gstack-banned-terms: non-blocking for this PR; the next census refresh widens the map (docs/TESTING_INTERNALS.md#exercised-path-map)
  MAP_GAP review-army-migration-safety bin/gstack-approval-classes: non-blocking for this PR; the next census refresh widens the map (docs/TESTING_INTERNALS.md#exercised-path-map)
  MAP_GAP review-gate-integrity bin/gstack-approval-classes: non-blocking for this PR; the next census refresh widens the map (docs/TESTING_INTERNALS.md#exercised-path-map)
  MAP_GAP review-gate-integrity bin/gstack-banned-terms: non-blocking for this PR; the next census refresh widens the map (docs/TESTING_INTERNALS.md#exercised-path-map)
  MAP_GAP review-gate-integrity bin/gstack-contributor-mode: non-blocking for this PR; the next census refresh widens the map (docs/TESTING_INTERNALS.md#exercised-path-map)
  MAP_GAP review-gate-integrity bin/gstack-pregate: non-blocking for this PR; the next census refresh widens the map (docs/TESTING_INTERNALS.md#exercised-path-map)
[test:paid] report: every planned shard accounted and passed

Sliced lane: planner → duration-packed executors → fail-closed report. Behavior cases run a pre-registered 3-trial panel (PASS at 2/3 with no contract violation); a PASS 2/3 is shown with its failed trial, never as a clean pass. Reused results retain their original provenance and expiry.

garrytan and others added 3 commits October 17, 2026 17:48
…EPS_MISSING

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions github-actions Bot changed the title feat(pregate): Python import lanes (#3201) and a missing-dependencies regen diagnostic v1.91.126.0 feat(pregate): Python import lanes (#3201) and a missing-dependencies regen diagnostic Oct 17, 2026
garrytan and others added 5 commits October 17, 2026 21:01
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…en-deps

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
…ve 1.91.127.0)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…en-deps

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions github-actions Bot changed the title v1.91.126.0 feat(pregate): Python import lanes (#3201) and a missing-dependencies regen diagnostic v1.91.131.0 feat(pregate): Python import lanes (#3201) and a missing-dependencies regen diagnostic Oct 18, 2026
@capy-ai
capy-ai Bot merged commit 8f103ba into main Oct 18, 2026
70 checks passed
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.

2 participants