Found in review of #78: a rig's tab with declared panes never closes, and stale pane records stay #91

Merged
city-root merged 2 commits from worker/rexcity-o1qc1 into main 2026-11-12 14:20:21 +00:00
Contributor

Closes the findings in rexcity-o1qc1 (from the review of #78): an idle rig tab with declared panes never ended, and a failed read-back after a declared pane opened failed the agent's start.

What changes

prune, which runs at every agent start, now also ends the idle rig tabs: those with no agent record or view of the rig, other than the tab of the start in hand.

  • Closes the panes the city no longer declares (the tab closes with its last pane), so a city that drops [[rig_tab.pane]] loses the tab of a rig that never starts again.
  • Closes the tab of a rig that is no longer in the city. gc rig remove takes the rig's entry from city.toml and its binding from .gc/site.toml and leaves the checkout, so a rig that neither [[rigs]] nor [[rig]] names is gone. Only the names are read. A city directory that is not known, a file that does not parse, or no city.toml keeps the tab.
  • Closes the tab of a rig whose directory is gone (the runtime records the directory the panes opened in, .rig-dirs.<sid>; a tab from an earlier version gets it at the rig's next start).
  • Forgets the records of panes whose tab Rex no longer holds.
  • The declaration is read once per prune, without its warnings: the start in hand reads the same file for its own tab and says what is wrong with it.
  • A failed read of the tab right after a declared pane opens is a warning, not a failed start, in a rig's tab and in the city tab: the agent goes into the tab as last read, less a pane closed to make room for its replacement. Not covered: opening the city tab for the first time still fails when it cannot be read back (there is no tab to go on with).
  • Nothing runs when no agent starts anywhere: no timer closes a tab.

README and the fragment (.changelog/idle-rig-tabs.md) say the same.

Rework of round 1 (review 241 on 385deff)

  • Blocking, removal of a rig: handled as above, with tests; the comment at rigpanes.go no longer claims that removal deletes the directory.
  • Declaration warnings repeated per idle rig: read once, quietly.
  • City tab's read-back: handled, with a test.
  • Stale window after a replaced pane's read-back fails: the closed block is taken out of the window, with a test.

Verification

go vet ./..., GOOS=linux go vet ./..., go test ./... and the changelog check (valid=true) pass. New tests fail without their fix (the replacement one fails with "no such tab"; the warnings one counts two). Placing a pane put back beside existing agents' panes is checked on the fake Rex only; the Operator checks it on the real one when the city declares the pane.

Closes the findings in rexcity-o1qc1 (from the review of #78): an idle rig tab with declared panes never ended, and a failed read-back after a declared pane opened failed the agent's start. ## What changes `prune`, which runs at every agent start, now also ends the idle rig tabs: those with no agent record or view of the rig, other than the tab of the start in hand. - **Closes the panes the city no longer declares** (the tab closes with its last pane), so a city that drops `[[rig_tab.pane]]` loses the tab of a rig that never starts again. - **Closes the tab of a rig that is no longer in the city.** `gc rig remove` takes the rig's entry from `city.toml` and its binding from `.gc/site.toml` and leaves the checkout, so a rig that neither `[[rigs]]` nor `[[rig]]` names is gone. Only the names are read. A city directory that is not known, a file that does not parse, or no `city.toml` keeps the tab. - **Closes the tab of a rig whose directory is gone** (the runtime records the directory the panes opened in, `.rig-dirs.<sid>`; a tab from an earlier version gets it at the rig's next start). - **Forgets the records of panes whose tab Rex no longer holds.** - The declaration is read once per prune, without its warnings: the start in hand reads the same file for its own tab and says what is wrong with it. - A failed read of the tab right after a declared pane opens is a warning, not a failed start, in a rig's tab and in the city tab: the agent goes into the tab as last read, less a pane closed to make room for its replacement. **Not covered:** opening the city tab for the first time still fails when it cannot be read back (there is no tab to go on with). - Nothing runs when no agent starts anywhere: no timer closes a tab. README and the fragment (`.changelog/idle-rig-tabs.md`) say the same. ## Rework of round 1 (review 241 on 385deff) - Blocking, removal of a rig: handled as above, with tests; the comment at `rigpanes.go` no longer claims that removal deletes the directory. - Declaration warnings repeated per idle rig: read once, quietly. - City tab's read-back: handled, with a test. - Stale window after a replaced pane's read-back fails: the closed block is taken out of the window, with a test. ## Verification `go vet ./...`, `GOOS=linux go vet ./...`, `go test ./...` and the changelog check (`valid=true`) pass. New tests fail without their fix (the replacement one fails with "no such tab"; the warnings one counts two). Placing a pane put back beside existing agents' panes is checked on the fake Rex only; the Operator checks it on the real one when the city declares the pane.
fix: end the idle rig tabs a city no longer wants, and survive a failed read-back (rexcity-o1qc1)
All checks were successful
test / changelog (pull_request) Successful in 5s
image / image (pull_request) Successful in 9s
test / go (pull_request) Successful in 1m44s
385deffbaf
Found in the review of #78: a rig's tab with declared panes outlived its last agent on purpose, but nothing ever ended it, even when the rig was gone or the city had dropped the declaration, and records of panes whose tab Rex lost stayed for good. Separately, a failed read of the tab right after a declared pane opened returned an empty window, so the agent's own start failed with "tab has no pane".

prune, which runs at every agent start, now also ends idle rig tabs (pruneRigTabs): those with no agent record or view of the rig, other than the tab of the start in hand. It closes the panes the city no longer declares (the tab closes with its last pane), closes the tab of a rig whose directory is gone, and forgets the records of panes whose tab Rex no longer holds. The directory is a new record, .rig-dirs.<sid>, written whenever a rig's panes are saved and at every start of the rig, so tabs opened by an earlier version get it at the rig's next start. A declaration that cannot be read, or a directory that cannot be told, keeps the tab, as the start of the rig does. Nothing runs when no agent starts anywhere: the tab is not closed by a timer.

addMissingPanes now returns the last tab it read when the read-back fails, so the rig's start puts its pane in the tab as it was instead of failing.

TestEachRigsTabHoldsItsOwnCopyInItsOwnDirectory asserted that a start in one rig leaves another rig's idle tab alone after the declaration is dropped; that is the behaviour the bead asks to change, so it now drops a pane while the declaration stays and checks the other rig is untouched. New tests cover the dropped declaration, a still-declared pane, a gone directory, an unreadable declaration, the starting rig's own tab, a lost tab's records and the failed read-back (which fails without the fix). go vet and go test ./... pass. The placement of a pane put back beside existing agents' panes is still checked on the fake Rex only; the Operator checks it on the real one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
city-root-review requested changes 2026-11-12 13:50:15 +00:00
Dismissed
city-root-review left a comment

Review of 385deffbaf for rexcity-o1qc1. Checks of the head: success.

Verdict

fail

Findings

  • [blocking] internal/rpp/rigpanes.go:167, :219: the bead's first case, "when a rig is removed from the city", is not handled. The tab only closes when the rig's recorded directory is gone from disk, and the comment at :167 says that is "what a rig removed from the city leaves". That is not true. gc rig remove --help: "Removes the rig entry from city.toml and removes its machine-local path binding from .gc/site.toml". A rig is an external project directory, and its checkout stays. So after gc rig remove kube, kube's tab and its records stay for as long as the city declares [[rig_tab.pane]], which is the case the bead reports. To fix: tell removal from what gc knows. For example, run gc rig list --json with the gc that GC_BIN names in the city directory, or read the rig bindings of the city's .gc/site.toml, which the runtime already reads for workspace_name. Keep the missing-directory check as well. If the bead's owner accepts directory-only detection, the README (README.md:145), the fragment (.changelog/idle-rig-tabs.md:3) and the PR description must say so plainly: a rig removed with gc rig remove keeps its tab until its checkout is deleted or the declaration is dropped. The comment at :167 must be corrected too.
  • [minor] internal/rpp/rigpanes.go:235-236: pruneRigTab calls rigPanesFor for each idle rig, and rigPanesFor reads and validates rexcity.toml again with its warnings. A file with a skipped entry or an unknown key now prints those warnings once more for each idle rig, at every start of any agent. The same goes for a recorded directory that exists but is not a directory, which warns "is not there; the tab ... keeps its panes" at every start. One fix: read the declaration once per prune, or drop the warnings in this path.
  • [minor] internal/rpp/citypanes.go:349: the read-back fix covers only the rig's tab. The bead says the city tab has the same path. There, ensureCityPanes still returns the error, and a failed read-back after a declared pane opens still fails the start of an agent in the city tab (now with Rex's error instead of tab has no pane). The PR description and the README speak only of rig tabs. Either handle the city tab the same way, or state that it is left as it is.
  • [minor] internal/rpp/citypanes.go:428-434: after a failed read-back, the start goes on with the tab as it was before the pane opened. When that pane replaced a pane whose command changed, the old block has already been closed, but the stale window still lists it as a candidate for the agent's split. The Split can then target a closed block and fail the start anyway. This is rare (it needs a replacement and a Rex failure at once). A note or a test would settle it.

Verified

  • Read the work bead rexcity-o1qc1, the PR description, REVIEW.md and README.md of origin/main (no AGENTS.md or CLAUDE.md there), and the whole diff (9 files, +387/-11), with prune, openTab, openPane, rigPanesFor, addMissingPanes, closeUnwantedPanes, saveTracked and Store.Names in context. .rig-dirs.<sid> is not picked up by Names, since it has no .json suffix. SaveRigDir runs under the city lock, which openTab holds.
  • The head merges cleanly into origin/main (65a1054).
  • On the merged tree, with the city's variables removed (proved: 0): go vet ./... passes, as do GOOS=darwin GOARCH=arm64 go vet ./... and GOOS=linux GOARCH=amd64 go vet ./.... go test ./... -count=1 passes in every package. go test -race ./internal/... -count=1: passes in every package.
  • Changelog: built changelog v2.0.1 from the module cache and ran it with -warn missing-fragment on the merged tree. Exit 0, no errors. The fragment holds only a ### Fixed section. A change to internal/ needs a fragment, and it is there.
  • Reverting the addMissingPanes read-back change makes TestAFailedReadBackAfterADeclaredPaneOpensDoesNotFailTheStart fail with tab has no pane, so that test tests the fix. The changed assertion in TestEachRigsTabHoldsItsOwnCopyInItsOwnDirectory follows from the behaviour the bead asks for.
  • Checked gc rig remove --help for what removing a rig leaves on disk.
Review of 385deffbafbf7d58c8cc913b068d232ae83e2f60 for rexcity-o1qc1. Checks of the head: success. ### Verdict fail ### Findings - [blocking] internal/rpp/rigpanes.go:167, :219: the bead's first case, "when a rig is removed from the city", is not handled. The tab only closes when the rig's recorded directory is gone from disk, and the comment at :167 says that is "what a rig removed from the city leaves". That is not true. `gc rig remove --help`: "Removes the rig entry from city.toml and removes its machine-local path binding from .gc/site.toml". A rig is an external project directory, and its checkout stays. So after `gc rig remove kube`, kube's tab and its records stay for as long as the city declares `[[rig_tab.pane]]`, which is the case the bead reports. To fix: tell removal from what gc knows. For example, run `gc rig list --json` with the `gc` that `GC_BIN` names in the city directory, or read the rig bindings of the city's `.gc/site.toml`, which the runtime already reads for `workspace_name`. Keep the missing-directory check as well. If the bead's owner accepts directory-only detection, the README (README.md:145), the fragment (.changelog/idle-rig-tabs.md:3) and the PR description must say so plainly: a rig removed with `gc rig remove` keeps its tab until its checkout is deleted or the declaration is dropped. The comment at :167 must be corrected too. - [minor] internal/rpp/rigpanes.go:235-236: `pruneRigTab` calls `rigPanesFor` for each idle rig, and `rigPanesFor` reads and validates `rexcity.toml` again with its warnings. A file with a skipped entry or an unknown key now prints those warnings once more for each idle rig, at every start of any agent. The same goes for a recorded directory that exists but is not a directory, which warns "is not there; the tab ... keeps its panes" at every start. One fix: read the declaration once per prune, or drop the warnings in this path. - [minor] internal/rpp/citypanes.go:349: the read-back fix covers only the rig's tab. The bead says the city tab has the same path. There, `ensureCityPanes` still returns the error, and a failed read-back after a declared pane opens still fails the start of an agent in the city tab (now with Rex's error instead of `tab has no pane`). The PR description and the README speak only of rig tabs. Either handle the city tab the same way, or state that it is left as it is. - [minor] internal/rpp/citypanes.go:428-434: after a failed read-back, the start goes on with the tab as it was before the pane opened. When that pane replaced a pane whose command changed, the old block has already been closed, but the stale window still lists it as a candidate for the agent's split. The Split can then target a closed block and fail the start anyway. This is rare (it needs a replacement and a Rex failure at once). A note or a test would settle it. ### Verified - Read the work bead rexcity-o1qc1, the PR description, REVIEW.md and README.md of origin/main (no AGENTS.md or CLAUDE.md there), and the whole diff (9 files, +387/-11), with prune, openTab, openPane, rigPanesFor, addMissingPanes, closeUnwantedPanes, saveTracked and Store.Names in context. `.rig-dirs.<sid>` is not picked up by Names, since it has no `.json` suffix. SaveRigDir runs under the city lock, which openTab holds. - The head merges cleanly into origin/main (65a1054). - On the merged tree, with the city's variables removed (proved: 0): `go vet ./...` passes, as do `GOOS=darwin GOARCH=arm64 go vet ./...` and `GOOS=linux GOARCH=amd64 go vet ./...`. `go test ./... -count=1` passes in every package. `go test -race ./internal/... -count=1`: passes in every package. - Changelog: built changelog v2.0.1 from the module cache and ran it with `-warn missing-fragment` on the merged tree. Exit 0, no errors. The fragment holds only a `### Fixed` section. A change to `internal/` needs a fragment, and it is there. - Reverting the `addMissingPanes` read-back change makes `TestAFailedReadBackAfterADeclaredPaneOpensDoesNotFailTheStart` fail with `tab has no pane`, so that test tests the fix. The changed assertion in `TestEachRigsTabHoldsItsOwnCopyInItsOwnDirectory` follows from the behaviour the bead asks for. - Checked `gc rig remove --help` for what removing a rig leaves on disk.
mikluko force-pushed worker/rexcity-o1qc1 from 385deffbaf
All checks were successful
test / changelog (pull_request) Successful in 5s
image / image (pull_request) Successful in 9s
test / go (pull_request) Successful in 1m44s
to ad75baaa9d
All checks were successful
test / changelog (pull_request) Successful in 4s
image / image (pull_request) Successful in 9s
test / go (pull_request) Successful in 1m44s
2026-11-12 13:57:43 +00:00
Compare
city-root-review left a comment

Review of ad75baaa9d for rexcity-o1qc1. Checks of the head: success.

Verdict

pass

Findings

  • [minor] internal/rpp/rigpanes.go:248-250, :270: when the rig is removed or its directory is gone, endRigTab closes the whole window with CloseWindow. In the third case, panes no longer declared, only the declared blocks close, so the tab goes only with its last pane. So a pane the user split into an idle rig's tab by hand is closed along with it. So is the block the runtime itself runs in. prune spares that block (REX_BLOCK, runtime.go:389) and endRigTab does not. Both are unlikely, and the rig is gone anyway. Closing the recorded declared blocks, as the third case does, would leave any other pane alone. Not blocking.

Round 1 (review 241 on 385deff), finding by finding:

  • [blocking] removal of a rig: fixed. rigRemoved (rigpanes.go:278) reads only the names from [[rigs]] of city.toml and [[rig]] of .gc/site.toml. It reports the rig gone only when both files are read and neither names it, so a missing or broken file keeps the tab. The rig is keyed by GC_RIG (tabs.go:34), which is the name gc writes in both files. I checked this against the live city's city.toml and .gc/site.toml, which have the same layout. The missing-directory check stays, using missing(), which counts only ErrNotExist. The comment, README, fragment and description now say that gc rig remove leaves the checkout.
  • [minor] declaration warnings for each idle rig: fixed. The declaration is read once per prune with stderr discarded (pruneRigTabs). TestTheIdleRigsDoNotRepeatTheWarningsOfTheDeclaration counts one warning. A path that is there but is not a directory no longer warns on every start.
  • [minor] the city tab's read-back: fixed with errReadBack in ensureCityPanes, plus a test. The README and the fragment state that opening the city tab for the first time is not covered.
  • [minor] stale window after a replacement: fixed. replaced() takes the closed block out before the read-back, with TestReplaced and TestAFailedReadBackAfterAReplacementLeavesNoClosedBlockInTheTab.

Verified

  • Read the work bead, its round-1 note and review 241, the PR description, and REVIEW.md and README.md of origin/main (there is no AGENTS.md or CLAUDE.md). Read the whole diff: 10 files, +656/-36. Read prune and openTab as merged. pruneRigTabs runs under the city lock that openTab holds. prune reads the windows again after it, so a tab closed there is not acted on twice.
  • The head merges cleanly into origin/main at 369b5a8, which has moved since the branch was cut (merge 25df68b). All checks below ran on the merged tree.
  • Ran everything with the city's variables removed (proved: 0). go vet ./... passes, and so do GOOS=darwin GOARCH=arm64 go vet ./... and GOOS=linux GOARCH=amd64 go vet ./.... go test ./... -count=1 passes in every package, including packs and chart. go test -race ./internal/... -count=1 passes in every package.
  • Changelog: built changelog v2.1.0 (the v2 tag) from the module cache and ran it with -warn missing-fragment. It printed valid=true, exit 0. The fragment holds only ### Fixed, as REVIEW.md asks for a change to internal/.
  • Mutations, each reverted afterwards:
    • rigRemoved always false fails TestAnIdleRigTabEndsWhenTheRigIsRemovedFromTheCityAndItsCheckoutStays.
    • missing always false fails TestAnIdleRigTabEndsWhenTheRigsDirectoryIsGone.
    • rigRemoved true whenever both files parse fails the "still in city.toml" and "still bound in site.toml" cases.
    • Dropping replaced fails the replacement test.
    • Dropping the city tab's errReadBack branch fails TestAFailedReadBackAfterADeclaredPaneOpensDoesNotFailTheCityTabsStart.
  • Not checked: pane placement on the real Rex. As the bead and the description say, the Operator checks that when the city declares the pane.
Review of ad75baaa9d8b47853947955940d46a47c46994b7 for rexcity-o1qc1. Checks of the head: success. ### Verdict pass ### Findings - [minor] internal/rpp/rigpanes.go:248-250, :270: when the rig is removed or its directory is gone, `endRigTab` closes the whole window with `CloseWindow`. In the third case, panes no longer declared, only the declared blocks close, so the tab goes only with its last pane. So a pane the user split into an idle rig's tab by hand is closed along with it. So is the block the runtime itself runs in. `prune` spares that block (`REX_BLOCK`, runtime.go:389) and `endRigTab` does not. Both are unlikely, and the rig is gone anyway. Closing the recorded declared blocks, as the third case does, would leave any other pane alone. Not blocking. Round 1 (review 241 on 385deff), finding by finding: - [blocking] removal of a rig: fixed. `rigRemoved` (rigpanes.go:278) reads only the names from `[[rigs]]` of `city.toml` and `[[rig]]` of `.gc/site.toml`. It reports the rig gone only when both files are read and neither names it, so a missing or broken file keeps the tab. The rig is keyed by `GC_RIG` (tabs.go:34), which is the `name` gc writes in both files. I checked this against the live city's `city.toml` and `.gc/site.toml`, which have the same layout. The missing-directory check stays, using `missing()`, which counts only `ErrNotExist`. The comment, README, fragment and description now say that `gc rig remove` leaves the checkout. - [minor] declaration warnings for each idle rig: fixed. The declaration is read once per prune with stderr discarded (`pruneRigTabs`). `TestTheIdleRigsDoNotRepeatTheWarningsOfTheDeclaration` counts one warning. A path that is there but is not a directory no longer warns on every start. - [minor] the city tab's read-back: fixed with `errReadBack` in `ensureCityPanes`, plus a test. The README and the fragment state that opening the city tab for the first time is not covered. - [minor] stale window after a replacement: fixed. `replaced()` takes the closed block out before the read-back, with `TestReplaced` and `TestAFailedReadBackAfterAReplacementLeavesNoClosedBlockInTheTab`. ### Verified - Read the work bead, its round-1 note and review 241, the PR description, and REVIEW.md and README.md of origin/main (there is no AGENTS.md or CLAUDE.md). Read the whole diff: 10 files, +656/-36. Read `prune` and `openTab` as merged. `pruneRigTabs` runs under the city lock that `openTab` holds. `prune` reads the windows again after it, so a tab closed there is not acted on twice. - The head merges cleanly into origin/main at 369b5a8, which has moved since the branch was cut (merge 25df68b). All checks below ran on the merged tree. - Ran everything with the city's variables removed (proved: 0). `go vet ./...` passes, and so do `GOOS=darwin GOARCH=arm64 go vet ./...` and `GOOS=linux GOARCH=amd64 go vet ./...`. `go test ./... -count=1` passes in every package, including `packs` and `chart`. `go test -race ./internal/... -count=1` passes in every package. - Changelog: built changelog v2.1.0 (the `v2` tag) from the module cache and ran it with `-warn missing-fragment`. It printed `valid=true`, exit 0. The fragment holds only `### Fixed`, as REVIEW.md asks for a change to `internal/`. - Mutations, each reverted afterwards: - `rigRemoved` always false fails `TestAnIdleRigTabEndsWhenTheRigIsRemovedFromTheCityAndItsCheckoutStays`. - `missing` always false fails `TestAnIdleRigTabEndsWhenTheRigsDirectoryIsGone`. - `rigRemoved` true whenever both files parse fails the "still in city.toml" and "still bound in site.toml" cases. - Dropping `replaced` fails the replacement test. - Dropping the city tab's `errReadBack` branch fails `TestAFailedReadBackAfterADeclaredPaneOpensDoesNotFailTheCityTabsStart`. - Not checked: pane placement on the real Rex. As the bead and the description say, the Operator checks that when the city declares the pane.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/rexcity!91
No description provided.