Skip to content

test(pi): drop duplicate tests and assertions on Pi's tables - #403

Merged
eersnington merged 4 commits into
mainfrom
chore/pi-tests-drop-duplicates
Nov 17, 2026
Merged

eersnington merged 4 commits into
mainfrom
chore/pi-tests-drop-duplicates

Conversation

@eersnington

@eersnington eersnington commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Removes tests that other tests already run, and assertions that read Pi Durable's tables. The remaining tests check what a caller sees.

Test Change Covered by
actor.test.ts: a failed commit reopens the harness, and the next prompt is answered removed the watch test after it, which runs the same steps
actor.test.ts: a long retry wait lets the actor sleep, and a scheduled wake finishes the run removed tracing.test.ts, which runs the same 61 s retry. Renamed there to say so.
tracing.test.ts: traceparent in Pi's tables assertion removed the sleeping-retry test, which shows the trace continues
tracing-no-sdk.test.ts: Pi's table rows assertion removed the span assertions
upgrade.test.ts: saved watch rows assertion removed the wake, watch, and answer checks

tests/helpers/pi-tables.ts is removed, because nothing uses it now.


This is part 2 of 6 in a stack:

Nathaneil Flurry and others added 4 commits November 16, 2026 15:45
RivetKit's default crash policy leaves a crashed actor asleep, and
keep-awake only lasts while the process does, so an actor that crashed
mid-run stayed asleep until something called it. While Pi Durable's wake
is active, the actor now keeps a pi.wake scheduled about 15 seconds ahead
and re-arms it every 7.5 seconds, cancelling the previous one. When work
ends the wake is cancelled; a stop with work still active keeps it, so the
actor wakes by itself and Pi resumes the run.

A new test runs the agent in a child process, kills it with its engine
while a tool runs, and checks that the run finishes with no call to the
actor.
A commit that fails while a run is going, with no call in flight, must
reopen Pi Durable at once so the run finishes. In 0.5.7-rc.1 closing the
failed harness asked it for its wake, which it refuses, so the reopen
failed and the run waited for the recovery wake about 15 seconds later.
The new test has a replay-safe tool whose first run commits a document
that storage rejects, and checks that the tool reruns within 10 seconds
and the run ends done. It fails on rc.1's runtime and passes on this
stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pi Durable's host contract asks a host to keep a recovery wakeup armed while
harness.wake() is active. The actor now keeps one pi.wake at the earliest
sleep, and while work is active no later than 15 s ahead. It fires on the live
actor and is armed again, so a crash leaves a wake that resumes the run.

- One scheduled wake replaces the interval and the second recovery wake.
- A call waits until the wake for the work it started is written.
- The crash test kills the child's engine by PID, so it never reuses it.
- Sleep and crash tests make no call before they check the outcome.
- Removes the failed-commit test that the watch test fully covers.
- Removes the sleeping-retry test that the tracing test runs too, and names
  that test after the wake it proves.
- Drops assertions that read Pi's tables or the saved watch rows directly.
  The tests keep their caller-visible checks.
@github-actions

Copy link
Copy Markdown

📟 Pip-Boy · 0738439

📦 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 392.5 MB 392.5 MB 392.5 MB 0 220 (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 31.0 MB 31.0 MB 31.0 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
changes 21s checkout · 17s
zizmor 15s checkout · 9s
footprint 2m57s Run pnpm --dir sandbox-agent install --frozen-lockfile · 1m00s
⏭ native · ${{ matrix.platform }} — skipped
⏭ self-test — skipped
⏭ hygiene — skipped
report 30s checkout · 13s
🔭 Full CI trace for this commit

One OpenTelemetry trace of CI and Pip-Boy for 0738439: 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 07384392edb977b767ae13082a808cc6ddfe6a79

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.

Base automatically changed from fix/pi-recovery-wake to main November 17, 2026 14:07
@eersnington
eersnington merged commit bb6c048 into main Nov 17, 2026
10 checks passed
@eersnington
eersnington deleted the chore/pi-tests-drop-duplicates branch November 17, 2026 14:08
eersnington added a commit that referenced this pull request Nov 17, 2026
The squash merge of #403 added the test "a commit that fails during a run
reopens the harness at once" a second time. The second copy shares the
poisonRuns counter with the first, so it waits for a count that is already
past, and fails.
eersnington added a commit that referenced this pull request Nov 17, 2026
…xt (#398)

* test(pi): remove the failed-commit test that a merge added twice

The squash merge of #403 added the test "a commit that fails during a run
reopens the harness at once" a second time. The second copy shares the
poisonRuns counter with the first, so it waits for a count that is already
past, and fails.

* feat(pi): define tools and hooks like actions, with the actor's context

pi() takes `tools` and `hooks` keyed by name. A tool's
`execute(c, args, api, context)` and every Pi Durable hook, such as
`beforeTool(c, call, api, context)`, get the actor's context first, typed
from the actor's state and vars, so a tool can read `c.key`, read and
write `c.state`, use `c.pi`, and call other actors through `c.client()`.

The harness opens with the actor's context as a context value. Pi derives
every task's context from the one it opens with, so the wrappers find the
actor after a wake and in conversations a tool creates. They are installed
as the `rivet-pi-actor` extension. `registry` is now optional and still
works alongside `tools`.

* fix(pi): keep the tools docs off deprecated c.state, and check tool results

- The docs example stores its data with c.db, since RivetKit 3 deprecates
  c.state.
- The interrupted-tool test calls nothing before the tool reruns, so a call
  cannot resume the run for it.
- The registry-tool test checks the tool's own result, not the scripted reply.
- The tests keep per-generation data in c.vars.

* test(pi): check that tools of two actors see only their own actor

- Two actors prompted at the same time each refund into their own vars
  and ledger.
- Drops the hasPi field, which was always true or never recorded. The
  refund tool still reads c.pi, so a missing harness fails it.
- The docs example creates its table once in onWake.

---------

Co-authored-by: Sree Narayanan <sreeaadhi07@gmail.com>
Co-authored-by: Nathaneil Flurry <nathan@rivet.gg>
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.

2 participants