Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ This workspace is **github-agent-contracts** only.
- Prefer Node 20 ESM scripts with zero dependencies.
- Load root `agent-policy.yml` through `scripts/load-agent-policy.mjs` and follow `skills/agent-policy/SKILL.md` before publication or GitHub writes. Missing or invalid policy denies all actions; never fall back to the example or a different role.
- Agents must not edit, create, replace, or delete `agent-policy.yml` to grant themselves rights, or modify the executor to bypass a denial. A human reviews and publishes active policy changes.
- App permissions, branch protection/environments, and policy are cumulative gates. The coder publisher requires `commit_branch` and `open_pr`, checks the reviewed default-branch policy, and has no protected-push/deploy or role-override mode. Human-only merge is the default; `--merge-when-green` additionally requires a human-published coder `merge` grant and explicit authorization for merge and remote-branch cleanup.
- App permissions, branch protection/environments, and policy are cumulative gates. The publisher requires coder `commit_branch` and `open_pr`, checks the reviewed default-branch policy, and has no protected-push/deploy or role-override mode. Human-only merge is the default; `--merge-when-green` additionally requires a human-published `merger.merge` grant in local and reviewed policy and explicit authorization for merge and branch cleanup. Coder `merge` alone is insufficient; policy role does not switch App keys.
- Follow `docs/ROLES.md`: use separate role Apps, and keep only the coder key on the WSL orchestration host. Never use merger/deploy credentials or a human token there.
- Agents must commit and publish through `node scripts/agent-pr.mjs`, never raw `git commit`, `git push`, or a separate `gh pr create`. Never commit as R4yHarris or use a human token as a fallback.
- Agents must commit and publish through `node scripts/agent-pr.mjs`, never raw `git commit`, `git push`, a separate `gh pr create`, or `gh pr merge` as the signed-in human. Never commit as R4yHarris or use a human token as a fallback. Staged or selected `.github/workflows/**` changes are refused before token minting; a human must publish those paths.
- Follow `skills/signed-bot-commit/SKILL.md`. App environment variables never authorize use of the signed-in human's identity, and missing App configuration means stop. Never self-approve, squash, push main, or enable GitHub auto-merge. The authorized merge flag must verify `check-agent-trailers` on the exact head SHA and honor all required reviews.
- Invoke the helper only after authorization for commit, push, and a draft PR. A request to stop after writing files and testing means no publication. Humans may perform their own bootstrap commits.
- After reviewing/staging files, passing tests and policy gates, invoke the helper as the final step only after authorization for commit, push, and a draft PR. A request to stop after writing files and testing means no publication. Missing App configuration means leave changes uncommitted after tests. Humans may perform their own bootstrap commits.
- The human supplies `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY_PATH` in the environment. Do not read the PEM into chat, print tokens, or stage/commit `.env` or key files; the helper does not load `.env`.
- Use the consuming user/org's own App through `docs/ONBOARDING.md` and `docs/app-manifest.json`; do not recommend the maintainer demo App for private or production repositories.
- The helper discovers the configured App's verified bot identity for author and committer and uses its slug in `AI-Agent`. `--model` defaults to `unknown`; `--files` must be last. Without it, only reviewed staged changes are committed.
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/check-agent-trailers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ permissions:
contents: read

