Skip to content

feat: wake yolo direct-PR tasks when GitHub checks turn green - #6052

Open
PawanAIT wants to merge 7 commits into
kunchenguid:mainfrom
PawanAIT:pawan/direct-pr-green-wake
Open

PawanAIT wants to merge 7 commits into
kunchenguid:mainfrom
PawanAIT:pawan/direct-pr-green-wake

Conversation

@PawanAIT

@PawanAIT PawanAIT commented Sep 28, 2026 •

Copy link
Copy Markdown

What Changed

  • Add a checks-green watcher probe for yolo direct-PR tasks at their recorded GitHub head, sharing required-check and producer verification with the merge gate; landing still requires live merge verification.
  • Deduplicate wakes by canonical PR identity, head, and passing check set using private markers written after durable wake publication and removed during teardown.
  • Document the landing-wake lifecycle and add regression coverage for eligibility, required-check failures, fallback checks, duplicate suppression, new-head notifications, and subsequent merge retirement.

Risk Assessment

✅ Low: The fix rounds did exactly what the user decided: a verbatim helper move, green detection gated on the base branch's required checks, and skipping counted as passing. All of it fails silent on errors, never grants merge authority, and has behavioral tests that tell the fixed code from the old code.

Testing

Focused regression checks passed. Live CLI validation confirmed malformed-input refusal, silent authentication failure, and notification-marker cleanup during isolated teardown. Captured CLI and persisted-state evidence plus explicitly mocked watcher transcripts. No full suite, lint, or static analysis ran; authenticated GitHub wake and merge behavior remains untested live.

  • Live validation: ⚠️ inconclusive - 3 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Malformed or unsupported green-probe requests remain silent ✅ pass live round4-live-cli.json records seven direct invocations, each exiting successfully without output.
Unavailable GitHub authentication produces no green notification ✅ pass live round4-live-cli.json records real gh exiting 4 for missing authentication and the green probe exiting 0 with empty stdout and stderr.
A green yolo direct-PR head wakes once, changed checks or heads wake again, and merging retires monitoring ⏸️ untested no The isolated real gh attempt required authentication; no GH_TOKEN or GITHUB_TOKEN was supplied. Local fixtures exercised the watcher but mocked GitHub and are not live proof. Completing this scenario…
Skipped and neutral checks permit notification in required and fallback check lists ⏸️ untested no Real gh could not authenticate in the disposable environment. Local API responses cannot establish actual GitHub SKIPPED/NEUTRAL behavior. Dedicated credentials and an authorized disposable GitHub rep…
Absent requirements, unreadable rules, pending or failed checks, empty lists, and stale heads suppress notification ⏸️ untested no The real authentication attempt failed before GitHub state could be read. Disposable local fixtures covered these adversarial cases only through mocked responses. Live coverage requires dedicated GitH…
Tasks lacking yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green wake ⏸️ untested no The isolated watcher regression used mocked forge/backend responses. Without an authenticated controllable PR, silence cannot distinguish correct eligibility filtering from unavailable forge access. D…
The merge command retains required-check enforcement after moving helpers into the shared library ⏸️ untested no The tests execute the merge command with mocked GitHub. Real gh authentication was unavailable, and remote merge mutations are outside the workspace-only authority. Live proof requires dedicated crede…
Tearing down a finished task removes its green-notification marker ✅ pass live round4-live-teardown.txt shows the private persisted marker before teardown, the real command exiting 0, and both marker and task metadata absent afterward.
Evidence: Real green-probe input guards and authentication-failure transcript

Source: Real green-probe input guards and authentication-failure transcript

