Skip to content

The shell suite times each of its sections and its exit-trap teardown, and prints both in its transcript and in CI's step summary (#77, step 1a) - #261

Merged
brettheap merged 2 commits into
mainfrom
fix/shell-suite-section-timings-77
Oct 19, 2026
Merged

brettheap merged 2 commits into
mainfrom
fix/shell-suite-section-timings-77

Conversation

@brettheap

@brettheap brettheap commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Part of #77 (step 1a only: measure before changing anything).

What was wrong

The Linux tests job runs the shell suite in about 45 minutes (the nightly, run 39097381383: tests 04:31:18Z to 05:16:39Z, 45m21s). The only breakdown anyone has is lane 1's one instrumented run on WSL, in #77's comments: 56% of the wall in the exit trap's rm -rf "$SANDBOX", and 57% of the rest in two sections (Amendment 18 Addendum 1 657 s, lanes 182 s). That run was under contention on one workstation, and nothing about a CI runner's own split has ever been printed:

  • tests/test_lane_helpers_suite.py (:191-201) captures the suite's stdout and stderr and prints the transcript only when the suite fails, so a green run says nothing at all;
  • the suite had no clock: its 28 == heading == lines carried no time and its exit trap's rm -rf was not timed.

What changed

tests/test_lane_helpers.sh only. Nothing is skipped and the teardown itself is untouched: the numbers come first.

  • section "== … ==" replaces the 28 bare echo "== … ==" headings. It prints each exactly as echo did and stamps bash's own $SECONDS (no process spawned, bash 3.2 safe), so each section's whole-second wall time is a row. A first row, (preamble, before the first heading), holds everything before the first heading.
  • section_report prints those rows, longest first, with the share of the run and a total, just before the final echo "----". The footer stays the last stdout line (the wrapper looks for passed, 0 failed).
  • cleanup times its rm -rf (the sandbox and $A11T_ROOT together) and says so on stderr, once: the INT and TERM handlers run cleanup and then exit, which runs it again through the EXIT trap, so a flag (TEARDOWN_SAID) is set after the first report. A removal that failed is worded FAILED after N s, so part of it is left behind, not took. (First version guarded on whether the sandbox still existed; see the fix round below.)
  • Where $GITHUB_STEP_SUMMARY is set, both tables are appended to it as Markdown (step_summary). A passing run's stdout and stderr are discarded by the wrapper, so the step summary is where a green run's numbers can be read. A failed append is a note on stderr, never a failed assertion.

Functions and regions edited:

  • tests/test_lane_helpers.sh: new section_close, section, step_summary, section_report and teardown_report (a block just above SANDBOX="$(mktemp -d)", near :65-170)
  • tests/test_lane_helpers.sh: cleanup (the two rm -rf lines at its foot: the timer, the exit status of both removals, and the once-only report), and teardown_report (takes took or failed)
  • tests/test_lane_helpers.sh: the 28 echo "== … ==" heading lines (one word each, echo to section)
  • tests/test_lane_helpers.sh: two new assertions and one section_report call at the foot, after the liveness assertion and before the final echo "----"

Not touched: tests/test_lane_helpers_suite.py and tests/run.sh. Lane 4's #217 edits the suite near :6495 and :11491-11493; none of the 28 heading lines or the regions above is within those hunks (gh pr diff 217 shows its two hunks in this file at :6261 and :11018 of its base).

Tests, and how fail-before and pass-after were shown

Two assertions at the foot of the suite keep the clock honest:

  1. No heading is spelled with echo in the suite's own source (grep -cE '^[[:space:]]*echo[[:space:]]+["']== ' is 0, so any indent and either quote), so a heading added later with a bare echo cannot silently join the section before it.
  2. By the last heading's start, $SECTION_ROWS holds one row per section "== heading in the file (the preamble's, plus every heading's but the open one's), which also proves none sits in a branch the run skipped.

Local proof, never the full suite, with every LANES_* seam and TMUX unset (env | grep '^LANES_\|^TMUX' printed nothing):

  • A scratch copy built from the REAL file (its preamble up to the fakes, two fake sections of sleep 1 and sleep 2, then the real assertions and the real tail): the table printed 2 s / 1 s / 0 s rows plus a total, the footer 4 passed, 0 failed, 0 skipped, 0 pending was the last stdout line, exit 0, and stderr said teardown: rm -rf of the sandbox took 0 s.
  • GITHUB_STEP_SUMMARY set to a pre-seeded file: both Markdown tables were appended after the earlier line. Pointing it at a directory: exit 0 and a note: could not append … on stderr. A TERM during a section: exit 143 and the teardown reported once, not twice. A failing assertion: exit 1 and the footer still last.
  • Fail-before: against main's file the first assertion's count is 28 (wants 0) and there is no SECTION_ROWS or section_report at all. Mutations on the scratch copy: one heading put back to a bare echo turns assertion 1 red (expected [0], got [1]); section_close made a no-op turns assertion 2 red (expected [2], got [0]).
  • The REAL suite's first section only (the real preamble, fakes and lane-start section, plus the real tail): 59 passed, 0 failed; the table showed 67 s 98% lane-start, 1 s 1% (preamble …), total 68 s, and the step summary got both tables.
  • bash -n tests/test_lane_helpers.sh: ok. tests/test_repo_hygiene.py, tests/test_test_roots.py::test_the_lane_suite_fails_a_missing_manual_by_name and ::test_the_lane_suite_reads_the_manual_only_inside_its_guard, and tests/test_lane_helpers_suite.py::test_the_liveness_fixture_outlives_the_suite_timeout, run under flock with the seams unset: 206 passed.

Fix round (after the independent review, commit d05dc0b)

  1. The once-only guard read whether the sandbox still existed, so a failed rm -rf (a non-writable directory inside the sandbox) under TERM or INT reported twice, and a plain exit said took N s though the removal had failed. Now a flag is set after the first report, the second call still retries the removal and says nothing, and a failed removal is worded FAILED after N s. Proof in a scratch harness built from the real preamble and foot, with a chmod a-w directory holding a file inside the sandbox: against the first commit a TERM printed two took 0 s lines and a plain exit took 0 s; now a plain exit prints one FAILED after 0 s line, TERM prints one, INT prints one (delivered by python, because bash ignores INT sent to a background job), the sandbox is left behind as it should be, and without the locked directory each of those paths prints one took line.
  2. The rows-equal-headings assertion sat above the place a new section naturally goes, so a section added there would be counted in the file and not yet in the clock and turn it red. Both assertions now run at the foot, just before section_report, after the last heading has opened. Mutations re-proved: a bare echo heading gives expected [0], got [1], a disabled section_close gives expected [2], got [0], and a new section added after the last one stays green.
  3. Assertion 1 now also catches an indented echo heading and an echo '== …' heading (proved with an indented, single-quoted one inside an if).

Where the per-section numbers will be

This PR's own CI tests job (and every one after it) writes them to that job's step summary, on the run's Summary page, because a passing run's transcript is discarded. Row precision is one second. The tables can only be read on that Summary page in a browser while logged in to GitHub: there is no REST endpoint for a step summary, and gh run view --log does not carry it.

🤖 Generated with Claude Code

…, and prints both in its transcript and in CI's step summary (#77, step 1a)

Lane 1 measured one run on WSL and put 56% of the wall in the exit trap's rm -rf of the sandbox and 57% of the rest in two sections, but no CI runner's own split was ever printed, and the pytest wrapper prints the suite's transcript only when it fails. A new section helper prints each == heading exactly as echo did and clocks it with SECONDS; section_report prints the rows longest first just before the footer, which stays the last stdout line; cleanup times its rm -rf and says so on stderr. Where GITHUB_STEP_SUMMARY is set both tables are appended there, because a passing run's stdout and stderr are discarded. Two assertions keep a bare echo heading from joining the section before it. Nothing is skipped or changed in the teardown: the numbers come first.

Part of #77.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR adds non-invasive, Bash 3.2-compatible timing instrumentation to all shell-suite sections and exit cleanup, prints the results without disturbing the existing transcript contract, and publishes both reports to the CI step summary for successful runs.

File-Level Changes

Change Details Files
Instrument each shell-suite section with whole-second wall-clock timing while preserving existing heading output and test execution.
  • Added Bash 3.2-compatible section timing using $SECONDS, including a preamble row.
  • Replaced all bare section-heading echoes with the section helper.
  • Added assertions that enforce complete heading instrumentation and row creation.
  • Prints a longest-first timing report before the existing footer.
tests/test_lane_helpers.sh
Measure and report exit-trap sandbox teardown separately without changing cleanup behavior.
  • Timed the combined removal of the auxiliary root and sandbox.
  • Reported teardown duration once only when the sandbox actually existed, avoiding duplicate signal/EXIT reports.
tests/test_lane_helpers.sh
Publish timing data to GitHub Actions step summaries while keeping reporting non-blocking.
  • Appends Markdown section and teardown tables when GITHUB_STEP_SUMMARY is configured.
  • Reports summary-write failures on stderr without affecting assertions or exit status.
  • Keeps stdout's existing final footer line intact for the Python wrapper.
tests/test_lane_helpers.sh

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

…emoval is said to have failed, and its clock check moves to the foot and also catches an indented or single-quoted echo heading (#77, step 1a fix round)

The teardown guard read whether the sandbox still existed, so a rm -rf that failed (a directory inside it that was not writable) reported twice under TERM or INT, and a plain exit said took N s though the removal had failed. cleanup now sets TEARDOWN_SAID after the first report, still retries the removal on the second call without saying anything, and teardown_report words a failed removal as FAILED after N s. The two clock assertions moved from above the guards to just before section_report, because a section added where the next one naturally goes would have been counted in the file and not yet in the clock. The first assertion's pattern now matches an echo heading at any indent and in either quote.

Part of #77.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

brettheap added a commit that referenced this pull request Oct 19, 2026
… cause and both documented rows, so a die that claims nothing was pushed or a fourth die no row documents fails it (#68 item 5) (#259)

Landed on Brett Heap's word "land #259 #260 #261 when green" (2026-10-19), by lane openRepoTools-5. Required Linux CI (guard-launch-mode, tests, tests-no-submodule; run 39171682413) was green on head adb6940 with main 08e7550 in its tree. Main 5e88a2c merged with head adb6940 is tree afe4dc7, which queue run 39248744253 (workflow_dispatch of tests on fb9c0d8) tested whole and green.

Independent review (lane 5, Opus, of 25ae36d): LAND. Fix round 1 (adb6940) took its non-blocking points: the timeout-call reader reads bare and quoted operation words, the exit-3 die pattern takes any spacing, and the anchor wording is exact.

Part of #68

Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 19, 2026
…tead of reading it as no answer, and its window ref is checked as a whole string (#72 item 8, #80 item 4) (#260)

Landed on Brett Heap's word "land #259 #260 #261 when green" (2026-10-19), by lane openRepoTools-5. Required Linux CI (guard-launch-mode, tests, tests-no-submodule; run 39246399617) was green on head c249ba6 with main 9b94a59 in its tree. Main ec4555b merged with head c249ba6 is tree 36a1d17, which queue run 39248750040 (workflow_dispatch of tests on 961fcb7) tested whole and green.

Independent review (lane 5, Opus, of c9d681f): LAND. Fix round 1 (c249ba6) adds the canon-lane read after the three rungs, so a case-twin lane is refused whichever rung found it, and refuses a window ref carrying a newline.

Part of #72
Part of #80

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brettheap
brettheap marked this pull request as ready for review October 19, 2026 13:03
@sourcery-ai

sourcery-ai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 7 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit b707bd7 into main Oct 19, 2026
5 checks passed
brettheap pushed a commit that referenced this pull request Oct 19, 2026
Main now holds lane 4 queue, lane 5 queue (#259 #260 #261) and #246 (55aae16).
The one conflict is tests/test_repo_hygiene.py import block: #262 adds
import sys and #259 adds from collections import namedtuple; both are kept.
The tree is lane3-queue/q1d-228pr1-on-p246c, run 39256880821, green.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap pushed a commit that referenced this pull request Oct 19, 2026
Main moved past this branch's base 5e88a2c: #259, #260, #261 and #246.
#246 touches lanes-edit.sh and docs/README-lanes.md too. The merge is
clean, the lock lines are main's own, and lanes-edit.sh parses under
bash 3.2.57 and 5.2. CI tests the moved main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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