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: 1 addition & 1 deletion docs/reference/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ GENERATED , do not hand-edit. Regenerate: `bash lib/registry/feature-registry.sh
| `/kit:verify` | `[H/I]` | Re-run the test levels (kit:task-verifier + kit:integration-verifier + kit:acceptance-verifier, plus kit:system-verifier only with --full) … | SPEC-002, SPEC-003, SPEC-006 +57 | test-board-digest.sh, test-board-hermes.sh, test-board-lock-required.sh +35 |
| `/kit:visual-team` | `[H/I]` | Parallel multi-lens critique of a visual/UI design. Dispatches 5 design lenses, merges findings, reports a verdict. Report-only, downstream… | SPEC-016, SPEC-018, SPEC-019 +12 | test-command-emit-sweep.sh, test-meta-review-verifiers.sh, test-meta-spec-depth.sh +1 |
| `/kit:wayfind` | `[H]` | Plan a chunk of work too big for one agent session as a shared decision map: map.md + typed decision tickets in the mega-goal folder, resol… | SPEC-206, SPEC-207, SPEC-217 +2 | - |
| `/kit:wrap` | `[H/I]` | The session-scoped landing step after ship: flips board rows, merges green PRs, checks deploys, tidies worktrees, prints the skim-first rep… | SPEC-020, SPEC-060, SPEC-072 +75 | test-bin-forwarders.sh, test-board-lock-required.sh, test-board-work.sh +55 |
| `/kit:wrap` | `[H/I]` | The session-scoped landing step after ship: flips board rows, merges green PRs, checks deploys, tidies worktrees, prints the skim-first rep… | SPEC-020, SPEC-060, SPEC-072 +75 | test-bash32-parse.sh, test-bin-forwarders.sh, test-board-lock-required.sh +56 |

## Agents

Expand Down
153 changes: 153 additions & 0 deletions docs/verification/l312-bash32-hotfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Verification: l312-bash32-hotfix

Headless bash 3.2 compatibility hotfix for `lib/wrap/wrap-session.sh` and `lib/wrap/report-lint.sh`, plus an always-on `/bin/bash` 3.2 parse and runtime guard (`tests/test-bash32-parse.sh`) that runs in the fast PR lane on macOS: no visible UI surface.

## Cause

`lib/wrap/wrap-session.sh` (merged in PR 1257) failed to parse under Apple's stock `/bin/bash` 3.2 (`line 740: syntax error near unexpected token '('`). Under bash 3.2, `parse_comsub` inside `"$( ... )"` tracks quotes before stripping comments: the unmatched apostrophes in `# ... its record's cwd` (line 611, inside `acted="$( ... )"`) and `# ... another user's repo` (line 655, inside `repos_json="$( ... )"`) left a phantom single quote open until line 736's `jq -r '`, which closed it and exposed line 740 as unquoted bash syntax. Running the wrap pipeline under a `/bin/bash` 3.2 PATH shim exposed two more 3.2-only runtime failures that `/bin/bash -n` alone cannot see: unparenthesized `case` clauses inside `acted="$( ... )"` in `lib/wrap/wrap-session.sh` (lines 617 and 630, which cause `wrap session` to exit 0 with `.transcript == null`), and an unguarded empty array expansion `"${built_items[@]}"` under `set -u` in `lib/wrap/report-lint.sh` (line 284). CI missed both classes because `.github/workflows/test.yml` prepends Homebrew bash 5 to `PATH` on `macos-latest`, so `#!/usr/bin/env bash` never ran under `/bin/bash` 3.2. `tests/test-bash32-parse.sh` now closes both halves: Stage 1 parses every shipped shell file with `/bin/bash -n`, and Stage 2 executes `bin/wrap session --json/--summary --transcript` and `lib/wrap/report-lint.sh` under `/bin/bash` 3.2 with `bash` shimmed to `/bin/bash` first on `PATH`, asserting both clean stderr and expected output.

## Green runs

### 1. Bash 3.2 parse and runtime guard (`tests/test-bash32-parse.sh`)

```text
Command: bash tests/test-bash32-parse.sh && /bin/bash tests/test-bash32-parse.sh
Exit: 0
Output:
test-bash32-parse: RUNNING under /bin/bash (3.2)
test-bash32-parse: PASS under /bin/bash (3.2) (272 shipped shell files parsed; wrap session and report-lint runtime verified)
test-bash32-parse: RUNNING under /bin/bash (3.2)
test-bash32-parse: PASS under /bin/bash (3.2) (272 shipped shell files parsed; wrap session and report-lint runtime verified)
Verdict: PASS
```

When `/bin/bash` is not 3.2 (simulated against Homebrew bash 5.3), the suite prints a clear skip line and exits 0:

```text
Command: bash -c 't="$(mktemp)"; trap "rm -f \"\$t\"" EXIT; sed "s|BASH32=\"/bin/bash\"|BASH32=\"$(which bash)\"|" tests/test-bash32-parse.sh > "$t"; bash "$t"'
Exit: 0
Output:
test-bash32-parse: SKIP (/opt/homebrew/bin/bash is 5.3, not 3.2; bash 3.2 check runs on macOS)
Verdict: PASS
```

### 2. Output parity on `wrap session --summary` before and after (bash 5 and `/bin/bash` 3.2 shim)

Captured `wrap session --summary --prs acme/widgets#12 --transcript <fixture> <repo>` and direct `_session_summary_text` output on `origin/master` (under bash 5) before editing, then diffed against post-fix output under bash 5 and under `/bin/bash` 3.2 with `bash` shimmed to `/bin/bash` first on `PATH` (timestamps normalized for `generated_at`, `epoch`, and `read_at`).

```text
Command: diff -u before.direct.summary after.direct.bash5.summary && diff -u before.direct.summary after.direct.bash32.summary && diff -u <(norm before.summary) <(norm after.bash5.summary) && diff -u <(norm before.summary) <(norm after.bash32.summary)
Exit: 0
Output:
DIRECT BASH5 DIFF: IDENTICAL (0 diffs)
DIRECT BASH32 DIFF: IDENTICAL (0 diffs)
E2E BASH5 DIFF: IDENTICAL (0 diffs)
E2E BASH32 DIFF: IDENTICAL (0 diffs)
Verdict: PASS
```

### 3. Wrap suites on bash 5 and `/bin/bash` 3.2 (with `PATH` shimmed to `/bin/bash`, rebased onto `origin/master`)

```text
Command: bash tests/test-wrap-session.sh && PATH="$SHIM:$PATH" /bin/bash tests/test-wrap-session.sh && bash tests/test-wrap-report-lint.sh && PATH="$SHIM:$PATH" /bin/bash tests/test-wrap-report-lint.sh
Exit: 0
Output:
test-wrap-session: all 159 passed
test-wrap-session: all 159 passed
test-wrap-report-lint: all 184 passed
test-wrap-report-lint: all 184 passed
Verdict: PASS
```

### 4. Fast PR lane selection on an unrelated diff (`# always:` header)

```text
Command: bash tests/run-all.sh --changed "$base" --list | grep -Fx "tests/test-bash32-parse.sh"
Exit: 0
Output:
docs-only diff selected 19 suites
tests/test-bash32-parse.sh
CONFIRMED: test-bash32-parse.sh runs in fast PR lane on any diff
Verdict: PASS
```

### 5. Lints, operator-pin, owners, secret-scan, and feature-registry

```text
Command: shellcheck --norc -S warning lib/wrap/wrap-session.sh lib/wrap/report-lint.sh tests/test-bash32-parse.sh && bash tests/test-operator-pin.sh && bash scripts/check-owners.sh && bash scripts/secret-scan.sh && bash lib/registry/feature-registry.sh check
Exit: 0
Output:
operator-pin: 4 passed, 0 failed
owners: 14 paths, all have a row
secret-scan: 2319 tracked files, no secret found
feature-registry: docs/reference/FEATURES.md is fresh
Verdict: PASS
```

## Negative control

### 1. Reverting only the two `case` clauses in `lib/wrap/wrap-session.sh` turns Stage 2 RED while Stage 1 stays green

```text
Command: /bin/bash tests/test-bash32-parse.sh
Exit: 1
Output:
stderr: or see the jq manpage, or online docs at https://jqlang.org
transcript: null
FAIL: runtime bin/wrap session --summary --transcript under /bin/bash (3.2) (exit 0)
stderr: lib/wrap/wrap-session.sh: command substitution: line 645: syntax error near unexpected token `newline'
stderr: lib/wrap/wrap-session.sh: command substitution: line 645: ` case "$d" in /*'
stderr: jq: invalid JSON text passed to --argjson
test-bash32-parse: FAILED (2 failure(s) under /bin/bash 3.2; 272 files parsed):
- runtime: bin/wrap session --json --transcript
- runtime: bin/wrap session --summary --transcript
Verdict: RED, as expected
```

