Skip to content

Keep prompt runs to the actor's own comments and the step's output files in place - #2098

Merged
mhegazy merged 2 commits into
mainfrom
claude/project-thread-a0vw5a
Nov 18, 2026
Merged

mhegazy merged 2 commits into
mainfrom
claude/project-thread-a0vw5a

Conversation

@mhegazy

@mhegazy mhegazy commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Human: @mhegazy

Requested by Mohamed · project thread

Two small changes, one commit each.

Prompt runs and other people's comments. docs/security.md says that editing or deleting another person's comment or review doesn't start a run, even with a prompt. That held with track_progress only. It now holds for every prompt run on comment and review events. Deleting your own comment doesn't start one either, as in tag mode. Dismissing your own review still does, in both modes.

  • New comments and reviews run as before, including those of an app whose author login differs from the actor.
  • Without track_progress, label_trigger and assignee_trigger still don't apply to prompt runs, and prompts on other events are unchanged.

Output files after the session. GITHUB_OUTPUT and GITHUB_STEP_SUMMARY keep what a session writes to them. If one is no longer a plain file of its own when the session ends, the file from before the session is put back and the action logs a warning, as it already does for GITHUB_ENV and GITHUB_PATH.

Upgrading: a workflow with a prompt that listens to edited, deleted or dismissed events no longer runs when someone edits or dismisses another person's comment or review, or when a comment is deleted. The step succeeds without starting Claude.

Testing: the full suite passes (1,448 tests), including runs of run.ts against a stand-in GitHub. The output file change was also run end to end on Linux with a mock GitHub and a scripted model. Not run on a GitHub-hosted runner.


Generated by Claude Code

claude and others added 2 commits November 18, 2026 06:06
… deleted

docs/security.md says that editing or deleting another person's comment or review
doesn't start a run, even with a prompt. That held with track_progress only. It now
holds for every prompt. New comments and reviews run as before, and label_trigger
still doesn't apply to prompts without track_progress.

Co-authored-by: mhegazy <mhegazy@anthropic.com>
GITHUB_OUTPUT and GITHUB_STEP_SUMMARY keep what a session writes to them, but a link
put in their place is replaced by the file from before the session, because the action
adds to them afterwards.

Co-authored-by: mhegazy <mhegazy@anthropic.com>
@mhegazy mhegazy self-assigned this Nov 18, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Beyond the inline findings, I also checked two points and found no problem with either:

  • The docs line "deleting any comment does not start a run" matches the code. isTextFromActor in src/github/validation/trigger.ts returns false for every deleted comment event whoever wrote it, so isModeration also stops a prompt run when the actor deletes their own comment.
  • In filesLaterStepsTrust in src/github/operations/session-guard.ts, the GITHUB_ENV, GITHUB_PATH and git config entries are listed before the output files. An output path that resolves to one of those is therefore still fully restored and does not keep session writes.
Extended reasoning...

The change touches the trigger gate for prompt runs (src/github/validation/trigger.ts, src/entrypoints/run.ts) and the post-session file restore (src/github/operations/session-guard.ts), both security-sensitive, so a human should still review it alongside the inline findings. The two points in the body were checked by reading the code only; no tests were run in this review.

