Skip to content

fix(pi): never run two harnesses on one actor or pile up pi.wake schedules - #422

Merged
eersnington merged 1 commit into
stack/test-pi-engine-rootfrom
stack/fix-pi-host-state
Dec 3, 2026
Merged

eersnington merged 1 commit into
stack/test-pi-engine-rootfrom
stack/fix-pi-host-state

Conversation

@eersnington

Copy link
Copy Markdown
Member

Gives the Pi host one owner for the harness lifecycle: a HostState tagged union that only step(state, event) changes, and a WakeSlot that owns the actor's one pi.wake. Fixes 4 bugs on main, each with an end-to-end test that fails on main.

stateDiagram-v2
    idle --> opening: open
    failed --> opening: open
    opening --> open: opened
    opening --> failed: openFailed
    open --> opening: ended
    open --> draining: stop (sleep)
    open --> closed: stop (destroy)
    draining --> closed: drained
Loading
Bug on main Now
An open step that fails after Harness.open leaves a second harness on the actor's SQLite The failed open closes its harness first
Each wake and sleep adds a pi.wake row The slot adopts the earliest row and cancels the rest
A storage failure during a drain leaves a reopened harness running after the sleep Only open and draining hold a harness
Work that onSleep starts gets no wake The sleep keeps a wake for it
  • A new wake is written before the old one is cancelled, so a failed write keeps the old wake. The sleep wake is the earlier of Pi's at and the 15 s recovery wake.
  • A commit that lands while the harness closes counts as active work, so it keeps a wake.
  • An illegal transition throws IllegalHostTransition. No public API changes.

This is part 2 of 10 in a stack:

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

📟 Pip-Boy · 4f241fb

📦 Packages · fresh npm install resolve, no lockfile · this PR vs base

No notable install size, dependency, or entrypoint changes across 10 packages.

All 10 packages · linux-x64-gnu
package (linux-x64-gnu) @latest base this PR Δ vs base packages
@rivet-dev/pi 405.8 MB 405.8 MB 405.9 MB +31.4 KB (+0.0%) 227 (0)
@rivet-dev/sandbox-adapter 114.5 KB 114.5 KB 114.5 KB 0 1 (0)
@sandbox-agent/cli-shared 27.2 KB 27.2 KB 27.2 KB 0 1 (0)
@sandbox-agent/persist-indexeddb 12.4 KB 12.4 KB 12.4 KB 0 1 (0)
@sandbox-agent/persist-postgres 12.3 KB 12.3 KB 12.3 KB 0 1 (0)
@sandbox-agent/persist-rivet 12.2 KB 12.2 KB 12.2 KB 0 1 (0)
@sandbox-agent/persist-sqlite 12.3 KB 12.3 KB 12.3 KB 0 1 (0)
@sandbox-agent/react 41.6 MB 41.9 MB 41.9 MB 0 15 (0)
acp-http-client 6.7 MB 6.7 MB 6.7 MB 0 3 (0)
sandbox-agent 30.9 MB 30.9 MB 30.9 MB 0 8 (0)

🧹 Rust dependencies

Skipped: this PR doesn't change any Rust code or dependencies.

🦀 Binaries

Skipped: this PR doesn't change any Rust code.

⏱ Timing

job wall time slowest step
zizmor 15s checkout · 10s
changes 19s checkout · 16s
footprint 3m53s Run pnpm --dir sandbox-agent install --frozen-lockfile · 1m17s
⏭ hygiene — skipped
⏭ native · ${{ matrix.platform }} — skipped
⏭ self-test — skipped
report 27s checkout · 11s
🔭 Full CI trace for this commit

One OpenTelemetry trace of CI and Pip-Boy for 4f241fb: every job and step, with the sizes above attached. Run after CI finishes.

pnpm install --frozen-lockfile --filter 'pipboy...'
pnpm --filter pipboy pipboy trace --sha 4f241fbf3d22686d55bb41729abcec1da15d523c

Add --otlp <url> to send it to any OTLP/HTTP collector.

Agent instruction: From a rivet-dev/agents checkout, run the commands above, then read the trace file the last command prints. List the slowest jobs and steps and explain where CI time went.

@eersnington
eersnington added this pull request to stack #433 December 3, 2026 19:30
@eersnington
eersnington merged commit 1f98c68 into main Dec 3, 2026
10 checks passed
@eersnington
eersnington deleted the stack/fix-pi-host-state branch December 3, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant