Files
w3cjandClaude Opus 5.5 2de3e31a6c fix(vm): devvm ports shows a status line as it restarts a running VM's forwarder, and every lock's wait is tested for its label
Lock waits:
- Tests record the label of each lock's wait that had none, the lock held
  as by another devvm and the wait ended by a cancel, a deadline failing
  one that shows nothing rather than hanging: git_lock_waiting
  (TestGitLockWaits; .git protection's Serial is gitSerial, so a test can
  reach it), packages_waiting and rebuilds_waiting (TestImageLocksWait),
  ubuntu_pin_waiting (TestPinOriginWaits), custom_secrets_waiting
  (TestYoursLockWaits) and forwarder_waiting (TestForwardsLockWaits).
- A test build's locks panic on a nil platform.Waiting
  (platform.CheckWaiting, which the root's run calls in every test build
  beside state.CheckLockOrder), so the CLI tests and e2e catch a nil wait
  the structure test can't see, such as a zero agentlogin.File's; a
  msg.Waiting given a nil status shows nothing and stays review only.
  msg.Waiting with no status gives a wait that shows nothing, never nil;
  platform.NoWait is the Waiting of a lock that never waits (the build
  port's record, which passed nil), and the status-lines rule holds it to
  statusSites as it does nil (TestCheckWaiting, TestWaiting, the rule's
  NoWait case).
- forbidigo refuses syscall.Flock and unix.Flock outside internal/platform,
  internal/proxy/rotate.go, the stubs and tests (testdata/lint, both).
- TestLockFileWaiting runs in a synctest bubble and checks the wait shows
  while held, not before (its counters under a mutex, which the race
  detector needs, as only the file's lock orders them).

Status lines:
- TestCommandStatusLines runs the setters too: devvm ports LIST and ports
  add, size --cpus, network open, allowlist, transparent off and on, learn
  and allow, git-protect off and on, ssh-agent off. It found devvm ports on
  a running VM starting its forwarder again (ssh and a command in the VM)
  with no status line; that step now shows ports_restarting.

The folder named twice:
- vm_folder_unreadable's why was the open's error, the folder's path in
  it; folderUnreadable gives the system's reason alone when the error is
  about the folder itself (TestUnreadableFolder checks the whole message).
- platform.OpenNoLinks and StatFolder return a link on the path as an
  fs.PathError about the folder too (ErrLinkOnPath still matches), so that
  case names it once as well (TestStatFolderUnique).

Docs: Contributing's CLI page (status lines) and structure page, the
codebase-standards guards; CHANGELOG (devvm ports' status line).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 17:04:29 -07:00

34 lines
1.2 KiB
Go

package msg
import "context"
// Waiting is the wait for a lock (platform.Waiting) that shows label on a
// status line of status, a Reporter's Status, while devvm waits for
// another devvm that holds the lock, and never when it's free. A nil
// status, as in a process with no UI, shows nothing, but the wait is
// never nil, which a test build refuses (platform.CheckWaiting).
func Waiting(status func(M) func(), label M) func() func() {
if status == nil {
return func() func() { return func() {} }
}
return func() func() { return status(label) }
}
// statusKey is the context key of the run's status (WithStatus).
type statusKey struct{}
// WithStatus returns ctx carrying status, the run's Reporter's Status,
// which the run's root sets: a package that takes no Reporter, such as
// internal/state for a VM's lock or the layout's, shows its waits for a
// lock through it (StatusOf).
func WithStatus(ctx context.Context, status func(M) func()) context.Context {
return context.WithValue(ctx, statusKey{}, status)
}
// StatusOf is ctx's status (WithStatus), nil for none, as in a process
// with no UI, where Waiting shows nothing.
func StatusOf(ctx context.Context) func(M) func() {
s, _ := ctx.Value(statusKey{}).(func(M) func())
return s
}