Repository navigation
Conversation
Path table rewritten for the tree that exists now: .github/, scripts/, deploy/, the vendor tree and the dependency/deploy manifests are T3 (the old table named core/, plugins/ and ds-bot/, none of which exist); services/, manager/, runtime/flybot* and flybot_workspace code are T2; client code, tests and checked-in pages T1; docs T0. unknownPathTier stays T2 so a path no rule names is never silently passed as low risk. Size caps are recomputed from six real changes in this tree (#3390 5L/1F, #3389 54L/5F, #3386 280L/11F, #3391 386L/13F, #3382 633L/7F, #3388 1128L/14F): the old caps would have called #3388 T3. limitsNote records it. The T3 meaning no longer claims a self-PASS lets the gate merge by itself; this file only reports a tier.
The 0.2 script mixed the rules engine, the network reads and the CLI in one file. The engine (tier paths, glob matching, judge, size caps, report) is pure over the rules file and the list of changed files, so it moves to risk-tier.mjs on its own; the command and the REST reads follow in risk-gate.mjs, which re-exports this module. No behaviour change: same ORDER, globToRe, judge, summaryLine, render, loadRules as the 0.2 version, and the two intended differences of the port (a reason for T1/T2 as well as T3, and a `--replay` that filters on merged_at instead of `gh pr list`) live here and in the CLI.
The 0.2 script shelled out to `gh api`, which does not exist here. This reads the REST API with the global fetch, so the command runs with no `gh` and no token: `node .github/scripts/risk-gate.mjs --pr 3382` is the acceptance command. A token is used when the environment has one (the anonymous core quota is 60/h and shared) and is never required; a spent quota is named in the error with its reset time instead of a bare 403. The changed-file list is read page by page off the Link header, so a PR with more than 100 files is read whole (#3112 has 194), and `--replay` filters closed PRs on merged_at rather than calling `gh pr list --state merged`, which no longer exists. Report only: it prints a tier and exits 0; it does not block, label, merge or touch tests.yml.
The 0.2 test file is carried over as-is: glob matching, tierOf precedence, judge over a set of files, content red flags (JS and Python), renames, size caps, the truncated-list rule, the report and the summary line, plus the #679 topic narrowing. Added for this layout: every tier path and cap in .github/agent/risk-rules.json is asserted against real paths of this tree, and the unknown-path default must stay at T2 or above. The set-up shared by the test files (rules, gate, a changed-file factory) moves to risk-gate.fixtures.mjs so each test file stays small. Local: node --test '.github/scripts/*.test.mjs' -> 24 tests, 24 pass, 0 fail.
… without a network Second and third test file of the same 24-test suite, split only so no file is oversized: - risk-gate-judge.test.mjs: what must not raise a tier (removed lines, prose, allowed hosts), what must (an unreadable diff, generated-file counting, size caps at the tier reached, a possibly truncated list), the T2-is-quotable report, the summary line, and the rules file's own shape. - risk-gate-api.test.mjs: the REST layer with a stubbed fetch and no token: an anonymous request sends no authorization header, a token is sent when one is set, the Link header is followed, a spent quota is named in the error, --replay keeps only merged PRs, and the command does not shell out to `gh`. Local: node --test '.github/scripts/*.test.mjs' -> 24 tests, 24 pass, 0 fail.
This was referenced Nov 26, 2026
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.
Related #3393 (stage 1, the risk tier engine; report only)
The 0.2 guard that graded a PR's risk died with the 0.3.0 layout:
.github/scripts/risk-gate.mjsand.github/agent/risk-rules.jsonwere deleted in the rewrite, and the 0.2 script itself calledgh api, which does not exist on this box. This ports both to the current tree.Report only. It prints a tier and exits 0; it does not block, label or merge anything, does not touch
tests.yml, and introduces no check name.The tier is the highest of three things: the path of every changed file (and the old path of a rename), red-flag hits in the added lines of code files, and a size cap for the tier reached so far.
unknownPathTierstaysT2, so a new directory cannot fall below T2 by default.Files:
.github/agent/risk-rules.json— the path table and caps, recomputed for this layout, with the sample PRs that justify each cap inlimitsNote..github/scripts/risk-tier.mjs— the engine (glob matching,judge, size caps, report). Pure over the rules file and the file list..github/scripts/risk-gate.mjs— the command: reads the PR over the REST API with the globalfetch, follows theLinkheader so a PR with more than 100 files is read whole (Add staged Teamily-style chat tools and owner-scoped history search #3112 has 194), and uses a token only if the environment has one..github/scripts/risk-gate.{fixtures,test,judge,api}*.mjs— the 0.2 test file carried over, set-up extracted torisk-gate.fixtures.mjsand the rest split over three files so no file is oversized.Local, on this branch (
node v24.22.3, no token, nogh):Verdicts from the same command, all four read anonymously against
main's layout:runtime/flybot/plugins/social/test/client-harness.mjs: /new Function\(/(same inpoll-visibility.test.js)core/src/host/diagnostics.js, twopatches/ds-bot/*.patch— unnamed paths, so T2core/src/host/schedules.js, one patch filecore/client.js, pluscore/dev/offline-fixture/package.jsonand amessage-fold.jsred flag; the file list came from page 2 of the API, so pagination worksTwo intended behaviour changes from 0.2, both visible in the tests:
--replayfilters closed PRs onmerged_atinstead of callinggh pr list --state merged.render()gives a reason for T1/T2 too: with no T3 hit it lists the paths that set the tier reached, so a T2 verdict is quotable instead of having an emptyWhy.One thing for review rather than for this PR: #3382 lands on T3 because it adds
new Function('window', readFileSync(...client.js...))in a new test harness. That is the rule doing what it says, not a bug in the port — but whether new test scaffolding should be able to raise a PR to T3 is a rule decision (tier scope), and I have not tuned the rules to make that PR greener.Not in this slice: no workflow, no
risk:T*label, no queue, no audit gate — those are later stages of #3393.