{
  "isolation": "Real installed gh and repository CLI; fresh workspace-only HOME and GH_CONFIG_DIR; no mocks, operator credentials, or remote mutations.",
  "records": [
    {
      "label": "missing arguments",
      "command": [
        "bin/fm-pr-green-poll.sh"
      ],
      "exit_code": 0,
      "stdout": "",
      "stderr": ""
    },
    {
      "label": "unsupported forge",
      "command": [
        "bin/fm-pr-green-poll.sh",
        "https://gitlab.com/g/p/-/merge_requests/7",
        "1111111111111111111111111111111111111111"
      ],
      "exit_code": 0,
      "stdout": "",
      "stderr": ""
    },
    {
      "label": "noncanonical pull number",
      "command": [
        "bin/fm-pr-green-poll.sh",
        "https://github.com/o/r/pull/07",
        "1111111111111111111111111111111111111111"
      ],
      "exit_code": 0,
      "stdout": "",
      "stderr": ""
    },
    {
      "label": "short head",
      "command": [
        "bin/fm-pr-green-poll.sh",
        "https://github.com/o/r/pull/7",
        "111111111111111111111111111111111111111"
      ],
      "exit_code": 0,
      "stdout": "",
      "stderr": ""
    },
    {
      "label": "uppercase head",
      "command": [
        "bin/fm-pr-green-poll.sh",
        "https://github.com/o/r/pull/7",
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
      ],
      "exit_code": 0,
      "stdout": "",
      "stderr": ""
    },
    {
      "label": "multiline head",
      "command": [
        "bin/fm-pr-green-poll.sh",
        "https://github.com/o/r/pull/7",
        "1111111111111111111111111111111111111111\nx"
      ],
      "exit_code": 0,
      "stdout": "",
      "stderr": ""
    },
    {
      "label": "extra argument",
      "command": [
        "bin/fm-pr-green-poll.sh",
        "https://github.com/o/r/pull/7",
        "1111111111111111111111111111111111111111",
        "extra"
      ],
      "exit_code": 0,
      "stdout": "",
      "stderr": ""
    },
    {
      "label": "real gh authentication prerequisite",
      "command": [
        "gh",
        "api",
        "graphql",
        "-f",
        "query=query { viewer { login } }"
      ],
      "exit_code": 4,
      "stdout": "",
      "stderr": "To get started with GitHub CLI, please run:  gh auth login\nAlternatively, populate the GH_TOKEN environment variable with a GitHub API authentication token.\n"
    },
    {
      "label": "unavailable forge stays silent",
      "command": [
        "bin/fm-pr-green-poll.sh",
        "https://github.com/o/r/pull/7",
        "1111111111111111111111111111111111111111"
      ],
      "exit_code": 0,
      "stdout": "",
      "stderr": ""
    }
  ]
}
Evidence: Supplemental watcher notification transcript — mocked GitHub, not live validation

Source: Supplemental watcher notification transcript — mocked GitHub, not live validation

{
  "notice": "Supplemental integration evidence: real watcher and persisted wake outputs, but gh and backend responses are mocked. NOT live GitHub validation.",
  "outputs": {
    "green-a.out": "check: ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-tmp/fm-pr-check-security.QckSh1/checks-green-once-per-head/home/state/task-a.check.sh: checks-green\n",
    "green-a-again.out": "check: ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-tmp/fm-pr-check-security.QckSh1/checks-green-once-per-head/home/state/z-stop.check.sh: stop-cycle\n",
    "required-absent.out": "check: ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-tmp/fm-pr-check-security.QckSh1/checks-green-once-per-head/home/state/z-stop.check.sh: stop-cycle\n",
    "required-expected.out": "check: ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-tmp/fm-pr-check-security.QckSh1/checks-green-once-per-head/home/state/z-stop.check.sh: stop-cycle\n",
    "required-passed.out": "check: ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-tmp/fm-pr-check-security.QckSh1/checks-green-once-per-head/home/state/task-a.check.sh: checks-green\n",
    "required-reordered.out": "check: ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-tmp/fm-pr-check-security.QckSh1/checks-green-once-per-head/home/state/z-stop.check.sh: stop-cycle\n",
    "green-b.out": "check: ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-tmp/fm-pr-check-security.QckSh1/checks-green-once-per-head/home/state/task-a.check.sh: checks-green\n",
    "watch.out": "check: ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-tmp/fm-pr-check-security.QckSh1/checks-green-once-per-head/home/state/task-a.check.sh: merged\n"
  }
}
Evidence: Real isolated teardown removes the persisted green-notification marker

Source: Real isolated teardown removes the persisted green-notification marker

Real fm-teardown.sh; marked workspace-only lab; private PID namespace and /proc; absent private tmux socket; no mocks or bypass.
Before teardown: task metadata exists = True
Before teardown: notification marker mode = 0o600
Persisted notification marker:
fm-pr-poll-green-notified-v2
github
github.com
o/r
7
1111111111111111111111111111111111111111
51d655849fba2b818a8595df16996c57b43a5081eafb78bf721864c83716b9b8

fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-live/fm-lab.KzyVBF
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 1s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.pi/extensions/fm-primary-turnend-guard.ts -e ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
teardown task-a complete (window fm-lab-cleanup:fm-task-a, worktree ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-live/fm-lab.KzyVBF/missing-worktree)
Backlog: task-a just finished (config/backlog-backend selects manual editing). Update ~/.no-mistakes/worktrees/c936b9d8764d/01M3MFM0A9WC1KFH8ECBP61EYK/.test-green-live/fm-lab.KzyVBF/data/backlog.md - move task-a to Done, keep Done to the 10 most recent, then re-scan Queued and dispatch only work whose blockers are gone and date is due.

fm-teardown.sh exit=0
After teardown: task-a.meta exists = False
After teardown: task-a.pr-poll-green-notified exists = False
- Outcome: ⚠️ 1 warning across 4 runs (31m57s)

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 0 issues

✅ No issues found.

  • ⚠️ bin/fm-pr-green-poll.sh:46 - The ci-1 fix round introduced a rule that treats only gh bucket pass as green. gh puts SKIPPED and NEUTRAL conclusions in the skipping bucket, so they never count as green. GitHub counts a skipped required check as satisfied, and the rollup still reads SUCCESS. bin/fm-pr-merge.sh also treats them as green (github_checks_not_green accepts SUCCESS, NEUTRAL, or SKIPPED, lines 570-590). Example: a yolo direct-PR head has required check ci passing and required job deploy-preview skipped by an if: condition. fm-pr-merge.sh would land it, but this probe stays silent forever, so the landing prompt the feature exists to send never arrives. The fallback path (repos with no required checks, line 41) is hit harder: any skipped or neutral job in any workflow blocks the wake for that head permanently. Before this round, a SUCCESS rollup was enough, so this lost-wake case is new. The recorded decision said "bucket pass for each", but it did not address skipped or neutral checks, and the wake definition now disagrees with the merge gate it prompts. Same rule elsewhere: tests/fm-pr-check-security.test.sh:3734 asserts skipping is not green in both the required and fallback lists; docs/architecture.md:82-83 describe "every bucket pass". Decision needed: should skipping count as passing, matching fm-pr-merge.sh?
  • ⚠️ bin/fm-pr-green-poll.sh:37 - The ci-1 decision asked that a head count as green only when every required check has reported and passed. gh pr checks --required only lists checks that exist in the rollup. A required GitHub Actions or app check run that has not been created yet does not appear at all. Example: required checks are ci and review; ci passes and review has no check run yet. The rollup reads SUCCESS, --required returns [ci pass], and the probe sends checks-green, which is the premature wake greptile described. The fix round's check-set digest does prevent the lost prompt: a later review success changes the digest and wakes again. But the premature wake is still reachable. The test the fix round added for this, test_green_poll_missing_required (tests/fm-pr-check-security.test.sh:3715), mocks review as a reported pending entry, not an absent one, so it would pass without covering the greptile case. docs/architecture.md:88 claims coverage of "missing required checks", and docs/architecture.md:82 implies --required enumerates all requirements. A durable fix would compare against the base branch's required contexts, which fm-pr-merge.sh already reads (github_read_required_contexts / github_required_checks_missing). That means moving that logic into a shared helper, which goes beyond the prescribed mechanism, so the remedy needs authorization. Otherwise, accept the premature-then-re-wake behavior and fix the test name and docs so they describe it honestly.
  • ℹ️ bin/fm-pr-green-poll.sh:40 - Any --required failure with empty stdout falls back to the all-checks list. That includes transient network, auth, or rate-limit errors, not just gh's "no required checks reported" case. The fallback list includes non-required checks, so its digest differs from the required-list digest. Example: a repo has required check ci and optional check lint. Sweep 1 wakes with {ci}; the merge is refused (for example, the branch is BEHIND). Sweep 2 hits a transient --required failure, falls back to {ci, lint}, and wakes again. Sweep 3 returns {ci} and wakes a third time, because the marker holds only the last digest. This contradicts the header's "Errors and partial reads stay silent" (line 8). Fix: fall back only when gh's stderr reports that no required checks exist, and exit silently on any other --required failure.

🔧 Fix applied.
6 issues (5 warnings, 1 info) still open:

  • ⚠️ bin/fm-pr-green-poll.sh:46 - The ci-1 fix round introduced a rule that treats only gh bucket pass as green. gh puts SKIPPED and NEUTRAL conclusions in the skipping bucket, so they never count as green. GitHub counts a skipped required check as satisfied, and the rollup still reads SUCCESS. bin/fm-pr-merge.sh also treats them as green (github_checks_not_green accepts SUCCESS, NEUTRAL, or SKIPPED, lines 570-590). Example: a yolo direct-PR head has required check ci passing and required job deploy-preview skipped by an if: condition. fm-pr-merge.sh would land it, but this probe stays silent forever, so the landing prompt the feature exists to send never arrives. The fallback path (repos with no required checks, line 41) is hit harder: any skipped or neutral job in any workflow blocks the wake for that head permanently. Before this round, a SUCCESS rollup was enough, so this lost-wake case is new. The recorded decision said "bucket pass for each", but it did not address skipped or neutral checks, and the wake definition now disagrees with the merge gate it prompts. Same rule elsewhere: tests/fm-pr-check-security.test.sh:3734 asserts skipping is not green in both the required and fallback lists; docs/architecture.md:82-83 describe "every bucket pass". Decision needed: should skipping count as passing, matching fm-pr-merge.sh?
  • ⚠️ bin/fm-pr-green-poll.sh:37 - The ci-1 decision asked that a head count as green only when every required check has reported and passed. gh pr checks --required only lists checks that exist in the rollup. A required GitHub Actions or app check run that has not been created yet does not appear at all. Example: required checks are ci and review; ci passes and review has no check run yet. The rollup reads SUCCESS, --required returns [ci pass], and the probe sends checks-green, which is the premature wake greptile described. The fix round's check-set digest does prevent the lost prompt: a later review success changes the digest and wakes again. But the premature wake is still reachable. The test the fix round added for this, test_green_poll_missing_required (tests/fm-pr-check-security.test.sh:3715), mocks review as a reported pending entry, not an absent one, so it would pass without covering the greptile case. docs/architecture.md:88 claims coverage of "missing required checks", and docs/architecture.md:82 implies --required enumerates all requirements. A durable fix would compare against the base branch's required contexts, which fm-pr-merge.sh already reads (github_read_required_contexts / github_required_checks_missing). That means moving that logic into a shared helper, which goes beyond the prescribed mechanism, so the remedy needs authorization. Otherwise, accept the premature-then-re-wake behavior and fix the test name and docs so they describe it honestly.
  • ℹ️ bin/fm-pr-green-poll.sh:40 - Any --required failure with empty stdout falls back to the all-checks list. That includes transient network, auth, or rate-limit errors, not just gh's "no required checks reported" case. The fallback list includes non-required checks, so its digest differs from the required-list digest. Example: a repo has required check ci and optional check lint. Sweep 1 wakes with {ci}; the merge is refused (for example, the branch is BEHIND). Sweep 2 hits a transient --required failure, falls back to {ci, lint}, and wakes again. Sweep 3 returns {ci} and wakes a third time, because the marker holds only the last digest. This contradicts the header's "Errors and partial reads stay silent" (line 8). Fix: fall back only when gh's stderr reports that no required checks exist, and exit silently on any other --required failure.
  • ⚠️ bin/fm-pr-green-poll.sh:47 - Still waiting on a decision; the code is unchanged since round 2. The ci-1 fix round made gh's pass bucket the only green result. gh puts SKIPPED and NEUTRAL conclusions in the skipping bucket, so those checks never count as green. The merge gate this wake prompts disagrees: bin/fm-pr-merge.sh github_checks_not_green treats SUCCESS, NEUTRAL and SKIPPED as green (around lines 570-590), and GitHub counts a skipped required check as satisfied. Example: required ci passes and required deploy-preview is skipped by an if: condition. fm-pr-merge.sh would land the PR, but this probe stays silent at that head forever, so the landing prompt is lost. The no-required-checks fallback (line 40) has the same problem: any skipped or neutral job in any workflow blocks the wake. The same rule is encoded in tests/fm-pr-check-security.test.sh:3750 (skipping asserted not green for both the required and fallback lists) and in docs/architecture.md:82. Decision needed: should the skipping bucket count as passing, to match fm-pr-merge.sh?
  • ⚠️ bin/fm-pr-green-poll.sh:37 - Still waiting on a decision. The latest fix round made this case easier to reach. gh pr checks --required filters the reported rollup by isRequired, so a required check with no check run yet does not appear. Path 1: required checks are ci and review, ci passes and review has not been created. The list is [ci pass] and the probe emits checks-green early. Path 2, sibling added by the round-3 fallback change (lines 38-40): gh's no required checks reported on '<branch>' branch error means no reported check is required, not that the repo requires none. If required ci has not started yet and optional lint has passed, the probe falls back to all checks and wakes on {lint}. The later {ci} digest wakes again, so the prompt is not lost, but the premature wake greptile described (ci-1) is still reachable. test_green_poll_missing_required (tests/fm-pr-check-security.test.sh:3731) mocks review as a reported pending entry, so it does not cover an absent check. docs/architecture.md:88 claims coverage of "missing required checks", and docs/architecture.md:82-83 imply --required lists every requirement. A durable fix would compare against the base branch's required contexts, which fm-pr-merge.sh already reads (github_read_required_contexts / github_required_checks_missing), through a shared helper. That goes beyond the prescribed mechanism, so the remedy needs authorization. The alternative is to accept premature-then-re-wake and make the test name and docs describe it honestly.
  • ⚠️ tests/fm-pr-check-security.test.sh:3773 - The round-3 fix added a --green argument mode to the security test script that runs only the green-poll tests and exits. The finding it was addressing (green-fallback-digest-flap) did not need a new test-runner mode, and no intent requirement asks for one. It is a second entry path into the suite, and it will silently drift if new green tests are added only to the default list. Recommend removing it.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ The central green-check notification flow remains unproven against GitHub. The focused regression tests passed with mocked forge responses, but no GitHub token was supplied, and real gh refused GraphQL access in the isolated environment. Completing live validation requires a dedicated GH_TOKEN and authorization to use a disposable GitHub repository/PR beyond the current workspace-only boundary; operator credentials and shared repositories were left untouched.
  • ⚠️ live validation verdict: inconclusive (3 of 6 scenarios were driven live against the product); untested: A yolo direct-PR head turning green notifies once, a newly recorded head notifies again, and a later merge still retires monitoring, Pending, failed, absent, closed, or stale-head check results never announce green, Tasks without yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green notification
  • Live validation: ⚠️ inconclusive - 3 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A yolo direct-PR head turning green notifies once, a newly recorded head notifies again, and a later merge still retires monitoring ⏸️ untested no Built disposable task homes and exercised the complete script flow with mocked forge responses. Live GraphQL access through real gh failed because no test credential was supplied. GitHub's authenticat…
