Skip to content

ci(stack-breadcrumb): bring forward the evolved topology-aware breadcrumb - #56

Merged
theCodeDrift merged 3 commits into
mainfrom
jakob/stack-breadcrumb-forward
Jul 10, 2026
Merged

theCodeDrift merged 3 commits into
mainfrom
jakob/stack-breadcrumb-forward

Conversation

@theCodeDrift

Copy link
Copy Markdown
Member

We sent an early version of the stack-breadcrumb workflow to the taskless/taskless team; they evolved it with a series of fixes. This brings that improved version back into our repo — the zero-dependency script, its test suite, and the workflow — reformatted to our Prettier style and MIT-licensed (with permission; the repo is already MIT, headers added for provenance).

What improved over our current version

  • Topology-aware markers. The stack marker now encodes each member's parent (pr=82,83:82,84:83) rather than a flat list (pr=82,83,84), so the tree shape is durable and not re-inferred from scratch each run.
  • Additive tree. A PR stays in the breadcrumb after it merges, rendered ✅ merged (vs ⛔ closed), instead of vanishing from the stack.
  • Recorded-parent resolution. When a parent merges, GitHub deletes its branch and retargets the child onto the default branch, which severs the live base/head edge. The recorded parent survives that, so buildTree climbs back to the true root and keeps the merged ancestor in the tree. Because the marker is written while edges are still live, topology is captured before any retarget can sever it.
  • Robustness. A defensive recursion guard in the region renderer terminates on a malformed/cyclic childrenOf; legacy flat markers self-migrate to the recorded form on their next reconcile.

Provenance & licensing

The logic is repo-agnostic — no taskless/taskless-specific wiring (repo/owner refs are all dynamic via github.repository/context.repo). Files carry an SPDX-License-Identifier: MIT header plus a note that they were adapted from the taskless/taskless implementation.

Validation

  • node --test .github/scripts/*.test.cjs → 54 pass, 0 fail (CI already runs this).
  • node --check clean on both scripts; workflow reformatted with our Prettier config.

@theCodeDrift
theCodeDrift marked this pull request as ready for review July 10, 2026 01:46
Copilot AI review requested due to automatic review settings July 10, 2026 01:46
…rumb

We sent an early stack-breadcrumb workflow to the taskless/taskless team;
they evolved it with a series of fixes. This brings that version (the
zero-dependency script + its tests + the workflow) back into this repo,
reformatted to our Prettier style and MIT-licensed with permission.

Notable improvements over our current version:
- Topology-aware markers: the stack marker now encodes each member's
  parent (`pr=82,83:82,84:83`) instead of a flat list, so the tree shape
  is durable.
- Additive tree: a PR stays in the breadcrumb after it merges, rendered
  `✅ merged` (vs `⛔ closed`), instead of vanishing.
- Recorded-parent resolution: when a parent merges, GitHub deletes its
  branch and retargets the child onto the default branch, severing the
  live base/head edge. The recorded parent survives that, so the merged
  ancestor stays in the tree rather than disappearing.
- Defensive cycle guard in the region renderer; legacy flat markers
  self-migrate to the recorded form on the next reconcile.

The logic is repo-agnostic (no taskless/taskless-specific wiring). All 54
unit tests pass via `node --test`; CI already runs
`.github/scripts/*.test.cjs`.

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

This PR updates the stack-breadcrumb GitHub Actions workflow and its zero-dependency implementation to preserve durable stack topology across merges/retargets, and to keep merged/closed ancestors visible in the rendered breadcrumb.

Changes:

  • Encode stack topology in the marker as member:parent pairs and consolidate recorded parent links across PR bodies for retarget resilience.
  • Render merged vs. closed members distinctly (✅ merged vs ⛔ closed) and keep merged ancestors in the breadcrumb (additive tree).
  • Expand/adjust the unit test suite to cover topology encoding, retarget scenarios, cycle-guard rendering, and merged/closed annotations.

Reviewed changes

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

File Description
.github/workflows/stack-breadcrumb.yml Fetches historical (non-open) stack members and supplies merged-vs-closed info for additive breadcrumb rendering.
.github/scripts/stack-breadcrumb.cjs Implements recorded-parent topology parsing/union, additive tree construction, merged/closed rendering, and recursion safety guard.
.github/scripts/stack-breadcrumb.test.cjs Adds/updates tests for topology parsing, recorded-parent consolidation, merged/closed annotation, and retarget preservation behavior.

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

Pull the newer stack-breadcrumb improvements the team landed on
taskless/taskless main since the initial port, reformatted to our
Prettier style with the MIT/provenance headers preserved.

New over the previous version:
- Breadcrumb titles: entries render bare `#N` so GitHub autolinks the
  title + state, instead of a plain number.
- Carry-forward job: on a stack member's merge, embed its body into its
  parent PR (keyed), so an incrementally-landed stack keeps its history.
  The job runs with contents:read (top-level `permissions: {}` grants no
  default) and skips merges into the default branch.
- Topology hardening against crafted markers and cycles.

Repo-agnostic (owner/repo/default-branch all resolved dynamically). All
59 unit tests pass via `node --test`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@theCodeDrift theCodeDrift added the skip-changeset PR intentionally ships no release note (bypasses the changeset requirement) label Jul 10, 2026
@theCodeDrift
theCodeDrift requested a review from Copilot July 10, 2026 03:56

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/scripts/stack-breadcrumb.cjs Outdated
…he code

The tree-derivation block comment and buildTree docstring said the
RECORDED parent wins, but the implementation (and the inline comment at
the resolver) makes the LIVE edge authoritative — the recorded parent is
a contained fallback used only for a severed edge that names a known
merged/closed ancestor. That containment is a security property (PR
bodies are user-editable, so a crafted marker must not re-parent an
unrelated PR), so the stale "recorded must win" framing was not just
imprecise — following it could reintroduce the crafted-marker hole the
hardening pass closed. Also drop the "rendered ✅ merged" aside: entries
render bare #N and GitHub supplies the status icon.

Comment-only; no behavior change. Flagged by Copilot review on #56;
applies cleanly back onto taskless/taskless (prose-only, quote-agnostic).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@theCodeDrift
theCodeDrift merged commit 108f90e into main Jul 10, 2026
4 checks passed
@theCodeDrift
theCodeDrift deleted the jakob/stack-breadcrumb-forward branch July 10, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changeset PR intentionally ships no release note (bypasses the changeset requirement)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants