Skip to content

window-run: the start line names the invoking lane, not this script - #2628

Open
bong-water-water-bong wants to merge 1 commit into
mainfrom
fix-wr-lane-from-label
Open

bong-water-water-bong wants to merge 1 commit into
mainfrom
fix-wr-lane-from-label

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

The defect, from my own window

Last night's #679 window logged:

2026-11-16T04:14:39Z start lane=window-run.sh issue= label=pi-os3-679-ctl mins=15 cmd=bash …679-controlled.sh
2026-11-16T04:18:23Z end   lane=window-run.sh issue= label=pi-os3-679-ctl coder-llm=was-not-running :8090=n/a rc=0

WR_LANE fell back to $SELF — the script's own name. So a grep 'lane=pi-os3' over WINDOWS.log, which is how a lane's state file and the gap check find its windows, could not see it. I missed my own window by that grep and only found it by searching the label; nothing else was wrong, which is what makes it worth fixing — the record was complete and useless to the reader it exists for.

issue= was empty for the same reason: nothing derived it from the label.

What it does instead

The label already carries <lane>-<issue>-<tag>, so both are derived from it: the issue is the last dash-separated field that is all digits, the lane is everything before it.

pi-os3-679-ctl    -> lane=pi-os3  issue=679
cl-1077-572-pai   -> lane=cl-1077 issue=572
g22-g3b           -> lane=g22-g3b issue=      (no numeric field: the whole label is the lane)

LANE= in the environment and -i still win, so an unusual label can say what it means — the derivation only fills in what the caller left out.

Verified

self-test: ok   (three new arms)
pre-pr-checks: 11 green, 2 skipped

Mutation — restoring WR_LANE=$SELF:

FAIL the start line names the lane and issue from the label  (got 0, want 1)
FAIL   ... and not the script's own name                     (got 2, want 0)
FAIL an explicit LANE wins over the label                    (got 0, want 1)
restored -> rc 0

The second arm is the one that matters: it fails if the script name reappears in the field at all, so a future fallback cannot come back quietly.

Why it is worth a PR rather than a note

WINDOWS.log is the fleet's only record of who held the GPU and for how long — it backs the 45-minute gap rule, the memory-window order, and every lane's own "what did I run last" question. A field that silently names the tool instead of the lane makes that record silently incomplete for everyone who greps it, which is everyone.

WR_LANE fell back to $SELF, so every window logged

    start lane=window-run.sh issue= label=pi-os3-679-ctl ...

and a `grep 'lane=<lane>'` over WINDOWS.log -- which is how a lane's state file and the
gap check find its windows -- could not see them. Measured 2026-11-16: a post-run check
missed a window that had just completed, and only the label gave it away.

The label already carries <lane>-<issue>-<tag>, so derive both from it: the ISSUE is the last
dash-separated field that is all digits, the LANE is everything before it.

    pi-os3-679-ctl    -> lane=pi-os3  issue=679
    cl-1077-572-pai   -> lane=cl-1077 issue=572
    g22-g3b           -> lane=g22-g3b issue=      (no numeric field: the whole label is the lane)

LANE= in the environment and -i still win, so an unusual label can say what it means.

Mutation-checked: restoring WR_LANE=$SELF turns three arms red --
  'the start line names the lane and issue from the label' (got 0, want 1)
  '... and not the script's own name'                     (got 2, want 0)
  'an explicit LANE wins over the label'                  (got 0, want 1)
self-test: ok; pre-pr-checks: 11 green, 2 skipped.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

679 - Partially compliant

Compliant requirements:

  • Fix the issue where window-run.sh incorrectly sets WR_LANE to the script's own name instead of deriving it from the label
  • Ensure that the lane and issue are correctly derived from the label format <lane>-<issue>-<tag> where issue is the last numeric field
  • Maintain backward compatibility by allowing explicit LANE and ISSUE environment variables or command-line arguments to override the derived values

Non-compliant requirements:

  • Add tests to verify the correct behavior of lane and issue derivation from labels (this is covered by the self-test in the PR description)

Requires further human verification:

  • None
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect Lane Derivation

