Skip to content

fix(pregate): Dart import graph and test lanes - #3285

Closed
arlophoenix wants to merge 17 commits into
garrytan:mainfrom
arlophoenix:feat/pregate-dart-lanes
Closed

arlophoenix wants to merge 17 commits into
garrytan:mainfrom
arlophoenix:feat/pregate-dart-lanes

Conversation

@arlophoenix

@arlophoenix arlophoenix commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Part 1 of 3 split from #3193 at maintainer request.

Why (in your own words)

gstack-pregate can now select and run the tests a Flutter or Dart change touches. On main, every touched _test.dart file fails lanes with "has no test lane", so a Dart repo can't pass the tests stage at all. With this branch, the import graph reads Dart import/export/part directives, and package: URIs resolve through every tracked pubspec.yaml. lanes runs each Dart package's selected tests from that package's root, using fvm flutter test when the package pins fvm and plain flutter test or dart test otherwise. CI jobs that run flutter test, dart test, melos or very_good count as lanes, and their test paths resolve against the step's working-directory and any literal cd.

The runner sits on main's supervise() path. --timeout keeps main's documented per-runner-process meaning, so a timed-out package is incomplete and the next package still runs; the old branch's shared deadline across packages was dropped. Pregate never passes a lane it couldn't run. A Dart SDK missing from PATH, or a .dart file with no pubspec.yaml above it, leaves the lane incomplete with a fix line, and the packages that can run still do, so a real failure still fails. An all-skipped Dart run (+0 ~N) is ZERO-RUN. Device tests (integration_test/, test_driver/) are not unit lanes. The fix text names the "**/integration_test/**": [] declaration in .gstack/pregate.json.

This does not make flutter-bbtm green. bbtm keeps .gstack/ gitignored and has Actions off, so its ubuntu lanes stay requires-remote, and its ship receipts also need piece 2 (user-owned policy and local).

Live evidence

flutter-bbtm, run in a throwaway git clone --shared with a branch off develop that touches one widget test: gstack-pregate --stage tests --allow-repo-commands --base develop.

Before (upstream/main):

tests      lanes     fail                172 ms  1 touched file(s) with no test lane: test/ui/widgets/bbtm_drawer_widget_test.dart (PREGATE_NO_LANE)
    lanes: Tiers ran: (none); requires-remote: none

After (this branch):

tests      lanes     requires-remote   10682 ms  14 tests ran in 1 file(s), exit 0; 3 requires-remote obligation(s)
    lanes: requires-remote qa-driver.yml/smoke (linux): 1 test(s) — test/ui/widgets/bbtm_drawer_widget_test.dart
    lanes: requires-remote test.yml/guards (linux): 1 test(s) — test/ui/widgets/bbtm_drawer_widget_test.dart
    lanes: requires-remote test.yml/flutter (linux): 1 test(s) — test/ui/widgets/bbtm_drawer_widget_test.dart
    lanes: Tiers ran: unit; requires-remote: linux
    lanes: ran: fvm flutter test 'test/ui/widgets/bbtm_drawer_widget_test.dart'
PREGATE: requires-remote (3 uncleared)

A Dart test outside any package (fixture, no pubspec.yaml):

tests      lanes     incomplete          422 ms  no test runner detected for 1 of 1 selected file(s): tools/test/x_test.dart; no pubspec.yaml above 1 .dart file(s) (PREGATE_INCOMPLETE)
    lanes: fix: commit the Dart package's pubspec.yaml, or declare `runner` (with {files}) in .gstack/pregate.json

On bbtm's real tree the graph recognises 1033 tests and builds in about 210 ms. lib/theme.dart selects 822 tests, and packages/cache/lib/cache.dart selects 782 across packages through package:cache.

Scope

  • Changed:
    • lib/pregate/import-graph.ts: Dart directives, package: resolution and _test.dart recognition.
    • lib/pregate/checks/lanes.ts: Dart run groups, fvm, verdict parsing and incomplete plans.
    • lib/pregate/workflows.ts: Dart CI test commands, and working-directory/cd path resolution.
    • lib/pregate/checks/strays.ts: Dart root manifests are not strays.
    • docs/pregate.md and docs/troubleshooting.md.
    • test/pregate-dart.test.ts (new) and a fixture helper error message.
  • Verified live by: the bbtm and no-pubspec runs above, on macOS with fvm and Flutter installed. The bbtm run was repeated on the final tree.
  • Did NOT test:
    • Linux or Windows hosts.
    • A real dart test (non-Flutter) package; the runner choice and verdict parsing are unit-tested only.
    • Paid evals. The touchfile selection picks about 110 probes and 24 judges, through derived references from lib/pregate/*. None were run, and no prompt or skill template changed.

Liveness proof (required for external contributors)

Screenshot 2026-10-19 at 10 10 17 AM

Checklist

  • Liveness screenshot attached (GSTACK PR typed live into a real surface) or PR author is @garrytan (owner exemption)
  • This is not a generated-file-only diff (I edited the source/template and regenerated)
  • No ETHOS.md edits, and no changes to voice / founder perspective / YC references
  • New public command / external service / host adapter has an accepted issue linked (or N/A)
  • Linked issue or reproduction: v1.91.102.0 fix(pregate): run Dart and Flutter test lanes #3193

Not addressed

  • remote_gate's command for a requires-remote obligation still names only the detected JS/Python runner, not the Dart command, for Dart selections.
  • flutter test and dart test may run pub get implicitly when a package's resolution is stale. That can fetch from pub.dev, and if it rewrites a tracked file the tree-change guard reports the lane incomplete.
  • Wide selections (lib/theme.dart → 822 tests) run as one flutter test per package and may need a higher --timeout.
  • Pieces 2 (user-owned policy, local) and 3 (diff-scope and review/ship stack detection) are separate PRs.

Test plan

  • test/pregate-dart.test.ts 21/21, plus pregate-import-graph-paths 12/12, pregate-manifest-paths 4/4, pregate-bats-nested 6/6, troubleshooting-anchors 205/205 and touchfiles 69/69; bun run typecheck clean
  • 11 failures that are identical on unpatched upstream/main, the same names on both trees, all from macOS host assumptions: pregate-selection 4 ("a clean branch passes every check…", "lanes: a touched file with no test lane…", "p0-4-windows-lane-unrun…", "lanes prints the lane list…"), pregate-supervise 4, pregate-guards 1 ("serial-pattern test files run in their own process…") and pregate-invalidation 2
  • Full bun run test, not run (shared machine)
  • Paid evals (bun run eval:bg:pr), deferred as above

🤖 Generated with Claude Code

arlophoenix and others added 17 commits October 18, 2026 14:13
…ckage: URIs resolve through every pubspec.yaml

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ep paths resolve against working-directory

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…en pinned; +N -M verdicts; missing SDK is incomplete

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A .dart test with no pubspec.yaml above it is unclaimed (incomplete), not
handed to the detected runner. Runnable groups run even when another
package's SDK is missing: a failure still fails, an otherwise green run is
incomplete for the rest. DART_DIRECTIVE_RUN is linear (indented continuation
lines only, bounded body). The Dart verdict line is read first only for
dart/flutter runners. Pubspecs sharing a name keep every root. Coverage rows
for working-directory guards, quoted pubspec names, the read cap and the
unpinned missing-SDK hint.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An ambiguous package: import selects every same-name copy, a leading BOM
no longer hides a Dart file's directives, and parseSummary drops colour
codes and treats a carriage return as a line end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A package: import prefers the importer's actual package, so a same-name
ancestor no longer steals it. Comments are blanked before the directive
scan, so a ';' in a comment cannot truncate a conditional import.
'sdk: flutter' under any dependency name, in flow style too, selects
flutter test. A workflow step whose working-directory cannot be resolved
leaves the lane's test set unknown (may run any test), and a step that
cds claims its paths both under the directory and repo-relative.

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

A workflow run command is walked through its literal cd/pushd segments,
so a test path resolves against the directory current where it is named;
a non-literal or escaping cd leaves the lane's test set unknown. A blank
or comment-only line continues a multi-line Dart directive, a pubspec's
leading BOM no longer hides its name, and a quoted sdk key still selects
flutter test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…end at ')'

A root package.json script run from a sub-directory leaves the lane's
test set unknown instead of resolving its paths against that directory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Oct 18, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Thanks @arlophoenix — this is excellent work, and the Dart lanes are landing in #3306, squashed with you as co-author. Review (gstack /review plus an outside voice on another model family) found two places where selection could quietly shrink, which I fixed on top in #3306 rather than send back: a cd inside a pipeline or a redirected subshell (cd pkg | cat; bun test test/a.test.ts) moved later test paths into pkg/ and dropped a Windows obligation, so any cd in a command with pipes, ||, &, control flow or command substitution now leaves the lane's set unknown; and an unindented conditional import continuation (import 'a.dart'\nif (dart.library.io) 'b.dart';), a long show list, metadata and nested comments lost edges, so directives are now read to the next unquoted ;. I'll close this once #3306 is through its gate.

@capy-ai

capy-ai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Thanks @arlophoenix. Your Dart/Flutter pregate work (Dart lane, _test.dart handling) landed in #3306, squashed with your Co-authored-by credit, on top of current main with the Django/asset fixes from the same wave. Closing this in favour of that port; it's stamped v1.91.161.0 and through its gate.

@capy-ai capy-ai Bot closed this Oct 20, 2026
capy-ai Bot added a commit that referenced this pull request Oct 20, 2026
…init drafts from the repo (#3266-#3269) (#3306)

* fix(pregate): Dart import graph and test lanes (#3285)

Port of arlophoenix's #3285. The import graph reads Dart import/export/part
directives and resolves package: URIs through every tracked pubspec.yaml;
_test.dart files under test/ are tests. lanes runs each Dart package's
selected tests from its own root with flutter test or dart test (through fvm
when the package pins it). flutter/dart/melos/very_good CI jobs are lanes,
and run-step test paths resolve against working-directory and literal cd.
A missing Dart SDK or a .dart file outside any package leaves the lane
incomplete with a fix line; device tests (integration_test/, test_driver/)
are not unit lanes.

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

* fix(pregate): a --base that names a commit gets a branch fix, not an impossible fetch (#3269)

gstack-pregate --base <sha> refused with "fix: git fetch origin <sha>
--depth=1". That fetch can never create origin/<sha>: a short SHA fails
with "couldn't find remote ref", and a full SHA only reaches FETCH_HEAD.
A fork clone hits the same wall with --base upstream/main.

When origin/<base> does not resolve but <base> names a commit here and
no local branch (a SHA, a tag, another remote's ref), the refusal now
says --base takes a branch name on origin and suggests origin/HEAD's
branch. A local branch, or a name that resolves nowhere, keeps the
fetch fix: that is the unfetched or shallow checkout it repairs. Same
code, same exit 3, and pin files are still read only from the reviewed
origin/<base>.

Fixes #3269

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

* fix(pregate): Django, asset and tool-config lanes; init drafts from the repo (#3266, #3267, #3268)

- Django: settings modules, settings strings, include(), app migrations,
  admin, templates, static files and project templates get framework edges
  (lib/pregate/django.ts).
- Assets, stylesheets and dotfile tool config take a no-tests empty lane;
  licence text under any name is documentation.
- gstack-pregate init drafts languages, runner notes and nearest-test
  dependencies; never writes [].
- Review fixes on the #3285 port: untracked shell scopes leave a lane
  unknown; Dart directives read to their semicolon; nested comments.

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

* test(pregate): init draft API is exercised directly, so init-draft.ts has a lane

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

* docs(changelog): restore the history a truncated rewrite dropped

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

* fix(pregate): outside-voice review fixes for the non-JS lanes

- Tool config is an allowlist: unknown dotfiles (.rspec, .husky hooks) and
  stylesheets still need a lane; snapshot, golden and fixture trees and
  .gstack/ are never inert.
- Django edges need Django evidence (manage.py or code importing django)
  and settings assignments in code, not strings or comments.
- A cd after ||, &, control flow or braces leaves a lane unknown.
- Dart directives allow metadata and quoted semicolons.
- init drafts at most 256 dependencies (the schema limit); the rest are TODO.

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

* test(windows): pregate-dart and pregate-non-js join the POSIX-run pregate fixtures

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

* chore: release v1.91.161.0

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

---------

Co-authored-by: arlophoenix <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: y$un_ <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant