Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 199 additions & 1 deletion .github/workflows/dev-lead-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,22 @@
actions: read
checks: read
statuses: read
# A guarded pass (fix-reviews, fix-bot-comment, review-changes) does not push
# from here (#2143): it hands its result to `test-suite` and `push` below.
outputs:
handoff: ${{ steps.handoff.outputs.handoff }}
handoff_sha256: ${{ steps.handoff.outputs.handoff_sha256 }}
artifact: ${{ steps.handoff.outputs.artifact }}
intent: ${{ steps.handoff.outputs.intent }}
pr_number: ${{ steps.handoff.outputs.pr_number }}
base_sha: ${{ steps.handoff.outputs.base_sha }}
pass_start_iso: ${{ steps.handoff.outputs.pass_start_iso }}
env:
# The repo's test suite is PR code and never runs in this job, which holds
# the secrets (#2143). `work` makes the test-regression guard hand the pass's
# result to the test-suite job instead (scripts/lib/test-job-handoff.sh).
DEV_LEAD_PHASE: work
DEV_LEAD_HANDOFF_DIR: /tmp/dev-lead-handoff-${{ github.run_id }}
# dev-lead's acting identity is DECLARED in personas/dev-lead/persona.yml
# (runtime.identity.account) and resolved into BOT_USER by the "Resolve
# persona identity" step below. This job-level value is the hardcoded
Expand All @@ -145,7 +160,8 @@
# Repo-named test command for the pre-push regression guard
# (scripts/lib/test-regression-guard.sh, #2013). Mapped from a repository
# variable — NOT a workflow_call input — so no channel-pin sequencing is
# needed. Empty => the guard auto-discovers (npm/make/pytest/bats).
# needed. Empty => the guard auto-discovers (npm/make/pytest/bats). The suite
# itself runs in the test-suite job, which maps the same variable (#2143).
DEV_LEAD_TEST_CMD: ${{ vars.DEV_LEAD_TEST_CMD }}
# The instant from which a maintainer's "no change needed" reply may resolve a
# bot review thread (nochange_epoch_cutoff in dev-lead-fix-reviews.sh, #2079 /
Expand Down Expand Up @@ -632,6 +648,31 @@
REPO: ${{ github.repository }}
run: bash .dev-lead/scripts/dev-lead-fix-reviews.sh

# ── hand off to the test-suite job (#2143) ────────────────────────────
# A guarded pass stopped before its push and wrote the handoff. Publish its
# digest as a job output: the test-suite job runs PR code and cannot change
# this job's outputs, so the push job only accepts the tarball this job wrote.
- name: Hand off to the test-suite job
id: handoff
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
if: always()
env:
ARTIFACT: dev-lead-handoff-${{ github.run_id }}-${{ github.run_attempt }}
run: |
if [ -f "$DEV_LEAD_HANDOFF_DIR/outputs" ]; then
cat "$DEV_LEAD_HANDOFF_DIR/outputs" >> "$GITHUB_OUTPUT"
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
echo "::notice::handed off to test-suite: $(grep '^handoff_sha256=' "$DEV_LEAD_HANDOFF_DIR/outputs")"
fi

- name: Upload handoff
if: always() && steps.handoff.outputs.handoff == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ steps.handoff.outputs.artifact }}
path: ${{ env.DEV_LEAD_HANDOFF_DIR }}/handoff.tar
if-no-files-found: error
retention-days: 1

- name: Upload token usage log
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand All @@ -641,6 +682,163 @@
if-no-files-found: ignore
retention-days: 30

# ── test-suite ──────────────────────────────────────────────────────────────
# Runs the repo's test suite on a guarded pass's result (#2143). The suite is
# code from the PR branch, so this job holds NOTHING it could read: no secrets.*,
# `permissions: {}`, no checkout. It sees only the handoff tarball the dispatch
# job wrote (the pass's tree, the pre-pass tree, and the guard scripts) and its
# only output is the verdict. tests/dev-lead/unit/test_test_job_handoff.bats
# fails if this job gains a secret, a permission or a credentialed checkout.
# Skipped (no runner) for every pass that did not hand off.
test-suite:
needs: dispatch
if: needs.dispatch.outputs.handoff == 'true' && vars.AGENTS_PAUSED != 'true'
runs-on: ubuntu-latest
# At most two suite runs (the result, then the pre-pass head when the result is
# red), each capped by the guard's own 1500 s limit, plus setup.
timeout-minutes: 60
permissions: {}
env:
DEV_LEAD_TEST_CMD: ${{ vars.DEV_LEAD_TEST_CMD }}
outputs:
result: ${{ steps.suite.outputs.result }}
steps:
- name: Download handoff
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.dispatch.outputs.artifact }}
path: ${{ runner.temp }}/handoff

