Skip to content

Fix Markdown-escaped temporary ID resolution in safe outputs - #75688

Merged
pelikhan merged 5 commits into
mainfrom
copilot/fix-temporary-id-resolution
Nov 7, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/fix-temporary-id-resolution

Conversation

Copilot AI commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Markdown rendering escapes temporary references such as \#aw\_track1, causing resolution and deferred-update detection to miss them.

  • Matching: Recognize escaped hashes and underscores across reference detection, dependency extraction, and replacement.
  • Resolution: Remove escapes when looking up IDs and emit issue references or resource URLs.
  • Preservation: Leave unresolved references and unrelated Markdown escapes unchanged; avoid resolving valid prefixes of malformed IDs.
  • Regression coverage: Cover escaped references and comments published before their temporary-ID producer.
\#aw\_track1 → github/gh-aw-firewall#123

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan November 7, 2026 14:23
@pelikhan
pelikhan marked this pull request as ready for review November 7, 2026 14:35
Copilot AI dynamic review requested due to automatic review settings November 7, 2026 14:35
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt56 max · ~3 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #75688

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Generated by PR Specification Reviewer for #75688

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Warning

Threat detection engine error

Threat detection could not complete its analysis due to a tooling error. This is not a security finding.

What happened

The threat detection results could not be parsed.

Review the workflow run logs to troubleshoot the error.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions github-actions 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.

Reviewed the changed temporary-ID matching and regression coverage. I found no merge-blocking correctness issues in the changed lines. Static review only; tests were not run per review constraints.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again

@github-actions github-actions 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.

Reviewed head 255ef84e2d088296d5249abf23246f871060ea22 against base 983d462a96bb14b1a78365698b7ba5c535a05317. The PR is aligned with its stated intent and preserves unresolved/malformed references, complete-token matching, and existing authorization/deferral behavior. No blocking contract violation found.

Applicable contract: docs/src/content/docs/specs/safe-outputs-specification.md v1.29.19, Section 7.1 item 2 (issue-body temporary-ID resolution), Section 7.3 item 5 (comment-memory rewrite), Section 4.2 Phase 8 item 5, and Stage 6. The implementation and added tests provide evidence for an intentional lexical expansion, but the contract should be synchronized.

Proposed update (not applied): bump version to 1.29.20, status Working Draft, publication date 2026-11-07, and add this changelog entry:

**Version 1.29.20** (2026-11-07):

- **Specified**: Temporary-ID resolution recognizes Markdown-escaped and partially escaped hashes and underscores across dependency extraction, unresolved detection, replacement, supported URL patch handling, and artifact/project URL replacement.
- **Specified**: Implementations remove only escapes immediately preceding `#` or `_` for lookup and output, preserve unrelated escapes, leave unresolved or malformed references unchanged, and reject valid-prefix matching.
- **Clarified**: Issue-body and comment-memory rewrites apply the same normalization and complete-identifier requirements before replacement or comment upsert.
- **Updated**: Publication metadata to 1.29.20.

Proposed normative replacement for the Temporary ID definition:

**Temporary ID**: A workflow-scoped placeholder identifier using the form `aw_<id>` for a not-yet-created resource. A temporary-ID reference MAY appear in ordinary Markdown form or with a Markdown escape immediately before `#`, `_`, or both (for example, `#aw_track1`, `\#aw_track1`, `#aw\_track1`, or `\#aw\_track1`). Implementations MUST remove only those backslash escapes immediately preceding `#` or `_` when normalizing a reference for lookup or emitted replacement. They MUST preserve unrelated backslash escapes. A valid temporary-ID candidate MUST match the complete identifier form; implementations MUST NOT match a valid prefix of a longer or malformed identifier.

Replace Section 7.1 item 2 with:

2. **Temporary ID Resolution**: References to temporary IDs in issue bodies MUST be recognized in ordinary Markdown form and in Markdown-escaped or partially escaped forms, including `#aw_track1`, `\#aw_track1`, `#aw\_track1`, and `\#aw\_track1`. Implementations MUST remove only backslash escapes immediately preceding `#` or `_` for lookup and replacement, then replace resolved references with the actual resource numbers. Unresolved references and malformed identifiers MUST remain unchanged. Implementations MUST require a complete valid identifier and MUST NOT replace a valid prefix within a longer or malformed identifier.

Replace Section 7.3 item 5 with:

