Skip to content

feat(ci): preserve merged PRs in the stack breadcrumb - #51

Merged
thecodedrift merged 4 commits into
mainfrom
jakob/breadcrumb-preserve-history
Jul 4, 2026
Merged

feat(ci): preserve merged PRs in the stack breadcrumb#51
thecodedrift merged 4 commits into
mainfrom
jakob/breadcrumb-preserve-history

Conversation

@thecodedrift

Copy link
Copy Markdown
Member

The stack breadcrumb dropped merged PRs and cleared entirely once a stack collapsed to its last open PR, so the record of how the final merged-down PR was constructed was lost. This keeps the full history.

What changes

  • Reconcile now includes merged/closed members recorded in existing breadcrumb markers: the job reads each open PR's marker pr= list, pulls.gets any member that's no longer open, and passes the union to reconcile for tree structure + rendering. Root resolution still uses the open-PR list only.
  • Merged/closed members are frozenreconcile keeps them in the tree (so open PRs keep listing them, and the last open PR captures the whole stack) but never rewrites their bodies (new frozen bucket; members without a state are treated as open, so unit fixtures are unaffected).
  • No explicit status marker — GitHub auto-renders a #123 reference with its merged/closed badge, so plain list items are enough.

Result

After landing a stack (e.g. 50 → 49 → 47), #47 (the last to merge) freezes with:

**Stack** (root → tip):

- ➡️ #47 (you are here)
  - #49
    - #50

where #49/#50 render with their merged badges — a permanent record of the construction.

Notes

  • Pure infra (.github/**); the zero-dep .cjs is covered by its node --test suite (41 tests, +2 here). Workflow YAML validated.
  • Stage 2 (reconcile) runs from the default branch, so this takes effect once merged to main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TEuUE3F23dgEyrkGPq3FiM

The breadcrumb previously dropped merged PRs (tree built from open PRs only) and
cleared entirely once a stack collapsed to its last open PR — losing the record
of how the final merged-down PR was constructed.

Now the reconcile step also pulls in the stack members recorded in existing
breadcrumb markers that are no longer open, fetches them for tree structure, and
keeps them in the rendered list. GitHub auto-renders the PR reference with its
merged/closed badge, so no explicit status marker is needed. Merged/closed
members are frozen — reconcile keeps them in the tree (so open PRs keep listing
them and the last open PR captures the whole history) but never rewrites their
bodies. Root resolution still uses the open-PR list only.

- stack-breadcrumb.cjs: reconcile skips writing any member whose state is not
  'open' (records them under a new 'frozen' bucket); members without state are
  treated as open (unit fixtures / open-PR list).
- stack-breadcrumb.yml: the reconcile job collects historical members from open
  PRs' markers, fetches them via pulls.get with state, and passes the union to
  reconcile; open PRs are tagged state: 'open'.
- tests: a merged member is frozen but still listed; a lone open root with only
  merged descendants still renders (no clear).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 20:02

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

This PR updates the stack-breadcrumb GitHub Actions workflow + its zero-dependency reconciliation script to preserve full stack history by keeping merged/closed PRs in the rendered breadcrumb, so the last open PR in a stack doesn’t lose the construction record.

Changes:

  • Extend Stage 2 (reconcile) to fetch and include merged/closed stack members referenced by existing breadcrumb markers, and pass the union into reconcile.
  • Add a “frozen” bucket in reconcile so merged/closed members remain in the tree but their PR bodies are never rewritten.
  • Add unit tests covering “frozen merged member” behavior and the “lone open root with merged descendants” case.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/stack-breadcrumb.yml Includes historical (non-open) PRs from existing breadcrumb markers and reconciles using the union list.
.github/scripts/stack-breadcrumb.cjs Freezes non-open PRs during reconcile while still rendering them in open PR breadcrumbs.
.github/scripts/stack-breadcrumb.test.cjs Adds coverage for frozen merged members and “don’t clear breadcrumb” behavior when only descendants are merged.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/stack-breadcrumb.yml Outdated
Comment thread .github/workflows/stack-breadcrumb.yml Outdated
Address Copilot review on #51:

- Skip a historical (merged/closed) PR whose head ref collides with an open PR's
  headRefName — the tree is keyed by head ref, so a reused branch name would
  corrupt derivation.
- Validate marker member numbers (positive integers) before fetching, guarding
  against a malformed marker.
- Fetch the historical members in parallel instead of sequentially (the set is
  bounded by stack size).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread .github/workflows/stack-breadcrumb.yml Outdated
Follow-up to the previous hardening: the head-ref collision guard only compared
historical PRs against open PRs. Two historical (merged/closed) PRs that reused
the same branch name could still collide in the head-ref-keyed tree. Admit a
historical PR only if its head ref isn't already claimed by an open OR an
earlier historical member.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread .github/workflows/stack-breadcrumb.yml Outdated
The pr= marker lives in a user-editable PR body, so a crafted/malformed list
could trigger a large burst of pulls.get calls. Cap the historical fetch at 50
members (with a truncation log) before issuing any API calls.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thecodedrift
thecodedrift merged commit f764540 into main Jul 4, 2026
3 checks passed
@thecodedrift
thecodedrift deleted the jakob/breadcrumb-preserve-history branch July 4, 2026 21:15
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.

2 participants