fix(spec-sync): update PR body via REST so the LLM summary lands - #132
Merged
Conversation
`gh pr edit` eagerly loads org-level PR metadata (review-request team `slug`, assignee `login`/`name`), which fails with a `read:org` GraphQL scope error under SPEC_SYNC_TOKEN — a classic PAT scoped to repo+workflow. Because the step is continue-on-error, the failure was swallowed and every spec-sync PR kept its static body with no "## What changed" section. Read and update the body through the REST pulls endpoint instead; it needs only `repo`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates spec-sync PR summaries to avoid GraphQL organization-scope failures.
Changes:
- Parses repository and PR number from the PR URL.
- Reads and patches the PR body through GitHub’s REST API.
- Preserves existing safeguards against empty bodies and duplicate summaries.
The inline summarize step runs only at PR-open time, so its "## What changed" block misses commits a human adds later (e.g. a breaking removal the AI didn't wire). Two changes fix that: - summarize-pr.sh now writes the section into a stable <!-- what-changed:start/ end --> fence and replaces it in place on re-run (idempotent), instead of the skip-if-present guard — so it can be recomputed without duplicating or touching human-written body text. - New spec-sync-summary.yml runs the summarizer on push to spec-sync/**, skipping bot pushes (the inline step covers those; skipping also avoids a double-write race at open time), so the description tracks the final diff. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
scripts/spec-sync/summarize-pr.sh:85
- The replacement is idempotent only for bodies already using the new markers. Existing spec-sync PRs created by the old script—including the cited #129—contain the same generated
## What changedsection without markers, so the next refresh falls into thiselseand appends a second section. Add an explicit migration/legacy-heading path that avoids duplication while preserving any human-authored body text.
if ($b =~ /<!-- what-changed:start -->.*?<!-- what-changed:end -->/s) {
$b =~ s/<!-- what-changed:start -->.*?<!-- what-changed:end -->/$k/s;
} else {
$b =~ s/\s+\z//; # trim trailing whitespace before appending
$b .= "\n\n" . $k . "\n";
- Remove spec-sync-summary.yml. A push-triggered workflow runs the pushed ref's code with secrets (SPEC_SYNC_TOKEN, ANTHROPIC_API_KEY), so anyone who can push a spec-sync/** branch could exfiltrate them — the scheduled spec-sync.yml deliberately runs only from main. Keep the marker + REST changes; the summary stays a one-shot at PR-open time. - Guard the perl rewrite in summarize-pr.sh: if perl is missing/errors or returns empty, skip the PATCH instead of wiping the PR body with an empty string. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
scripts/spec-sync/summarize-pr.sh:72
- The PR description promises a push-triggered
spec-sync-summary.ymlthat reruns this replacement asspec-sync/**evolves, but no such workflow is included. The only callers remain the open-time steps in.github/workflows/spec-sync.yml:199-205and499-509, so later pushes will not refresh the summary and the stated final-diff behavior is not implemented. Please add the described workflow (including the bot-push exclusion) or update the PR scope/description.
# Wrap the AI section in stable markers so a re-run REPLACES it in place (idempotent) rather than
# appending a second copy, and so it never disturbs body text a human wrote outside the fence.
yzld2002
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
summarize-pr.shstep that appends the LLM "## What changed" section usedgh pr edit, which eagerly loads org-level PR metadata (review-request teamslug, assigneelogin/name) and fails with aread:orgGraphQL scope error underSPEC_SYNC_TOKEN(a classic PAT scoped torepo+workflow). Because the step iscontinue-on-error, the failure was swallowed and every spec-sync PR kept its static body (e.g. #129, ade-typescript#93).Changes:
repo) instead ofgh pr edit.<!-- what-changed:start/end -->block and replace it in place on re-run, never duplicating or touching body text outside the fence; the perl rewrite is guarded so a failure can’t blank the body.Paired with ade-typescript#97.