waitregistry

package
v0.173.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package waitregistry records outstanding delegated waits so that someone other than the waiting process can see them.

A wait that exists only as a background process in one harness's memory has moved the "did anyone remember this?" problem rather than solved it: an agent that correctly delegates its waiting goes quiet, and a quiet session is indistinguishable from a crashed one. The only recourse available to a watching human is to interrupt, which destroys the quiet that delegating the wait exists to create.

This is deliberately not a watch service. It stores no events, delivers nothing, and wakes nobody. It answers one question — what is this session waiting for, since when, and how would it resume — and forgets the answer when the wait ends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAlive added in v0.172.0

func DefaultAlive(pid int) bool

DefaultAlive reports whether a process still exists. It delegates to WB's existing per-platform liveness check rather than reimplementing one: an earlier hand-rolled version used Process.Signal(nil), which always fails Go's signal type assertion, so every live waiter was reported as stale.

It is List's liveness check when Options.Alive is nil. Callers that need a different answer — tests deciding liveness without spawning processes — set Options.Alive instead of replacing this function: liveness is an injected dependency, not mutable package state, so parallel tests never race on it.

func Prune

func Prune(home string, opts Options) (int, error)

Prune removes records whose process is gone and reports how many went. It is separate from List so that seeing a dead waiter is never a side effect of asking what is waiting.

func Register

func Register(home string, record Record) (func(), error)

Register writes the record and returns a function that removes it. The caller defers that function: a wait that ends normally leaves nothing behind, and one that is killed leaves a record List reports as stale.

Types

type Options added in v0.172.0

type Options struct {
	// Alive reports whether a process still exists. Nil defaults to
	// DefaultAlive, the real OS check.
	Alive func(pid int) bool
}

Options configures registry behaviour that differs between production and tests. The zero value is production behaviour.

type Record

type Record struct {
	Schema      int       `json:"schema"`
	ID          string    `json:"id"`
	PID         int       `json:"pid"`
	WBSessionID string    `json:"wb_session_id,omitempty"`
	Kind        string    `json:"kind"`
	Targets     []string  `json:"targets"`
	Until       string    `json:"until"`
	StartedAt   time.Time `json:"started_at"`
	Deadline    time.Time `json:"deadline,omitempty"`
	ResumeArgs  []string  `json:"resume_args,omitempty"`
	// Stale marks a record whose process is gone. It is never persisted; List
	// derives it, because a wait that died without clearing its record is
	// exactly the thing worth seeing.
	Stale bool `json:"stale,omitempty"`

	// Provenance fields (wb#631, SDLC logging-gap analysis 2026-09-18): IDs
	// only, stamped by Register from the environment at zero cost, never a
	// prompt or response body. Additive and omitempty; recordSchema did not
	// need to move for a purely additive field.
	HarnessSessionID string `json:"harness_session_id,omitempty"`
	Harness          string `json:"harness,omitempty"`
	EffortLevel      string `json:"effort_level,omitempty"`
	AgentID          string `json:"agent_id,omitempty"`
	ToolUseID        string `json:"tool_use_id,omitempty"`
	WBVersion        string `json:"wb_version,omitempty"`
}

Record is one outstanding wait. It holds no provider payloads, no credentials, and no prompt text: only what is needed to answer "who is waiting for what, and how does it resume".

func List

func List(home string, opts Options) ([]Record, error)

List reports every recorded wait, newest first, marking as stale any whose process is gone. Listing never deletes: a stale record is evidence, and removing it is an explicit Prune.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL