Skip to content

refactor: keep the L2 system prompt in one file instead of three inline copies - #161

Merged
STRML merged 4 commits into
mainfrom
refactor/l2-system-prompt-file
Oct 20, 2026
Merged

STRML merged 4 commits into
mainfrom
refactor/l2-system-prompt-file

Conversation

@STRML

@STRML STRML commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

The L2 aggregator's system prompt (657 characters) was inline in three places: the claude adapter's l2-argv, the omp adapter's l2-argv, and run.sh's built-in claude fallback. It now lives in prompts/L2_SYSTEM.txt, read through bin/l2-prompt.sh. The text states the stdout grammar that bin/report-format.sh parses (the report, AUTODREAM_REPORT_END, the optional pin block, the summary), so a copy that drifted from the parser would show up only as an L2 run whose output the runner cannot split.

All three old copies were byte-identical (checked with cmp, including the em dash, and run.sh's \$ turned back into $). install.sh links the prompt and the loader.

A missing prompt now stops things instead of starting an engine with no instructions: both adapters' l2-argv exit 2 and print no argv, and run.sh refuses to start before L1 for every engine, claude included.

Sibling of #160 (the report contract as one lib); the two are independent.

Status

Check Result
tests/l2-prompt.sh 27 assertions (25 when written first, with 8 failing before the change; cb3e3a0 adds two). Covers the text, the loader's missing, empty and symlinked cases, both adapters in a throwaway tree with and without the file, and that no script keeps an inline copy.
test_a_missing_l2_prompt_stops_the_run_before_l1 in tests/run-all.sh passes; fails with the startup check mutated away (2 assertions go red: no Refusing to start, and an L1 round starts)
Full tests/run-all.sh on a clean export of 7e707a4 (the head before cb3e3a0, which only touches the loader's whitespace check, one log line and tests/l2-prompt.sh, whose suite was re-run) 2735 passed, 4 failed. The 4 fail on unchanged main in this sandbox (adapter-claude needs ps, two review-cmux interactive assertions, the prune-worktrees watchdog timing). Run with TZ=America/New_York.
shellcheck no new findings on the changed files
Subagent review (code-reviewer) on ba742eb no blocking findings. Byte identity confirmed; path resolution lands in the checkout in every layout it traced; no apostrophe or helper call inside the L1 worker's single-quoted bash -c.

The review found one real gap, fixed in 7e707a4: with the prompt file absent and the claude adapter current, the claude engine was exempt from the startup probe, so a run paid for L1 and then failed all three L2 attempts. The prompt is now checked for every engine before L1. The sandbox installs in tests/run-all.sh (four helpers) now carry L2_SYSTEM.txt as install.sh does, because a run from a copied bin/ finds the prompt only there. My first version of the new test was vacuous (it passed with the check removed because the mock only writes captures when a capture variable is set); the version here asserts on the run log.

Review nits, fixed in cb3e3a0

  • A prompt file of only whitespace is now refused (the check was -s); the relative-symlink branch of the loader has a test; the fallback's log line no longer claims the adapter "has no l2-argv". Each new loader test fails with its rule mutated away; tests/l2-prompt.sh is now 27 assertions.

Open follow-ups

Test plan

  • bash tests/l2-prompt.sh
  • tests/run-all.sh on a clean export of the head, TZ=America/New_York
  • Subagent review
  • Merge, git pull in the install checkout, then ./install.sh so the install links L2_SYSTEM.txt and l2-prompt.sh (a stale install still finds them through the checkout)

STRML added 4 commits October 20, 2026 07:05
…ne copies

prompts/L2_SYSTEM.txt holds the text the claude adapter, the omp adapter and run.sh's built-in claude fallback each carried inline (byte-identical, 657 characters). bin/l2-prompt.sh reads it and returns 2 with a message when it cannot. Both adapters' l2-argv exit 2 and print no argv without it, and run.sh's fallback builds no argv and logs why, because an engine started without the prompt runs L2 with no word on where the report goes. install.sh links the file and the loader.

tests/l2-prompt.sh (25 assertions): red first (8 failures), then green. Covers the text, the loader's missing and empty cases, a symlinked lib, both adapters with and without the file in a throwaway tree, and that no script keeps an inline copy.
…claude engine included

Review of ba742eb: with prompts/L2_SYSTEM.txt absent and the claude adapter current, l2-argv exits 2, the built-in fallback also finds no prompt, and every L2 attempt fails after L1 has been paid for (the claude engine is exempt from the argv probe). run.sh now checks the prompt for every engine next to the AUTODREAM_L2_ENGINE validation, so the night stops with a FATAL naming the file.

tests/run-all.sh: setup_env, setup_env_altroot and the two install-like fixtures now put L2_SYSTEM.txt in the sandbox's autodream dir, as install.sh does, because a run from a copied bin/ finds the prompt only there. New test_a_missing_l2_prompt_stops_the_run_before_l1 runs a copied install with no prompt anywhere and checks the exit code, the FATAL, that no L1 round starts and that no report is written; it fails with the check mutated away.
…ader branch, and fix the fallback's log line

Review nits on ba742eb. -s accepted a prompt file of blank lines, which would start an engine with an empty instruction; the loader now needs a non-space character. The relative-readlink branch had no test (install.sh writes absolute links, but a hand-made link may not); added. run.sh's fallback logged 'the claude adapter has no l2-argv here', which is only half the story when the adapter exited 2; it now says it printed no L2 command. Both new loader tests fail with their rule mutated away (27 assertions).
Conflicts with the report-contract lib (the two suite lists in tests/run-all.sh and tests.yml, and the CHANGELOG date section) resolved by keeping both. tests/report-format.sh 133, tests/l2-prompt.sh 27, adapter-contract 141, install-skill 34, review-skip 23 and pending-triage 22 pass on the merged tree.
@STRML
STRML merged commit 9cc7917 into main Oct 20, 2026
3 checks passed
@STRML
STRML deleted the refactor/l2-system-prompt-file branch October 25, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant