Repository navigation
Description
Analysis
push_repo_memory always pushes with the workflow's GITHUB_TOKEN. In pkg/workflow/repo_memory.go, the push step built by buildSinglePushRepoMemoryStep sets GH_TOKEN: ${{ github.token }}, and tools.repo-memory has no option for another credential. Its keys in v0.93.5 and v1.0.1 are allowed-extensions, branch-name, branch-prefix, create-orphan, description, file-glob, format-json, id, ledger, max-file-count, max-file-size, max-patch-size, target-repo, validation and wiki.
That makes memory branches impossible to protect with repository rulesets:
- Rulesets accept only installed GitHub Apps as bypass actors. The built-in GitHub Actions integration (
GITHUB_TOKEN) can't be added; the API answersActor GitHub Actions integration must be part of the ruleset source or owner organization. - So a ruleset on
memory/**with Restrict updates / Restrict creations blocks gh-aw's own memory pushes. - Without such a ruleset, anyone with write access, and any workflow with
contents: write, can push ordinary commits to a memory branch.
Repo-memory content is read back by agents as trusted, accumulated knowledge, so being able to say "only this workflow's app may write it" matters. It's the same reason tools.github.github-app and safe-outputs support GitHub App tokens. It would also give target-repo a natural credential for writing memory in another repository, which GITHUB_TOKEN can't do.
Implementation Plan
Please implement the following changes:
-
Update the schema (
pkg/parser/schemas/main_workflow_schema.json): add an optionalgithub-appobject totools.repo-memory, in both the object form and each array entry. Use the same shape astools.github.github-app:client-id(or legacyapp-id),private-key,owner,repositories,ignore-if-missing. -
Parse it (
pkg/workflow/repo_memory.go): addGitHubApp *GitHubAppConfigtoRepoMemoryEntry, filled with the existingparseAppConfig(safe_outputs_app_config.go), the waytarget-repois applied inapplyRepoMemoryIdentityFields. -
Mint and use the token in
push_repo_memory(buildPushRepoMemoryJob/buildSinglePushRepoMemoryStep), when an entry setsgithub-app:- add a pinned
actions/create-github-app-tokenstep before the push, withpermission-contents: write; - default
ownerandrepositoriesto the entry'starget-repo, or the current repository; - use the step's token for that entry's
GH_TOKENinstead ofgithub.token; - keep the current behaviour unchanged when
github-appis absent.
With every entry on an app, the job's own
contents: writecould drop toread. - add a pinned
-
Validation (
app_token_permissions_validation.go): make sure the minted token for repo-memory requests onlycontents: write, and fail compilation ifgithub-appis set withoutclient-id/private-key(unlessignore-if-missing). -
Agent-side clone (
generateRepoMemorySteps): optionally use the same app token for the clone whentarget-repois private and outside the current repository. Otherwise leave it ongithub.token. -
Add tests:
- Compiler: a workflow with
tools.repo-memory.github-appemits a token-mint step inpush_repo_memory, and the push step'sGH_TOKENreferences that step's output, notgithub.token. - Array form: per-entry apps mint per-entry tokens, and entries without
github-appkeepgithub.token. - Schema: invalid
github-app(missingprivate-key) is rejected.
- Compiler: a workflow with
-
Update the docs (repo-memory reference): document
github-app, with a recipe for amemory/**ruleset (Restrict updates and creations; bypass: the app, plus an admin team if desired). -
Follow guidelines: run
make agent-finish.
Acceptance Criteria
tools.repo-memoryacceptsgithub-app(object and array forms), andpush_repo_memorypushes with a token minted from that app (Contents: write only).- A repository can enforce a ruleset on
memory/**that restricts updates and creations to that app, and the workflow's memory pushes still succeed. - Workflows without
github-appcompile and push exactly as before.
Activity