Skip to content

fix(spec-sync): update PR body via REST so the LLM summary lands - #132

Merged
tian-lan-landing merged 3 commits into
mainfrom
fix/spec-sync-summary-rest-patch
Jul 28, 2026
Merged

fix(spec-sync): update PR body via REST so the LLM summary lands#132
tian-lan-landing merged 3 commits into
mainfrom
fix/spec-sync-summary-rest-patch

Conversation

@tian-lan-landing

@tian-lan-landing tian-lan-landing commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

The summarize-pr.sh step that appends the LLM "## What changed" section used gh pr edit, which eagerly loads org-level PR metadata (review-request team slug, assignee login/name) and 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 (e.g. #129, ade-typescript#93).

Changes:

  • REST transport — read/update the body via the REST pulls endpoint (needs only repo) instead of gh pr edit.
  • Idempotent fence — write the section into a stable <!-- 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.

`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>
Copilot AI review requested due to automatic review settings July 28, 2026 07:57

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.

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>
Copilot AI review requested due to automatic review settings July 28, 2026 08:57

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.

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 changed section without markers, so the next refresh falls into this else and 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";

Comment thread .github/workflows/spec-sync-summary.yml Outdated
@tian-lan-landing tian-lan-landing added the breaking-change-approved Surface-lock override: a reviewed, intentional public-surface change label Jul 28, 2026
- 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>
Copilot AI review requested due to automatic review settings July 28, 2026 09:27

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.

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.yml that reruns this replacement as spec-sync/** evolves, but no such workflow is included. The only callers remain the open-time steps in .github/workflows/spec-sync.yml:199-205 and 499-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.

@tian-lan-landing
tian-lan-landing merged commit 1610a2d into main Jul 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change-approved Surface-lock override: a reviewed, intentional public-surface change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants