Skip to content

fix(git-sync): exempt template-committed .trinity convention files from the gitignore untrack sweep (trinity-enterprise#76) - #1479

Closed
vybe wants to merge 2 commits into
devfrom
feature/76-brain-orb-template
Closed

vybe wants to merge 2 commits into
devfrom
feature/76-brain-orb-template

Conversation

@vybe

@vybe vybe commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Brain-Orb-capable templates (e.g. github:Abilityai/cornelius) COMMIT their convention files — the .trinity/brain-orb/{scopes,scope,search,action} hooks and .trinity/setup.sh. The fleet gitignore migration (_migrate_workspace_gitignore, run on every operator Push) appends the fleet-wide .trinity/ ignore and then git rm --cacheds ignored-but-tracked files — untracking those files and pushing their deletion, so a later re-clone/recreate boots hookless and never runs startup setup.
  • _build_rm_cached_ignored_command now pathspec-exempts .trinity/brain-orb and .trinity/setup.sh from both the emptiness probe and the removal pipe; sibling .trinity/ runtime files are still swept.
  • Compatibility check S-005 additionally accepts the .trinity/* star form — the only shape a template can commit re-included hooks under (git cannot re-include beneath a dir-form exclusion) — so the compat panel doesn't flag Brain-Orb templates and its auto-fix doesn't churn.

Changes

  • src/backend/services/git_service.py — sweep exemptions (probe + removal pipe)
  • src/backend/services/compatibility/static_checks.py — S-005 accepts .trinity/*
  • tests/unit/test_github_init_gitignore.py — real-git regression test (hooks + setup.sh survive the merge+sweep; sibling state still swept; working tree untouched)
  • tests/unit/test_compatibility_checks.py — S-005 star-form snapshot test

Test Plan

  • pytest tests/unit/test_github_init_gitignore.py tests/unit/test_compatibility_checks.py — 43 passed
  • Live e2e: created cornelius-e2e from github:Abilityai/cornelius, ran an operator Push through this backend — all 6 hook files + setup.sh stayed tracked, the vault capture committed, non-exempt .trinity/ state was swept. (The pre-fix backend reproduced the bug: the first Push deleted setup.sh — caught live, second exemption added.)

Part of abilityai/trinity-enterprise#76 (Brain Orb full cycle from the public cornelius template — agent-side kit shipped in Abilityai/cornelius@1ce85bd).

🤖 Generated with Claude Code

Eugene Vyborov and others added 2 commits July 6, 2026 14:04
…rack sweep (trinity-enterprise#76)

Brain-Orb-capable templates COMMIT their convention hooks under
.trinity/brain-orb/ (scopes/scope/search/action). The fleet gitignore
migration appends `.trinity/` on every push and then `git rm --cached`s
ignored-but-tracked files — which untracked the hooks and pushed their
deletion, so any later re-clone/recreate booted hookless.

- _build_rm_cached_ignored_command: pathspec-exempt `.trinity/brain-orb`
  from both the emptiness probe and the removal pipe; sibling .trinity/
  files are still swept.
- compatibility S-005: accept the `.trinity/*` star form (the only shape
  a template can commit re-included hooks under — git cannot re-include
  beneath a dir-form exclusion) as satisfying the ignore intent, so the
  compat panel doesn't flag Brain-Orb templates and its auto-fix doesn't
  churn.
- Regression tests for both (real git repo + snapshot check).

Co-Authored-By: Claude Fable 5 <[email protected]>
…trinity-enterprise#76)

Caught by the live e2e Push: the fleet .trinity/ append made the template's
committed setup.sh ignored-but-tracked and the sweep untracked it — a re-clone
of the synced agent repo would never run its startup setup (Brain Orb seed
copy + hook chmod). Same class as the brain-orb hook deletion; same fix.

Co-Authored-By: Claude Fable 5 <[email protected]>

@dolho dolho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — approve-with-a-question. Solid, surgical fix with an excellent real-git regression test; I reproduced one sibling of the same bug that isn't covered.

I ran the branch's actual _build_gitignore_merge_command + _build_rm_cached_ignored_command output against a real git repo mirroring the scenario (plus a .trinity/pre-check file):

BEFORE:  brain-orb/action, brain-orb/scopes, pre-check, runtime-state.yaml, setup.sh   (tracked)
AFTER merge+sweep:  brain-orb/action, brain-orb/scopes, setup.sh   ✅ survive
                    runtime-state.yaml   ✅ swept (correct)
                    .trinity/pre-check   ❌ SWEPT

What's right

  • Root cause is correct: the fleet merge appends dir-form .trinity/, which defeats the template's !.trinity/brain-orb/ re-include → hooks become ignored-but-tracked → the git rm --cached sweep untracks them. The pathspec exemption is the correct, surgical compensation, applied to both the probe and the removal pipe (consistent), with a positive -- . pathspec so the :! excludes have something to subtract. No injection risk (hardcoded constants, git_dir is shlex.quoted).
  • S-005 change is correct and complete for the shapes in play.
  • Tests are excellent — real git, asserts survival AND that siblings are still swept AND the working tree is untouched; the live e2e actually caught the setup.sh case.

The one substantive point (see inline): .trinity/pre-check (SCHED-COND-001 / #454 — a documented template-committed convention hook) hits the identical bug and isn't exempted. Fine to scope this PR to #76 and file a follow-up, but it shouldn't be left silent since a template that ships pre-check will have it untracked on the first Push.

Nit: commit.gpgsign false in the test is fine (throwaway repo), just noting it's local-repo config.

hookless and never runs its startup setup (verified live: the e2e Push
swept setup.sh before the second exemption was added).
"""
exempt = '":!.trinity/brain-orb" ":!.trinity/setup.sh"'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified (real git): .trinity/pre-check — a documented template-committed convention hook (SCHED-COND-001, #454) — is swept by this same pipe because it isn't in the exempt set, so a template shipping it re-hits exactly the bug this PR fixes (untracked on first Push → re-clone boots without it).

Two options: add .trinity/pre-check here now, or scope this PR to #76 and file a follow-up for the general class.

Nit while here: this exempt list will grow one path at a time. Promoting it to a named module constant (e.g. _TEMPLATE_COMMITTED_TRINITY_PATHS) makes adding pre-check a one-liner and self-documents the growing allowlist.

@vybe

vybe commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1490 — the fork-to-own branch was stacked on this one, so #1490 now carries both tasks (trinity-enterprise#76 git-sync exemptions + trinity-enterprise#93 fork-to-own) as one PR against dev. Closing unmerged; commits eed834e + 9117024 live on in feature/93-fork-to-own.

@vybe vybe closed this Jul 6, 2026
@vybe
vybe deleted the feature/76-brain-orb-template branch July 6, 2026 16:03
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.

2 participants