Skip to content

Defer supported temporary targets before authorization - #79498

Merged
pelikhan merged 3 commits into
mainfrom
pelikhan/temporary-target-deferral
Nov 20, 2026
Merged

pelikhan merged 3 commits into
mainfrom
pelikhan/temporary-target-deferral

Conversation

@pelikhan

Copy link
Copy Markdown
Collaborator

Unresolved temporary targets accepted by the issue resolver could consume an allow decision before the handler deferred. This follow-up to #79482 fixes that pre-existing mismatch without changing the authorization protocol or snapshot-backed execution boundary.

Changes

  • Reuse the existing issue and discussion resolvers in the manager's pre-authorization guard, limiting detection to explicit target fields rather than arbitrary number/ID suffixes.
  • Cover canonical, uppercase, hash-prefixed uppercase, matching single/double quotes and surrounding whitespace across item_number, issue_number, pr_number and pull_number. The real remove-labels handler obtains exactly one decision after production and mutates only the literal expected repository/number; permanently unresolved targets consume none.
  • Add guard-level coverage for 14 other native handlers, malformed IDs and unrelated identities. Preserve the discussion resolver's rejection of quoted targets.
  • Clarify that the authorization snapshot is deep-frozen while handlers receive an independent, initially data-equivalent mutable message copy. Add a reusable safe-output-target-deferral skill.

Validation

The original guard reproduced five consumer-before-producer failures with one authority call before production, plus premature authorization for a permanently unresolved quoted target. The canonical control passed.

The focused manager-authorization, bound-temporary-ID and resolver suites pass: 228 tests. JavaScript typecheck, changed-file ESLint, formatting and the skill prefix check pass. The repository final gate initially encountered missing linter dependencies; after restoring them, the failed lint check passed. No Go files or workflow sources changed.

Coverage limits

Other native handlers have guard-level coverage, not exhaustive authorization-to-effect coverage. Custom executors and queue/Claim adapters remain outside the assessed scope. No new hashes, configuration, authorization service or effect framework; snapshot-backed map and per-invocation cache refreshes remain unchanged.

Reuse target resolvers at the manager guard, cover accepted variants across native consumers, clarify the mutable handler copy, and add a reusable deferral skill.

Co-authored-by: Copilot App <[email protected]>
@pelikhan
pelikhan marked this pull request as ready for review November 20, 2026 10:31
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 10:31

Copilot AI 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.

🟡 Changes recommended

Temporary-ID handling regressions cause indefinite deferrals, prevent retries for project updates, and reject valid cross-repository targets.

5 open issues
What changed in this PR

This follow-up to #79482 updates safe-output target detection so supported unresolved temporary targets defer before authorization, while preserving invocation binding and snapshot-backed execution.

Changes:

  • Reuse existing target resolvers and replace suffix-based detection with explicit target fields.
  • Expand regression coverage for accepted spellings, aliases, deferred execution, malformed IDs and unrelated fields.
  • Clarify handler-input mutability and add reusable target-deferral guidance.
File Description
docs/​src/​content/​docs/​specs/​safe-outputs-specification.md Clarifies snapshot immutability, mutable handler messages and target deferral.
actions/​setup/​js/​safe_output_handler_manager.cjs Uses existing resolvers to detect unresolved targets before authorization.
actions/​setup/​js/​safe_output_handler_manager_authorization.test.cjs Adds guard-level and real-handler authorization regressions.
.github/​skills/​safe-output-target-deferral/​SKILL.md Documents deferral contracts, investigation steps and validation guidance.

Review effort: Max (adaptive)

/** @type {Set<string>} Project-safe-output handlers that should default to GH_AW_PROJECT_GITHUB_TOKEN when no per-handler github-token is configured. */
const PROJECT_HANDLER_TYPES = new Set(["create_project", "create_project_status_update", "update_project"]);
const MENTION_HANDLER_TYPES = new Set(["add_comment", "close_discussion", "create_discussion", "create_issue", "create_pull_request", "create_pull_request_review_comment", "reply_to_pull_request_review_comment"]);
const TEMPORARY_TARGET_FIELDS = new Set(["item_number", "issue_number", "pr_number", "pull_number", "pull_request_number", "pr-number", "parent_issue_number", "sub_issue_number", "discussion_number", "content_number"]);

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.

Fixed in cfc1de8. The guard now defers a valid unresolved draft_issue_id when no title fallback is available, using the existing draftItemId mapping; consumer-before-producer coverage was added.

Comment on lines 1274 to 1275
// Targets that are still temporary cannot consume an authority decision.
for (const [key, value] of Object.entries(message)) {

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.

Fixed in cfc1de8. The guard follows update_project's effective content_number/contentNumber > issue > pull_request precedence and ignores those fields in draft_issue mode; alias regressions were added.

if (typeof value !== "string" || !/(?:number|_id)$/.test(key) || key === "temporary_id" || key === "output_id") continue;
if (/^#?aw_[A-Za-z0-9_]+$/.test(value) && !temporaryIdMap.has(normalizeTemporaryId(value))) {
if (typeof value !== "string" || !TEMPORARY_TARGET_FIELDS.has(key)) continue;
const target = key === "discussion_number" ? resolveNumberFromTemporaryId(value, resolvedTemporaryIds) : resolveIssueNumber(value, temporaryIdMap);

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.

Fixed in cfc1de8. merge_pull_request.pull_request_number now uses resolveNumberFromTemporaryId in the guard, preserving the handler's rejection of quoted targets instead of deferring them.

Comment on lines +1277 to +1278
const target = key === "discussion_number" ? resolveNumberFromTemporaryId(value, resolvedTemporaryIds) : resolveIssueNumber(value, temporaryIdMap);
if (target.wasTemporaryId && !target.resolved) {

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.

Fixed in cfc1de8. Recognized effective temporary targets remain intact for the snapshot-bound native resolver instead of being rewritten as body-text repository/number strings; cross-repository resolver coverage was added.

Comment on lines +1276 to +1278
if (typeof value !== "string" || !TEMPORARY_TARGET_FIELDS.has(key)) continue;
const target = key === "discussion_number" ? resolveNumberFromTemporaryId(value, resolvedTemporaryIds) : resolveIssueNumber(value, temporaryIdMap);
if (target.wasTemporaryId && !target.resolved) {

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.

Fixed in cfc1de8. The guard checks only effective targets, respecting wildcard alias precedence and configured parent selection; regressions cover ignored remove_labels and link_sub_issue fields.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/safe_output_handler_manager.cjs:166): address unresolved feedback - Review comment
  3. Review (actions/setup/js/safe_output_handler_manager.cjs:1275): address unresolved feedback - Review comment
  4. Review (actions/setup/js/safe_output_handler_manager.cjs:1277): address unresolved feedback - Review comment
  5. Review (actions/setup/js/safe_output_handler_manager.cjs:1278): address unresolved feedback - Review comment
  6. Review (actions/setup/js/safe_output_handler_manager.cjs:1278): address unresolved feedback - Review comment
  7. Fix failing check Analyze (python) (FAILURE): Check run.
  8. Fix failing check prefetch (FAILURE): Check run.

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "e30bfce8b2506708885b659a44333be36a38a8a6",
  "kind": "requested",
  "schema_version": "1",
  "state": "f9ee6dc26f6dcc0003641a92c57814729eaf24d7391a6e0ffd7994a35e0bda77",
  "work": [
    "23027a7a3ebe972cffc3eabad4a22e44dac70312f0e8b312d61f867187f7f01d",
    "3d63b100a8a02eec93a50a1ce2eb6adb12851120ace9470e7100dabca2616edb",
    "43282e7f5b3023b8c8cf9099eab79e7b99f650965f08b47d3df33cde5589879d",
    "527a2f09f2ef6206ba1bf3012b5c6c5a04280157c5b7a19bb0475c5dddb8e25d",
    "52b4439d964c2fb3c6c3a5830f072f28abd3ce8f0fa9d191354747f3bfb53b4f",
    "660689bfe433762235cb5831afe1ff78e2258be888b99e773d8f1112d0e24817",
    "ad80fc8e9dbede03337726bec209112a7e5133c55b246116a76c3f9170a64f8b"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 20, 2026 11:24

Copilot AI commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Completed in cfc1de8; the latest-main merge is 1bd228c. The five target-handling findings are fixed with regression coverage. Analyze (python) and prefetch failed with GitHub App installation API rate-limit 403s in their logs, not code defects; no workflow rerun or dispatch was made.

Copilot AI requested a review from gh-aw-bot November 20, 2026 11:43
@pelikhan
pelikhan merged commit e86a3a7 into main Nov 20, 2026
68 checks passed
@pelikhan
pelikhan deleted the pelikhan/temporary-target-deferral branch November 20, 2026 15:02
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