From c4dd6086788471c948a6ee21b34d4734a6c11034 Mon Sep 17 00:00:00 2001 From: Robert Gruen Date: Mon, 2 Nov 2026 10:53:14 -0800 Subject: [PATCH] Acknowledge accepted work and owner build commands Confirm exact acceptance with an idempotent thumbs-up on the owner command. Add the native build rocket without granting write permissions to inference or generated checks. Preserve fail-closed publication and document verified live-run limits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../workflows/issue-implementation.lock.yml | 19 +++- .github/workflows/issue-implementation.md | 2 +- AUTOMATION.md | 33 ++++++- OWNER-CHEATSHEET.md | 12 ++- tools/discussion-draft.mjs | 24 ++++++ tools/tests/discussion-draft.test.mjs | 86 +++++++++++++++++++ tools/tests/implementation-workflow.test.mjs | 14 ++- 7 files changed, 182 insertions(+), 8 deletions(-) diff --git a/.github/workflows/issue-implementation.lock.yml b/.github/workflows/issue-implementation.lock.yml index 4c043b81..33081eb1 100644 --- a/.github/workflows/issue-implementation.lock.yml +++ b/.github/workflows/issue-implementation.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"de9c41591ec86a9ea59847b6e7b5b21b3881f3fd039733b728f49bcde4f38d2d","body_hash":"0060d6357fc727d5a1c00f788d34d99a4a62f4cc2074c21d27d5fd8957464836","compiler_version":"v0.93.5","strict":true,"agent_id":"copilot","agent_model":"gpt-6.1-sol","detection_agent_id":"copilot","engine_versions":{"copilot":"1.0.101"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"00b308bbd06174a8c66a601f6c2cfecc2e33e1d2401866553960c148173e5fc8","body_hash":"0060d6357fc727d5a1c00f788d34d99a4a62f4cc2074c21d27d5fd8957464836","compiler_version":"v0.93.5","strict":true,"agent_id":"copilot","agent_model":"gpt-6.1-sol","detection_agent_id":"copilot","engine_versions":{"copilot":"1.0.101"}} # gh-aw-manifest: {"version":1,"secrets":["DEPENDABOT_APP_PRIVATE_KEY","GH_AW_DEFAULT_OTLP_ENDPOINT","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/checkout","sha":"d23441a48e516b6c34aea4fa41551a30e30af803","version":"d23441a48e516b6c34aea4fa41551a30e30af803"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"9000827ccba6bdab643e8b6fd33ac0654aef8333"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"3a2844b7e9c422d3c10d287c895573f7108da1b3"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"cf430e030ddbb5b0abf93d22962f4752f3646cd9"},{"repo":"github/gh-aw/actions/setup","sha":"32ecafbc061c9af57e9361942099e381102ae304","version":"32ecafbc061c9af57e9361942099e381102ae304"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.28.70","digest":"sha256:b15ab48cbbab02904eb9bbd359a398db59690eebbea1e6934d47ed2bb407dd34","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.28.70@sha256:b15ab48cbbab02904eb9bbd359a398db59690eebbea1e6934d47ed2bb407dd34"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.70","digest":"sha256:9ac8f9c7294e892c916de3da9d2588dfd8cd4931e5c39b00143266d7ed9fd52a","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.70@sha256:9ac8f9c7294e892c916de3da9d2588dfd8cd4931e5c39b00143266d7ed9fd52a"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.28.70","digest":"sha256:b5bc53f4becfd96e926e63c83831f1b3c9512f713c83161d2b8c9b7204b3e917","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.28.70@sha256:b5bc53f4becfd96e926e63c83831f1b3c9512f713c83161d2b8c9b7204b3e917"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.37","digest":"sha256:9c7f242f6dec2d7d7b55d4c9e07872d59b85377c6cb3de46c915a5d1ffb91442","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.37@sha256:9c7f242f6dec2d7d7b55d4c9e07872d59b85377c6cb3de46c915a5d1ffb91442"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:23746305eeded20dc2726ab18bb081962d66ee3b2e09a54291afd1869ab3ef6d","pinned_image":"ghcr.io/github/gh-aw-node@sha256:23746305eeded20dc2726ab18bb081962d66ee3b2e09a54291afd1869ab3ef6d"}],"mcp_servers":[{"name":"safeoutputs","tools":["noop","report_incomplete","report_missing_data"]}],"threat_detection":{"mode":"enabled"},"admission":false} # This file was automatically generated by gh-aw (v0.93.5). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md # @@ -105,6 +105,8 @@ jobs: permissions: actions: read contents: read + issues: write + pull-requests: write env: GH_AW_MAX_DAILY_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS || '5000' }} GH_AW_RUNTIME_FEATURES: ${{ vars.GH_AW_RUNTIME_FEATURES }} @@ -231,6 +233,21 @@ jobs: overwrite: true if-no-files-found: ignore retention-days: ${{ vars.GH_AW_DEFAULT_ARTIFACT_RETENTION_DAYS || '3' }} + - name: Add rocket reaction for immediate feedback + id: react + if: github.event_name == 'issues' || github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment' || github.event_name == 'discussion' || github.event_name == 'discussion_comment' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.id == github.repository_id + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + GH_AW_REACTION: "rocket" + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const path = require('path'); + const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions'); + const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs')); + setupGlobals(core, github, context, exec, io, getOctokit); + const { main } = require(path.join(actionsDir, 'add_reaction.cjs')); + await main(); - name: Check for OAuth tokens id: check-oauth-tokens run: bash "${RUNNER_TEMP}/gh-aw/actions/check_oauth_tokens.sh" diff --git a/.github/workflows/issue-implementation.md b/.github/workflows/issue-implementation.md index c77fb14d..f9658032 100644 --- a/.github/workflows/issue-implementation.md +++ b/.github/workflows/issue-implementation.md @@ -17,7 +17,7 @@ on: type: string roles: [admin, maintain, write] github-token: ${{ secrets.GITHUB_TOKEN }} - reaction: none + reaction: rocket status-comment: false if: &owner_request >- github.repository == 'microsoft/TypeChat' && diff --git a/AUTOMATION.md b/AUTOMATION.md index 43385f58..00ce17ac 100644 --- a/AUTOMATION.md +++ b/AUTOMATION.md @@ -639,6 +639,19 @@ the original draft command, approval, completed successful producer, unchanged policy and discussion, referenced PR revisions, and exact acceptance hash before posting one top-level **Accepted work** comment. +After confirming that exact record, the publisher adds a thumbs-up reaction to +the owner's `/typechat accept` comment, on either an Issue or a Discussion. +The reaction confirms recorded acceptance, not merely receipt of the command. +Rejected approvals and unconfirmed publication outcomes do not receive it. +An unchanged, already-published record can also confirm a subsequent valid +approval command without creating another acceptance comment. + +Reaction failures are reported separately from the already-recorded decision. +A valid publisher retry can restore the reaction without editing or reposting +accepted work. Reaction requests are idempotent, and reactions do not change +the frozen discussion evidence. The existing target-scoped publisher credentials +are reused; the acceptance record, not the reaction alone, remains authoritative. + The conversational response and acceptance record have different hashes and publication markers. A response publish command cannot accept work; an accept command cannot use the response hash. A direct-reply artifact cannot be accepted. @@ -880,7 +893,7 @@ decisions should be clear and visible. ## Third pilot: owner-triggered Issue implementation -**Prepared for review; disabled and not live-verified.** The +**Default-off; successful automated PR publication is not yet live-verified.** The [accepted agreement for #504](https://github.com/microsoft/TypeChat/issues/504#issuecomment-6562465109) authorizes development of this workflow, not an automated coding run. The new [workflow](./.github/workflows/issue-implementation.md) requires @@ -899,6 +912,24 @@ command with the same hash, is supported. Ordinary manual acceptance remains valid human governance but is not machine-readable authority for this pilot. Discussion builds and inline notes remain unsupported; #502 is still deferred. +The native rocket reaction acknowledges startup for an eligible owner build +command. It does not mean that agreement validation, App preflight, generation, +or tests have passed. Manual command preparation does not add a reaction or +authorize execution. Only trusted activation receives reaction-write permissions; +the pinned compiler also grants `pull-requests: write` for the shared +`issue_comment` event, while the owner guard continues to reject PR comments. +The coding agent, detector, and generated checks retain read-only repository access. +No start comment is posted. + +The owner-authorized [live run](https://github.com/microsoft/TypeChat/actions/runs/41493733655) +exercised App preflight, generation, full-patch threat detection, and isolated +checks. The Python suite passed 107 runtime tests with 3 skipped, but failed +strict Pyright checks on three partially unknown types. Publication was correctly +blocked, and the temporary activation flag was removed. Native usage was +50.71891 coding credits plus 10.53936 detection credits. This verifies rejection +of a failing candidate, not successful automated PR creation. Manual recovery +of that candidate does not change the failed run's outcome. + ### Frozen authorization and bounded spending Preflight verifies owner identity, default-branch workflow code, the current diff --git a/OWNER-CHEATSHEET.md b/OWNER-CHEATSHEET.md index d26922f8..fbbdd5db 100644 --- a/OWNER-CHEATSHEET.md +++ b/OWNER-CHEATSHEET.md @@ -130,6 +130,12 @@ separate check.** This is a real scope decision, not a test acknowledgment. 4. Follow **Publish approved response or work acceptance** to the **Accepted work** comment. Confirm it records the terms you approved. +After acknowledgment rollout, a thumbs-up on your command confirms that the +exact acceptance was recorded; it is not an acknowledgment of merely receiving +the command. This works for both Issues and Discussions. If the reaction fails +after recording acceptance, inspect the publisher's error before retrying the +still-valid command. An unchanged confirmed record is not posted twice. + Use the acceptance hash, not the conversational reply's publish hash. A `/typechat reply` artifact cannot be accepted. Publishing a response first changes the context; request a fresh draft before accepting rather than reusing it. @@ -187,8 +193,10 @@ yet. After review and merge, and a separate decision to activate: variable `TYPECHAT_IMPLEMENTATION_ENABLED=true`, then post the generated `/typechat build :` as a fresh Issue comment. This authorizes one run with **1,000 main credits plus 400 detection credits**. -4. Follow Actions, then the resulting PR. Build commands do not add an eyes/start - comment. The PR links the agreement, exact patch origin, checks, usage, and +4. Follow Actions, then the resulting PR. After acknowledgment rollout, a rocket + reaction on the build command acknowledges startup, not successful validation + or completion. No start comment is posted. The PR links the agreement, + exact patch origin, checks, usage, and limitations. Verify normal PR CI and Copilot review actually ran before review and any separate merge decision. diff --git a/tools/discussion-draft.mjs b/tools/discussion-draft.mjs index afd1003a..9e07f1e7 100644 --- a/tools/discussion-draft.mjs +++ b/tools/discussion-draft.mjs @@ -957,6 +957,7 @@ export async function checkPublication(github, context, env, bundle, clock = () const publication = await identifyPublication(github, context, env, clock); const { existing } = await verifyBundleContext(github, publication, bundle); if (existing) { + await acknowledgeAcceptance(github, publication.request); return { shouldPost: false, url: existing.url }; } const prior = await priorIntent(github, publicationIntentName(publication)); @@ -977,6 +978,7 @@ export async function publishDraft(github, context, env, bundle, intentId, clock const publication = await identifyPublication(github, context, env, clock); const { existing } = await verifyBundleContext(github, publication, bundle); if (existing) { + await acknowledgeAcceptance(github, publication.request); return { posted: false, url: existing.url, bodyHash: digest(existing.body) }; } const intent = (await github.rest.actions.getArtifact({ ...API_REPO, artifact_id: integer(Number(intentId), "Missing durable publication intent.") })).data; @@ -991,14 +993,36 @@ export async function publishDraft(github, context, env, bundle, intentId, clock const latest = await identifyPublication(github, context, env, clock); const rechecked = await verifyBundleContext(github, latest, bundle); if (rechecked.existing) { + await acknowledgeAcceptance(github, latest.request); return { posted: false, url: rechecked.existing.url, bodyHash: digest(rechecked.existing.body) }; } await verifyCommand(github, latest.request); const content = publicationContent(bundle, latest.request.command.action); const comment = await writeDiscussionComment(github, bundle.target, content.body); + await acknowledgeAcceptance(github, latest.request); return { posted: true, id: comment.id, url: comment.url, bodyHash: content.bodyHash }; } +async function acknowledgeAcceptance(github, request) { + if (request.command.action !== "accept") { + return; + } + await verifyCommand(github, request); + try { + const result = await github.graphql(`mutation DiscussionPilotAcceptReaction($id:ID!) { + addReaction(input:{subjectId:$id,content:THUMBS_UP}) { + subject { ... on Node { id } } + reaction { content } + } + }`, { id: request.commentId }); + requireValue(result.addReaction?.subject?.id === request.commentId && + result.addReaction?.reaction?.content === "THUMBS_UP", "The reaction response does not confirm the target and content."); + } catch (error) { + throw new Error("Acceptance is recorded, but its confirmation reaction failed. Inspect the command before retrying; do not recreate accepted work.", + { cause: error }); + } +} + async function writeDiscussionComment(github, target, body, existing = null) { const commentId = existing && target.kind === "issue" ? integer(Number(existing.url.split("#issuecomment-")[1]), "Invalid receipt comment URL.") : null; diff --git a/tools/tests/discussion-draft.test.mjs b/tools/tests/discussion-draft.test.mjs index 6b1f3860..b027877b 100644 --- a/tools/tests/discussion-draft.test.mjs +++ b/tools/tests/discussion-draft.test.mjs @@ -109,6 +109,7 @@ function setup(kind = "issue") { }, historyRequests: [], posts: [], references: new Map(), comment, postError: null, persistBeforeError: false, onHistory: null, + reactions: new Set(), reactionError: null, reactionResponse: null, }; function event(action = "draft", body = "/typechat draft", commentId = "request", runId = 100, attempt = 1) { const currentComment = comment(commentId, body); @@ -199,6 +200,21 @@ function setup(kind = "issue") { assert.ok(!query.includes("replyToId"), "Discussion publication is top-level"); return { addDiscussionComment: { comment: await post(variables.body) } }; } + if (query.includes("DiscussionPilotAcceptReaction")) { + const command = comments.get(variables.id); + assert.equal(command?.author.login, OWNER.login); + assert.match(command.body, /^\/typechat accept /); + assert.match(query, /content:THUMBS_UP/); + assert.ok(thread.comments.some(item => item.author.id === ACTIONS_BOT_ID && + item.body.startsWith("## Accepted work\n")), "A reaction must follow a confirmed acceptance"); + if (state.reactionError) { + throw state.reactionError; + } + state.reactions.add(variables.id); + return state.reactionResponse ?? { + addReaction: { subject: { id: variables.id }, reaction: { content: "THUMBS_UP" } }, + }; + } throw new Error("Unexpected GraphQL operation in the test."); }, rest: { @@ -965,18 +981,22 @@ for (const kind of ["issue", "discussion"]) { assert.ok(bundle.acceptance.body.includes(`${REPO_URL}/blob/${SHA}/GOALS.md`)); assert.equal(fixture.state.posts.length, 0, "A sealed proposal is not acceptance"); const id = await reserve(fixture); + assert.equal(fixture.state.reactions.size, 0, "Approval and reservation alone are not confirmed acceptance"); assert.equal(fixture.state.artifacts.get(id).name, `${INTENT_PREFIX}accept-500`); const result = await publishDraft(fixture.github, fixture.publication.context, fixture.publication.env, bundle, id, clock); assert.equal(result.posted, true); assert.equal(result.bodyHash, bundle.acceptance.bodyHash); assert.deepEqual(fixture.state.posts, [bundle.acceptance.body]); + assert.deepEqual([...fixture.state.reactions], ["approval"]); const repeated = await publishDraft(fixture.github, fixture.publication.context, fixture.publication.env, bundle, id, clock); assert.equal(repeated.posted, false); assert.equal(repeated.bodyHash, bundle.acceptance.bodyHash); + assert.deepEqual([...fixture.state.reactions], ["approval"]); const anotherApproval = fixture.event("accept", `/typechat accept 500:${bundle.acceptance.bodyHash}`, "another-approval", 201); const checked = await checkPublication(fixture.github, anotherApproval.context, anotherApproval.env, bundle, clock); assert.deepEqual(checked, { shouldPost: false, url: result.url }); assert.equal(fixture.state.posts.length, 1); + assert.deepEqual([...fixture.state.reactions], ["approval", "another-approval"]); }); test(`${kind}: publishing a draft with a proposal still does not accept work`, async () => { @@ -984,6 +1004,7 @@ for (const kind of ["issue", "discussion"]) { const id = await reserve(fixture); await publishDraft(fixture.github, fixture.publication.context, fixture.publication.env, fixture.bundle, id, clock); assert.deepEqual(fixture.state.posts, [fixture.bundle.body]); + assert.equal(fixture.state.reactions.size, 0); assert.ok(!fixture.state.posts[0].includes("typechat-work-acceptance:")); const acceptance = fixture.event("accept", `/typechat accept 500:${fixture.bundle.acceptance.bodyHash}`, "acceptance", 201); await assert.rejects(() => checkPublication(fixture.github, acceptance.context, acceptance.env, fixture.bundle, clock), @@ -992,6 +1013,67 @@ for (const kind of ["issue", "discussion"]) { }); } +test("acceptance reaction failures recover without duplicating or editing accepted work", async () => { + for (const kind of ["issue", "discussion"]) { + const fixture = await readyAcceptance(kind); + const id = await reserve(fixture); + fixture.state.reactionError = new Error("Reaction service unavailable"); + await assert.rejects(() => publishDraft(fixture.github, fixture.publication.context, fixture.publication.env, + fixture.bundle, id, clock), /Acceptance is recorded, but its confirmation reaction failed/); + assert.deepEqual(fixture.state.posts, [fixture.bundle.acceptance.body]); + assert.equal(fixture.state.reactions.size, 0); + const accepted = fixture.state.thread.comments.find(comment => comment.author.id === ACTIONS_BOT_ID); + const before = structuredClone(accepted); + fixture.state.reactionError = null; + const checked = await checkPublication(fixture.github, fixture.publication.context, fixture.publication.env, + fixture.bundle, clock); + assert.deepEqual(checked, { shouldPost: false, url: accepted.url }); + assert.deepEqual(accepted, before); + assert.deepEqual([...fixture.state.reactions], ["approval"]); + const repeated = await publishDraft(fixture.github, fixture.publication.context, fixture.publication.env, + fixture.bundle, id, clock); + assert.equal(repeated.posted, false); + assert.equal(fixture.state.posts.length, 1); + assert.equal(fixture.state.reactions.size, 1); + } +}); + +test("acceptance confirmation verifies the reaction target and content", async () => { + for (const response of [ + {}, + { addReaction: { subject: { id: "another-comment" }, reaction: { content: "THUMBS_UP" } } }, + { addReaction: { subject: { id: "approval" }, reaction: { content: "ROCKET" } } }, + ]) { + const fixture = await readyAcceptance(); + const id = await reserve(fixture); + fixture.state.reactionResponse = response; + await assert.rejects(() => publishDraft(fixture.github, fixture.publication.context, fixture.publication.env, + fixture.bundle, id, clock), /Acceptance is recorded, but its confirmation reaction failed/); + assert.equal(fixture.state.posts.length, 1); + fixture.state.reactionResponse = null; + assert.equal((await checkPublication(fixture.github, fixture.publication.context, fixture.publication.env, + fixture.bundle, clock)).shouldPost, false); + assert.equal(fixture.state.posts.length, 1); + } +}); + +test("an acceptance confirmed during the final write recheck acknowledges without another post", async () => { + const fixture = await readyAcceptance(); + const id = await reserve(fixture); + fixture.state.onHistory = () => { + fixture.state.onHistory = null; + const existing = fixture.state.comment("concurrent-record", fixture.bundle.acceptance.body, "github-actions", "Bot"); + existing.url = `${fixture.state.target.url}#issuecomment-10001`; + fixture.state.thread.comments.push(existing); + fixture.state.comments.set(existing.id, existing); + }; + const result = await publishDraft(fixture.github, fixture.publication.context, fixture.publication.env, + fixture.bundle, id, clock); + assert.equal(result.posted, false); + assert.equal(fixture.state.posts.length, 0); + assert.deepEqual([...fixture.state.reactions], ["approval"]); +}); + test("response and acceptance approval hashes cannot be exchanged", async () => { for (const action of ["publish", "accept"]) { const fixture = await readyAcceptance(); @@ -1000,6 +1082,7 @@ test("response and acceptance approval hashes cannot be exchanged", async () => await assert.rejects(() => checkPublication(fixture.github, approval.context, approval.env, fixture.bundle, clock), /exact rendered draft/); assert.equal(fixture.state.posts.length, 0); + assert.equal(fixture.state.reactions.size, 0); } }); @@ -1035,6 +1118,7 @@ test("acceptance requires the owner and the target-scoped default-branch manual await assert.rejects(() => checkPublication(fixture.github, fixture.publication.context, fixture.publication.env, fixture.bundle, clock)); assert.equal(fixture.state.posts.length, 0); + assert.equal(fixture.state.reactions.size, 0); } }); @@ -1067,9 +1151,11 @@ test("acceptance retries retain uncertain-write protection and never recreate ed fixture.state.persistBeforeError = persisted; await assert.rejects(() => publishDraft(fixture.github, fixture.publication.context, fixture.publication.env, fixture.bundle, id, clock), /outcome is uncertain/); + assert.equal(fixture.state.reactions.size, 0); if (persisted) { const existing = await checkPublication(fixture.github, fixture.publication.context, fixture.publication.env, fixture.bundle, clock); assert.equal(existing.shouldPost, false); + assert.deepEqual([...fixture.state.reactions], ["approval"]); fixture.state.thread.comments.find(comment => comment.author.__typename === "Bot").body += "Edited terms"; await assert.rejects(() => checkPublication(fixture.github, fixture.publication.context, fixture.publication.env, fixture.bundle, clock), /different content/); diff --git a/tools/tests/implementation-workflow.test.mjs b/tools/tests/implementation-workflow.test.mjs index 572b8dcf..7bd0f077 100644 --- a/tools/tests/implementation-workflow.test.mjs +++ b/tools/tests/implementation-workflow.test.mjs @@ -16,7 +16,7 @@ const ci = parse(fs.readFileSync(new URL("agent-workflow-check.yml", workflows), test("coding is inactive by default and only an owner Issue comment can activate inference", () => { assert.deepEqual(Object.keys(source.on.workflow_dispatch.inputs), ["issue", "acceptance"]); - assert.equal(source.on.reaction, "none"); + assert.equal(source.on.reaction, "rocket"); assert.equal(source.on["status-comment"], false); assert.match(source.if, /TYPECHAT_IMPLEMENTATION_ENABLED == 'true'/); assert.match(source.if, /!github\.event\.issue\.pull_request/); @@ -91,15 +91,23 @@ test("failed prerequisites cannot authorize detector inference", () => { assert.equal(job.env.COPILOT_GITHUB_TOKEN, undefined); }); -test("App secrets exist only in trusted preflight and publication steps, never coding, detection, or generated checks", () => { +test("only trusted activation can acknowledge commands; App secrets remain confined to preflight and publication", () => { assert.deepEqual(compiled.permissions, {}); for (const [id, job] of Object.entries(compiled.jobs)) { const serialized = JSON.stringify(job); if (!["prepare", "publish"].includes(id)) assert.ok(!serialized.includes("DEPENDABOT_APP_PRIVATE_KEY"), id); for (const [permission, value] of Object.entries(job.permissions ?? {})) { - assert.ok(value === "read" || permission === "copilot-requests" && ["agent", "detection"].includes(id) && value === "write", + const reactionPermission = id === "activation" && ["issues", "pull-requests"].includes(permission); + assert.ok(value === "read" || value === "write" && + (reactionPermission || permission === "copilot-requests" && ["agent", "detection"].includes(id)), `${id} must not receive repository-write authority: ${permission}:${value}`); } + assert.deepEqual(Object.entries(compiled.jobs.activation.permissions).filter(([, value]) => value === "write"), + [["issues", "write"], ["pull-requests", "write"]]); + const reaction = compiled.jobs.activation.steps.find(step => step.id === "react"); + assert.equal(reaction.name, "Add rocket reaction for immediate feedback"); + assert.ok(!reaction.if.includes("workflow_dispatch")); + assert.equal(reaction.env.GH_AW_REACTION, "rocket"); for (const step of job.steps ?? []) { if (step.uses?.startsWith("actions/checkout@")) { assert.equal(step.with["persist-credentials"], false, `${id} must not retain Git credentials`);