Additional findings (outside the current diff — GitHub can't attach inline comments there):

  • 🟣 src/github/operations/session-guard.ts — Pre-existing, security: a session can still leave a symlink at GITHUB_OUTPUT, so the action's later outputs land in GITHUB_PATH or GITHUB_ENV. The restore removes the link with rmSync at src/github/operations/session-guard.ts:251. If the session removed write permission from the folder holding the file, that call throws and the catch at :256 only warns. The action then appends through the link at src/entrypoints/run.ts:441. Fix: when a keepsWrites file cannot be put back, stop writing through it, e.g. delete process.env.GITHUB_OUTPUT and GITHUB_STEP_SUMMARY for the rest of the process or fail the step. (Finding ID: f-5825fa47)

    Why this was flagged

    A session with Bash replaces GITHUB_OUTPUT with a symlink to GITHUB_PATH, then runs chmod a-w on the folder holding both, which the non-root runner user owns. At restore, isItsOwnFile returns false (session-guard.ts:210) and the loop reaches rmSync at :251, which throws EACCES. The catch at :256-260 logs "Could not restore GITHUB_OUTPUT after the session (EACCES)" and continues. run.ts:441, :449-457 and :514-515 then call core.setOutput, which appends through the link, so lines such as false and success become PATH entries for later steps. The base does not track GITHUB_OUTPUT at all, so this is not a regression, and the same failed restore keeps session writes in GITHUB_ENV on the base. The doc comment at :222 excludes code that stops the action, but here the action keeps running and writes. Not checked: whether the runner can start later steps while that folder is read-only.

    Verification: Triggers when the session can run shell commands that create a link and chmod a-w the runner's file-commands folder, on a non-root runner. rmSync at src/github/operations/session-guard.ts:251 throws EACCES and the catch at :256-260 only warns. src/entrypoints/run.ts then writes through it at :441. On the base commit, filesLaterStepsTrust did not track GITHUB_OUTPUT at all.

Comment on lines +44 to +47
export function isModeration(context: ParsedGitHubContext): boolean {
const isNew =
context.eventAction === "created" || context.eventAction === "submitted";
return !isNew && !isTextFromActor(context);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 (optional) Workflows with a prompt may silently stop running when an app edits its own comment or review, if the app's author login differs from the actor. isModeration at src/github/validation/trigger.ts:47 exempts only created and submitted from the login comparison. On edited, such an app's own edit fails isSameLogin and the step skips. Fix: an edit made by the account that wrote the text must not count as moderation for these apps either, for example by also accepting a match against the event's sender.login, while still skipping edits made by anyone else.

Why this was flagged

Condition I could not confirm from this checkout: an app whose comment or review author login differs from GITHUB_ACTOR on edited events; the doc comment at src/github/validation/trigger.ts:41-42 says such apps exist and src/github/validation/actor.ts:47 names Copilot with GITHUB_ACTOR="Copilot". The workflow sets prompt without track_progress, lists the app in allowed_bots, and listens to issue_comment, pull_request_review_comment or pull_request_review with edited. src/entrypoints/run.ts:255-256 calls isModeration; isNew is false, and isTextFromActor returns false at trigger.ts:24 or trigger.ts:31, so containsTrigger is false. The step logs "No trigger found, skipping remaining steps" (run.ts:262) and succeeds without starting Claude. On the base branch run.ts used !!context.inputs?.prompt, so the same event started a run. No safeguard applies: the exemption at trigger.ts:45-46 covers only new comments and reviews.

Verification: Triggers when an app whose comment/review author login differs from GITHUB_ACTOR edits its own comment or review, in a workflow that sets prompt. src/github/validation/trigger.ts:45-47: only new comments/reviews are exempt from the login comparison. Base: this event started a run. No test covers the same app on edited.

Finding ID: f-74ded994

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as it is. For an app whose author login differs from the actor, an edit can't be told from moderation by these two logins, so it is skipped, as it already is with track_progress. New comments and reviews from such an app still run.


Generated by Claude Code

Comment thread src/entrypoints/run.ts
Comment on lines +255 to +256
: !!context.inputs?.prompt &&
!(isEntityContext(context) && isModeration(context));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 (optional) Workflows with a prompt that react to a person editing an app's comment, such as ticking a task-list checkbox, silently stop running after upgrade. The step succeeds with no warning. isModeration (src/github/validation/trigger.ts:47) counts every edited event whose editor is not the comment author as moderation, and src/entrypoints/run.ts:256 then skips the run. Fix: make the skip visible to operators, for example a core.notice or core.warning naming the reason at run.ts:262, or add an opt-in for edits of app-authored comments. The only trace today is a console.log at trigger.ts:26.

Why this was flagged

A workflow uses on: issue_comment (which fires for created, edited and deleted by default) with a prompt and no track_progress, and a maintainer with write access edits a bot-authored comment, for example to tick a checkbox. detectMode returns "agent" at src/modes/detector.ts:41-42. On the base branch run.ts computed containsTrigger = !!context.inputs?.prompt, so the run started. Now isModeration at src/github/validation/trigger.ts:44-48 returns true because the action is edited and isSameLogin(comment.user.login, actor) fails at trigger.ts:24, so run.ts:261-264 logs "No trigger found, skipping remaining steps" and returns with a green step. The dismissal rested on the author stating this is intended; that does not size the consequence: the user gets a successful job that did nothing, with no annotation, and the only signal is two console.log lines (trigger.ts:26, run.ts:262). No safeguard or opt-out input exists for this population.

Verification: Triggering condition: a workflow with a prompt, no track_progress, listening to comment edited events, where a write-access user edits a comment authored by a different login. Base run.ts computed containsTrigger = ... : !!context.inputs?.prompt, so the run started. Head src/entrypoints/run.ts:255-256 adds && !(isEntityContext(context) && isModeration(context)). What is missing is a core.warning/core.notice annotation.

Finding ID: f-e7656a96

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as it is. The skip is the documented behavior and the description lists it under Upgrading. Workflows that listen to edited get many such events, so an annotation on each would be noisy.


Generated by Claude Code

Comment thread src/github/operations/session-guard.ts Resolved
Comment on lines +207 to +210
function isItsOwnFile(before: FileSnapshot): boolean {
try {
const stats = lstatSync(restorePath(before));
return stats.isFile() && stats.nlink <= (before.names ?? 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟣 pre-existing, not blocking: Pre-existing, security: a session can still redirect the action's later output writes into GITHUB_PATH or GITHUB_ENV when the output file already had two names. isItsOwnFile at src/github/operations/session-guard.ts:210 only compares link counts. A hard link to a trusted file that had one name has a count of 2, which passes when before.names is 2. Fix: accept a file with more than one name only when it is the same file as before, for example by recording dev and ino in the snapshot and comparing them when nlink > 1, while still keeping a replaced file that has a single name.
A small fix can ride a push you are already making; otherwise a short reply is enough.

Why this was flagged

Condition: GITHUB_OUTPUT or GITHUB_STEP_SUMMARY has 2 or more hard links before the session, the state the new test "keeps what a session wrote to a file that had a second name before" sets up, so names: stats.nlink at session-guard.ts:164 records 2. The session runs rm "$GITHUB_OUTPUT"; ln "$GITHUB_PATH" "$GITHUB_OUTPUT". GITHUB_PATH now has nlink 2, so stats.isFile() && stats.nlink <= (before.names ?? 1) at session-guard.ts:210 is true and the loop does continue at session-guard.ts:238 with no restore and no warning. GITHUB_PATH's own entry is skipped because its content is unchanged. The core.setOutput calls at src/entrypoints/run.ts:441-457, including the session-controlled structured_output at run.ts:455, are then appended into GITHUB_PATH, so a later step gets session-chosen PATH entries. The base branch does not track these two files at all, so it has the same exposure; the new guard does not close it in this state. No inode comparison exists to tell the original file from a different one with the same link count.

Verification: Pre-existing (security-relevant, does not block) — triggers when GITHUB_OUTPUT or GITHUB_STEP_SUMMARY already has 2+ hard links before the session and the trusted target has fewer names than that. In src/github/operations/session-guard.ts, line 210 compares counts only, so line 238 skips the restore and the warning. The hard-link tests at lines 191-219 only cover a file that had one name before. The base does not track GITHUB_OUTPUT or GITHUB_STEP_SUMMARY at all.

Finding ID: f-c238dce4

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this here. It needs an output file that already had a second name before the step, and the runner makes a fresh file for each step.


Generated by Claude Code

Comment on lines 244 to 246
if (before.state === "opaque") {
core.warning(
`Could not restore ${before.label} after the session: it was not a regular file before`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟣 pre-existing, not blocking: A session can still leave a symlink at GITHUB_OUTPUT or GITHUB_STEP_SUMMARY when that file could not be snapshotted before the session. At src/github/operations/session-guard.ts:244 an opaque before-state only logs a warning and continues, so the link stays. The action then appends its outputs through it at src/entrypoints/run.ts:441. Fix: for a keepsWrites file that is no longer its own file, remove what is at the path even when there is no saved content, and leave an empty file. The before-state is opaque when the file was over 64 MB or unreadable at snapshot time.
A small fix can ride a push you are already making; otherwise a short reply is enough.

Why this was flagged

If GITHUB_OUTPUT or GITHUB_STEP_SUMMARY is over MAX_SNAPSHOT_BYTES (session-guard.ts:34, :155) or cannot be opened when snapshotSessionFiles runs (run.ts:419), readSnapshot returns state "opaque" with no names. A session then replaces the file with a symlink to GITHUB_PATH or GITHUB_ENV. At restore, isItsOwnFile is false (:210) and leadsElsewhere is true (:240), but the opaque branch at :244-249 warns "Could not restore GITHUB_OUTPUT after the session: it was not a regular file before" and continues without removing the link. core.setOutput at run.ts:441 and :449-457, and appendFile at run.ts:159, then write through it. The base does not track these two files, so the result matches the base; the new guard does not hold for this state. I found no concrete trigger on a hosted runner, where each step gets a fresh, small file, so this depends on a runner setup I could not rule out.

Verification: Triggers when GITHUB_OUTPUT or GITHUB_STEP_SUMMARY is opaque at snapshot time and the session then swaps it for a symlink. In src/github/operations/session-guard.ts, lines 244-249 warn and continue, so the rmSync(path, ...) at line 251 is never reached and the symlink stays. The base does not track GITHUB_OUTPUT or GITHUB_STEP_SUMMARY at all. No test covers it.

Finding ID: f-9fe5a134

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this here. It needs an output file that could not be read, or was over 64 MB, before the session, and the runner makes a fresh, empty file for each step.


Generated by Claude Code

Comment thread src/github/validation/trigger.ts Resolved
Comment thread src/github/validation/trigger.ts Resolved
@mhegazy
mhegazy merged commit 5a85689 into main Nov 18, 2026
86 checks passed
@mhegazy
mhegazy deleted the claude/project-thread-a0vw5a branch November 18, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants