Skip to content

Sprites runner pool (restart, Astra): shared cap, conservative orphan cleanup, ambiguous restart #3799

Done

Description

@integry

Restart of #3765 (Sprites runner pool). The first attempt, #3795, grew to about 4,600 lines, and its review loop stalled at 6/10 on orphan-cleanup edge cases. Build it fresh from the epic branch with the narrow scope below. You may read #3795 for ideas, but follow THIS spec.

What already exists (do not rebuild it)

packages/core/src/agents/runtime/sprites/spritesProvisioning.ts SpritePool: an in-process idle pool. Each Sprite is provisioned once with a clean checkpoint and reset on release (restart, wipe /tmp, restore checkpoint, then clear the network policy). A Sprite whose reset fails is destroyed, and the pool closes on worker shutdown. Extend it.

Scope (only this)

  1. Shared cap across workers. A Redis-backed counter and lease limit the number of Sprites that exist at once to PROPR_SPRITES_MAX (default 2; document that the Free plan allows 3). It counts every Sprite this deployment created that has not been confirmed deleted. Each lease has a TTL that its worker renews; a worker that crashes loses its leases when they expire. When the cap is reached, the run waits in admission or the queue with a clear "waiting for a Sprite" status and does not fail.
  2. Conservative orphan cleanup. Name or tag every Sprite with a deployment marker (for example propr-<deploymentId>-<uuid>). At worker start and every N minutes, list Sprites with this deployment's marker that have no live lease and are older than PROPR_SPRITES_ORPHAN_AGE (default 30 min), and delete them. Never touch Sprites without this marker. Before deleting, release any cap slot whose Sprite is confirmed gone. No result-recovery logic for orphans: an orphan's run already failed.
  3. Ambiguous restart. The Sprites API sometimes answers restart() with restart outcome unknown (seen live on about 2 of 5 releases). Treat that as "maybe": poll until a trivial execFile('true') succeeds (bounded, for example 60 s), then continue the reset. Destroy the Sprite only if it never comes back.
  4. Status. Show the pool (cap, in use, idle, provisioning, orphans deleted) in propr status, the Web UI runtime panel and MCP (existing runtime or status tools). Record restore and provisioning timings in run compute usage.

Out of scope: per-repo warm-clone checkpoints, multi-region, and anything else not listed above.

Acceptance

  • Fake-Sprites and fake-Redis tests:
    • the cap is held across two pools;
    • a crashed worker's lease expires and its slot is freed;
    • an orphan with our marker is deleted only when older than the age limit;
    • foreign Sprites are never touched;
    • an ambiguous restart recovers, and a restart that never comes back leads to destroy;
    • an at-cap run waits instead of failing.
  • About 1,000 lines of non-test code.
  • test/spritesRuntime.live.test.ts still passes. A maintainer will run it before merge.

Activity

  1. propr-dev commented on Nov 25, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using codex agent with gpt-6.2-astra model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-6.2-astra
    • Branch: 3799/gpt-6.2-astra-sprites-runner-pool-resta-20261125-0640-bjh
    • Base Branch: 3758-epic-runtime-abstraction-sc0
    • Worktree: issue-3799-20261125-0640-gpt-6.2-astra-bjh

    🔍 Track Task Execution

  2. integry commented on Nov 25, 2026

    @integry
    OwnerAuthor

    Pitfalls found in the #3795 review. The restart must avoid them by design; please add a test for each.

    1. Never delete a Sprite that may still be running. A lease can expire while its holder is alive, for example after a Redis outage longer than the TTL. So expiry alone must never authorize deletion. Before deleting an "orphan", confirm on the Sprite itself that no run is active (for example, no launcher process and the status file not running). A holder whose heartbeat finds its lease gone must stop the run and report it, not keep executing.
    2. Redis is not the authority on what's live. After a Redis flush or a restart without persistence, a startup inventory that turns every marked Sprite with no record into an orphan would delete live runs. Apply the same on-Sprite liveness check and the age threshold, which counts from the Sprite's own creation time, not from when it was first seen.
    3. An ambiguous create (timeout or 5xx) may still have succeeded. Keep it as a pending slot that counts against the cap until a later listing confirms the Sprite exists or is gone, and let the periodic sweep (not only startup) adopt or delete such late Sprites.
    4. Heartbeat each reap claim while reaping several orphans in sequence, or make reaping claimless and idempotent (deleting a missing Sprite is a no-op).
    5. Queueing time does not eat the run timeout. The agent timeout starts once a Sprite is acquired, and queueing has its own bound with a clear "no Sprite available" error.
    6. Count provisioning, restore and queue time in compute wall time. They are billed on Sprites.
    7. WATCH retries: use jittered backoff, and don't rewrite waiter records on every poll.
    8. Do not commit test leftovers (.propr/* TAP output or SQLite files). Make sure tests write to an ignored temp dir.
  3. integry commented on Nov 25, 2026

    @integry
    OwnerAuthor

    Done via #3800 (Sprites runner pool restart), merged into the epic after live verification on real Sprites: orphan cleanup, Redis flush, and the Sprites runtime live test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions