Skip to content

feat: Dependabot auto-merge shadow step in pr-triage.yml - #225

Merged
bketelsen merged 3 commits into
mainfrom
lucilla/dependabot-shadow
Nov 9, 2026
Merged

bketelsen merged 3 commits into
mainfrom
lucilla/dependabot-shadow

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the Dependabot auto-merge shadow step to pr-triage.yml. It gathers evidence for a later decision on a narrow auto-merge class, and changes nothing else: it never enables auto-merge, approves, merges or labels (ADR-0019 holds). Idea from Airlock's go-live (shadow first) and GitHub's dependabot/fetch-metadata pattern. Builds on #220 (pr-triage.yml), #223 (levels, ADR-0078) and #221 (required checks, ADR-0076).

On a Dependabot PR (opened, synchronize, reopened, not a draft, caller input dependabot-shadow true), the step writes 1 comment for each head when all 4 criteria hold:

  • S1, patch or minor: every entry of updated-dependencies-json is semver-patch or semver-minor, both versions parse as v?N.N(.N)*, the first number is the same, and for 0.x the second number too. A grouped PR (ADR-0075) passes only when every entry passes.
  • S2, manifest and lock files only: each changed path (both names of a rename) has a base name in a fixed set (go.mod, go.sum, package.json, the lock files, requirements*.txt, ...). 0 files or a truncated list fails.
  • S3, no risk path: levelOfPullRequest on the list at the base SHA gives L3 or L4. It reads no label: a kept stricter label does not count. Any error fails S3.
  • S4, required checks exist: GET rules/branches/{base} has at least 1 required status check; the marker records them for the later measurement.

Marker (first line of the comment): <!-- frostyard:dependabot-shadow v1 head=<sha> level=<L3|L4> checks=<JSON> -->. The JSON escapes <, > and &, so a check name cannot end the HTML comment. A re-run finds the marker for its head and writes nothing.

  • scripts/lib/pr-triage.mjs: runShadowStep, checkS1 to checkS4, parseVersion, shadowMarker, shadowComment; main accepts PR_TRIAGE_STEP=shadow. 1 private headShaOf serves readiness and shadow.
  • scripts/lib/risk-paths.mjs: 1 read-only API method, listBranchRules. The vendored exports keep their names and results.
  • .github/workflows/pr-triage.yml: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0 (the newest v2; v3 needs the Node 24 runtime) with continue-on-error: true, so a metadata failure fails S1 and does not turn the triage check red; then the shadow step. Both use the same if:. The 2 embedded copies are re-synced.
  • Docs: docs/specs/pr-triage.md section G (the step contract), new docs/design/dependabot-shadow.md (how the calls are measured over 2 weeks, the false-call classes F1 to F4, and what a go-live decision needs: at least 10 calls, F2 = F3 = 0, F1 + F4 ≤ 2, and a new ADR amending ADR-0019, ADR-0042 and ADR-0040), index line, risk-paths spec derived-artifacts row.

Out of scope: the measurement script (a later change), any go-live.

Risk tier

Risk tier: 3 — highest. The PR touches these paths of the base .github/risk-paths.json (L2):

  • .github/workflows/pr-triage.yml: 2 new steps, header comments, input description, re-synced embedded copies. No permission, trigger or existing if: changes. The new action is SHA-pinned; the job permissions stay contents: read and pull-requests: write; no secret.
  • scripts/lib/pr-triage.mjs: the shadow step. Its only write is POST issues/{n}/comments; a test asserts the step calls only 5 read/comment methods and that its fake API has no label or merge method.
  • scripts/lib/risk-paths.mjs: 1 read-only GET method. No change to other exports.

Under pull_request_target, core's local caller resolves to the base branch, so this PR's run uses the old steps; the shadow runs on core's Dependabot PRs after the merge.

Docs housekeeping

  • New docs started from their category's TEMPLATE.md
  • Every new doc indexed in docs/README.md
  • Cross-links added in both directions (design ↔ spec)
  • No new ADR: the shadow writes a comment only; go-live needs a new ADR (stated in the design doc)
  • Conformance aliases (ADR-0029) untouched

Verification

  • make check: docs, organization, risk-paths ("workflow in sync"), 662 tests, 0 failures
  • Docs-site scaffold tests: 5 pass
  • actionlint .github/workflows/pr-triage.yml clean
  • Smoke: the generated "Write the triage scripts" step, run with bash, wrote both files; PR_TRIAGE_STEP=shadow on a non-Dependabot event exits 0 with "the pull request author is not dependabot[bot]. No comment."

Review fixes (after the first push)

  • The step reads the live PR head before the criteria and again before it writes; a run for an older head writes nothing (stale).
  • Version parts compare as BigInt (exact, no size limit).
  • Duplicate calls converge: a call comment is a github-actions[bot] comment with the marker for the head; the lowest id is the call; every run, on both paths, deletes the other call comments for that head, so a retry repairs a failed cleanup. Comments by other authors are never counted or deleted. The step's writes are therefore POST of its comment and DELETE of its own duplicate call comments; still no label, approve, merge or auto-merge call.
  • Guards: targeted tests for each point, and 2 lines in .memory/corrections.jsonl.

Cross-review

  • Coder: deepseek/deepseek-flash (parent edits to docs and tests). Reviewer: openai/gpt-6.1-sol.
  • Base 1c62146877c2b8df1af923415e5dc5d5c849968b. Initial review at b9cdb34: Not ready (3 blockers: concurrent duplicate, stale head, Number precision). Re-review 1 at 2b51827: Not ready (cleanup not recoverable after a failed delete). Re-review 2 at 41e44b65163d26b533aa142d06ab5357465bd768: Ready, Blocking: none. Generated heredoc bodies excluded from line-by-line review (checked by test and npm run check:risk-paths).
  • Revert tests (scratch worktree, node --test test/pr-triage.test.mjs): no per-head dedupe → "the shadow step writes 1 comment for each head" fails; no 0.x rule → "checkS1 passes patch and minor updates only" fails; S3 accepts L2 → "checkS3 wants the computed level at L3 or L4 and fails on any error" fails; no draft check and no > escape → their tests fail; no live-head checks → 3 stale tests fail; Number instead of BigInt → "checkS1 compares version numbers exactly, with no size limit" fails; no early-path cleanup → "a retry after a failed cleanup removes the duplicate" fails.
  • make check at the head: 678 tests, 0 failures; CI green at the head.

On a Dependabot pull request that is patch or minor (S1), changes only
manifest and lock files (S2), has a computed level of L3 or L4 (S3) and
a base branch with required status checks (S4), the new shadow step
writes 1 marker comment for each head: auto-merge would be enabled.
It never enables auto-merge, approves, merges or labels (ADR-0019).

- scripts/lib/pr-triage.mjs: runShadowStep, checkS1 to checkS4,
  parseVersion, the marker and comment; main accepts PR_TRIAGE_STEP=shadow.
- scripts/lib/risk-paths.mjs: read-only listBranchRules.
- pr-triage.yml: dependabot/fetch-metadata v2.5.0 (SHA-pinned,
  continue-on-error) and the shadow step; embedded copies re-synced.
- docs/specs/pr-triage.md section G; docs/design/dependabot-shadow.md
  with the measurement and what a go-live decision needs.
@github-actions github-actions Bot added the risk:high Touches a path in .github/risk-paths.json label Nov 9, 2026
…removes its own duplicate

- Read the pull request head before the criteria and again before the
  comment; write nothing when it is not the event head (a delayed or
  re-run job must not judge the files of a newer head).
- Compare version parts as BigInt, so that versions that differ only
  above 2^53 are not equal.
- After the write, list the comments again; when an earlier marker for
  the same head has a lower id, delete this run's own comment, so 2
  concurrent runs keep 1 comment.
- Tests for each point, a test that L1 and L2 fail S3, and 1 line in
  .memory/corrections.jsonl.
A call comment is a github-actions[bot] comment with the marker for the
head; the lowest id is the call. Both the early path and the write path
delete every other call comment for that head, so a retry after a
failed cleanup removes the duplicate. Comments by other authors are
never counted or deleted. Test and .memory/corrections.jsonl line.
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 9, 2026
@bketelsen
bketelsen merged commit c996ea3 into main Nov 9, 2026
6 checks passed
@bketelsen
bketelsen deleted the lucilla/dependabot-shadow branch November 9, 2026 13:34
This was referenced Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge risk:high Touches a path in .github/risk-paths.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants