@soleur/opencode 3.374.1 → 3.374.2
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
CHANGED
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
# Idempotent MERGE: creates the file if absent, preserves counters, merges
|
|
81
81
|
# --max-* flags into cap_<dim>. Prints `tally-init: <slug> <outcome>` where
|
|
82
82
|
# outcome ∈ fresh | continued | reset | capped-reset | stale-reset |
|
|
83
|
-
# repaired:
|
|
83
|
+
# repaired | default-branch-reset:
|
|
84
84
|
# fresh no file existed; new ledger created
|
|
85
85
|
# continued existing ledger kept; argv caps merged. A capped ledger
|
|
86
86
|
# prints `continued capped=<dim>` — the latch is visible.
|
|
@@ -99,7 +99,30 @@
|
|
|
99
99
|
# clean (fail-open) with SOLEUR_TALLY_ERROR
|
|
100
100
|
# reason=unreadable; NEVER reported `continued`, because
|
|
101
101
|
# nothing readable was preserved.
|
|
102
|
-
#
|
|
102
|
+
# default-branch-reset
|
|
103
|
+
# the branch is exactly `main` or `master` (derived or
|
|
104
|
+
# --branch; `feat-main`, `main-x` and a detached HEAD do
|
|
105
|
+
# not match) and the ledger existed and was readable: a
|
|
106
|
+
# default-branch ledger is shared across sessions, so init
|
|
107
|
+
# scopes it to the run that is starting — counts/warned/
|
|
108
|
+
# capped cleared, caps merged as for every reset. Precedence:
|
|
109
|
+
# fresh > reset (--reset) > repaired > default-branch-reset >
|
|
110
|
+
# capped-reset > stale-reset > continued. Applies to ledgers
|
|
111
|
+
# that are NOT capped: a capped main/master ledger follows
|
|
112
|
+
# the ordinary capped rules (bare init -> `continued
|
|
113
|
+
# capped=<dim>`; raised caps -> capped-reset; 24h idle ->
|
|
114
|
+
# stale-reset), so the CAP SEMANTICS latch below holds on
|
|
115
|
+
# main as on every branch. Not idempotent
|
|
116
|
+
# on main/master: each init there zeroes the counts, so a
|
|
117
|
+
# second init inside one run loses the first's. Side
|
|
118
|
+
# effect: a concurrent session's init on `main` zeroes
|
|
119
|
+
# another session's counts (ADR-268 amendment
|
|
120
|
+
# 2026-10-31). Only `init` scopes the ledger: `incr`,
|
|
121
|
+
# `gate` and `show` on main read whatever has accumulated
|
|
122
|
+
# since the last init, which is why `show` carries the
|
|
123
|
+
# note: line. A detached HEAD (branch `HEAD`) is not a
|
|
124
|
+
# default branch and still shares one ledger.
|
|
125
|
+
# CAP SEMANTICS (holds on main/master too): a ledger carrying `capped` is NOT reset by a bare `init` —
|
|
103
126
|
# it reports `continued` and `capped` persists, so the next `gate` still
|
|
104
127
|
# returns STOP (a budget-capped run cannot be accidentally resumed under
|
|
105
128
|
# the same caps; livelock impossible). `capped` clears only via an explicit
|
|
@@ -129,7 +152,10 @@
|
|
|
129
152
|
# Absent/unreadable file → UNKNOWN. Else prints
|
|
130
153
|
# `tally: seats=N ci_cycles=N fix_rounds=N agent_rounds=N`, a `cap:<dim>=<n>`
|
|
131
154
|
# token line when caps are set (the stop-hook floor reads this), and, when
|
|
132
|
-
# any is set, `warned:<dim>=<at>` / `capped:<dim>=<cap>` tokens.
|
|
155
|
+
# any is set, `warned:<dim>=<at>` / `capped:<dim>=<cap>` tokens. On a
|
|
156
|
+
# default-branch ledger (`main`/`master`) a last line
|
|
157
|
+
# `note:default-branch-ledger (shared across sessions; not attributable to
|
|
158
|
+
# one run)` follows; the `tally:` line and the tokens above are unchanged.
|
|
133
159
|
#
|
|
134
160
|
# gate <dim> [n] [--branch <b>]
|
|
135
161
|
# Reads cap_<dim> from the FILE, never argv. Verdict on stdout:
|
|
@@ -224,6 +250,11 @@ _tally_shorthash() {
|
|
|
224
250
|
# Map _tally_paths rc -> the right error reason (1=bad-branch, 2=lib-missing).
|
|
225
251
|
_tally_paths_err() { case "$1" in 1) _tally_err bad-branch ;; *) _tally_err lib-missing ;; esac; }
|
|
226
252
|
|
|
253
|
+
# Default branches: exact `main` or `master` only. `feat-main`, `main-x` and a
|
|
254
|
+
# detached `HEAD` do not match. Their ledgers are shared across sessions (no
|
|
255
|
+
# per-run key), so init scopes them to one run and show discloses it.
|
|
256
|
+
_tally_is_default_branch() { [[ "${T_BRANCH:-}" == "main" || "${T_BRANCH:-}" == "master" ]]; }
|
|
257
|
+
|
|
227
258
|
# Canonicalize a dim token -> seats|ci_cycles|fix_rounds|agent_rounds, or fail.
|
|
228
259
|
_tally_dim() {
|
|
229
260
|
case "$1" in
|
|
@@ -233,7 +264,8 @@ _tally_dim() {
|
|
|
233
264
|
esac
|
|
234
265
|
}
|
|
235
266
|
|
|
236
|
-
# _tally_paths <branch-or-empty> -> T_SLUG T_COUNTERS_DIR T_FILE
|
|
267
|
+
# _tally_paths <branch-or-empty> -> T_BRANCH T_SLUG T_COUNTERS_DIR T_FILE
|
|
268
|
+
# (T_BRANCH = the resolved branch name, or the --branch value, or `HEAD`.)
|
|
237
269
|
# rc 1 = unsafe branch token refused; rc 2 = no session-state root.
|
|
238
270
|
# _tally_paths_err maps the rc to the right reason marker.
|
|
239
271
|
_tally_paths() {
|
|
@@ -242,6 +274,7 @@ _tally_paths() {
|
|
|
242
274
|
branch=$(git branch --show-current 2>/dev/null || true)
|
|
243
275
|
[[ -n "$branch" ]] || branch="HEAD"
|
|
244
276
|
fi
|
|
277
|
+
T_BRANCH="$branch"
|
|
245
278
|
T_SLUG=$(_tally_slug "$branch")-$(_tally_shorthash "$branch")
|
|
246
279
|
# `.`/`..` survive the slug transform and would compose a path outside
|
|
247
280
|
# counters/ (mv deposits the tmp file in the state root). Same refusal
|
|
@@ -443,6 +476,20 @@ _tally_init_locked() {
|
|
|
443
476
|
# a continuation.
|
|
444
477
|
outcome="repaired"
|
|
445
478
|
_tally_err unreadable
|
|
479
|
+
elif _tally_is_default_branch && [[ -z "$T_capped" ]]; then
|
|
480
|
+
# `main`/`master` ledgers are shared by every session on the default branch
|
|
481
|
+
# and would accumulate forever (a read there is not one run's cost), so an
|
|
482
|
+
# init scopes them to the run that is starting. Beats stale-reset and
|
|
483
|
+
# `continued`; --reset (explicit) and repaired (corrupt) keep their own
|
|
484
|
+
# names above. A CAPPED ledger is not scoped here: it falls through to the
|
|
485
|
+
# ordinary capped rules (raised caps -> capped-reset, bare -> `continued
|
|
486
|
+
# capped=<dim>`, or stale-reset after 24h idle), exactly as on any other
|
|
487
|
+
# branch — the sticky latch is the budget stop, and a bare init (every skill
|
|
488
|
+
# runs one) must not lift it. The latch is written by `gate`, not by `incr`: an
|
|
489
|
+
# uncapped-latched ledger that is merely at its cap is scoped like any other
|
|
490
|
+
# until a gate has run (ADR-268 amendment). A concurrent session's init on `main` still
|
|
491
|
+
# zeroes this session's counts — accepted (ADR-268 amendment 2026-10-31).
|
|
492
|
+
outcome="default-branch-reset"
|
|
446
493
|
elif [[ -n "$T_capped" ]] && (( caps_given )); then
|
|
447
494
|
# Raised-cap resume BEATS stale: an explicit `--max-*` argv is operator
|
|
448
495
|
# intent to continue THIS run under a new budget, and the counts are the
|
|
@@ -461,7 +508,7 @@ _tally_init_locked() {
|
|
|
461
508
|
fi
|
|
462
509
|
|
|
463
510
|
case "$outcome" in
|
|
464
|
-
reset|stale-reset|repaired)
|
|
511
|
+
reset|stale-reset|repaired|default-branch-reset)
|
|
465
512
|
# Fresh ledger — counts, warnings, capped cleared. cap_<dim> survive:
|
|
466
513
|
# reset clears the ledger, never the budget.
|
|
467
514
|
_tally_setf seats 0; _tally_setf ci_cycles 0
|
|
@@ -644,6 +691,10 @@ cmd_show() {
|
|
|
644
691
|
[[ -n "$T_capped" ]] && ann="${ann}capped:${T_capped}=$(_tally_getf "cap_$T_capped")"
|
|
645
692
|
ann="${ann% }"
|
|
646
693
|
[[ -n "$ann" ]] && printf '%s\n' "$ann"
|
|
694
|
+
# Last line: a default-branch ledger is shared across sessions, so its counts
|
|
695
|
+
# are not attributable to one run. Carries none of the tally:/cap:/warned:/
|
|
696
|
+
# capped: tokens, so the stop-hook and ship's render parse as before.
|
|
697
|
+
_tally_is_default_branch && printf 'note:default-branch-ledger (shared across sessions; not attributable to one run)\n'
|
|
647
698
|
return 0
|
|
648
699
|
}
|
|
649
700
|
|
|
@@ -69,6 +69,14 @@ new_repo() { # $1 = dir name under $TMP; prints the path
|
|
|
69
69
|
printf '%s' "$d"
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
new_repo_on() { # $1 = dir name under $TMP, $2 = branch; prints the path
|
|
73
|
+
local d="$TMP/$1"
|
|
74
|
+
assert_fixture_dir "$d"
|
|
75
|
+
mkdir -p "$d"
|
|
76
|
+
git -C "$d" init -q -b "$2"
|
|
77
|
+
printf '%s' "$d"
|
|
78
|
+
}
|
|
79
|
+
|
|
72
80
|
# run_tally <repo> <state-root> <args...> — invoke the SUT as a skill would:
|
|
73
81
|
# cwd = the repo being tallied, session-state root redirected into the fixture
|
|
74
82
|
# (`SOLEUR_SESSION_STATE_ROOT` is the lib's documented test override).
|
|
@@ -84,6 +92,9 @@ run_tally() {
|
|
|
84
92
|
# Counter-file path the contract assigns this fixture: <root>/counters/<slug>.
|
|
85
93
|
cf_path() { printf '%s/counters/%s' "$1" "$SLUG"; }
|
|
86
94
|
|
|
95
|
+
# Counter-file path for an arbitrary branch: <root>/counters/<slug-of-branch>.
|
|
96
|
+
cf_path_for() { printf '%s/counters/%s' "$1" "$(tally_slug "$2")"; }
|
|
97
|
+
|
|
87
98
|
# Flat key=value read, contract format (same grep+cut idiom as the lib).
|
|
88
99
|
cf_get() { grep "^$2=" "$1" 2>/dev/null | head -1 | cut -d= -f2-; }
|
|
89
100
|
|
|
@@ -111,6 +122,32 @@ assert_path_absent() {
|
|
|
111
122
|
|
|
112
123
|
assert_rc0() { assert_eq "0" "$RC" "$1"; }
|
|
113
124
|
|
|
125
|
+
# Exact-line verdict helpers. `reset` is a SUBSTRING of `default-branch-reset`
|
|
126
|
+
# (and of `capped-reset`/`stale-reset`), so outcome asserts must match a whole
|
|
127
|
+
# line, never assert_contains. line_present is the predicate; assert_line and
|
|
128
|
+
# assert_no_line wrap it.
|
|
129
|
+
line_present() { grep -qxF -- "$2" <<<"$1"; }
|
|
130
|
+
assert_line() {
|
|
131
|
+
if line_present "$1" "$2"; then
|
|
132
|
+
echo " PASS: $3"; PASS=$((PASS + 1))
|
|
133
|
+
else
|
|
134
|
+
echo " FAIL: $3"
|
|
135
|
+
echo " expected exact line: '$2'"
|
|
136
|
+
echo " actual: '$1'"
|
|
137
|
+
FAIL=$((FAIL + 1))
|
|
138
|
+
fi
|
|
139
|
+
}
|
|
140
|
+
assert_no_line() {
|
|
141
|
+
if ! line_present "$1" "$2"; then
|
|
142
|
+
echo " PASS: $3"; PASS=$((PASS + 1))
|
|
143
|
+
else
|
|
144
|
+
echo " FAIL: $3"
|
|
145
|
+
echo " expected NO exact line: '$2'"
|
|
146
|
+
echo " actual: '$1'"
|
|
147
|
+
FAIL=$((FAIL + 1))
|
|
148
|
+
fi
|
|
149
|
+
}
|
|
150
|
+
|
|
114
151
|
echo "=== pipeline-tally.sh contract tests ==="
|
|
115
152
|
echo ""
|
|
116
153
|
|
|
@@ -734,7 +771,214 @@ assert_contains "$OUT" "continued" "post-gate init continues (mtime refreshed),
|
|
|
734
771
|
assert_eq "5" "$(cf_get "$C29" seats)" "counts survive the gate-touched init"
|
|
735
772
|
echo ""
|
|
736
773
|
|
|
774
|
+
# --- Tests 30-34: default-branch ledgers are init-scoped (ADR-268 amendment) ----
|
|
775
|
+
# `main`/`master` ledgers are shared across sessions and accumulate forever
|
|
776
|
+
# (the 83/15/1/12 tally was the shared `main` ledger, not one run). `init` on a
|
|
777
|
+
# default branch therefore resets (outcome `default-branch-reset`) and `show`
|
|
778
|
+
# discloses the shared scope with a trailing `note:` line. `git init -b <name>`
|
|
779
|
+
# with the sandboxed state root puts the ledger under $TMP; the unborn branch
|
|
780
|
+
# name is what `git branch --show-current` prints, so no real ledger is touched.
|
|
781
|
+
DB_NOTE='note:default-branch-ledger (shared across sessions; not attributable to one run)'
|
|
782
|
+
|
|
783
|
+
# Instrument self-test: the exact-line helper must discriminate the new outcome
|
|
784
|
+
# from its substring `reset`, or every precedence row below is vacuous.
|
|
785
|
+
echo "Test 30a: instrument self-test — assert_line tells reset from default-branch-reset"
|
|
786
|
+
if line_present "tally-init: x default-branch-reset" "tally-init: x reset"; then
|
|
787
|
+
FAIL=$((FAIL + 1)); echo " FAIL: line_present matched 'reset' inside 'default-branch-reset'"
|
|
788
|
+
else
|
|
789
|
+
PASS=$((PASS + 1)); echo " PASS: line_present is exact-line (substring 'reset' does not match)"
|
|
790
|
+
fi
|
|
791
|
+
if line_present "tally-init: x reset" "tally-init: x reset"; then
|
|
792
|
+
PASS=$((PASS + 1)); echo " PASS: line_present matches an identical line"
|
|
793
|
+
else
|
|
794
|
+
FAIL=$((FAIL + 1)); echo " FAIL: line_present missed an identical line"
|
|
795
|
+
fi
|
|
796
|
+
echo ""
|
|
797
|
+
|
|
798
|
+
# --- Test 30: precedence rows on the derived default branch --------------------
|
|
799
|
+
echo "Test 30: init on main/master — fresh / reset / repaired / default-branch-reset precedence"
|
|
800
|
+
for DB in main master; do
|
|
801
|
+
RDB=$(new_repo_on "r30-$DB" "$DB"); S30="$TMP/s30-$DB"; C30=$(cf_path_for "$S30" "$DB"); SL30=$(tally_slug "$DB")
|
|
802
|
+
run_tally "$RDB" "$S30" init
|
|
803
|
+
assert_line "$OUT" "tally-init: $SL30 fresh" "$DB + absent ledger -> fresh (not default-branch-reset)"
|
|
804
|
+
run_tally "$RDB" "$S30" incr seats 3
|
|
805
|
+
run_tally "$RDB" "$S30" init
|
|
806
|
+
assert_rc0 "$DB default-branch-reset exits 0 (fail-open)"
|
|
807
|
+
assert_line "$OUT" "tally-init: $SL30 default-branch-reset" "$DB + live ledger -> default-branch-reset"
|
|
808
|
+
assert_no_line "$OUT" "tally-init: $SL30 continued" "$DB live ledger is not continued"
|
|
809
|
+
assert_eq "0" "$(cf_get "$C30" seats)" "$DB default-branch-reset zeroes counts"
|
|
810
|
+
assert_not_contains "$ERR" "SOLEUR_TALLY_ERROR" "$DB default-branch-reset is not an error"
|
|
811
|
+
run_tally "$RDB" "$S30" incr seats 2
|
|
812
|
+
touch -d "25 hours ago" "$C30"
|
|
813
|
+
run_tally "$RDB" "$S30" init
|
|
814
|
+
assert_line "$OUT" "tally-init: $SL30 default-branch-reset" "$DB + stale ledger -> default-branch-reset (not stale-reset)"
|
|
815
|
+
assert_eq "0" "$(cf_get "$C30" seats)" "$DB stale default-branch-reset zeroes counts"
|
|
816
|
+
run_tally "$RDB" "$S30" incr seats 4
|
|
817
|
+
run_tally "$RDB" "$S30" init --reset
|
|
818
|
+
assert_line "$OUT" "tally-init: $SL30 reset" "$DB + explicit --reset -> reset (explicit beats default-branch)"
|
|
819
|
+
assert_eq "0" "$(cf_get "$C30" seats)" "$DB --reset zeroes counts"
|
|
820
|
+
assert_fixture_dir "$C30"
|
|
821
|
+
printf 'corrupt bytes\n' > "$C30"
|
|
822
|
+
run_tally "$RDB" "$S30" init
|
|
823
|
+
assert_line "$OUT" "tally-init: $SL30 repaired" "$DB + corrupt ledger -> repaired (beats default-branch-reset)"
|
|
824
|
+
assert_contains "$ERR" "reason=unreadable" "$DB repaired still emits the unreadable marker"
|
|
825
|
+
done
|
|
826
|
+
echo ""
|
|
827
|
+
|
|
828
|
+
# --- Test 31: capped default-branch ledger + caps ------------------------------
|
|
829
|
+
echo "Test 31: capped main follows the ordinary capped rules (raised cap -> capped-reset; bare -> continued; idle -> stale-reset)"
|
|
830
|
+
R31=$(new_repo_on r31 main); S31="$TMP/s31"; C31=$(cf_path_for "$S31" main); SL31=$(tally_slug main)
|
|
831
|
+
assert_fixture_dir "$C31"
|
|
832
|
+
mkdir -p "$(dirname "$C31")"
|
|
833
|
+
cat > "$C31" <<EOF
|
|
834
|
+
seats=13
|
|
835
|
+
ci_cycles=4
|
|
836
|
+
fix_rounds=1
|
|
837
|
+
agent_rounds=7
|
|
838
|
+
cap_seats=12
|
|
839
|
+
cap_ci_cycles=0
|
|
840
|
+
cap_fix_rounds=0
|
|
841
|
+
cap_agent_rounds=0
|
|
842
|
+
warned_seats=11
|
|
843
|
+
warned_ci_cycles=0
|
|
844
|
+
warned_fix_rounds=0
|
|
845
|
+
warned_agent_rounds=0
|
|
846
|
+
capped=seats
|
|
847
|
+
EOF
|
|
848
|
+
run_tally "$R31" "$S31" init --max-seats 20
|
|
849
|
+
assert_line "$OUT" "tally-init: $SL31 capped-reset" "capped main + raised cap -> capped-reset (as on any branch)"
|
|
850
|
+
assert_no_line "$OUT" "tally-init: $SL31 default-branch-reset" "capped main is not default-branch-reset"
|
|
851
|
+
assert_eq "13" "$(cf_get "$C31" seats)" "raised-cap init on a capped main keeps the counts (the forensic record)"
|
|
852
|
+
assert_eq "7" "$(cf_get "$C31" agent_rounds)" "raised-cap init on a capped main keeps every dim"
|
|
853
|
+
assert_eq "" "$(cf_get "$C31" capped)" "capped-reset clears the latch"
|
|
854
|
+
assert_eq "0" "$(cf_get "$C31" warned_seats)" "capped-reset clears warned_*"
|
|
855
|
+
assert_eq "20" "$(cf_get "$C31" cap_seats)" "the raised cap is merged and kept"
|
|
856
|
+
# Bare init on a capped main ledger: caps survive every reset form.
|
|
857
|
+
printf 'seats=9\nci_cycles=0\nfix_rounds=0\nagent_rounds=0\ncap_seats=12\ncap_ci_cycles=0\ncap_fix_rounds=0\ncap_agent_rounds=0\nwarned_seats=0\nwarned_ci_cycles=0\nwarned_fix_rounds=0\nwarned_agent_rounds=0\ncapped=seats\n' > "$C31"
|
|
858
|
+
run_tally "$R31" "$S31" init
|
|
859
|
+
assert_line "$OUT" "tally-init: $SL31 continued capped=seats" "bare init on capped main -> continued capped=seats (the sticky latch holds)"
|
|
860
|
+
assert_no_line "$OUT" "tally-init: $SL31 default-branch-reset" "bare init on capped main does not default-branch-reset"
|
|
861
|
+
assert_eq "9" "$(cf_get "$C31" seats)" "bare init on capped main keeps the counts"
|
|
862
|
+
assert_eq "seats" "$(cf_get "$C31" capped)" "bare init on capped main keeps the latch"
|
|
863
|
+
assert_eq "12" "$(cf_get "$C31" cap_seats)" "bare init on capped main keeps the persisted cap"
|
|
864
|
+
# A cap given that is NOT raised (equal or lower) is also an ordinary capped-reset with the counts
|
|
865
|
+
# kept and the persisted cap kept (ratchet guard), so a forwarded flag cannot refund a budget.
|
|
866
|
+
printf 'seats=9\nci_cycles=0\nfix_rounds=0\nagent_rounds=0\ncap_seats=12\ncap_ci_cycles=0\ncap_fix_rounds=0\ncap_agent_rounds=0\nwarned_seats=0\nwarned_ci_cycles=0\nwarned_fix_rounds=0\nwarned_agent_rounds=0\ncapped=seats\n' > "$C31"
|
|
867
|
+
run_tally "$R31" "$S31" init --max-seats 5
|
|
868
|
+
assert_line "$OUT" "tally-init: $SL31 capped-reset" "capped main + a LOWER cap -> capped-reset, not a budget refund"
|
|
869
|
+
assert_eq "9" "$(cf_get "$C31" seats)" "a lower cap on a capped main keeps the counts"
|
|
870
|
+
assert_eq "12" "$(cf_get "$C31" cap_seats)" "a lower cap on a capped main keeps the persisted cap"
|
|
871
|
+
# A latch on a different dimension holds the same way.
|
|
872
|
+
printf 'seats=0\nci_cycles=6\nfix_rounds=0\nagent_rounds=0\ncap_seats=0\ncap_ci_cycles=5\ncap_fix_rounds=0\ncap_agent_rounds=0\nwarned_seats=0\nwarned_ci_cycles=0\nwarned_fix_rounds=0\nwarned_agent_rounds=0\ncapped=ci_cycles\n' > "$C31"
|
|
873
|
+
run_tally "$R31" "$S31" init
|
|
874
|
+
assert_line "$OUT" "tally-init: $SL31 continued capped=ci_cycles" "bare init on a main ledger capped on ci_cycles keeps that latch"
|
|
875
|
+
# Idle for more than 24h, a capped main ledger stale-resets exactly like a capped feature-branch ledger.
|
|
876
|
+
printf 'seats=9\nci_cycles=0\nfix_rounds=0\nagent_rounds=0\ncap_seats=12\ncap_ci_cycles=0\ncap_fix_rounds=0\ncap_agent_rounds=0\nwarned_seats=0\nwarned_ci_cycles=0\nwarned_fix_rounds=0\nwarned_agent_rounds=0\ncapped=seats\n' > "$C31"
|
|
877
|
+
touch -d '3 days ago' "$C31"
|
|
878
|
+
run_tally "$R31" "$S31" init
|
|
879
|
+
assert_line "$OUT" "tally-init: $SL31 stale-reset" "capped + idle >24h + bare init on main -> stale-reset (as on any branch)"
|
|
880
|
+
assert_eq "" "$(cf_get "$C31" capped)" "stale-reset clears the latch after 24h idle"
|
|
881
|
+
printf 'seats=9\nci_cycles=0\nfix_rounds=0\nagent_rounds=0\ncap_seats=12\ncap_ci_cycles=0\ncap_fix_rounds=0\ncap_agent_rounds=0\nwarned_seats=0\nwarned_ci_cycles=0\nwarned_fix_rounds=0\nwarned_agent_rounds=0\ncapped=seats\n' > "$C31"
|
|
882
|
+
# The gate still stops on that ledger: the whole point of the latch.
|
|
883
|
+
run_tally "$R31" "$S31" gate seats
|
|
884
|
+
assert_contains "$OUT" "STOP" "gate on a capped main ledger still returns STOP after a bare init"
|
|
885
|
+
echo ""
|
|
886
|
+
|
|
887
|
+
# --- Test 32: --branch, and names that merely contain main ---------------------
|
|
888
|
+
echo "Test 32: --branch main/master match; feat-main and main-x stay continued"
|
|
889
|
+
R32=$(new_repo_on r32 feat/tally-probe); S32="$TMP/s32"
|
|
890
|
+
for DB in main master; do
|
|
891
|
+
SLB=$(tally_slug "$DB")
|
|
892
|
+
run_tally "$R32" "$S32" init --branch "$DB"
|
|
893
|
+
assert_line "$OUT" "tally-init: $SLB fresh" "--branch $DB from a feature repo -> fresh first time"
|
|
894
|
+
run_tally "$R32" "$S32" incr seats 5 --branch "$DB"
|
|
895
|
+
run_tally "$R32" "$S32" init --branch "$DB"
|
|
896
|
+
assert_line "$OUT" "tally-init: $SLB default-branch-reset" "--branch $DB behaves like the derived default branch"
|
|
897
|
+
assert_eq "0" "$(cf_get "$(cf_path_for "$S32" "$DB")" seats)" "--branch $DB zeroed counts"
|
|
898
|
+
done
|
|
899
|
+
for NB in feat-main main-x xmain main/x Main; do
|
|
900
|
+
SLN=$(tally_slug "$NB")
|
|
901
|
+
run_tally "$R32" "$S32" init --branch "$NB"
|
|
902
|
+
run_tally "$R32" "$S32" incr seats 2 --branch "$NB"
|
|
903
|
+
run_tally "$R32" "$S32" init --branch "$NB"
|
|
904
|
+
assert_line "$OUT" "tally-init: $SLN continued" "--branch $NB is not a default branch (continued)"
|
|
905
|
+
assert_eq "2" "$(cf_get "$(cf_path_for "$S32" "$NB")" seats)" "--branch $NB keeps counts"
|
|
906
|
+
run_tally "$R32" "$S32" show --branch "$NB"
|
|
907
|
+
assert_not_contains "$OUT" "note:" "show --branch $NB carries no default-branch note"
|
|
908
|
+
done
|
|
909
|
+
# Derived (not --branch) feat-main repo, the real skill call shape.
|
|
910
|
+
RFM=$(new_repo_on r32-featmain feat-main)
|
|
911
|
+
run_tally "$RFM" "$S32" init
|
|
912
|
+
run_tally "$RFM" "$S32" incr seats 1
|
|
913
|
+
run_tally "$RFM" "$S32" init
|
|
914
|
+
assert_line "$OUT" "tally-init: $(tally_slug feat-main) continued" "derived branch feat-main is still continued"
|
|
915
|
+
echo ""
|
|
916
|
+
|
|
917
|
+
# --- Test 33: detached HEAD is not a default branch ------------------------------
|
|
918
|
+
echo "Test 33: init on a detached HEAD (real commit) does not default-branch-reset"
|
|
919
|
+
R33=$(new_repo_on r33 main); S33="$TMP/s33"
|
|
920
|
+
assert_fixture_dir "$R33"
|
|
921
|
+
git -C "$R33" -c user.name=tally-test -c user.email=tally-test@example.invalid -c commit.gpgsign=false \
|
|
922
|
+
commit -q --allow-empty -m probe
|
|
923
|
+
git -C "$R33" checkout -q --detach
|
|
924
|
+
DETACHED=$(git -C "$R33" branch --show-current)
|
|
925
|
+
assert_eq "" "$DETACHED" "fixture is really detached (branch --show-current is empty)"
|
|
926
|
+
run_tally "$R33" "$S33" init
|
|
927
|
+
assert_contains "$OUT" "tally-init: HEAD-" "detached HEAD keys on HEAD-<hash>"
|
|
928
|
+
assert_contains "$OUT" " fresh" "first detached init is fresh"
|
|
929
|
+
run_tally "$R33" "$S33" incr seats 4
|
|
930
|
+
run_tally "$R33" "$S33" init
|
|
931
|
+
assert_contains "$OUT" " continued" "second detached init is continued"
|
|
932
|
+
assert_not_contains "$OUT" "default-branch-reset" "detached HEAD never default-branch-resets"
|
|
933
|
+
run_tally "$R33" "$S33" show
|
|
934
|
+
assert_contains "$OUT" "seats=4" "detached HEAD keeps its counts"
|
|
935
|
+
assert_not_contains "$OUT" "note:" "detached HEAD show carries no default-branch note"
|
|
936
|
+
echo ""
|
|
937
|
+
|
|
938
|
+
# --- Test 34: show discloses the shared scope without disturbing consumers -----
|
|
939
|
+
echo "Test 34: show on main appends the note line AFTER capped:, tally: line byte-identical"
|
|
940
|
+
R34M=$(new_repo_on r34-main main); R34F=$(new_repo_on r34-feat feat/x); S34="$TMP/s34"
|
|
941
|
+
for R in "$R34M" "$R34F"; do
|
|
942
|
+
run_tally "$R" "$S34" init --max-seats 12
|
|
943
|
+
run_tally "$R" "$S34" incr seats 3
|
|
944
|
+
run_tally "$R" "$S34" incr agent_rounds 2
|
|
945
|
+
done
|
|
946
|
+
run_tally "$R34M" "$S34" show; SHOW_MAIN="$OUT"
|
|
947
|
+
run_tally "$R34F" "$S34" show; SHOW_FEAT="$OUT"
|
|
948
|
+
assert_line "$SHOW_MAIN" "$DB_NOTE" "show on main carries the exact note line"
|
|
949
|
+
assert_eq "1" "$(printf '%s\n' "$SHOW_MAIN" | grep -c '^note:')" "exactly one note: line"
|
|
950
|
+
assert_eq "$DB_NOTE" "$(printf '%s\n' "$SHOW_MAIN" | tail -1)" "the note is the LAST line of show"
|
|
951
|
+
assert_not_contains "$SHOW_FEAT" "note:" "show on a feature branch has no note"
|
|
952
|
+
assert_eq "$(printf '%s\n' "$SHOW_FEAT" | grep '^tally:')" "$(printf '%s\n' "$SHOW_MAIN" | grep '^tally:')" "tally: line is byte-identical to a feature ledger with the same counts"
|
|
953
|
+
assert_eq "tally: seats=3 ci_cycles=0 fix_rounds=0 agent_rounds=2" "$(printf '%s\n' "$SHOW_MAIN" | sed -n 1p)" "tally: line format unchanged and first"
|
|
954
|
+
assert_eq "$(printf '%s\n' "$SHOW_FEAT" | grep '^cap:')" "$(printf '%s\n' "$SHOW_MAIN" | grep '^cap:')" "cap: token line is unchanged"
|
|
955
|
+
# Capped main ledger: note must follow the capped: annotation line.
|
|
956
|
+
C34=$(cf_path_for "$S34" main)
|
|
957
|
+
sed -i 's/^capped=.*/capped=seats/; s/^warned_seats=.*/warned_seats=10/' "$C34"
|
|
958
|
+
run_tally "$R34M" "$S34" show
|
|
959
|
+
LN_CAPPED=$(printf '%s\n' "$OUT" | grep -n '^warned:.*capped:\|^capped:' | head -1 | cut -d: -f1)
|
|
960
|
+
LN_NOTE=$(printf '%s\n' "$OUT" | grep -n '^note:' | head -1 | cut -d: -f1)
|
|
961
|
+
assert_contains "$OUT" "capped:seats=12" "capped main ledger renders capped:seats=12"
|
|
962
|
+
if [[ -n "$LN_CAPPED" && -n "$LN_NOTE" ]] && (( LN_NOTE > LN_CAPPED )); then
|
|
963
|
+
PASS=$((PASS + 1)); echo " PASS: note line ($LN_NOTE) follows the capped: line ($LN_CAPPED)"
|
|
964
|
+
else
|
|
965
|
+
FAIL=$((FAIL + 1)); echo " FAIL: note line ($LN_NOTE) must follow the capped: line ($LN_CAPPED)"
|
|
966
|
+
fi
|
|
967
|
+
# Stop-hook regression: derive from hooks/stop-hook.sh's `grep -o` extractors.
|
|
968
|
+
# The note line must match none of them, so the hook's parse of a main ledger
|
|
969
|
+
# is identical with and without it.
|
|
970
|
+
NOTE_LINE=$(printf '%s\n' "$OUT" | grep '^note:')
|
|
971
|
+
HOOK_HITS=$(printf '%s\n' "$NOTE_LINE" | grep -oE 'capped:[a-z_]*=[0-9]*|cap:[a-z_]*=[0-9]*|^tally:.*|(seats|ci_cycles|fix_rounds|agent_rounds)=[0-9]+' || true)
|
|
972
|
+
assert_eq "" "$HOOK_HITS" "the note line matches none of stop-hook.sh's grep -o patterns"
|
|
973
|
+
HOOK_CAPPED=$(printf '%s' "$OUT" | grep -o 'capped:[a-z_]*=[0-9]*' | cut -d: -f2 | cut -d= -f1)
|
|
974
|
+
HOOK_CAP=$(printf '%s' "$OUT" | grep -o 'cap:[a-z_]*=[0-9]*' | cut -d: -f2 | cut -d= -f1)
|
|
975
|
+
assert_eq "seats" "$HOOK_CAPPED" "hook's capped: extraction still yields seats with the note present"
|
|
976
|
+
assert_eq "seats" "$HOOK_CAP" "hook's cap: extraction still yields seats with the note present"
|
|
977
|
+
echo ""
|
|
978
|
+
|
|
737
979
|
# --- Summary -------------------------------------------------------------------
|
|
738
|
-
# Anti-vacuity floor:
|
|
739
|
-
#
|
|
740
|
-
|
|
980
|
+
# Anti-vacuity floor: 253 assertions pass on a full run (flock and orphan arms
|
|
981
|
+
# may each skip ~4-5 on hosts lacking flock or with a live orphan root), so the
|
|
982
|
+
# floor sits 2 below that. Derive it from a green run, never from the number you
|
|
983
|
+
# expected, and raise it in the same edit that adds an assertion.
|
|
984
|
+
print_results 251
|
|
@@ -4,3 +4,5 @@ Loaded from the Defect Classes list in [SKILL.md](../SKILL.md) (Defect Classes)
|
|
|
4
4
|
|
|
5
5
|
- **A workflow suite's coverage is the set of step BODIES it executes under the shell GitHub runs — name each step that writes state and the row that runs it to failure.** A step with no `shell:` key runs as `bash -e {0}` (no pipefail, errexit ON), so `rc=$?` after a failing command is unreachable unless `set +e` brackets it (ADR-170; `lint-workflow-errexit-capture.py` fails on it in CI). A harness that runs bodies under `-eo pipefail` and stubs only the read path certifies the guards and never the writer, and regex pins over the apply line are satisfied by a trailing comment, a double space, `-chdir`, an env-borne `TF_CLI_ARGS_*` or an extra step. Also: a guard's name/config/address list must be READ from the graded artifact (the plan JSON), not restated, and a stub env var shadows the one under test unless namespaced `STUB_*`. **Why:** #9481 — the P1 and four of twelve P2s were this; 169 rows and 35 mutants were green. See `knowledge-base/project/learnings/2026-10-04-a-create-only-workflow-whose-writing-step-my-suite-never-executed.md`.
|
|
6
6
|
- **A gate's WIRING is not pinned by regex over its workflow text: execute the extracted `run:` block against a stub that REFUSES any other argv, with a control case proving a changed selector flips the verdict, and keep `absent`/`unknown` apart from `skipped` when classifying run records.** Regex pins stayed green with a case arm replaced by `:`, a changed `--event`, a swapped `--jq` field order and a post-scan reassignment; a classifier that read an absent or conclusion-less step as "skipped" read the plan's own cited failed rotate (a pre-rename step name) as nothing-happened. **Why:** #10166/PR #10184. See `knowledge-base/project/learnings/2026-10-13-a-classifier-that-reads-absent-as-skip-fails-open-on-name-drift.md`.
|
|
7
|
+
|
|
8
|
+
- **A guard whose property is CONTROL FLOW cannot be pinned by pattern greps over the body — pin the flow skeleton, and refuse substitution inside the lines you drop.** Pattern checks (`if ! cmd; then`, `exit 1`, a ban on `|| true`) are satisfied by dead branches, `echo ... # exit 1`, `trap 'exit 0' EXIT`, `if: ${{ false }}`, an early unconditional `exit 0`, and by `env:` (`BASH_ENV`, `NODE_OPTIONS`, `PATH`) at step, job or workflow level. Reduce the body to its flow (drop only inert `echo "..."` lines with no `$(`, `${`, backtick or backslash) and compare to a pinned golden, count publishes of every spelling (`pnpm publish`, a `\`-continued `npm publish`, a `uses:` action), and pin the env and `working-directory` of the step. **Why:** #11688 — ten distinct bypasses of a pattern-based `diagnose-on-failure` member, then two P1s in its first skeleton (an echo dropper that accepted `echo "$(printf x >> .npmrc)"`, unconstrained env). See `knowledge-base/project/learnings/2026-10-31-a-pattern-grep-guard-is-satisfied-by-dead-branches-pin-the-control-flow-skeleton.md`.
|
|
@@ -15,6 +15,10 @@ before `## Changelog` in BOTH body templates, per these rules (in order):
|
|
|
15
15
|
`Pipeline-Tally: seats=N; ci_cycles=N; fix_rounds=N; agent_rounds=N` — it is the
|
|
16
16
|
cross-PR aggregation surface (squash merge drops commit trailers, so counts live in
|
|
17
17
|
the body, never a git trailer).
|
|
18
|
+
- **`show` prints a `note:default-branch-ledger` line** (the ledger is keyed to `main`/`master`, shared
|
|
19
|
+
across sessions): the counts are NOT this run's cost. Render them with the words
|
|
20
|
+
`shared default-branch ledger, not attributable to this run`, or render `SOLEUR_TALLY_ABSENT`
|
|
21
|
+
when a per-run figure is required. Never copy them into `Pipeline-Tally:` as one run's cost.
|
|
18
22
|
- **Ledger present, all counters 0:** `tally: 0 — no counted operations`
|
|
19
23
|
(instrumented-but-unused is a real state, not an absence).
|
|
20
24
|
- **Ledger absent / `show` prints UNKNOWN:** the literal line `SOLEUR_TALLY_ABSENT` —
|