feat(directives): harvest 10 process/workflow directives from AGENTS.md + workflow.md

This commit is contained in:
ed
2026-07-02 22:07:08 -04:00
parent 02320a13ea
commit 412494d205
10 changed files with 203 additions and 0 deletions
@@ -0,0 +1,23 @@
# live_gui_poll_not_sleep — v1
**Why this iteration:** Lifted verbatim from `conductor/workflow.md` §"Live_gui Test Fragility (Authoring-Side)" — Anti-Pattern: push_event + time.sleep(N) + assert (lines 464-475). This is the baseline encoding — the rationale-then-before/after-example style currently in production.
Future variants will test alternative encodings (rule-only, tabular) against this baseline.
**Source:** `conductor/workflow.md:464-475`
---
#### Anti-Pattern: `push_event` + `time.sleep(N)` + `assert` is a guaranteed race (Added 2026-06-10)
The pattern `push_event(...)``time.sleep(N)``assert` is a guaranteed race condition in batched runs. The first time you write this, the test passes in isolation because the sleep happens to be long enough. Then it lands in the batched run, the subprocess is busier, the sleep is no longer long enough, and the assert fires before the GUI render loop has processed the event.
**Fix:** Replace `time.sleep(N)` with a poll loop on `get_value` or `wait_for_event`. The poll doubles as a wait-for-ready AND a correctness assertion.
```python
# WRONG: race condition
def test_open_modal(live_gui):
client.push_event("custom_callback", {"callback": "_toggle_settings", "args": []})
time.sleep(1) # hope the modal opened
assert some_cached_value["settings_open"] is True # may be stale
# RIGHT: poll-until-state-visible