@soleur/opencode 3.357.15 → 3.357.17
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/package.json +1 -1
- package/scripts/affected-tests.sh +117 -16
- package/scripts/affected-tests.test.sh +581 -2
- package/scripts/collision-precheck.sh +141 -0
- package/scripts/lib/affected-tests/common.sh +20 -3
- package/scripts/lib/affected-tests/content-trigger.sh +248 -0
- package/skills/plan/SKILL.md +7 -5
- package/skills/review/SKILL.md +17 -18
- package/skills/ship/SKILL.md +6 -5
- package/skills/ship/references/affected-gate-contract.md +60 -3
- package/skills/work/SKILL.md +22 -26
package/package.json
CHANGED
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
# Exit contract — produced ONLY by finish() in lib/affected-tests/common.sh,
|
|
30
30
|
# the single exit site for the whole gate:
|
|
31
31
|
# 0 every selected test passed, OR NO_TESTS_AFFECTED for an all-inert diff
|
|
32
|
-
# 1 a selected test failed,
|
|
33
|
-
# maps to 1 reason=runner-signal)
|
|
32
|
+
# 1 a selected test failed, the delegated runner was signal-killed (rc 3
|
|
33
|
+
# maps to 1 reason=runner-signal), or the content-trigger command failed
|
|
34
|
+
# (reason=content-trigger-failed); a failure seen before budget expiry
|
|
34
35
|
# wins over deferral
|
|
35
36
|
# 4 AFFECTED_GATE_REFUSED — no-stack, bad-config key=<k>,
|
|
36
37
|
# vacuous-test-command, no-base-ref, not-a-repo (--self-check outside a
|
|
@@ -71,6 +72,22 @@
|
|
|
71
72
|
# must be a positive integer
|
|
72
73
|
# max_workers number overrides the width formula; positive integer
|
|
73
74
|
# budget_ci boolean forces CI-deferral eligibility without a workflow
|
|
75
|
+
# content_trigger_pattern / content_trigger_paths / content_trigger_command
|
|
76
|
+
# string / string[] / string ALL THREE or none (a partial or
|
|
77
|
+
# empty group → rc 4 bad-config naming the key, as do a
|
|
78
|
+
# match-everything glob, a glob that can never match
|
|
79
|
+
# (`./x/*`, `/x/*`, `x/`) and a vacuous command). When a
|
|
80
|
+
# diff ADDS a line (tracked) or holds a line (untracked)
|
|
81
|
+
# containing the fixed string in a file under the globs,
|
|
82
|
+
# a passing run — selected, inert, or a gate-side
|
|
83
|
+
# escalation to full — ALSO runs the command (via
|
|
84
|
+
# `bash -c`, same trust as test_command). An operator's
|
|
85
|
+
# own --full, test_command and --explain never run it.
|
|
86
|
+
# A scan that cannot decide runs it; a failing primary
|
|
87
|
+
# skips it. The marker gains a trailing
|
|
88
|
+
# `content_trigger=<clear|ran|failed|deferred|skipped|
|
|
89
|
+
# scan-error>`; --explain prints `CONTENT_TRIGGER
|
|
90
|
+
# armed=1 state=…`. Lib: content-trigger.sh
|
|
74
91
|
#
|
|
75
92
|
# Base-ref order (adapter arm only — a delegated runner resolves its own):
|
|
76
93
|
# --base > @{upstream} > origin/HEAD > origin/main >
|
|
@@ -118,6 +135,8 @@ source "$GATE_DIR/lib/affected-tests/js.sh"
|
|
|
118
135
|
source "$GATE_DIR/lib/affected-tests/python.sh"
|
|
119
136
|
# shellcheck source=plugins/soleur/scripts/lib/affected-tests/go.sh
|
|
120
137
|
source "$GATE_DIR/lib/affected-tests/go.sh"
|
|
138
|
+
# shellcheck source=plugins/soleur/scripts/lib/affected-tests/content-trigger.sh
|
|
139
|
+
source "$GATE_DIR/lib/affected-tests/content-trigger.sh"
|
|
121
140
|
|
|
122
141
|
# Scratch files (config dump, changed-set census, adapter logs) are registered
|
|
123
142
|
# in AFFECTED_SCRATCH by affected_mktemp — remove them on every exit shape,
|
|
@@ -162,6 +181,10 @@ while (( $# > 0 )); do
|
|
|
162
181
|
shift
|
|
163
182
|
done
|
|
164
183
|
|
|
184
|
+
# The operator's own --full, captured before any arm can escalate ARG_FULL: the
|
|
185
|
+
# content trigger skips only an explicit --full, never a gate-side escalation.
|
|
186
|
+
ARG_FULL_REQUESTED=$ARG_FULL
|
|
187
|
+
|
|
165
188
|
# --- repository root ------------------------------------------------------------
|
|
166
189
|
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
|
|
167
190
|
if [[ -z "$REPO_ROOT" ]]; then
|
|
@@ -213,6 +236,22 @@ affected_detect_ci() {
|
|
|
213
236
|
return 1
|
|
214
237
|
}
|
|
215
238
|
|
|
239
|
+
# --- glob matcher ---------------------------------------------------------------------
|
|
240
|
+
# A pattern containing `/` matches the whole path; `**/` also matches zero
|
|
241
|
+
# directories (its `**/` prefix is stripped for the second try). A bare
|
|
242
|
+
# pattern matches the basename. Defined before the config block: the
|
|
243
|
+
# match-everything probes and the content trigger both call it.
|
|
244
|
+
affected_glob_match() {
|
|
245
|
+
local p="$1" pat="$2" alt
|
|
246
|
+
if [[ "$pat" == */* ]]; then
|
|
247
|
+
[[ "$p" == $pat ]] && return 0
|
|
248
|
+
alt="${pat//\*\//}"
|
|
249
|
+
[[ "$alt" != "$pat" && "$p" == $alt ]] && return 0
|
|
250
|
+
return 1
|
|
251
|
+
fi
|
|
252
|
+
[[ "${p##*/}" == $pat ]]
|
|
253
|
+
}
|
|
254
|
+
|
|
216
255
|
# --- config: .soleur-test-gate.json ------------------------------------------------
|
|
217
256
|
CFG_TEST_COMMAND=""
|
|
218
257
|
CFG_BUDGET_SECONDS=900 # default, unmeasured
|
|
@@ -222,6 +261,10 @@ CFG_GLOBAL_SET=0
|
|
|
222
261
|
CFG_INERT_SET=0
|
|
223
262
|
CFG_GLOBAL_PATHS=()
|
|
224
263
|
CFG_INERT_PATHS=()
|
|
264
|
+
# Content trigger (lib content-trigger.sh): three flat keys, all or none. Values
|
|
265
|
+
# land directly in AFFECTED_CT_PATTERN/_PATHS/_COMMAND; this flag records that any
|
|
266
|
+
# of the three appeared, so a partial group is refused rather than silently ignored.
|
|
267
|
+
CFG_CT_SET=0
|
|
225
268
|
|
|
226
269
|
# Dump the JSON object as NUL-separated KEY\0TYPE\0VALUE\0 triples on stdout —
|
|
227
270
|
# array elements arrive as one `elem:<type>` record each, an empty array as a
|
|
@@ -300,6 +343,10 @@ JSEOF
|
|
|
300
343
|
return 2
|
|
301
344
|
}
|
|
302
345
|
|
|
346
|
+
# Refusal of a content-trigger key: names the offending key (a missing key and an empty one
|
|
347
|
+
# are the same refusal).
|
|
348
|
+
_affected_ct_bad() { finish 4 none "bad-config key=$1" config "$CI_NAME" - - -; }
|
|
349
|
+
|
|
303
350
|
# Load and validate. Fail-closed everywhere: malformed, unknown key, or wrong
|
|
304
351
|
# type → rc 4 reason=bad-config key=<k>; a vacuous test_command →
|
|
305
352
|
# reason=vacuous-test-command.
|
|
@@ -346,6 +393,23 @@ affected_load_config() {
|
|
|
346
393
|
budget_ci)
|
|
347
394
|
[[ "$t" == boolean ]] || { badkey="$k"; break; }
|
|
348
395
|
CFG_BUDGET_CI="$v" ;;
|
|
396
|
+
content_trigger_pattern)
|
|
397
|
+
[[ "$t" == string ]] || { badkey="$k"; break; }
|
|
398
|
+
CFG_CT_SET=1
|
|
399
|
+
AFFECTED_CT_PATTERN="$v" ;;
|
|
400
|
+
content_trigger_command)
|
|
401
|
+
[[ "$t" == string ]] || { badkey="$k"; break; }
|
|
402
|
+
CFG_CT_SET=1
|
|
403
|
+
AFFECTED_CT_COMMAND="$v" ;;
|
|
404
|
+
content_trigger_paths)
|
|
405
|
+
if [[ "$t" == array ]]; then
|
|
406
|
+
CFG_CT_SET=1
|
|
407
|
+
elif [[ "$t" == elem:string ]]; then
|
|
408
|
+
CFG_CT_SET=1
|
|
409
|
+
AFFECTED_CT_PATHS+=("$v")
|
|
410
|
+
else
|
|
411
|
+
badkey="$k"; break
|
|
412
|
+
fi ;;
|
|
349
413
|
*) badkey="$k"; break ;;
|
|
350
414
|
esac
|
|
351
415
|
done <"$tmp"
|
|
@@ -353,6 +417,39 @@ affected_load_config() {
|
|
|
353
417
|
finish 4 none "bad-config key=$(affected_marker_field "$badkey")" config "$CI_NAME" - - -
|
|
354
418
|
fi
|
|
355
419
|
|
|
420
|
+
# Content trigger: all three keys or none, each refused naming ITS key (a missing
|
|
421
|
+
# key and an empty one are the same refusal). A half-declared trigger that silently
|
|
422
|
+
# never fires is exactly the failure it exists to prevent.
|
|
423
|
+
if (( CFG_CT_SET )); then
|
|
424
|
+
if [[ -z "$AFFECTED_CT_PATTERN" || "$AFFECTED_CT_PATTERN" == *$'\n'* ]]; then
|
|
425
|
+
_affected_ct_bad content_trigger_pattern
|
|
426
|
+
fi
|
|
427
|
+
((${#AFFECTED_CT_PATHS[@]} > 0)) || _affected_ct_bad content_trigger_paths
|
|
428
|
+
local _ct_g _ct_probe
|
|
429
|
+
for _ct_g in "${AFFECTED_CT_PATHS[@]}"; do
|
|
430
|
+
# Refused: empty, multi-line or whitespace-bearing globs; shapes that can never match
|
|
431
|
+
# a repo-relative path in `[[ == ]]` (leading `./`, `/` or `!`, trailing `/`, `//`, a
|
|
432
|
+
# `.`/`..` segment, `{a,b}` which is not expanded); and a match-everything glob (the
|
|
433
|
+
# scan would be unbounded and the command near-permanent, as for inert_paths): any
|
|
434
|
+
# glob that matches one of a handful of improbable probe paths.
|
|
435
|
+
if [[ -z "$_ct_g" || "$_ct_g" == *$'\n'* || "$_ct_g" == *[[:space:]]* \
|
|
436
|
+
|| "$_ct_g" == ./* || "$_ct_g" == /* || "$_ct_g" == '!'* || "$_ct_g" == */ \
|
|
437
|
+
|| "$_ct_g" == *//* || "$_ct_g" == */./* || "$_ct_g" == . || "$_ct_g" == */. \
|
|
438
|
+
|| "$_ct_g" == *..* || "$_ct_g" == *[{}]* ]]; then
|
|
439
|
+
_affected_ct_bad content_trigger_paths
|
|
440
|
+
fi
|
|
441
|
+
for _ct_probe in "zz9q8/probe.nonexistent" "a" ".hidden" "x/y.z" "Q9"; do
|
|
442
|
+
if affected_glob_match "$_ct_probe" "$_ct_g"; then _affected_ct_bad content_trigger_paths; fi
|
|
443
|
+
done
|
|
444
|
+
done
|
|
445
|
+
# A vacuous command (`true`, `cmd || true`) would certify nothing: same denylist
|
|
446
|
+
# as test_command, but the refusal names THIS key.
|
|
447
|
+
if [[ -z "$AFFECTED_CT_COMMAND" ]] || _affected_cmd_vacuous "$AFFECTED_CT_COMMAND"; then
|
|
448
|
+
_affected_ct_bad content_trigger_command
|
|
449
|
+
fi
|
|
450
|
+
AFFECTED_CT_ARMED=1
|
|
451
|
+
fi
|
|
452
|
+
|
|
356
453
|
if [[ -n "$CFG_TEST_COMMAND" ]]; then
|
|
357
454
|
# Vacuous escape hatches are refused — `true`, `:`, `exit 0`, a bare echo,
|
|
358
455
|
# and every composition that ends in a swallower: `cmd || true`,
|
|
@@ -470,6 +567,7 @@ if [[ -n "$RUNNER" ]]; then
|
|
|
470
567
|
# the operator (it can cost real time), so explain reports the delegation.
|
|
471
568
|
echo "SELECTION mode=delegated runner=$RUNNER flag=$_flag"
|
|
472
569
|
echo "runner owns selection — inspect with: bash $RUNNER --print-selection"
|
|
570
|
+
(( ARG_FULL_REQUESTED )) || AFFECTED_CT_ELIGIBLE=1
|
|
473
571
|
finish 0 explain delegated runner "$CI_NAME" - - -
|
|
474
572
|
fi
|
|
475
573
|
if [[ "$CI_NAME" != none ]]; then
|
|
@@ -480,6 +578,9 @@ if [[ -n "$RUNNER" ]]; then
|
|
|
480
578
|
fi
|
|
481
579
|
rc=0
|
|
482
580
|
affected_bound bash "$RUNNER" "$_flag" || rc=$?
|
|
581
|
+
# A delegated verdict is eligible for the content trigger unless the operator
|
|
582
|
+
# passed --full; finish() runs it only when this run passed.
|
|
583
|
+
(( ARG_FULL_REQUESTED )) || AFFECTED_CT_ELIGIBLE=1
|
|
483
584
|
# Delegated-runner rc mapping: 4 (REFUSED — nothing ran) → 4
|
|
484
585
|
# reason=runner-refused; 3 (UNRESOLVED — killed/declined suites) → 1
|
|
485
586
|
# reason=runner-signal; 2 (usage) → 4 runner-refused; the rest pass through
|
|
@@ -589,20 +690,8 @@ while IFS= read -r _p; do
|
|
|
589
690
|
done <"$CHANGED_TMP"
|
|
590
691
|
|
|
591
692
|
# --- classifiers ---------------------------------------------------------------------
|
|
592
|
-
#
|
|
593
|
-
#
|
|
594
|
-
# pattern matches the basename.
|
|
595
|
-
affected_glob_match() {
|
|
596
|
-
local p="$1" pat="$2" alt
|
|
597
|
-
if [[ "$pat" == */* ]]; then
|
|
598
|
-
[[ "$p" == $pat ]] && return 0
|
|
599
|
-
alt="${pat//\*\//}"
|
|
600
|
-
[[ "$alt" != "$pat" && "$p" == $alt ]] && return 0
|
|
601
|
-
return 1
|
|
602
|
-
fi
|
|
603
|
-
[[ "${p##*/}" == $pat ]]
|
|
604
|
-
}
|
|
605
|
-
|
|
693
|
+
# (affected_glob_match is defined above the config block: config validation and
|
|
694
|
+
# the content trigger need it before this point.)
|
|
606
695
|
GLOBAL_PATHS_BUILTIN=(
|
|
607
696
|
# manifests + lockfiles (any depth — a monorepo's nested manifests count too)
|
|
608
697
|
package.json package-lock.json npm-shrinkwrap.json yarn.lock pnpm-lock.yaml
|
|
@@ -698,6 +787,13 @@ if (( ALL_INERT )) && (( ${#AFFECTED_CHANGED[@]} > 0 )) && (( ARG_FULL == 0 )) &
|
|
|
698
787
|
(( ARG_EXPLAIN )) && echo "SELECTION mode=none reason=inert inert_rule=$(affected_marker_field "$INERT_RULE")"
|
|
699
788
|
# UNIT NOTE: on this path of= counts CHANGED files (all inert), not the
|
|
700
789
|
# repo test-file census other paths emit — units differ by design here.
|
|
790
|
+
AFFECTED_CT_ELIGIBLE=1 # under --explain the hook only reports; it runs nothing
|
|
791
|
+
# The inert exit precedes the budget arming below: arm it here so the content-trigger
|
|
792
|
+
# command is bounded (and deferred to CI at expiry) like every other post-primary run.
|
|
793
|
+
if [[ "$CI_NAME" != none ]]; then
|
|
794
|
+
AFFECTED_BUDGET_ACTIVE=1
|
|
795
|
+
AFFECTED_DEADLINE=$(( $(affected_now) + CFG_BUDGET_SECONDS ))
|
|
796
|
+
fi
|
|
701
797
|
finish 0 none inert - "$CI_NAME" 0 "${#AFFECTED_CHANGED[@]}" "${#AFFECTED_CHANGED[@]}"
|
|
702
798
|
fi
|
|
703
799
|
|
|
@@ -714,6 +810,7 @@ fi
|
|
|
714
810
|
|
|
715
811
|
if (( ARG_EXPLAIN )); then
|
|
716
812
|
echo "SELECTION mode=${MODE} reason=${REASON} global_hit=$(affected_marker_field "${GLOBAL_HIT:--}") ci=${CI_NAME}"
|
|
813
|
+
(( ARG_FULL_REQUESTED )) || AFFECTED_CT_ELIGIBLE=1
|
|
717
814
|
finish 0 explain "$REASON" - "$CI_NAME" - - -
|
|
718
815
|
fi
|
|
719
816
|
|
|
@@ -899,6 +996,10 @@ if (( GATE_ESCALATED_FULL )) && [[ "$OUT_MODE" == selected ]]; then
|
|
|
899
996
|
OUT_MODE=full
|
|
900
997
|
[[ "$REASON" == ok ]] && REASON=no-selector
|
|
901
998
|
fi
|
|
999
|
+
# Eligible unless the operator passed --full. A gate-side escalation to full
|
|
1000
|
+
# (global paths, empty diff, degraded census, no selector) is still eligible: the
|
|
1001
|
+
# stack adapter's full run never runs the repo-declared command.
|
|
1002
|
+
(( ARG_FULL_REQUESTED )) || AFFECTED_CT_ELIGIBLE=1
|
|
902
1003
|
case "$WORST" in
|
|
903
1004
|
0) finish 0 "$OUT_MODE" "$REASON" "${STACKS:--}" "$CI_NAME" "$OUT_RAN" "$OUT_OF" "$SKIP_SUM" ;;
|
|
904
1005
|
4) finish 4 "$OUT_MODE" "${AGG_REASON:-failed}" "${STACKS:--}" "$CI_NAME" \
|