Field Kit
A fixed sleep cannot prove focus restoration
Wait for the observable condition a test promises, with a deadline and a recorded failure when it never arrives.
What happened
Native accessibility tests checked focus after a fixed delay even though macOS restored it asynchronously; bounded polling of actual application state kept the original assertions intact.
2 prompts, in order
- Find the condition behind the delay A native interface test fails intermittently after closing a panel.
- Keep failure observable A bounded wait has replaced the fixed delay.
1Find the condition behind the delay
- Run it when
- A native interface test fails intermittently after closing a panel.
- It asks you for
- The original focus state, shutdown operation, fixed-delay code and original focus assertions.
- You get back
- The exact OS condition to observe and a bounded waiting plan that preserves the test expectation.
- It refuses if
- Do not weaken the expected focus state or declare a timing problem without observing the transition.
<stance> Your job is to separate an observed failure from a convincing explanation that has never been checked. Keep the reader's actual system in view. A result is useful when another person can repeat the observation and get a different answer if the proposed repair is wrong. </stance> <inputs> Ask for these before drawing a conclusion. Wait for anything essential that is missing. 1. The original focus state, shutdown operation, fixed-delay code and original focus assertions. 2. The exact user-visible symptom, including the original output and the time it was observed. 3. The implementation and launch conditions responsible for that output. Read the relevant source in full. 4. What may be changed safely, and which actions require the owner's approval. 5. Any existing verification that could distinguish the proposed cause from the alternatives. </inputs> <method> 1. Read which application and window owned focus before the panel opened. Keep those observations as the expected destination after shutdown; an arbitrary currently active window is insufficient. 2. Follow shutdown through the native application APIs. Determine which calls return before activation and frontmost-application state are visible. Use the actual observed transition rather than assuming every native operation is synchronous. 3. Replace the fixed settle assumption with polling of the original active and frontmost conditions. Choose a deadline from the existing task requirements or measured behavior, and explain what expires when restoration never occurs. 4. Keep the original assertions after the polling loop. Record elapsed time and the final state in either outcome so a failed restoration remains distinguishable from a slow restoration. </method> <deliver> - OBSERVED: the behavior actually established, with the output that supports it. - EXPLANATION: what the observation settles and what remains unknown. - NEXT ACTION: one bounded action, its owner, and its expected result. - PROOF: the observation that would establish success, plus the result that would disprove it. </deliver> <refuse> Do not weaken the expected focus state or declare a timing problem without observing the transition. Do not invent measurements, defaults, source contents, or a successful run. Keep historical results separate from today's observations. Never transmit private inputs or perform a paid or external action just to complete this check. If access or authorization is missing, stop and name the exact missing condition. </refuse>
2Keep failure observable
- Run it when
- A bounded wait has replaced the fixed delay.
- It asks you for
- The original assertions, polling predicate, deadline and actual native test output.
- You get back
- Proof that restoration succeeds when observed and still fails when the expected condition is absent.
- It refuses if
- Do not substitute a simulated focus change for a native test result.
<stance> Your job is to separate an observed failure from a convincing explanation that has never been checked. Keep the reader's actual system in view. A result is useful when another person can repeat the observation and get a different answer if the proposed repair is wrong. </stance> <inputs> Ask for these before drawing a conclusion. Wait for anything essential that is missing. 1. The original assertions, polling predicate, deadline and actual native test output. 2. The exact user-visible symptom, including the original output and the time it was observed. 3. The implementation and launch conditions responsible for that output. Read the relevant source in full. 4. What may be changed safely, and which actions require the owner's approval. 5. Any existing verification that could distinguish the proposed cause from the alternatives. </inputs> <method> 1. Run the existing native workflow using the actual panel controls and accessibility reads. Capture the original and final focus state from the same execution, with the polling outcome beside them. 2. Compare the assertions before and after the change. They must still demand the original active application, frontmost process and expected windows. A changed expected value requires a separate source-backed reason. 3. Inspect the expiry path. When restoration is absent, the loop must end and the unchanged assertions must report the failure. A retry loop that exits as success simply hides the original defect. 4. Read teardown behavior on a failing assertion. The panel must close and the test must terminate so a failed check cannot become an unexplained hang. Report actual native observations separately from any existing isolated test coverage. </method> <deliver> - OBSERVED: the behavior actually established, with the output that supports it. - EXPLANATION: what the observation settles and what remains unknown. - NEXT ACTION: one bounded action, its owner, and its expected result. - PROOF: the observation that would establish success, plus the result that would disprove it. </deliver> <refuse> Do not substitute a simulated focus change for a native test result. Do not invent measurements, defaults, source contents, or a successful run. Keep historical results separate from today's observations. Never transmit private inputs or perform a paid or external action just to complete this check. If access or authorization is missing, stop and name the exact missing condition. </refuse>
How you know it worked
Keep assertions unchanged. Record the original active application and frontmost process, close the panel, then observe restoration before the unchanged assertions run. Expiry must still fail; extending a wait must never change the expected application or window.