Repository navigation
fix(git): ignore .trinity/ contents-only so template-committed hooks survive a Push (#2070) - #2078
Conversation
…survive a Push (#2070) Every backend Push runs `git rm --cached` over tracked-but-now-ignored files. The fleet-wide list ignored `.trinity/` WHOLESALE, so anything a template legitimately commits there was untracked and its deletion pushed. The only protection was a hardcoded two-entry pathspec exemption — and it has now been wrong three times, with the function's own docstring recording the first two: 1. .trinity/brain-orb/ (trinity-enterprise#76) 2. .trinity/setup.sh ("verified live: the e2e Push swept setup.sh before the second exemption was added") 3. .trinity/pre-check (this issue) `pre-check` is the SCHED-COND-001 hook (#454) that architecture.md, requirements/scheduling.md, agent-validation-spec.md (A-004) and the agent guide all tell template authors to commit. The platform was deleting a file it documents as authored content. The failure is silent and delayed. Only the index is touched, so the working tree keeps running; it surfaces at the next re-clone or container recreate, which boots with no hook — and every cron tick then runs a full LLM turn instead of skipping, reintroducing exactly the cost SCHED-COND-001 exists to remove, on a poll-driven agent, with no error anywhere. Inverted rather than extended. Adding `":!.trinity/pre-check"` would have been a fourth instance of the pattern that produced the issue, and does nothing for `pipelines/`. Now: .trinity/* <- contents-only, so negations below it apply !.trinity/pre-check <- _TRINITY_AUTHORED_PATHS, one entry per !.trinity/post-check authored path (pre/post-check, pre-snapshot, !.trinity/pre-snapshot setup.sh, persistent-processes.allow, !.trinity/setup.sh brain-orb/, pipelines/) ... so the DEFAULT under `.trinity/` is ignored — a new runtime file needs no action — while authored content is tracked by construction. The `rm --cached` exemptions are DERIVED from the same constant, so adding an authored path is one edit instead of two and the two cannot drift. The dir-form is not merely untidy: git never descends into a directory excluded by `.trinity/`, so re-includes beneath it are inert. Every agent synced before this change carries that exact line — precisely the fleet this fixes — so the merge now REMOVES it before appending, by exact whole-line match (`grep -vxF`, the same discipline as the G-001 auto-fix). A user rule that merely mentions the directory (`.trinity/scratch/`, `!.trinity/mine`) does not match and is untouched. Coupled surfaces moved in the same change, as the AC requires: the guide's gitignore fence (test_doc_and_constant_in_sync), the S-005 check (star form is now canonical; the dir-forms stay ACCEPTED because they do exclude the runtime state the check grades, and the merge repairs them anyway), the S-005 auto-fix patterns (re-adding the wholesale line would have re-broken this), c_g002 (follows the constant), the validation spec, architecture.md, and all 16 bundled template .gitignore files. Verified in a REAL agent container (trinity-agent-base), starting from the pre-#2070 `.gitignore` every live agent has: old commands: tracked after sweep -> .trinity/setup.sh only (pre-check and pipelines/r.yaml untracked — the bug) new commands: tracked after sweep -> pre-check, setup.sh, pipelines/r.yaml runtime (operator-queue.json, pipeline-state/) untracked .gitignore migrated to the star form fresh `git clone` of the result: hook present, runs, prints "skip" 25 tests over real git repos, asserting the split rather than today's exemption strings. Mutation-verified: wholesale ignore restored -> 5 failed; hardcoded two-entry exemptions -> 1 failed; stale-line migration removed -> 2 failed; pre-check dropped from the authored set -> 4 failed. Related to #2070 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vybe
left a comment
There was a problem hiding this comment.
Validated via /validate-pr. All 19 checks green. Inverting the rule (.trinity/* + derived re-includes) is the right fix rather than a fourth exemption string, and deriving the rm --cached pathspec from the same constant removes the drift that caused all three recurrences. Verified locally: merges conflict-free on top of #2077 and the combined tree passes pytest tests/unit -k "git or compat" (594 passed, 8 skipped) plus all 25 new tests.
Non-blocking nit for a follow-up: in _build_gitignore_merge_command, grep -vxF ... > .gitignore.tmp || true swallows grep's exit 2 (real error) as well as exit 1 (no lines selected), so a genuine read failure mid-filter would mv a truncated file over the user's .gitignore. || [ $? -eq 1 ] would narrow it to the intended case.
Fixes #2070
Problem
Every backend Push runs
git rm --cachedover tracked-but-now-ignored files. The fleet-wide list ignored.trinity/wholesale, so anything a template legitimately commits there was untracked and its deletion pushed. The only protection was a hardcoded two-entry pathspec — wrong three times now, the first two recorded in the function's own docstring:.trinity/brain-orb/(trinity-enterprise#76).trinity/setup.sh— "verified live: the e2e Push swept setup.sh before the second exemption was added".trinity/pre-check— this issuepre-checkis the SCHED-COND-001 hook (#454) thatarchitecture.md,requirements/scheduling.md,agent-validation-spec.md(A-004) and the agent guide all tell template authors to commit. The platform documents a file as authored content and then deletes it.Silent and delayed: only the index is touched, so the working tree keeps running. It surfaces at the next re-clone or container recreate, which boots with no hook — and every cron tick then runs a full LLM turn instead of skipping, reintroducing exactly the cost SCHED-COND-001 exists to remove, with no error anywhere.
Fix — inverted, not extended
Appending
":!.trinity/pre-check"would be a fourth instance of the pattern that produced this issue, and does nothing forpipelines/.The default under
.trinity/is now ignored — a new runtime file needs no action — while authored content is tracked by construction. Therm --cachedexemptions are derived from the same constant, so adding an authored path is one edit instead of two and the two cannot drift.The dir-form is load-bearing, not cosmetic: git never descends into a directory excluded by
.trinity/, so re-includes beneath it are inert. Every agent synced before this change carries that exact line — precisely the fleet this fixes — so the merge now removes it before appending, by exact whole-line match (grep -vxF, the discipline the G-001 auto-fix already uses). A user rule that merely mentions the directory (.trinity/scratch/,!.trinity/mine) doesn't match and is left alone.Verified in a real agent container
trinity-agent-base, starting from the pre-#2070.gitignoreevery live agent has:Coupled surfaces, moved in the same change
Per the AC: the guide's gitignore fence (
test_doc_and_constant_in_sync), S-005 (star form is now canonical; the dir-forms stay accepted — they do exclude the runtime state the check grades, and the merge repairs them anyway, so failing them would report a problem the platform fixes itself), the S-005 auto-fix patterns (re-adding the wholesale line would have re-broken this), c_g002 (follows the constant automatically), the validation spec,architecture.md, and all 16 bundled template.gitignorefiles.Tests
tests/unit/test_2070_trinity_authored_paths.py— 25 tests running the real command builders against real git repos (the defect is in git's own descend/negation semantics, which a mocked container can't express). They assert the split, never today's exemption strings, so a fourth forgotten path fails here rather than shipping:.trinityare preserved; the merge is idempotent_TRINITY_AUTHORED_PATHS; a newly-invented runtime file needs no action🤖 Generated with Claude Code