@patronage/factory-ci 1.0.0-alpha.46 → 1.0.0-alpha.48
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/README.md +9 -6
- package/dist/.build-fingerprint.json +1 -1
- package/dist/alchemy/index.d.ts +2 -2
- package/dist/alchemy/index.js +20 -10
- package/dist/{bundle-alchemy-entry-Ba1Ebp91.js → bundle-alchemy-entry-CcxZTIqt.js} +4 -5
- package/dist/{execute-alchemy-entry-CxQrjSg8.js → execute-alchemy-entry-D-dMPvaC.js} +1 -1
- package/dist/index.d.ts +51 -17
- package/dist/index.js +221 -31
- package/package.json +10 -8
- package/src/alchemy/destroy-postcondition.ts +12 -4
- package/src/alchemy/evaluate-stack.ts +5 -0
- package/src/alchemy/lifecycle.ts +6 -4
- package/src/alchemy/state-tree.ts +6 -4
- package/src/github-transport.ts +1 -1
- package/src/index.ts +1 -0
- package/src/proof-reuse-gate.ts +207 -24
- package/src/proof-reuse-presentation.ts +19 -4
- package/src/vitest-profile-reader.ts +1 -1
- package/src/vitest-profile.ts +5 -2
package/src/proof-reuse-gate.ts
CHANGED
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* It answers one question, before checkout and before install: may this job
|
|
5
5
|
* reuse the local verification the factory already published for *this exact
|
|
6
|
-
* head*?
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* head*? On a pull request the head is the PR branch tip. On a push to the
|
|
7
|
+
* default branch, a **merge fallback** extends "this exact head" to "this
|
|
8
|
+
* exact tree": a merge whose tree is byte-identical to the producing pull
|
|
9
|
+
* request's proven head tree reuses that head's proof, but only when the proof
|
|
10
|
+
* is a whole-tree run that *executed* every command the surface requires
|
|
11
|
+
* (#1658). Impact-stamp releases and diff-scoped runs never count on a push,
|
|
12
|
+
* because a merge target is owed the whole tree (#931). Refusing runs hosted
|
|
13
|
+
* CI; it never fails the candidate.
|
|
9
14
|
*
|
|
10
15
|
* What a consumer chooses is only *what its guarded surface requires*: the
|
|
11
16
|
* plain profile command objects that surface selects. Everything else below is
|
|
@@ -108,6 +113,14 @@ export const FACTORY_PROOF_GATE_MODE_OUTPUT = "mode";
|
|
|
108
113
|
/** Exact Checks API URL of the proof generation selected by the gate. */
|
|
109
114
|
export const FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT = "source-check-url";
|
|
110
115
|
|
|
116
|
+
/**
|
|
117
|
+
* The commit whose proof was reused, when the gate reused one. On a pull
|
|
118
|
+
* request it is the head itself; on a merge-target push it is the producing
|
|
119
|
+
* pull request's head, a different commit than the pushed one (#1658). Empty
|
|
120
|
+
* on every refusal.
|
|
121
|
+
*/
|
|
122
|
+
export const FACTORY_PROOF_GATE_SOURCE_HEAD_OUTPUT = "source-head";
|
|
123
|
+
|
|
111
124
|
/**
|
|
112
125
|
* Guard for every step the gate protects. Deliberately `!= 'true'` and not
|
|
113
126
|
* `== 'false'`: an unset, empty, or garbled output must run the suite.
|
|
@@ -115,21 +128,32 @@ export const FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT = "source-check-url";
|
|
|
115
128
|
export const FACTORY_PROOF_GATE_GUARD = `steps.${FACTORY_PROOF_GATE_STEP_ID}.outputs.${FACTORY_PROOF_GATE_OUTPUT} != 'true'`;
|
|
116
129
|
|
|
117
130
|
/**
|
|
118
|
-
* Pull requests
|
|
119
|
-
*
|
|
131
|
+
* Pull requests, plus pushes to the default branch (#611, #1658) — the gate's
|
|
132
|
+
* single condition.
|
|
133
|
+
*
|
|
134
|
+
* A merge target's guarantee is about the whole tree, not the diff. A squash
|
|
135
|
+
* merge mints a new commit, so no proof is ever written for the merged SHA;
|
|
136
|
+
* the push path exists only for the merge fallback, which reuses the
|
|
137
|
+
* producing pull request's head proof when the merge tree *is* that head's
|
|
138
|
+
* tree and the proof's whole-tree run executed every command the surface
|
|
139
|
+
* requires.
|
|
120
140
|
*
|
|
121
|
-
*
|
|
122
|
-
* candidate proof
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* proof
|
|
141
|
+
* #931 is why both conditions are load-bearing. A `main` push once reused an
|
|
142
|
+
* impact-scoped candidate proof, executed no command for an untouched
|
|
143
|
+
* package, and left that package red for three days. An impact-scoped proof
|
|
144
|
+
* is a sound gate for the candidate and an unsound one for the merge target,
|
|
145
|
+
* so a push credits no `notRequiredCommands` release. The same holds for a
|
|
146
|
+
* command that ran but scoped itself to the diff through the run context
|
|
147
|
+
* (`psf affected`): only a proof recording `runScope: "whole-tree"` counts.
|
|
148
|
+
* Anything else runs the full battery.
|
|
128
149
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
150
|
+
* The push side is deliberately the default branch only. Which branches
|
|
151
|
+
* trigger a workflow at all stays repository-owned; this condition only keeps
|
|
152
|
+
* the gate from consulting proof on pushes that are not merges into the
|
|
153
|
+
* default branch.
|
|
131
154
|
*/
|
|
132
|
-
export const FACTORY_PROOF_GATE_IF =
|
|
155
|
+
export const FACTORY_PROOF_GATE_IF =
|
|
156
|
+
"github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch))";
|
|
133
157
|
|
|
134
158
|
/**
|
|
135
159
|
* The complete refusal vocabulary: the only distinctions the gate can make
|
|
@@ -291,6 +315,15 @@ export const resolveProofReuseCommands = (
|
|
|
291
315
|
* jq program: every page of the Checks API result in, four sanitized lines
|
|
292
316
|
* (`reason`, `mode`, uncovered commands, source URL) out.
|
|
293
317
|
*
|
|
318
|
+
* `$creditReleases` is `true` on a pull request and `false` on any push,
|
|
319
|
+
* the merge fallback included. With it `false`, a validated
|
|
320
|
+
* `notRequiredCommands` release still covers nothing, and the proof must
|
|
321
|
+
* also record `runScope: "whole-tree"`: `pr:verify` hands each command the
|
|
322
|
+
* diff, and a command may scope itself to it (`psf affected`), so a command
|
|
323
|
+
* name in `executedCommands` says the command ran, not that it covered the
|
|
324
|
+
* tree. Only a whole-tree run's executed commands are what a merge target is
|
|
325
|
+
* owed (#931, #1658). Without it, `whole-tree run` is reported missing.
|
|
326
|
+
*
|
|
294
327
|
* The input is what `gh api --paginate` actually writes: the pages
|
|
295
328
|
* *concatenated* as a stream of top-level response objects, not merged into
|
|
296
329
|
* one document and not wrapped in an array. That is why the script invokes
|
|
@@ -638,8 +671,13 @@ def releaseAuthorized($release; $commands; $stamp):
|
|
|
638
671
|
and (([$releases[].name] - $executed | length) == ($releases | length))
|
|
639
672
|
and ($releases | all(.[]; releaseAuthorized(.; $commands; $stamp)))
|
|
640
673
|
end) as $releasesValid
|
|
641
|
-
| (if $releasesValid
|
|
642
|
-
|
|
674
|
+
| (if $releasesValid and $creditReleases
|
|
675
|
+
then [$releases[].name]
|
|
676
|
+
else []
|
|
677
|
+
end) as $released
|
|
678
|
+
| ($creditReleases or ($proof.runScope == "whole-tree")) as $wholeTree
|
|
679
|
+
| ( ($required - $executed - $released)
|
|
680
|
+
+ (if $wholeTree then [] else ["whole-tree run"] end) ) as $missing
|
|
643
681
|
| (if $run.status != "completed" then "pending"
|
|
644
682
|
elif $run.conclusion != "success" then "failed"
|
|
645
683
|
elif ($run | bound | not) then "unreadable"
|
|
@@ -681,6 +719,109 @@ const safeLabel = (surface: string): string => {
|
|
|
681
719
|
return cleaned.length > 0 ? cleaned : "verification";
|
|
682
720
|
};
|
|
683
721
|
|
|
722
|
+
/**
|
|
723
|
+
* The push-event merge fallback (#611, restored with executed-only coverage
|
|
724
|
+
* by #1658). Emitted into every gate script; on a pull request event it is
|
|
725
|
+
* inert.
|
|
726
|
+
*/
|
|
727
|
+
const MERGE_FALLBACK_BLOCK = String.raw`# Merge fallback (#611, #1658). A squash merge mints a new commit, so the
|
|
728
|
+
# direct read at a pushed merge-target head finds nothing even when the
|
|
729
|
+
# factory proved the producing pull request head. Only when the direct read
|
|
730
|
+
# found no generation at all on a push event, look up the producing pull
|
|
731
|
+
# request and reuse its head proof, and only when:
|
|
732
|
+
#
|
|
733
|
+
# - the merge commit's TREE id equals the proven head's tree id, which makes
|
|
734
|
+
# the pushed content byte-identical to what was verified. That is a clean
|
|
735
|
+
# squash of a head that already contained the previous default-branch tip.
|
|
736
|
+
# Patch identity was considered and rejected as the comparator: git
|
|
737
|
+
# patch-id normalizes whitespace and ignores base motion, so an identical
|
|
738
|
+
# patch can still produce an integrated tree that was never tested. Tree
|
|
739
|
+
# identity also makes "no other merge landed in between" unnecessary to
|
|
740
|
+
# check separately: if one had, the trees would differ.
|
|
741
|
+
# - the proof EXECUTED every command this surface requires, in a run that
|
|
742
|
+
# handed every command the whole tree (runScope "whole-tree"). Impact-stamp
|
|
743
|
+
# releases are not credited here (gate_lookup ... false), and neither is a
|
|
744
|
+
# diff-scoped run, whose commands may have scoped themselves to the diff:
|
|
745
|
+
# both are weaker than the whole tree a merge target is owed (#931).
|
|
746
|
+
#
|
|
747
|
+
# Everything else -- no unique merged producing PR, an unreadable commit, a
|
|
748
|
+
# proof that is anything but proven, an executed set that does not cover the
|
|
749
|
+
# surface, or tree drift from a dirty or stale merge -- leaves the direct
|
|
750
|
+
# "none" refusal standing, so the full suite runs (fail open).
|
|
751
|
+
if [ "$reason" = 'none' ] && [ "${shellExpansion("GITHUB_EVENT_NAME:-")}" = 'push' ]; then
|
|
752
|
+
producing_head=''
|
|
753
|
+
producing_number=''
|
|
754
|
+
producing_row=''
|
|
755
|
+
merge_tree=''
|
|
756
|
+
head_tree=''
|
|
757
|
+
if ! producing_pulls=$(gh api --method GET --paginate \
|
|
758
|
+
"repos/$GITHUB_REPOSITORY/commits/$HEAD_SHA/pulls" \
|
|
759
|
+
-f per_page=100 2>&1); then
|
|
760
|
+
detail="producing pull request unreadable: $producing_pulls"
|
|
761
|
+
elif ! producing_row=$(jq -r -s \
|
|
762
|
+
--arg sha "$HEAD_SHA" \
|
|
763
|
+
'[ add[]?
|
|
764
|
+
| select((.merged_at // null) != null)
|
|
765
|
+
| select((.merge_commit_sha // "") == $sha)
|
|
766
|
+
| [((.head.sha // "") | tostring), ((.number // "") | tostring)]
|
|
767
|
+
| join(" ") ]
|
|
768
|
+
| if length == 1 then .[0] else "" end' 2>&1 <<< "$producing_pulls"); then
|
|
769
|
+
detail="producing pull request unreadable: $producing_row"
|
|
770
|
+
producing_row=''
|
|
771
|
+
fi
|
|
772
|
+
if [ -n "$producing_row" ]; then
|
|
773
|
+
read -r producing_head producing_number <<< "$producing_row" || :
|
|
774
|
+
fi
|
|
775
|
+
if [ -n "$detail" ]; then
|
|
776
|
+
:
|
|
777
|
+
elif ! [[ "$producing_head" =~ ^[0-9a-f]{40}$ ]] \
|
|
778
|
+
|| ! [[ "$producing_number" =~ ^[0-9]+$ ]]; then
|
|
779
|
+
detail='no single merged producing pull request at this commit'
|
|
780
|
+
producing_head=''
|
|
781
|
+
elif ! merge_commit=$(gh api --method GET \
|
|
782
|
+
"repos/$GITHUB_REPOSITORY/commits/$HEAD_SHA" 2>&1); then
|
|
783
|
+
detail="merge commit unreadable: $merge_commit"
|
|
784
|
+
elif ! merge_tree=$(jq -r \
|
|
785
|
+
'(.commit.tree.sha // "") | tostring' 2>&1 <<< "$merge_commit"); then
|
|
786
|
+
detail="merge commit unreadable: $merge_tree"
|
|
787
|
+
merge_tree=''
|
|
788
|
+
elif ! [[ "$merge_tree" =~ ^[0-9a-f]{40}$ ]]; then
|
|
789
|
+
detail='merge commit carries no readable tree id'
|
|
790
|
+
merge_tree=''
|
|
791
|
+
elif ! head_commit=$(gh api --method GET \
|
|
792
|
+
"repos/$GITHUB_REPOSITORY/commits/$producing_head" 2>&1); then
|
|
793
|
+
detail="producing head commit unreadable: $head_commit"
|
|
794
|
+
elif ! head_tree=$(jq -r \
|
|
795
|
+
'(.commit.tree.sha // "") | tostring' 2>&1 <<< "$head_commit"); then
|
|
796
|
+
detail="producing head commit unreadable: $head_tree"
|
|
797
|
+
head_tree=''
|
|
798
|
+
elif ! [[ "$head_tree" =~ ^[0-9a-f]{40}$ ]]; then
|
|
799
|
+
detail='producing head commit carries no readable tree id'
|
|
800
|
+
head_tree=''
|
|
801
|
+
elif [ "$merge_tree" != "$head_tree" ]; then
|
|
802
|
+
detail="tree drift: the merge result is not the tree proven at pull request #$producing_number head $producing_head"
|
|
803
|
+
merge_tree=''
|
|
804
|
+
fi
|
|
805
|
+
if [ -z "$detail" ] \
|
|
806
|
+
&& [[ "$producing_head" =~ ^[0-9a-f]{40}$ ]] \
|
|
807
|
+
&& [[ "$merge_tree" =~ ^[0-9a-f]{40}$ ]] \
|
|
808
|
+
&& [ "$merge_tree" = "$head_tree" ]; then
|
|
809
|
+
gate_lookup "$producing_head" false
|
|
810
|
+
if [ "$lookup_reason" = 'proven' ]; then
|
|
811
|
+
reason=proven
|
|
812
|
+
mode="$lookup_mode"
|
|
813
|
+
missing=''
|
|
814
|
+
source_url="$lookup_url"
|
|
815
|
+
proof_head="$producing_head"
|
|
816
|
+
merge_note="pull request #$producing_number. The merge result's tree \`$merge_tree\` is byte-identical to the tree proven at its head \`$producing_head\`, and that proof's whole-tree run executed every command this surface requires"
|
|
817
|
+
elif [ "$lookup_reason" = 'incomplete' ]; then
|
|
818
|
+
detail="producing pull request #$producing_number proof not reusable (incomplete: a merge target counts only the commands a whole-tree run executed; missing: $lookup_missing)"
|
|
819
|
+
else
|
|
820
|
+
detail="producing pull request #$producing_number proof not reusable ($lookup_reason) $lookup_detail"
|
|
821
|
+
fi
|
|
822
|
+
fi
|
|
823
|
+
fi`;
|
|
824
|
+
|
|
684
825
|
const gateScript = (required: readonly string[], surface: string): string =>
|
|
685
826
|
String.raw`
|
|
686
827
|
set -uo pipefail
|
|
@@ -695,12 +836,19 @@ detail=''
|
|
|
695
836
|
mode=''
|
|
696
837
|
missing=''
|
|
697
838
|
source_url=''
|
|
839
|
+
proof_head=''
|
|
840
|
+
merge_note=''
|
|
698
841
|
|
|
699
842
|
# One proof lookup at one commit. Sets lookup_reason / lookup_mode /
|
|
700
843
|
# lookup_missing / lookup_url, or lookup_detail when the read itself
|
|
701
844
|
# failed. Always returns 0: every caller must reach the single
|
|
702
845
|
# GITHUB_OUTPUT write below whatever this function meets.
|
|
703
846
|
#
|
|
847
|
+
# $2 is whether impact-stamp releases may cover a required command: 'true'
|
|
848
|
+
# on a pull request, 'false' on any push, where only executed commands count
|
|
849
|
+
# because a merge target is owed the whole tree (#931, #1658). Anything but
|
|
850
|
+
# 'true' is false.
|
|
851
|
+
#
|
|
704
852
|
# filter=all with full pagination is load-bearing (ADR 0022). GitHub's
|
|
705
853
|
# default "latest" filter is ordered by completion, so a newer generation
|
|
706
854
|
# that is still running can be hidden behind an older completed one — the
|
|
@@ -711,6 +859,10 @@ gate_lookup() {
|
|
|
711
859
|
lookup_missing=''
|
|
712
860
|
lookup_url=''
|
|
713
861
|
lookup_detail=''
|
|
862
|
+
lookup_credit=false
|
|
863
|
+
if [ "${shellExpansion("2:-")}" = 'true' ]; then
|
|
864
|
+
lookup_credit=true
|
|
865
|
+
fi
|
|
714
866
|
if ! lookup_response=$(gh api --method GET --paginate \
|
|
715
867
|
"repos/$GITHUB_REPOSITORY/commits/$1/check-runs" \
|
|
716
868
|
-f "check_name=$CHECK_NAME" \
|
|
@@ -727,6 +879,7 @@ gate_lookup() {
|
|
|
727
879
|
--arg sha "$1" \
|
|
728
880
|
--arg repository "$GITHUB_REPOSITORY" \
|
|
729
881
|
--argjson required "$REQUIRED_COMMANDS" \
|
|
882
|
+
--argjson creditReleases "$lookup_credit" \
|
|
730
883
|
'${GATE_JQ}' 2>&1 <<< "$lookup_response"); then
|
|
731
884
|
lookup_detail="unreadable proof binding: $lookup_finding"
|
|
732
885
|
return 0
|
|
@@ -762,14 +915,25 @@ if [ -z "${shellExpansion("HEAD_SHA:-")}" ]; then
|
|
|
762
915
|
elif [ -z "${shellExpansion("GITHUB_REPOSITORY:-")}" ]; then
|
|
763
916
|
detail='no repository name'
|
|
764
917
|
else
|
|
765
|
-
|
|
918
|
+
# A push is a merge target even when the pushed tip is a candidate's own
|
|
919
|
+
# head (a fast-forward), so it credits executed commands only there too.
|
|
920
|
+
direct_credit=true
|
|
921
|
+
if [ "${shellExpansion("GITHUB_EVENT_NAME:-")}" = 'push' ]; then
|
|
922
|
+
direct_credit=false
|
|
923
|
+
fi
|
|
924
|
+
gate_lookup "$HEAD_SHA" "$direct_credit"
|
|
766
925
|
reason="$lookup_reason"
|
|
767
926
|
detail="$lookup_detail"
|
|
768
927
|
mode="$lookup_mode"
|
|
769
928
|
missing="$lookup_missing"
|
|
770
929
|
source_url="$lookup_url"
|
|
930
|
+
if [ "$reason" = 'proven' ]; then
|
|
931
|
+
proof_head="$HEAD_SHA"
|
|
932
|
+
fi
|
|
771
933
|
fi
|
|
772
934
|
|
|
935
|
+
${MERGE_FALLBACK_BLOCK}
|
|
936
|
+
|
|
773
937
|
# The binding is App-verified, but it still reaches markdown. Only a plain
|
|
774
938
|
# lowercase token is quoted back; anything else is reported as unknown.
|
|
775
939
|
case "$mode" in
|
|
@@ -780,6 +944,8 @@ esac
|
|
|
780
944
|
verdict=false
|
|
781
945
|
if [ "$reason" = 'proven' ]; then
|
|
782
946
|
verdict=true
|
|
947
|
+
else
|
|
948
|
+
proof_head=''
|
|
783
949
|
fi
|
|
784
950
|
|
|
785
951
|
# detail can carry arbitrary gh or jq error text. Collapse it to one bounded
|
|
@@ -803,7 +969,7 @@ say ''
|
|
|
803
969
|
|
|
804
970
|
case "$reason" in
|
|
805
971
|
proven)
|
|
806
|
-
echo "Factory proof: reusing local verification of $
|
|
972
|
+
echo "Factory proof: reusing local verification of $proof_head; skipping the $SURFACE suite."
|
|
807
973
|
say "Skipped. The factory already verified this exact content, so this job did not run the $SURFACE suite a second time."
|
|
808
974
|
say ''
|
|
809
975
|
if [ -n "$source_url" ]; then
|
|
@@ -811,13 +977,20 @@ case "$reason" in
|
|
|
811
977
|
else
|
|
812
978
|
say "- Reused proof: the \`$CHECK_NAME\` check run published by the pinned factory GitHub App."
|
|
813
979
|
fi
|
|
814
|
-
say "- Covers head: \`$
|
|
980
|
+
say "- Covers head: \`$proof_head\`"
|
|
981
|
+
if [ -n "$merge_note" ]; then
|
|
982
|
+
say "- Merge-target reuse: $merge_note."
|
|
983
|
+
fi
|
|
815
984
|
say "- Recorded mode: \`$mode\` (diagnostic only), outcome \`passed\`."
|
|
816
985
|
;;
|
|
817
986
|
none)
|
|
818
987
|
say 'Ran the full suite. No trusted factory proof covers this commit.'
|
|
819
988
|
say ''
|
|
820
989
|
say "The factory GitHub App has published no \`$CHECK_NAME\` check run at head \`$HEAD_SHA\`. Proof is keyed to the commit, so proof written for any other commit is not visible here. A pull request opened by hand carries no factory proof at all, which is normal."
|
|
990
|
+
if [ -n "$detail" ]; then
|
|
991
|
+
say ''
|
|
992
|
+
say "- Merge fallback: $detail"
|
|
993
|
+
fi
|
|
821
994
|
say ''
|
|
822
995
|
say '${CORRECTIVE_LINE}'
|
|
823
996
|
;;
|
|
@@ -845,7 +1018,11 @@ case "$reason" in
|
|
|
845
1018
|
incomplete)
|
|
846
1019
|
say "Ran the full suite. The factory proof for this commit does not cover every command the $SURFACE surface requires."
|
|
847
1020
|
say ''
|
|
848
|
-
|
|
1021
|
+
if [ "${shellExpansion("GITHUB_EVENT_NAME:-")}" = 'push' ]; then
|
|
1022
|
+
say "The newest \`$CHECK_NAME\` check run at head \`$HEAD_SHA\` passed, but a merge target counts only the commands a whole-tree run executed, and those do not cover this surface. Missing: \`$missing\`"
|
|
1023
|
+
else
|
|
1024
|
+
say "The newest \`$CHECK_NAME\` check run at head \`$HEAD_SHA\` passed, but its executed commands plus stamp-authorized \`notRequiredCommands\` do not cover this surface. Missing: \`$missing\`"
|
|
1025
|
+
fi
|
|
849
1026
|
say ''
|
|
850
1027
|
say '${CORRECTIVE_LINE}'
|
|
851
1028
|
;;
|
|
@@ -877,6 +1054,7 @@ fi
|
|
|
877
1054
|
printf '${FACTORY_PROOF_GATE_REASON_OUTPUT}=%s\n' "$reason"
|
|
878
1055
|
printf '${FACTORY_PROOF_GATE_MODE_OUTPUT}=%s\n' "$mode"
|
|
879
1056
|
printf '${FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT}=%s\n' "$source_url"
|
|
1057
|
+
printf '${FACTORY_PROOF_GATE_SOURCE_HEAD_OUTPUT}=%s\n' "$proof_head"
|
|
880
1058
|
} >> "${shellExpansion("GITHUB_OUTPUT:-/dev/null")}"
|
|
881
1059
|
`.trim();
|
|
882
1060
|
|
|
@@ -930,8 +1108,11 @@ export interface FactoryProofGateStep {
|
|
|
930
1108
|
* The step itself, structurally accepted by gagen's `step()` without adding a
|
|
931
1109
|
* gagen runtime dependency. It belongs first in the job it guards: a few API
|
|
932
1110
|
* reads with the default `GITHUB_TOKEN`, no checkout, no install, so a proven
|
|
933
|
-
* head costs a runner nothing beyond job startup.
|
|
934
|
-
*
|
|
1111
|
+
* head costs a runner nothing beyond job startup. A pull request read needs
|
|
1112
|
+
* only `checks: read`. The merge fallback on a default-branch push also reads
|
|
1113
|
+
* the producing pull request (`pull-requests: read`) and the two commit
|
|
1114
|
+
* objects whose tree ids it compares (`contents: read`). A job that grants
|
|
1115
|
+
* less loses only the fallback: the failed read degrades to the full suite.
|
|
935
1116
|
*
|
|
936
1117
|
* A **step, not a job**, and that is not a style preference. A separate gate
|
|
937
1118
|
* job that errored would leave the guarded job `skipped`, and a summary job
|
|
@@ -947,7 +1128,9 @@ export const factoryProofGateStep = (
|
|
|
947
1128
|
continueOnError: true as const,
|
|
948
1129
|
env: Object.freeze({
|
|
949
1130
|
GH_TOKEN: githubExpression("secrets.GITHUB_TOKEN"),
|
|
950
|
-
//
|
|
1131
|
+
// On a pull request the verified head is the PR branch tip. On a push
|
|
1132
|
+
// there is no pull_request payload and `github.sha` is the pushed head,
|
|
1133
|
+
// which the merge fallback resolves its producing pull request from.
|
|
951
1134
|
HEAD_SHA: githubExpression(
|
|
952
1135
|
"github.event.pull_request.head.sha || github.sha"
|
|
953
1136
|
),
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
FACTORY_PROOF_GATE_MODE_OUTPUT,
|
|
5
5
|
FACTORY_PROOF_GATE_OUTPUT,
|
|
6
6
|
FACTORY_PROOF_GATE_REASON_OUTPUT,
|
|
7
|
+
FACTORY_PROOF_GATE_SOURCE_HEAD_OUTPUT,
|
|
7
8
|
FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT,
|
|
8
9
|
FACTORY_PROOF_GATE_STEP_ID,
|
|
9
10
|
} from "./proof-reuse-gate.ts";
|
|
@@ -60,6 +61,8 @@ say '## ${label} timing'
|
|
|
60
61
|
say ''
|
|
61
62
|
|
|
62
63
|
if [ "${shellExpansion("GITHUB_EVENT_NAME:-")}" = 'push' ] && [ -z "${shellExpansion("PROOF_REASON:-")}" ]; then
|
|
64
|
+
# A push run with no recorded reason is one where the gate step's condition
|
|
65
|
+
# kept it off entirely: a push to a ref other than the default branch.
|
|
63
66
|
say '- Path: full execution, no proof consulted'
|
|
64
67
|
say '- Proof-reuse gate: did not run on this ref; the full suite ran.'
|
|
65
68
|
say "- Verified head: \`${shellExpansion("GITHUB_SHA:-unknown")}\`"
|
|
@@ -69,9 +72,18 @@ elif [ "${shellExpansion("PROOF_REUSED:-")}" = 'true' ]; then
|
|
|
69
72
|
if [ -n "${shellExpansion("PROOF_SOURCE_URL:-")}" ]; then
|
|
70
73
|
say "- Reused proof: [exact source check](${shellExpansion("PROOF_SOURCE_URL")})"
|
|
71
74
|
fi
|
|
72
|
-
|
|
75
|
+
# On a merge-target push the reused proof is the producing pull request
|
|
76
|
+
# head's, a different commit than the pushed one (#1658).
|
|
77
|
+
bound_head="${shellExpansion("PROOF_SOURCE_HEAD:-")}"
|
|
78
|
+
if [ -z "$bound_head" ]; then
|
|
79
|
+
bound_head="${shellExpansion("PROOF_HEAD_SHA:-unknown")}"
|
|
80
|
+
fi
|
|
81
|
+
say "- Bound head: \`$bound_head\`"
|
|
82
|
+
if [ "$bound_head" != "${shellExpansion("PROOF_HEAD_SHA:-")}" ]; then
|
|
83
|
+
say "- Merge target: \`${shellExpansion("PROOF_HEAD_SHA:-unknown")}\` has the same tree as the proven head"
|
|
84
|
+
fi
|
|
73
85
|
say "- Factory verification mode: ${shellExpansion("PROOF_MODE:-unavailable")} (diagnostic only)"
|
|
74
|
-
echo "::notice title=Factory proof reuse::Reused trusted local proof for ${label} at $
|
|
86
|
+
echo "::notice title=Factory proof reuse::Reused trusted local proof for ${label} at $bound_head."
|
|
75
87
|
else
|
|
76
88
|
say "- Path: full GitHub CI fallback (${shellExpansion("PROOF_REASON:-error")})"
|
|
77
89
|
say "- Bound head: \`${shellExpansion("PROOF_HEAD_SHA:-unknown")}\`"
|
|
@@ -104,8 +116,8 @@ export const factoryProofReuseSummaryStep = (
|
|
|
104
116
|
CI_STARTED_MS: githubExpression(
|
|
105
117
|
`steps.${FACTORY_PROOF_TIMING_STEP_ID}.outputs.started_ms`
|
|
106
118
|
),
|
|
107
|
-
// PR runs bind to the PR branch tip; push runs to the pushed head.
|
|
108
|
-
//
|
|
119
|
+
// PR runs bind to the PR branch tip; push runs to the pushed head. This
|
|
120
|
+
// value only labels the summary.
|
|
109
121
|
PROOF_HEAD_SHA: githubExpression(
|
|
110
122
|
"github.event.pull_request.head.sha || github.sha"
|
|
111
123
|
),
|
|
@@ -118,6 +130,9 @@ export const factoryProofReuseSummaryStep = (
|
|
|
118
130
|
PROOF_REUSED: githubExpression(
|
|
119
131
|
`steps.${FACTORY_PROOF_GATE_STEP_ID}.outputs.${FACTORY_PROOF_GATE_OUTPUT}`
|
|
120
132
|
),
|
|
133
|
+
PROOF_SOURCE_HEAD: githubExpression(
|
|
134
|
+
`steps.${FACTORY_PROOF_GATE_STEP_ID}.outputs.${FACTORY_PROOF_GATE_SOURCE_HEAD_OUTPUT}`
|
|
135
|
+
),
|
|
121
136
|
PROOF_SOURCE_URL: githubExpression(
|
|
122
137
|
`steps.${FACTORY_PROOF_GATE_STEP_ID}.outputs.${FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT}`
|
|
123
138
|
),
|
|
@@ -220,6 +220,6 @@ export const readVitestProfileDocument = (
|
|
|
220
220
|
// return reasons rather than narrowing `value`. Rebuilding the document
|
|
221
221
|
// field-by-field here would copy the writer's shape into the reader and let
|
|
222
222
|
// the two drift. Keep the one double assertion; the checks are the proof.
|
|
223
|
-
// oxlint-disable-next-line
|
|
223
|
+
// oxlint-disable-next-line quality/no-chained-type-assertions
|
|
224
224
|
return { kind: "profile", profile: value as unknown as VitestProfile };
|
|
225
225
|
};
|
package/src/vitest-profile.ts
CHANGED
|
@@ -454,8 +454,11 @@ const spawnVitest = async ({
|
|
|
454
454
|
try {
|
|
455
455
|
// `once` rejects if the child emits `error` first, which is how a Vitest
|
|
456
456
|
// that never started is told apart from one that ran and failed.
|
|
457
|
-
const [code, signal] = await once(child, "exit")
|
|
458
|
-
|
|
457
|
+
const [code, signal] = (await once(child, "exit")) as [
|
|
458
|
+
number | null,
|
|
459
|
+
NodeJS.Signals | null,
|
|
460
|
+
];
|
|
461
|
+
exitCode = code ?? (signal ? 1 : 0);
|
|
459
462
|
} catch (error) {
|
|
460
463
|
exitCode = 1;
|
|
461
464
|
failure = `Vitest could not start: ${
|