Broke via `bash scripts/negctl.sh "/bin/bash tests/test-bash32-parse.sh" "perl -pi -e 's/case \"\\\$d\" in \\(\\/\\*\\) ;; \\(\\*\\) d=\"\" ;; esac/case \"\\\$d\" in \\/*) ;; *) d=\"\" ;; esac/; s/case \"\\\$n\" in \\('\'''\''\\|\\*\\[!0-9\\]\\*\\) continue ;; esac/case \"\\\$n\" in '\'''\''|*[!0-9]*) continue ;; esac/' lib/wrap/wrap-session.sh"` (changed: `lib/wrap/wrap-session.sh`). Restored with `git checkout`; the tree is clean and the suite is green again (exit 0).

### 2. Reverting only `lib/wrap/report-lint.sh` turns Stage 2 RED on `built_items[@]: unbound variable`

```text
Command: /bin/bash tests/test-bash32-parse.sh
Exit: 1
Output:
test-bash32-parse: RUNNING under /bin/bash (3.2)
FAIL: runtime lib/wrap/report-lint.sh under /bin/bash (3.2) (exit 1)
stderr: lib/wrap/report-lint.sh: line 392: built_items[@]: unbound variable

test-bash32-parse: FAILED (1 failure(s) under /bin/bash 3.2; 272 files parsed):
- runtime: lib/wrap/report-lint.sh (empty built_items)
Verdict: RED, as expected
```

Broke via `bash scripts/negctl.sh "/bin/bash tests/test-bash32-parse.sh" "git checkout origin/master -- lib/wrap/report-lint.sh"` (changed: `lib/wrap/report-lint.sh`). Restored with `git checkout`; the tree is clean and the suite is green again (exit 0).

### 3. Reverting `lib/wrap/wrap-session.sh` to `origin/master` turns Stage 1 and Stage 2 RED

```text
Command: /bin/bash tests/test-bash32-parse.sh
Exit: 1
Output:
lib/wrap/wrap-session.sh: line 740: ` "config " + (.config | to_entries | map("\(.key)=\(.value | v)") | join(" ")),'
FAIL: runtime bin/wrap session --json --transcript under /bin/bash (3.2) (exit 1)
stderr: lib/wrap/wrap-session.sh: line 740: syntax error near unexpected token `('
stderr: FATAL: lib/wrap/wrap-session.sh missing or unreadable
test-bash32-parse: FAILED (3 failure(s) under /bin/bash 3.2; 272 files parsed):
- parse: lib/wrap/wrap-session.sh
- runtime: bin/wrap session --json --transcript
- runtime: bin/wrap session --summary --transcript
Verdict: RED, as expected
```

Broke via `bash scripts/negctl.sh "/bin/bash tests/test-bash32-parse.sh" "git checkout origin/master -- lib/wrap/wrap-session.sh"` (changed: `lib/wrap/wrap-session.sh`). Restored with `git checkout`; the tree is clean and the suite is green again (exit 0).

## Rollback

Revert the merge commit on `master` (or restore `lib/wrap/wrap-session.sh` and `lib/wrap/report-lint.sh` and remove `tests/test-bash32-parse.sh` and this proof file):

```bash
git revert <merge-sha>
```

No external state, secrets, hooks, gates, or workflow files are modified by this change.
2 changes: 1 addition & 1 deletion lib/wrap/report-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ else
# session does not build is REPORTED here and nowhere else; a board row is the operator's
# call, never a side effect of the wrap.
_v_idx=0
for _v_item in "${built_items[@]}"; do
for _v_item in ${built_items[@]+"${built_items[@]}"}; do
_v_idx=$((_v_idx + 1))
case "$_v_item" in
REPORTED\ *)
Expand Down
16 changes: 10 additions & 6 deletions lib/wrap/wrap-session.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=bash
# wrap-session.sh -- the session verb: one read-only gather for commands/wrap.md.
# Sourced by lib/wrap/wrap.sh. stdout is exactly one JSON document; diagnostics stay on stderr.

Expand Down Expand Up @@ -608,13 +609,13 @@ _session_transcript_json() {
unknown="$(mktemp "${TMPDIR:-/tmp}/kit.XXXXXX")"
acted="$( { printf '%s\n' "$raw" | grep -av "$(printf '^\001BARE')"
# \037 (unit separator), not a tab: IFS would fold a run of tabs and shift empty fields.
# A relative `cd` target is already joined onto its record's cwd; a target that does not
# A relative cd target is already joined onto the record cwd; a target that does not
# land in a git repo with a GitHub origin is UNKNOWN, never credited to another repo.
while IFS="$(printf '\037')" read -r _ dir slug n branch; do
[ -n "$dir$slug$n$branch" ] || continue
if [ -z "$slug" ]; then
d="$(printf '%s' "$dir" | sed "s#^~/#$HOME/#")"
case "$d" in /*) ;; *) d="" ;; esac
case "$d" in (/*) ;; (*) d="" ;; esac
while [ -n "$d" ] && [ "$d" != "/" ] && [ ! -d "$d" ]; do d="$(dirname "$d")"; done
main=""
[ -n "$d" ] && [ "$d" != "/" ] && main="$(_session_main_checkout "$d" 2>/dev/null)"
Expand All @@ -627,7 +628,7 @@ _session_transcript_json() {
if [ -z "$n" ] && [ -n "$branch" ] && [ "$(_gh_state)" = ok ]; then
n="$(gh pr list --repo "$slug" --head "$branch" --state all --limit 1 --json number --jq '.[0].number // empty' 2>/dev/null)" # merged-ok: names the PR a branch-only merge acted on, read live after; never a deletion proof
fi
case "$n" in ''|*[!0-9]*) continue ;; esac
case "$n" in (''|*[!0-9]*) continue ;; esac
printf 'https://github.com/%s/pull/%s\n' "$slug" "$n"
done <<EOF_SESSION_BARE
$bare
Expand All @@ -652,7 +653,7 @@ EOF_SESSION_BARE
while [ -n "$d" ] && [ "$d" != "/" ] && [ ! -d "$d" ]; do d="$(dirname "$d")"; done
[ -d "$d" ] && [ "$d" != "/" ] && [ "$d" != "$HOME" ] || continue
main="$(_session_main_checkout "$d" 2>/dev/null)" || continue
# Only a checkout the current user owns; another user's repo is never gathered from transcript text.
# Only a checkout owned by the current user; a repo owned by another user is never gathered from transcript text.
[ -n "$main" ] && [ "$main" != "$HOME" ] && [ -O "$main" ] && printf '%s\n' "$main"
done <<EOF_SESSION_TPATHS | awk '!seen[$0]++' | _session_lines_json
$paths
Expand Down Expand Up @@ -733,7 +734,8 @@ _session_named_prs_json() {
# _session_summary_text <json> -- the compact view of one wrap-session/1 document: every field
# commands/wrap.md reads, one fact per line, so the report never re-reads the JSON.
_session_summary_text() {
printf '%s' "$1" | jq -r '
local prog
IFS= read -r -d '' prog <<'EOF_SESSION_SUMMARY_JQ' || true
def v: if . == null then "-" else tostring end;
def sha: if . == null then "-" else .[0:12] end;
"wrap-session/1 generated_at=\(.generated_at) epoch=\(.generated_at_epoch) repos=\(.summary.repos) open_own_prs=\(.summary.open_own_prs) pending_prs=\(.summary.pending_prs) named_prs=\(.summary.named_prs) foreign_activity_repos=\(.summary.foreign_activity_repos)",
Expand Down Expand Up @@ -771,7 +773,9 @@ _session_summary_text() {
" sweep " + ((.rows // []) | group_by(.verdict) | map("\(.[0].verdict)=\(length)") | join(" ") | if . == "" then "rows=0" else . end) + (if .error then " error=\"\(.error)\"" else "" end),
((.rows // [])[] | select(.verdict != "keep") | " \(.verdict) \(.kind) \(.branch // .path | v) \(.reason)"))
else " sweep text-fallback (read-only, no fetch): see --json" end)
end)' 2>/dev/null
end)
EOF_SESSION_SUMMARY_JQ
printf '%s' "$1" | jq -r "$prog" 2>/dev/null
}

# _session_repo_json <repo> -- one repo object. Every child read degrades into a field,
Expand Down
Loading
Loading