chore(security): untrack docs.local and guard against re-adding it - #40
Conversation
docs.local/convex-auth-patterns.md was tracked and published in this public repo. The content is generic Convex auth documentation with no secrets, and it is the only path that has ever existed under docs.local in this repo's history, so no history rewrite is needed. .gitignore alone does not hold: `git add -f` overrides it, and once a path is tracked .gitignore no longer applies to it. On voicelayer that gap published dictation transcripts and personal-data screenshots and forced a full history rewrite plus repo rebuild on 2026-09-01. Adds scripts/guard-no-docslocal.sh, wired into the husky pre-commit hook and a CI job, so a tracked docs.local path cannot come back. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoPrevent docs.local files from being tracked
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1. Guard utility lacks tests
|
| tracked="$(git ls-files -- 'docs.local' 'docs.local/**' 2>/dev/null || true)" | ||
|
|
||
| if [ -z "$tracked" ]; then | ||
| echo "docs.local guard: OK — 0 tracked paths" | ||
| exit 0 |
There was a problem hiding this comment.
1. Guard utility lacks tests 📘 Rule violation ☼ Reliability
The new guard-no-docslocal.sh utility has no corresponding automated test covering its clean and blocked outcomes. Regressions in the repository-protection logic could therefore pass unnoticed.
Agent Prompt
## Issue description
The new `guard-no-docslocal.sh` utility lacks an automated unit test.
## Issue Context
Add a Vitest test that runs the script against temporary Git repositories and verifies both exit paths: success when `docs.local` is untracked and failure when a path beneath it is tracked.
## Fix Focus Areas
- scripts/guard-no-docslocal.sh[19-24]
- src/utils/guard-no-docslocal.test.ts[1-1]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Fixed in 7d27208 — added `src/tests/guard-no-docslocal.test.ts` (Vitest, throwaway git repos via `mkdtemp`), covering both branches you cited plus two more:
- nothing tracked → exit 0
- `git add -f docs.local/leaked.md` → exit 1, offending path listed
- untracked again → exit 0, and the file is still on disk (the untrack must not delete local data)
- the pre-commit hook invokes `bash`, not `sh` — regression test for the dash bug in the sibling thread
4 tests, green; full suite 203 passed, tsc clean.
Two findings from the review on #40. 1. BUG — the hook ran `sh scripts/guard-no-docslocal.sh`. The guard uses `set -o pipefail`, which POSIX shells reject. On Ubuntu/Debian /bin/sh is dash, so the guard aborted with "Illegal option -o pipefail" and, via `|| exit 1`, rejected EVERY commit — even with nothing tracked. Reproduced locally: `dash scripts/guard-no-docslocal.sh` exits 2. macOS hid it because /bin/sh there is bash 3.2 in POSIX mode. 2. RULE VIOLATION — new helpers need unit tests (CLAUDE.md). Adds src/__tests__/guard-no-docslocal.test.ts covering both exit paths against throwaway git repos: - nothing tracked -> exit 0 - `git add -f` a docs.local path -> exit 1, path listed - untracked again -> exit 0, file still on disk - hook invokes bash, not sh -> regression test for finding 1 Verified the regression test actually catches it: reverting the hook to `sh` turns that test red, restoring `bash` turns it green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Why
docs.local/convex-auth-patterns.mdis tracked and published in this public repo..gitignoredid not stop it —git add -foverrides.gitignore, and once a path is tracked.gitignoreno longer applies to it at all.On voicelayer that same gap published verbatim dictation transcripts and personal-data screenshots, and forced a full history rewrite plus a repo rebuild on 2026-09-01. This closes the gap here.
No history rewrite needed — verified
returns exactly one path across all refs:
docs.local/convex-auth-patterns.md. Contents reviewed — generic Convex authentication guidance (usectx.auth.getUserIdentity(), never take a user id as an argument). No secrets, no personal data. The blob can stay in history safely.READ BEFORE YOU MERGE — this deletes the file in other checkouts
git rm --cachedkeeps the file only in the worktree that ran it. Every other checkout that pulls this merge gets the path DELETED from its working tree. Normal git, recoverable, but it looks like data loss.Backup already taken outside git (926 files, verified):
If a checkout loses it after pulling:
After merging, check every checkout (
git worktree list) — there is a second one at~/.config/superpowers/worktrees/songscript/auth-fixes. Single-worktree green is false green.The guard
scripts/guard-no-docslocal.shexits 1 ifgit ls-files docs.localis non-empty. Wired into:.husky/pre-commitdocs.local guardCI workflow, so a PR is blocked even where the local hook is unwiredPre-commit on this branch ran clean: 199 tests passed, tsc clean, guard exit 0.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Note
Untrack
docs.local/files and add guard to prevent re-adding themgit ls-filesto detect trackeddocs.local/paths and exits 1 with remediation instructions when any are found.bash(notsh) due topipefailusage.git rm --cachedscenarios, plus an assertion that the pre-commit hook usesbash.docs.local/path will be blocked by both the pre-commit hook and CI; reviewers should ensure the guard script remains executable and the workflow runs on the intended branches.Macroscope summarized 7d27208.