Repository navigation
feat(github): agent containers fetch a repo-scoped git token at use time (abilityai/trinity-enterprise#1278) - #4653
Open
obasilakis wants to merge 3 commits into
Open
obasilakis wants to merge 3 commits into
obasilakis wants to merge 3 commits into
Conversation
…ime (Abilityai/trinity-enterprise#1278) When a registered repo-token provider covers an agent's repo, the agent's container is started with TRINITY_GIT_TOKEN_BROKER=1 and no baked GITHUB_PAT, GH_TOKEN or GITHUB_TOKEN. With no provider registered nothing changes. - github_token_provider: coverage() answers True, False or None (the provider could not answer within 5 seconds). wants_broker() is the one mode decision shared by agent creation, the recreate matcher and the recreate env writer. The flag stands only where the platform PAT would have been baked; a per-agent PAT outranks the provider; unknown coverage keeps the mode a container has. - GET /api/agents/{name}/git/token: the agent's own key only. 200 with a provider token for a broker-mode container, 204 otherwise, 503 when the mint failed or the container cannot be read. Never returns a PAT. Added to the own-runtime route allowlist. - git-credential-trinity (and its backend mirror): with the flag set, asks the route first, key on stdin. 204 continues to the PAT sources; any other failure yields no credential and skips them. - gh wrapper at /usr/local/bin/gh: fetches a token through the helper on every gh call in broker mode. This replaces the spawn-time GH_TOKEN fetch the issue described, so a turn longer than an hour never holds an expired token. - startup.sh: the flag counts as a resolving credential without a network call, and stale GitHub token lines are removed from the workspace .env. - PAT rotation skips broker containers; the harvest file refuses ghs_ tokens. Tests: tests/unit/test_ent1278_git_token_broker.py runs the real helper, wrapper and startup.sh blocks against a local HTTP server. Fifteen mutations each turn a named test red. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…token-fetch # Conflicts: # tests/registry.json
…Abilityai/trinity-enterprise#1278) Declares the route's tier as "self" in agent_route_tiers.json, gives the self-gate identity test a request for it, and spells the agents-only refusal the way the other agent-only routes do, so the hand-copied self-gate guard recognises it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Resolve by running |
|
Resolve by merging |
This branch has not been deployed
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.
Summary
Implements the open-core half of abilityai/trinity-enterprise#1278, on top of the repo-token seam from #4624.
When a registered repo-token provider covers an agent's repo, the agent's container starts with
TRINITY_GIT_TOKEN_BROKER=1and no bakedGITHUB_PAT,GH_TOKENorGITHUB_TOKEN. It fetches a short-lived, repo-scoped token from the backend on each git orghoperation. With no provider registered, nothing changes.Changes
services/github_token_provider.py):coverage(repo)answers True, False, or None when the provider cannot answer within 5 seconds.wants_broker(...)is shared by agent creation, the recreate matcher and the recreate env writer.GET /api/agents/{name}/git/token: the agent's own key only. 200 with a provider token for a broker-mode container, 204 otherwise, 503 when the mint failed or the container cannot be read. It never returns a PAT. Added to the own-runtime route allowlist so ephemeral agents and agents owned by Workspace-only people can reach it.git-credential-trinity.shand its backend mirror): with the flag set it asks the route first, sending the key tocurlon stdin. 204 continues to the PAT sources. Any other failure yields no credential and skips them.ghwrapper (/usr/local/bin/gh): in broker mode it gets a token through the helper on everyghcall.startup.sh: the flag counts as a resolving credential without a network call, and GitHub token lines are removed from the workspace.envin broker mode.ghs_tokens.Difference from the issue text
The issue describes a
GH_TOKENfetch at spawn inexecution_env.pyandplugins_reinstall.py, with a documented limit that a turn longer than one hour holds an expired token. Theghwrapper replaces both: the token is fetched perghcall, so that limit does not exist. Those two files are unchanged.Known limits
ghcalls against other repos lose the access the platform PAT gave them.Testing
tests/unit/test_ent1278_git_token_broker.pyruns the real helper script,ghwrapper andstartup.shblocks against a local HTTP server, and covers the mode decision, the matcher, the route and the rotation skip.tests/unit/test_ent109_git_env_seam.py::TestBrokerModecovers the env writer..envlines kept, and others) each turn a named test red.Private half (integration test against the real provider, feature-flow doc): branch
feature/1278-agent-token-fetchin the enterprise repo.🤖 Generated with Claude Code