Skip to content

refactor: read the report's marker and sentinel in one lib instead of copies in six scripts - #160

Merged
STRML merged 2 commits into
mainfrom
refactor/report-contract-helpers
Oct 20, 2026
Merged

STRML merged 2 commits into
mainfrom
refactor/report-contract-helpers

Conversation

@STRML

@STRML STRML commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Summary

The two contracts a report carries, the open-questions marker (<!-- autodream:open-questions=N -->) and L2's AUTODREAM_REPORT_END sentinel, were read by inline sed, grep and awk copies in six scripts. They are now six helpers in bin/report-format.sh: report_marker_count, report_has_marker, report_has_sentinel, report_body, report_after_sentinel, report_pin_lines. run.sh (7 sites), notify.sh, question-streaks.sh and triage-dream.sh call them.

The refactor changes no behaviour. The strict marker count (a well-formed comment) and the loose presence check (any line with the key) stay different on purpose, now documented in the lib: question-streaks.sh refuses to clear a streak on a malformed marker while run.sh still accepts a truncated report that carries the key.

One idea, from the cleanup pass that produced #158 and #159.

Status

Check Result
tests/report-format.sh 133 assertions. Written first: 110 failed before the helpers existed. Each helper is compared with the code it replaced (kept in the test as reference implementations) over 16 fixtures for output and exit status: CRLF, no trailing newline, two sentinels, an unclosed pin block, a quoted pin block above the sentinel, a missing file and others.
Full tests/run-all.sh on a clean export of cfbad54 2838 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; run.sh unchanged at 20
Subagent review (code-reviewer) on acc9245 no blocking findings. All 8 migrated call sites match the old code in output and exit status, no helper sits inside the L1 worker's single-quoted bash -c, and no function name collides. Its three nits are fixed in cfbad54.

Review follow-ups in cfbad54: notify.sh and question-streaks.sh now say so when report-format.sh is missing (the latter still exits 0 for update, as its header promises); the test requires each caller to call its helper and scans for any grep, sed or awk read of the marker or sentinel outside the lib; the test no longer overrides the cleanup trap that suite_tmp installs, which left an empty temp dir per run.

Open follow-ups

  • test_fanout_stats in tests/run-all.sh fails on any machine outside a US timezone. Its orphan fixture uses 18:05Z, which is the next local day in HKT, so the day-window logic correctly drops it (5 assertions; they pass with TZ=America/New_York). The fixture should use a timestamp that is mid-day in every zone. Not touched here.
  • The sibling change (the L2 system prompt as one file, refactor/l2-system-prompt-file) edits the same CHANGELOG.md date section, so whichever merges second needs a trivial rebase.

Test plan

  • bash tests/report-format.sh
  • tests/run-all.sh on a clean export of the head, TZ=America/New_York
  • Subagent review
  • Merge, then git pull in the install checkout (the installed scripts are symlinks into it)

STRML added 2 commits October 20, 2026 06:58
… copies in six scripts

bin/report-format.sh gains report_marker_count (strict), report_has_marker (loose), report_has_sentinel, report_body, report_after_sentinel and report_pin_lines. notify.sh, question-streaks.sh, triage-dream.sh and run.sh call them instead of keeping their own sed, grep and awk. The strict and loose marker checks stay different on purpose and are now documented as such. run.sh stops at startup if the lib is missing.

tests/report-format.sh compares each helper with the replaced code, kept as a reference implementation, over 16 fixtures for output and exit status (119 assertions), and fails if another script keeps an inline copy. Full suite: 2819 passed, 9 failed = the 4 sandbox-only baseline failures plus 5 in test_fanout_stats, which fail only because the machine timezone is HKT (the fixture's 18:05Z falls on the next local day) and pass with TZ=America/New_York.
… test prove its claims

Review of acc9245: a missing lib would let question-streaks.sh read every report as marker-less and freeze the streaks behind a misleading message (N1); the leftover-copy scan caught only the exact sed and awk spellings and the sources check passed on any mention of the file name (N2); the test's own EXIT trap replaced the one suite_tmp installs and left an empty temp dir per run (N3, the leak issue 63 is about).

notify.sh exits 1 and question-streaks.sh exits 1 (0 for update, as its header promises) with a message naming the lib. The test now requires each caller to call its helper, scans for any grep, sed or awk read of the marker or sentinel outside the lib, and pins both guards. Swept the other suites that use suite_tmp for the same trap override: none.
@STRML
STRML merged commit ebca110 into main Oct 20, 2026
2 checks passed
@STRML
STRML deleted the refactor/report-contract-helpers 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