# The `bats --recursive tests` fallback of the guard needs it (#2013).
- name: Install bats
run: sudo apt-get install -y bats
Comment thread
don-petry marked this conversation as resolved.
Resolved

- name: Run the test suite on the pass's result
id: suite
env:
HANDOFF_SHA256: ${{ needs.dispatch.outputs.handoff_sha256 }}
run: |
set -euo pipefail
tarball="$RUNNER_TEMP/handoff/handoff.tar"
if [ "$(sha256sum "$tarball" | cut -d' ' -f1)" != "$HANDOFF_SHA256" ]; then
echo "::error::the handoff does not match the digest the dispatch job published — no verdict (#2143)"
exit 1
fi
guard="$RUNNER_TEMP/guard"
mkdir -p "$guard"
tar -xf "$tarball" -C "$guard" ./guard
source "$guard/guard/test-regression-guard.sh"
source "$guard/guard/test-job-handoff.sh"
log="$RUNNER_TEMP/suite.log"
rc=0
result="$(tjh_run_suite "$tarball" "$RUNNER_TEMP/suite" 2>"$log")" || rc=$?
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
cat "$log" >&2
if [ "$rc" -ne 0 ] || [ -z "$result" ]; then
echo "::error::the test suite could not be run on the handoff — no verdict (#2143)"
exit 1
fi
echo "result=$result" >> "$GITHUB_OUTPUT"
# The run summary: the verdict, the failing tests, and how long the suite took.
{
trg_summary_line "$(jq -r .verdict <<<"$result")" "$(jq -r .cmd <<<"$result")"
jq -r '.tests[] | "- `\(.)`"' <<<"$result"
echo
echo '```'
cat "$log"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
echo "::notice::$(trg_summary_line "$(jq -r .verdict <<<"$result")" "$(jq -r .cmd <<<"$result")")"

# ── push ────────────────────────────────────────────────────────────────────
# Finishes a guarded pass (#2143): restores the dispatch job's exact commits,
# reads the test-suite verdict and pushes only when it allows, then runs
# everything that follows a push — push verification, the claim-retraction
# sweep, thread resolution, the terminal comment. The 60-minute timeout (below)
# covers the push and all cleanup; if paginated API calls or post-push operations
# exceed that limit, the commit lands but terminal reporting and thread resolution
# may not complete. `always()`: a failed, cancelled or timed-out test job still
# gets here, so a "Fixed" reply whose commit does not land is retracted. That case
# has no verdict, so the script does not push (tjh_verdict fails closed). Skipped
# (no runner) without a handoff. AGENTS_PAUSED skips this whole job (every job
# carries the pause gate; see tests/dev-lead/integration/test_agents_paused_preflight.py),
# so nothing is pushed and no cleanup runs. A pause set before the run also skips
# dispatch, so no handoff exists; flipping it mid-run leaves dispatch's claims for
# the next pass to retract (#2143).
push:
needs: [dispatch, test-suite]
if: always() && needs.dispatch.outputs.handoff == 'true' && vars.AGENTS_PAUSED != 'true'
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: write
pull-requests: write
issues: write
actions: read
checks: read
statuses: read
env:
# Fail-safe default; the "Resolve persona identity" step sets the real one.
BOT_USER: 'don-petry'
DEV_LEAD_DRY_RUN: ${{ (vars.AGENTS_PAUSED == 'true' || vars.DEV_LEAD_DRY_RUN == 'true') && 'true' || 'false' }}
GH_TOKEN: ${{ secrets.GH_PAT_DON_PETRY || secrets.GH_PAT_WORKFLOWS || github.token }}

steps:
- name: Checkout caller repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ secrets.GH_PAT_DON_PETRY || secrets.GH_PAT_WORKFLOWS || github.token }}

- name: Checkout dev-lead scripts
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: petry-projects/.github-private
ref: ${{ inputs.agent_ref }}
path: .dev-lead
token: ${{ secrets.GH_PAT_DON_PETRY || secrets.GH_PAT_WORKFLOWS || github.token }}
sparse-checkout: |
scripts
prompts/dev-lead
personas/dev-lead

- name: Protect dev-lead scripts from accidental git staging
Comment thread
don-petry marked this conversation as resolved.
Resolved
run: echo ".dev-lead/" >> .git/info/exclude

- name: Resolve persona identity
run: |
if account="$(bash .dev-lead/scripts/lib/resolve-persona-identity.sh dev-lead .dev-lead/personas account)"; then
echo "BOT_USER=$account" >> "$GITHUB_ENV"
echo "resolved dev-lead identity: BOT_USER=$account"
else
echo "::warning::could not resolve dev-lead identity from manifest; using fallback BOT_USER=$BOT_USER"
fi

# A missing handoff must not stop the next step: it still retracts the
# pass's claim replies, then fails.
- name: Download handoff
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.dispatch.outputs.artifact }}
path: ${{ runner.temp }}/handoff

- name: Push the pass on the test-suite verdict
env:
DEV_LEAD_PHASE: push
INTENT_TYPE: ${{ needs.dispatch.outputs.intent }}
PR_NUMBER: ${{ needs.dispatch.outputs.pr_number }}
REPO: ${{ github.repository }}
PROMPTS_DIR: .dev-lead/prompts/dev-lead
DEV_LEAD_HANDOFF_FILE: ${{ runner.temp }}/handoff/handoff.tar
DEV_LEAD_HANDOFF_SHA256: ${{ needs.dispatch.outputs.handoff_sha256 }}
DEV_LEAD_BASE_SHA: ${{ needs.dispatch.outputs.base_sha }}
DEV_LEAD_PASS_START_ISO: ${{ needs.dispatch.outputs.pass_start_iso }}
DEV_LEAD_TEST_JOB_RESULT: ${{ needs.test-suite.result }}
DEV_LEAD_TRG_RESULT: ${{ needs.test-suite.outputs.result }}
run: |
bash .dev-lead/scripts/dev-lead-fix-reviews.sh || rc=$?
[ "${rc:-0}" -eq 2 ] && exit 0
exit "${rc:-0}"

# ── ci-relay ──────────────────────────────────────────────────────────────────
# Handles check_run completed failure events. No LLM — resolves PR number and
# fires repository_dispatch dev-lead-ci-failure back to the calling repo.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
tests/dev-lead/unit/test_claim_landing.bats \
tests/dev-lead/unit/test_test_tamper_guard.bats \
tests/dev-lead/unit/test_test_regression_guard.bats \
tests/dev-lead/unit/test_test_job_handoff.bats \
tests/dev-lead/unit/test_deferred_thread_verify.bats \
tests/dev-lead/unit/test_fewshot_assemble.bats \
tests/dev-lead/unit/test_net_diff_guard.bats \
Expand Down Expand Up @@ -361,7 +362,7 @@
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# NOTE: persist-credentials is intentionally left at the default (true) —

Check warning on line 365 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / Lint

365:9 [comments-indentation] comment not indented like content
# vci_resolve_reusable needs `git fetch origin` to authenticate against this
# private repo when resolving same-repo channel tags. Setting
# persist-credentials: false would silently push every such caller into the
Expand Down
2 changes: 2 additions & 0 deletions docs/dev-lead/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ on:
| Job | Trigger condition | Purpose |
|---|---|---|
| `dispatch` | All events except `check_run` + `repository_dispatch` from ci-relay | Classify intent, run handler |
| `test-suite` | `dispatch` handed off a guarded pass (fix-reviews, fix-bot-comment, review-changes, human-pr) | Run the repo's test suite on the pass's result with no secrets, `permissions: {}` and no checkout; output the verdict, command and test names (#2143) |
| `push` | `always()` after `test-suite`, when `dispatch` handed off | Push when the verdict permits (green, preexisting, unattributed, unbaselined, timeout, not-run), then run push verification, claim retraction, thread resolution and the terminal comment; refusal (no verdict or regression) retracts outstanding claims (#2143) |
| `ci-relay` | `check_run` completed, failure, not `dev-lead / *` | Resolve PR, emit `repository_dispatch` |

**Concurrency:**
Expand Down
Loading
Loading