Implement trusted agent forge identity and guidance #520
Reference in New Issue
Block a user
Delete Branch "feat/trusted-agent-forge-identity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements PRD prd-new-trusted-agent-forge-identity (added in #480). Stacked on
prd-forge-subroles— review/merge #480 first.Moves author identity and named forge configurations onto the host-only trusted agent definition, and lets a bottle repo optionally associate a git-gate repo with one of the agent's forge aliases — giving the agent proxy-authenticated forge API access (token never enters the bottle) plus generated workflow guidance.
What's implemented (per PRD implementation chunks)
$CWD/.bot-bottle/agentsno longer contributes, overrides, or is selectable — warned-and-ignored like cwd bottles. Enumeration, lazy load,require_agent, defaults, and the start selector are all home-only.author(name/email) andforge-accounts(alias → canonical Gitea/api/v1origin + hosttoken_secretref).git-gate.userremoved from agents and bottles (fail-closed with a migration pointer toauthor);git-gaterejected entirely on agents. New optional bottle-onlygit-gate.repos.<name>.forge, resolved against the selected agent's forge-accounts at composition (fail-closed on unknown alias). Fail-closed Gitea API URL validation (https only; no userinfo/query/fragment;/api/v1base; host lowercased; trailing slash normalized; origin dedup).token-authenticated egress route synthesized per referenced forge alias, scoped to the origin + API prefix. The token is resolved from the host env at launch into the egress proxy only — never the bottle env, prompt, gitconfig, or workspace.token_secretname.Testing
tests/unit/test_forge_identity.py(34 tests): author validation, Gitea URL canonicalization/fail-closed, repo→forge association, synthesized route shape + token-slot resolution + secret-absence in rendered routes, guidance rendering, and prompt append.git-gate.user/ cwd-agent tests updated to the agent-owned identity model.🤖 Generated with Claude Code
46fd97356ato2fafeef61c2fafeef61ctoba19012179Requesting changes for one credential-routing issue:
[P1] Reject conflicting forge credentials on the same routed host —
bot_bottle/egress/service.py:135-140egress_forge_routes()deduplicates referenced accounts only by hostname and silently discards every account after the first. The manifest permits two aliases for the same host (and even the same origin) with differenttoken_secretvalues. If repos reference both aliases, composition succeeds and guidance advertises both, but the generated proxy plan contains only the first credential; all API calls to that host are therefore authenticated as the first account. This breaks the per-agent/per-alias identity guarantee and can perform mutations as the wrong forge user. I reproduced it with two aliases onhttps://same.example/api/v1: associations containedFIRST_TOKENandSECOND_TOKEN, while the resolved token map contained onlyFIRST_TOKEN. Please fail closed when referenced aliases sharing a routable host disagree on origin/auth/token, or change the routing model so the intended credential can be selected unambiguously. Add a regression test with two aliases/tokens on the same host (the current dedup test covers only two repos sharing one alias).The focused manifest/forge/git-gate suite passes: 186 tests.
Thanks — fixed in
e53e078.[P1] Conflicting forge credentials on the same routed host — you're right,
egress_forge_routes()deduped by hostname and silently kept only the first account. Rather than pick a credential at route-synthesis time, I now fail closed at composition (resolve_forge_associations, before the bottle is created): when two referenced aliases resolve to the same host but disagree onorigin/auth/token_secret, it raisesManifestError("... both resolve to host '' ... the intended credential would be ambiguous"). Identicalurl/authunder two aliases still collapses to a single route. The host-dedup inegress_forge_routesnow only ever merges genuinely-identical credentials, and I noted that guarantee in its docstring.Added regression tests for both branches:
test_conflicting_aliases_same_host_fail_closed(two aliases / two tokens onhttps://same.example/api/v1→ raises) andtest_matching_aliases_same_host_ok(identical config → one route, correct token).forge.pystays at 100% line+branch coverage; pyright strict clean; focused manifest/forge/egress suite green.Re-reviewed at
e53e078. The prior credential-routing issue is resolved: referenced aliases sharing a proxy-routed host now fail closed when origin/auth/token_secret differ, while genuinely identical credentials remain safely deduplicated. The added regression tests cover both cases.Focused manifest/forge/git-gate suite passes: 188 tests. No remaining findings.
Re-reviewed at
e53e078. The prior credential-routing issue is resolved: referenced aliases sharing a proxy-routed host now fail closed when origin/auth/token_secret differ, while genuinely identical credentials remain safely deduplicated. The added regression tests cover both cases.Focused manifest/forge/git-gate suite passes: 188 tests. No remaining findings.