Skip to content

refactor(cc-249): PR-B.2 v2 — consumer migration to unified assert_* helpers (3 batches, 10 files)#152

Merged
screenleon merged 6 commits into
mainfrom
cc-249-pr-b2-consumer-migration-v2
May 24, 2026
Merged

refactor(cc-249): PR-B.2 v2 — consumer migration to unified assert_* helpers (3 batches, 10 files)#152
screenleon merged 6 commits into
mainfrom
cc-249-pr-b2-consumer-migration-v2

Conversation

@screenleon
Copy link
Copy Markdown
Owner

Summary

CC-249 PR-B.2 v2 — the clean pure-rename + delete-local-defs migration the spike (docs/spikes/CC-249.md, #146) originally envisioned. Migrates 10 of 13 test-*.sh consumers off divergent local assert_* helpers onto the unified harness API added by PR-B.1 (#148) and amended by CC-254 (#149, no auto-pass).

3 commits of migration + 1 commit filing the defer ticket for the remaining 3 excluded files:

  • 9ed320e Batch A — 4 files variant-A literal rename: test-skill-refine, test-commands-runner, test-usage-tracker, test-usage-weekly (-54 LoC)
  • 9f05981 Batch B — 4 files: test-setup-project, test-pr-gate, test-install (variant-A literal); test-commands.sh (per-call regex-vs-literal classify per spike Q2/U2) (-83 LoC)
  • be7af17 Batch C — 2 files: test-check-docs-freshness (assert_exit arg-order FLIP + assert_output_contains→assert_string_contains with explicit $LAST_OUTPUT); test-patch-gitignore (assert_contains→assert_file_contains + assert_output_contains→assert_string_contains)
  • dfa4895 CC-256 — defer ticket for the 3 excluded files (test-test-harness cyclic dependency, test-run-all-tests orchestrator shape, test-hooks audit-confirm-only)

Net: −114 LoC across the 10 migrated files (≈63% reduction in assert helper boilerplate). Harness untouched; 3 excluded files untouched.

Lineage

PR-B.2 v1 was abandoned (became CC-253 misdirected output). This v2 is the clean re-execution.

Test plan

  • Each of the 10 migrated files runs locally with exit 0
  • scripts/test-test-harness.sh 30/30 passes (no regression)
  • Golden-parity round-trip spot-check on test-skill-refine.sh (Batch A) and test-check-docs-freshness.sh (Batch C): both empty (byte-identical stdout vs origin/main)
  • 0 local redefinitions of the 4 unified helpers across all 10 migrated files (grep -cE '^(function )?(assert_exit|assert_file_contains|assert_file_matches|assert_string_contains)\(\)' returns 0 for each)
  • scripts/lib/test-harness.sh untouched (git diff --stat empty)
  • 3 excluded files untouched: scripts/test-run-all-tests.sh, scripts/test-test-harness.sh, scripts/test-hooks.sh (git diff --stat empty)
  • .github/workflows/lint.yml ignore_names block already includes both Batch C basenames (no edit needed)
  • bash scripts/lint-scripts.sh OK (52 files); CI ludeeus shellcheck will run strict layer
  • pm/scripts/validate.sh BACKLOG.md DECISIONS.md CHANGELOG.md — validator-neutral (30 pre-existing E-codes unchanged, tracked by CC-228)
  • /pr-gate standard (critic / qa-tester / architecture-reviewer): Final: GO, 0 findings, escalation empty — .gate-results/gate-20260524-174507.md

Process notes

  • Per [[feedback_codex_brief_discipline]]: every Batch C apply_patch pinned expected_head_sha: 9f05981, retry-cap 3 (HALT-and-report); brief delivered as dispatch_handover_v1 block per [[feedback_pm_dispatch_handover_inline]].
  • Per [[feedback_test_migration_format_preservation]]: pre-migration baseline captured for both Batch C files; post-migration diff empty (byte-identical stdout).
  • Per [[feedback_codex_dispatch_lifecycle_leak]]: dispatched via main-thread Bash(codex-dispatch.sh, run_in_background: true), not Agent(codex-executor).
  • Per [[feedback_pr_gate_before_pr]]: gated locally before opening PR, not after.
  • Codex sandbox blocked .git/index.lock (known recurring per memory §CC-203 GROUP-B retro 3); main thread committed Batch C manually.

🤖 Generated with Claude Code

screenleon and others added 6 commits May 24, 2026 03:05
Per CC-249 spike Q3 (break-and-rewrite) + CC-254 amendment (harness
helpers no longer auto-call pass), this batch migrates 4 consumer
test scripts from local `assert_exit` + `assert_contains` defs to
harness helpers (`assert_exit`, `assert_file_contains`,
`assert_string_contains`). All variant A (literal substring); pure
rename + delete local defs.

Files:
- scripts/test-skill-refine.sh
- scripts/test-commands-runner.sh
- scripts/test-usage-tracker.sh
- scripts/test-usage-weekly.sh

Out-of-scope local helpers preserved: assert_not_contains,
assert_matches, assert_occurrences, assert_line_count,
assert_all_case_lines_match (no harness equivalent).

Existing `pass "$name"` / `|| return` chains UNCHANGED — works
because CC-254 made the harness helpers return-only on success.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…mands regex classify

Per CC-249 spike Q3 + CC-254 amendment. Batch B of the 3-batch PR-B.2
consumer migration plan (Batch A in 9ed320e). Migrates:

- scripts/test-setup-project.sh (variant A literal, pure rename)
- scripts/test-pr-gate.sh        (variant A literal, pure rename, 1973 LoC)
- scripts/test-install.sh        (variant A literal, pure rename, 1869 LoC)
- scripts/test-commands.sh       (per-call regex-vs-literal classification)

test-commands.sh classification per spike Q2: calls with regex
metachars (^, $, \|, |, *, .) → assert_file_matches; plain literals
→ assert_file_contains. Worked examples confirmed:
  "^\| `off`" → matches
  "^### Rules: off" → matches
  "imperative" → contains
  "`feat`" → contains

Out-of-scope local helpers preserved: assert_not_contains,
assert_frontmatter, assert_in_section, assert_entry_once,
assert_expected_entries_once, assert_symlink_target,
assert_dir_not_symlink, assert_file_content (all have no harness
equivalent).

Existing `pass "$name"` / `|| return` chains UNCHANGED — works
because CC-254 made harness helpers return-only on success.

Verification:
- 0 local defs of assert_exit / assert_contains across 4 files
- 0 shadow-shim defs (no consumer redefining the harness helpers)
- 0 bare `assert_contains` calls (all renamed)
- harness byte-identical (git diff --quiet passed)
- 3 excluded files (test-run-all-tests, test-test-harness, test-hooks)
  byte-identical
- test-test-harness.sh 30/30 passes
- Golden parity round-trip verified for setup-project, pr-gate,
  commands (no VERBOSE + VERBOSE=1); test-install.sh round-trip
  exceeded codex wall-time budget but file-level checks all pass
  (revisit on next session if golden-diff confirmation needed)

Net diff: -83 LoC (213 insertions / 296 deletions) — deletions
dominate as spike Cost Estimate predicted.

Batch C deferred to next session (per user 2026-05-24): 2 files
remain (test-check-docs-freshness arg-order flip,
test-patch-gitignore output_contains merge).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…-harness / test-run-all-tests / test-hooks)

