Skip to content

fleet: wake and hold the macos display for display-backed runs - #5160

Open
jakildev wants to merge 2 commits into
masterfrom
claude/5144-macos-display-wake
Open

jakildev wants to merge 2 commits into
masterfrom
claude/5144-macos-display-wake

Conversation

@jakildev

@jakildev jakildev commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

On macOS, a display that has idled to sleep reads awake=0, and the engine then finds 0 monitors. Every display-backed fleet run started while nobody was at the Mac failed with RESULT=NO-DISPLAY or the awake=0 preflight, and enough of those declines parked the task. This PR makes each entry point that owns a display-backed run wake the display, wait until the engine can use it, and keep it from idling back to sleep until the run is over.

  • New shared helper, scripts/fleet/fleet_display_session.py. hold_display(owner_pid) starts /usr/bin/caffeinate -d -u -w <owner-pid>. That declares user activity, which wakes the display, and holds PreventUserIdleDisplaySleep until the owner exits, even when the owner is SIGKILLed. The helper then polls the CoreGraphics/AppKit probe for up to 15 s. If the display never becomes ready, it reports exactly one unmet condition with the final counts: no online CoreGraphics display, the online display stayed asleep, or an awake display with no Aqua NSScreen. A probe that cannot run is reported, and the launch goes ahead. FLEET_DISPLAY_HOLDER passes an outer owner's hold to the runs it starts.
  • ir-run, capture verbs on macOS only. Before the launch it calls the helper with --owner-pid $$. A display that never becomes ready gives RESULT=NO-DISPLAY, exit 69, and the exe never runs. The EXIT trap kills a holder that this run started. A hold inherited from an outer run is reused and left alone. The runtime zero-monitor backstop is unchanged.
  • verify_common.display_preflight (render-, light- and gui-verify). It now wakes and holds the display instead of rejecting a sleeping one, and exports the holder to its fleet-run children.
  • fleet-jobs supervisor, display profiles. It takes the hold after anchor_tree and before launching the verifier, and holds it until the job's whole tree has drained (ExitStack around the drain). The holder pid is kept out of job_members, so the drain never counts it as part of the job. A display that never becomes ready fails the job with exit 69 before the verifier starts. fleet-jobs start also exits 69 in that case, with the condition on stderr.
  • Docs. docs/AGENT_FLEET_SETUP.md § "Display-backed runs on an unattended Mac" covers the host settings a display-backed run needs, what the tools do, and the three failure conditions. docs/agents/FLEET-RUNTIME.md points to it.
  • CI. render-harness-tests.yml now also triggers on the helper, the fake and ir-run, which test_no_display_env_fail.py exercises.

Closes #5144

Plan departures

  • Probe failure goes ahead with the launch rather than stopping it. The plan lists "probe failure" among the diagnostic categories but does not say whether it blocks the run. Before this PR, display_preflight also let a failed probe through. A probe can fail where the engine still works, and the engine's own zero-monitor check still catches a real no-display run, so the helper reports the failure and the launch proceeds. Waiting cannot fix a probe that cannot run, so the helper stops waiting at once.
  • Only the asleep-display case is covered, per the plan corrections. A run that reads online=1 awake=1 NSScreen=1 and still logs 0 monitors is now tracked in fleet: macOS engine launches find 0 display monitors while the display is awake #5159. That issue is unlabeled and waits for triage.
  • The criterion-3 run set IR_QUEUE_TIMEOUT=2400 in its environment. The command is otherwise exactly the planned one. The variable only raises ir-run's gpu-lock queue bound from 600 s to 2400 s. It does not touch the display path or the 60 s run clock. While the run was going, other panes were holding the host's gpu lock for up to about 550 s at a time. In an earlier attempt with the display awake and the default bound (job 20261126T041146Z-render-verify-068824), 2 of 58 capture passes got RESULT=LOCK-FAILED and never ran. The other 165 rows passed, and the job ended failed exit=1.
  • No lock or lid configuration was tested. The host's screen does not lock on display sleep (CGSSessionScreenIsLocked unset), and an agent cannot close the lid. The helper's diagnostics report those states, but no transcript of an unwakeable configuration exists.

Acceptance evidence

All live runs are on the macOS host (26.5.2), using this worktree's scripts/fleet/fleet-run / scripts/fleet/fleet-jobs. The fleet-* commands on PATH resolve to the main clone.

Criterion Evidence
1. Hermetic wake and lifecycle tests python3 scripts/tests/test_no_display_env_fail.py: 18 tests OK. IrRunDisplayWakeTest covers wake then held run on both launch paths (no-timeout and --timeout); a holder bound to the ir-run pid and gone after SIGKILL; CRASH (both paths), ALIVE-TIMEOUT and runtime NO-DISPLAY each end the hold; each of the three conditions stops the launch with exit 69 and the exe never runs; probe failure launches without waiting; an inherited hold is reused and not killed; no caffeinate off macOS or without a capture verb. DisplaySessionTest covers the condition table and the injected-clock deadline, and requires the holder started under the injected env to log its invocation and stay alive until release. That assertion fails against the pre-fix helper, which started the holder under the ambient env, in 2 of 2 runs; with the fix, 3 of 3 runs pass. python3 scripts/fleet/tests/test_fleet_jobs.py: 36 tests OK (2 skipped, Windows-only). DisplayHold covers wake then verifier under the hold, -w = supervisor pid, for exit 0 and exit 3; fleet-jobs kill ends the hold; the hold outlives the child until the tree drains; an unready display fails the start and the job with 69 before the verifier runs; no caffeinate for a build or off macOS. Every display test in the suite runs against tests/fake_display.py, so none touches the host's real display. Mutation controls (each run, then reverted): supervisor never holds → 5/5 DisplayHold red; holder counted as a job member → drain test red ('dead' != 'alive'); hold released before the drain → drain test red; ir-run display block disabled → 11 IrRunDisplayWakeTest failures/errors. Removing only ir-run's EXIT-trap kill stays green, because caffeinate -w still ends the holder, which is the design.
2. Live direct positive fire pmset displaysleepnow → online=1 awake=0 NSScreen=1; scripts/fleet/fleet-run IRShapeDebug --auto-screenshot 10 → ir-run: display before wake: CoreGraphics online=1 awake=0 NSScreen=1 / display wake requested: /usr/bin/caffeinate -d -u -w 22544 (pid 22622) / display ready after 0.1s: CoreGraphics online=1 awake=1 NSScreen=1 / Discovered 1 display monitors / ir-run: RESULT=CLEAN exe=IRShapeDebug exit=0. Control, the origin/master ir-run on the same asleep state: Discovered 0 display monitors → RESULT=NO-DISPLAY exe=IRShapeDebug exit=69. Transcript below.
3. Live detached positive fire pmset displaysleepnow → awake=0; scripts/fleet/fleet-jobs start render-verify -- --target IRMetalClearTest --no-build → log opens [fleet-jobs] display: … awake=0 … MISMATCH, display before wake, display wake requested … -w 40519 (pid 40557), display ready after 0.1s … awake=1 NSScreen=1; the verifier's preflight reads display held by the outer run (caffeinate pid 40557): … awake=1 NSScreen=1 and launches. all 3 checks PASS; fleet-jobs: 20261118T025225Z-render-verify-51bfba succeeded exit=0. The planned IRShapeDebug command, on head 637cb12e4, which is this PR rebased onto origin/master f6d489ad6 after the stale references were refreshed. pmset displaysleepnow → 1 0 1. Then scripts/fleet/fleet-jobs start render-verify -- --target IRShapeDebug --no-build (job 20261126T051501Z-render-verify-8ef7e2). The log opens with awake=0 … MISMATCH, then display wake requested … -w 68913 (pid 68941) and display ready after 0.1s … awake=1 NSScreen=1. The preflight reads display held by the outer run (caffeinate pid 68941). All 58 capture passes ran, and the verifier reported all 187 checks PASS. The terminal record is fleet-jobs: 20261126T051501Z-render-verify-8ef7e2 succeeded exit=0, wait exit=0. Met.
4. Assertion ownership and cleanup Direct mid-run: PreventUserIdleDisplaySleep 1, owned by pid 22622(caffeinate) … asserting on behalf of Process ID 22544 (the ir-run); after exit 0, no caffeinate. Detached mid-job: 1, owned by pid 40557(caffeinate) … on behalf of Process ID 40519 (the supervisor); after the terminal wait, holder 40557 gone. The IRShapeDebug criterion-3 job behaved the same way: PreventUserIdleDisplaySleep 1 with 68941(caffeinate) … on behalf of Process ID 68913 (the supervisor) mid-run; after the terminal wait PreventUserIdleDisplaySleep 0 and no display-wake caffeinate. A different caffeinate -d -i -u python3 scripts/light-verify.py (pid 41959) from another pane was live at that moment; it is unrelated to this run. Live kill: SIGTERM to ir-run → 0, no caffeinate; SIGKILL to ir-run → 0, no caffeinate; fleet-jobs kill …022918Z-render-verify-02d419 → killed exit=143, 1 → 0, no caffeinate. The hermetic timeout and launch-refusal arms are in row 1.
5. Environment-result regression python3 scripts/tests/test_no_display_env_fail.py OK, with the persistent zero-monitor arm still RESULT=NO-DISPLAY/69 with the hold active. python3 scripts/fleet/tests/test_fleet_jobs.py OK. bash scripts/fleet/tests/run_all.sh --only fleet_claim_decline → 1 passed, 0 failed. Every not-ready message carries awake=… counts, and the ENV-FAIL / fleet-jobs start text also carries 0 display monitors, so fleet_decline.DECLINE_HOST_RE classifies it as a host decline. python3 scripts/fleet/tests/test_fleet_task_class.py OK, now with the three new message shapes in test_sleeping_display_declines_read_as_host.
6. Documentation and lint docs/AGENT_FLEET_SETUP.md § "Display-backed runs on an unattended Mac" covers the logged-in Aqua session, the connected and open display, the system kept awake, the automatic wake and hold, and the three-condition table. python3 scripts/lint_instruction_refs.py --against origin/master → none new; ruff check scripts/ → All checks passed!; git diff --check origin/master...HEAD clean; lint_instruction_size.py --against origin/master → no introduced offenders.

Live transcripts

Direct (criterion 2, 4):

== 2026-11-18T02:27:44Z host: 26.5.2,  displaysleep         0
== pre-sleep: online=1 awake=1 NSScreen=1; screen locked: unset(unlocked)
   PreventUserIdleDisplaySleep    0
== pmset displaysleepnow rc=0
== asleep: online=1 awake=0 NSScreen=1; screen locked: unset(unlocked)
   PreventUserIdleDisplaySleep    0
== $ scripts/fleet/fleet-run IRShapeDebug --auto-screenshot 10
== mid-run (02:27:52): online=1 awake=1 NSScreen=1; screen locked: unset(unlocked)
   PreventUserIdleDisplaySleep    1
   pid 22622(caffeinate): [0x0002fb54000594aa] 00:00:00 PreventUserIdleDisplaySleep named: "caffeinate command-line tool"
	Details: caffeinate asserting on behalf of Process ID 22544
   pid 22622(caffeinate): [0x0002fb54000994ab] 00:00:00 UserIsActive named: "caffeinate command-line tool"
== fleet-run exit=0
ir-run: display before wake: CoreGraphics online=1 awake=0 NSScreen=1
ir-run: display wake requested: /usr/bin/caffeinate -d -u -w 22544 (pid 22622) holds PreventUserIdleDisplaySleep for the run
ir-run: display ready after 0.1s: CoreGraphics online=1 awake=1 NSScreen=1
[2026-11-17 18:27:54.727] [EngineLog] [info] Discovered 1 display monitors
ir-run: RESULT=CLEAN exe=IRShapeDebug exit=0
== after exit: online=1 awake=1 NSScreen=1
   PreventUserIdleDisplaySleep    0
no caffeinate process

Control on the origin/master ir-run, then the kill arms:

=== CONTROL: origin/master ir-run (6236f5854 main clone; no wake code) ===
asleep: online=1 awake=0 NSScreen=1
control exit=69
[2026-11-17 18:28:26.249] [EngineLog] [info] Discovered 0 display monitors
ir-run: RESULT=NO-DISPLAY exe=IRShapeDebug exit=69
=== LIVE KILL ARM: SIGTERM to ir-run mid-run ===
asleep: online=1 awake=0 NSScreen=1
held: PreventUserIdleDisplaySleep 1; caffeinate pid(s)=27221; ir-run pid=27173
ir-run exit=143
after SIGTERM: PreventUserIdleDisplaySleep 0; caffeinate: none
=== LIVE KILL ARM: SIGKILL to ir-run mid-run ===
asleep: online=1 awake=0 NSScreen=1
held: PreventUserIdleDisplaySleep 1; caffeinate pid(s)=28364; ir-run pid=28323
ir-run exit=137
after SIGKILL: PreventUserIdleDisplaySleep 0; caffeinate: none

Detached (criterion 3, 4):

== 2026-11-18T02:52:17Z
pmset displaysleepnow rc=0
asleep: online=1 awake=0 NSScreen=1; PreventUserIdleDisplaySleep 0
$ scripts/fleet/fleet-jobs start render-verify -- --target IRMetalClearTest --no-build
started 20261118T025225Z-render-verify-51bfba (running)
mid-job: PreventUserIdleDisplaySleep 1
   pid 40557(caffeinate): [0x000301150005990e] 00:00:00 PreventUserIdleDisplaySleep named: "caffeinate command-line tool"
	Details: caffeinate asserting on behalf of Process ID 40519
$ scripts/fleet/fleet-jobs wait --timeout 540 20261118T025225Z-render-verify-51bfba
wait exit=0
[fleet-jobs] display: 1 online CoreGraphics display(s), awake=0, NSScreen=1; MISMATCH: engine monitor discovery will see 0
[fleet-jobs] display before wake: CoreGraphics online=1 awake=0 NSScreen=1
[fleet-jobs] display wake requested: /usr/bin/caffeinate -d -u -w 40519 (pid 40557) holds PreventUserIdleDisplaySleep for the run
[fleet-jobs] display ready after 0.1s: CoreGraphics online=1 awake=1 NSScreen=1
[render-verify] target=IRMetalClearTest demo=metal_clear_test backend=macos-debug warmup=10
[render-verify] 3 shots: metal_clear_zoom1, metal_clear_zoom2, metal_clear_zoom4_offset
[render-verify] display held by the outer run (caffeinate pid 40557): CoreGraphics online=1 awake=1 NSScreen=1
+ fleet-run --timeout 60 IRMetalClearTest --auto-screenshot 10
...
metal_clear_zoom1                        PASS        100.0      0      inf
metal_clear_zoom2                        PASS        100.0      0      inf
metal_clear_zoom4_offset                 PASS        100.0      0      inf
[render-verify] all 3 checks PASS
fleet-jobs: 20261118T025225Z-render-verify-51bfba succeeded exit=0

Detached, the planned IRShapeDebug command (criterion 3, 4), on head 637cb12e4 (base = origin/master f6d489ad6). It was run by a driver script that keeps retrying pmset displaysleepnow until the probe reads awake=0, and only then starts the job. Before that, ten attempts at 04:10Z never got the display to awake=0, because someone was using the host's keyboard at the time. No job was started then.

== 2026-11-26T05:14:59Z head 637cb12e4 base origin/master f6d489ad6
== pre-sleep: online awake NSScreen = 1 1 1
   PreventUserIdleDisplaySleep    0
== 2026-11-26T05:15:01Z attempt 1: pmset displaysleepnow rc=0; asleep: online awake NSScreen = 1 0 1
$ scripts/fleet/fleet-jobs start render-verify -- --target IRShapeDebug --no-build
started 20261126T051501Z-render-verify-8ef7e2 (running)
== mid-job 2026-11-26T05:15:05Z:
   PreventUserIdleDisplaySleep    1
   pid 68941(caffeinate): [0x0001082000058064] 00:00:03 PreventUserIdleDisplaySleep named: "caffeinate command-line tool"
	Details: caffeinate asserting on behalf of Process ID 68913
$ scripts/fleet/fleet-jobs wait --timeout 7000 20261126T051501Z-render-verify-8ef7e2
[fleet-jobs] display: 1 online CoreGraphics display(s), awake=0, NSScreen=1; MISMATCH: engine monitor discovery will see 0
[fleet-jobs] display before wake: CoreGraphics online=1 awake=0 NSScreen=1
[fleet-jobs] display wake requested: /usr/bin/caffeinate -d -u -w 68913 (pid 68941) holds PreventUserIdleDisplaySleep for the run
[fleet-jobs] display ready after 0.1s: CoreGraphics online=1 awake=1 NSScreen=1
[render-verify] target=IRShapeDebug demo=shape_debug backend=macos-debug warmup=10
[render-verify] 21 shots: …
[render-verify] 57 extra run(s): …
[render-verify] display held by the outer run (caffeinate pid 68941): CoreGraphics online=1 awake=1 NSScreen=1
+ fleet-run --timeout 60 IRShapeDebug --auto-screenshot 10
…  (58 capture passes, 0 LOCK-FAILED / CRASH / NO-DISPLAY / TIMEOUT; 187 PASS rows, 0 FAIL)
[render-verify] all 187 checks PASS
fleet-jobs: 20261126T051501Z-render-verify-8ef7e2 succeeded exit=0
wait exit=0
== after 2026-11-26T06:08:51Z:
   PreventUserIdleDisplaySleep    0
no display-wake caffeinate
JOB=20261126T051501Z-render-verify-8ef7e2

Detached kill (criterion 4):

before kill: PreventUserIdleDisplaySleep 1; caffeinate: 29728 caffeinate
$ scripts/fleet/fleet-jobs kill 20261118T022918Z-render-verify-02d419
20261118T022918Z-render-verify-02d419  killed  exit=143  profile=render-verify  ...  reason='cancelled by fleet-jobs kill'
after kill: PreventUserIdleDisplaySleep 0; caffeinate: none

Phase 0 (the wake premise, run before any dependent code): asleep 1 0 1 → caffeinate -d -u -t 120 → 1 1 1 within 0.5 s; PreventUserIdleDisplaySleep 1 while held, 0 after kill. caffeinate -d -u -w <pid> keeps the display assertion past -u's 5 s default and exits when the -w pid does.

Notes

  • Head ae0bcee7c starts the display holder under the env passed to hold_display() instead of the ambient one. That fixes the red injected-clock test in render-harness-tests. In production the passed env is os.environ, so the live evidence in row 3, taken on 637cb12e4, still describes this head.

  • fleet-pr-overlap --base master on the rebased head returns VERDICT: block. The only competitor is fleet: stop sandboxed macos display launches before the wake (#5159) #5173, which is stacked on this branch (base claude/5144-macos-display-wake). Its rows conflict because this pass rebased the parent onto f6d489ad6 and moved it out from under the child. They are not a competing change. fleet: stop sandboxed macos display launches before the wake (#5159) #5173 needs its own rebase onto the new parent head 637cb12e4. fleet: let a macos pin outrank a cited opengl path #5156, the earlier overlap row, is no longer an open competitor.

  • Killing ir-run from outside (SIGTERM/SIGKILL) still orphans the engine child. That was true before this PR, and the hold is released either way.

  • fleet-jobs start waits up to 30 s for the supervisor to report. The wake adds about 0.1 s on this host, and at most 15 s plus probe timeouts if the display never becomes ready.

🤖 Generated with Claude Code

@jakildev jakildev added fleet:wip Work in progress — not ready for review fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend and removed fleet:wip Work in progress — not ready for review labels Nov 18, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — fleet: wake and hold the macos display for display-backed runs

Verdict: needs-fix

The implementation and hermetic coverage are well-scoped, but the PR does not supply the required terminal detached IRShapeDebug verification.

Needs-fix

  • Issue #5144 acceptance criterion 3 — the required asleep-display fleet-jobs start render-verify -- --target IRShapeDebug --no-build terminal run is not evidenced. The PR explicitly substitutes a terminal IRMetalClearTest run and reports only IRShapeDebug preflight plus its first ten extra runs. Run the specified IRShapeDebug verifier to a terminal fleet-jobs wait exit 0 with its wake/preflight log, or obtain an explicit plan change before merge.

Praise

  • fleet_display_session.hold_display centralizes the readiness condition and keeps the supervisor-owned hold outside job_members, which preserves the existing descendant-draining lifetime boundary.

Acceptance (issue #5144)

5 of 6 met. Criterion 3 is unmet: the terminal detached positive-fire evidence uses IRMetalClearTest rather than the planned IRShapeDebug command.

Checked

  • Read the complete PR and issue #5144 threads, metadata, inline comments, and the full changed-file context.
  • Reviewed display-session ownership, inherited-hold propagation, verifier preflight, and supervisor drain integration.
  • CI remains unread: linux-build, render-harness-tests, fleet-tests, and all-checks were in progress on the reviewed head.
  • Local python3 scripts/tests/test_no_display_env_fail.py could not complete because this Codex sandbox denies the test's ps -o stat= -p <pid> subprocess calls (PermissionError: [Errno 1] Operation not permitted: 'ps'); this is a host permission limitation, not a PR failure finding.

🤖 Reviewed by Codex (GPT-5; sonnet review class)
Opus recheck not required.

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:reviewing-mac-pool-2 labels Nov 18, 2026
@jakildev jakildev added fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:needs-fix Fleet reviewer found issues — author must address labels Nov 18, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (worker, feedback dispatch on the 03:03Z review):

  • Criterion 3: IRShapeDebug terminal detached run. Ran the planned command, scripts/fleet/fleet-jobs start render-verify -- --target IRShapeDebug --no-build (job 20261118T030737Z-render-verify-dce90e), from a display read as awake=0 after pmset displaysleepnow, through to a terminal fleet-jobs wait. The wake and hold worked as the criterion asks. The log opens awake=0 … MISMATCH, then display wake requested … -w 52616 (pid 52627) and display ready after 0.1s … awake=1 NSScreen=1. The verifier preflight passed under the outer hold, and all 47 launched runs captured. The holder was gone after the wait. The terminal record is failed exit=1, not 0. render-verify graded 37 of 176 checks FAIL (10 skipped — references pending).
  • Why exit 0 isn't reachable on this tree. The PR changes no engine, shader or demo source, so the captures are master's renders. Thirty-six of the 37 failing rows are the stale macOS ShapeDebug references tracked in render: refresh stale macos-debug ShapeDebug and CanvasStress references #4904: the 180°/270° rows at max delta 109–120, and the yaw-45 rows. They include lod_scene_fine_yaw90 at exactly the 96.150% / 32 / 32.63 dB recorded there, which render: make lod_scene_fine_yaw90 deterministic across macOS build trees #5106 owns. The 37th, text_size_sample (99.625% / max delta 108), has no open issue. The PR body's Plan departures and transcript have the row list.
  • Disposition: parked, no code change. Added Parked-until: #4904, #5106 to the body and fleet:awaiting-infra, and left fleet:needs-fix on so the tier re-arms when reconcile un-parks. Once both issues close, re-run the same command (the transcript's sleep-until-awake=0 loop avoids another pane's caffeinate -u waking the display first) and paste the exit-0 record into row 3. If text_size_sample is still red then, it needs its own issue.
  • Faster route, for a human or the architect. Add a ## Plan corrections comment on fleet: display-backed runs fail whenever the macOS display has idled to sleep #5144 that accepts this record for criterion 3: an asleep start, the preflight passing under the hold, every run captured, and a failing set that matches master's tracked reference staleness. Then remove fleet:awaiting-infra and the Parked-until line.

— worker (pool-2)

@evin-mac-claude-app

Copy link
Copy Markdown
Contributor

Every failed workflow on this head is also red on master:

These failures are inherited and are not this pull request's to fix.

@evin-mac-claude-app

Copy link
Copy Markdown
Contributor

Every failed workflow on this head is also red on master:

These failures are inherited and are not this pull request's to fix.

@evin-mac-claude-app evin-mac-claude-app Bot added fleet:amending-mac-pool-4 and removed fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N labels Nov 26, 2026
A display that idled to sleep reads awake=0 and the engine discovers 0
monitors, so every unattended capture or verifier run on the macOS host
failed NO-DISPLAY until a human touched the machine.

fleet_display_session.hold_display starts caffeinate -d -u -w <owner>,
which wakes the display and holds PreventUserIdleDisplaySleep for the
owner's lifetime, then waits for CoreGraphics + AppKit readiness and
names the one unmet condition when it never comes. ir-run (capture
verbs), the verifiers' preflight and the fleet-jobs supervisor (until
the job drains) each own a hold; FLEET_DISPLAY_HOLDER hands it to nested
runs. An unready display stops the run with exit 69 before launch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev removed the fleet:needs-fix Fleet reviewer found issues — author must address label Nov 26, 2026
@jakildev
jakildev force-pushed the claude/5144-macos-display-wake branch from 2eeca21 to 637cb12 Compare November 26, 2026 06:10
@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:amending-mac-pool-4 labels Nov 26, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (worker pool-4, feedback dispatch after reconcile un-parked the PR; #4904 and #5106 are both closed):

  • Needs-fix: criterion 3, the IRShapeDebug terminal detached run. Now met. I rebased the PR onto origin/master f6d489ad6, which contains the macOS reference refresh. The rebase was clean and the new head is 637cb12e4. I rebuilt IRShapeDebug and ran pmset displaysleepnow, which read 1 0 1. Then I ran the planned command, scripts/fleet/fleet-jobs start render-verify -- --target IRShapeDebug --no-build (job 20261126T051501Z-render-verify-8ef7e2). Its log opens with awake=0 … MISMATCH, then the wake, display ready after 0.1s … awake=1 NSScreen=1, and the verifier preflight passing under the outer hold. It finishes with all 187 checks PASS and succeeded exit=0. The holder was gone after the wait. Row 3, row 4 and the transcript in the body now show this run.
  • Plan departure recorded: the run set IR_QUEUE_TIMEOUT=2400, which only raises the gpu-lock queue bound. An earlier attempt with the default 600 s bound lost 2 of 58 capture passes to LOCK-FAILED while other panes held the lock. The other 165 rows passed.
  • Park removed: I took out the Parked-until: #4904, #5106 line. Reconcile had already cleared fleet:awaiting-infra.
  • Re-ran on the rebased head: test_no_display_env_fail.py (18 OK), test_fleet_jobs.py (36 OK, 2 skipped), test_fleet_task_class.py OK, run_all.sh --only fleet_claim_decline (1 passed), ruff, lint_instruction_refs --against origin/master (none new), and git diff --check, all clean.
  • Stacked child fleet: stop sandboxed macos display launches before the wake (#5159) #5173: it now needs a rebase onto 637cb12e4. fleet-pr-overlap reports block only for that child (see Notes).

— worker (pool-4)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — fleet: wake and hold the macos display for display-backed runs

Verdict: needs-fix

The revised detached IRShapeDebug evidence satisfies the prior acceptance finding, but this head turns a PR-owned CI validator red.

Needs-fix

  • scripts/tests/test_no_display_env_fail.py:255 — DisplaySessionTest.test_hold_waits_on_an_injected_clock fails in the PR's render-harness-tests workflow: the helper reports waiting 3.0s, while the test requires waiting 5.0s. The helper starts its fake caffeinate with the ambient process environment rather than the injected env, so the test seam is not carried into that subprocess and the holder exits unpredictably. Pass the injected environment to the holder process (or otherwise make the seam deterministic), then rerun the affected suite.

Acceptance (issue #5144)

5 of 6 met. Criterion 1 remains unmet because its hermetic suite is red on this head.

Checked

  • Read the complete PR and issue #5144 threads, PR metadata, inline-comment feed, full changed-file context, and the prior review.
  • Verified the prior criterion-3 finding against the new terminal IRShapeDebug evidence on head 637cb12e4.
  • render-harness-tests failed on this head; the workflow reports the injected-clock failure above. Other failures shown in that job concern unchanged harness surfaces, while this failure is in the added test.
  • linux-build remained in progress at review time.
  • Local python3 scripts/tests/test_no_display_env_fail.py could not complete: the test invokes ps -o stat= -p <pid>, and this Codex sandbox returned PermissionError: [Errno 1] Operation not permitted: 'ps'.

🤖 Reviewed by Codex (GPT-5; sonnet review class)
Opus recheck not required.

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-6 labels Nov 26, 2026
@jakildev jakildev removed the fleet:needs-fix Fleet reviewer found issues — author must address label Nov 26, 2026
hold_display() launched caffeinate with the ambient process environment,
so a caller-supplied env never reached the holder. The fake caffeinate in
the hermetic suite reads its log and state paths from that env, crashed
on startup, and the injected-clock test raced the early exit (red in
render-harness-tests with "waiting 3.0s"). The test now also requires the
holder to have logged its invocation and still be alive at release, which
fails deterministically without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:amending-mac-pool-4 labels Nov 26, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (worker pool-4, feedback dispatch on the 06:45Z review):

  • Needs-fix: DisplaySessionTest.test_hold_waits_on_an_injected_clock red in render-harness-tests ("waiting 3.0s"). The reviewer's diagnosis holds. hold_display() started the holder with subprocess.Popen and no env=, so the fake caffeinate never got FAKE_CAFFEINATE_LOG. It crashed on startup, and the wait loop broke early on "holder exited early" whenever the crash beat five probe polls. The fix passes env=dict(env) to the holder (scripts/fleet/fleet_display_session.py). Production passes os.environ, so live behaviour is unchanged. The test now also requires the holder to log its invocation and still be alive at release. On this Mac the race goes the other way, so the old test passed even before the fix. The new assertion fails against the pre-fix helper in 2 of 2 runs and passes with the fix in 3 of 3.
  • Re-ran on ae0bcee7c: test_no_display_env_fail.py 18 OK, test_fleet_jobs.py 36 OK (2 skipped), test_fleet_task_class.py 154 OK, ruff, lint_comment_refs.py, git diff --check, all clean. The body's row 1 and Notes are updated. The row 3 live run on 637cb12e4 still stands, since production behaviour is unchanged.
  • Stacked child fleet: stop sandboxed macos display launches before the wake (#5159) #5173 needs a rebase onto ae0bcee7c.

— worker (pool-4)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — fleet: wake and hold the macos display for display-backed runs

Verdict: approve

The targeted environment propagation fix makes the injected-clock lifecycle test deterministic, and the reviewed wake/hold ownership still satisfies the issue's acceptance criteria.

Praise

  • scripts/fleet/fleet_display_session.py::hold_display now starts the holder under the same injected environment used by its probe, so the fake process follows the test seam rather than ambient state.
  • scripts/fleet/fleet-jobs::supervise keeps the supervisor-owned holder outside job_members while the ExitStack extends its lifetime through descendant drain.

Acceptance (issue #5144)

6 of 6 met.

Checked

  • Read the complete PR and issue #5144 threads, current metadata, inline-comment feed, prior reviews, and all changed-file context.
  • Delta-reviewed ae0bcee7c, including its new holder invocation/liveness assertions; confirmed the current head matches the checked-out commit.
  • CI: test_no_display_env_fail.py passes in the PR's render-harness-tests job. That workflow's nine remaining failures exactly match the base branch's failing suites, so the red aggregate is inherited. linux-build remains in progress.
  • Local python3 scripts/tests/test_no_display_env_fail.py is blocked by this Codex sandbox denying its ps -o stat= -p <pid> subprocess (PermissionError: [Errno 1] Operation not permitted); three process-lifecycle assertions therefore cannot run locally.
  • git diff --check origin/master...HEAD completed cleanly.

🤖 Reviewed by Codex (GPT-5; sonnet review class)
Opus recheck not required.

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-4 labels Nov 26, 2026
@evin-mac-claude-app

Copy link
Copy Markdown
Contributor

Every failed workflow on this head is also red on master:

These failures are inherited and are not this pull request's to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fleet: display-backed runs fail whenever the macOS display has idled to sleep

1 participant