Skip to content

Commit 4a30625

Browse files
authored
refactor!: simplify identity model; drop acting-user plumbing (#32)
The action creates a Coder Agents chat against a GitHub issue or PR. The chats API binds chat ownership to whoever the `coder-token` authenticates as; there is no owner override. This PR simplifies the action around that contract and pushes trigger policy out to the workflow author. ## What changed - Drop inputs `github-user-id` and `coder-username`. The chat owner is always the token holder regardless of these inputs, so the action no longer resolves a non-token user. - Output `coder-username` reports the token holder, read once from `GET /api/v2/users/me`. - Workflow author defines trigger policy via `if:`; the action does not gate. GitHub's `secrets.*`-on-forks rule already covers the load-bearing case for `pull_request`. README's Security model section ships three patterns for the broader trigger surfaces. - Drop the per-user reuse label (`coder-agents-chat-action-user`). Chats are reused by `gh-target` plus workflow name; workflows that want per-actor separation pass `idempotency-key: ${{ github.actor }}` themselves. - Idempotency is stored as the VALUE of a fixed `coder-agents-chat-action-idempotency` label key, not as the key itself. A sanitized `idempotency-key` input can no longer collide with an action-owned label key. - Validate `github-url` against `github.com` in a shared `parseGithubItemURL` helper. Non-github hosts and malformed paths are refused before any GitHub API call. - Failure comments wrap `detail.message` and `chat.last_error` in a 4-backtick fenced block. Control bytes are stripped, embedded 4+-backtick runs are downgraded, and the body is capped at `DETAIL_BLOCK_MAX_CHARS` (4000) chars. - Rewrite the README around the simpler model: one Security model section covering ownership, trigger gating, and indirect prompt injection. Closes CODAGT-437 Closes CODAGT-394 Closes CODAGT-438 🤖 Authored by Coder Agents.
1 parent 7fc11ff commit 4a30625

18 files changed

Lines changed: 784 additions & 3109 deletions

README.md

Lines changed: 67 additions & 42 deletions
Large diffs are not rendered by default.

action.yaml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,8 @@ inputs:
2727
description: "GitHub token used to post and update issue comments."
2828
required: true
2929

30-
github-user-id:
31-
description: "GitHub user ID to resolve to a Coder user. Mutually exclusive with coder-username."
32-
required: false
33-
34-
coder-username:
35-
description: "Coder username to use directly. Mutually exclusive with github-user-id; useful for service-account workflows."
36-
required: false
37-
3830
coder-organization:
39-
description: "Coder organization name. Looked up by name to resolve the organization UUID for chat creation. Recommended when the resolved Coder user belongs to more than one organization, since the fallback choice is non-deterministic."
31+
description: "Coder organization name. Looked up by name to resolve the organization UUID for chat creation. Recommended when the Coder user belongs to more than one organization, since the fallback choice is non-deterministic."
4032
required: false
4133

4234
workspace-id:
@@ -67,7 +59,7 @@ inputs:
6759
default: "600"
6860

6961
idempotency-key:
70-
description: "Optional sharding key to narrow the default per-workflow scope. By default the action reuses the most recent non-archived chat scoped to `gh-target`, the resolved Coder user, and the workflow name. Set this to maintain multiple parallel chats on the same target/user/workflow (for example, one per matrix dimension)."
62+
description: "Optional sharding key to narrow the default reuse scope. By default the action reuses the most recent non-archived chat scoped to `gh-target` and the workflow name (when `GITHUB_WORKFLOW` is set). All chats are owned by the `coder-token` holder, so the scope does not include a per-actor component. Set this to maintain multiple parallel chats on the same target/workflow (for example, one per matrix dimension). Pass `${{ github.actor }}` here if you want per-actor separation."
7163
required: false
7264

7365
force-new-chat:
@@ -77,7 +69,7 @@ inputs:
7769

7870
outputs:
7971
coder-username:
80-
description: "The Coder username resolved from the GitHub user."
72+
description: "The Coder username the `coder-token` belongs to (always the chat owner; the chats API has no owner override)."
8173

8274
chat-id:
8375
description: "The chat ID."
@@ -125,7 +117,7 @@ outputs:
125117
description: "Base branch name when available."
126118

127119
chat-error-kind:
128-
description: "Machine-readable error kind when the chat fails (one of `spend_exceeded`, `user_not_found`, `user_ambiguous`, `org_not_found`, `api_error`, `timeout`)."
120+
description: "Machine-readable error kind when the chat fails (one of `spend_exceeded`, `org_not_found`, `api_error`, `timeout`)."
129121

130122
chat-error-message:
131123
description: "Human-readable error message when the chat fails."

dist/index.js

Lines changed: 105 additions & 323 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)