Pending, failed, absent, closed, or stale-head check results never announce green ⏸️ untested no The response matrix was exercised with mocked forge data, not live PR states. The isolated real-gh credential probe failed; constructing these states on GitHub requires dedicated credentials and permi…
Tasks without yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green notification ⏸️ untested no Disposable task configurations were exercised successfully against mocked forge responses. Demonstrating exclusion while a real PR is green still needs authenticated access to an authorized GitHub fix…
Invalid poll arguments and unsupported PR URLs produce no green signal ✅ pass live live-cli-checks.json records real CLI invocations for noncanonical numbering, GitLab URLs, short/multiline heads, and missing/extra arguments.
Unavailable GitHub authentication cannot be mistaken for passing checks ✅ pass live live-cli-checks.json records real gh exiting 4 and the real green poll emitting no output.
Cleaning up a finished task removes its delivered-green notification marker ✅ pass live live-cli-checks.json contains the private marker before cleanup, the real teardown completion output, and both metadata and marker absent afterward.
  • TMPDIR="$PWD/.test-phase-tmp" bash tests/fm-pr-check-security.test.sh passed.

  • Re-ran test_green_poll_contract, test_checks_green_wakes_once_per_recorded_head, test_checks_green_needs_a_yolo_direct_pr_recorded_head, and test_teardown_removes_poll_artifacts through a temporary focused driver, retaining product transcripts and persisted records. Forge responses were mocked.

  • Ran python3 .test-phase-tmp/live-checks.py: invoked the real bin/fm-pr-green-poll.sh with malformed URLs, invalid heads, missing/extra arguments, and unavailable GitHub authentication.

  • Ran real gh api graphql -f 'query=query { viewer { login } }' with isolated HOME and GH_CONFIG_DIR; it exited 4 requesting authentication.

  • Created a marked disposable home using bin/fm-lab-home.sh create, seeded a delivered-head marker, and ran real bin/fm-teardown.sh task-a without force or lifecycle bypass. Verified the task metadata and green-notification marker were removed.

  • Corrected an initially invalid windowless cleanup fixture to reference an absent private tmux endpoint, then successfully repeated cleanup.

  • Removed temporary drivers and disposable data; git status --short and git diff --exit-code confirmed no remaining worktree changes.

  • ⚠️ live validation verdict: inconclusive (3 of 8 scenarios were driven live against the product); untested: A green yolo direct-PR head wakes once, later checks or a new head wake again, and a subsequent merge retires monitoring, Skipped and neutral checks permit a green wake in both required and fallback check lists, Absent required checks, unreadable requirements, pending or failed checks, empty lists, and stale heads remain silent, Tasks lacking yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green notification, The merge command preserves required-check enforcement after its helpers move into the shared library

  • Live validation: ⚠️ inconclusive - 3 of 8 scenarios driven live against the product

Scenario Result Live Evidence
Invalid or unsupported green-poll requests produce no notification ✅ pass live live-cli-transcript.json: missing arguments, GitLab URL, noncanonical PR number, malformed head, and extra argument all returned silently.
A GitHub authentication failure does not announce green ✅ pass live live-cli-transcript.json: real gh returned authentication-required exit code 4; the real green probe returned exit code 0 with empty output.
Tearing down a retired task removes its green-notification marker ✅ pass live live-cli-transcript.json: fm-teardown reported completion, and both marker_exists and task_meta_exists were false.
A green yolo direct-PR head wakes once, later checks or a new head wake again, and a subsequent merge retires monitoring ⏸️ untested no Built disposable local fixtures and exercised the watcher, but GitHub responses were mocked. Real gh in isolated configuration required authentication, and no dedicated GH_TOKEN was supplied. Creating…
Skipped and neutral checks permit a green wake in both required and fallback check lists ⏸️ untested no Exercised SKIPPED, NEUTRAL, and skipping-bucket fixtures, but cannot create authentic GitHub check conclusions locally. The real gh authentication probe failed in isolation. Live proof requires a dedi…
Absent required checks, unreadable requirements, pending or failed checks, empty lists, and stale heads remain silent ⏸️ untested no Disposable fixtures covered classic protection, rulesets, producer identity, required-list fallback, and stale-head boundaries. These are mocked forge observations, not live proof. Authenticated GitHu…
Tasks lacking yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green notification ⏸️ untested no The watcher eligibility regression ran in disposable fixtures, but authentic green GitHub state could not be supplied: isolated real gh required authentication and no dedicated token was available. A…
The merge command preserves required-check enforcement after its helpers move into the shared library ⏸️ untested no Executed the real merge entrypoint against mocked forge responses. An actual merge would require a dedicated GitHub token and explicit authorization to mutate a disposable remote repository; neither w…
  • TMPDIR="$PWD/.test-phase-tmp" bash tests/.test-phase-green.sh ran seven existing tests selected from tests/fm-pr-check-security.test.sh: test_green_poll_missing_required, test_green_poll_requirement_reads, test_green_poll_check_lists, test_green_poll_contract, test_checks_green_wakes_per_head_and_check_set, test_checks_green_needs_a_yolo_direct_pr_recorded_head, and test_teardown_removes_poll_artifacts. Repeated to capture mocked watcher output.
  • TMPDIR="$PWD/.test-phase-tmp" bash tests/.test-phase-merge.sh ran six existing shared-helper regressions: test_required_check_that_never_reported_refuses, test_required_checks_reported_and_green_merge, test_unreadable_required_set_refuses, test_required_producer_identity, test_app_bound_required_status_context_matches_by_name, and test_required_partial_reads_report_all_failures.
  • python3 .test-phase-tmp/live.py drove the real green-poll CLI with invalid requests and an unauthenticated GitHub request, then ran bin/fm-teardown.sh task-a against a disposable marked lab home and verified removal of the notification marker and task metadata.
  • Captured live CLI output and explicitly labeled mocked watcher output in the evidence directory. Removed temporary runners, fixtures, and lab data; git status --short and git diff --stat were empty.

🔧 Fix applied.
1 warning still open:

  • ⚠️ live validation verdict: inconclusive (3 of 8 scenarios were driven live against the product); untested: A green yolo direct-PR head wakes once, later checks or a new head wake again, and a subsequent merge retires monitoring, Skipped and neutral checks permit a green wake in both required and fallback check lists, Absent required checks, unreadable requirements, pending or failed checks, empty lists, and stale heads remain silent, Tasks lacking yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green notification, The merge command preserves required-check enforcement after its helpers move into the shared library
  • Live validation: ⚠️ inconclusive - 3 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Invalid URLs, unsupported forges, and malformed head arguments produce no green announcement ✅ pass live round3-live-cli.json: six direct green-poll CLI invocations
An actual GitHub authentication failure never announces green ✅ pass live round3-live-cli.json: real gh credential probe and subsequent green-poll invocation
Tearing down a completed task removes its delivered green-notification marker ✅ pass live round3-live-cli.json: persisted marker, teardown output, and final state
A green yolo direct-PR head wakes once, later checks or a new head wake again, and a subsequent merge retires monitoring ⏸️ untested no The targeted watcher regression passed with mocked GitHub responses. A real gh GraphQL attempt in isolated configuration exited 4 for missing authentication. Local fixtures cannot reproduce authoritat…
Skipped and neutral checks permit a green wake in both required and fallback check lists ⏸️ untested no Focused regressions passed for skipping buckets and satisfied skipped/neutral requirements, but used mocked forge responses. Real gh requires an unavailable isolated credential; creating remote check…
Absent required checks, unreadable requirements, pending or failed checks, empty lists, and stale heads remain silent ⏸️ untested no Adversarial regressions passed with mocked classic protection, rulesets, check producers, and rollups. The real isolated gh credential probe failed, preventing authoritative GitHub state setup and obs…
Tasks lacking yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green notification ⏸️ untested no The targeted watcher regression passed, but its forge and endpoint dependencies were mocked. Direct unsupported-forge rejection was exercised live separately. Full watcher validation with registered r…
The merge command preserves required-check enforcement after its helpers move into the shared library ⏸️ untested no Six focused merge regressions passed with mocked forge responses. A real merge would require authenticated GitHub access and remote write authority, neither available within this phase's constraints.…
  • Ran six selected functions from tests/fm-pr-check-security.test.sh: test_green_poll_contract, test_green_poll_missing_required, test_green_poll_requirement_reads, test_green_poll_check_lists, test_checks_green_wakes_per_head_and_check_set, and test_checks_green_needs_a_yolo_direct_pr_recorded_head, using a temporary runner and mocked forge responses.
  • Ran six selected functions from tests/fm-pr-merge.test.sh: test_required_check_that_never_reported_refuses, test_required_checks_reported_and_green_merge, test_unreadable_required_set_refuses, test_required_producer_identity, test_app_bound_required_status_context_matches_by_name, and test_required_partial_reads_report_all_failures, using a temporary runner and mocked forge responses.
  • Ran python3 .test-phase/live.py to invoke the real bin/fm-pr-green-poll.sh against malformed inputs, unsupported forge input, and an actual unauthenticated gh failure.
  • Ran gh api graphql -f 'query=query { viewer { login } }' with isolated configuration; gh exited 4 requesting a credential.
  • Created an isolated home with bin/fm-lab-home.sh create, seeded a delivered-head/check-set marker, and ran bin/fm-teardown.sh task-a against an absent private tmux endpoint; verified task metadata and marker removal.
  • Captured CLI output and persisted-state evidence, removed disposable labs and temporary runners, and verified git status --short was empty. No full suite, lint, or static analysis was run.