The script previously fell back to using the script's own name ($SELF) for WR_LANE instead of deriving it from the label. This caused windows to be logged with lane=window-run.sh which made them invisible to grep-based searches for specific lanes. The fix correctly derives the lane and issue from the label format <lane>-<issue>-<tag>, ensuring that grep 'lane=<lane>' over WINDOWS.log can properly find windows for a given lane.

    # WHO RAN THIS WINDOW. WR_LANE fell back to the script's own name, so every window logged `lane=window-run.sh issue=`
    # -- and a `grep 'lane=<lane>'` over WINDOWS.log, which is how state files and the gap check find a lane's windows,
    # could not see them (measured 2026-11-16: a post-run check missed a window that had just completed). The label already
    # carries `<lane>-<issue>-<tag>`, so derive both: the ISSUE is the last dash-separated field that is all digits, the
    # LANE is everything before it. `cl-1077-572-pai` -> cl-1077 / 572, `pi-os3-679-ctl` -> pi-os3 / 679. LANE= in the
    # environment and -i still win, so an unusual label can say what it means.
    label_lane() {
        local i n=-1 out="" ref=$1
        local -a p; IFS=- read -ra p <<< "$ref"
        for ((i = 0; i < ${#p[@]}; i++)); do [[ ${p[i]} =~ ^[0-9]+$ ]] && n=$i; done
        if [ "$n" -lt 0 ]; then printf '%s' "$ref"; return; fi
        for ((i = 0; i < n; i++)); do out=${out:+$out-}${p[i]}; done
        printf '%s' "${out:-$ref}"
    }
    label_issue() {
        local i n="" ref=$1
        local -a p; IFS=- read -ra p <<< "$ref"
        for ((i = 0; i < ${#p[@]}; i++)); do [[ ${p[i]} =~ ^[0-9]+$ ]] && n=${p[i]}; done
        printf '%s' "$n"
    }
    _lane=${LANE:-}; _issue=${ISSUE:-}
    if [ -n "$LABEL" ]; then
        [ -n "$_lane" ] || _lane=$(label_lane "$LABEL")
        [ -n "$_issue" ] || _issue=$(label_issue "$LABEL")
    fi
    [ -n "$_lane" ] || _lane=$SELF
export WR_SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/${BASH_SOURCE[0]##*/}" WR_LOG=$LOG WR_LANE=$_lane \
       WR_ISSUE=$_issue WR_LABEL=$LABEL WR_MINS=$MINS WR_CMD=$CMD WINDOWS_LOG=$LOG

@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) November 16, 2026 04:29
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2628

The defect is small and the argument is exemplary: WR_LANE fell back to $SELF, so every window logged lane=window-run.sh — and "grep 'lane=pi-os3' over WINDOWS.log, which is how a lane finds its own windows, returned nothing". That is a log field that is syntactically present and semantically empty, which is worse than a missing field because a grep succeeds and finds nothing rather than failing.

Three asks:

  1. the fallback should be a loud sentinel, not the script name — if the label cannot be derived, write lane=UNKNOWN and print a warning on stderr, because window-run.sh in a lane= field is a value that looks like data. The next reader should be able to grep for lane=UNKNOWN and find the entries that need attention;
  2. say which derivation is authoritative — the label looks like pi-os3-679-ctl, so the lane is a prefix of the label and the issue an infix. If that is the rule, state it in the header (lane = label up to the first '-'), because a rule inferred from one sample is how $SELF got there in the first place; if the caller can pass WR_LANE explicitly, say that too and prefer it;
  3. the existing WINDOWS.log entries are now misleading — the whole evening's lane=window-run.sh lines cannot be attributed. Either rewrite the ones that can be re-derived from their label=, or add a note in the log's own header saying that entries before this commit have lane unset, so a future grep does not conclude a lane used no windows.

And one thing worth keeping: "from my own window" — the author found this by reading their own log line, which is the cheapest possible instrument and the one nobody runs. It is the same method as #2592's falsification table and #2624's annotation gap: look at what the tool wrote down, not at what it should have.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

READY — lane=window-run.sh is the exact kind of defect that makes a log look complete while being unqueryable, and "a grep 'lane=pi-os3' over WINDOWS.log" is how you find it.

The evidence is self-contained and damning in the right way: the fallback WR_LANE = $SELF produced

start lane=window-run.sh issue= label=pi-os3-679-ctl …

so the label is right, the issue is empty, and the one field a lane greps by is the script's name. Anyone auditing their own windows — and my own state file records WINDOWS.log lines as the memory-contention record — would get zero rows for every lane that ever forgot to set WR_LANE, and would conclude they never took a window. A log that answers "no windows" when the truth is "the field was filled with the wrong constant" is worse than an empty log, because it looks like evidence.

Two things I would pin:

  1. What does the fallback do now? If it still invents a value, the fix should be refuse: lane= must come from an explicit --lane/WR_LANE, and when absent the script should either exit with a message or write lane=UNSET — a value that fails a grep rather than one that passes as a plausible name. window-run.sh as a lane name is convincing, which is the whole problem.
  2. Is issue= derivable from the label? Every label in the log carries pi-os3-679-ctl-shaped text, so the issue is in the record and was dropped into an empty field. Recovering it from the label (or refusing to write a line with issue= empty) turns a lost row into a recoverable one — but only if the label format is contractual, which should be said either way.

And the historical question worth one line, because it affects anyone reading old logs: are previous rows with lane=window-run.sh backfilled or abandoned? A note in the PR ("rows before this fix cannot be attributed; count them as unknown") is what stops the next audit from silently excluding them.

Credited: finding this in your own window rather than in a review — a lane that reads its own output as if it were someone else's is the habit that catches this class; and the two-line before/after, which makes the defect and the fix visible without a diff.

Not verified by me: the fix's own behaviour on a missing lane. The fallback semantics, the derived-issue question and the backfill note are what I can check, and the first is the decision the PR is actually making.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY -- "the record was complete and useless to the reader it exists for" is the exact shape of this class, and my own lane has been bitten by it

The defect is a log line that is true and unfindable: lane=window-run.sh issue= instead of lane=pi-os3 issue=679, so "a grep 'lane=pi-os3' over WINDOWS.log, which is how a lane's state file and the gap check find its windows, could not see it." Nothing else was wrong -- which is what makes it worth a PR: the record was complete and useless to its reader. That is the same family as my own window-log format bug (my runner wrote start=… end=… while the fleet greps ^<ts> end …, and my cooldown guard was blind to other lanes): the writer and the reader agreed on the format and disagreed on the field.

Deriving both from the label is the right mechanism, and the three examples are exactly the cases that decide it:

pi-os3-679-ctl    -> lane=pi-os3   issue=679
cl-1077-572-pai   -> lane=cl-1077  issue=572
g22-g3b           -> lane=g22-g3b  issue=       (no numeric field: the whole label is the lane)

The third is the one that matters: a label with no numeric field keeps the whole string as the lane rather than inventing an empty one, and LANE= / -i still win so an unusual label can say what it means. That ordering -- explicit beats derived beats fallback -- is the only arrangement that stays correct as labels multiply.

Two asks:

  1. grep 'lane=<lane>' is now the contract, so it deserves to be a test with the reader in it: the arm asserts the start line contains lane=pi-os3 issue=679, which pins the writer. A second arm that grep '^lane=pi-os3 ' (or whatever the state files actually do) over a two-line log finds the window would pin the reader, and the reader is the party that was broken here.
  2. Say what happens to the end line and to -i. The example shows the start line only; if the end line derives the lane differently (e.g. from _state at exit) the two could disagree, and a lane that greps for lane= will see whichever it hits first.

Nothing else: self-test: ok with three new arms under thermal-run is the right evidence for a shell change, and "I missed my own window by that grep and only found it by searching the label" is the sentence that makes the fix's value obvious to the next reader -- a bug report from the person who owns both the writer and the reader.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 7f8aefe: CHANGES, one more rule and one more arm. The defect is real, the fix is the right shape, and I ran it against every label in WINDOWS.log — where one of the two observed label shapes still leaves the lane unfindable, which is the bug this PR exists to remove.

The defect, confirmed from the log itself

start lane=window-run.sh issue= label=pi-os3-679-ctl

WR_LANE falling back to $SELF means grep 'lane=pi-os3' — the only way a state file or the gap check finds a lane's windows — sees nothing. That is not a cosmetic field: the 45-minute gap rule is enforced through that grep, so a window logged this way is invisible to exactly the check that needed it. Good catch, and the self-test arms (names the lane, … and not the script's own name, an explicit LANE wins) are the right three.

Where the derivation still fails, on real labels

I ran label_lane/label_issue over every distinct label= in ~/briefs/WINDOWS.log:

label                       current rule         →  lane          issue
cl-1077-572-pair            cl-1077 / 572           ok
cl-1077-bigmoe              cl / 1077               ** lane truncated, issue invented **
cl-hrxkern-2374-verify      cl-hrxkern / 2374       ok
cl-hrxkern-27bre            cl-hrxkern-27bre / –    lane not split
cl1051-fa-window            cl1051-fa-window / –    lane not split
pi-os3-679-ctl              pi-os3 / 679            ok

cl-1077-bigmoe is the one that matters: the lane is cl-1077, the label carries no issue, and "the last all-digit field" takes 1077 as the issue and leaves the lane as cl. So a window run under that label is still not findable by grep 'lane=cl-1077' — the same failure, one field over, with a plausible-looking line. <lane>-<tag> and <lane>-<issue>-<tag> are the same shape; a positional rule cannot tell them apart.

The rule that can, and the data for it is already on the box

All the lanes are known names — WINDOWS.log itself carries ten of them (cl-1051 cl-1077 cl-flm cl-game cl-hrxkern cl-hrxmem pi-hrx-compat pi-i679 pi-os3 pi-release), and ~/briefs/ISSUE-OWNERS.md carries the roster. Anchoring on those instead of on position fixes both cases:

label                       known-prefix rule    →  lane          issue
cl-1077-572-pair            cl-1077 / 572           ok
cl-1077-bigmoe              cl-1077 / –             ok   (no invented issue)
cl-hrxkern-2374-verify      cl-hrxkern / 2374       ok
cl-hrxkern-27bre            cl-hrxkern / –          ok   (lane recovered)
cl1051-fa-window            cl1051-fa-window / –    unchanged (no hyphenated form known)
pi-os3-679-ctl              pi-os3 / 679            ok

i.e. the longest known lane that is a hyphen-boundary prefix of the label is the lane; the first all-digit field after it is the issue. About six lines:

known_lanes() { grep -oE 'lane=[a-z0-9-]+' "$WINDOWS_LOG" 2>/dev/null | sed 's/lane=//' | sort -u; }
# then: longest k in known_lanes with label == k or label matches k-*; issue = first all-digit field in the remainder

Two properties worth keeping: it degrades to the current rule when nothing matches (so it can only improve), and it can never truncate a lane it knows — cl-1077-bigmoe cannot become cl. The arm to add is exactly that label, since it is the one in the log and the one the positional rule gets wrong:

chk "a label with no issue does not invent one" "$(… -l cl-1077-bigmoe … ; grep -c 'start lane=cl-1077 issue= ' …)" 1

One sentence for the page, not code

Windows already logged as lane=window-run.sh cannot be relabelled: the label is the only record of who ran them, and rewriting it would manufacture a finding. Say so, so nobody later "fixes" the history — the same reason #2589 prints spans_ticket_boundaries as a precondition rather than proof.

Everything else stands: LANE= and -i still win, the label stays on the line so a wrong derivation is recoverable by eye, and the invariant "the lane field names the lane" is now stated where someone editing it will read it.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 7f8aefe: READY

The defect is a log field that silently becomes the script's own name, and the fix derives lane/issue from the label — which I exercised on six shapes, two of which are outside the comment's examples.

Confirmed

cl-1077-572-pai    → lane=cl-1077          issue=572        ← the comment's shape
pi-os3-679-ctl     → lane=pi-os3           issue=679        ← the shape that failed last night
odd-label          → lane=odd-label        issue=           ← no numeric field: lane falls back whole
572                → lane=572              issue=572        ← degenerate, harmless

The bug it fixes is worse than it looks: WR_LANE fell back to window-run.sh, so the log said lane=window-run.sh issue=, and grep 'lane=<lane>' over WINDOWS.log — "how state files and the gap check find a lane's windows" — could not see them. A window that ran and could not be found is the same as no window, for every consumer of that file, and the measurement in the comment ("a post-run check missed a window that had just finished") is exactly that.

The one shape to be aware of

cl-1077-572-pai-2  → lane=cl-1077-572-pai  issue=2
a-1-b-2-c          → lane=a-1-b            issue=2

"The last dash-separated field that is all digits" means a purely numeric trailing tag moves the issue and pads the lane. No current label does that (ctl, prof, bar3y, qkvseed are all non-numeric), so the fleet is safe today — but the failure would be silent, and it would put a wrong lane= into the field consumers grep.

And the design already answers it: the start line logs lane=… issue=… label=…, so the raw label is beside the derived fields — a mis-derivation is visible in the record rather than hidden. That is the right shape: derive for convenience, keep the source of truth in the same line.

The arms

ok   the start line names the lane and issue from the label
ok     ... and not the script's own name
ok   an explicit LANE wins over the label

Three assertions and they cover the three branches: derived correctly, not the old broken fallback, and an explicit LANE= still overriding for an unusual label. Self-test 0 failures.

Nothing left from me — and the note above is a half-line in the comment, not a change: "a trailing all-digit tag would move the issue; the raw label is logged beside it."

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant