Skip to content

refactor(list): derive the Status column width from PositionMask - #3845

Merged
max-sixty merged 3 commits into
mainfrom
nightly/clean-32106850263
Aug 18, 2026
Merged

max-sixty merged 3 commits into
mainfrom
nightly/clean-32106850263

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Nightly sweep finding in src/commands/list/. build_estimated_widths allocated the Status column with a literal 8 plus a comment restating PositionMask::FULL's arithmetic (1+1+1+1+1+1+2), while render_with_mask pads every one of the seven positions to that mask's widths. The two numbers had to agree and nothing made them — widening a position (say USER_MARKER to 3 for a wider marker) would have left the column narrower than the cell it renders. This reads the width off the mask via a new PositionMask::total_width(), and pins the invariant with a test that measures a rendered cell's visible width against it.

The same pass corrects the docs that described a mask nobody builds. PositionMask claimed to track "which status symbol positions are actually used across all items and the maximum width needed for each position", with "a width of 0 means the position is unused"; layout.rs's module doc stated it in most detail (status_width = max(rendered_width_across_all_items), plus a "position mask removes columns for symbols that appear in zero rows" bullet); render_with_mask's own doc repeated it. Nothing measures anything: ::FULL is the only mask constructed, because the column's geometry is chosen at skeleton time before any task result exists and progressive and final renders have to agree on it. All three now say that. The derived Default goes with them — an all-zero mask would silently collapse the cell, and no caller wants one.

No behavior change — total_width() is 8, exactly what the literal was, so no snapshot moves.

Verification
cargo test --bins -- list::layout list::render list::model   # 116 passed
cargo test --test integration -- integration_tests::list     # 128 passed
cargo clippy --bins --lib                                    # clean
cargo fmt --all -- --check                                   # clean

The new test isn't a regression test in the strict sense — there's no wrong behavior today, since both numbers are 8. It's the guard that makes them one number: it fails if FULL's widths and what render_with_mask draws ever diverge from total_width(). The drift it prevents is latent, not live.

The layout hardcoded 8 for the Status column with a comment restating
PositionMask::FULL's arithmetic, so widening a position would have left
the column one character short of what render_with_mask draws. Read the
width off the mask instead, and pin the invariant with a test.

PositionMask's docstring described adaptive per-position measurement that
nothing performs — every construction is ::FULL, because the column's
geometry is fixed at skeleton time. Say that instead, and drop the unused
Default, whose all-zero mask would silently collapse the cell.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Aug 18, 2026

@worktrunk-bot worktrunk-bot 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.

Self-review. The change itself is right — widths.status at build_estimated_widths is the only production assignment for that column, so reading it off FULL.total_width() genuinely makes the two numbers one number, and the new test pins the pad-per-position contract that makes the sum meaningful. Three things to fix, all of which I'm pushing now.

lint is red — cargo fmt reflows the new closure in test_full_mask_total_width_matches_rendered_cell onto one line. Nothing else in the pre-commit run failed (clippy passed).

The stale docstring survives in two more places, one of them in a file this PR edits. The PR corrects PositionMask's docstring for claiming per-position measurement that nothing performs, but layout.rs's module doc says the same thing in more detail, under ## Width Calculation: status_width = max(rendered_width_across_all_items), "the width is calculated by rendering each item's status with the position mask and taking the maximum width", and under "Eliminates wasted space", "position mask removes columns for symbols that appear in zero rows / user marker only takes space when present". None of that happens — the width is fit_header(header, FULL.total_width()), fixed at skeleton time, and every position is always allocated. Leaving it means the file now contradicts itself: a comment eight hundred lines below it, added by this PR, says the column is sized off the mask precisely because nothing measures.

Same claim once more on StatusSymbols::render_with_mask — "the mask provides the maximum width needed for each position across all rows", directly above the function whose invariant this PR is about. Both are outside the diff, so I'm pushing them rather than suggesting inline.

Minor: total_width is pub where its sibling width is pub(crate). No practical difference in a binary crate; matching the sibling is one token.

`cargo fmt` reflows the closure in the width test onto one line — the
`lint` job was red on it.

The stale "measured across rows" model this PR corrects on PositionMask
survived in two more places. layout.rs's own module doc stated it in most
detail — `status_width = max(rendered_width_across_all_items)`, and a
"position mask removes columns for symbols that appear in zero rows"
bullet — which the same file's new comment contradicts. Same claim on
`render_with_mask`, right above the function the invariant is about.

`total_width` drops to `pub(crate)`, matching its sibling `width`.
The module doc still described selective rendering and illustrated it with a
six-column, three-position cell, contradicting the paragraph above it that
says every row allocates every position. Widen the example to the eight
columns PositionMask::FULL actually draws.
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

All three review points are in, across two commits — lint is green again and every required check passes on ce0e94ce7.

  • fmt — cargo fmt reflowed the visible_width closure in test_full_mask_total_width_matches_rendered_cell onto one line.
  • Stale docstrings — layout.rs's ## Width Calculation now states the width as max(header_width, PositionMask::FULL.total_width()) and says it isn't measured across items; the "Eliminates wasted space" bullets are gone; render_with_mask's "maximum width needed for each position across all rows" is corrected.
  • total_width — now pub(crate), matching its sibling width.

One residual of the same defect survived the first pass and is fixed in ce0e94ce7: the ## Unified Position Grid prose still said "selective rendering", and its example illustrated a six-column, three-position cell — directly contradicting the paragraph above it that every row allocates every position. The example now shows the eight columns PositionMask::FULL actually draws.

Verification

