Skip to content

Agent lifecycle: heartbeat, pause/checkpoint, and withdrawal #30

@jeremymanning

Description

@jeremymanning

Description

src/agent/lifecycle.rs contains three TODO items for core agent lifecycle operations:

  1. heartbeat() (line ~134): Send heartbeat to broker/coordinator, receive lease offers
  2. pause() (line ~143): Checkpoint any active sandboxes, notify broker
  3. withdraw() (lines ~176-177): Checkpoint and terminate all active sandboxes, notify broker/coordinator of withdrawal

These are critical for Principle III (Donor Sovereignty) — donors must be able to pause and withdraw at any time with clean state transitions.

Requirements

  • Heartbeat: periodic signal to broker with node state, resource availability, active leases
  • Pause: checkpoint all running sandboxes (SIGSTOP + snapshot), transition to Paused state, stop accepting new leases
  • Withdraw: checkpoint all sandboxes, terminate them, wipe scoped working directory, revoke keypair, notify broker, leave no host state

Success Criteria

  • Heartbeat sends periodic updates to broker and receives lease offers
  • Pause checkpoints active work and transitions agent to Paused state
  • Withdraw fully cleans up: no files, processes, scheduled tasks, or network state remain
  • State transitions follow the AgentState machine (Enrolling→Idle→Working→Paused→Withdrawing)
  • Integration test: agent joins, receives work, pauses, resumes, withdraws cleanly
  • cargo test passes with zero regressions

Testing (Principle V)

  • Run agent on real hardware, submit job, trigger pause, verify checkpoint saved
  • Withdraw and verify zero host residue (scan for files, processes, network listeners)
  • Test rapid pause/resume cycles under load
  • Test withdraw during active job execution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions