Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .claude/skills/series-loop/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ Reference: [`references/4-port.md`](references/4-port.md).
because a fold low in the window rewrites everything above it;
once a round comes back mostly green, pass a larger `--chunk`, and go back to the declared size at the next red low in the window.
* **Extend on pending, never on red**: a reported `failure` in `main-green..main-dev` stops the stage until stage 2 has folded its fix.
* **Mint without pushing when a fold has to come before CI**, as when R-side fixes or a doc sweep wait for the commits the chunk adds.
`--no-push-dev` keeps the extension in `refs/series/main-dev-next` and prints the leased push to run once the folds are in.
* A conflicting replay **stops the stage with the worktree kept**:

```sh
Expand Down
4 changes: 4 additions & 0 deletions .claude/skills/series-loop/references/5-extend.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ The push triggers one `each-rcc` run for the commits it added,
and every verdict that run reaches is readable from it as soon as the leg has written it.
The leg's own publish fills the store behind it.

**Mint without pushing when CI should judge the chunk folded, not as minted.**
When R-side fixes or a doc sweep wait for the commits a chunk adds, `--no-push-dev` leaves it in the local ref `refs/series/main-dev-next`.
The script prints the leased push to run once the folds are in, and its header says how `--continue` and `--abort` treat the option.

**Realign the rc strand, last.**
Once `main-rc-dev` exists, `scripts/series-rc.sh main --push` follows every write this firing made to `main-dev`,
here or in stages 2 and 4,
Expand Down
92 changes: 89 additions & 3 deletions scripts/series-advance-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# including glue, which is why the carry is a difference and not an allow-list.
# A forward series inherits only the first when its buffer is replayed out of
# `-build`, and both when it is replayed out of `-dev`
# (scripts/series-forward-build.sh). Twenty-one things are checked.
# (scripts/series-forward-build.sh). Twenty-two things are checked.
#
# 1. A buffered commit whose base `-dev` twin folded a test-side fix is minted
# with that fix in the same commit -- not stacked above it -- carrying the
Expand Down Expand Up @@ -71,6 +71,11 @@
# has a twin for the plain commit only.
# 21. The chunk is the series' own: the `chunk` `main`'s scripts/series.yaml
# declares bounds what one run appends, and `--chunk` overrides it.
# 22. `--no-push-dev` moves green, its canonical copy and `-build-base` as
# always, and mints the extension into `refs/series/<S>-dev-next` without
# writing `-dev`; the push it prints publishes it. A replay stopped under
# the option keeps it through a `--continue` that leaves it off, and
# `--abort` drops the unpushed ref.
#
# Usage:
# scripts/series-advance-test.sh
Expand Down Expand Up @@ -410,9 +415,34 @@ git branch late-fwd-dev base-seed
git branch late-fwd-green base-seed
git branch late-fwd-build-base base-seed

# --- an extension minted for folding, not pushed (claim 22) -----------------
# `hold` has one commit in flight with a successful verdict, so stage 3 has a
# green to move, mirror and match on the buffer, and two buffer commits above it
# on `-dev`'s line: the plain ref move. `stay` is the replay: `-dev` carries a
# repair the buffer's first commit conflicts with, so the run stops there.
git checkout -q -b hold-dev base-seed
bvendor dad1111 1.0.0.9000.1 v.c
HOLD_OK=$(git rev-parse HEAD)
git branch hold-green base-seed
git checkout -q -b hold-build hold-dev
bvendor dad2222 1.0.0.9000.2 w.c
bvendor dad3333 1.0.0.9000.3 x.c
git branch hold-build-base base-seed

git checkout -q -b stay-dev base-seed
echo 'foo <- function() 3' > R/foo.R
git add -A
git commit -qm 'fix: foo() returns 3, a repair -dev carries'
git branch stay-green base-seed
git checkout -q -b stay-build base-seed
echo 'foo <- function() 4' > R/foo.R
bvendor bee1111 1.0.0.9000.1 y.c
bvendor bee2222 1.0.0.9000.2 z.c
git branch stay-build-base base-seed

# The store stub: stage 5 refuses over a `failure` and reads `missing` for
# anything absent, which is what a freshly pushed commit looks like. The `red`
# series is the one case that needs real records, so it gets two.
# and `hold` series are the cases that need real records.
git checkout -q --orphan rcc2
git rm -rqf .
rec() { # <sha> <state>
Expand All @@ -422,6 +452,7 @@ rec() { # <sha> <state>
}
rec "$RED_OK" success
rec "$RED_BAD" failure
rec "$HOLD_OK" success
git add -A
git commit -q -m 'chore: store stub'

Expand Down Expand Up @@ -453,7 +484,9 @@ git push -q origin main base-seed base-build base-dev base-green base-build-base
loss-fwd-build loss-fwd-dev loss-fwd-green loss-fwd-build-base \
kept-dev kept-fwd-build kept-fwd-dev kept-fwd-green kept-fwd-build-base \
late-build late-dev late-green late-build-base \
late-fwd-build late-fwd-dev late-fwd-green late-fwd-build-base rcc2
late-fwd-build late-fwd-dev late-fwd-green late-fwd-build-base \
hold-build hold-dev hold-green hold-build-base \
stay-build stay-dev stay-green stay-build-base rcc2
git fetch -q origin

# A canonical remote, because `red` is the one series here whose green moves,
Expand Down Expand Up @@ -832,6 +865,59 @@ hasnt "so it carries no provenance trailer" "$(git log -1 --format=%B "$K")" 'Ca
is "the snapshot holds the fix and main's line both" \
"$(git show "$K:tests/testthat/_snaps/sql.md" | tr '\n' '|')" 'snapshot one, corrected|main added a snapshot|'

# --- claim 22: --no-push-dev mints the extension and leaves the push ----------
echo
echo "== --no-push-dev on the plain ref move"
before=$(git rev-parse origin/hold-dev)
out=$(run hold --no-push-dev)
[ -z "${KEEP:-}" ] || echo "$out"
git fetch -q origin
has "the run completes" "$out" 'EXIT=0'
is "green takes the commit CI proved" "$(git rev-parse origin/hold-green)" "$HOLD_OK"
is "and the canonical copy takes it too" "$(git --git-dir="$CANON" rev-parse hold-green)" "$HOLD_OK"
is "and -build-base is set to its match" "$(git rev-parse origin/hold-build-base)" "$HOLD_OK"
is "-dev is not written" "$(git rev-parse origin/hold-dev)" "$before"
is "the extension is minted into the local ref" \
"$(git rev-parse refs/series/hold-dev-next)" "$(git rev-parse origin/hold-build)"
has "the run says it did not push" "$out" 'dev not pushed: refs/series/hold-dev-next'
hasnt "and does not claim -dev moved" "$out" 'dev ->'
push=$(sed -n 's/^ \(git push --force-with-lease=.*\)$/\1/p' <<<"$out")
is "the push it prints leases the -dev the run read" \
"$push" "git push --force-with-lease=refs/heads/hold-dev:$before origin refs/series/hold-dev-next:refs/heads/hold-dev"
read -r -a argv <<<"$push"
[ ${#argv[@]} -eq 0 ] || "${argv[@]}" -q
git fetch -q origin
is "and publishes the extension" "$(git rev-parse origin/hold-dev)" "$(git rev-parse origin/hold-build)"
has "after which the buffer is consumed" "$(run hold)" 'buffer empty'

echo
echo "== --no-push-dev through a stopped replay"
before=$(git rev-parse origin/stay-dev)
out=$(run stay --no-push-dev)
has "stops on the conflicting pick" "$out" 'conflicted'
is "the stop records the option" "$(awk '{print $5}' .git/series-advance-stay)" no-push-dev
WT=$(awk '{print $1}' .git/series-advance-stay)
echo 'foo <- function() 4' > "$WT/R/foo.R"
git -C "$WT" add R/foo.R
out=$(run stay --continue)
[ -z "${KEEP:-}" ] || echo "$out"
has "a --continue without the option finishes the chunk" "$out" 'EXIT=0'
has "and still does not push" "$out" 'dev not pushed: refs/series/stay-dev-next'
git fetch -q origin
is "-dev is not written" "$(git rev-parse origin/stay-dev)" "$before"
is "both buffer commits are minted onto -dev's repair" \
"$(git rev-list --count origin/stay-dev..refs/series/stay-dev-next)" 2
is "with the counter risen once per vendor commit" \
"$(git show refs/series/stay-dev-next:DESCRIPTION | sed -n 's/^Version: //p')" 1.0.0.9000.2
is "no state file survives" "$([ -f .git/series-advance-stay ] && echo yes || echo no)" no
is "the kept worktree is gone" "$([ -d "$WT" ] && echo yes || echo no)" no
out=$(run stay --abort)
has "--abort drops the unpushed extension" "$out" 'unpushed extension'
is "the local ref is gone" \
"$(git rev-parse -q --verify refs/series/stay-dev-next || echo gone)" gone
git fetch -q origin
is "and -dev is still where it was" "$(git rev-parse origin/stay-dev)" "$before"

echo
echo "$pass passed, $fail failed"
[ "$fail" -eq 0 ]
76 changes: 63 additions & 13 deletions scripts/series-advance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@
# stage 2's mining step anchor on: a note written without it lands in the commit
# and is read by nothing, which is the one outcome the option exists to prevent.
#
# **`--no-push-dev` mints the extension and leaves its push to the operator.**
# The push that publishes `-dev` starts an each-rcc run whenever the branch's
# concurrency group is idle, so when R-side fixes or a doc sweep wait to be
# folded into the commits this stage mints, CI judges commits known to be broken
# and the run has to be cancelled. With the option, green, its mirror and
# `-build-base` move as always, and the extension is minted exactly as it would
# be, but it is written to the local ref `refs/series/<S>-dev-next` rather than
# pushed. The stage prints the push that publishes it, under a lease on the
# `-dev` this run read, for the operator to run once the folds are in. A stopped
# replay keeps the option, so a `--continue` without it still pushes nothing,
# and `--abort` drops the local ref as well as a stopped replay.
#
# **`--canonical` mirrors the green into the repository r-universe reads.**
# The series refs live in the fork, but the base flavors are published from the
# canonical repository, so `<S>-green` has to exist in both and nothing else
Expand All @@ -91,9 +103,9 @@
# a series adapts to a new engine, because a fold low in `-dev` rewrites
# everything above it (.claude/skills/series-loop/references/5-extend.md).
#
# Usage: series-advance.sh <series> [--chunk <n>] [--dev-note <file>]
# series-advance.sh <series> --continue [--dev-note <file>]
# series-advance.sh <series> --abort # discard a stopped replay
# Usage: series-advance.sh <series> [--chunk <n>] [--dev-note <file>] [--no-push-dev]
# series-advance.sh <series> --continue [--dev-note <file>] [--no-push-dev]
# series-advance.sh <series> --abort # discard a stopped replay or -dev-next
#
# --remote is spelled the same in every scripts/series-*.sh, and the chunk size
# is an option like vendor-one.sh's --commits rather than a bare number beside
Expand All @@ -106,13 +118,14 @@ set -euo pipefail
# shellcheck source=vendor-lib.sh
. "$(dirname "$0")/vendor-lib.sh"

usage='usage: series-advance.sh <series> [--chunk <n>] [--remote <name>] [--canonical <name>] [--dev-note <file>]
series-advance.sh <series> --continue [--dev-note <file>]
usage='usage: series-advance.sh <series> [--chunk <n>] [--remote <name>] [--canonical <name>] [--dev-note <file>] [--no-push-dev]
series-advance.sh <series> --continue [--dev-note <file>] [--no-push-dev]
series-advance.sh <series> --abort'
argerr() { echo "$usage" >&2; exit 2; }
CONTINUE=
ABORT=
DEV_NOTE=
NO_PUSH_DEV=
# Empty until --chunk gives one; the series' declared chunk is read below.
chunk=
remote=${SERIES_REMOTE:-origin}
Expand All @@ -128,6 +141,7 @@ while [ $# -gt 0 ]; do
--remote) [ $# -ge 2 ] || argerr; remote=$2; shift 2 ;;
--canonical) [ $# -ge 2 ] || argerr; canonical=$2; shift 2 ;;
--dev-note) [ $# -ge 2 ] || argerr; DEV_NOTE=$2; shift 2 ;;
--no-push-dev) NO_PUSH_DEV=1; shift ;;
-h | --help) echo "$usage"; exit 0 ;;
-*) argerr ;;
*) args+=("$1"); shift ;;
Expand All @@ -143,22 +157,39 @@ fi
rcc=${RCC_BRANCH:-rcc2}

# A stopped stage 5 lives here: the worktree it kept, the buffer commit whose
# replay stopped, its base twin, and which half stopped -- `pick` or `carry`.
# replay stopped, its base twin, which half stopped (`pick` or `carry`), and a
# fifth field, `no-push-dev`, when the run is not to push `-dev`.
# Per series, so one stopped series never blocks the firing's other ones.
STATE="$(git rev-parse --git-dir)/series-advance-${S//\//-}"
# Where --no-push-dev leaves the extension: a local ref, which every worktree
# of the clone sees, with a reflog, so a rerun that replaces it loses nothing.
NEXT_REF="refs/series/$S-dev-next"

if [ -n "$ABORT" ]; then
aborted=
if [ -f "$STATE" ]; then
read -r awt _ _ _ < "$STATE"
[ -d "$awt" ] && git worktree remove --force "$awt"
rm -f "$STATE"
echo "$S: stopped replay discarded; no ref was written"
else
echo "$S: nothing to abort"
aborted=1
fi
if git rev-parse -q --verify "$NEXT_REF" >/dev/null; then
echo "$S: unpushed extension $(git rev-parse --short "$NEXT_REF") discarded from $NEXT_REF"
git update-ref -d "$NEXT_REF"
aborted=1
fi
[ -n "$aborted" ] || echo "$S: nothing to abort"
exit 0
fi

# A stopped replay keeps the --no-push-dev it started with, so a --continue
# that leaves the option off still pushes nothing.
if [ -n "$CONTINUE" ] && [ -f "$STATE" ]; then
read -r _ _ _ _ smode < "$STATE"
[ "$smode" != no-push-dev ] || NO_PUSH_DEV=1
fi

# Every buffer commit stage 5 replays moves `Version:`, so the `ours-version`
# merge driver decides DESCRIPTION on each pick. The name -> command mapping
# lives in .git/config and cannot be committed, so a fresh clone has the
Expand Down Expand Up @@ -640,6 +671,16 @@ n=$((ahead < chunk ? ahead : chunk))
# remote-tracking ref this resolves -- read it once, here.
dev_before=$(git rev-parse "$dev")

# The one write stage 5 makes: `-dev` itself, or under --no-push-dev the local
# ref the operator pushes once the folds are in.
publish_dev() { # <tip>
if [ -n "$NO_PUSH_DEV" ]; then
git update-ref --create-reflog -m "series-advance.sh $S --no-push-dev" "$NEXT_REF" "$1"
else
git push "$remote" "$1:refs/heads/$S-dev"
fi
}

# Which commits in this chunk have a test-side fix waiting on the base series.
# Computed before anything is written, because it decides the route: a plain ref
# move cannot carry content, so one carry in the chunk makes the whole chunk a
Expand Down Expand Up @@ -674,7 +715,7 @@ fi
if [ "$anchor" = "$(git rev-parse "$dev")" ] && [ "$carries" -eq 0 ] &&
[ -z "$CONTINUE" ] && [ -z "$DEV_NOTE" ]; then
next=$(git rev-list --reverse "$anchor..$build" | sed -n "${n}p")
git push "$remote" "$next:refs/heads/$S-dev"
publish_dev "$next"
else
# Replay onto the repaired tip in a throwaway worktree; a conflict means the
# repair and the buffer touch the same paths — judgement, not mechanics.
Expand All @@ -689,7 +730,7 @@ else
# conflict, and whoever resolves it needs somewhere to do that. Nothing has
# been pushed at this point, so a stop costs a rerun and no ref motion.
stop() { # <worktree> <buffer commit> <twin or -> <pick|carry>
printf '%s %s %s %s\n' "$1" "$2" "$3" "$4" > "$STATE"
printf '%s %s %s %s%s\n' "$1" "$2" "$3" "$4" "${NO_PUSH_DEV:+ no-push-dev}" > "$STATE"
echo >&2
if [ "$4" = carry ]; then
echo "Error: $S — carrying the test-side fix from $(git rev-parse --short "$3") into" >&2
Expand Down Expand Up @@ -807,7 +848,7 @@ else
}

if [ -n "$CONTINUE" ]; then
read -r wt rc rd rstage < "$STATE"
read -r wt rc rd rstage _ < "$STATE"
[ -d "$wt" ] || { echo "Error: the kept worktree $wt is gone — rerun with --abort" >&2; exit 1; }
[ -z "$(git -C "$wt" diff --name-only --diff-filter=U)" ] ||
stop "$wt" "$rc" "$rd" "$rstage"
Expand Down Expand Up @@ -924,6 +965,15 @@ else
fi
git worktree remove --force "$wt"
rm -f "$STATE"
git push "$remote" "$next:refs/heads/$S-dev"
publish_dev "$next"
fi
added=$(git rev-list --count "$dev_before..$next")
if [ -n "$NO_PUSH_DEV" ]; then
# The lease is on the -dev this run read and minted on: a -dev that moved
# since was written by someone else, and the push refuses rather than drop it.
echo "dev not pushed: $NEXT_REF -> $(git rev-parse --short "$next") (+$added), $S-dev stays at $(git rev-parse --short "$dev_before")"
echo " fold what the new commits need, move the ref to the folded tip (git update-ref $NEXT_REF <tip>), then:"
echo " git push --force-with-lease=refs/heads/$S-dev:$dev_before $remote $NEXT_REF:refs/heads/$S-dev"
else
echo "dev -> $(git rev-parse --short "$next") (+$added)"
fi
echo "dev -> $(git rev-parse --short "$next") (+$(git rev-list --count "$dev_before..$next"))"
7 changes: 7 additions & 0 deletions scripts/series-args-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ done
is "series-port.sh --dev-note without --apply" \
"$(rc series-port.sh s --dev-note /dev/null)" 2

echo
echo "== --no-push-dev is a flag of series-advance.sh"
isnt "series-advance.sh --no-push-dev is not a usage error" \
"$(rc series-advance.sh s --no-push-dev)" 2
is "series-advance.sh offers it" \
"$(out series-advance.sh --help | grep -c -- '--no-push-dev')" 1

echo
echo "== a missing series is a usage error too"
for s in series-advance.sh series-land.sh series-patch-sync.sh series-port.sh; do
Expand Down
Loading