5. **Temporary ID Rewrite**: If temporary IDs are resolved during processing, comment-memory content MUST recognize ordinary and Markdown-escaped or partially escaped references, remove only escapes immediately preceding `#` or `_` for lookup and output, and rewrite resolved references before final upsert. Unresolved references, malformed identifiers, and unrelated backslash escapes MUST remain unchanged; valid prefixes MUST NOT be rewritten.

Also update Phase 8 item 5 and Stage 6 with the same normalization, preservation, and complete-token requirements, while retaining the existing repository authorization checks and deferred-retry semantics. This is a synchronization proposal, not a security relaxation. Review was static; no tests or conformance scripts were run.

Generated by PR Specification Reviewer for #75688 · copilot · gpt50 · ~5 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review-specs to run again

* Markdown rendering may escape the hash and underscores; consume those escapes too.
*/
const TEMPORARY_ID_PATTERN = /#(aw_[A-Za-z0-9_]{3,12})\b/gi;
const TEMPORARY_ID_PATTERN = /\\?#(aw\\?_(?:[A-Za-z0-9]|\\?_){3,12})(?![A-Za-z0-9_-]|\\_)/gi;

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.

Specification synchronization is needed for this intentional lexical expansion. The current contract Section 7.1 item 2 and Section 7.3 item 5 only specify canonical #aw_<id> references, so they do not define the escaped and partially escaped forms implemented here. Please apply the exact proposed replacements and version/changelog update in the final review body; preserve the existing authorization and deferral requirements.

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.

Updated the specification to define ordinary, escaped, and partially escaped temporary-ID references, including the requested Section 7.1/7.3 wording, Phase 8 and Stage 6 semantics, and v1.29.20 changelog. Existing authorization and deferred-retry requirements remain intact. Commit: 1f02512.

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.

🟢 Approval recommended

No active review issues are recorded for the Markdown-escaped temporary-ID resolution changes.

No open issues 🎉

What changed in this PR

This PR fixes temporary-ID resolution in safe outputs when Markdown escapes hashes or underscores, including references awaiting later resource creation.

Changes:

  • Recognize and normalize escaped references for detection, dependency extraction, and replacement.
  • Preserve unresolved references and unrelated escapes while preventing partial matches of malformed IDs.
  • Add regression coverage for escaped issue, artifact, project, and patch URL references, plus deferred comment updates.
File Description
actions/​setup/​js/​temporary_id.test.cjs Adds escaped-reference resolution and preservation tests.
actions/​setup/​js/​temporary_id.cjs Updates matching and normalization to handle Markdown escapes.
actions/​setup/​js/​safe_output_handler_manager.test.cjs Extends deferred comment tracking and update tests to escaped references.

Review effort: Balanced (auto)

@github-actions github-actions 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.

Skills-Based Review 🧠

Applied /diagnosing-bugs, /tdd, and /codebase-design. The fix is well targeted, and the tests cover the main escaped-reference paths. I found one coverage gap and one design concern.

📋 Key Themes & Highlights

Key Themes

  • Structured-field coverage gap: normalizeTemporaryId strips escapes, but isTemporaryId (line 76) and extractTemporaryIdReferences (issue_number, blocked_by, item_url) still reject escaped IDs. I reproduced this. The gap predates the PR, so it is not a regression, but the new tests stop at text fields.
  • Duplicated URL regex: the URL-context pattern at line 142 (replaceTemporaryIdReferencesInPatch) copies TEMPORARY_ID_PATTERN instead of sharing it. Both now carry the same escape rules, so they can drift. My earlier inline comment was anchored to line 58, which is outside the diff, so treat this note as the applicable one.
  • Trailing-hyphen behavior: the new lookahead changes unescaped text such as #aw_abc-def. This is intended and covered by the malformed-ID test near line 250, so it is a nit only.

Positive Highlights

  • ✅ Escape handling is applied consistently across the text, patch-URL, and artifact paths.
  • ✅ Malformed-ID warnings are tested for escaped and unescaped forms.
  • ✅ The safe_output_handler_manager tests use it.each over escaped and unescaped IDs, which keeps the two forms in sync.

Limitations

I could not run the vitest suites because the npm registry rejects its TLS certificate in this environment. The results above come from standalone Node probes and an assertion script covering the 14 expectations in the test files. Please run make test-unit to confirm.

@copilot please address the structured-field gap and the duplicated URL regex. The trailing-hyphen point is optional.

Comments that could not be inline-anchored

actions/setup/js/temporary_id.cjs:90

**[/diagnosing-bugs]** `normalizeTemporaryId` now strips `\#` and `\_`, but `isTemporaryId` (line 76) still accepts only the unescaped form. `extractTemporaryIdReferences` also has no escape coverage for structured fields (`issue_number`, `blocked_by`, `item_url`). I reproduced that escaped IDs in those fields are not extracted. This is a coverage gap rather than a regression, since those paths never handled escapes. Normalize before validating on those paths, and add regression tests that pin t...

actions/setup/js/temporary_id.cjs:58

**[/codebase-design]** This inline regex copies `TEMPORARY_ID_PATTERN` (line 32) rather than reusing it, so the two can drift. The duplication predates this PR, but the PR extends it with the same escape rules, so the next escape change has to be made in two places. Build both from one shared source string, or add a comment explaining why the URL form needs its own boundary. @copilot please address this.

actions/setup/js/temporary_id.cjs:32

**[/tdd]** The new lookahead `(?![A-Za-z0-9_-]|(redacted))` also rejects a trailing hyphen, which is intended and already covered by the malformed-ID test near line 250. It is worth confirming that `#aw_abc-def` and `\#aw\_abc-def` have the expected behavior in one place. This is a nit, not a blocker. @copilot please address this.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

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/temporary_id.cjs:32): Specification synchronization is needed for this intentional lexical expansion. The current contract Section 7.1 item 2 and Section 7.3 item 5 only specify canonical #aw_<id> references, so they do not define the escaped and partially escaped forms implemented here. Please apply the exact proposed replacements and version/changelog update in the final review body; preserve the existing authorization and deferral requirements. - Fix Markdown-escaped temporary ID resolution in safe outputs #75688 (comment)
  3. Fix failing check Docker root-owned staging cleanup (FAILURE): https://github.com/github/gh-aw/actions/runs/42381359046/job/128429539227.
  4. Fix failing check JS Tests (shard 1/8) (FAILURE): https://github.com/github/gh-aw/actions/runs/42382299462/job/128432457819.
  5. Fix failing check JS Tests (shard 1/8) (FAILURE): https://github.com/github/gh-aw/actions/runs/42381359046/job/128429539614.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: 255ef84
Sous-chef requested-work: 0929277d4969cb7c6f2468fb23af4e1356990694e03bab2692334e737ed0f657 1233d7d521d5a5d4c95d951ce598fd234d873db85a7b5b39aa899a83269fe32b be8977fed8539981a9de7f424c3c95730603faded3a88272a303c0b1b996a2af
Sous-chef requested-state: 8807a8a3dd871f3bab5a4b261e4e910f126959eb3764fe8329868d19244b18fc

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~8 AIC · ⌖ ~9 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI and others added 2 commits November 7, 2026 15:12
…-id-resolution

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@pelikhan

pelikhan commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot avoid escaping temporary ids in markdown as they need to be expanded

Copilot AI commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Assignment running:

  1. Update the branch from main and preserve intended changes.
  2. Verify the specification synchronization and review thread.
  3. Investigate the Docker staging cleanup failure.
  4. Investigate both JS shard failures.
  5. Preserve temporary IDs in Markdown for expansion.

Sous-chef requested-head: 255ef84
Sous-chef requested-work: 0929277d4969cb7c6f2468fb23af4e1356990694e03bab2692334e737ed0f657 1233d7d521d5a5d4c95d951ce598fd234d873db85a7b5b39aa899a83269fe32b be8977fed8539981a9de7f424c3c95730603faded3a88272a303c0b1b996a2af
Sous-chef requested-state: 8807a8a3dd871f3bab5a4b261e4e910f126959eb3764fe8329868d19244b18fc

@copilot avoid escaping temporary ids in markdown as they need to be expanded

Updated Markdown rendering to preserve complete temporary IDs for expansion while retaining other escaping. Commit: 4b678bdd.

Copilot AI and others added 2 commits November 7, 2026 15:58
…-id-resolution

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
pelikhan merged commit 710903a into main Nov 7, 2026
32 checks passed
@pelikhan
pelikhan deleted the copilot/fix-temporary-id-resolution branch November 7, 2026 17:26
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants