Repository navigation
docs(decisions): ADR-027 propose git provider abstraction (#456) - #1032
ClintEastman02 wants to merge 14 commits into
Conversation
…s#456) Record the design for a GitProvider (agent) / ScmProvider (handlers) abstraction with GitHub as the reference implementation, per aws-samples#456. Adopts the layering from PR aws-samples#824 and turns the failure modes its review found into rules: the repo row is the only authority for git_provider, unknown values fail closed, every payload hop gets a round-trip test, capabilities are declared rather than assumed, ScmCredential is bound to its repo by a binding the agent cannot choose, tokens never touch disk, and redaction only widens. Delivery is phased (0, 1a-c, 2, 3a-b, 4 GitLab, 5 Bitbucket); this commit is Phase 0 with no behaviour change. Starlight mirror generated with docs:sync. Refs aws-samples#456 Co-authored-by: Kiro <noreply@kiro.dev>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1032 +/- ##
=======================================
Coverage ? 93.80%
=======================================
Files ? 406
Lines ? 116911
Branches ? 12989
=======================================
Hits ? 109670
Misses ? 6639
Partials ? 602 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Kiro <noreply@kiro.dev>
|
Thanks for tracing where GitHub is wired in. Could we bring the first GitLab task forward in the plan? I’d start by onboarding a GitLab.com project, running I’d change the credential proposal in §4 before accepting the ADR. ECS and MicroVM can store task payloads in S3, and their compute roles can read other tasks’ payloads. Please keep the payload to a secret reference and spell out how each task gets access to just its own token. The platform GitHub token should also be scoped to A few details matter for that first GitLab task:
Since the proposed repo key already identifies the provider, I’d derive the provider from it and drop the extra stored field. I’d keep the GitLab pipeline webhook in scope for #456 and leave the decision about sharing a receiver with Bitbucket until there’s a second implementation. |
Responds to review on aws-samples#1032: key-derived provider with no stored field, reference-only payload and github.com scoping of the platform secret, providers omitted from bundled workflows, pr_number stored, stable memory actor id, GitLab pipeline webhook in scope, first GitLab task moved to Phase 3. Co-authored-by: Kiro <noreply@kiro.dev>
|
Thanks, this was useful. I pushed a revision that takes all of it:
One thing I left open for your input: the mechanism that gives each task access to only its own token on ECS, MicroVM and AgentCore. §4 sets the requirement, and the Phase 2 PR picks the mechanism. If you already prefer one approach, I'll write it into the ADR. |
isadeks
left a comment
There was a problem hiding this comment.
Thanks for the revision. The layering (key-derived provider, capability declarations, deterministic PR creation, structured review findings) reads well and should carry GitHub, GitLab and Bitbucket Cloud. Inline comments cover the specifics; the main themes are below.
Should be resolved before accepting
- Both Phase 2 delivery candidates conflict with §4/§9 (no token or session credential in the payload).
memoryActorIdidentity mapping for bare GitHub keys that contain a period.- Host canonicalisation, so
github.comcannot be spelled a second way. - GitHub Enterprise Server keys are admitted in Phase 1a but only guarded in Phase 2.
- The legacy
github_token_secret_arnfallback conflicts with the prefix/tag check and the prefix-scoped grant. - The credential contract shape (
scm_token_secret_arn, one credential per repo) is built for a static per-repo secret, which will not fit the GitHub App (#50) or Token Vault (#249) resolvers the ADR names as successors. I am not asking for those resolvers to be in scope here, only for the contract this ADR approves to leave room for them.
How far the abstraction reaches
Worth stating in the ADR, even if only as known limits:
- The vocabulary is closed. A new provider means editing the vocabulary, three copies of
providerOfRepoKey, two interfaces, aDeploymentFeatureskey and synth-time egress. Is an out-of-tree or internal provider meant to be supported, or explicitly not? - "Each provider supplies only its HTTPS username" assumes HTTPS plus a token.
codecommitis in the vocabulary and uses SigV4; self-hosted tools often use SSH or mTLS. git pushis declared provider-neutral andpr_numberis a number. Tools that push to a review ref, or whose review ids are not numeric, do not fit.- One prefix per product: Bitbucket Cloud and Bitbucket Data Center have different APIs under
bitbucket:, so dispatch needs the host as well. - Issue listing sits in
ScmProvider(Phase 4), but many teams keep issues in a separate tracker. - Private hosts need network reachability in both directions, not only a DNS allowlist entry.
Smaller points
Numbering clash with #1013, the Amends header versus the documented ADR process, and a few cross-references. Details inline.
| - Agent compute roles get no `bgagent/scm/*` grant. A prefix grant there would let a prompt-injected task read every repo's token. | ||
| - The agent receives only its own repo's token. The binding comes from the orchestrator, not from the agent. Today's `AgentSessionRole` `repo` session tag does not qualify: the agent sets it from its own config, and it drives only cost attribution. Phase 2 chooses between two mechanisms: | ||
| - orchestrator-minted session credentials whose `repo` tag the orchestrator sets, with the grant conditioned on `secretsmanager:ResourceTag/bgagent:repo` equal to `${aws:PrincipalTag/repo}`; | ||
| - the orchestrator resolving the token and delivering it through the per-task payload channel. |
There was a problem hiding this comment.
Both candidates seem to conflict with the rules in this section and §9. This one delivers the token through the per-task payload, and the first needs orchestrator-minted session credentials to reach the agent, while §4 and §9 say the payload shall contain neither a repository token nor a session credential. The Context section also notes that every task's compute role can read the shared payload bucket, so a token in the payload is readable by another repo's task.
Suggestion: name a delivery channel that is not the task payload (or make the payload per-task readable first), and reword each candidate so it satisfies §9.
| - the orchestrator resolving the token and delivering it through the per-task payload channel. | ||
| - Token resolution moves from the compute role (`platform_client`, before session setup) to that per-task path. | ||
| - Legacy `github_token_secret_arn` secrets are arbitrarily named and untagged. The Phase 2 PR states whether they are migrated to tagged SCM secrets or keep a compute-role read path. | ||
| - **Orchestrator check.** The orchestrator rejects a row whose secret is outside the prefix, or whose tag does not equal the task's repo key. |
There was a problem hiding this comment.
This check and the prefix-scoped grant appear to make the legacy fallback unreadable. Trusted Lambdas get GetSecretValue only on bgagent/scm/*, and this check rejects a secret outside the prefix or without the tag, but §4 keeps github_token_secret_arn as a github.com fallback and notes those secrets are arbitrarily named and untagged. After Phase 2 such a repo would either be rejected or silently revert to the platform secret.
Could the ADR state whether the check applies only to scm_token_secret_arn, and how legacy ARNs are read? The tag comparison also needs DescribeSecret, which is not listed.
| - Token resolution moves from the compute role (`platform_client`, before session setup) to that per-task path. | ||
| - Legacy `github_token_secret_arn` secrets are arbitrarily named and untagged. The Phase 2 PR states whether they are migrated to tagged SCM secrets or keep a compute-role read path. | ||
| - **Orchestrator check.** The orchestrator rejects a row whose secret is outside the prefix, or whose tag does not equal the task's repo key. | ||
| - **Payload key.** `scm_token_secret_arn` is a per-task payload key. The partition and account anchor check in `server.py` extends to cover it. Holding the ARN does not grant access to the secret: access comes from the per-task binding above. |
There was a problem hiding this comment.
This is the one contract that accepting the ADR approves, and it is shaped for a static per-repo Secrets Manager secret. A GitHub App installation or a Token Vault entry has no per-repo secret ARN, spans many repos, and yields tokens that expire mid-task (installation tokens last one hour). As written, #50 would have to change an approved contract.
Three small edits would leave room without adding the resolvers to scope:
- Make the key an opaque credential reference plus a resolver kind, with
secrets_manageras the only kind in v1. - Change "one per repo" to "binds at repo scope in v1", leaving wider scopes (namespace, host) to a later resolver.
- Add a requirement that the agent's token path tolerates a token that expires during a task. The credential helper reading a fixed environment variable does not.
Then list OAuth and GitHub App resolvers as out of scope in §10, pointing at this reference shape. If you would rather not change the contract in this revision, marking scm_token_secret_arn as provisional would also work.
There was a problem hiding this comment.
Following up after reading RFC #249, which is approved and has its Linear phase shipped (#809). It makes the AgentCore Identity Token Vault the credential source for outbound targets, GitHub included: GithubOauth2 is a built-in vendor, CustomOauth2 covers targets without one, and tokens bind to (workload identity, user) with refresh handled by the vault. Its Phase 1 text replaces direct Secrets Manager reads in resolve_github_token().
§4 here approves a Secrets Manager ARN as the contract and mentions the vault only as a later resolver. Could the ADR reconcile the two?
- Say whether
ScmCredentialv1 (a direct token in Secrets Manager) is a stopgap until the vault path, or a permanent option beside it. - Make the credential reference able to name a vault provider, not only a secret ARN.
- Note what the vault does not give you: a
GithubOauth2user token is not limited to one repo (the RFC: Identity propagation — composable credential delegation via AgentCore Identity Token Vault #249 spike requestedscope=repo), so the per-repo isolation goal in this section needs a separate answer on that path, and webhook-triggered tasks have no user to consent (an open question in RFC: Identity propagation — composable credential delegation via AgentCore Identity Token Vault #249). - The delivery question is shared: on ECS and MicroVM the agent mints its workload token from the user's JWT, so that JWT has to reach the agent without travelling in the payload, which is the same constraint as the Phase 2 candidates.
|
|
||
| - **GitHub.** A bare `owner/repo` key means github.com, so existing rows need no migration. GitHub Enterprise Server uses `github:<host>/<owner>/<repo>`. | ||
| - **Other providers.** Every other repo uses `<provider>:<host>/<path>`, for example `gitlab:gitlab.com/group/sub/project`. | ||
| - **Consistency.** A key whose prefix is not in the vocabulary, or is `github:` with the host `github.com` (the bare form is the only spelling for github.com), fails config load. |
There was a problem hiding this comment.
The single-spelling rule can be bypassed, because §9 requires exact matching with no case folding or trimming and no host normalisation is specified. github:GitHub.com/acme/app or github:github.com./acme/app would pass this check, be treated as an Enterprise Server key, and coexist with bare acme/app with its own row, memory identity and credential binding.
Suggestion: define host canonicalisation in providerOfRepoKey (lower case, no trailing dot, no port or www.), reject non-canonical hosts, and add those cases to contracts/repo-keys.json.
| - **GitHub.** A bare `owner/repo` key means github.com, so existing rows need no migration. GitHub Enterprise Server uses `github:<host>/<owner>/<repo>`. | ||
| - **Other providers.** Every other repo uses `<provider>:<host>/<path>`, for example `gitlab:gitlab.com/group/sub/project`. | ||
| - **Consistency.** A key whose prefix is not in the vocabulary, or is `github:` with the host `github.com` (the bare form is the only spelling for github.com), fails config load. | ||
| - **Memory identity.** The repo key is not used as an AgentCore Memory `actorId`. One function, `memoryActorId(key)`, maps a key to a stable ID that is valid as an `actorId`. A bare GitHub key maps to itself, so existing memory records stay reachable. Any other key maps to `<provider>_<first 32 hex characters of SHA-256(key)>`. The CDK handlers and the agent both call it for every read and write, and the shared corpus in `contracts/repo-keys.json` covers it. The Phase 3 PR checks the output against the service's `actorId` constraints before any non-GitHub key is written. |
There was a problem hiding this comment.
A bare GitHub key maps to itself, but owner/repo can contain a period (for example acme/site.js), which the Context section reports is not a valid actorId. The constraint check is deferred to Phase 3 and scoped to non-GitHub keys, so the function would ship in Phase 1a without being valid for every GitHub key, and the corpus would still pass because it pins identity for bare keys.
Suggestion: specify the mapping for bare keys with characters outside the actorId set, with a compatibility read path for existing records, and run the constraint check in Phase 1a over the whole corpus.
| | 4 | GitLab remainder: hydration, comment upsert and issue listing behind `ScmProvider`; path grammar edge cases | new provider capabilities | | ||
| | 5 | Bitbucket Cloud, starting from #824, and the decision on a shared webhook receiver | new provider | | ||
|
|
||
| Accepting this ADR approves only the payload key `scm_token_secret_arn` as an agent-to-orchestrator contract addition. Each of the following is still raised as ask-first in its own PR: |
There was a problem hiding this comment.
Nit: §1 and §4 describe scm_token_secret_arn as a key on the orchestrator → agent payload, so this should read "orchestrator-to-agent". The current direction reads like the agent-selected binding that §9 forbids.
| - tokens persisted to `.git/config`; | ||
| - fail-open defaults. | ||
|
|
||
| §§1 to 5 and 8 turn these into rules. This phased plan supersedes #824. Its Bitbucket REST client, preflight probes and tests are the intended starting point for the Bitbucket phase, and @Agsiegert is invited to own it. |
There was a problem hiding this comment.
Nit: the fail-open and webhook rules are in §9; §8 only defers decisions. Also, the Context and §10 discuss Azure DevOps, but the §1 vocabulary has no id for it, so it would be worth saying it needs a vocabulary addition.
| **Revision:** 2 (responds to review on #1032) | ||
| **Amends:** ADR-016 (credential types), ADR-017 (custom token secrets), ADR-024 §1 (optional features) | ||
|
|
||
| Per the [ADR lifecycle](./README.md#lifecycle), this decision remains proposed until its implementing PR merges. |
There was a problem hiding this comment.
Nit: with six implementing phases, which phase's merge moves the status to accepted?
| **Date:** 2026-11-10 | ||
| **Issue:** [#456](https://github.com/aws-samples/sample-autonomous-cloud-coding-agents/issues/456) | ||
| **Revision:** 2 (responds to review on #1032) | ||
| **Amends:** ADR-016 (credential types), ADR-017 (custom token secrets), ADR-024 §1 (optional features) |
There was a problem hiding this comment.
Nit: docs/decisions/README.md describes two paths, refining in place with a dated Changelog entry or a new ADR that supersedes the old one, and its template has no Amends, Issue or Revision fields. ADR-014 also changes here (rule 14, and the meaning of an omitted repo_config.provider) but is not listed. The Consequences section says ADR-017 is refined in place, though this PR does not touch that file.
| @@ -0,0 +1,180 @@ | |||
| # ADR-025: Git provider abstraction | |||
There was a problem hiding this comment.
Nit: open PR #1013 also adds an ADR-025 (ADR-025-trusted-approval-writer.md). Whichever merges second will need renumbering, including the docs mirror and the self-references.
| - Token resolution moves from the compute role (`platform_client`, before session setup) to that per-task path. | ||
| - Legacy `github_token_secret_arn` secrets are arbitrarily named and untagged. The Phase 2 PR states whether they are migrated to tagged SCM secrets or keep a compute-role read path. | ||
| - **Orchestrator check.** The orchestrator rejects a row whose secret is outside the prefix, or whose tag does not equal the task's repo key. | ||
| - **Payload key.** `scm_token_secret_arn` is a per-task payload key. The partition and account anchor check in `server.py` extends to cover it. Holding the ARN does not grant access to the secret: access comes from the per-task binding above. |
There was a problem hiding this comment.
One more on the contract shape: multi-repo tasks. Many repos with mixed providers per deployment work fine here, but every rule assumes a single repo key per task: the agent "receives only its own repo's token", the secret's tag must equal the task's repo key, the clone guard matches one key, and the task record stores one pr_number and pr_url.
A task that spans repos (for example a service and its infrastructure repo) would need a set of repo keys, one credential binding per key and a list of PRs on the record. The per-repo binding could extend to that, since the orchestrator can grant several tagged secrets to one task, but a single scm_token_secret_arn payload key cannot carry it.
I am not asking for this to be in scope. Could §10 list multi-repo tasks as out of scope and name the extension path (a list of credential references and PR records)? It is another reason to prefer an opaque reference over a single ARN key.
Responds to the review on aws-samples#1032: - Credentials (4): an opaque scm_credential_kind and scm_credential_ref at repo scope in v1, so GitHub App and Token Vault resolvers add a kind without changing the approved contract. The credential helper asks a resolver per git operation, so expiring tokens work. - Delivery channel (4, 9): no token or session credential in any channel another task's role can read. Phase 2 needs a per-task channel first (aws-samples#1015 or another). Both candidates reworded to use it. - Legacy github_token_secret_arn (4): outside the prefix and tag check, exact-ARN read path, DescribeSecret added, never silently replaced by the platform secret. - Identity (6, 9): hosts must be canonical and are rejected, not normalised. memoryActorId hashes any key outside the actorId pattern, including bare GitHub keys with a period. Checked in Phase 1a. - GitHub Enterprise Server (1, 9, 10): every prefixed key is rejected until Phase 2. - Known limits (11), multi-repo tasks and credential resolvers out of scope (10). - Header, status trigger, 1a behaviour change, cross-references and "orchestrator-to-agent" wording fixed. Renumbered to ADR-027, since aws-samples#1013 holds 025 and main has 026. Co-authored-by: Kiro <noreply@kiro.dev>
|
Thanks for the careful review. I pushed a revision ( Must-resolve points
Also added. §11 lists the known limits you asked for. The nits are fixed, including the 1a behaviour change now reading "none". Where I'd like your view.
|
Proposes ADR-025: a provider abstraction so ABCA can work with git hosts other than GitHub (GitLab first, per #456), with GitHub refactored as the reference implementation. This PR is the design only; no code changes.
Area
cdk— infrastructure, handlers, constructsagent— Python runtime / Docker imagecli—bgagentclientdocs— guides or design sources (docs/guides/,docs/design/)tooling— rootmise.toml, scripts, CI workflowsRelated
.git/config, fail-open defaults); §§1–5 and 8 turn these into rules. The ADR proposes that feat(platform): add GitProvider abstraction for Bitbucket support #824's Bitbucket REST client, preflight probes and tests seed the Bitbucket phase, and invites @Agsiegert to own it.Stack position
PR 1 for #456 — provider abstraction for non-GitHub git hosts
Prior: none (targets
main)This PR: ADR-025 (proposed) and its generated Starlight mirror
Next: Phase 1, as small stacked PRs, each verified on its own and with no behaviour change for existing GitHub repos:
git_providerscontract incontracts/constants.jsonand orchestrator plumbing:git_providerresolved fail-closed inloadBlueprintConfigand carried in every payloadTaskConfig; an unsupported value fails before clonerepo onboard/repo showrespect a stored valueScmProviderinterface, with GitHub delegating to the existing checks (wire behaviour pinned by a golden test)Changes
docs/decisions/ADR-025-git-provider-abstraction.mddecides:git_provider. An absent value meansgithub, so existing rows are unaffected. An unrecognised value fails at blueprint load. A workflow'srepo_config.provideris a constraint, never a source.GitProvider(agent) andScmProvider(handlers); GitHub delegates to existing code.ScmCredentialbound per repo by a binding the orchestrator chooses, not the agent. Tokens never touch disk. Redaction only widens.ghin prompts. PR creation stays deterministic inensure_pr.owner/repostays GitHub; other hosts use<provider>:<host>/<path>.DeploymentFeatures(amends ADR-024 §1).Status is
proposed; per the ADR lifecycle it is accepted when its implementing PR merges.Testing:
mise //docs:sync(mirror regenerated and committed) andmise //docs:buildboth pass.Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.