PR-B.2 v2 (CC-249) migrated 10/13 consumers off divergent assert_*
helpers onto the unified harness API. The remaining 3 files need
per-file analysis rather than a mechanical rename batch:

- test-test-harness.sh: cyclic dependency (tests the harness itself)
- test-run-all-tests.sh: orchestrator shape, 2 call-sites need review
- test-hooks.sh: 0 unified-helper call-sites — audit-confirm-only

Filed as P3 reuse-debt so CC-249 epic can close as scoped (10/13).
Validator-neutral edit (30 pre-existing E-codes unchanged, tracked
by CC-228).
CC-249 (consolidate divergent assert_* helpers) closes via the spike
(#146) → PR-B.1 helpers (#148) → CC-254 amendment (#149) → PR-B.2 v2
consumer migration (#152, this branch). 10/13 consumers migrated;
3 excluded files carried as CC-256.

Tail commit updates:
- index row: 🟢 someday → ✅ closed 2026-05-24; pr ref → pr:#148,#149,#152
- body heading: deferred → closed 2026-05-24
- Outcome + See blocks appended
- CC-256 row pr ref: pr:TBD → pr:#152

Validator-neutral edit (30 pre-existing E-codes unchanged, tracked
by CC-228).
… (7× command-not-found per invocation)

Discovered while running /pr-gate standard on cc-249-pr-b2-consumer-migration-v2
(this branch). Gate verdict + result file emit correctly (Final: GO
produced cleanly) but scripts/pr-gate.sh:362 throws 7 "command not
found" errors per invocation matching literal `Final:`/`final:`/`**Final:`
tokens from inside the codex brief heredoc body.

Classified medium per [[feedback_gate_finding_triage]]: no-block gate +
no correctness impact, but hits 100% of /pr-gate runs and buries real
shell errors under false-positive noise.

Hypothesis: unquoted heredoc delimiter `<< BRIEF_EOF` lets bash expand
metachars in the body; OR a downstream eval/source re-executes parsed
lines. Investigation + fix carried by CC-257.

Validator-neutral edit (30 pre-existing E-codes unchanged).
@screenleon screenleon merged commit e9f4257 into main May 24, 2026
16 checks passed
@screenleon screenleon deleted the cc-249-pr-b2-consumer-migration-v2 branch May 24, 2026 09:27
screenleon added a commit that referenced this pull request May 24, 2026
…e (22/23) + format/fail-fast options + consumer adoption (#153)

CC-247 + CC-248 (th_init --format=<preset> + --fail-fast harness options)
shipped in PR #142 on 2026-05-23 but BACKLOG status was never flipped.
Final consumer adoption verified post PR-B.2 v2 (#152) close-out:
- 4 of 10 migrated consumers select a non-default --format preset
- 3 of 4 fail-fast consumers use --fail-fast (test-skill-refine,
  test-usage-tracker, test-usage-weekly)
- grep '^(pass|fail)()' scripts/test-*.sh returns 0 (no per-file
  print-format or fail() overrides remain)

CC-203 (shared scripts/lib/test-harness.sh) reaches its closure
threshold at 22/23 test-*.sh adoption. The lone non-adopter is the
orchestrator scripts/test-run-all-tests.sh which runs other test-*.sh
as subprocesses and asserts on aggregated output — not a case-based
harness fit; deliberately excluded per the GROUP-B re-analysis. The
3 files excluded from PR-B.2 v2's assert_* migration (CC-256) are
on a separate axis and do not block CC-203 closure.

Index + body sections updated for all 3 tickets with Outcome / See
blocks. Validator-neutral edit (30 → 29 E-codes — opportunistically
cleared CC-203 invalid area enum `ops/test/reuse` → `ops/test` as
part of the row touch).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant