Repository navigation
feat(create): fork-to-own agent creation + brain-orb git-sync exemptions (trinity-enterprise#93, #76) - #1490
Merged
Merged
Conversation
2 tasks done
AndriiPasternak31
self-requested a review
July 6, 2026 16:23
AndriiPasternak31
approved these changes
Jul 6, 2026
AndriiPasternak31
enabled auto-merge
July 6, 2026 16:23
…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]>
… user's own repo (trinity-enterprise#93) Templates declaring `fork_to_own: required` in template.yaml are copied at creation into a repo the USER owns (private by default): the user's PAT creates the destination, pushes the template's default branch with full history, and persists as the per-agent PAT (#347) so recreates never fall back to the platform PAT. Origin points at the user's repo — captures, operator Push, and the 15-min auto-sync (enabled for fork agents even in source mode) all land there, never in the shared upstream template. `GIT_UPSTREAM_REPO` + a credential-less `upstream` remote keep template updates one `git pull upstream` away. Cornelius is the first user; the mechanism is template-generic. - models: ForkToOwnRequest (SecretStr PAT, anchored destination regex, private-by-default) on AgentConfig - fork_to_own.py orchestrator: create/reuse/refuse destination semantics (empty or template-tip SHA-match → reuse; else 409), REST + git-plane readiness polls, auth via GIT_CONFIG_* env (token never on argv/URL), scrub_secret on all output, staging under /data (backend /tmp is tmpfs) - crud: fork block before the docker try (structured FORK_* errors survive); PAT persist inside it (rollback covers); destination-binding guard re-checked post-reservation (source-mode rows bypass the UNIQUE index) — concurrent losers roll back deterministically; 409 names the bound agent only when the caller can access it (#186) - frontend: featured cards for fork_to_own templates, destination/PAT/ visibility fields, loud public-repo warning, fine-grained-token guidance - tests: 40 new (model, orchestrator, crud gates, deep-slice env/PAT persistence/rollback, race, facade delegation, startup.sh) /review: 2 critical findings fixed (missing DatabaseManager delegation; binding-guard TOCTOU). /cso --diff: clean, 1 Low accepted-risk remediated in UI copy (docs/security-reports/cso-2026-07-06.md). Part of abilityai/trinity-enterprise#93 Co-Authored-By: Claude Fable 5 <[email protected]>
vybe
force-pushed
the
feature/93-fork-to-own
branch
from
July 6, 2026 16:30
1e2ca7a to
fc0e904
Compare
| ) | ||
| if rc != 0: | ||
| logger.error("fork-to-own: template clone failed for %s: %s", | ||
| template_repo, scrub_secret(out, read_pat)) |
| timeout=PUSH_TIMEOUT_S, auth_pat=user_pat, | ||
| ) | ||
| if rc != 0: | ||
| logger.error("fork-to-own: push to %s failed: %s", destination_repo, out) |
AndriiPasternak31
added a commit
that referenced
this pull request
Jul 6, 2026
…#1490) PR #1490 (fork-to-own) merged test_fork_to_own.py with three bare `del sys.modules['services.*']` and no baseline entry, reddening the `sys.modules pollution` lint on dev's tip — every open PR inherits it via the merge-ref. This PR rebased onto that tip, so fold in the fix rather than block on it. Add the linter's blessed snapshot/restore exemption pair (top-level `_STUBBED_MODULE_NAMES` + autouse `_restore_sys_modules`, precedent tests/unit/test_telegram_webhook_backfill.py): snapshot the services.*/database sys.modules subtrees before each test and restore after, so the dynamic per-test purges can't leak across the session. Behavior-preserving — the file's 40 tests still pass; the lint now treats the file as exempt (0 findings). Co-Authored-By: Claude Opus 4.8 <[email protected]>
AndriiPasternak31
added a commit
that referenced
this pull request
Jul 6, 2026
…wn (#1490) PR #1490 (fork-to-own) merged tests/unit/test_fork_to_own.py with three raw `del sys.modules['services.*']` and no baseline entry, reddening the sys.modules pollution lint on dev's tip — every open PR inherits it via the merge-ref. This PR rebased onto that tip, so record the three pre-existing violations in the lint baseline to restore green. Deliberately a baseline entry, NOT a code change: an autouse snapshot/restore fixture (the lint's other sanctioned remedy) was tried first but re-adds modules a test deliberately deletes, which broke test_owner_mismatch_forbidden under full-suite ordering (regression-diff flagged it as a new HEAD failure). Baselining touches zero test behavior and is the lint's explicit escape hatch for accepted pre-existing debt. Properly draining these three to monkeypatch.delitem is a #1490-owned follow-up for that file's author. Co-Authored-By: Claude Opus 4.8 <[email protected]>
vybe
pushed a commit
that referenced
this pull request
Jul 7, 2026
… as prod build args (#1489) (#1492) * fix(frontend): plumb VITE_BUG_REPORTING_ENABLED / VITE_BUG_INTAKE_URL as prod build args HelpChatWidget (#1116) reads two build-time knobs to disable in-app bug reporting or repoint it off the hosted intake, but the prod build path never passed them. Vite inlines import.meta.env.* at build time, so an operator setting VITE_BUG_REPORTING_ENABLED=false in .env had no effect — every prod build shipped with reporting on, pointed at intake.abilityai.dev, with no supported off switch. Copy the existing VITE_API_URL plumbing verbatim: two ARG+ENV in Dockerfile.prod (before npm run build), two build.args in docker-compose.prod.yml, keeping compose default == ARG default == code default so an unset .env byte-reproduces today. Document both in .env.example with prod-only, no-secrets, and CSP-caveat warnings. Repoint path is CSP-blocked (connect-src hard-codes the intake host in both security-headers.conf and vite.config.js); disable path works end-to-end. CSP parameterization for a working self-host repoint is an umbrella #1485 follow-up. Fixes #1489 Refs #1485 Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(#1489): static guards for VITE_BUG_* prod build-arg plumbing Pure static tests (no Docker, no backend — mirroring test_858_dockerfile_unbuffered.py) over the prod frontend build path: Dockerfile.prod declares both ARG + ENV ${VAR} pass-throughs before `RUN npm run build`, docker-compose.prod.yml forwards both via ${VAR:-default} build.args, and the three defaulting layers agree (Dockerfile ARG == compose default == HelpChatWidget code default) so an unset .env byte-reproduces today's behavior. Scoped to #1489; the general VITE_* parity guard is a deferred #1485 follow-up. Refs #1489, #1485 Co-Authored-By: Claude Opus 4.8 <[email protected]> * docs(feature-flows): note prod build-arg plumbing for VITE_BUG_* knobs (#1489) Update the in-app-bug-reporting flow's Config-knobs bullet to record that the #1116 build-time knobs are Vite build args (not runtime env) and are now plumbed through docker/frontend/Dockerfile.prod + docker-compose.prod.yml with three-layer default agreement; expand the CSP bullet with the repoint caveat. Add a Recent Updates index row. Refs #1489, #1485 Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(test): sync dependencies + models stubs in test_login_rate_limit_split with auth.py Pre-existing dev-baseline failure (8 fixture errors, deterministic in isolation), surfaced here because #1492's lint fix unmasks it in CI ordering. routers/auth.py grew its imports over time but the fake-module stubs in this test drifted: - `from dependencies import (...)` gained get_current_user / is_token_revoked / oauth2_scheme / revoke_token_jti via the #187 JWT-revocation/logout work; the stub defined only authenticate_user + create_access_token. - `from models import User` (a Depends(get_current_user) param annotation on the #187 logout endpoint) was added; the models stub defined only Token. `from dependencies import (...)` / `from models import (...)` resolve every name at import time, so a missing stub attr errors the whole file at fixture setup. Add the four dependencies stubs + the User stub (bare lambdas / a bare class — none are exercised by the rate-limit paths under test). 8 errors -> 8 passed. Co-Authored-By: Claude Opus 4.8 <[email protected]> * chore(lint): baseline pre-existing sys.modules debt in test_fork_to_own (#1490) PR #1490 (fork-to-own) merged tests/unit/test_fork_to_own.py with three raw `del sys.modules['services.*']` and no baseline entry, reddening the sys.modules pollution lint on dev's tip — every open PR inherits it via the merge-ref. This PR rebased onto that tip, so record the three pre-existing violations in the lint baseline to restore green. Deliberately a baseline entry, NOT a code change: an autouse snapshot/restore fixture (the lint's other sanctioned remedy) was tried first but re-adds modules a test deliberately deletes, which broke test_owner_mismatch_forbidden under full-suite ordering (regression-diff flagged it as a new HEAD failure). Baselining touches zero test behavior and is the lint's explicit escape hatch for accepted pre-existing debt. Properly draining these three to monkeypatch.delitem is a #1490-owned follow-up for that file's author. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidated PR carrying two tasks (supersedes #1479, closed unmerged — its commits are the base of this branch):
Task 1 — Git-sync exemptions for Brain-Orb template files (trinity-enterprise#76)
.trinity/brain-orb/{scopes,scope,search,action}hooks and.trinity/setup.sh. The fleet gitignore migration (_migrate_workspace_gitignore, run on every operator Push) used to untrack them and push their deletion, so a re-clone/recreate booted hookless._build_rm_cached_ignored_commandnow pathspec-exempts.trinity/brain-orband.trinity/setup.shfrom both the emptiness probe and the removal pipe; sibling.trinity/runtime files are still swept..trinity/*star form (the only shape a template can commit re-included hooks under) so the compat panel doesn't flag Brain-Orb templates.test_github_init_gitignore.py(real-git regression),test_compatibility_checks.py(S-005 star form). Live-validated in the Configurable MCP Server URL in Admin Settings #76 e2e (cornelius-e2e).Task 2 — Fork-to-own agent creation (trinity-enterprise#93)
fork_to_own: requiredintemplate.yamlget a featured card in Create Agent and are copied at creation into a repo the user owns — private by default, created + pushed with the user's PAT, which then persists as the per-agent PAT (feat: Per-agent GitHub PAT configuration #347) so recreates never fall back to the platform PAT.GIT_UPSTREAM_REPO+ a credential-lessupstreamremote keep template updates onegit pull upstream mainaway.Hardening (from /autoplan reviews + /review + /cso --diff)
GIT_CONFIG_*env (http.extraHeader) — token never on argv or in URLs; all git output scrubbed (plain + b64)FORK_*errors reach the UI); PAT persist runs inside it (rollback deletes the reserved row + MCP key)/data/agent-fork-tmp(backend/tmpis a 100 MB tmpfs)/review: 2 criticals found & fixed (missingDatabaseManagerfacade delegation — learning captured; binding-guard TOCTOU)./cso --diff: clean; 1 Low accepted-risk (account-scoped PAT blast radius) remediated in UI guidance — report atdocs/security-reports/cso-2026-07-06.mdDeliberate scope decisions
create_agentdoes not acceptfork_to_own— MCP tool args are audit-logged; a PAT arg would persist in plaintext.fork_to_own: requiredenforcement is fail-open on a template.yaml metadata-fetch failure (advisory gate; documented).Release step (cross-repo)
The featured Cornelius card appears once
Abilityai/corneliustemplate.yamladdsfork_to_own: required+tagline(canonical internal repo → /sync-to-public). Until then Cornelius creation behaves as today.Test Plan
pytest tests/unit/test_fork_to_own.py— 40 passed (model validation, orchestrator collision/scrub/timeout, crud gates, deep-slice env + PAT persistence + rollback, destination race, facade delegation, startup.sh static)pytest tests/unit/test_github_init_gitignore.py tests/unit/test_compatibility_checks.py— task-1 suites greenfork_to_own: requiredtemplate → destination repo created private → agent booted,origin=user repo /upstream=template → per-agent PATsource: "agent"→ capture synced → commit landed in the user's repo, template untouchedPart of abilityai/trinity-enterprise#93 and abilityai/trinity-enterprise#76 (closed manually at release — cross-repo keywords don't auto-close)
🤖 Generated with Claude Code