diff --git a/.github/workflows/dashboard_refresh.yml b/.github/workflows/dashboard_refresh.yml index 8d9f91a..9f4b759 100644 --- a/.github/workflows/dashboard_refresh.yml +++ b/.github/workflows/dashboard_refresh.yml @@ -51,7 +51,10 @@ on: # actions: write → re-dispatch pages_dashboard.yml after a heal: the heal commit # is made with GITHUB_TOKEN, which never triggers other workflows, so without # the explicit dispatch the Pages page stays stale while the repo copy is fresh -# (the Mind was bitten by exactly this on 2026-08-21). +# (the Mind was bitten by exactly this on 2026-08-21). The same permission +# dispatches cortex_check.yml after a heal, and after a fresh-tip run that +# ledger_merge.yml or the cron started, so a GITHUB_TOKEN commit on main is +# always checked (Cortex#103). permissions: contents: write actions: write @@ -130,6 +133,15 @@ jobs: GH_TOKEN="${{ github.token }}" gh workflow run pages_dashboard.yml --ref main \ || echo "::warning::could not dispatch pages_dashboard.yml — the Pages page will lag until its next trigger" fi + # A dispatched run is usually ledger_merge.yml's, after a merge that + # left the board fresh: its GITHUB_TOKEN merge commit fired no push + # event, so check it from here. A push run needs no dispatch — the + # same push already triggered cortex_check.yml. + case "${GITHUB_EVENT_NAME}" in + workflow_dispatch|schedule) + GH_TOKEN="${{ github.token }}" gh workflow run cortex_check.yml --ref main \ + || echo "::warning::could not dispatch cortex_check.yml — its next push-triggered run will check main" ;; + esac exit 0 fi # Only PR runs error-without-healing; push, the nightly schedule and @@ -168,6 +180,10 @@ jobs: # healed page explicitly or the Pages site stays stale. GH_TOKEN="${{ github.token }}" gh workflow run pages_dashboard.yml --ref main \ || echo "::warning::could not dispatch pages_dashboard.yml — the Pages page will lag until its next trigger" + # ...and nothing checks the healed tip unless asked: without this + # main shows the stale tip's red check until the next push. + GH_TOKEN="${{ github.token }}" gh workflow run cortex_check.yml --ref main \ + || echo "::warning::could not dispatch cortex_check.yml — its next push-triggered run will check main" exit 0 fi echo "push rejected (attempt ${attempt}) — retrying on the new tip of main" diff --git a/.github/workflows/ledger_merge.yml b/.github/workflows/ledger_merge.yml index 24f1274..fd33345 100644 --- a/.github/workflows/ledger_merge.yml +++ b/.github/workflows/ledger_merge.yml @@ -53,10 +53,11 @@ on: # contents: write → the merge push to main and the branch delete. # pull-requests: write → merge through an open PR when the branch has one, so # the PR records as MERGED rather than being orphaned by a direct push. -# actions: write → re-dispatch cortex_check.yml and pages_dashboard.yml on -# main. A push made with GITHUB_TOKEN triggers nothing, so without this -# main's check never runs on the merge commit and the Pages board keeps the -# previous render. +# actions: write → dispatch dashboard_refresh.yml on main after the merge. A +# push made with GITHUB_TOKEN triggers nothing, so without this a merge that +# changes the board (a birth, a retirement) leaves dashboard.md stale and main +# red until the nightly cron; the refresh then dispatches cortex_check.yml and +# pages_dashboard.yml itself, on the healed tip. permissions: contents: write pull-requests: write @@ -309,17 +310,22 @@ jobs: done # The merge push above was made with GITHUB_TOKEN, which triggers no - # workflows, so main's check and the Pages board must be asked for - # explicitly — or the merge commit is never checked on main and Pages - # keeps serving the previous render (dashboard_refresh.yml dispatches - # Pages after its own heal push for the same reason). A redundant Pages - # dispatch is harmless: pages_dashboard.yml cancels in progress. - - name: Run the check on main and publish the board + # workflows, so the board must be asked for explicitly. Dispatch the + # REFRESH, not the check: a merge that adds or retires a project leaves + # dashboard.md stale, and a check dispatched straight from here runs on + # that stale tip and fails (09a0de6, the sdssj0946_subhalo_v2 birth, + # 2026-11-26 — main stayed red until the nightly cron). The refresh shares + # the cortex-main-writers queue, so it starts after this run has pushed, + # heals the board if it needs to, and then dispatches cortex_check.yml and + # pages_dashboard.yml on the tip it left. If the dispatch itself fails, + # fall back to checking main directly so the merge commit is still seen. + - name: Refresh the board on main (it then checks and publishes) if: steps.merge.outputs.via != '' env: GH_TOKEN: ${{ github.token }} run: | - gh workflow run cortex_check.yml --repo "${{ github.repository }}" --ref main \ - || echo "::warning::could not dispatch cortex_check.yml — its next push-triggered run will check main" - gh workflow run pages_dashboard.yml --repo "${{ github.repository }}" --ref main \ - || echo "::warning::could not dispatch pages_dashboard.yml — the Pages board will lag until its next trigger" + if ! gh workflow run dashboard_refresh.yml --repo "${{ github.repository }}" --ref main; then + echo "::warning::could not dispatch dashboard_refresh.yml — checking main directly; the 03:35 cron will heal the board" + gh workflow run cortex_check.yml --repo "${{ github.repository }}" --ref main \ + || echo "::warning::could not dispatch cortex_check.yml — its next push-triggered run will check main" + fi diff --git a/tests/test_ledger_merge.py b/tests/test_ledger_merge.py index 301078e..6872201 100644 --- a/tests/test_ledger_merge.py +++ b/tests/test_ledger_merge.py @@ -336,6 +336,22 @@ def test_the_page_workflow_spells_the_conductor_as_implemented(): assert "dashboard --cortex . --apply" in text +def test_a_landed_merge_refreshes_the_board_and_the_refresh_checks_main(): + """A GITHUB_TOKEN merge push triggers nothing, so ledger_merge.yml must ask + for the refresh (a birth leaves dashboard.md stale), and the refresh must + then dispatch the check on the tip it left — or main stays red until the + nightly cron (09a0de6, 2026-11-26; Cortex#103).""" + wf = REPO / ".github" / "workflows" + merge = (wf / "ledger_merge.yml").read_text() + refresh = (wf / "dashboard_refresh.yml").read_text() + assert "gh workflow run dashboard_refresh.yml" in merge + heal = refresh.split('echo "healed on attempt ${attempt}"', 1)[1].split("exit 0", 1)[0] + assert "gh workflow run cortex_check.yml" in heal + fresh = refresh.split("if check; then", 1)[1].split("exit 0", 1)[0] + assert "workflow_dispatch|schedule)" in fresh + assert "gh workflow run cortex_check.yml" in fresh + + def test_no_scheduled_job_mutates_the_ledger(): """The only scheduled writer renders the two generated pages.""" for p in (REPO / ".github" / "workflows").glob("*.yml"):