Repository navigation
feat(pr-unblock): dark-launch test-scope declarations from the selection trace - #18460
Conversation
A test-scope patch row lets the lane add `test-scope:` lines to suites a PR changed, and nothing else. It is the first api-only row: the write runner keeps only the trusted base checkout (checkout: base), and apply-patch reads each patched file's head blob over the API, verifies its id, applies the patch in a scratch index, builds the tree from the head's over the API, checks each patched path in the built tree, and moves the branch with force: false from the observed head. No PR code is checked out or run in the job that holds the lane token. The test-scope-lines content rule admits only inserted lines matching ^(#|//) test-scope: <one exact path>$ with the suite type's comment character and the file's line ending, inside the leading comment block scripts/affected-tests.sh scope_declarations reads, repeating no declared path, with the mode unchanged. The parser lives in .github/scripts/pr-unblock/test-scope.mjs, which the write runner now stages beside apply-patch, and its test checks it line for line against the real scope_declarations. The test-suites predicate admits suites outside .github/ only. The api-only path also refuses a Dependabot PR and a head that already carries the row's Lane-Activity trailer. Refs: melodic-software/architecture#194 Co-Authored-By: Claude Opus 5.5 <[email protected]>
declare-test-scope.mjs is the base-code select step for the new declare-test-scope activity. `locate` re-reads the pull request (head SHA, same-repository head, not a draft, not Dependabot), stops with test-scope-gaps-remain when the head is the lane's own trailer commit or the PR already carries two of them, and names the pull_request run of pr-require-checks whose only failed job is Test Selection, failed first at "Trace the changed suites". `build` treats the uploaded trace as untrusted. gaps.tsv, suites.tsv and verdicts.tsv must be regular files of at most 1 MiB with exact tab fields and no CR. A not-traced suite, a "not checked" verdict, or a gap verdict not matching ^(selects |unmapped: ) (a deleted read included) refuses the whole trace as test-scope-not-all-gaps. Each gap's suite must be a suite the PR changes, outside .github/, regular at the head; each read must be one exact path present at the base and the head and not yet declared. Any gap the lane cannot answer refuses them all, so no partial fix is built. The patch is built from blobs in a scratch index, never by running PR code, and keeps the suite's line endings. Refs: melodic-software/architecture#194 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The existing pr-unblock dispatcher (pr-unblock-dispatch.yml, on its cron and push triggers) now also sends fix-test-scope for an open pull request into main that is ready, from this repository, not Dependabot's, carries no do-not-merge or needs-session label, whose ci-lanes failed and whose pr-require-checks run failed only at Test Selection's "Trace the changed suites" step. It has no adoption idle wait, and sends a head once: any fix-test-scope check on the head records it. pr-unblock.yml runs fix-test-scope-select (base code only: it reads the head, resolves the slot, locates the trace run, downloads its artifact, checks out the head without credentials as data, and runs declare-test-scope.mjs), fix-test-scope-not-run, which posts the check on every decided outcome, and apply-test-scope, which calls the write runner with patch-prepare test-scope. The new test-scope config section's apply key is false, and apply-test-scope runs only when it is true: until then the select job validates, builds and uploads the patch (kept 30 days so each can be compared with the human fix) and nothing is pushed. apply-test-scope is a checkout: base activity, so the write runner holds only the trusted base and apply-patch takes its api-only path. Its hold labels include the activity's labels-absent list, needs-session among them, read again before the push. The write runner admits the five test-scope-* reasons at both enum sites; they route to fix-test-scope as fail with no label and are not wired into report-escalation, so during the dark launch a refusal shows only as the check's skip reason. The activity is fix-test-scope, not declare-test-scope: the actions vocabulary (.github/standards/github-actions-conventions/vocabulary.json) has no `declare` verb and the config reader refuses the name. Refs: melodic-software/architecture#194 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…its stops
- declare-test-scope.mjs TRAILER is now Lane-Activity: pr-unblock/fix-test-scope,
the value apply-test-scope's commit carries (patch-activity: fix-test-scope,
filled into patch-rules.json's {lane}/{activity}). locate's own-head check
and two-commit cap read the wrong trailer before. A callers test builds the
trailer from the workflow's apply-test-scope inputs and patch-rules.json,
and the locate test builds its fixture the same way, so a drift fails.
apply-patch.mjs compares against the message it built itself and needs no
change; its test fixtures now pass the activity production passes.
- report-stop-status and report-escalation consume fix-test-scope-select's and
apply-test-scope's escalation-reason, head and clear, as for shared-copies,
so the test-scope routes in escalation-routes.json reach a person.
pr-pipeline.yaml's report-escalation needs lists both activities.
The comment above report-escalation's if: is removed rather than edited
(the comment lint refuses rewritten lines). What it said, now with the new
source: a reply job that failed with no reason (its lane token, a script
error) stops as feedback-publish-failed, derived from its result; when
report-stop-status withheld that stop's status, because the feedback sweep
sends a workflow-modified refusal again, no comment posts either, and a
skipped or failed report-stop-status leaves the output empty, so the comment
posts. escalation-reason is set only by the write runner's own steps, the
base's reply, verdict and apply-patch scripts, and the base scripts of
resolve-conflicts-select, check-conflict-scan-refusal,
address-feedback-select, review-dependency-select, fix-ci-context,
sync-shared-copies-select and fix-test-scope-select. At most one escalates:
one activity runs per dispatch, a reply, verdict or push job runs only after
a select job proceeded, and a select job, or fix-ci-context, escalates only
before any model turn. A rung-up stop escalates too unless
apply-patch-rung-up applied the retry's patch cleanly: its own reason, else
ci-fix-escalated. On a cancelled run the always() branch fires, but the
write workflow's run job skips, so no label is applied and ci-status stays
red.
- test-scope-lines refuses a declaration inserted above a shebang and a path
that is not one exact path (an empty, . or .. segment). exactPath moves to
test-scope.mjs, which planDeclarations imports. The `../a.sh x` case, which
was refused for its second word, is split into separate cases.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
test-scope.mjs (the apply-side content rule) and declare-test-scope.mjs (the select job's script) decide what the lanes App may push, so they join merge.diff-check.floor-paths as gate rows with author-lift: false, like the prompt-text rows. scripts/sync-hold-floor.py regenerated merge-holds.mjs, the review callers' hold-paths and ci-status's hold_patterns. The floor pins in test_floor_paths.py, test_diff_risk.py and test_merge_holds_sync.py move by the two rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ly is off A dark activity makes no new unattended writes. While the base config's test-scope.apply is not true, declare-test-scope.mjs turns a locate or build stop into skip-reason=lane-stopped (escalation-routes.mjs stopSkip), so the fix-test-scope check posts as before and report-stop-status and report-escalation, which read only escalation-reason, post no failing status and no comment. With apply on, the same stops emit escalation-reason, so the flip needs no workflow edit. apply is read once per run through loadTestScope from BASE_DIR, now passed to the locate step too; the select job's proceed and skip-reason outputs carry the build step's skip. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main added its own hold-floor row. pr-pipeline.yaml merged cleanly with main's row and this branch's two test-scope rows. scripts/sync-hold-floor.py regenerated pr-require-checks.yml's hold_patterns, and the floor pins in test_floor_paths.py, test_diff_risk.py and test_merge_holds_sync.py are computed from the merged floor: 164 classes (gate 74), 99 high, 24 author-review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: PR #18460 at
|
|
claude-review reviewed Code review: PR #18460 at
|
Keep main's trusted-actors.mjs trust row and this branch's two test-scope gate rows in the merge-holds floor, regenerate the floor copies with scripts/sync-hold-floor.py, and repin the babysit floor tests to the combined counts and digests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
|
The pr-unblock lane stopped
When a retry on this head can change the outcome, the lane runs one on its own, up to its per-head cap, and edits this comment if it stops again; a run that does not stop clears the status. When no retry can (a review thread the lane does not take or settle, or a failing check after the retries are spent), a person resolves the threads or gets the checks green, then dispatches the workflow below: that run finds the cause gone and clears the status. On a pull request the lanes App opened, the dispatchers start that run once per stop; on any other, a person does. A new commit to the branch starts clean. To run it again on this head now, dispatch the gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=18460 -f activity=resolve-conflicts |
…lare apply-patch's reads - workflow-gates.test.mjs: the report-stop-status HEAD_SHA case lists fix-test-scope-select beside sync-shared-copies-select, so its head-sha resolves in the fixture and the test asserts the stop status posts on the test-scope select head. - apply-patch.test.mjs: declare test-scope on .github/scripts/lib/* and .github/scripts/apply-patch/*. The staged-layout test copies both directories whole, so the trace saw 55 reads the selector did not map; the same declaration covers the same copy in publish-feedback.test.mjs. - Changelog fragments: pr-pipeline minor for the test-scope.apply schema key; source-control none, test pins only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
Brings main's ci-workflows re-pin to v0.82.1 (#18487). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
The fix-test-scope jobs were written against v0.81.0, and main has since re-pinned every ci-workflows action to v0.82.1 (#18487). callers.test.mjs requires one pin across the tip steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
…sh writes scripts/selection-audit.sh writes each suites.tsv row as suite, exit code or not-traced, seconds and read count, but readTrace read it at two columns, so every real trace was refused as test-scope-invalid. readTrace now reads four columns and checks each row's shape, which also covers the exit-code check traceGaps carried. The tests built their traces by hand at the wrong width. A new test runs selection-audit.sh trace on a throwaway repository with only strace and the selector stubbed, and reads the trace it writes; another fails when a suites.tsv printf in the script changes width. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
Keep main's floor rows from #18434 and this branch's two test-scope gate rows in the merge-holds floor, regenerate the floor copies with scripts/sync-hold-floor.py, and repin the babysit floor tests to the combined counts and digests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
Keep main's merge-holds floor rows and this branch's two test-scope gate rows, regenerate the floor copies with scripts/sync-hold-floor.py, and repin the babysit floor tests to the combined counts and digests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
Refs: melodic-software/architecture#194
Summary
A pull request whose only red lane is Test Selection's "Trace the changed suites" step needs
test-scope:lines a person writes by hand. This PR adds a lane activity that builds those lines from the failed trace. It ships dark:test-scope.applyisfalse, so the select job validates the trace, builds the patch and uploads it, and nothing is pushed. The existing pr-unblock dispatcher starts it on its existing cron and push triggers. This PR adds noworkflow_runtrigger, no trusted-dispatcher change and no broker change.Fix
test-scoperow isapi-only. The write runner holds only the trusted base checkout (checkout: base). apply-patch reads each patched file's head blob over the API and verifies its id, applies the patch in a scratch index, and builds the tree from the head's tree over the API. It checks each patched path in the built tree, then moves the branch withforce: falsefrom the observed head SHA. It refuses a Dependabot PR and a head that already carries theLane-Activity: pr-unblock/fix-test-scopetrailer, the trailer the write runner fills frompatch-activity.test-scope-linesand predicatetest-suites. The content rule admits only inserted lines matching^(#|//) test-scope: [A-Za-z0-9._@+/-]+$. Each line must use the suite type's comment character and the file's line ending, sit inside the leading blockscope_declarationsreads, and repeat no declared path. The mode must not change. The predicate admits suites outside.github/only. The shared parser is.github/scripts/pr-unblock/test-scope.mjs, and its test checks it line for line against the realscope_declarations.declare-test-scope.mjs, run by the select job as base code. It locates the PR's pull_request run of pr-require-checks whose only failed job is Test Selection, failed first at the trace step. It reads the trace as untrusted data:not checkedverdict, and any gap verdict outside^(selects |unmapped: ),deletedincluded.fix-test-scope-selectandfix-test-scope-not-runpost the check on every outcome, so each head is sent once.apply-test-scoperuns only whenapplyis true. The dispatcher's own filter requires a same-repository, ready PR into main, not opened by Dependabot, with nodo-not-mergeorneeds-sessionlabel and no adoption idle wait.test-scope.apply.test-scope.applyis nottrue, every select-side stop givesskip-reason: lane-stoppedand no escalation reason. The check run is the only write, so no failing status and no comment are posted. Withapplytrue, the same stops escalate, so the flip needs no workflow edit.test-scope.mjsanddeclare-test-scope.mjsdecide what the bot writes unattended, so they get floor rows withauthor-lift: false, regenerated byscripts/sync-hold-floor.py. In the three workflows the regeneration touched, only those two paths were added.fix-test-scope. The actions vocabulary has nodeclareverb, and the config reader refusesdeclare-test-scope. The script keeps its name,declare-test-scope.mjs.Verification
Each file was run alone under
nice -n 19 node --test:apply-patch.test.mjs: 443 pass (12 new).test-scope.test.mjs: 5 pass, including the parity check againstscripts/affected-tests.sh.declare-test-scope.test.mjs: 7 pass.fix-ci-dispatch.test.mjs,declare-test-scope.test.mjsanddispatch.test.mjstogether: 180 pass..github/actions/resolve-config/*.test.mjs(callers, live-config, resolve, lane-grants, api-budget-coverage and the rest),workflow-gates.test.mjs,gate-source.test.mjs,check-kill-switch.test.mjs,lane-registry.test.mjsandcollect-base-activity.test.mjs, with the files above: 2069 pass, 0 fail.live-config.test.mjs67 pass.Other suites, all with 0 failures:
Shell suites, all passing:
report-escalation.test.sh: 0 failures.check-artifact-retention.test.sh: 52 pass.check-convention-yaml.test.sh: 51 pass.pr-unblock-trusted-base.test.sh: 33 pass.read-runner-dispatcher-gate.test.sh: 10 pass.check-read-caller-keys.test.sh: 76 pass.write-runner-never-rules.test.sh: 75 pass.Flip criterion
test-scope.applystaysfalseuntil both of these are true:patch-pr-unblock-fix-test-scope-*patch equals the human fix that landed.The flip is its own PR and carries those numbers. Before the flip, also:
Independent review
Code and security review ran at c5f7aa3. Two Important findings were fixed in fcffa74:
The content rule now refuses a line above a shebang and any path that is not exact. The re-review at 8ea0167 found no Critical or Important finding and no security finding at P1-P3. Open suggestions: pin the write runner's
PATCH_ACTIVITYinput in a test, and assert that both reporters'if:is false in the dark context. Remaining P5: the check that the PR changed the suite is enforced only on the select side; the apply-side exact-path check narrows it.Related
Baseline from the
.workmeasurements of human fixes for Test Selection gaps:🤖 Generated with Claude Code