rungate 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gates/.gate-salt +1 -1
- package/hooks/BunTestPathGuard.hook.ts +106 -0
- package/hooks/TopLevelCdGuard.hook.ts +38 -6
- package/lib/bun-test-paths.ts +253 -0
- package/lib/conformity.ts +9 -5
- package/lib/finding-jury.ts +13 -4
- package/lib/gate-check-audit.ts +535 -148
- package/lib/organize.ts +18 -8
- package/lib/release-preflight.ts +90 -1
- package/lib/report-provenance.ts +153 -0
- package/lib/scaffold/ai-review-findings.ts +219 -16
- package/lib/scaffold/ai-review-step.ts +263 -9
- package/lib/scaffold/steps.ts +26 -9
- package/lib/spec-updater.ts +11 -7
- package/lib/spec-write-ast.ts +728 -0
- package/lib/spec-write-sweep.ts +470 -0
- package/lib/test-suite-lock.ts +127 -13
- package/lib/ts-ast.ts +26 -0
- package/lib/validators/spec-validators.ts +15 -12
- package/lib/write-spec.ts +138 -0
- package/package.json +1 -1
- package/scripts/audit-specs.ts +8 -9
- package/scripts/convert-spec.ts +7 -2
- package/scripts/create-sc.ts +7 -6
- package/scripts/create-spec.ts +5 -2
- package/scripts/split-spec.ts +9 -8
- package/scripts/sync-sc-status.ts +7 -6
|
@@ -3606,6 +3606,58 @@ export const AI_REVIEW_PASS_VERDICT = "PASS";
|
|
|
3606
3606
|
/** The verdict word meaning "something here blocks the pull request". */
|
|
3607
3607
|
export const AI_REVIEW_BLOCK_VERDICT = "BLOCK";
|
|
3608
3608
|
|
|
3609
|
+
/**
|
|
3610
|
+
* The three tags a surviving finding is posted under, and no fourth (CRC-B7).
|
|
3611
|
+
*
|
|
3612
|
+
* ## This is NOT a second severity table, and the distinction is the whole
|
|
3613
|
+
* of why both exist
|
|
3614
|
+
*
|
|
3615
|
+
* `AI_REVIEW_SEVERITIES` above is the reviewer's MAGNITUDE word — how bad the
|
|
3616
|
+
* defect is — and it is the input to one question: does this block the pull
|
|
3617
|
+
* request? This is ATTRIBUTION — whose change the defect belongs to, and
|
|
3618
|
+
* therefore how it should read to whoever opens the checks tab.
|
|
3619
|
+
*
|
|
3620
|
+
* **The input on which the two must disagree for both to be right** is a
|
|
3621
|
+
* finding declaring `severity: "critical"` against a file the pull request
|
|
3622
|
+
* does not touch. `AI_REVIEW_SEVERITIES` must still say `critical` blocks: a
|
|
3623
|
+
* critical defect is critical whoever wrote it, and the table is a statement
|
|
3624
|
+
* about the word, not about the diff. This must still say `Pre-existing`: the
|
|
3625
|
+
* change cannot have introduced it and usually cannot fix it. Their
|
|
3626
|
+
* COMPOSITION is the demotion in `lib/scaffold/ai-review-findings.ts` —
|
|
3627
|
+
* reported, tagged, and not blocking.
|
|
3628
|
+
*
|
|
3629
|
+
* They cannot be collapsed in either direction. Folding `Pre-existing` into
|
|
3630
|
+
* `AI_REVIEW_SEVERITIES` would require the REVIEWER to write it, and the
|
|
3631
|
+
* reviewer is deliberately not given the pull request's file list — that is
|
|
3632
|
+
* why `readPayload` measures verdict agreement BEFORE the demotion. Deriving
|
|
3633
|
+
* these three from the five would require the magnitude word to encode
|
|
3634
|
+
* attribution, which nothing in `critical … info` does.
|
|
3635
|
+
*
|
|
3636
|
+
* ## Declared here rather than in `lib/finding-jury.ts`, where it was
|
|
3637
|
+
*
|
|
3638
|
+
* Same reason `AI_REVIEW_FINDING_FIELDS` is declared here: this module has no
|
|
3639
|
+
* relative imports, so it is the one module the three mutation batteries that
|
|
3640
|
+
* copy `ai-review-findings.ts` into a scratch directory can carry with it. A
|
|
3641
|
+
* tag vocabulary the deployed path cannot import is a tag vocabulary the
|
|
3642
|
+
* deployed path does not use, which is exactly the state CRC-B7 found —
|
|
3643
|
+
* `SEVERITY_RANK` had zero callers reachable from CI. `lib/finding-jury.ts`
|
|
3644
|
+
* imports and re-exports these two names, so its own callers are unchanged
|
|
3645
|
+
* and there is still exactly ONE declaration.
|
|
3646
|
+
*/
|
|
3647
|
+
export type Severity = "Important" | "Nit" | "Pre-existing";
|
|
3648
|
+
|
|
3649
|
+
/**
|
|
3650
|
+
* Sort order for the posted findings. A pre-existing bug is still a bug, so
|
|
3651
|
+
* it outranks a nit; it is not the author's, so it does not outrank an
|
|
3652
|
+
* Important one.
|
|
3653
|
+
*
|
|
3654
|
+
* ONE binding, and the only ordering in the deployed path. A second
|
|
3655
|
+
* comparator would be two deciders over one question and a mutation of
|
|
3656
|
+
* either would leave the other holding every case up
|
|
3657
|
+
* (`.claude/rules/checks-must-be-able-to-fail.md`, the fourth shape).
|
|
3658
|
+
*/
|
|
3659
|
+
export const SEVERITY_RANK: Record<Severity, number> = { Important: 0, "Pre-existing": 1, Nit: 2 };
|
|
3660
|
+
|
|
3609
3661
|
const AI_REVIEW_BLOCKING_SEVERITIES = Object.keys(AI_REVIEW_SEVERITIES).filter(
|
|
3610
3662
|
s => AI_REVIEW_SEVERITIES[s],
|
|
3611
3663
|
);
|
|
@@ -4105,6 +4157,22 @@ if [ "\${${AI_REVIEW_EVENT_VAR}:-}" = merge_group ]; then
|
|
|
4105
4157
|
exit 0
|
|
4106
4158
|
fi
|
|
4107
4159
|
|
|
4160
|
+
# #1469. Same reading for a push to the default branch, and taken here rather
|
|
4161
|
+
# than left to the refusal below. \`AI_REVIEW_ROUNDS_BRANCH\` is
|
|
4162
|
+
# \`github.event.pull_request.head.ref\` and is EMPTY on a push, so without
|
|
4163
|
+
# this the step would refuse with \${AI_REVIEW_REQUIRED_EXIT} and red the
|
|
4164
|
+
# check on every commit that lands — reporting "this job cannot tell which
|
|
4165
|
+
# round it is on", which is a true sentence about a question that does not
|
|
4166
|
+
# apply.
|
|
4167
|
+
${aiReviewPushBranch(
|
|
4168
|
+
` echo "${AI_REVIEW_ROUND_OUTPUT}=" >> "\${GITHUB_OUTPUT}"
|
|
4169
|
+
echo "${AI_REVIEW_AT_CAP_OUTPUT}=" >> "\${GITHUB_OUTPUT}"
|
|
4170
|
+
echo "${AI_REVIEW_INTENT_OUTPUT}=${AI_REVIEW_INTENT_NONE}" >> "\${GITHUB_OUTPUT}"
|
|
4171
|
+
echo "ai-review rounds: push to the default branch, no review and so no round"
|
|
4172
|
+
exit 0
|
|
4173
|
+
`,
|
|
4174
|
+
)}
|
|
4175
|
+
|
|
4108
4176
|
# \`AI_REVIEW_ROUNDS_SINCE\` is in this refusal and not defaulted, deliberately
|
|
4109
4177
|
# (#1281). An unset value would widen the query back to the whole branch NAME
|
|
4110
4178
|
# — the exact defect — and it would do it silently, because the response is
|
|
@@ -4379,8 +4447,17 @@ if [ "\${${AI_REVIEW_EVENT_VAR}:-}" = merge_group ]; then
|
|
|
4379
4447
|
exit 0
|
|
4380
4448
|
fi
|
|
4381
4449
|
|
|
4450
|
+
# #1469. A push to the default branch carries no pull request either, and the
|
|
4451
|
+
# same distinction applies: ABSENT is a complete reading, UNMEASURED is a
|
|
4452
|
+
# failed one. Without this branch a push falls into the refusal below and
|
|
4453
|
+
# reports that the history "could not be read", which names a lookup that was
|
|
4454
|
+
# never applicable rather than one that failed.
|
|
4455
|
+
${aiReviewPushBranch(` carry_state '${AI_REVIEW_CARRY_ABSENT}'
|
|
4456
|
+
exit 0
|
|
4457
|
+
`)}
|
|
4458
|
+
|
|
4382
4459
|
if [ -z "\${${AI_REVIEW_LEDGER_PR_VAR}:-}" ]; then
|
|
4383
|
-
carry_unmeasured "this run is
|
|
4460
|
+
carry_unmeasured "this run is neither a merge_group entry nor a push, and no pull request number reached this step, so there was nowhere to look for the history."
|
|
4384
4461
|
fi
|
|
4385
4462
|
|
|
4386
4463
|
if [ -z "\${${AI_REVIEW_LEDGER_TOKEN_VAR}:-}" ] || [ -z "\${${AI_REVIEW_LEDGER_REPO_VAR}:-}" ]; then
|
|
@@ -4467,16 +4544,32 @@ fi
|
|
|
4467
4544
|
# fence. A marked comment whose block is missing, unterminated or unparseable
|
|
4468
4545
|
# is UNREADABLE and never an empty ledger — treating a damaged ledger as empty
|
|
4469
4546
|
# discards every round it holds at the moment nothing can tell it happened.
|
|
4547
|
+
#
|
|
4548
|
+
# SPLIT, NEVER \`index\` WITH A SLICE (#1568). jq's \`index\` on a string
|
|
4549
|
+
# returns a BYTE offset and \`.[a:b]\` slices by CODEPOINTS, so the two
|
|
4550
|
+
# disagree by exactly the number of multi-byte UTF-8 bytes before the cut.
|
|
4551
|
+
# \`readLedger\`'s \`indexOf\`/\`slice\` pair agrees with itself and this
|
|
4552
|
+
# restatement did not, which is why two readers disagreed about the same
|
|
4553
|
+
# bytes. Measured on #1569's ledger: 13,826 codepoints in 13,846 bytes, so
|
|
4554
|
+
# the closing-fence cut overshot by 16 and carried the fence and the prose
|
|
4555
|
+
# after it into the JSON. Every round from round 3 on started from nothing.
|
|
4556
|
+
# The em dashes were in the findings' own summaries — this repository writes
|
|
4557
|
+
# them in every sentence, so the failure was the rule and not the exception,
|
|
4558
|
+
# and ASCII is what the whole battery had held fixed.
|
|
4559
|
+
#
|
|
4560
|
+
# \`split\` is unit-free: it never names an offset. The \`join\` on each tail
|
|
4561
|
+
# preserves the original's "from the FIRST occurrence onward" semantics for a
|
|
4562
|
+
# body that repeats the marker or the fence.
|
|
4470
4563
|
if ! fenced=\$(printf '%s' "\${selected}" | jq -r --arg m '${AI_REVIEW_LEDGER_MARKER}' --arg f '${AI_REVIEW_LEDGER_FENCE}' '
|
|
4471
4564
|
(.body // "") as \$b
|
|
4472
|
-
| (\$b |
|
|
4473
|
-
| (if \$
|
|
4474
|
-
| (\$after |
|
|
4475
|
-
| (if \$
|
|
4476
|
-
| (\$block |
|
|
4477
|
-
| (if \$
|
|
4478
|
-
| (\$rest |
|
|
4479
|
-
| if \$
|
|
4565
|
+
| (\$b | split(\$m)) as \$mp
|
|
4566
|
+
| (if (\$mp | length) < 2 then error("marker") else (\$mp[1:] | join(\$m)) end) as \$after
|
|
4567
|
+
| (\$after | split(\$f)) as \$fp
|
|
4568
|
+
| (if (\$fp | length) < 2 then error("fence") else (\$fp[1:] | join(\$f)) end) as \$block
|
|
4569
|
+
| (\$block | split("\\n")) as \$lp
|
|
4570
|
+
| (if (\$lp | length) < 2 then error("fence") else (\$lp[1:] | join("\\n")) end) as \$rest
|
|
4571
|
+
| (\$rest | split("\\n${fence}")) as \$cp
|
|
4572
|
+
| if (\$cp | length) < 2 then error("unterminated") else \$cp[0] end
|
|
4480
4573
|
' 2>/dev/null); then
|
|
4481
4574
|
# NO BACKTICKS IN AN ANNOTATION STRING. These messages sit inside a bash
|
|
4482
4575
|
# double-quoted argument, where a backtick opens COMMAND SUBSTITUTION — and
|
|
@@ -5584,6 +5677,32 @@ export function buildReviewRunScript(version: string): string {
|
|
|
5584
5677
|
`happened. Unset ${AI_REVIEW_REQUIRE_VAR}, or keep ai-review a required ` +
|
|
5585
5678
|
`context on pull_request and accept the per-head review as sufficient.`;
|
|
5586
5679
|
|
|
5680
|
+
// #1469. The same shape as the two above and a DIFFERENT argument, which is
|
|
5681
|
+
// the whole reason it is a separate branch rather than an extra alternative
|
|
5682
|
+
// on the queue test. A queue entry can be passed because the head commit it
|
|
5683
|
+
// batches was already reviewed; a push has no such guarantee available to
|
|
5684
|
+
// this job. Nothing here claims the commit was reviewed elsewhere — it
|
|
5685
|
+
// usually was, on the pull request that produced it, but a direct push to
|
|
5686
|
+
// the default branch is a push too and this step cannot tell them apart.
|
|
5687
|
+
const pushEntry =
|
|
5688
|
+
`This run is a ${AI_REVIEW_PUSH_EVENT} to the default branch, and no AI ` +
|
|
5689
|
+
`review ran on it: the review action does not support the ` +
|
|
5690
|
+
`${AI_REVIEW_PUSH_EVENT} event and refuses it as an unsupported event ` +
|
|
5691
|
+
`type. The trigger exists so that ai-review REPORTS on push, which is ` +
|
|
5692
|
+
`what lets branch protection be reasoned about (#1469) — it is not a ` +
|
|
5693
|
+
`review of this commit and must not be read as one. This check is ` +
|
|
5694
|
+
`UNMEASURED on this ref. What reviewed the content was the pull request ` +
|
|
5695
|
+
`that produced it, if there was one; a direct push to this branch was ` +
|
|
5696
|
+
`reviewed by nothing at all, and this job cannot tell those two apart.`;
|
|
5697
|
+
|
|
5698
|
+
const pushRefusal =
|
|
5699
|
+
`${AI_REVIEW_REQUIRE_VAR} is '${AI_REVIEW_REQUIRE_VALUE}' and this run is ` +
|
|
5700
|
+
`a ${AI_REVIEW_PUSH_EVENT} to the default branch, which the review action ` +
|
|
5701
|
+
`refuses as an unsupported event type, so no AI review ran on this ` +
|
|
5702
|
+
`commit. Failing rather than reporting a green check for a review that ` +
|
|
5703
|
+
`never happened. Unset ${AI_REVIEW_REQUIRE_VAR} if the review on the ` +
|
|
5704
|
+
`pull request that produced this commit is the measurement you want.`;
|
|
5705
|
+
|
|
5587
5706
|
const absentRefusal =
|
|
5588
5707
|
`${AI_REVIEW_REQUIRE_VAR} is '${AI_REVIEW_REQUIRE_VALUE}' and the ` +
|
|
5589
5708
|
`credential-detection step produced no mode output, so this pull ` +
|
|
@@ -5694,6 +5813,28 @@ if [ "\${${AI_REVIEW_EVENT_VAR}:-}" = ${AI_REVIEW_QUEUE_EVENT} ]; then
|
|
|
5694
5813
|
exit 0
|
|
5695
5814
|
fi
|
|
5696
5815
|
|
|
5816
|
+
# #1469, and SECOND for the reason the branch above is first: on a push the
|
|
5817
|
+
# action threw before producing an outcome, so none of the readings below can
|
|
5818
|
+
# hold and falling through would report a cause this job did not measure.
|
|
5819
|
+
#
|
|
5820
|
+
# The flag check is INSIDE the branch, not above it and not below it — the
|
|
5821
|
+
# fifth and now sixth spelling of ONE decider, same variable, same \`=\`
|
|
5822
|
+
# against the same value, same \${AI_REVIEW_REQUIRED_EXIT}. #939's fence in
|
|
5823
|
+
# test/ai-review-merge-group.test.ts runs every no-verdict route through one
|
|
5824
|
+
# table precisely so that a branch added here without it reds rather than
|
|
5825
|
+
# reintroducing that issue.
|
|
5826
|
+
#
|
|
5827
|
+
# \`::warning\` and not \`::notice\`: nothing reviewed this commit.
|
|
5828
|
+
${aiReviewPushBranch(
|
|
5829
|
+
` echo "::warning title=${AI_REVIEW_UNMEASURED_TITLE}::${pushEntry}"
|
|
5830
|
+
if [ "\${${AI_REVIEW_REQUIRE_VAR}:-}" = "${AI_REVIEW_REQUIRE_VALUE}" ]; then
|
|
5831
|
+
echo "::error title=${AI_REVIEW_UNMEASURED_TITLE}::${pushRefusal}" >&2
|
|
5832
|
+
exit ${AI_REVIEW_REQUIRED_EXIT}
|
|
5833
|
+
fi
|
|
5834
|
+
exit 0
|
|
5835
|
+
`,
|
|
5836
|
+
)}
|
|
5837
|
+
|
|
5697
5838
|
if [ -z "\${AI_REVIEW_MODE:-}" ]; then
|
|
5698
5839
|
echo "::warning title=${AI_REVIEW_UNMEASURED_TITLE}::${absent}"
|
|
5699
5840
|
if [ "\${${AI_REVIEW_REQUIRE_VAR}:-}" = "${AI_REVIEW_REQUIRE_VALUE}" ]; then
|
|
@@ -6511,6 +6652,78 @@ export const AI_REVIEW_EVENT_VAR = "AI_REVIEW_EVENT";
|
|
|
6511
6652
|
/** The event a merge queue fires, and the only one that takes the queue branch. */
|
|
6512
6653
|
export const AI_REVIEW_QUEUE_EVENT = "merge_group";
|
|
6513
6654
|
|
|
6655
|
+
/**
|
|
6656
|
+
* The event a push to the default branch fires (#1469).
|
|
6657
|
+
*
|
|
6658
|
+
* ## Why the trigger exists at all
|
|
6659
|
+
*
|
|
6660
|
+
* `PROTECT-1` in `lib/branch-protection.ts` REFUSES to recommend
|
|
6661
|
+
* `required_status_checks.strict = false` on a repository whose required
|
|
6662
|
+
* contexts do not run on `push:` to the default branch, and it refuses
|
|
6663
|
+
* `strict = true` on a user-owned account because it serialises every swarm's
|
|
6664
|
+
* pull requests. A repository whose `ai-review` is required and runs only on
|
|
6665
|
+
* `pull_request` therefore has no reading that clears: both directions are
|
|
6666
|
+
* refused, and the refusal's own remedy is this trigger. `readPushCi` reads
|
|
6667
|
+
* `.github/workflows/` and asks exactly one question of each file — does it
|
|
6668
|
+
* run on push to this branch, and which contexts does it name — so the
|
|
6669
|
+
* trigger is what moves `ai-review` out of that reading's `missing` list.
|
|
6670
|
+
*
|
|
6671
|
+
* ## What the job can DO on it: nothing, and that is measured
|
|
6672
|
+
*
|
|
6673
|
+
* Read from `anthropics/claude-code-action` at the SHA `lib/claude-code-action.ts`
|
|
6674
|
+
* pins, the same way #867 established it for `merge_group`:
|
|
6675
|
+
* `parseGitHubContext()` in `src/github/context.ts` switches on
|
|
6676
|
+
* `context.eventName`, and `push` appears in neither of its two event-name
|
|
6677
|
+
* lists, so the `default:` branch throws `Unsupported event type: push`
|
|
6678
|
+
* before the action reads anything. There is no version to bump to.
|
|
6679
|
+
*
|
|
6680
|
+
* So this is #867's distinction again, and it has to be drawn the same way:
|
|
6681
|
+
* an argument about what the job can DO on an event is not an argument about
|
|
6682
|
+
* whether it REPORTS on one. The job reports; every step that reads a pull
|
|
6683
|
+
* request says it had none rather than reading an empty value.
|
|
6684
|
+
*
|
|
6685
|
+
* ## And it is NOT a review of the merged commit
|
|
6686
|
+
*
|
|
6687
|
+
* Worth stating where the constant is, because the tempting reading of "the
|
|
6688
|
+
* required context now runs on push" is that main is being reviewed. It is
|
|
6689
|
+
* not. The honest severity is `::warning` and the honest word is UNMEASURED:
|
|
6690
|
+
* nothing read this commit. What push-CI buys under `strict: false` is the
|
|
6691
|
+
* SEMANTIC-conflict net PROTECT-1's header argues for — two changes green
|
|
6692
|
+
* alone and broken together — and in this repository that net is `test`,
|
|
6693
|
+
* which has run on push since the scaffold's first CI file. `ai-review` adds
|
|
6694
|
+
* no part of it and must not be read as adding one.
|
|
6695
|
+
*/
|
|
6696
|
+
export const AI_REVIEW_PUSH_EVENT = "push";
|
|
6697
|
+
|
|
6698
|
+
/**
|
|
6699
|
+
* The one spelling of "this run is a push, so there is no pull request".
|
|
6700
|
+
*
|
|
6701
|
+
* A function and not four hand-written `if` lines, for the reason this module
|
|
6702
|
+
* gives everywhere else: four copies of one comparison are four things to
|
|
6703
|
+
* mutate, and a battery that removes one of them leaves the other three
|
|
6704
|
+
* holding the case up. `AI_REVIEW_PUSH_EVENT` decides the name and this
|
|
6705
|
+
* decides the comparison — exact string, `:-` default, the same shape the
|
|
6706
|
+
* `merge_group` branches use — so a test can remove the branch in one place
|
|
6707
|
+
* and watch every push case go red at once.
|
|
6708
|
+
*
|
|
6709
|
+
* The BODY is the caller's, because the four sites say four different true
|
|
6710
|
+
* things: the rounds step has outputs to blank, the carry step has a state to
|
|
6711
|
+
* declare, the restore step has nothing to restore, and the report step has a
|
|
6712
|
+
* verdict to reach. A shared body would be one of those four wearing the
|
|
6713
|
+
* other three's names.
|
|
6714
|
+
*
|
|
6715
|
+
* Trailing newlines are stripped so a call site can close its template
|
|
6716
|
+
* literal on a line of its own, and that is not cosmetic. `AC-6b` in
|
|
6717
|
+
* `test/ai-review-scaffold.test.ts` reads every line of THIS MODULE whose
|
|
6718
|
+
* trimmed form begins `exit ` and requires it to be `0` or the exported
|
|
6719
|
+
* constant — so a body ending `` exit 0`,`` reads as the literal ``0`,``
|
|
6720
|
+
* and reds the guard that keeps every refusal mutable in one place.
|
|
6721
|
+
* Measured: it did, on the first draft of this change.
|
|
6722
|
+
*/
|
|
6723
|
+
export function aiReviewPushBranch(body: string): string {
|
|
6724
|
+
return `if [ "\${${AI_REVIEW_EVENT_VAR}:-}" = ${AI_REVIEW_PUSH_EVENT} ]; then\n${body.replace(/\n+$/, "")}\nfi`;
|
|
6725
|
+
}
|
|
6726
|
+
|
|
6514
6727
|
/**
|
|
6515
6728
|
* The bash that restores the untrusted path set BEFORE the baseline is read.
|
|
6516
6729
|
*
|
|
@@ -6588,11 +6801,46 @@ export function buildRestoreScript(): string {
|
|
|
6588
6801
|
`empty value as a write that never happened, and the drift step would ` +
|
|
6589
6802
|
`refuse every run for a cause nothing names. Refusing`;
|
|
6590
6803
|
|
|
6804
|
+
// #1469. What a push to the default branch does here, and why it is a
|
|
6805
|
+
// branch rather than a third reading in the expression that sets
|
|
6806
|
+
// AI_REVIEW_BASE_REF_VAR.
|
|
6807
|
+
//
|
|
6808
|
+
// The tempting fix is `|| github.ref_name`, which is one token and makes
|
|
6809
|
+
// the refusal below stop firing. It is Silent Default Substitution: on a
|
|
6810
|
+
// push the checkout IS the branch, so "restore the untrusted paths from
|
|
6811
|
+
// the base" would fetch `origin/<branch>` — a ref that may already have
|
|
6812
|
+
// moved past the commit being built — and overwrite the tree with it. The
|
|
6813
|
+
// step would report success having done something nobody asked for, and
|
|
6814
|
+
// the drift reading downstream would carry the difference.
|
|
6815
|
+
//
|
|
6816
|
+
// There is no base here, and no review either: the action refuses `push`
|
|
6817
|
+
// as an unsupported event type, so nothing will read the paths this step
|
|
6818
|
+
// exists to make trustworthy. Saying that and publishing no base-remote
|
|
6819
|
+
// output is the complete reading. Both downstream consumers of that output
|
|
6820
|
+
// already treat an empty value as a reading rather than a failure — the
|
|
6821
|
+
// changed-files step warns and exits 0, and the drift step asks for the
|
|
6822
|
+
// base only when a restored path was modified, which cannot happen when
|
|
6823
|
+
// the reviewer never ran.
|
|
6824
|
+
const pushNoBase =
|
|
6825
|
+
`This run is a ${AI_REVIEW_PUSH_EVENT} to the default branch, so there is ` +
|
|
6826
|
+
`no pull request base to restore the untrusted paths from and no review ` +
|
|
6827
|
+
`that could read them — the review action refuses this event as an ` +
|
|
6828
|
+
`unsupported event type. Nothing was restored and nothing needed to be. ` +
|
|
6829
|
+
`The base-ref output is left empty deliberately, so the steps that read ` +
|
|
6830
|
+
`it report UNMEASURED rather than measuring against a ref this step ` +
|
|
6831
|
+
`invented.`;
|
|
6832
|
+
|
|
6591
6833
|
return `# Generated by rungate — lib/scaffold/ai-review-step.ts. Do not edit.
|
|
6592
6834
|
set -uo pipefail
|
|
6593
6835
|
|
|
6594
6836
|
${AI_REVIEW_ANNOTATION_ESCAPE}
|
|
6595
6837
|
|
|
6838
|
+
# FIRST, above the empty-base refusal, because on this event an empty base
|
|
6839
|
+
# ref is the correct reading rather than the failure that refusal describes.
|
|
6840
|
+
${aiReviewPushBranch(` echo "::warning title=${AI_REVIEW_UNMEASURED_TITLE}::${pushNoBase}"
|
|
6841
|
+
exit 0
|
|
6842
|
+
`)}
|
|
6843
|
+
|
|
6596
6844
|
if [ -z "\${${AI_REVIEW_BASE_REF_VAR}:-}" ]; then
|
|
6597
6845
|
echo "::error title=${AI_REVIEW_DRIFT_TITLE}::${noRef}" >&2
|
|
6598
6846
|
exit ${AI_REVIEW_REQUIRED_EXIT}
|
|
@@ -9959,6 +10207,12 @@ export function buildReviewRunStep(
|
|
|
9959
10207
|
// workflow expression has no string operations and a second spelling
|
|
9960
10208
|
// introduced here would be a decider the script could not see.
|
|
9961
10209
|
` ${AI_REVIEW_BASE_REF_VAR}: \${{ github.event.pull_request.base.ref || github.event.merge_group.base_ref }}`,
|
|
10210
|
+
// #1469. NOT a third `||` alternative above: a push has no base, and the
|
|
10211
|
+
// script needs to say so rather than be handed a ref that looks like
|
|
10212
|
+
// one. Same binding the rounds, carry and report steps read, and the
|
|
10213
|
+
// same reason it is `github.event_name` — the runner sets it and no
|
|
10214
|
+
// repository setting can.
|
|
10215
|
+
` ${AI_REVIEW_EVENT_VAR}: \${{ github.event_name }}`,
|
|
9962
10216
|
// The job's own token, for one fetch. It is not persisted into
|
|
9963
10217
|
// `.git/config` and the reviewer runs in a later step with its own
|
|
9964
10218
|
// environment, so nothing of it reaches the agent.
|
package/lib/scaffold/steps.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { readdirSorted } from "../readdir-sorted";
|
|
|
12
12
|
import { fileExtensions } from "../file-extensions";
|
|
13
13
|
import { join, basename, dirname, resolve, sep } from "path";
|
|
14
14
|
import { auditSpecs } from "../../scripts/audit-specs";
|
|
15
|
-
import {
|
|
15
|
+
import { writeSpec } from "../write-spec";
|
|
16
16
|
import { generateAgentsMd as buildAgentsMdContent, generateScopedRules } from "../generators/agents-md";
|
|
17
17
|
import { HARNESS_PACKAGE, isHarnessItself } from "../harness-identity";
|
|
18
18
|
import { scanSpecs } from "../scanner";
|
|
@@ -1699,16 +1699,13 @@ export function copySpecTemplateIfEmpty(specsDir: string, actions: string[]): vo
|
|
|
1699
1699
|
// spec writers and missed this one, because its completeness check is built
|
|
1700
1700
|
// from files that read and write the same path — and this writes a path it
|
|
1701
1701
|
// never read. Ask who owns the bytes before replacing them.
|
|
1702
|
+
// #1552: the reading, the refusal line and the write are one call now.
|
|
1702
1703
|
const existed = existsSync(destPath);
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
return;
|
|
1708
|
-
}
|
|
1704
|
+
const result = writeSpec(destPath, template, { label: "specs/SPEC-TEMPLATE.md" });
|
|
1705
|
+
if (!result.written) {
|
|
1706
|
+
actions.push(result.refusal!);
|
|
1707
|
+
return;
|
|
1709
1708
|
}
|
|
1710
|
-
|
|
1711
|
-
writeFileSync(destPath, template);
|
|
1712
1709
|
// #1549: the verb is a reading, not a label. `CREATED` for a file that was
|
|
1713
1710
|
// already on disk tells a reader scanning the report for destructive
|
|
1714
1711
|
// actions the opposite of what happened.
|
|
@@ -3999,6 +3996,26 @@ on:
|
|
|
3999
3996
|
# See the block comment in lib/scaffold/steps.ts: no branches: filter, and
|
|
4000
3997
|
# its absence hangs a merge queue silently rather than failing it (#867).
|
|
4001
3998
|
merge_group:
|
|
3999
|
+
# #1469. PROTECT-1 (lib/branch-protection.ts) refuses to recommend
|
|
4000
|
+
# required_status_checks.strict = false on a repository whose required
|
|
4001
|
+
# contexts do not run on push: to the default branch, and refuses
|
|
4002
|
+
# strict = true on a user-owned account because it serialises every PR.
|
|
4003
|
+
# A required ai-review that runs only on pull_request therefore has no
|
|
4004
|
+
# reading that clears, and this trigger is the refusal's own remedy.
|
|
4005
|
+
#
|
|
4006
|
+
# It does NOT review the commit. The review action throws
|
|
4007
|
+
# "Unsupported event type: push" before reading anything, exactly as it
|
|
4008
|
+
# does on merge_group, so every step that wants a pull request says it
|
|
4009
|
+
# had none and the report step annotates UNMEASURED and passes. What
|
|
4010
|
+
# push-CI buys here is the semantic-conflict net, and in this generated
|
|
4011
|
+
# set that is ci.yml's test job, which has had this trigger all along.
|
|
4012
|
+
#
|
|
4013
|
+
# The branch list is the consumer's own ci.branches, the same reading
|
|
4014
|
+
# ci.yml and gates.yml use. A literal here would be a second decider and
|
|
4015
|
+
# would be wrong on every repository whose default branch is not ours.
|
|
4016
|
+
push:
|
|
4017
|
+
branches:
|
|
4018
|
+
${branchList}
|
|
4002
4019
|
${AI_REVIEW_PULL_REQUEST_TRIGGER}
|
|
4003
4020
|
|
|
4004
4021
|
${aiReviewPermissions}
|
package/lib/spec-updater.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* replaces ACCEPTED status with SHIPPED + issue number.
|
|
5
5
|
* Project-agnostic: never hardcodes any specific spec filename.
|
|
6
6
|
*/
|
|
7
|
-
import { readFileSync,
|
|
8
|
-
import {
|
|
7
|
+
import { readFileSync, existsSync } from "fs";
|
|
8
|
+
import { skipLine } from "./derived-spec";
|
|
9
|
+
import { maySpecBeWritten, writeSpec } from "./write-spec";
|
|
9
10
|
|
|
10
11
|
export interface SpecUpdateInput {
|
|
11
12
|
goalRecord: {
|
|
@@ -83,20 +84,23 @@ export async function updateSpecStatus(input: SpecUpdateInput): Promise<SpecUpda
|
|
|
83
84
|
// #1286: marking a decision row SHIPPED is an in-place spec edit. On a
|
|
84
85
|
// spec a generator owns it is discarded at the next regeneration, after
|
|
85
86
|
// breaking whatever pins the file.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
// #1552: asked early because the caller's `skipped`/`reason` fields are
|
|
88
|
+
// part of this function's contract, then asked again by `writeSpec`. Two
|
|
89
|
+
// consults of one decider — `mayWrite` — not two deciders.
|
|
90
|
+
const early = maySpecBeWritten(content);
|
|
91
|
+
if (rowsUpdated > 0 && !early.allowed) {
|
|
92
|
+
console.warn(skipLine(specPath, early.reading));
|
|
89
93
|
return {
|
|
90
94
|
updated: false,
|
|
91
95
|
skipped: true,
|
|
92
96
|
specPath,
|
|
93
97
|
rowsUpdated: 0,
|
|
94
|
-
reason: skipLine(specPath,
|
|
98
|
+
reason: skipLine(specPath, early.reading),
|
|
95
99
|
};
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
if (rowsUpdated > 0) {
|
|
99
|
-
|
|
103
|
+
writeSpec(specPath, content);
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
return {
|