Skip to content

feat(pregate): user-owned policy file and local lanes - #3286

Closed
arlophoenix wants to merge 15 commits into
garrytan:mainfrom
arlophoenix:feat/pregate-user-policy
Closed

arlophoenix wants to merge 15 commits into
garrytan:mainfrom
arlophoenix:feat/pregate-user-policy

Conversation

@arlophoenix

@arlophoenix arlophoenix commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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

Why (in your own words)

A contributor who uses gstack on a shared repo, one that keeps .gstack/ out of git, can now give gstack-pregate a policy without committing one. Today pregate falls back to defaults there, so every platform lane the Mac cannot run (an ubuntu-latest suite, say) becomes a requires-remote obligation that never clears, even when that suite runs identically here. This PR reads <state root>/projects/<slug>/pregate.json when the base branch carries no .gstack/pregate.json, and adds a local key naming platform lanes a local run satisfies; those lanes run here as tier unit.

The user file is read only under --policy-from base and only when the base has no copy, so a repo that commits its policy is unaffected. A path that is relative or resolves inside the checkout (including through a symlink) is ignored, because a PR could supply it. An unreadable file, a dangling symlink on its path, sealed or price_file refuses with PREGATE_CONFIG_INVALID rather than falling back to defaults, and a base copy git cannot read refuses with POLICY_SOURCE_UNAVAILABLE unless git ls-tree confirms it is absent. The record names the file (policy user <path>) and each check's inputs.policy carries its sha256. Fix texts for missing lanes, strays, stalls and remote_gate name the active policy file. The slug and state root come from the caller's environment: the bin ignores a checkout's .env, and verify treats a changed, deleted or newly present user file as stale.

Parts 1 and 3 landed in #3306 and #3300; this branch points their no-lane and runner fix texts at the active policy file.

Live evidence

A scratch repo whose .gstack/ is not committed, GSTACK_HOME pointing at a scratch home holding projects/live-demo/pregate.json = { "runner": "node --test {files}", "local": ["ci.yml/unit"] }, ci.yml/unit being an ubuntu-latest job, on darwin.

$ GSTACK_HOME=<scratch>/home GSTACK_PROJECT_SLUG=live-demo bun <upstream/main>/bin/gstack-pregate --base main --stage tests --allow-repo-commands
pregate: policy origin/main@84395b866992 (no .gstack/pregate.json); ...; platform darwin
tests      lanes     requires-remote     422 ms  1 tests ran in 1 file(s), exit 0; 1 requires-remote obligation(s)
    lanes: requires-remote ci.yml/unit (linux): 1 test(s) — test/add.test.js
PREGATE: requires-remote (1 uncleared) tree=58b987a35a4d head=fa11bd421609 checks=1

$ GSTACK_HOME=<scratch>/home GSTACK_PROJECT_SLUG=live-demo bun <this branch>/bin/gstack-pregate --base main --stage tests --allow-repo-commands
pregate: policy user <scratch>/home/projects/live-demo/pregate.json; ...; platform darwin
tests      lanes     pass                487 ms  1 tests ran in 1 file(s), exit 0
    lanes: Tiers ran: unit; requires-remote: none
PREGATE: pass tree=58b987a35a4d head=fa11bd421609 checks=1

The same repo with a state root placed inside the checkout (GSTACK_HOME=<repo>/..st) and --explain:

pregate: policy origin/main@84395b866992 (no .gstack/pregate.json); ...
user policy: <repo>/..st/projects/live-demo/pregate.json ignored (inside the repository; a PR could supply it)

With a malformed user file, --json, exit 3:

{"ok": false, "status": "refused", "code": "PREGATE_CONFIG_INVALID", "detail": "user <scratch>/home-bad/projects/live-demo/pregate.json: not valid JSON: ... at <scratch>/home-bad/projects/live-demo/pregate.json", "fix": "edit <scratch>/home-bad/projects/live-demo/pregate.json directly at each path the message names, then rerun gstack-pregate; ..."}