Locally on ce0e94ce7: cargo fmt --check, cargo clippy --all-targets, and cargo doc --no-deps --document-private-items are all clean, and the nine status_symbols / md_help unit tests pass.

Example rows were checked against the render path rather than composed by eye — styled_symbols fixes the order (staged +, modified !, untracked ?, worktree state, main state, upstream, user marker) and FULL the widths 1,1,1,1,1,1,2, so each row is eight columns. fit_header is data_width.max(header.width()), which is what makes the max(...) formula in the doc accurate.

Still pending, neither blocking: affected tests (macos, advisory) and the review workflow.

@max-sixty
max-sixty merged commit e07dead into main Aug 18, 2026
36 checks passed
@max-sixty
max-sixty deleted the nightly/clean-32106850263 branch August 18, 2026 20:24
max-sixty added a commit that referenced this pull request Aug 24, 2026
…3897)

The agent tend runs as, `tend-sandbox`, could not reach `cargo-insta`,
`cargo-nextest`, or `pre-commit` — all three of the tools `cargo run --
hook pre-merge --yes` invokes. That command is what `CLAUDE.md` and
`.claude/skills/running-tend/SKILL.md` tell the bot to verify its work
with, and in the sandbox it died at `✗ pre-merge command failed:
pre-commit: exit status: 127`.

Tend derives the sandbox's PATH from the runner's, rewriting a leading
`/home/runner` to `/home/tend-sandbox` and keeping an entry only where
the rewritten directory exists. `useradd -m` seeds the sandbox home from
`/etc/skel`, so a toolchain baked into the runner image has a sibling
there and survives; anything `tend-setup` installs at runtime into the
runner's home has none and is dropped, with nothing logged.
`baptiste0928/cargo-install` forces `--root
$HOME/.cargo-install/<crate>` and `uv tool install` writes to the
runner's `~/.local/bin`, so all three went the second way. `uv` itself
stayed reachable only because `astral-sh/setup-uv` puts it under
`/opt/hostedtoolcache`, a system path the rewrite leaves alone.

`sandbox_setup:` runs as the sandbox user once its PATH is built, with
`~/.local/bin` already first on it. `pre-commit` installs into the
sandbox's own home so uv's shim shebang resolves there; the cargo
binaries are copied from where `tend-setup` already built them, at the
versions pinned there. The closing probe is the assertion —
`sandbox-setup.sh` runs the block under `bash -eo pipefail`, so a tool
that goes missing again fails the job and files a `tend-outage` issue
naming it, rather than degrading quietly.

A fourth tool needed the same treatment by a different route. The gate's
`insta` step runs `--all-features`, which turns on
`shell-integration-tests`; that needs `nu` as much as zsh and fish, and
two tests `.expect()` it outright. `tend-setup` apt-installed only zsh
and fish, so the probe would have cleared the agent to run a gate that
then died on a missing shell. `hustcer/setup-nu` installs under
`/opt/hostedtoolcache`, a system path the derivation carries across
verbatim, so `nu` needs no `sandbox_setup:` line — it just needed
installing. Pinned at 0.115.0, level with `test-setup` and
`dev/codex.sh`; `running-tend`'s weekly pin-bump recipe enumerates the
`setup-nu` call sites, so it gains the fifth.

The remaining `shell-integration-tests` prerequisites — bash, zsh, fish,
pwsh, jq — all resolve from `/usr/bin`, which the derivation keeps, so
they were never affected. The probe deliberately covers only the four
tools `tend-setup` provisions for the agent rather than everything the
gate touches.

The generated `tend-*.yaml` files are `uvx tend@latest init` output
(still 0.1.18); the only change in each is the `sandbox_setup:` block.

#3891 landed mid-review and appended its Nix steps at the same
end-of-file anchor as the nushell step, so this branch carries a merge
resolving that — keeping both, nushell next to the shells it belongs
with. Its Nix comment restated the "system PATH entries carry into the
sandbox verbatim" rule that this PR centralizes in `.github/CLAUDE.md`,
which would have left the rule written three times in one file, so it
now points there and keeps only what's specific to Nix. Every #3891 step
is unchanged.

<details><summary>Evidence, and what it cost</summary>

Sandbox PATH, captured from the agent's own launch env in tend-weekly
run 32630901712:

```
/home/tend-sandbox/.local/bin:/opt/hostedtoolcache/uv/0.12.5/x86_64:/opt/pipx_bin:/home/tend-sandbox/.cargo/bin:/usr/local/.ghcup/bin:/home/tend-sandbox/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
```

`error: no such command: insta` appears in runs 31332910927, 31465475753
and 32436240803; `pre-commit: command not found` in 32662391023. Across
3,057 captured Bash calls the bot never once invoked `cargo nextest`,
and substituted `cargo test` with `INSTA_UPDATE=always` or
`INSTA_FORCE_UPDATE=1` fifteen times — which writes snapshots rather
than checking them, and never runs `--check` or `--unreferenced reject`.

Since 2026-06-18, when #3122 moved the repo to tend 0.1.6 and the agent
first ran sandboxed, 16 of 197 bot PRs pushed a first commit with the
`lint` job red. Over the same window 4 of 350 of the maintainer's own
PRs did. #3845 is the shape: a closure `cargo fmt` wanted on one line,
caught by CI rather than locally.

Verified by simulating the block under `bash -eo pipefail` against a
fake runner home, in both directions: all three tools land on PATH and
it exits 0; remove one and it prints the `::error::` naming it and exits
1. Two things changed after that test — `install -D` is GNU-only, so the
parent directory is created explicitly, and `command -v a b c` exits 0
when any one resolves, so the assertion is a loop rather than a single
call.

</details>

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants