Repository navigation
v1.91.131.0 feat(pregate): Python import lanes (#3201) and a missing-dependencies regen diagnostic - #3252
Merged
Conversation
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>
|
😎 This pull request was merged. |
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>
Contributor
E2E Evals: ✅ PASS121 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 Derived dependents (scripts/pr-dependencies.ts):
Rule and judge shards
Fail-closed reconciliationSliced 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. |
…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>
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>
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.
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:
lanesfollows Python imports (from #3201, authorship kept)Scott's commit is cherry-picked as-is with his authorship. Main had since reworked
referencesInaroundresolveRefsand tsconfig path aliases, so the conflict inlib/pregate/import-graph.tsis resolved by keeping both: the Python helpers sit after main's resolvers, and a quoted literal in a Python test falls back to the dottedmock.patchtarget lookup only whenresolveRefsfinds no repo path. The test conflict keeps main's markdown case and adds the Python case.What it adds, for
.pysources:import a.b,from a.b import c(also tried as the submodulea.b.c), parenthesised lists and relativefrom . import x/from ..pkg import y, resolved from the repo root toa/b.pyora/b/__init__.py, plus the package__init__.pyfiles Python runs on the way in. Stdlib and site-packages modules resolve to nothing.'pkg.mod.Class.method'map to the longest dotted prefix that is a repo module.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:
mock.patchreading.;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.jsondeclares dependencies andnode_modulesis missing, the scratch worktree runs a generator without them. A generator that degrades and still exits 0 was reported asREGEN_STALEwith "run the generator and commit", which sends people the wrong way (GSTA-31 hit this in gbrain).gstack-regen checkand the pregateregencheck now report the entry asdeps-missingwith a new result code,REGEN_DEPS_MISSING:bun.lock/bun.lockb→bun install,pnpm-lock.yaml,yarn.lock,package-lock.json), withbun installas the default.incomplete(the outputs were not verified), neverpass.gstack-regenexits 1 withstatus=incomplete.node_modulespresent, behaves exactly as before, so a genuinely stale output is stillREGEN_STALE.lib/result-codes-release.tsbecauselib/result-codes.tsis at the 800-line module ratchet. It has adocs/troubleshooting.mdanchor and a note indocs/pregate.md.bin/gstack-doctor-components.shis regenerated.Tests
test/pregate-selection.test.ts: Scott's Python import-graph case, and a pregateregencase assertingREGEN_DEPS_MISSINGand noREGEN_STALE(it fails on main with the stale message).test/gstack-regen.test.ts: a gbrain-shaped fixture (the generator falls back withoutfixture-depand exits 0) that isdeps-missing, turnsfreshoncenode_modulesexists, and is stillstaleon a real input change with deps installed. Also covers the lockfile choice.VERSION and CHANGELOG are not stamped; that waits for the release slot.