Pre-alpha documentation
Run one durable Agent scheduling quantum.
Bind the Graph Driver, atomic lifecycle coordination, trusted evidence, and tenant-scoped scheduling without weakening fencing or lost-ack recovery.
Assemble one immutable worker deployment
Install all three standard Driver, lifecycle, and cancellation audit
schemas plus every application binding before work can be claimed. DurableTenantScheduler constructs its
DurableAgentLoop internally, so Driver and lifecycle coordination
share one store and one frozen executable registry.
let mut schemas = JsonSchemaRegistryBuilder::with_default_limits();
register_standard_graph_driver_event_schema(&mut schemas)?;
register_standard_graph_lifecycle_event_schema(&mut schemas)?;
register_standard_agent_cancellation_event_schema(&mut schemas)?;
register_application_schemas(&mut schemas)?;
let mut executables = ExecutableGraphRegistryBuilder::new(schemas.build()?);
register_release_graphs_reducers_and_nodes(&mut executables)?;
let scheduler = DurableTenantScheduler::new(
store,
executables.build()?,
Arc::new(application_lifecycle_evidence),
DurableGraphDriverOptions::default(),
DurableGraphLifecycleOptions::default(),
DurableTenantSchedulerOptions::default(),
)?;
The lifecycle audit schema is published at https://stknot.com/schemas/runtime/graph-lifecycle-event/1.0.0. Register it through the runtime helper; do not hard-code its digest.
Cancellation confirmation also requires the public-safe schema at https://stknot.com/schemas/runtime/agent-cancellation-event/1.0.0. Missing it makes lifecycle startup fail closed.
Recover trusted evidence; never invent it
A successful terminal barrier does not own the admitted Agent descriptor,
request, resolved budget, final artifacts, or cumulative usage.
GraphLifecycleEvidenceProvider must recover those existing durable
facts through bounded, deterministic, read-only calls. It must never repeat
model/tool work, infer a request, or replace missing usage with zero.
The lifecycle coordinator validates input and output schemas offline, constructs the final Agent result, and rechecks provenance, request, descriptor, budget, artifacts, and usage before the transaction. An evidence error releases or makes the exact fence reclaimable instead of partially finalizing the run.
Commit each lifecycle edge as one unit
-
Wait
Node code returns complete registration-time-free
NodeWaits. One transaction commits the journal event, result consumption, successor checkpoint, database-time interrupt/timer registrations, Waiting transition, and lease release. -
Successful Terminal
Trusted evidence and schema validation precede one transaction that stores the terminal checkpoint and Agent result, transitions the run, and clears ownership.
-
Blocked failure
Same-fence in-flight work releases ownership for higher-fence crash recovery. Only a plan without in-flight work can enter terminal failure supervision.
-
Confirmed cancellation
The Driver stops new dispatch and returns an exact cancellation handoff. Lifecycle reconstructs cumulative usage and atomically confirms cancellation with database time; unavailable evidence keeps the run cancellation-requested.
The Driver allocates one stable lifecycle event identity per handoff. A lost-ack retry for success, failure, or cancellation accepts only the matching revision-plus-one, terminal status, journal event, and cleared lease. It recovers the committed result, failure, or cancellation usage without rereading external evidence; every other changed terminal snapshot fails as stale.
Wait replay is event-first: the provider verifies the original event, projection, checkpoint, result consumptions, and immutable registrations. It can therefore return that exact idempotent commit after a resolver, timer, or cancellation advances the run, without reverting later state.
Keep tenant scheduling bounded
One tick scans fixed-cutoff keyset pages in durable queue order, allocates one stable claim Attempt ID per candidate, treats ordinary contention as a skip, and executes at most one run. Page count, decoded candidates, contention, and retries are all bounded and reported.
-
Executed - One run was claimed and reached Waiting, Succeeded, Failed, RecoveryReleased, Deferred, Yielded, or Cancelled through the bounded Agent Loop.
-
ExecutionFailed - A run-local Driver or lifecycle error occurred. Exact-fence cleanup was attempted and the worker remains available for later ticks.
-
Idle - The complete fixed-cutoff tenant snapshot contained no claimable run.
-
ScanLimitReached - The configured page ceiling stopped the tick before the stable snapshot ended. Schedule another bounded tick; do not silently widen memory.
-
Cancelled - The process-owned monotonic shutdown signal won before a claim.
Keep isolation beneath global fairness
This worker remains intentionally tenant-scoped. Wrap it through DurableFairScheduler for replica-global smooth weighted selection and an exact reservation-count
starvation bound. Keep storage credentials tenant-scoped; do not widen a worker’s
queue visibility to simulate fairness.
Operate the Worker independently of HTTP ingress
AgentWorkerBinding::tenant and AgentWorkerBinding::fair
exclusively own a concrete scheduler. AgentWorker::start checks
its actual database schema, frozen registry and persisted fair policy, plus
mandatory AgentWorkerReadiness for real host dependencies. Fixed
slots bound concurrency; stale or failed readiness pauses new ticks. Periodic
checks never overlap. No Worker is started by HTTP admission.
Defaults are 4 slots, a 5-minute tick deadline and a 30-second drain.
worker.begin_shutdown() closes admission;
worker.shutdown().await joins ticks and nested Graph node futures,
forcing task cancellation after the graceful deadline. Cancelling
worker.wait() does not lose task ownership. Drop only requests
cleanup; non-yielding callbacks still require an OS supervisor deadline. Shutdown
is not durable Run cancellation and never proves rollback.
worker.health() exposes payload-free local state and counts, not
a public endpoint or durable billing. Hosts must separately operate timer, deadline,
child and failure-close maintenance. PostgreSQL 16/17 tests exercise failure
recovery, bounded concurrency, joined shutdown, fresh-process terminal replay
without repeating a node, and continuous fair-slot sequencing. Follow the assembly and operations guide
and Draft RFC-0013. This is not complete multi-role production qualification or a stable
release.
Own maintenance separately from execution
AgentMaintenanceBinding::new binds 1–128 explicitly authorized,
distinct tenants, the actual store and four frozen audit schemas.
AgentMaintenance::start requires AgentMaintenanceReadiness. One bounded loop rotates through deadline cancellation, child
cancellation and settlement, Join publication, and failure closure. No
model or tool executes inside this role.
Each tenant/job retains its cursor past individual errors, so a failed page cannot starve its tail. Exhausted sweeps and fresh processes revisit failed work. Two replicas rely on durable serialization and idempotency. Defaults are 250 ms normal pacing, 1 s after item errors, a 30 s tick deadline and a 10 s drain deadline. Stale readiness pauses new work; discovery errors, panic and tick deadline fail-stop.
role.health() exposes payload-free counters: Ready does not mean
zero item failures. Protect diagnostics and alert on failures even when dependencies
are ready. role.shutdown().await joins owned work; forced cancellation
never proves transaction rollback. Drop only initiates cleanup. No pool closure,
automatic retention or timer business policy is added.
Read the maintenance operations guide and Draft RFC-0014. PostgreSQL 16/17 qualification includes actual effects, failed-page progress and SIGKILL recovery. Full measured multi-role deployment remains separate; the API remains pre-alpha.
Qualification evidence
CI runs runtime and provider qualification on both PostgreSQL 16 and 17. The runtime cases cover lifecycle atomicity and exact lost-ack replay, database-time Wait materialization, Agent Loop success and evidence failure, tenant and weighted cross-tenant scheduling, durable model/tool attempts and streaming, noninitial replay, lease renewal, duplicate suppression, quarantine, higher-fence takeover, provider-native multi-turn recovery, exact cancellation, and durable run/result reads. Read the complete integration and operations contract before deploying this pre-alpha surface.
Atomic admission, public run/result reads, and provider-native lifecycle evidence are implemented. The embedding application still owns real price tables and trusted artifact evidence; the runtime revalidates committed facts but does not invent missing evidence.