jobs:
check-agent-trailers:
trailers:
name: check-agent-trailers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 6 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Reusable conventions and small tools so Copilot, GitHub Agentic Workflows (`gh-a
- Follow `skills/agent-policy/SKILL.md` and load root `agent-policy.yml` with `scripts/load-agent-policy.mjs` before publication or any GitHub write, including safe outputs. Missing or invalid policy denies every capability; never fall back to the example.
- App permissions, branch protection/environments, and the policy allow-list must all permit an action. A task prompt, available tool, App environment variable, or broader token does not override a denial.
- Agents must not create, edit, replace, or delete root `agent-policy.yml` to grant themselves rights. Humans review and publish policy changes. Do not bypass policy by changing the loader, publisher, or harness configuration.
- The publisher is fixed to coder and requires `commit_branch` plus `open_pr`, matching the reviewed default-branch policy. There is no role or policy-path override. `--merge-when-green` also requires `merge` in that same role; a merger-role grant does not authorize coder. Human-only merge remains the default. Protected pushes and deploys remain unsupported.
- The publisher requires coder `commit_branch` plus `open_pr`, matching the reviewed default-branch policy. There is no role or policy-path override. `--merge-when-green` additionally requires `merger.merge` in both local and reviewed default-branch policy; coder `merge` alone is insufficient. Human-only merge remains the default. A policy role is not proof of which App key is loaded: the helper uses the two supplied App environment variables and does not switch keys. Protected pushes and deploys remain unsupported.
- Use separate user/org-owned role Apps. The WSL orchestration host holds only the coder key, never merger/deploy keys or human fallback credentials. Follow `docs/POLICY.md` and `docs/ROLES.md`.

```bash
Expand All @@ -40,16 +40,16 @@ node scripts/load-agent-policy.mjs --role coder --capability open_pr

- Follow `skills/signed-bot-commit/SKILL.md` for all publishing. The security control is the required PR check plus protected branch, bot author, and trailers; an App installation supplies authentication, not a merge exemption.
- Agents must use `node scripts/agent-pr.mjs` for commits and publication in this repository. Do not run raw `git commit`, `git push`, or a separate `gh pr create`, and never commit as R4yHarris or fall back to a human's credentials.
- If App environment variables are set, never commit or push as the signed-in human. If they are missing, stop rather than falling back. Their presence is not authorization to publish.
- Run the script only when the human has authorized committing, pushing the current feature branch, and creating a draft PR. If told to stop after editing or testing, do not invoke it.
- Only use `--merge-when-green` when the human also authorizes merging and remote feature-branch deletion. A human must first allow `merge` in root `agent-policy.yml`, using `roles.coder.allow` in this policy format, and publish that grant on the default branch. Never edit the policy yourself or treat the flag as a grant.
- If App environment variables are set, never commit or push as the signed-in human. If they are missing, finish after tests and leave changes uncommitted; never fall back to a human token. Their presence is not authorization to publish.
- After reviewing the files, staging or selecting only intended files, passing tests and policy gates, run the script as the final step only when the human has authorized committing, pushing the current feature branch, and creating a draft PR. If told to stop after editing or testing, do not invoke it.
- Only use `--merge-when-green` when the human also authorizes merging and remote feature-branch deletion. A human must first add `merge` to `roles.merger.allow` in root `agent-policy.yml` and publish that grant on the default branch. Never edit the policy yourself or treat the flag as a grant. Keep the flag disabled on coder-only WSL; a trusted launcher/operator must use a separately approved merger App/context for merging.
- The human supplies `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY_PATH` through the environment. Never read the PEM into chat, paste key material, print tokens, or commit `.env` or private-key files. The script does not load `.env` automatically.
- Default onboarding is a user/org-owned App from `docs/app-manifest.json`; follow `docs/ONBOARDING.md` and `docs/THREAT_MODEL.md`. Never recommend the maintainer's `r4yharris-agent-coder` App for private or production repositories; a demo install is for public playgrounds only.
- The helper verifies origin's installation against `GITHUB_APP_ID`, resolves that App's bot account, sets both author and committer to it, and adds `AI-Agent: <app-slug>` plus `AI-Model: unknown`. Do not hard-code or invent a bot identity; use `--model` when the model is known.
- Without `--files`, it commits the reviewed staged changes. With `--files`, pass individual repository files last; unrelated staged files cause a failure. Inspect the changes and run the tests before publication.
- Without `--files`, it commits the reviewed staged changes. With `--files`, pass individual repository files last; unrelated staged files cause a failure. Staged or selected `.github/workflows/**` paths are refused before token minting; a human must publish workflow changes. Inspect the changes and run the tests before publication.
- Node 20+, Git, and `gh` are required. The App must be installed on origin's repository with contents and pull requests write permissions; the opt-in merge flow also needs Checks read permission. The helper creates a repository-scoped installation token, pushes without force, creates a draft PR only if no open PR exists, and revokes the token.
- This is the explicitly authorized branch-publication path, not a general grant of GitHub write permissions. It refuses main, master, and the repository's default branch. Never bypass repository protections.
- Require the `check-agent-trailers` check on protected branches and forbid direct agent pushes or bypass. By default, leave merges to humans. The sole script-managed exception is authorized `--merge-when-green`: require a successful GitHub Actions check on the exact head SHA and all repository merge requirements, then create a merge commit and delete only the unchanged remote feature branch.
- Require the `check-agent-trailers` check on protected branches and forbid direct agent pushes or bypass. By default, leave merges to humans. The sole script-managed exception is authorized `--merge-when-green`: require a successful GitHub Actions check on the exact head SHA and all repository merge requirements, then create a merge commit and delete only the unchanged remote feature branch. After confirmed merge, fetch origin with App auth, check out and fast-forward the default branch, and delete the local feature ref only if the worktree is clean and that ref still points to the published head included in the merge. Dirty or moved state aborts local cleanup without discarding work; report partial cleanup.
- Never self-approve, squash, rebase-merge, force-push, push main, or enable GitHub auto-merge. Marking an authorized draft ready does not approve it or bypass required human reviews. See `docs/POLICY.md` for polling, permission, and failure details.
- Commits are unsigned for now. If signing is required or any step fails, stop and report it without a raw Git fallback. A human may commit a bootstrap slice themselves; agents may not assume that identity. After a partial failure, inspect the existing commit and PR before retrying.

Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Repository instructions

Follow [AGENTS.md](AGENTS.md) for all repository rules and required skills.
Follow [AGENTS.md](AGENTS.md) for all repository rules and required skills. After tests, policy gates, and reviewed staging, use `node scripts/agent-pr.mjs --message "..."` as the final step only for explicitly authorized publication with App configuration present. Otherwise leave changes uncommitted; never use human credentials or edit the active policy. Merge requires separate authorization and `merger.merge`, not merely a coder key.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This is community OSS for GitHub, not a GitHub replacement.

1. **[Register App from manifest](docs/app-manifest.json).** Create an App owned by you or your organization, keep it private to that account, and choose **Only select repositories** during installation.
2. **Configure and copy.** Supply `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY_PATH` outside git, then copy AGENTS.md, the policy and commit skills, publisher/loader, and check Action/workflow as listed in [ONBOARDING.md](docs/ONBOARDING.md). A human installs the root capability policy. CI stores the key in the `GITHUB_APP_PRIVATE_KEY` secret.
3. **Protect and publish.** Require `check-agent-trailers`, disallow direct pushes to `main` and agent bypass, and reserve merges for humans. Tell the agent: "Use signed-bot-commit / scripts/agent-pr.mjs for all publish."
3. **Protect and publish.** Require `check-agent-trailers`, disallow direct pushes to `main` and agent bypass, and leave merging to humans by default. After tests, policy gates, and reviewed staging, authorized agent publication ends with `node scripts/agent-pr.mjs --message "..."`; without App configuration, stop with uncommitted changes, never a human-token fallback.

The manifest is a static template, not a hosted registration button. An owner-controlled manifest callback is a follow-on; placeholder URLs must be replaced before completing GitHub's flow. The [onboarding guide](docs/ONBOARDING.md) describes that boundary and the manual registration fallback.

### Create your own App (recommended)

Your account or organization owns the App and controls its private key. No project-maintainer installation is needed. Use the [manifest](docs/app-manifest.json), [harness guide](docs/HARNESSES.md), and [threat model](docs/THREAT_MODEL.md). The App key holder can mint tokens for **every installation of that App**, so installation scope and key custody matter.
Your account or organization owns the App and controls its private key. No project-maintainer installation is needed. Use the [manifest](docs/app-manifest.json), [harness guide](docs/HARNESSES.md), [dedicated machine guide](docs/ORCHESTRATION-MACHINE.md), and [threat model](docs/THREAT_MODEL.md). The App key holder can mint tokens for **every installation of that App**, so installation scope and key custody matter. The manifest includes Checks read-only; humans must accept this permission on existing installations for opt-in merge.

### Demo App

Expand Down Expand Up @@ -58,7 +58,7 @@ Follow the [adoption guide](docs/adopt.md) and copy the [consumer workflow](exam

Hermes, Copilot, Claude Code, and Cursor share one human-owned root `agent-policy.yml`. The [example](examples/agent-policy.yml) allows coder branch commits, draft PRs, comments, and labels; merger and deploy allow-lists are empty. Missing policy denies publication, and agents must not edit policy to grant themselves rights.

Read [POLICY.md](docs/POLICY.md) for the three permission layers, human bootstrap, and optional `--merge-when-green` flow, and [ROLES.md](docs/ROLES.md) for role-key separation. Merging remains disabled unless a human grants coder `merge` and authorizes the flag; it requires a successful exact-head trailer check and creates a merge commit before remote-branch cleanup. Protected pushes and deploys remain unsupported. No active policy grant or hosted control plane is installed by this pack.
Read [POLICY.md](docs/POLICY.md) for the three permission layers, human bootstrap, and optional `--merge-when-green` flow, and [ROLES.md](docs/ROLES.md) for role-key separation. Merging remains disabled unless a human publishes `roles.merger.allow: [merge]` and explicitly authorizes the flag; coder `merge` alone is insufficient. The flag requires a successful exact-head trailer check and all GitHub reviews, creates a merge commit, and cleans up only unchanged remote and local feature refs after confirmation. Policy does not select the App key; a coder-only WSL host must disable merge and a trusted launcher/operator must use a separately approved merger App/context. Protected pushes and deploys remain unsupported. No active policy grant or hosted control plane is installed by this pack.

## Non-goals

Expand Down
6 changes: 3 additions & 3 deletions docs/HARNESSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The common contract is [AGENTS.md](../AGENTS.md), which requires [agent-policy](../skills/agent-policy/SKILL.md) first, then [signed-bot-commit](../skills/signed-bot-commit/SKILL.md) and [scripts/agent-pr.mjs](../scripts/agent-pr.mjs) for authorized publication. Use the consuming user's or organization's App from [ONBOARDING.md](ONBOARDING.md), never a shared maintainer App for private repositories.

Harness setup does not replace the required `check-agent-trailers` check, branch protection, bot authorship, or trailers. No harness may publish as the signed-in human, print credentials, or merge an agent PR. App environment variables do not themselves authorize publication.
Harness setup does not replace the required `check-agent-trailers` check, branch protection, bot authorship, or trailers. No harness may publish as the signed-in human or print credentials. Human-only merge is the default; opt-in merge needs explicit authorization, `merger.merge` in local and reviewed policy, and a separately approved merger App/context. App environment variables do not themselves authorize publication.

Every harness reads the same human-owned root `agent-policy.yml` through [the loader](../scripts/load-agent-policy.mjs), not a harness-specific allow-list or cached fallback. Missing policy denies writes. No harness may edit policy to grant itself rights, change its assigned role, or deploy by default. [POLICY.md](POLICY.md) defines the shared capabilities; [ROLES.md](ROLES.md) defines operator-controlled role and key boundaries.

Expand All @@ -20,7 +20,7 @@ Keep [CLAUDE.md](../CLAUDE.md) as a short pointer to AGENTS.md. Claude Code read

Load AGENTS.md as repository instructions, the agent-policy skill before writes, and [skills/signed-bot-commit/SKILL.md](../skills/signed-bot-commit/SKILL.md) for publication using the installed runtime's supported mechanism. For GitHub issue, PR, or code reads, also follow the [GitHub MCP allowlist skill](../skills/github-mcp-allowlist/SKILL.md). Safe-output handlers must enforce the shared policy in addition to their tool allowlists.

Use repository-scoped installation tokens supplied by a trusted launcher; never store tokens in repository MCP configuration. Keep default agent tools read-only and write-capable credentials in the approved publication context. No Hermes runtime changes are needed.
Use repository-scoped installation tokens supplied by a trusted launcher; never store tokens in repository MCP configuration. Keep default agent tools read-only and write-capable credentials in the approved publication context. For a dedicated WSL/Hermes machine, follow [ORCHESTRATION-MACHINE.md](ORCHESTRATION-MACHINE.md): no human `gh` sign-in or forwarded SSH credentials, only the coder key, and no merge flag there. No Hermes runtime changes are needed.

## Cursor

Expand All @@ -32,4 +32,4 @@ Keep root policy changes human-owned. No Cursor-specific credential, role overri

If you honor **AGENTS.md**, you honor **agent-policy** and **signed-bot-commit**. Read the referenced skills and invoke the same helper after policy checks and explicit authorization, regardless of whether your runtime has a native skill loader.

When the necessary instructions, App environment, or publishing tools are unavailable, stop and report the missing prerequisite. Do not fall back to raw Git, human credentials, or automatic merging. Humans review and merge.
After tests, policy checks, and reviewed staging, run `node scripts/agent-pr.mjs --message "docs: clarify agent contracts"` as the final step only when publication is authorized. When the necessary instructions, App environment, or publishing tools are unavailable, stop with uncommitted changes and report the missing prerequisite. Do not fall back to raw Git, human credentials, or automatic merging. Humans review and merge by default; [POLICY.md](POLICY.md) describes the separate opt-in.
Loading
Loading