Skip to content

pm:mailbox — qa@os-justin · os-justin #851

pm:mailbox — qa@os-justin · os-justin

pm:mailbox — qa@os-justin · os-justin #851

Workflow file for this run

# Opt-in pre-merge dogfood battery (#38694, ruling D on #38688).
#
# ## The gap this closes
#
# A breaking change (a `!` title, or a `Clause-②:` line carrying the
# `(narrowing)` arm) owes proof that the real-app regression suite still passes
# on its own head BEFORE it queues. The three dogfood shards that are that suite
# run only in `ci.yml`'s `dogfood` job, and that job skips `pull_request` (THE
# TWO SPEEDS above its `jobs:`): a PR first meets the battery inside the merge
# queue, where a red ejects it and rebuilds every entry behind it. Until now the
# proof was a local run on the shared agent box, reported as typed text; that
# run no longer fits the box's foreground limit.
#
# Maintainer ruling D on #38688 (comment 7269391948, 「云端流水线代跑」): a CI
# runner proves a labelled breaking PR's battery, and the landing door reads
# that result by head SHA. This workflow is that runner. It adds a TRIGGER and a
# verdict, nothing else: the shards, their slicing and their guards are the
# queue's, copied from `ci.yml` (see "Drift" below).
#
# ## What the door reads
#
# label `needs:dogfood-battery`
# check `Dogfood battery (opt-in)` -- the `battery` job below, one check run
# per run, on the PR's head SHA (a `pull_request` run's check suite
# sits on `pull_request.head.sha`, not on the merge-preview commit).
#
# `success` there means all three shards ran on this head and each one attested
# that every step was green. Any other conclusion, or no such check run on the
# head, is NOT a proof. One head can carry several check runs of that name: every
# `pull_request` event starts a run, and a run whose guard says no (an unlabelled
# PR, or an unrelated label added later) publishes it as `skipped`. So the reader
# asks "is there a `success` of this name on this head", never "what does the
# newest one say". The three shard check runs
# (`Dogfood battery shard (k/3, opt-in)`) are evidence for a human reader; the
# door reads the one aggregate, so a shard-count change never moves its contract.
# ⛔ Neither name is `Dogfood Regression Gate`: that literal is a required context
# (`scripts/check-required-contexts.mjs`), and a check run here carrying it would
# satisfy branch protection on a PR without the queue ever running it.
#
# ## Opt-in, by ruling -- and what it must never grow
#
# The 2026-09-01 opt-in ruling quoted in `pack-smoke-optin.yml` binds here too,
# and ruling D restates it for this lane: the cost stays opt-in.
#
# ⛔ Never a `paths:` filter that runs it by default.
# ⛔ Never in `.github/labeler.yml`, nor any other step that applies the label
# from changed paths or from the title: the seat that owns a breaking PR
# hangs the label by hand. Auto-applying it is a different design
# (auto-detect), not the one ruled.
# ⛔ Never a required context, and no `merge_group:` trigger: a `merge_group`
# event carries no pull request, so the label cannot be read there, and the
# queue already runs the same three shards on every entry.
#
# When to apply the label: on a PR whose title carries `!` or whose body carries
# `Clause-②:` with `(narrowing)`, once its head is the one the seat means to
# land. Every later push to a labelled PR is another full run (cost below).
#
# Cost, measured on the 30 most recent green merge-queue runs of `ci.yml`
# (2026-11-29T16:58Z to 2026-11-30T04:16Z, 90 shard jobs): a shard job takes
# 18.8 min median, 25.8 max, so one labelled push costs about 59 runner-minutes
# (61 billed, 75 at the slowest). The ruling's figure is about 8 % on that
# runner: 12.5 breaking PRs a day against 164 queue builds a day, each queue
# build running the same three shards, is 12.5 / 164 = 7.6 % more dogfood shard
# jobs, at one labelled push per PR. An unlabelled PR costs nothing: its jobs
# skip, and a skipped job bills no minutes.
#
# ## Wiring decisions (the `pack-smoke-optin.yml` ones, for the same reasons)
#
# `pull_request`, ⛔ never `pull_request_target`: the run executes the PR's own
# code, so it must get the PR's own read-only token. It reads no secret at all:
# the turbo remote-cache lines of `ci.yml` are left out because a
# `pull_request` run receives no remote credentials there either (Build Core's
# "Turbo remote cache (#21186)" comment). So a fork PR runs it exactly as an
# internal one does, with nothing to withhold.
#
# `types:` restates GitHub's defaults beside `labeled` (naming `types:` REPLACES
# the default set). The guard has two limbs, on every job: the PR carries the
# label now, and on a `labeled` event the label just added is OURS -- otherwise
# every size label would start another run of an unchanged tree. `concurrency`
# supersedes per PR at workflow level (an unrelated label's run gets a group of
# its own) and again at job level, where the shard group carries the shard
# number: the three legs of one matrix share a job id, and one group for all
# three would cancel two of them.
#
# The checkout is the MERGE PREVIEW (no `ref:`), as on both precedents: the tree
# `main` will contain once this head lands, the nearest thing to what the queue
# builds. The verdict still lands on the head SHA (above).
#
# `fail-fast: false`, unlike the queue: nobody is waiting behind this run, and
# the author wants every red shard named in one run, not the first.
#
# The verdict COUNTS credentials, as `ci.yml`'s gates do since #6082: each shard
# ends with `check-shard-attestation.mjs --emit` and an upload that carry no
# `if:`, so they run only when every step before them passed. The aggregate
# passes only when the matrix result is `success` AND all three credentials of
# THIS run are present. Unlike `Dogfood Regression Gate` it does not pass a
# cancelled or skipped matrix: that gate must publish a context on every PR,
# this one is a proof, and a run that proved nothing must not read as one.
#
# ## Drift: two copies of one battery
#
# `ci.yml` exposes no callable unit (no `workflow_call`, no composite action for
# the dogfood steps), and it is out of this lane's scope, so the steps below are
# a COPY of its `dogfood` job: the closure build, the `OS_TEST_SHARD` slice, the
# vitest worker cap, the stall guard, the completeness guard and the turbo cache
# restore. Nothing holds the two equal. An edit to the queue's shard steps that
# is not repeated here leaves this lane proving a different battery than the one
# the queue runs, and it stays green while doing so. Left out on purpose: the
# queue-verdict seed-only path, the remote-cache lines, the cache save and prune
# (a PR never writes the cache), and the test-leftovers report (report-only).
name: Dogfood Battery (opt-in)
on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, labeled]
permissions:
contents: read
# A newer run for the same pull request supersedes this one, so the older run is
# cancelled. The group key is ci.yml's shape; `cancel-in-progress` is true only on
# `pull_request`, so no other event's run is ever cancelled. An unrelated label's run
# gets a group of its own (its jobs are skipped anyway), so adding some other label
# never cancels a running `needs:dogfood-battery` run.
concurrency:
group: dogfood-optin-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.after || github.ref }}-${{ github.event.action == 'labeled' && github.event.label.name != 'needs:dogfood-battery' && github.run_id || 'run' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
shard:
# ~19 minutes per shard, three in parallel. Opt-in only -- see the header.
name: Dogfood battery shard (${{ matrix.shard }}/3, opt-in)
if: >-
contains(github.event.pull_request.labels.*.name, 'needs:dogfood-battery')
&& (github.event.action != 'labeled' || github.event.label.name == 'needs:dogfood-battery')
runs-on: ubuntu-latest
# ci.yml's dogfood budget, unchanged: the stall guard below is the primary
# detector, and `check:stall-guard-budget` judges its window and cap against
# this number.
timeout-minutes: 30
concurrency:
group: dogfood-optin-${{ github.event.pull_request.number }}-shard-${{ matrix.shard }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
# No `ref:` -- the MERGE PREVIEW (header, "Wiring decisions").
- name: Checkout the merge preview
uses: actions/checkout@v7
- name: Setup workspace
uses: ./.github/actions/setup-workspace
# Restore-only: the queue's dogfood seeds, saved from `main`, replay the
# closure this PR did not change; a PR never writes the cache.
- name: Restore Turbo cache
uses: actions/cache/restore@v6
with:
path: .turbo/cache
key: ${{ runner.os }}-turbo-dogfood-${{ matrix.shard }}-main-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-dogfood-${{ matrix.shard }}-main-
${{ runner.os }}-turbo-dogfood-
# ci.yml's closure step, without the seed-only and remote-cache lines.
- name: Build the dogfood closure for this opt-in shard
env:
NODE_OPTIONS: --report-on-signal --report-signal=SIGUSR2 --report-directory=${{ runner.temp }}/stall-reports
run: |
mkdir -p "$RUNNER_TEMP/stall-reports"
node scripts/run-with-stall-guard.mjs --log "$RUNNER_TEMP/dogfood-build.log" --stall-minutes 10 \
--report-dir "$RUNNER_TEMP/stall-reports" -- \
pnpm turbo run build --filter=@objectstack/dogfood --concurrency=4 --log-order=stream
# ci.yml's test step: the slice travels in the task-declared env
# `OS_TEST_SHARD` (turbo.json hashes it into `@objectstack/dogfood#test`
# only, and the dogfood vitest config hands it to vitest's `shard`), never
# a `--` passthrough. The worker cap and the stall guard are the queue's.
- name: Run this opt-in shard of the dogfood battery
env:
NODE_OPTIONS: --report-on-signal --report-signal=SIGUSR2 --report-directory=${{ runner.temp }}/stall-reports
run: |
export VITEST_MAX_WORKERS="$(node scripts/vitest-worker-cap.mjs)"
mkdir -p "$RUNNER_TEMP/stall-reports"
export OS_TEST_SHARD="${{ matrix.shard }}/3"
node scripts/run-with-stall-guard.mjs --log "$RUNNER_TEMP/dogfood.log" --stall-minutes 10 \
--report-dir "$RUNNER_TEMP/stall-reports" -- \
pnpm turbo run test --filter=@objectstack/dogfood --log-order=stream
# A shard that dies silently looks like a shard that had less work. With
# no log the test step already failed, and the credential below is
# withheld by that failure.
- name: Test completeness guard
if: always()
run: |
if [ -f "$RUNNER_TEMP/dogfood.log" ]; then
node scripts/check-test-completeness.mjs "$RUNNER_TEMP/dogfood.log"
else
echo "No test log -- the test step did not get far enough to produce one."
fi
- name: Upload stall diagnostic reports
if: failure()
uses: actions/upload-artifact@v7
with:
name: stall-reports-dogfood-optin-${{ matrix.shard }}
path: ${{ runner.temp }}/stall-reports/
if-no-files-found: ignore
retention-days: 14
# This shard's positive credential (#6082). LAST, and with no `if:`, so it
# exists only when every step above passed.
- name: Attest this shard ran and passed
run: |
node scripts/check-shard-attestation.mjs --emit \
--job dogfood-optin --shard ${{ matrix.shard }} --total 3 \
--out "$RUNNER_TEMP/shard-attestation"
- name: Publish this shard's attestation
uses: actions/upload-artifact@v7
with:
name: shard-attest-dogfood-optin-${{ matrix.shard }}-of-3
path: ${{ runner.temp }}/shard-attestation/
if-no-files-found: error
retention-days: 7
overwrite: true
battery:
# The one check the landing door reads -- see "What the door reads".
name: Dogfood battery (opt-in)
needs: [shard]
if: >-
!cancelled()
&& contains(github.event.pull_request.labels.*.name, 'needs:dogfood-battery')
&& (github.event.action != 'labeled' || github.event.label.name == 'needs:dogfood-battery')
runs-on: ubuntu-latest
timeout-minutes: 10
concurrency:
group: dogfood-optin-${{ github.event.pull_request.number }}-battery
cancel-in-progress: true
steps:
- name: Download this run's shard attestations
id: attestations
continue-on-error: true
uses: actions/download-artifact@v8
with:
pattern: shard-attest-dogfood-optin-*
path: ${{ runner.temp }}/shard-attestations
merge-multiple: true
# Passes only on the matrix's `success` AND all three credentials of this
# run; a cancelled or skipped matrix is not a proof (header).
- name: Verify all three shards ran and passed on this head
env:
OS_ATTEST_DIR: ${{ runner.temp }}/shard-attestations
OS_SHARD_RESULT: ${{ needs.shard.result }}
OS_DOWNLOAD_OUTCOME: ${{ steps.attestations.outcome }}
OS_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
missing=''
for k in 1 2 3; do
[ -f "$OS_ATTEST_DIR/dogfood-optin-$k-of-3.json" ] || missing="$missing $k/3"
done
echo "head ${OS_HEAD_SHA}: shard matrix result '${OS_SHARD_RESULT}', attestation download '${OS_DOWNLOAD_OUTCOME}', missing credentials:${missing:- none}"
if [ "$OS_SHARD_RESULT" != 'success' ] || [ -n "$missing" ]; then
echo "::error::Dogfood battery NOT proven on ${OS_HEAD_SHA}: matrix '${OS_SHARD_RESULT}', missing credentials:${missing:- none}. Read the red shard's log; push a fix (or re-run the failed jobs) to prove the head again."
exit 1
fi
echo "Dogfood battery proven on ${OS_HEAD_SHA}: 3 of 3 shards ran and passed."