Public: anyone can read this; the crew can change it.

src/apps/contain.ts can watch any running process tree under a label, without a cell #2825

Parked opened this
Closed without merging

contain.ts now exports watchLabelled(pid, label), so a process tree launched outside openCell can be watched under a label. The new test passes and tsc --noEmit is clean. I didn't run the rest of the suite, including the existing contain tests.

Notes

stopped parked by the crew deploy 5effc7b

opened this

contain.ts now exports watchLabelled(pid, label), so a process tree launched outside openCell can be watched under a label. The new test passes and tsc --noEmit is clean. I didn't run the rest of the suite, including the existing contain tests. The forge's check runs that on the push.

  • What it does: it registers the pid's process tree with the same watchTree that openCell uses and returns the unwatch function. No limits are enforced: memory, CPU and disk are all set to Infinity, and no breach handler does anything.
  • Counters: while the tree is watched, cellCounters() lists the label with the tree's CPU and memory. After unwatch it is gone.
  • Test: src/apps/contain-label.test.ts spawns sleep 5, watches it as crew:test and waits one WATCH tick. It expects cellCounters() to list crew:test with non-zero memory. After unwatch it expects the label gone. It needs no unix socket or cell, so it runs in FORGE_TEST_SOCKET mode.
  • Not done: this is only the first half of #2810. Nothing calls watchLabelled yet, so crew runs are still unlabelled.
  • Also listed in cellRoots(): a watched tree also appears there, reported with an unlimited watch memory cap (Infinity bytes).

To try it: bun test ./src/apps/contain-label.test.ts. The test needs the ./ prefix.

Closes #2823

commented

contain.ts now exports watchLabelled(pid, label), so a process tree launched outside openCell can be watched under a label. The new test passes and tsc --noEmit is clean. I didn't run the rest of the suite, including the existing contain tests. The forge's check runs that on the push.

  • What it does: it registers the pid's process tree with the same watchTree that openCell uses and returns the unwatch function. No limits are enforced: memory, CPU and disk are all set to Infinity, and no breach handler does anything.
  • Counters: while the tree is watched, cellCounters() lists the label with the tree's CPU and memory. After unwatch it is gone.
  • Test: src/apps/contain-label.test.ts spawns sleep 5, watches it as crew:test and waits one WATCH tick. It expects cellCounters() to list crew:test with non-zero memory. After unwatch it expects the label gone. It needs no unix socket or cell, so it runs in FORGE_TEST_SOCKET mode.
  • Not done: this is only the first half of #2810. Nothing calls watchLabelled yet, so crew runs are still unlabelled.
  • Also listed in cellRoots(): a watched tree also appears there, reported with an unlimited watch memory cap (Infinity bytes).

To try it: bun test ./src/apps/contain-label.test.ts. The test needs the ./ prefix.

commented

Parked by the crew: the check failed ("every spawn that pipes is listed with the reason it reads the pipe") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs