Skip to content

TAP-1881 epic: .gitignore allowlist + idempotent upgrade backfill#22

Merged
wtthornton merged 2 commits into
mainfrom
tap-1881-gitignore-allowlist-epic
May 17, 2026
Merged

TAP-1881 epic: .gitignore allowlist + idempotent upgrade backfill#22
wtthornton merged 2 commits into
mainfrom
tap-1881-gitignore-allowlist-epic

Conversation

@wtthornton
Copy link
Copy Markdown
Owner

Summary

Closes the .gitignore audit epic (TAP-1881). Two stories:

  • TAP-1882templates/.gitignore switches from a hand-maintained per-file denylist (already 14 patterns behind what Ralph writes under .ralph/) to .ralph/* + ! allowlist exceptions for the committed set (PROMPT.md, AGENT.md, fix_plan.md, hooks/, .gitkeep). The duplicate hardcoded list in lib/enable_core.sh:884-897 and its marker-skip merge are removed; merge_gitignore_block becomes the single source-of-truth helper, doing line-by-line grep -qxF membership checks and appending only missing patterns.
  • TAP-1883ralph_upgrade_project.sh calls the same helper as a Tier-2 merge. ralph upgrade on a stale consumer repo now backfills missing entries automatically (tapps-brain commit ba09360 on 2026-05-16 was the worked example we're automating away). New dry_run=true mode in the helper publishes the would-be-appended count via GITIGNORE_MERGE_APPENDED so --dry-run still surfaces the diff. A BASH_SOURCE guard at the bottom of ralph_upgrade_project.sh makes its functions sourceable from tests without running main().

User-added .gitignore entries above and below the Ralph block are preserved byte-for-byte across both install and upgrade. Second run is a no-op (sha256 stable).

Test plan

  • bats tests/unit/test_gitignore_merge.bats21 cases pass (12 from TAP-1882: fresh install, missing-line backfill, no-op re-run, user-content preservation, template-contract assertions; 9 from TAP-1883: dry-run mode, GITIGNORE_MERGE_APPENDED publishing, upgrade_gitignore on stale repo / current repo / missing target / user-content preservation / DRY_RUN paths)
  • bats tests/unit/test_enable_core.bats — 44 cases pass (existing .gitignore tests rewritten against the new helper, ENABLE-4 marker-simulation tests rewritten to call merge_gitignore_block directly)
  • Full unit suite: 1772 tests pass (was 1763 before the epic, +9 new)
  • Smoke test against ralph_upgrade_project.sh: stale repo with node_modules/ + .ralph/.call_count → 24 entries merged on first run, "already current" on second run, user node_modules/ line preserved at top byte-for-byte
  • Operator validation: run ralph-upgrade-project --all --dry-run against a real consumer repo and confirm the "Would merge N missing Ralph entries" log line appears

🤖 Generated with Claude Code

wtthornton and others added 2 commits May 17, 2026 11:01
templates/.gitignore moves from a hand-maintained denylist (which has
already drifted 14 patterns behind what Ralph writes under .ralph/) to
`.ralph/*` plus `!` exceptions for the small known-good committed set
(PROMPT.md, AGENT.md, fix_plan.md, hooks/, .gitkeep). New state files
under .ralph/ are absorbed automatically — no template churn each time
a feature lands.

lib/enable_core.sh loses its duplicate hardcoded list and its
marker-skip merge. Both are replaced by merge_gitignore_block — a
top-level helper that reads canonical pattern lines straight from
templates/.gitignore and appends only those missing in the target via
`grep -qxF` (exact whole-line). The helper is the single source of
truth: it is reused by ralph_upgrade_project.sh in TAP-1883 (next
commit) so install-time and upgrade-time backfill share one code path.

User-added .gitignore entries above or below the Ralph block are
preserved byte-for-byte; second run is a no-op (sha256 stable).

Coverage: 12 new BATS cases in tests/unit/test_gitignore_merge.bats
(fresh install, old-denylist backfill, no-op re-run, user-content
preservation, missing-template error, get_templates_dir default,
template-contract assertions). Existing test_enable_core.bats merge
tests rewritten against the new helper.

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

Wire ralph_upgrade_project.sh's Tier-2 merge into the same
merge_gitignore_block helper TAP-1882 introduced. Running `ralph
upgrade` on a stale consumer repo (e.g. tapps-brain pre-ba09360 with
the 14-pattern leak) now backfills the missing entries automatically —
no more hand-patching per repo as new state files land.

merge_gitignore_block gains a dry_run="true" mode that publishes the
would-be-appended count via GITIGNORE_MERGE_APPENDED without writing,
so DRY_RUN=true in the upgrader still surfaces the operator-visible
"would merge N lines" / "already current" diff.

upgrade_gitignore lives in ralph_upgrade_project.sh and lazily sources
lib/enable_core.sh on first call. Idempotent — second run is a no-op.
User-added entries before/after the Ralph block are preserved
byte-for-byte; backups go through the existing create_backup helper.
Honors --dry-run, fresh-project (no .gitignore) is created from template.

ralph_upgrade_project.sh gets a `BASH_SOURCE` guard at the bottom so
its functions are now sourceable from tests without running main() —
the pattern matches every other script in the repo and was the only
thing blocking realistic upgrade smoke tests.

Coverage: 9 new BATS cases in tests/unit/test_gitignore_merge.bats
(dry-run mode, GITIGNORE_MERGE_APPENDED publishing, upgrade_gitignore
on stale repo / current repo / missing target / user-content
preservation / DRY_RUN paths). Full unit suite remains green at 1772
tests (was 1763 before TAP-1882+1883).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wtthornton wtthornton merged commit ed681c9 into main May 17, 2026
5 checks passed
@wtthornton wtthornton deleted the tap-1881-gitignore-allowlist-epic branch May 17, 2026 18:49
wtthornton added a commit that referenced this pull request May 17, 2026
… BETA, branch hygiene)

Bumps RALPH_VERSION + package.json to 2.15.2. CHANGELOG entry covers
the seven tickets shipped via PRs #22, #23, #24:

* TAP-1881 / TAP-1882 / TAP-1883 — .gitignore allowlist + idempotent
  upgrade backfill, single source-of-truth helper, 14-pattern leak
  fix originating from TAP-1682 (Fixed)
* TAP-1988 — Tool Search BETA opt-in via ANTHROPIC_BETA header (Added)
* TAP-1878 / TAP-1879 / TAP-1880 — branch hygiene epic (prompt-side
  delete + harness-side janitor with git cherry detection) (Added)

Unit suite: 1751 → 1778 cases (+27) across 4 new BATS files.
All green; full suite still 100% pass.

Real-world post-merge validation of the new janitor (TAP-1880):
deleted 2 stale tap-1838-* branches in this repo on first run with
no manual intervention.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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