Scope

  • Changed: lib/pregate/{config,context,lane-selection,types}.ts, the lanes and strays checks, bin/gstack-pregate, lib/result-codes.ts, docs/{pregate,troubleshooting,state-root}.md, and a new test/pregate-user-policy.test.ts. No Dart code (that is piece 1), and no VERSION, CHANGELOG or agents-digest stamp.
  • Verified live by: the runs above, on macOS (darwin, 18 cores), with Bun 1.4.2.
  • Did NOT test: Linux or Windows hosts; a real shared repo beyond the scratch fixture; --remote with a user-file remote_gate (only its refusal and fix wording are tested); the full free suite (bun run test). A final gstack-pregate --allow-repo-commands run was incomplete: lib/result-codes.ts selects 408 test files, and one runner hit the 600 s --timeout on a shared, loaded Mac. It recorded 41 failures, most at the 5 s test timeout (load 25 on 18 cores). The pregate files among them (invalidation, remote, supervise, regate, guards) failed in equal or higher numbers on upstream/main when run file by file, alternating base and branch; the other files (tree receipt, evidence bundles, docsync, consent) were not rerun against upstream/main, so their status is unverified.

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 (split); reproduction under Live evidence

Not addressed

  • gstack-pregate validate checks the working-tree .gstack/pregate.json only, not the user file.
  • The import-graph provenance hints (lib/pregate/import-graph.ts) and gstack-pregate --help still name .gstack/pregate.json and the base branch only.
  • The ship receipt does not say which policy produced a verdict; pregate.json does (policy user <path>).
  • There is no owner or permission check on the user file; gstack trusts its state root elsewhere too.

Test plan

  • bun test test/pregate-user-policy.test.ts: 16 pass, 0 fail, including that a committed .env cannot redirect the user policy and that a base .gstack/pregate.json whose blob is missing refuses instead of reading the user file
  • bun run typecheck clean; bun run gen:skill-docs --dry-run all FRESH; test/troubleshooting-anchors.test.ts 205 pass
  • bun test test/pregate-selection.test.ts: 24 pass, 4 fail. The same 4 fail on unpatched upstream/main on macOS, because they assume a Linux host (ubuntu-* lanes are platform-tier on darwin): "a clean branch passes every check…", "lanes: a touched file with no test lane…", "p0-4-windows-lane-unrun…", "lanes prints the lane list with platform tiers…"
  • Manual test pass (see checklist below)

Manual test pass

  • In a repo whose base carries no .gstack/pregate.json, write <state root>/projects/<slug>/pregate.json with "local": ["<workflow>.yml/<job>"] for an ubuntu-latest job, then run gstack-pregate run --allow-repo-commands: the header reads policy user <path> and that lane runs locally instead of becoming requires-remote.
  • Delete the file and rerun with --explain: it prints user policy: <path> (absent).
  • Commit a .gstack/pregate.json to the base and rerun: the header names the base copy and the user file is not read.

🤖 Generated with Claude Code

arlophoenix and others added 11 commits October 18, 2026 14:14
A repo that keeps .gstack/ out of git can hold its pregate policy at
<GSTACK_HOME>/projects/<slug>/pregate.json. gstack-pregate run reads it only
under --policy-from base when the base carries no .gstack/pregate.json, so a
reviewed base copy always wins and a PR still cannot reach the policy. A
missing file falls back; any other read error, and a non-null sealed or
price_file (read only from the git copies), refuse with PREGATE_CONFIG_INVALID
and a fix that names the file.

A new `local` key lists <workflow.yml>/<job> lanes a local run satisfies: a
platform lane named there runs here (tier unit) instead of becoming a
requires-remote obligation. Lane ids share one LANE_ID check with selection.

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

With no .gstack/pregate.json on the base, an edit to that path is never read,
so the no-lane, runner, stall_timeout_s, remote_gate and strays fixes now name
ctx.configFile: the user-owned path when it is the active policy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ignore a user policy path that is relative or inside the checkout, fingerprint
the active user file into check inputs, name the user file in its JSON errors
and the refusal lead, add --explain lines for an absent user file and an
unknown local id, and document the state-root location and slug lookup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A state root under an in-repo directory named ..something passed the
inside-the-repo check, and realpath kept the caller's casing on macOS.
The unknown-local explain line now says workflow lane, and the state-root
chain in explain and docs names every source.

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

Any git show failure read as no base policy, which now hands the run to
the unreviewed user file; it is absent only when cat-file says so, and a
spawn error (stdout cut at the buffer limit) counts as a failure. A user
pregate.json that is a dangling symlink refuses instead of reading as
absent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…angling parent links

cat-file -e checks the blob, so a missing or corrupt object still read as
no base copy; ls-tree reads the tree entry, and any failure refuses. The
dangling-symlink check now covers every path component, not just the file.

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

Guards, remote_gate, stall timeouts and lane fixes name the user-owned file
when it is the active policy; the trust boundary says run alone reads it;
the dangling-symlink and unreadable-base-copy refusals are documented, and
state-root lists the bucket's pregate.json.

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 careful work, and the containment edges (symlinks into the checkout, an unreadable base blob refusing instead of falling through) are exactly right. I reviewed it with gstack /review plus an outside-voice pass on another model family, and I'm holding it back for two changes before it can land:

  1. Critical: the repo's .env can redirect which user policy is read. bin/gstack-pregate runs under Bun, which auto-loads .env from the working directory. With no committed base policy, a branch that adds GSTACK_PROJECT_SLUG=<something-else> (or a GSTACK_STATE_ROOT/GSTACK_HOME) to .env points slugFromEnvironment()/resolveStateRoot() at a different file, and the outside-the-repo check still accepts it. In a probe, an unchanged user guard went from fail to pass: no guards declared; launching with --no-env-file restored the failure. The policy identity has to come from the caller's own environment: disable dotenv loading for every pregate launch path (the shebang and scriptInvocation), or resolve the slug and state root before anything can read the checkout's .env, with a test that commits such a .env on the branch.
  2. Medium: a user-policy change does not invalidate a recorded pass. inputs.policy records the digest, but gstack-pregate verify never re-checks it, so editing local from ["ci.yml/windows"] to [] after a pass leaves the old receipt valid even though a remote obligation is back. Verify should re-resolve the active policy (source and digest, including deletion) and treat a mismatch as stale.

The Dart lanes from #3285 and the --base fix from #3290 are landing in the pregate PR I'm about to open, so once those merge this will need a rebase onto lanes.ts/context.ts (the noLaneFix() hand-off you mentioned). Happy to review again when it's updated.

…e-checks it

Bun loads .env from the working directory, so a branch could set
GSTACK_PROJECT_SLUG or a state root and choose which pregate.json governs
it. The shebang now passes --no-env-file, scriptInvocation carries that
flag over when it launches the bin as bun <script>, and a bare bun launch
beside any dotenv file refuses (POLICY_SOURCE_UNAVAILABLE).

A recorded pass also outlived its policy: pregate.json now records the
user file's digest (or, under the defaults, the path that was absent), and
verify and the ship receipt treat an edited, deleted or newly present user
file as PREGATE_STALE, reading both paths from the record.

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

Copy link
Copy Markdown
Contributor Author

Thanks, both are addressed in 5247ac6.

  1. .env: the shebang passes --no-env-file, and scriptInvocation carries a shebang's --no-env-file over when it launches a bin as bun <script>, which ignores shebang flags. A bare bun gstack-pregate beside any dotenv file refuses with POLICY_SOURCE_UNAVAILABLE, since Bun's dotenv syntax (KEY: value, bare-CR lines) is looser than a key scan can follow. The test commits a .env with GSTACK_PROJECT_SLUG=elsewhere on the branch and checks all three launch paths.
  2. verify: pregate.json records policy_digest or, under the defaults, the policy_user_path that was looked for. verify and the ship receipt read both from the record rather than their own environment, and return PREGATE_STALE when the user file is edited, deleted, or appears after a defaults run.

A review pass here also found that a committed bunfig.toml preload runs inside any gstack Bun bin before it reads argv. That predates this PR and is listed under Not addressed. I'll rebase onto lanes.ts/context.ts once #3306 and #3290 land.

arlophoenix and others added 3 commits October 20, 2026 17:33
…olicy

# Conflicts:
#	bin/gstack-pregate
#	lib/pregate/checks/lanes.ts
#	lib/pregate/config.ts
#	lib/pregate/context.ts
#	lib/script-invocation.ts
…wording

The added '(or .gstack/pregate.json)' broke describeRefusal's rewrite to
'the reviewed pin files cannot be read', which pregate-wtree-refusal pins.

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

On a Windows host the windows lane is native, so it never became
requires-remote and the test failed on the Windows shards.

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

capy-ai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Thank you @arlophoenix. This is now ported in #3398 with all 13 of your commits kept and credited: the user-owned policy file, the local lanes, the .env isolation, and the refusals for unreadable and dangling paths. A security-focused review of the containment found two more edges, and we fixed them on top: a symlink chain that passes through the checkout and points back out, and verify not noticing a dangling parent link after a defaults run. Your tests made both easy to pin. Closing this in favour of #3398, which merges after #3380.

@capy-ai capy-ai Bot closed this Oct 25, 2026
capy-ai Bot added a commit that referenced this pull request Oct 25, 2026
…rt of #3286) (#3398)

* feat(pregate): user-owned policy file and local lanes

A repo that keeps .gstack/ out of git can hold its pregate policy at
<GSTACK_HOME>/projects/<slug>/pregate.json. gstack-pregate run reads it only
under --policy-from base when the base carries no .gstack/pregate.json, so a
reviewed base copy always wins and a PR still cannot reach the policy. A
missing file falls back; any other read error, and a non-null sealed or
price_file (read only from the git copies), refuse with PREGATE_CONFIG_INVALID
and a fix that names the file.

A new `local` key lists <workflow.yml>/<job> lanes a local run satisfies: a
platform lane named there runs here (tier unit) instead of becoming a
requires-remote obligation. Lane ids share one LANE_ID check with selection.

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

* docs(pregate): the user-owned policy file and local lanes

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

* fix(pregate): policy fixes name the user-owned file when it is the active policy

With no .gstack/pregate.json on the base, an edit to that path is never read,
so the no-lane, runner, stall_timeout_s, remote_gate and strays fixes now name
ctx.configFile: the user-owned path when it is the active policy.

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

* test(pregate): the remote_gate, strays and stall fixes name the active policy file

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

* fix(pregate): pre-landing review fixes for the user-owned policy

Ignore a user policy path that is relative or inside the checkout, fingerprint
the active user file into check inputs, name the user file in its JSON errors
and the refusal lead, add --explain lines for an absent user file and an
unknown local id, and document the state-root location and slug lookup.

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

* fix(pregate): containment edges and explain wording for the user policy

A state root under an in-repo directory named ..something passed the
inside-the-repo check, and realpath kept the caller's casing on macOS.
The unknown-local explain line now says workflow lane, and the state-root
chain in explain and docs names every source.

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

* fix(pregate): a base copy git cannot read, or a dangling user symlink, refuses

Any git show failure read as no base policy, which now hands the run to
the unreviewed user file; it is absent only when cat-file says so, and a
spawn error (stdout cut at the buffer limit) counts as a failure. A user
pregate.json that is a dangling symlink refuses instead of reading as
absent.

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

* fix(pregate): decide a missing base policy from the tree, and catch dangling parent links

cat-file -e checks the blob, so a missing or corrupt object still read as
no base copy; ls-tree reads the tree entry, and any failure refuses. The
dangling-symlink check now covers every path component, not just the file.

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

* fix(result-codes): POLICY_SOURCE_UNAVAILABLE names an unreadable committed pin file

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

* docs(pregate): the active policy may be the user-owned file; new refusals

Guards, remote_gate, stall timeouts and lane fixes name the user-owned file
when it is the active policy; the trust boundary says run alone reads it;
the dangling-symlink and unreadable-base-copy refusals are documented, and
state-root lists the bucket's pregate.json.

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

* fix(pregate): a checkout's .env cannot pick the user policy; verify re-checks it

Bun loads .env from the working directory, so a branch could set
GSTACK_PROJECT_SLUG or a state root and choose which pregate.json governs
it. The shebang now passes --no-env-file, scriptInvocation carries that
flag over when it launches the bin as bun <script>, and a bare bun launch
beside any dotenv file refuses (POLICY_SOURCE_UNAVAILABLE).

A recorded pass also outlived its policy: pregate.json now records the
user file's digest (or, under the defaults, the path that was absent), and
verify and the ship receipt treat an edited, deleted or newly present user
file as PREGATE_STALE, reading both paths from the record.

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

* fix(pregate): keep the POLICY_SOURCE_UNAVAILABLE summary's pin-files wording

The added '(or .gstack/pregate.json)' broke describeRefusal's rewrite to
'the reviewed pin files cannot be read', which pregate-wtree-refusal pins.

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

* test(pregate): pick the host-foreign lane in the user-policy local-lane test

On a Windows host the windows lane is native, so it never became
requires-remote and the test failed on the Windows shards.

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

* fix(pregate): Rust crate lanes and nested JS package runners

lanes reported PREGATE_NO_LANE for every touched .rs file and ran a nested
pnpm+vitest package's tests as `bun test` from the repo root.

- Rust: a .rs file of a crate (nearest Cargo.toml with [package]) is a test
  under <crate>/tests/ or when it holds a #[cfg(test)]; every .rs file of a
  crate and its Cargo.toml select the crate's tests and those of every crate
  depending on it (lib/pregate/rust.ts). Selected tests run per crate as
  `cargo test -p <name>` from the workspace root, judged on the summed
  `test result:` lines (doc-tests included); zero tests stays ZERO-RUN and a
  missing cargo is incomplete, like a missing Dart SDK.
- JS/TS: a test owned by a nested package.json that declares vitest or jest
  runs from that package with package-relative paths, through the package
  manager its packageManager field or nearest lockfile names (pnpm exec,
  yarn, bun x, else npx). Root detection and a declared runner are unchanged.
- init notes that Rust tests run per crate; docs/pregate.md updated.

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

* fix(pregate): parse Cargo manifests as TOML; follow workspace membership

The line scan of Cargo.toml missed dependents (a false green) and picked the
wrong workspace:
- an inherited renamed dependency (`base = { workspace = true }` with
  `[workspace.dependencies] base = { package = "alpha", path = ... }`);
- dotted keys (`alpha.path = "../a"`), `[dependencies.<name>]` tables and
  target-specific tables, matched by key name only;
- a crate the workspace excludes ran `cargo test -p` from the workspace root.

Manifests are now parsed with Bun.TOML. A dependency resolves by path
(relative to the manifest declaring it, or to the workspace root when
inherited), else by package name. A crate runs from the workspace it is a
member of under Cargo's rules (package.workspace, the nearest [workspace],
members globs, exclude, literal members, path dependencies of members),
else from its own directory. Nothing runs cargo.

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

* test(pregate): the Rust fixture's cargo shim wins PATH on Windows and beside a real cargo

windows-free-shard (5) failed 'a touched src file runs its crate...' and
'zero tests is ZERO-RUN...' deterministically: the shim PATH was joined with
':' so Git Bash never saw the shim dir, and the runner's real cargo ran
against the fixture (exit 1, no test result lines). On POSIX hosts where
Bun and cargo share a directory (/usr/local/bin on Capy's image), the lane
puts Bun's directory first and the real cargo wins the same way.

Join with path.delimiter, add cargo.cmd for Bun.which on Windows, and on
POSIX put the shim first again in the lane's own bash through BASH_ENV.

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

* fix(pregate): quote the crate name in cargoRunner

The crate name is read from the repo's Cargo.toml and was interpolated into
'cargo test -p <name>', which the lane runs through bash. A name like
'evil;touch pwned' ran the second command. Quote it like every file and cwd
the lane already passes; a new end-to-end case checks the name reaches cargo
as one argument and runs nothing.

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

* test(pregate): the nested-package pnpm shim wins PATH beside a real pnpm

'a touched file in a nested pnpm+vitest package runs vitest there' ran the
host's real pnpm wherever Bun and pnpm share a directory (/usr/local/bin on
Capy's image): the lane puts Bun's directory first, so pnpm installed vitest
from the network, dirtied the fixture tree and the check came back
incomplete. Put the shim first again in the lane's bash through BASH_ENV,
as the Rust fixture does.

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

* docs(changelog): pregate Rust crate lanes and nested package runners (#3344)

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

* fix(pregate): a crate name Cargo would reject never reaches the lane's shell

Port review (outside voice): quoting alone was not enough, because the lane
expands {files} after the runner string is built, so a crate named
'evil{files}' spliced the quoted file list into the quoted name and a file
name like tests/$(cmd).rs then ran. A name outside Cargo's grammar
(letters, digits, _ and -) now gets no runner: its files are unclaimed and
the lane is incomplete, as Cargo itself would refuse the manifest. A valid
name, Unicode included, still runs quoted.

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

* fix(pregate): match Cargo members globs per path component, without a backtracking regex

Port review (outside voice): members globs went through ship-policy's
matchesAny, which escapes [...] classes (crates/[ab] matched nothing, so the
crate was no member, lost its inherited [workspace.dependencies] path and its
dependents' tests were never selected: a false green) and backtracks
exponentially on a hostile glob such as '*a*a...*ab' (over 5 s for one crate,
before any runner deadline). A small dynamic-programming matcher handles *,
?, [..] with negation and ranges, and ** across components, in
O(pattern x path).

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

* fix(pregate): a plain #[test] in src is a Rust test; bound the cfg attribute scan

Port review (outside voice): only #[cfg(test)] modules and tests/ files
counted, so a dependent crate whose tests are plain #[test] or #[tokio::test]
functions in src never ran when its dependency changed (a false green). The
cfg scan also went quadratic on a run of unclosed '#[cfg(' (about 3 s on
120 KB). Test attributes now count, and the cfg predicate and its strings are
length-bounded so the scan stays linear.

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

* docs(pregate): Rust test attributes, workspace membership and rejected crate names; changelog for the port review fixes

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

* fix(pregate): match members globs by code point in one pass, and admit every crate past a size cap

Second port review round (outside voice): the matcher counted UTF-16 units, so
'crates/?' missed a crate directory named with a supplementary character and
dropped its inherited dependencies (a false green); and each unmatched '['
rescanned the rest of the glob (5 s for one crate with a million of them).
Tokenize by code point with a precomputed next-']' table, and past 4096
characters of members globs admit every crate under the workspace: a wrong
member fails loudly in cargo, a dropped one is silent. The new supervised
probe kills a super-linear matcher at 30 s instead of hanging the file.

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

* fix(pregate): scan cfg attributes once without truncating them; an unclosable one counts as a test

Second port review round (outside voice): the length bound from the first
round dropped a valid cfg(any(test, feature = "<257 chars>")), so its crate's
tests were no longer selected (a false green). Read each attribute once to
its closing ']' and resume after it, which keeps the scan linear without a
bound; an attribute the scan cannot close (an unterminated string, no ']')
counts as a test, which selects more, never fewer.

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

* docs(changelog): second port review round (code-point member globs, unbounded linear cfg scan)

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

* fix(pregate): past the members size cap, a crate's run root is undecided and its tests unclaimed

Third port review round (outside voice): admitting every crate past the cap
made a non-member run as 'cargo test -p <name>' from the workspace root,
where a same-named member answered and its passing tests stood in for the
orphan's failing one (a false green). Keep the conservative membership for
dependency edges, but leave such a crate's workspace undecided (null):
planRuns leaves its files unclaimed and the lane incomplete.

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

* test(pregate): the Rust end-to-end runs put the cargo shim under Windows' own Path key

windows-free-shard (5) still failed both end-to-end cases at fe99b20 with
the same symptom (the runner's real cargo, exit 1, no test result lines).
runBin merges process.env, whose Windows key is 'Path', with the shim's
'PATH', so the child got two path variables and read the original. Write the
shim under the key process.env actually uses, as test/helpers/unreachable-gbrain.ts
and sync-gbrain-readiness-fixture.ts do.

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

* test(pregate): run the cargo stand-in cases on POSIX only

windows-free-shard (5) still failed both end-to-end cargo-lane cases after the
delimiter, cargo.cmd and Path-key repairs: the lane's Git Bash exits 1 with an
empty log, and that log is not visible from CI. Skip the two cases that run the
bash stand-in on win32 (test.skipIf, as other POSIX-shim pregate fixtures are
handled) and drop the unproven cargo.cmd and Path-key changes. Selection,
planning and the hostile-name case still run on Windows.

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

* test(pregate): TODO(#3380) on the two win32-skipped cargo-lane cases

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

* fix(pregate): refuse a user policy whose link chain passes through the checkout

userConfigRejection checked the lexical path and the final realpath only. A
state root linked into the checkout, or a link hop inside it, let a branch pick
which existing out-of-repo policy governs it. Every hop of the resolution chain
is now checked. Found by the security review of #3286.

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

* fix(pregate): verify goes stale when a link on the way to the absent user policy dangles

A fresh run refuses a user policy path with a dangling parent link, but verify
looked only at the leaf, so the parent's ENOENT read as continued absence and
an old defaults pass stayed publishable. The loader and verify now share one
absence check. Found by the security review of #3286.

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

* docs(pregate): CHANGELOG entry for #3286 and the link-chain and dangling-parent rules

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

* v1.91.206.0 stamp

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

---------

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