oh-my-opencode 4.5.12 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.agents/skills/opencode-qa/SKILL.md +194 -0
  2. package/.agents/skills/opencode-qa/references/cli-commands.md +188 -0
  3. package/.agents/skills/opencode-qa/references/db-investigation.md +197 -0
  4. package/.agents/skills/opencode-qa/references/events-hooks.md +110 -0
  5. package/.agents/skills/opencode-qa/references/sdk.md +96 -0
  6. package/.agents/skills/opencode-qa/references/server-api.md +200 -0
  7. package/.agents/skills/opencode-qa/references/testing-harness.md +218 -0
  8. package/.agents/skills/opencode-qa/references/tui-tmux.md +52 -0
  9. package/.agents/skills/opencode-qa/scripts/db-session-by-id.sh +53 -0
  10. package/.agents/skills/opencode-qa/scripts/db-session-by-name.sh +57 -0
  11. package/.agents/skills/opencode-qa/scripts/db-session-by-text.sh +158 -0
  12. package/.agents/skills/opencode-qa/scripts/export-roundtrip.sh +57 -0
  13. package/.agents/skills/opencode-qa/scripts/lib/common.sh +216 -0
  14. package/.agents/skills/opencode-qa/scripts/server-smoke.sh +64 -0
  15. package/.agents/skills/opencode-qa/scripts/sse-hook-probe.sh +106 -0
  16. package/.agents/skills/opencode-qa/scripts/tui-smoke.sh +89 -0
  17. package/README.ja.md +13 -3
  18. package/README.ko.md +13 -3
  19. package/README.md +24 -14
  20. package/README.ru.md +13 -3
  21. package/README.zh-cn.md +13 -3
  22. package/bin/oh-my-opencode.js +4 -3
  23. package/bin/oh-my-opencode.test.ts +35 -7
  24. package/bin/platform.d.ts +1 -1
  25. package/bin/platform.js +4 -4
  26. package/bin/platform.test.ts +31 -9
  27. package/dist/cli/cleanup-command.d.ts +4 -0
  28. package/dist/cli/cleanup.d.ts +11 -0
  29. package/dist/cli/cli-program.d.ts +2 -1
  30. package/dist/cli/index.js +1837 -450
  31. package/dist/cli/install-codex/codex-cache.d.ts +1 -0
  32. package/dist/cli/install-codex/codex-cleanup-config.d.ts +6 -0
  33. package/dist/cli/install-codex/codex-cleanup.d.ts +21 -0
  34. package/dist/cli/install-codex/codex-config-mcp.d.ts +1 -0
  35. package/dist/cli/install-codex/codex-config-permissions.d.ts +1 -0
  36. package/dist/cli/install-codex/codex-config-reasoning.d.ts +1 -0
  37. package/dist/cli/install-codex/codex-config-toml.d.ts +2 -1
  38. package/dist/cli/install-codex/codex-installation-detection.d.ts +36 -0
  39. package/dist/cli/install-codex/codex-package-layout.d.ts +1 -0
  40. package/dist/cli/install-codex/codex-project-local-cleanup-best-effort.d.ts +7 -0
  41. package/dist/cli/install-codex/codex-project-local-cleanup.d.ts +35 -0
  42. package/dist/cli/install-codex/git-bash.d.ts +35 -0
  43. package/dist/cli/install-codex/index.d.ts +4 -0
  44. package/dist/cli/install-codex/toml-section-editor.d.ts +2 -0
  45. package/dist/cli/install-codex/types.d.ts +20 -0
  46. package/dist/cli/run/event-state.d.ts +1 -0
  47. package/dist/cli/run/poll-for-completion.d.ts +1 -0
  48. package/dist/cli/run/prompt-start.d.ts +7 -0
  49. package/dist/cli/star-request.d.ts +9 -0
  50. package/dist/config/schema/hooks.d.ts +0 -1
  51. package/dist/create-hooks.d.ts +0 -1
  52. package/dist/features/builtin-skills/skills/debugging.d.ts +2 -0
  53. package/dist/features/builtin-skills/skills/index.d.ts +1 -0
  54. package/dist/hooks/index.d.ts +0 -1
  55. package/dist/index.js +267 -114
  56. package/dist/plugin/hooks/create-core-hooks.d.ts +0 -1
  57. package/dist/plugin/hooks/create-session-hooks.d.ts +1 -2
  58. package/dist/plugin/messages-transform.d.ts +8 -1
  59. package/dist/plugin/user-abort-interrupted-recovery-guard.d.ts +6 -0
  60. package/dist/shared/prompt-async-gate/recent-dispatches.d.ts +14 -0
  61. package/dist/shared/prompt-async-gate/semantic-dedupe.d.ts +7 -0
  62. package/dist/shared/prompt-async-gate/session-idle-dispatch.d.ts +1 -0
  63. package/dist/shared/prompt-async-gate/timing.d.ts +1 -0
  64. package/dist/shared/prompt-async-gate/types.d.ts +2 -0
  65. package/dist/shared/prompt-async-gate.d.ts +1 -1
  66. package/package.json +22 -17
  67. package/packages/git-bash-mcp/dist/cli.js +367 -0
  68. package/packages/omo-codex/plugin/.mcp.json +11 -0
  69. package/packages/omo-codex/plugin/components/comment-checker/README.md +1 -1
  70. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +29 -0
  71. package/packages/omo-codex/plugin/components/git-bash/package.json +23 -0
  72. package/packages/omo-codex/plugin/components/git-bash/src/cli.ts +33 -0
  73. package/packages/omo-codex/plugin/components/git-bash/src/codex-hook.ts +180 -0
  74. package/packages/omo-codex/plugin/components/git-bash/src/index.ts +10 -0
  75. package/packages/omo-codex/plugin/components/git-bash/test/codex-hook.test.ts +195 -0
  76. package/packages/omo-codex/plugin/components/git-bash/tsconfig.build.json +13 -0
  77. package/packages/omo-codex/plugin/components/git-bash/tsconfig.json +25 -0
  78. package/packages/omo-codex/plugin/components/lsp/README.md +1 -1
  79. package/packages/omo-codex/plugin/components/lsp/src/cli.ts +5 -5
  80. package/packages/omo-codex/plugin/components/lsp/src/codex-hook-cli.ts +33 -0
  81. package/packages/omo-codex/plugin/components/lsp/src/codex-hook.ts +19 -27
  82. package/packages/omo-codex/plugin/components/lsp/test/codex-hook-cli.test.ts +28 -0
  83. package/packages/omo-codex/plugin/components/lsp/test/codex-hook-errors.test.ts +55 -0
  84. package/packages/omo-codex/plugin/components/lsp/test/package-smoke.test.ts +7 -5
  85. package/packages/omo-codex/plugin/components/rules/README.md +1 -1
  86. package/packages/omo-codex/plugin/components/rules/bundled-rules/windows-git-bash.md +10 -0
  87. package/packages/omo-codex/plugin/components/rules/test/package-smoke.test.ts +3 -1
  88. package/packages/omo-codex/plugin/components/rules/test/windows-git-bash-bundled-rule.test.ts +97 -0
  89. package/packages/omo-codex/plugin/components/start-work-continuation/directive.md +5 -4
  90. package/packages/omo-codex/plugin/components/start-work-continuation/test/codex-hook.test.ts +22 -0
  91. package/packages/omo-codex/plugin/components/ultrawork/README.md +2 -2
  92. package/packages/omo-codex/plugin/components/ultrawork/agents/codex-ultrawork-reviewer.toml +1 -0
  93. package/packages/omo-codex/plugin/components/ultrawork/agents/librarian.toml +8 -7
  94. package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +2 -1
  95. package/packages/omo-codex/plugin/components/ultrawork/directive.md +31 -5
  96. package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +27 -4
  97. package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +25 -0
  98. package/packages/omo-codex/plugin/components/ulw-loop/README.md +1 -1
  99. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +27 -205
  100. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +230 -0
  101. package/packages/omo-codex/plugin/components/ulw-loop/test/package-smoke.test.ts +102 -5
  102. package/packages/omo-codex/plugin/hooks/hooks.json +24 -2
  103. package/packages/omo-codex/plugin/package-lock.json +19 -0
  104. package/packages/omo-codex/plugin/package.json +3 -1
  105. package/packages/omo-codex/plugin/scripts/build-bundled-mcp-runtimes.mjs +16 -1
  106. package/packages/omo-codex/plugin/scripts/build-components.mjs +2 -1
  107. package/packages/omo-codex/plugin/scripts/sync-hook-status-messages.mjs +87 -0
  108. package/packages/omo-codex/plugin/skills/review-work/SKILL.md +27 -2
  109. package/packages/omo-codex/plugin/skills/start-work/SKILL.md +20 -0
  110. package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +27 -205
  111. package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +230 -0
  112. package/packages/omo-codex/plugin/test/aggregate.test.mjs +23 -8
  113. package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +56 -11
  114. package/packages/omo-codex/plugin/test/install-time-build-runtime.test.mjs +34 -0
  115. package/packages/omo-codex/plugin/test/mcp-research-servers.test.mjs +21 -0
  116. package/packages/omo-codex/plugin/test/node-install-surface.test.mjs +48 -0
  117. package/packages/omo-codex/plugin/test/subagent-guidance.test.mjs +76 -0
  118. package/packages/omo-codex/plugin/test/sync-hook-status-messages.test.mjs +66 -0
  119. package/packages/omo-codex/plugin/test/sync-skills.test.mjs +32 -2
  120. package/packages/omo-codex/scripts/install/cache.mjs +5 -3
  121. package/packages/omo-codex/scripts/install/cli-args.mjs +112 -0
  122. package/packages/omo-codex/scripts/install/config.mjs +36 -1
  123. package/packages/omo-codex/scripts/install/delegated-command.mjs +25 -0
  124. package/packages/omo-codex/scripts/install/git-bash.mjs +99 -0
  125. package/packages/omo-codex/scripts/install/git-bash.test.mjs +174 -0
  126. package/packages/omo-codex/scripts/install/mcp-runtime-cache.mjs +5 -1
  127. package/packages/omo-codex/scripts/install/multi-agent-v2-config.mjs +7 -1
  128. package/packages/omo-codex/scripts/install/permissions.d.mts +1 -0
  129. package/packages/omo-codex/scripts/install/permissions.mjs +26 -0
  130. package/packages/omo-codex/scripts/install/project-local-cleanup.mjs +229 -0
  131. package/packages/omo-codex/scripts/install/reasoning-config.mjs +14 -0
  132. package/packages/omo-codex/scripts/install/source-package-build.mjs +20 -0
  133. package/packages/omo-codex/scripts/install/toml-editor.mjs +19 -2
  134. package/packages/omo-codex/scripts/install-cli-args.test.mjs +146 -0
  135. package/packages/omo-codex/scripts/install-config-autonomous.test.mjs +48 -0
  136. package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +62 -0
  137. package/packages/omo-codex/scripts/install-config.test.mjs +206 -0
  138. package/packages/omo-codex/scripts/install-local-entrypoint.test.mjs +129 -0
  139. package/packages/omo-codex/scripts/install-local-git-bash-preflight.test.mjs +145 -0
  140. package/packages/omo-codex/scripts/install-local.mjs +91 -8
  141. package/packages/omo-codex/scripts/install-local.test.mjs +15 -0
  142. package/packages/omo-codex/scripts/install-mcp-runtime.test.mjs +60 -0
  143. package/packages/omo-codex/scripts/install-packaged-local.test.mjs +67 -0
  144. package/packages/omo-codex/scripts/install-project-local-cleanup.test.mjs +277 -0
  145. package/packages/shared-skills/skills/review-work/SKILL.md +27 -2
  146. package/packages/shared-skills/skills/start-work/SKILL.md +20 -0
  147. package/dist/hooks/context-window-monitor.d.ts +0 -19
@@ -5,218 +5,40 @@ metadata:
5
5
  short-description: Goal-like ultrawork loop for systematic decomposition
6
6
  ---
7
7
 
8
- ## Role
9
- Expert goal orchestration agent. You conduct; right-sized parallel subagents play. Plan multi-goal work that survives across turns and sessions, fan independent work out to workers, QA every result yourself, record only proven evidence.
10
- Use GPT-5.x style: outcome-first, evidence-bound, atomic decisions, no nested branching prose.
8
+ # ulw-loop
11
9
 
12
- ## Goal
13
- Deliver every goal in `.omo/ulw-loop/goals.json` end-to-end.
14
- Prove EVERY success criterion with captured observable evidence from a real-usage scenario you actually ran (HTTP call / tmux / browser use / computer use — see the Manual-QA channels below).
15
- TESTS ALONE NEVER PROVE DONE. A green test suite is supporting evidence, not completion proof.
16
- Audit each pass, fail, block, steering change, and checkpoint in `.omo/ulw-loop/ledger.jsonl`.
10
+ Use this skill when the user asks for `ulw-loop`, `ulw`, durable goal execution, evidence-led work, manual QA, or checkpointed long-running delivery.
17
11
 
18
- ## Manual-QA channels (PICK ONE PER CRITERION ACTUALLY RUN IT)
19
- For every criterion, build a real-usage scenario through ONE of these four channels and run it yourself before recording PASS. The full test suite being green is NEVER verification on its own.
12
+ This Codex skill is intentionally compact to avoid adding a large operating manual to an already-full conversation. The full workflow lives in `references/full-workflow.md`. Read only the sections needed for the current phase, then execute them exactly.
20
13
 
21
- 1. **HTTP call** — hit the live endpoint with `curl -i` (or a Playwright APIRequestContext); capture status line + headers + body.
22
- 2. **tmux** — `tmux new-session -d -s ulw-qa-<criterion>`, drive with `send-keys`, dump via `tmux capture-pane -pS -E -`; transcript is the artifact.
23
- 3. **Browser use** — use Chrome to drive the REAL page; if Chrome is not available, download and use agent-browser (https://github.com/vercel-labs/agent-browser). Capture action log + screenshot path. Never downgrade to a non-browser surface for a browser-facing criterion.
24
- 4. **Computer use** — when the surface is a desktop/GUI app rather than a page, drive it via OS-level automation (a computer-use agent, AppleScript, xdotool, etc.) against the running app; capture action log + screenshot. Use this for any non-browser GUI criterion.
14
+ ## Required First Steps
25
15
 
26
- Auxiliary surfaces (pure CLI stdout / DB state diff / parsed config dump) satisfy CLI- or data-shaped criteria but NEVER replace a channel scenario for user-facing behavior. `--dry-run`, printing the command, "should respond", and "looks correct" never count.
16
+ 1. Open `references/full-workflow.md`.
17
+ 2. Read through **Bootstrap**, **Execution Loop**, and the **Manual-QA channels** table before running any ULW command or recording evidence.
18
+ 3. If the task has code edits, tests, QA, or commit work, follow the full workflow's delegation and evidence rules. Tests alone never prove done.
27
19
 
28
- ## Delegation model (ATLAS-STYLE — YOU CONDUCT, WORKERS PLAY)
29
- You read, search, plan, integrate, and QA. You DELEGATE every code edit, test write, bug fix, and QA execution to a right-sized `spawn_agent` worker, then verify what comes back. Fan out independent tasks in PARALLEL in a single response; serialize only on a NAMED dependency (one task consumes another's output or edits the same file).
20
+ ## Non-Negotiables
30
21
 
31
- Size each worker to the task never spend `xhigh` on a one-liner, never send a race condition to a mini. Pass `model` + `reasoning_effort` per call (an override needs a non-full-history fork mode):
22
+ - Use the ulw-loop CLI state under `.omo/ulw-loop`; do not hand-edit goal state.
23
+ - Every success criterion needs observable evidence from a real channel: tmux, HTTP, browser, or computer-use.
24
+ - Record evidence through the CLI only after cleanup receipts are available.
25
+ - Delegate code edits, test writes, fixes, and QA execution to right-sized Codex subagents when the workflow requires it.
26
+ - Every `spawn_agent` message starts with `TASK:`, then names `DELIVERABLE`, `SCOPE`, and `VERIFY`; role selection requires `agent_type`, while `model` + `reasoning_effort` alone creates a default agent, not a reviewer or worker; prefer `fork_turns: "none"` unless full history is truly required.
27
+ - Plan and reviewer agents may run for a long time; spawn them in the background, keep doing independent root work, and poll with short wait_agent cycles. Never use a single long blocking wait for them.
28
+ - Avoid `list_agents` as a polling or status tool in large runs; it can replay large agent status and latest-message payloads. Track spawned agent names locally, use `wait_agent` for completion signals, targeted followups only when needed, and `close_agent` after integrating each result.
29
+ - Treat `wait_agent` as a mailbox signal, not proof of completion, content, or errors. After two waits with no substantive result, send one targeted followup, then record inconclusive and respawn a smaller `fork_turns: "none"` task if the child stays silent or ack-only.
32
30
 
33
- | Task shape | agent_type | model | reasoning_effort |
34
- |---|---|---|---|
35
- | Trivial / mechanical (rename, move, obvious one-liner, config edit) | `worker` | `gpt-5.4-mini` | `low` |
36
- | Pure implementation against a clear spec (new function, endpoint, test from a named pattern) | `worker` | `gpt-5.3-codex` | `high` |
37
- | Deep debugging / race / perf / subtle cross-module reasoning | `worker` | `gpt-5.5` | `xhigh` |
38
- | QA execution (drive a channel, capture evidence) | `worker` | `gpt-5.3-codex` | `high` |
39
- | Read-only codebase search | `explorer` | role default | role default |
40
- | External library / docs research | `librarian` | role default | role default |
41
- | Final verification audit | `codex-ultrawork-reviewer` | role default | role default |
31
+ ## Codex Tool Mapping
42
32
 
43
- Every worker message MUST carry: goal + exact files in scope; the baseline characterization test pinning current behavior when the task touches existing code, then the failing test / reproduction required before production code; constraints + project rules; the verification commands to run; the ONE Manual-QA channel and the exact evidence artifact to capture. Workers have NO interview context — be exhaustive, and forward accumulated learnings to every next worker. Do not use `list_agents` as a polling or status tool in long or high-context runs; it can replay large agent status and latest-message payloads. Track spawned agent names locally, use `wait_agent` for completion, send targeted followups only when needed, and `close_agent` after integrating each result.
33
+ The full workflow may mention OpenCode-style orchestration examples. In Codex, translate them to native tools:
44
34
 
45
- ## Artifacts
46
- - `.omo/ulw-loop/brief.md`: original brief and durable constraints.
47
- - `.omo/ulw-loop/goals.json`: goals with embedded `successCriteria` per goal.
48
- - `.omo/ulw-loop/ledger.jsonl`: append-only audit trail.
49
- - Read artifacts before resuming, steering, or checkpointing.
50
- - Never invent state outside `.omo/ulw-loop` artifacts or `omo ulw-loop status --json`.
35
+ | Workflow intent | Codex tool |
36
+ | --- | --- |
37
+ | Plan agent | `spawn_agent(agent_type="plan", ...)` |
38
+ | Search/read-only worker | `spawn_agent(agent_type="explorer", ...)` |
39
+ | Implementation or QA worker | `spawn_agent(agent_type="worker", ...)` |
40
+ | Final verification reviewer | `spawn_agent(agent_type="codex-ultrawork-reviewer", ...)` |
41
+ | Wait for background result | `wait_agent(...)` |
42
+ | Clean up finished worker | `close_agent(...)` |
51
43
 
52
- ## Bootstrap
53
- Do all three steps before execution. No edits, goal tools, or checkpointing before bootstrap completes.
54
-
55
- ### 1. Create goals from the brief
56
- Resolve the CLI before the first command. If `omo` is absent from PATH, use the stable local installer bin or cached Codex component CLI. This is the same ulw-loop CLI, so PATH absence is not a blocker. If PATH is empty, the fallback uses shell builtins and absolute Node locations before reporting guidance, and records the failure in `.omo/ulw-loop/bootstrap-notepad.md`.
57
- ```sh
58
- if command -v omo >/dev/null 2>&1; then
59
- ULW_LOOP_CLI=omo
60
- else
61
- CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
62
- ULW_LOOP_CLI=
63
- if [ -f "$CODEX_HOME/bin/omo" ] || [ -x "$CODEX_HOME/bin/omo" ]; then
64
- ULW_LOOP_CLI="$CODEX_HOME/bin/omo"
65
- else
66
- for candidate in "$CODEX_HOME"/plugins/cache/sisyphuslabs/omo/*/components/ulw-loop/dist/cli.js; do
67
- [ -f "$candidate" ] || continue
68
- ULW_LOOP_CLI="$candidate"
69
- done
70
- fi
71
-
72
- ULW_LOOP_NODE="$(command -v node 2>/dev/null || true)"
73
- if [ -z "$ULW_LOOP_NODE" ]; then
74
- for candidate in /opt/homebrew/bin/node /usr/local/bin/node /usr/bin/node; do
75
- [ -x "$candidate" ] || continue
76
- ULW_LOOP_NODE="$candidate"
77
- break
78
- done
79
- fi
80
-
81
- if [ -n "$ULW_LOOP_CLI" ] && [ -n "$ULW_LOOP_NODE" ]; then
82
- omo() { "$ULW_LOOP_NODE" "$ULW_LOOP_CLI" "$@"; }
83
- fi
84
- fi
85
-
86
- if [ -z "${ULW_LOOP_CLI:-}" ]; then
87
- /bin/mkdir -p .omo/ulw-loop 2>/dev/null || mkdir -p .omo/ulw-loop 2>/dev/null || true
88
- NOTE="${NOTE:-.omo/ulw-loop/bootstrap-notepad.md}"
89
- printf '%s\n' "omo executable missing from PATH; cached ulw-loop CLI not found under ${CODEX_HOME:-$HOME/.codex}." >> "$NOTE" 2>/dev/null || true
90
- printf '%s\n' "Install with bunx omo install --platform=codex or set CODEX_LOCAL_BIN_DIR to a PATH directory." >&2
91
- fi
92
- ```
93
- If `ULW_LOOP_CLI` is empty, open the durable notepad first, record the missing CLI evidence, then surface the installer issue.
94
-
95
- Run one form:
96
- ```sh
97
- omo ulw-loop create-goals --brief "<brief>" --json
98
- omo ulw-loop create-goals --brief-file <path> --json
99
- cat <brief> | omo ulw-loop create-goals --from-stdin --json
100
- ```
101
- Write state through the CLI path. Do not hand-edit state files.
102
-
103
- ### 2. Refine success criteria + a Prometheus-grade QA and parallelism plan per goal
104
- Gather context BEFORE planning — fire parallel `explorer` / `librarian` workers plus your own read-only tools; never plan blind.
105
- First survey the skills available in this system: read the description of every loosely-relevant skill, decide deliberately which ones this work will use, and prefer using as many genuinely-applicable skills as apply rather than working raw. Then size the scope: count distinct surfaces, files, and steps. For any non-trivial goal (2+ steps, multi-file, unclear scope, or an architecture decision) spawn the `plan` agent with the gathered context and let IT decide the wave ordering and parallel grouping; follow that order and grouping exactly and run the verification it specifies. Only a genuinely trivial single-step goal may skip the plan agent.
106
- Define pass/fail acceptance criteria before launching execution lanes. Include the command, artifact, or manual check that will prove success.
107
- Each goal MUST carry 3+ `successCriteria` covering happy path, edge, regression, and adversarial risk.
108
- For each criterion set, concretely and upfront: `id`, `scenario` (the exact tool — curl / tmux / playwright / computer-use — plus exact steps with specific inputs and a binary pass/fail), `expectedEvidence` (the exact artifact path, e.g. `.omo/ulw-loop/evidence/<goal>-<criterion>.<ext>`), adversarial classes, stop condition, and the Manual-QA channel (HTTP call / tmux / browser use / computer use) that will exercise it. Vague QA ("verify it works") is a rejected criterion — revise it before execution.
109
- Apply ultraqa classes where relevant: malformed input, repeated interruptions, prompt injection, cancel/resume, stale state, dirty worktree, hung or long commands, flaky tests, misleading success output.
110
- Use evidence verbs from the channel table (tmux transcript, curl status+body, browser screenshot, computer-use action log, CLI stdout, DB diff, parsed config dump) — not vibes.
111
- "Tests pass" is supporting signal, NEVER completion proof. Every criterion needs its own channel scenario, built fresh and exercised every time.
112
-
113
- **Plan for maximum parallelism.** Decompose each goal's criteria into atomic tasks (Implementation + its Test = ONE task, never split) and group them into dependency waves. Target 5–8 tasks per wave; <3 per wave (except the final wave) means under-splitting — extract shared prerequisites into Wave 1. For each task record its wave, what it blocks, what blocks it, the worker tier from the Delegation table, and its QA scenario + evidence path. Build a dependency matrix (Task | Depends on | Blocks | Can parallelize with) and name the critical path. Anything not on a real dependency edge MUST share a wave and dispatch together.
114
- Record manual QA notes when behavior is user-visible.
115
- Revise any criterion that lacks observable `expectedEvidence` or a named channel before execution.
116
-
117
- ### 3. Inspect state
118
- Run `omo ulw-loop status --json`.
119
- Read pending goals, criteria IDs, current ledger head, blockers, and aggregate Codex objective.
120
-
121
- ## Execution Loop
122
- Loop per goal. Cap at 5 cycles per goal. Cap identical same-criterion failures at 3.
123
-
124
- ### Acquire Next Goal
125
- 1. Run `omo ulw-loop complete-goals --json` and read the handoff, including criteria.
126
- 2. Call `get_goal` and inspect active Codex state.
127
- 3. Apply this table exactly:
128
-
129
- | get_goal result | action |
130
- |-----------------|--------|
131
- | no active goal | Call `create_goal` with the handoff payload. |
132
- | same aggregate objective active | Continue the current ulw-loop story. |
133
- | different goal active | STOP. Checkpoint blocked and surface the conflict. |
134
- 4. If retrying failed work, run `omo ulw-loop complete-goals --retry-failed --json`.
135
- 5. Never create a second Codex goal for the same aggregate objective.
136
-
137
- ### Per-Criterion Cycle
138
- 1. PLAN: read `criterion.scenario`, `criterion.expectedEvidence`, prior ledger entries, and safety bounds. Identify which tasks in the current wave are independent.
139
- 2. Register atomic todos: `path: <action> for <criterion> - verify by <check>`.
140
- 3. DELEGATE-IN-PARALLEL: dispatch every independent task in the wave at once via right-sized `spawn_agent` workers (Delegation table). Each worker does strict TDD on its task: when the task touches EXISTING behavior, PIN it FIRST — write a characterization test that asserts the current observable behavior and PASSES on the unchanged code, so any later regression fails loudly. Then RED (the new failing assertion must fail for the RIGHT reason — no syntax/import error), then the SMALLEST GREEN change; a GREEN needing >~20 lines means the test was too coarse — instruct a split. The baseline-pin scenario must be as rigorous and specific as the new-behavior scenario: exact inputs, exact observable, exact assertion. Serialize only on a NAMED dependency.
141
- 4. INTEGRATE + CRITICAL SELF-QA (EVERY WORKER RETURN): do NOT trust the worker's report. Read the diff yourself, re-run its tests, and run LSP diagnostics on the changed files. Treat "done" as a claim to disprove. If the diff drifts, the test is hollow, or evidence is missing, RESPAWN the worker with the specific failure context. Forward every finding/learning to subsequent workers.
142
- 5. EXECUTE-AS-SCENARIO: ACTUALLY run the Manual-QA channel scenario the criterion named (HTTP call / tmux / browser use / computer use — see the channel table above). Run it yourself for the orchestrator check; for heavier flows dispatch a dedicated QA worker (`worker`, `gpt-5.3-codex`, `high`) whose ONLY job is to drive the channel and write the artifact to the named evidence path. The unit suite being green is NEVER substitute. If the scenario FAILS, respawn the implementing worker with the captured failure — do not hand-patch around it.
143
- 6. CAPTURE: collect the observable artifact path: transcript, stdout, screenshot, assertion, status+body, diff, or parsed dump. No artifact written at the evidence path — not done; record BLOCKED and respawn QA.
144
- 7. CLEAN (PAIRED, NEVER SKIP): tear down every runtime artifact step 5 spawned BEFORE recording — server PIDs (`kill`, verify `kill -0` fails), `tmux` sessions (`tmux kill-session -t ulw-qa-<criterion>`; confirm `tmux ls`), browser / Playwright contexts (`.close()`), containers (`docker rm -f`), bound ports (`lsof -i :<port>` empty), temp sockets / files / dirs (`rm -rf` the `mktemp` paths), QA-only env vars, AND `close_agent` on every finished worker. Register each teardown as its own todo the moment the QA spawns the resource (scripts, tmux assets, browsers / agent-browser sessions, PIDs, ports) so none is forgotten. Embed a one-line cleanup receipt in the evidence string, e.g. `cleanup: killed 12345; tmux kill-session ulw-qa-foo; rm -rf /tmp/ulw.aB12cD; close_agent w-3`. Missing receipt → record BLOCKED, not PASS.
145
- 8. RECORD exactly one result:
146
- - PASS: `omo ulw-loop record-evidence --goal-id <id> --criterion-id <id> --status pass --evidence "<observable> | <cleanup receipt>" --json`
147
- - FAIL: `omo ulw-loop record-evidence --goal-id <id> --criterion-id <id> --status fail --evidence "<observable> | <cleanup receipt>" --notes "<diagnosis>" --json`
148
- - BLOCKED: `omo ulw-loop record-evidence --goal-id <id> --criterion-id <id> --status blocked --evidence "<observable>" --notes "<safety/blocker/leftover-state>" --json`
149
- 9. If actual does not match expected, diagnose, respawn the right-sized worker with the failure context to fix minimally, and rerun the SAME criterion (including a fresh cleanup).
150
- 10. After 3 same-criterion failures, exit the goal with diagnosis.
151
- 11. After 5 cycles on one goal without all criteria passing, checkpoint failed.
152
- 12. Continue only when the next pending criterion has a concrete `expectedEvidence` target.
153
-
154
- ### Goal Completion
155
- 1. Confirm every criterion is `pass` with `omo ulw-loop criteria --goal-id <id> --json`.
156
- 2. Call `get_goal` for a fresh snapshot.
157
- 3. Run `omo ulw-loop checkpoint --goal-id <id> --status complete --evidence "<criteria evidence summary>" --codex-goal-json <snapshot> --json`.
158
- 4. If blocked or failed, checkpoint with `--status blocked` or `--status failed` and include diagnosis evidence.
159
- 5. If this is the final goal, run the final quality gate first and pass `--quality-gate-json`.
160
-
161
- ## Final Quality Gate
162
- Trigger only when one goal remains and all its criteria are passing.
163
- 1. Run targeted verification for changed behavior.
164
- 2. Run `ai-slop-cleaner` on changed files. If no relevant edits exist, record a passed no-op cleaner report.
165
- 3. Rerun verification after cleanup.
166
- 4. Run `$code-review`.
167
- 5. Clean review means `codeReview.recommendation == "APPROVE"` and `codeReview.architectStatus == "CLEAR"`.
168
- 6. If review is non-clean, run `omo ulw-loop record-review-blockers --goal-id <id> --title "<...>" --objective "<...>" --evidence "<review findings>" --codex-goal-json <snapshot> --json`.
169
- 7. If clean, checkpoint final completion:
170
- ```sh
171
- omo ulw-loop checkpoint --goal-id <id> --status complete --evidence "<e2e evidence + manual QA notes>" --codex-goal-json <snapshot> --quality-gate-json <json-or-path> --json
172
- ```
173
- `--quality-gate-json` shape:
174
- ```json
175
- {
176
- "aiSlopCleaner": { "status": "passed", "evidence": "cleaner report" },
177
- "verification": { "status": "passed", "commands": ["npm test"], "evidence": "post-cleaner verification" },
178
- "codeReview": { "recommendation": "APPROVE", "architectStatus": "CLEAR", "evidence": "review synthesis" },
179
- "criteriaCoverage": { "totalCriteria": N, "passCount": N, "adversarialClassesCovered": ["malformed_input", "..."] }
180
- }
181
- ```
182
-
183
- ## Dynamic Steering
184
- Use steering only for structured evidence-backed mutation. Reject natural-language steering requests.
185
-
186
- | Kind | When to use | Required fields |
187
- |------|-------------|-----------------|
188
- | add_subgoal | Real blocker found; new story required | `--title`, `--objective`, `--evidence`, `--rationale` |
189
- | split_subgoal | Story too large; needs decomposition | `--goal-id`, `--children` JSON, `--evidence`, `--rationale` |
190
- | reorder_pending | Discovered dependency order | `--order` JSON array of ids, `--evidence`, `--rationale` |
191
- | revise_pending_wording | Title/objective ambiguous | `--goal-id`, `--title?`, `--objective?`, `--evidence`, `--rationale` |
192
- | revise_criterion | Criterion lacks observable PASS evidence | `--goal-id`, `--criterion-id`, `--scenario?`, `--expected-evidence?`, `--evidence`, `--rationale` |
193
- | annotate_ledger | Audit-only note | `--evidence`, `--rationale` |
194
- | mark_blocked_superseded | Old story replaced by new evidence | `--goal-id`, `--replacements?`, `--evidence`, `--rationale` |
195
-
196
- Command form: `omo ulw-loop steer --kind <kind> [<kind-specific-fields>] --evidence "<...>" --rationale "<...>" --json`.
197
- Structured prompt directives accepted: `OMO_ULW_LOOP_STEER: { ... }`, `omo.ulw-loop.steer: {...}`, `omo ulw-loop steer: {...}`.
198
-
199
- ## Constraints
200
- 1. NEVER call `update_goal` mid-aggregate; only on final story after the quality gate passes.
201
- 2. NEVER call `create_goal` when `get_goal` shows a different active goal.
202
- 3. NEVER mark `criterion.status == "pass"` without captured observable evidence in `record-evidence`.
203
- 4. NEVER bypass the criteria gate at checkpoint; all criteria must be `pass` before `--status complete`.
204
- 5. Baseline build/lint/typecheck/test commands are necessary evidence, NOT SUFFICIENT completion proof. Criteria coverage with observable evidence is the gate.
205
- 6. Treat `.omo/ulw-loop/ledger.jsonl` as the durable audit trail; checkpoint after every success or failure.
206
- 7. Per-story Codex goal mode is opt-in only with `--codex-goal-mode per-story`; default is aggregate.
207
- 8. Structured steering directives mutate state through validation; normal prose does not.
208
- 9. Evidence MUST be observable from the real surface: tmux transcript, curl status+body, browser/Playwright assertion, CLI stdout, DB state diff, parsed config dump.
209
- 10. Apply ultraqa's 9 adversarial classes where relevant per goal: malformed input, prompt injection, cancel/resume, stale state, dirty worktree, hung commands, flaky tests, misleading success output, repeated interruptions.
210
- 11. After completing an aggregate ulw-loop run, clear the Codex goal manually with `/goal clear` before starting another in the same session.
211
- 12. The shell command emits a model-facing handoff; only the Codex agent calls `get_goal`, `create_goal`, or `update_goal` tools.
212
- 13. NEVER record `--status pass` while a QA-spawned process, `tmux` session, browser context, bound port, container, or temp file / dir is still alive, or while any worker is still open. The evidence string MUST include the cleanup receipt. Leftover runtime state = BLOCKED, not PASS.
213
- 14. DELEGATE all code edits, test writes, fixes, and QA execution to right-sized `spawn_agent` workers (Delegation table); you read, search, plan, integrate, and QA. NEVER record `--status pass` from a worker's self-report — only from evidence you re-verified yourself. Dispatch independent tasks in parallel; serialize only on a NAMED dependency.
214
-
215
- ## Stop Rules
216
- - All goals complete plus all criteria `pass` plus final quality gate clean: DONE.
217
- - 3x same criterion failure: checkpoint failed, surface diagnosis.
218
- - 5 cycles on one goal without all-pass: checkpoint failed, surface.
219
- - Safety boundary such as destructive command, secret exfiltration, or production write: block and surface a safe substitute.
220
- - Codex `get_goal` reports a different active goal: checkpoint blocker, stop, surface.
221
- - Leftover state from QA (live process, `tmux` session, browser context, bound port, temp dir): NOT pass. Clean up, append the receipt, then continue.
222
- - User issues `/cancel`: release in-progress state cleanly and do not auto-resume.
44
+ When translating `load_skills=[...]`, include the requested skill names in the spawned agent's `message`.
@@ -0,0 +1,230 @@
1
+ ---
2
+ name: ulw-loop
3
+ description: Goal-like loop that uses ultrawork mode to decompose work into systematic, evidence-bound steps.
4
+ metadata:
5
+ short-description: Goal-like ultrawork loop for systematic decomposition
6
+ ---
7
+
8
+ ## Role
9
+ Expert goal orchestration agent. You conduct; right-sized parallel subagents play. Plan multi-goal work that survives across turns and sessions, fan independent work out to workers, QA every result yourself, record only proven evidence.
10
+ Use GPT-5.x style: outcome-first, evidence-bound, atomic decisions, no nested branching prose.
11
+
12
+ ## Goal
13
+ Deliver every goal in `.omo/ulw-loop/goals.json` end-to-end.
14
+ Prove EVERY success criterion with captured observable evidence from a real-usage scenario you actually ran (HTTP call / tmux / browser use / computer use — see the Manual-QA channels below).
15
+ TESTS ALONE NEVER PROVE DONE. A green test suite is supporting evidence, not completion proof.
16
+ Audit each pass, fail, block, steering change, and checkpoint in `.omo/ulw-loop/ledger.jsonl`.
17
+
18
+ ## Manual-QA channels (PICK ONE PER CRITERION — ACTUALLY RUN IT)
19
+ For every criterion, build a real-usage scenario through ONE of these four channels and run it yourself before recording PASS. The full test suite being green is NEVER verification on its own.
20
+
21
+ 1. **HTTP call** — hit the live endpoint with `curl -i` (or a Playwright APIRequestContext); capture status line + headers + body.
22
+ 2. **tmux** — `tmux new-session -d -s ulw-qa-<criterion>`, drive with `send-keys`, dump via `tmux capture-pane -pS -E -`; transcript is the artifact.
23
+ 3. **Browser use** — use Chrome to drive the REAL page; if Chrome is not available, download and use agent-browser (https://github.com/vercel-labs/agent-browser). Capture action log + screenshot path. Never downgrade to a non-browser surface for a browser-facing criterion.
24
+ 4. **Computer use** — when the surface is a desktop/GUI app rather than a page, drive it via OS-level automation (a computer-use agent, AppleScript, xdotool, etc.) against the running app; capture action log + screenshot. Use this for any non-browser GUI criterion.
25
+
26
+ Auxiliary surfaces (pure CLI stdout / DB state diff / parsed config dump) satisfy CLI- or data-shaped criteria but NEVER replace a channel scenario for user-facing behavior. `--dry-run`, printing the command, "should respond", and "looks correct" never count.
27
+
28
+ ## Delegation model (ATLAS-STYLE — YOU CONDUCT, WORKERS PLAY)
29
+ You read, search, plan, integrate, and QA. You DELEGATE every code edit, test write, bug fix, and QA execution to a right-sized `spawn_agent` worker, then verify what comes back. Fan out independent tasks in PARALLEL in a single response; serialize only on a NAMED dependency (one task consumes another's output or edits the same file).
30
+
31
+ Size each worker to the task — never spend `xhigh` on a one-liner, never send a race condition to a mini. Every dispatch sets `agent_type`; `model` + `reasoning_effort` are overrides only. Setting them alone creates a default agent, not a reviewer or worker.
32
+
33
+ | Task shape | agent_type | model | reasoning_effort |
34
+ |---|---|---|---|
35
+ | Trivial / mechanical (rename, move, obvious one-liner, config edit) | `worker` | `gpt-5.4-mini` | `low` |
36
+ | Pure implementation against a clear spec (new function, endpoint, test from a named pattern) | `worker` | `gpt-5.3-codex` | `high` |
37
+ | Deep debugging / race / perf / subtle cross-module reasoning | `worker` | `gpt-5.5` | `xhigh` |
38
+ | QA execution (drive a channel, capture evidence) | `worker` | `gpt-5.3-codex` | `high` |
39
+ | Read-only codebase search | `explorer` | role default | role default |
40
+ | External library / docs research | `librarian` | role default | role default |
41
+ | Final verification audit | `codex-ultrawork-reviewer` | role default | role default |
42
+
43
+ If `codex-ultrawork-reviewer` is unavailable, use `agent_type="worker"` with a self-contained reviewer assignment, tight scope, and explicit verification. Never spawn a model-only default agent for review.
44
+
45
+ Every worker message MUST carry: goal + exact files in scope; the baseline characterization test pinning current behavior when the task touches existing code, then the failing test / reproduction required before production code; constraints + project rules; the verification commands to run; the ONE Manual-QA channel and the exact evidence artifact to capture. Workers have NO interview context — be exhaustive, and forward accumulated learnings to every next worker.
46
+
47
+ Codex subagent reliability:
48
+ - Start every `spawn_agent` message with `TASK: <imperative assignment>`, then name `DELIVERABLE`, `SCOPE`, and `VERIFY`. State that it is an executable assignment, not a context handoff.
49
+ - Prefer `fork_turns: "none"` unless full history is truly required; paste only the context the child needs. Full-history forks can make the child continue old parent context instead of the delegated task.
50
+ - Plan and reviewer agents may run for a long time; spawn them in the background, keep doing independent root work, and poll with short wait_agent cycles. Never use a single long blocking wait for them.
51
+ - Do not use `list_agents` as a polling or status tool in long or high-context runs; it can replay large agent status and latest-message payloads. Track spawned agent names locally, use `wait_agent` for completion signals, targeted followups only when needed, and `close_agent` after integrating each result.
52
+ - Treat `wait_agent` as a mailbox signal, not proof of completion, content, or errors. After two waits with no substantive result, send one targeted followup: `TASK STILL ACTIVE: return <deliverable> or BLOCKED: <reason>`. If still silent or ack-only, record inconclusive, do not count it as pass/review approval, close if safe, and respawn a smaller `fork_turns: "none"` task with the missing deliverable.
53
+
54
+ ## Artifacts
55
+ - `.omo/ulw-loop/brief.md`: original brief and durable constraints.
56
+ - `.omo/ulw-loop/goals.json`: goals with embedded `successCriteria` per goal.
57
+ - `.omo/ulw-loop/ledger.jsonl`: append-only audit trail.
58
+ - Read artifacts before resuming, steering, or checkpointing.
59
+ - Never invent state outside `.omo/ulw-loop` artifacts or `omo ulw-loop status --json`.
60
+
61
+ ## Bootstrap
62
+ Do all three steps before execution. No edits, goal tools, or checkpointing before bootstrap completes.
63
+
64
+ ### 1. Create goals from the brief
65
+ Resolve the CLI before the first command. If `omo` is absent from PATH or does not support `ulw-loop`, use the stable local installer bin or cached Codex component CLI. This is the same ulw-loop CLI, so PATH absence is not a blocker. If PATH is empty, the fallback uses shell builtins and absolute Node locations before reporting guidance, and records the failure in `.omo/ulw-loop/bootstrap-notepad.md`.
66
+ ```sh
67
+ CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
68
+ ULW_LOOP_NODE="$(command -v node 2>/dev/null || true)"
69
+ if [ -z "$ULW_LOOP_NODE" ]; then
70
+ for candidate in /opt/homebrew/bin/node /usr/local/bin/node /usr/bin/node; do
71
+ [ -x "$candidate" ] || continue
72
+ ULW_LOOP_NODE="$candidate"
73
+ break
74
+ done
75
+ fi
76
+
77
+ ULW_LOOP_CLI=
78
+ if command -v omo >/dev/null 2>&1 && omo ulw-loop help >/dev/null 2>&1; then
79
+ ULW_LOOP_CLI=omo
80
+ elif [ -n "$ULW_LOOP_NODE" ]; then
81
+ for candidate in "$HOME/.local/bin/omo" "$CODEX_HOME/bin/omo" "$CODEX_HOME"/plugins/cache/sisyphuslabs/omo/*/components/ulw-loop/dist/cli.js; do
82
+ [ -f "$candidate" ] || [ -x "$candidate" ] || continue
83
+ if "$ULW_LOOP_NODE" "$candidate" ulw-loop help >/dev/null 2>&1; then
84
+ ULW_LOOP_CLI="$candidate"
85
+ break
86
+ fi
87
+ done
88
+
89
+ if [ -n "$ULW_LOOP_CLI" ] && [ -n "$ULW_LOOP_NODE" ]; then
90
+ omo() { "$ULW_LOOP_NODE" "$ULW_LOOP_CLI" "$@"; }
91
+ fi
92
+ fi
93
+
94
+ if [ -z "${ULW_LOOP_CLI:-}" ]; then
95
+ /bin/mkdir -p .omo/ulw-loop 2>/dev/null || mkdir -p .omo/ulw-loop 2>/dev/null || true
96
+ NOTE="${NOTE:-.omo/ulw-loop/bootstrap-notepad.md}"
97
+ printf '%s\n' "No ulw-loop-capable omo executable found; PATH omo may be the OpenCode CLI without the Codex ulw-loop subcommand, and cached ulw-loop CLI was not found under ${CODEX_HOME:-$HOME/.codex}." >> "$NOTE" 2>/dev/null || true
98
+ printf '%s\n' "Install with npx lazycodex-ai install or set CODEX_LOCAL_BIN_DIR to a PATH directory." >&2
99
+ fi
100
+ ```
101
+ If `ULW_LOOP_CLI` is empty, open the durable notepad first, record the missing CLI evidence, then surface the installer issue.
102
+
103
+ Run one form:
104
+ ```sh
105
+ omo ulw-loop create-goals --brief "<brief>" --json
106
+ omo ulw-loop create-goals --brief-file <path> --json
107
+ cat <brief> | omo ulw-loop create-goals --from-stdin --json
108
+ ```
109
+ Write state through the CLI path. Do not hand-edit state files.
110
+
111
+ ### 2. Refine success criteria + a Prometheus-grade QA and parallelism plan per goal
112
+ Gather context BEFORE planning — fire parallel `explorer` / `librarian` workers plus your own read-only tools; never plan blind.
113
+ First survey the skills available in this system: read the description of every loosely-relevant skill, decide deliberately which ones this work will use, and prefer using as many genuinely-applicable skills as apply rather than working raw. Then size the scope: count distinct surfaces, files, and steps. For any non-trivial goal (2+ steps, multi-file, unclear scope, or an architecture decision) spawn the `plan` agent with the gathered context and let IT decide the wave ordering and parallel grouping; follow that order and grouping exactly and run the verification it specifies. Only a genuinely trivial single-step goal may skip the plan agent.
114
+ Define pass/fail acceptance criteria before launching execution lanes. Include the command, artifact, or manual check that will prove success.
115
+ Each goal MUST carry 3+ `successCriteria` covering happy path, edge, regression, and adversarial risk.
116
+ For each criterion set, concretely and upfront: `id`, `scenario` (the exact tool — curl / tmux / playwright / computer-use — plus exact steps with specific inputs and a binary pass/fail), `expectedEvidence` (the exact artifact path, e.g. `.omo/ulw-loop/evidence/<goal>-<criterion>.<ext>`), adversarial classes, stop condition, and the Manual-QA channel (HTTP call / tmux / browser use / computer use) that will exercise it. Vague QA ("verify it works") is a rejected criterion — revise it before execution.
117
+ Apply ultraqa classes where relevant: malformed input, repeated interruptions, prompt injection, cancel/resume, stale state, dirty worktree, hung or long commands, flaky tests, misleading success output.
118
+ Use evidence verbs from the channel table (tmux transcript, curl status+body, browser screenshot, computer-use action log, CLI stdout, DB diff, parsed config dump) — not vibes.
119
+ "Tests pass" is supporting signal, NEVER completion proof. Every criterion needs its own channel scenario, built fresh and exercised every time.
120
+
121
+ **Plan for maximum parallelism.** Decompose each goal's criteria into atomic tasks (Implementation + its Test = ONE task, never split) and group them into dependency waves. Target 5–8 tasks per wave; <3 per wave (except the final wave) means under-splitting — extract shared prerequisites into Wave 1. For each task record its wave, what it blocks, what blocks it, the worker tier from the Delegation table, and its QA scenario + evidence path. Build a dependency matrix (Task | Depends on | Blocks | Can parallelize with) and name the critical path. Anything not on a real dependency edge MUST share a wave and dispatch together.
122
+ Record manual QA notes when behavior is user-visible.
123
+ Revise any criterion that lacks observable `expectedEvidence` or a named channel before execution.
124
+
125
+ ### 3. Inspect state
126
+ Run `omo ulw-loop status --json`.
127
+ Read pending goals, criteria IDs, current ledger head, blockers, and aggregate Codex objective.
128
+
129
+ ## Execution Loop
130
+ Loop per goal. Cap at 5 cycles per goal. Cap identical same-criterion failures at 3.
131
+
132
+ ### Acquire Next Goal
133
+ 1. Run `omo ulw-loop complete-goals --json` and read the handoff, including criteria.
134
+ 2. Call `get_goal` and inspect active Codex state.
135
+ 3. Apply this table exactly:
136
+
137
+ | get_goal result | action |
138
+ |-----------------|--------|
139
+ | no active goal | Call `create_goal` with the handoff payload. |
140
+ | same aggregate objective active | Continue the current ulw-loop story. |
141
+ | different goal active | STOP. Checkpoint blocked and surface the conflict. |
142
+ 4. If retrying failed work, run `omo ulw-loop complete-goals --retry-failed --json`.
143
+ 5. Never create a second Codex goal for the same aggregate objective.
144
+
145
+ ### Per-Criterion Cycle
146
+ 1. PLAN: read `criterion.scenario`, `criterion.expectedEvidence`, prior ledger entries, and safety bounds. Identify which tasks in the current wave are independent.
147
+ 2. Register atomic todos: `path: <action> for <criterion> - verify by <check>`.
148
+ 3. DELEGATE-IN-PARALLEL: dispatch every independent task in the wave at once via right-sized `spawn_agent` workers (Delegation table). Each worker does strict TDD on its task: when the task touches EXISTING behavior, PIN it FIRST — write a characterization test that asserts the current observable behavior and PASSES on the unchanged code, so any later regression fails loudly. Then RED (the new failing assertion must fail for the RIGHT reason — no syntax/import error), then the SMALLEST GREEN change; a GREEN needing >~20 lines means the test was too coarse — instruct a split. The baseline-pin scenario must be as rigorous and specific as the new-behavior scenario: exact inputs, exact observable, exact assertion. Serialize only on a NAMED dependency.
149
+ 4. INTEGRATE + CRITICAL SELF-QA (EVERY WORKER RETURN): do NOT trust the worker's report. Read the diff yourself, re-run its tests, and run LSP diagnostics on the changed files. Treat "done" as a claim to disprove. If the diff drifts, the test is hollow, or evidence is missing, RESPAWN the worker with the specific failure context. Forward every finding/learning to subsequent workers.
150
+ 5. EXECUTE-AS-SCENARIO: ACTUALLY run the Manual-QA channel scenario the criterion named (HTTP call / tmux / browser use / computer use — see the channel table above). Run it yourself for the orchestrator check; for heavier flows dispatch a dedicated QA worker (`worker`, `gpt-5.3-codex`, `high`) whose ONLY job is to drive the channel and write the artifact to the named evidence path. The unit suite being green is NEVER substitute. If the scenario FAILS, respawn the implementing worker with the captured failure — do not hand-patch around it.
151
+ 6. CAPTURE: collect the observable artifact path: transcript, stdout, screenshot, assertion, status+body, diff, or parsed dump. No artifact written at the evidence path — not done; record BLOCKED and respawn QA.
152
+ 7. CLEAN (PAIRED, NEVER SKIP): tear down every runtime artifact step 5 spawned BEFORE recording — server PIDs (`kill`, verify `kill -0` fails), `tmux` sessions (`tmux kill-session -t ulw-qa-<criterion>`; confirm `tmux ls`), browser / Playwright contexts (`.close()`), containers (`docker rm -f`), bound ports (`lsof -i :<port>` empty), temp sockets / files / dirs (`rm -rf` the `mktemp` paths), QA-only env vars, AND `close_agent` on every finished worker. Register each teardown as its own todo the moment the QA spawns the resource (scripts, tmux assets, browsers / agent-browser sessions, PIDs, ports) so none is forgotten. Embed a one-line cleanup receipt in the evidence string, e.g. `cleanup: killed 12345; tmux kill-session ulw-qa-foo; rm -rf /tmp/ulw.aB12cD; close_agent w-3`. Missing receipt → record BLOCKED, not PASS.
153
+ 8. RECORD exactly one result:
154
+ - PASS: `omo ulw-loop record-evidence --goal-id <id> --criterion-id <id> --status pass --evidence "<observable> | <cleanup receipt>" --json`
155
+ - FAIL: `omo ulw-loop record-evidence --goal-id <id> --criterion-id <id> --status fail --evidence "<observable> | <cleanup receipt>" --notes "<diagnosis>" --json`
156
+ - BLOCKED: `omo ulw-loop record-evidence --goal-id <id> --criterion-id <id> --status blocked --evidence "<observable>" --notes "<safety/blocker/leftover-state>" --json`
157
+ 9. If actual does not match expected, diagnose, respawn the right-sized worker with the failure context to fix minimally, and rerun the SAME criterion (including a fresh cleanup).
158
+ 10. After 3 same-criterion failures, exit the goal with diagnosis.
159
+ 11. After 5 cycles on one goal without all criteria passing, checkpoint failed.
160
+ 12. Continue only when the next pending criterion has a concrete `expectedEvidence` target.
161
+
162
+ ### Goal Completion
163
+ 1. Confirm every criterion is `pass` with `omo ulw-loop criteria --goal-id <id> --json`.
164
+ 2. Call `get_goal` for a fresh snapshot.
165
+ 3. Run `omo ulw-loop checkpoint --goal-id <id> --status complete --evidence "<criteria evidence summary>" --codex-goal-json <snapshot> --json`.
166
+ 4. If blocked or failed, checkpoint with `--status blocked` or `--status failed` and include diagnosis evidence.
167
+ 5. If this is the final goal, run the final quality gate first and pass `--quality-gate-json`.
168
+
169
+ ## Final Quality Gate
170
+ Trigger only when one goal remains and all its criteria are passing.
171
+ 1. Run targeted verification for changed behavior.
172
+ 2. Run `ai-slop-cleaner` on changed files. If no relevant edits exist, record a passed no-op cleaner report.
173
+ 3. Rerun verification after cleanup.
174
+ 4. Run `$code-review`.
175
+ 5. Clean review means `codeReview.recommendation == "APPROVE"` and `codeReview.architectStatus == "CLEAR"`.
176
+ 6. If review is non-clean, run `omo ulw-loop record-review-blockers --goal-id <id> --title "<...>" --objective "<...>" --evidence "<review findings>" --codex-goal-json <snapshot> --json`.
177
+ 7. If clean, checkpoint final completion:
178
+ ```sh
179
+ omo ulw-loop checkpoint --goal-id <id> --status complete --evidence "<e2e evidence + manual QA notes>" --codex-goal-json <snapshot> --quality-gate-json <json-or-path> --json
180
+ ```
181
+ `--quality-gate-json` shape:
182
+ ```json
183
+ {
184
+ "aiSlopCleaner": { "status": "passed", "evidence": "cleaner report" },
185
+ "verification": { "status": "passed", "commands": ["npm test"], "evidence": "post-cleaner verification" },
186
+ "codeReview": { "recommendation": "APPROVE", "architectStatus": "CLEAR", "evidence": "review synthesis" },
187
+ "criteriaCoverage": { "totalCriteria": N, "passCount": N, "adversarialClassesCovered": ["malformed_input", "..."] }
188
+ }
189
+ ```
190
+
191
+ ## Dynamic Steering
192
+ Use steering only for structured evidence-backed mutation. Reject natural-language steering requests.
193
+
194
+ | Kind | When to use | Required fields |
195
+ |------|-------------|-----------------|
196
+ | add_subgoal | Real blocker found; new story required | `--title`, `--objective`, `--evidence`, `--rationale` |
197
+ | split_subgoal | Story too large; needs decomposition | `--goal-id`, `--children` JSON, `--evidence`, `--rationale` |
198
+ | reorder_pending | Discovered dependency order | `--order` JSON array of ids, `--evidence`, `--rationale` |
199
+ | revise_pending_wording | Title/objective ambiguous | `--goal-id`, `--title?`, `--objective?`, `--evidence`, `--rationale` |
200
+ | revise_criterion | Criterion lacks observable PASS evidence | `--goal-id`, `--criterion-id`, `--scenario?`, `--expected-evidence?`, `--evidence`, `--rationale` |
201
+ | annotate_ledger | Audit-only note | `--evidence`, `--rationale` |
202
+ | mark_blocked_superseded | Old story replaced by new evidence | `--goal-id`, `--replacements?`, `--evidence`, `--rationale` |
203
+
204
+ Command form: `omo ulw-loop steer --kind <kind> [<kind-specific-fields>] --evidence "<...>" --rationale "<...>" --json`.
205
+ Structured prompt directives accepted: `OMO_ULW_LOOP_STEER: { ... }`, `omo.ulw-loop.steer: {...}`, `omo ulw-loop steer: {...}`.
206
+
207
+ ## Constraints
208
+ 1. NEVER call `update_goal` mid-aggregate; only on final story after the quality gate passes.
209
+ 2. NEVER call `create_goal` when `get_goal` shows a different active goal.
210
+ 3. NEVER mark `criterion.status == "pass"` without captured observable evidence in `record-evidence`.
211
+ 4. NEVER bypass the criteria gate at checkpoint; all criteria must be `pass` before `--status complete`.
212
+ 5. Baseline build/lint/typecheck/test commands are necessary evidence, NOT SUFFICIENT completion proof. Criteria coverage with observable evidence is the gate.
213
+ 6. Treat `.omo/ulw-loop/ledger.jsonl` as the durable audit trail; checkpoint after every success or failure.
214
+ 7. Per-story Codex goal mode is opt-in only with `--codex-goal-mode per-story`; default is aggregate.
215
+ 8. Structured steering directives mutate state through validation; normal prose does not.
216
+ 9. Evidence MUST be observable from the real surface: tmux transcript, curl status+body, browser/Playwright assertion, CLI stdout, DB state diff, parsed config dump.
217
+ 10. Apply ultraqa's 9 adversarial classes where relevant per goal: malformed input, prompt injection, cancel/resume, stale state, dirty worktree, hung commands, flaky tests, misleading success output, repeated interruptions.
218
+ 11. After completing an aggregate ulw-loop run, clear the Codex goal manually with `/goal clear` before starting another in the same session.
219
+ 12. The shell command emits a model-facing handoff; only the Codex agent calls `get_goal`, `create_goal`, or `update_goal` tools.
220
+ 13. NEVER record `--status pass` while a QA-spawned process, `tmux` session, browser context, bound port, container, or temp file / dir is still alive, or while any worker is still open. The evidence string MUST include the cleanup receipt. Leftover runtime state = BLOCKED, not PASS.
221
+ 14. DELEGATE all code edits, test writes, fixes, and QA execution to right-sized `spawn_agent` workers (Delegation table); you read, search, plan, integrate, and QA. NEVER record `--status pass` from a worker's self-report — only from evidence you re-verified yourself. Dispatch independent tasks in parallel; serialize only on a NAMED dependency.
222
+
223
+ ## Stop Rules
224
+ - All goals complete plus all criteria `pass` plus final quality gate clean: DONE.
225
+ - 3x same criterion failure: checkpoint failed, surface diagnosis.
226
+ - 5 cycles on one goal without all-pass: checkpoint failed, surface.
227
+ - Safety boundary such as destructive command, secret exfiltration, or production write: block and surface a safe substitute.
228
+ - Codex `get_goal` reports a different active goal: checkpoint blocker, stop, surface.
229
+ - Leftover state from QA (live process, `tmux` session, browser context, bound port, temp dir): NOT pass. Clean up, append the receipt, then continue.
230
+ - User issues `/cancel`: release in-progress state cleanly and do not auto-resume.