🔧 Fix applied.
1 warning still open:

  • ⚠️ live validation verdict: inconclusive (3 of 8 scenarios were driven live against the product); untested: A green yolo direct-PR head wakes once, changed checks or heads wake again, and merging retires monitoring, Skipped and neutral checks permit notification in required and fallback check lists, Absent requirements, unreadable rules, pending or failed checks, empty lists, and stale heads suppress notification, Tasks lacking yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green wake, The merge command retains required-check enforcement after moving helpers into the shared library
  • Live validation: ⚠️ inconclusive - 3 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Malformed or unsupported green-probe requests remain silent ✅ pass live round4-live-cli.json records seven direct invocations, each exiting successfully without output.
Unavailable GitHub authentication produces no green notification ✅ pass live round4-live-cli.json records real gh exiting 4 for missing authentication and the green probe exiting 0 with empty stdout and stderr.
A green yolo direct-PR head wakes once, changed checks or heads wake again, and merging retires monitoring ⏸️ untested no The isolated real gh attempt required authentication; no GH_TOKEN or GITHUB_TOKEN was supplied. Local fixtures exercised the watcher but mocked GitHub and are not live proof. Completing this scenario…
Skipped and neutral checks permit notification in required and fallback check lists ⏸️ untested no Real gh could not authenticate in the disposable environment. Local API responses cannot establish actual GitHub SKIPPED/NEUTRAL behavior. Dedicated credentials and an authorized disposable GitHub rep…
Absent requirements, unreadable rules, pending or failed checks, empty lists, and stale heads suppress notification ⏸️ untested no The real authentication attempt failed before GitHub state could be read. Disposable local fixtures covered these adversarial cases only through mocked responses. Live coverage requires dedicated GitH…
Tasks lacking yolo, direct-PR mode, a recorded head, or GitHub eligibility receive no green wake ⏸️ untested no The isolated watcher regression used mocked forge/backend responses. Without an authenticated controllable PR, silence cannot distinguish correct eligibility filtering from unavailable forge access. D…
The merge command retains required-check enforcement after moving helpers into the shared library ⏸️ untested no The tests execute the merge command with mocked GitHub. Real gh authentication was unavailable, and remote merge mutations are outside the workspace-only authority. Live proof requires dedicated crede…
Tearing down a finished task removes its green-notification marker ✅ pass live round4-live-teardown.txt shows the private persisted marker before teardown, the real command exiting 0, and both marker and task metadata absent afterward.
  • Ran seven focused functions from tests/fm-pr-check-security.test.sh using a disposable runner: test_green_poll_contract, test_green_poll_missing_required, test_green_poll_requirement_reads, test_green_poll_check_lists, test_checks_green_wakes_per_head_and_check_set, test_checks_green_needs_a_yolo_direct_pr_recorded_head, and test_teardown_removes_poll_artifacts.
  • Ran six focused functions from tests/fm-pr-merge.test.sh: required-check absence, successful satisfaction, unreadable requirements, producer identity, app-bound status contexts, and partial-read diagnostics.
  • Executed bin/fm-pr-green-poll.sh directly with missing arguments, unsupported forge, noncanonical PR number, invalid heads, and extra arguments.
  • Executed real gh api graphql -f 'query=query { viewer { login } }' with isolated configuration, then verified the real green probe remained silent when authentication was unavailable.
  • Re-ran test_checks_green_wakes_per_head_and_check_set and captured emitted watcher notifications, explicitly labelled as mocked integration evidence.
  • Ran unshare --user --map-root-user --pid --fork --mount-proc bash .test-green-live/teardown.sh, exercising real bin/fm-teardown.sh task-a in a marked lab home without mocks or a lifecycle bypass.
  • Removed disposable runners and lab directories; git status --short confirmed no remaining worktree changes.
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Adds automated landing trigger for direct-PR tasks when checks pass.

The PR appears safe to merge, with the previously reported repeated-read cost remaining non-blocking.

Reviews (3) · Last reviewed commit: "no-mistakes(test): Clarify shared requir..."

Comment thread bin/fm-pr-green-poll.sh Resolved
A direct-PR worker reports ready as soon as its pull request is open,
before CI finishes, and the merge poll only ever reported MERGED, so a
yolo task sat green until an unrelated heartbeat or a custom check
prompted the first mate to merge it.

