Skip to content

Commit 76a80e4

Browse files
chore(stage9): make the owner remote-cleanup script resumable and ruleset-aware
The owner's first run pushed main, feat/knowledge-proof and all 14 archive tags (verified on the remote) but every remote branch deletion was rejected: ruleset "Default" (22585978) forbids deletion and non-fast-forward on ~ALL branches with no bypass actors. The protection is worth keeping -- it is what stops any identity, agents included, from deleting or force-pushing main -- so the script now asks before switching it off for the deletion step, sends the full ruleset body on both PUTs rather than relying on partial-update semantics, re-enables via an EXIT trap even if a deletion fails, and proves afterwards that the ruleset matches its pre-change snapshot. Steps 1-2 are no-ops on re-run. The record carries the run's outcome as an addendum; the census gap (server-side protection was never asked about) is noted for Stage 10.
1 parent 4497efe commit 76a80e4

2 files changed

Lines changed: 73 additions & 10 deletions

File tree

‎docs/architecture/session-memory/receipts/council-stage9-2026-09-10.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,22 @@ Almost every finding was a verification request; each was run against git before
4343

4444
Push `main` (now 39 ahead) and `feat/knowledge-proof`; push the 14 tags; delete the 9 remote branches
4545
whose tips are tagged or fully merged. The script's preflight re-verifies every tag→OID first.
46+
47+
## Addendum — owner ran the remote script (2026-09-10 23:47)
48+
49+
- **Steps 1–2 succeeded and are verified on the remote:** `origin/main` `0adeb6c8 → 4497efed`,
50+
`origin/feat/knowledge-proof` `9a3eb5e1 → 464a8cdc`, all **14** `archive/*-2026-09-10` tags present.
51+
- **Step 3 rejected for all nine branches** (`GH013 … Cannot delete this branch`). Cause, read from the
52+
API: repository ruleset **"Default" (id 22585978)** — `enforcement=active`, `target=branch`,
53+
`include=["~ALL"]`, rules `deletion` + `non_fast_forward`, **no bypass actors**. It applies to every
54+
identity, so the web UI and the API would refuse the same way. The classification did not account for
55+
it; the plan council's Q-list did not ask about server-side protection. Recorded as a census gap.
56+
- **Not recommended:** adding the owner as a bypass actor — agents push under the owner's identity, so
57+
that would make the protection permanently moot for exactly the actor it most usefully constrains.
58+
- **Recommended and scripted:** switch the ruleset off for the deletion step only, with the script
59+
asking first, sending the full ruleset body on both PUTs, re-enabling through an `EXIT` trap even if a
60+
deletion fails, and diffing the ruleset against a pre-change snapshot afterwards. The script is
61+
idempotent, so re-running it repeats steps 1–2 as no-ops. Untested on the live ruleset by design (an
62+
access-control change is the owner's); the disabled body was dry-run against the live GET and equals the
63+
current ruleset with only `enforcement` changed.
64+
- Nothing is at risk while the branches remain: every tip is tagged on the remote.

‎scripts/maintenance/stage9-owner-remote-cleanup.sh‎

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
#!/usr/bin/env bash
22
# Stage 9 owner script — the remote half of the 2026-09-10 branch cleanup.
33
# Agents cannot push or delete remote refs on this repo (platform policy), so the
4-
# owner runs this once. Every step is idempotent; the preflight refuses to run if
5-
# any archive tag is missing or points somewhere other than the manifest says.
4+
# owner runs this. Every step is idempotent, so re-running after a partial run is
5+
# safe: already-pushed refs report "Everything up-to-date".
6+
#
7+
# First run (2026-09-10 23:47): steps 1-2 succeeded; step 3 was rejected for all
8+
# nine branches with GH013 "Cannot delete this branch". Cause: repository ruleset
9+
# "Default" (id 22585978) — active, target ~ALL branches, rules deletion +
10+
# non_fast_forward, no bypass actors. The rule is worth keeping (it is what stops
11+
# any identity, agents included, from force-pushing or deleting main), so step 3
12+
# now asks before switching it off, switches it back on whether or not the
13+
# deletions succeed, and proves afterwards that the ruleset is unchanged.
14+
#
615
# Manifest: docs/architecture/session-memory/receipts/stage9-disposition-2026-09-10.md
716
set -euo pipefail
817
cd "$(git rev-parse --show-toplevel)"
918

19+
REPO=NetDevAutomate/StudyLoop
20+
RULESET_ID=22585978
21+
RULESET_NAME=Default
22+
DOOMED=(
23+
feat/b1-fresh-install-scope feat/b2-ontology-migration feat/b3-concept-lifecycle
24+
feat/b4-recall-surfaces feat/sessionweaver-phase2-retrofit rescue/session-memory-mvp-20260907
25+
archive/gh-pages archive/socratic-study-mentor-main codex/evidence-context-evaluation
26+
)
27+
1028
echo "== preflight: every archive tag exists and points at the manifest's OID =="
1129
declare -A EXPECT=(
1230
[archive/feat-knowledge-proof-pre-okf-removal-2026-09-10]=27842b79
@@ -30,20 +48,46 @@ for t in "${!EXPECT[@]}"; do
3048
done
3149
echo " 14/14 tags verified"
3250

33-
echo "== 1. push main and the surviving feature branch (fast-forward only) =="
51+
echo "== 1. push main and the surviving feature branch (fast-forward only; no-op if already pushed) =="
3452
git push origin main
3553
git push origin feat/knowledge-proof
3654

37-
echo "== 2. push today's archive tags =="
55+
echo "== 2. push today's archive tags (no-op if already pushed) =="
3856
git push origin 'refs/tags/archive/*-2026-09-10'
3957

4058
echo "== 3. delete the remote branches whose tips are now tagged or fully merged =="
41-
git push origin --delete \
42-
feat/b1-fresh-install-scope feat/b2-ontology-migration feat/b3-concept-lifecycle \
43-
feat/b4-recall-surfaces feat/sessionweaver-phase2-retrofit rescue/session-memory-mvp-20260907 \
44-
archive/gh-pages archive/socratic-study-mentor-main codex/evidence-context-evaluation
59+
# The ruleset is switched off only for this step. The full ruleset body is sent on
60+
# both PUTs (not just the enforcement field) so nothing depends on partial-update
61+
# semantics, and the pre-change snapshot is kept for comparison and for a manual
62+
# restore if one were ever needed.
63+
SNAP="$(mktemp -t stage9-ruleset)"
64+
gh api "repos/${REPO}/rulesets/${RULESET_ID}" > "${SNAP}"
65+
minimal() { jq -c --arg e "$1" \
66+
'{name, target, enforcement: $e, bypass_actors: (.bypass_actors // []), conditions, rules}' "${SNAP}"; }
67+
reenable() {
68+
minimal active | gh api -X PUT "repos/${REPO}/rulesets/${RULESET_ID}" --input - --silent \
69+
&& echo " ruleset '${RULESET_NAME}' re-enabled (enforcement=active)"
70+
}
71+
echo " ruleset '${RULESET_NAME}' (${RULESET_ID}) currently: $(jq -r .enforcement "${SNAP}"), rules $(jq -c '[.rules[].type]' "${SNAP}"), target $(jq -c .conditions.ref_name.include "${SNAP}")"
72+
echo " snapshot: ${SNAP}"
73+
read -r -p " Switch it OFF for the deletions and straight back ON? [y/N] " ans
74+
if [[ "${ans}" =~ ^[Yy]$ ]]; then
75+
minimal disabled | gh api -X PUT "repos/${REPO}/rulesets/${RULESET_ID}" --input - --silent
76+
echo " ruleset disabled"
77+
trap reenable EXIT # safety net: re-enable even if a deletion fails
78+
git push origin --delete "${DOOMED[@]}" || echo " some deletions were rejected (see above)"
79+
reenable; trap - EXIT
80+
# prove the ruleset came back exactly as it was
81+
after="$(gh api "repos/${REPO}/rulesets/${RULESET_ID}" | jq -c '{name, target, enforcement, bypass_actors: (.bypass_actors // []), conditions, rules}')"
82+
before="$(minimal active)"
83+
if [[ "${after}" == "${before}" ]]; then echo " ruleset unchanged (verified against the snapshot)"; rm -f "${SNAP}"
84+
else echo " WARNING: ruleset differs from the snapshot — restore by hand from ${SNAP}"; echo " before: ${before}"; echo " after: ${after}"; fi
85+
else
86+
echo " skipped: the nine remote branches stay (their tips are tagged; nothing is at risk)"
87+
fi
4588

4689
echo "== 4. verify =="
4790
git fetch --prune origin
48-
echo "remote branches now:"; git branch -r | sed 's/^/ /'
49-
echo "remote archive tags: $(git ls-remote --tags origin 'archive/*-2026-09-10' | wc -l | tr -d ' ') (expect 14)"
91+
echo "remote branches now:"; git branch -r | grep -v HEAD | sed 's/^/ /'
92+
echo "remote archive tags: $(git ls-remote --tags origin 'archive/*-2026-09-10' | grep -vc '\^{}') (expect 14)"
93+
echo "ruleset '${RULESET_NAME}' enforcement: $(gh api "repos/${REPO}/rulesets/${RULESET_ID}" --jq .enforcement) (expect active)"

0 commit comments

Comments
 (0)