Repository navigation
fix(instances): name the crew that is off and lock every disable - #20895
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The disable path no longer trusts the pre-lock read, but the transport-key comparison on the same line still decides the locked teardown from that read. Not justified as shipped
What this change shipsInventory (6 items) — 5 justifiedIntent: the owner of a crew that is off sees the true labels, gets a refusal that names the crew that is off, and can trust that a disable closes the tunnel. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 6be6f4f Description read[DESCRIPTION-READ] 206300913016ee5f0a116e064b09c73317eafe444039e9ecb57cf39035da1e31 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 6be6f4f Description read[DESCRIPTION-READ] 09518d5b823271556c26b4511e9bc332268dc3d85969fb1034981dbbe3e1bdec That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
|
A chained crew under a disabled parent was refused with "this crew is disabled", while its own switch reads On. The connect 409 carries the manager's own message instead, which names the crew that is off by id. A disable PATCH on a crew the record already shows off skipped the locked teardown. That record is read before the manager lock, so an enable and a connect landing in between could leave a live forward under an Off switch. Every disabled: true goes through reconfigure(); on an idle crew the teardown changes nothing. The Remote Crew page quotes the labels on screen (Connections: On/Off, Off), and the instances spec covers the disabled field, the revive skip, the PATCH field and the 409 instance_disabled. Fixes #18661
29d8004 to
6be6f4f
Compare
|
Rebased: the only test reds on 29d8004 were main's #20893 census failures, now fixed on main by #20902 (6d4f287 -> 99d9aa6); CI re-running.
|
|
chenmingwei23
left a comment
There was a problem hiding this comment.
Approving: readiness: passed, all lanes green, no outstanding change requests.
Problem / Motivation
Goal: A crew's off switch is described with the words on screen, a refused connect names the crew that is off, and every disable closes the crew's tunnel under the manager lock.
Four gaps left after #18451 shipped the per-crew off switch:
409"this crew is disabled; enable it to connect", while that crew's own switch reads On.PATCH {"disabled": true}on a crew the record already shows off writes the flag outside the locked teardown. The route reads that record before it takes the manager lock, so an enable and a connect landing in between leave a live forward under an Off switch.409 instance_disabled.Why it matters
A reader looks for a label the screen does not show. A refused user is pointed at the wrong crew. A retried disable can leave a tunnel open while the switch says it is closed.
Not a goal
What changed (motivation → approach → change)
dashboard/handlers_instances.pyconnect, for a crew riding a disabled crew409"this crew is disabled; enable it to connect"409"crew 'cd-1', which 'kid' rides, is disabled; enable it to connect"dashboard/handlers_instances.pyupdate,disabled: trueon a crew already offreconfigure()teardown as every disabledocs/remote-crew.md(the Remote Crew page)modules/instances.md(the spec)409 instance_disabledA refused connect names the crew that is off.
InstanceDisabledErroralready says which crew, by id, so the connect route answers with that text plus "enable it to connect". Both places that raise it build the text from crew ids only, never a host, user, path or token.Every disable closes the tunnel under the lock. "Already off" is read before the lock, so it can be stale; the route no longer trusts it. On a crew that is off and idle,
reconfigure()changes nothing: no tunnel opens, no record field moves, its intent and its chained crews' intent stay, and other crews keep their forwards.The Remote Crew page and the instances spec describe what the code and the screen do.
Backwards compatibility
Compatible: the
409keeps its status andcode: instance_disabled, and only its humanerrortext changes (no code reads that text). A repeated disable answers the same200body.Removes nothing: no field, route, key or function goes away; the update route runs the locked teardown on more requests, never fewer.
Tests
In
test/test_instances_disable.py, through the realSshTunnelManagerand real handlers (fake tunnel factory):test_connect_route_names_the_crew_that_is_off: a chained crew under a disabled parent gets409 instance_disabledwhoseerrornames the parent's id, keeps "enable it to connect", and carries neither crew's host.test_a_repeated_disable_closes_a_forward_the_record_already_calls_off: a record that says off over a live forward is closed by a repeated disable.test_a_repeated_disable_of_an_idle_crew_opens_and_forgets_nothing: a repeated disable on an idle crew spawns nothing, leaves every record byte-equal (intent and its chained crew's intent kept), and an unrelated crew stays connected.In
test/test_remote_crew_doc.py,test_the_off_switch_labels_the_page_quotes_are_the_ones_on_screenreads the four labels fromen.jsonand requires the section to quote each.Red before, on main
ae5550c070with only the tests applied: three fail, the idle-crew guard passes (it pins behaviour main already has).Green after, with the fix:
25 passedfor both files; the 21 related backend files:1457 passed.Determinism, for the four new tests: 20/20 runs at
-n0; 10/10 at-n 2 --dist loadgroup --max-worker-restart=2besidetest_instances_unsupported_method.pyandtest_instances_connect_during_restart.py(-n 2, not 4, because the host was shared); both files in a shuffled order,seed=21129,25 passed.test_flake_pattern_ratchet.py:56 passed.Manual verification
N/A — unit coverage sufficient: both route changes run through the real handlers and the real tunnel manager, the same harness the off-switch tests already use, and no frontend file changes.
Screenshots / video
N/A — no frontend file changes. The one user-visible change is the
409errortext, quoted before and after in the table above.Related Issues
Fixes #18661
Pattern harvest
Rule candidate: review-prompt
Pattern: a route decides to skip a locked section from a read it made before taking the lock
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)