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.
Runs risk-gate.mjs on pull_request and writes the tier table to the job summary. It never labels, comments, or blocks, and its check name is risk-tier, not the required aggregate gate.
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
Slice: one workflow file,
.github/workflows/risk-tier.yml.Report-only.
pull_request(opened, synchronize, reopened) → job id and check namerisk-tier→node .github/scripts/risk-gate.mjswith the facts passed as env (PR,GITHUB_REPOSITORY,GITHUB_TOKEN), no new flags. The runner setsGITHUB_STEP_SUMMARY, so the tier table lands in the job summary and the console line carries the one-line verdict. No labels, no comments, no required check:risk-gate.mjsexits 0 for T0–T3 (T3 means "a human approves", not "the build fails") and 1 only when it could not compute a tier.Stacked on #3394 head
bdf1a871a1(Lead approved this base:risk-gate.mjs/risk-tier.mjs/.github/agent/risk-rules.jsonare not on main yet, and a real run needs them). The diff againstmaintherefore shows 8 files — the 7 from #3394 plus this one. After #3394 merges this must be rebased ontomainand re-checked; the slice itself is the single new file.Check name is
risk-tier: notFlyBot required checks, and notests-ok/enqueue-guardanywhere.Evidence (local, on the tree exported from
bdf1a871a1):PR=3394 GITHUB_REPOSITORY=ThinkFlowLab/FlyBot node .github/scripts/risk-gate.mjs→risk-gate (report only): PR #3394 tier T3; …, exit 0, andGITHUB_STEP_SUMMARYfile starts with### Risk tier: T3.grep -E "FlyBot required checks|tests-ok|enqueue-guard" .github/workflows/risk-tier.yml→ no match.sha256sum .github/workflows/tests.yml→6f60af36d734e48933f585e05857c2878f6673430065742568603fdea57fe2a9, identical to the same file on34a80ca5a1.tests.ymlis not touched.