When a validated GitHub merge poll reads no merge for a direct-PR task
recorded with yolo=on and a pr_head=, the watcher now runs
bin/fm-pr-green-poll.sh. It prints checks-green only while the pull
request is open at exactly that head and GitHub reports the commit's
combined check state as SUCCESS. The watcher surfaces that as one check
wake per recorded head, recorded in a private
state/<id>.pr-poll-green-notified marker after the durable wake row, so
a newly recorded head wakes again and an already-woken head is not read
again. The wake never merges, retires, or re-arms the poll: firstmate
lands through bin/fm-pr-merge.sh, whose live verification is unchanged.

bin/fm-pr-poll.sh stays byte-identical, so merge polls armed before an
update keep authenticating and MERGED detection is untouched. GitLab and
Gerrit polls record no pr_head= and are unchanged.
… entirely passing required-check list, falling back to entirely passing reported checks when requirements cannot be listed. Notifications are keyed by PR identity, head SHA, and normalized passing-check set, allowing later required successes on the same head to wake again. Updated documentation and behavioral regressions. Reproduced premature green before the fix; the full PR-check security suite, bash syntax checks, shellcheck -x, and git diff --check pass
Comment thread bin/fm-watch.sh
Comment on lines +2765 to +2769
if [ -z "$out" ] && green_head=$(pr_poll_green_head "$id" "$provider"); then
run_check_capture "$SCRIPT_DIR/fm-pr-green-poll.sh" "$url" "$green_head" || exit 1
if [[ "$FM_CHECK_RESULT" =~ ^checks-green\ ([0-9a-f]{64})$ ]]; then
green_checks=${BASH_REMATCH[1]}
if ! fm_pr_poll_green_already_notified "$STATE" "$id" "$provider" "$host" "$path" "$number" "$green_head" "$green_checks"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Repeated reads delay other checks

Already-notified green PRs are queried again on every check sweep. Each task makes two GitHub head reads and at least one checks read before its marker can suppress the wake. The watcher processes tasks one at a time, and each probe can take up to 30 seconds. With several open PRs or slow GitHub responses, this can delay checks for unrelated tasks. Consider bounding or sharing these repeated reads.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@PawanAIT
PawanAIT force-pushed the pawan/direct-pr-green-wake branch from de4b5af to c83e642 Compare September 28, 2026 22:49
@PawanAIT PawanAIT changed the title feat: wake firstmate when yolo direct-PR checks turn green feat: wake yolo direct-PR tasks when GitHub checks turn green Sep 28, 2026
Azd325 added a commit to Azd325/firstmate that referenced this pull request Nov 9, 2026
The early-readiness fixture must treat an absent queue as zero events.
The executable regression then passes for the changed scan and fails for the original scan.

The readiness delay is a missing prompt handoff rather than slow CI execution.
The generated contract already emits the ready line at the CI-ready return in bin/fm-dod-lib.sh:596-600.
Merge polling starts after PR registration through bin/fm-pr-check.sh.
The independent outcome scan previously waited for a 900-second inactivity interval.
Audit E3 records checks green at 16:20:20 UTC and merge at 16:40:10 UTC on October 19.
The CI log already reported checks passed and continued monitoring until merge or close.
The evidence does not isolate the exact division between reporting and observation delay.
Required owner approval remains unchanged.

The change complements kunchenguid#6052.
That change observes already registered direct-PR checks.
This change delivers an unregistered green PR through the existing outcome receipt and wake route.
It adds no competing forge probe and leaves merge authority and merge-time guards unchanged.

Validation: current-state and reconciliation suites passed; the original scan fails the new regression; lint and documentation checks passed.
Azd325 added a commit to Azd325/firstmate that referenced this pull request Nov 18, 2026
The early-readiness fixture must treat an absent queue as zero events.
The executable regression then passes for the changed scan and fails for the original scan.

The readiness delay is a missing prompt handoff rather than slow CI execution.
The generated contract already emits the ready line at the CI-ready return in bin/fm-dod-lib.sh:596-600.
Merge polling starts after PR registration through bin/fm-pr-check.sh.
The independent outcome scan previously waited for a 900-second inactivity interval.
Audit E3 records checks green at 16:20:20 UTC and merge at 16:40:10 UTC on October 19.
The CI log already reported checks passed and continued monitoring until merge or close.
The evidence does not isolate the exact division between reporting and observation delay.
Required owner approval remains unchanged.

The change complements kunchenguid#6052.
That change observes already registered direct-PR checks.
This change delivers an unregistered green PR through the existing outcome receipt and wake route.
It adds no competing forge probe and leaves merge authority and merge-time guards unchanged.

Validation: current-state and reconciliation suites passed; the original scan fails the new regression; lint and documentation checks passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant