Concepts

Lifecycle In progress

Starting a process is easy. Stopping one without losing work is the hard part. Clamp's lifecycle model is designed around both.

Status. A synchronous lifecycle prototype (example 05) is in development against fake resources and is not on the main branch yet. The full phase model below is the design; each row says what the prototype covers.

Alive does not mean Ready. Ready does not mean Healthy.

Phases

PhaseWhat happensStatus
CreatedThe application exists structurally. No side effects yet.Planned
ConfiguredConfiguration is resolved from defaults, files, environment and arguments. Missing required configuration fails before any work is accepted.Planned
ComposedModules, capabilities and contributions are assembled. Describe what exists and what is required — no I/O.Prototype
ValidatedThe known composition is checked before external resources open: missing or ambiguous providers, cycles, orphan contributions.Prototype
InitializedExternal resources are prepared — pools, keys, telemetry — in dependency order: providers before the modules that need them.In progress
StartedComponents begin active work. initialize() prepares; start() begins.In progress
ReadyThe process is prepared to accept its intended workload. Never ready if startup or a required health check failed.In progress
RunningNormal execution under supervision.Planned
StoppedReached through the shutdown pipeline below, or through Failed → cleanup from any phase.In progress

Shutdown, in order

Shutdown starts by refusing new work, not by destroying dependencies.

  1. Shutdown requested.
  2. Readiness becomes false; admission closes.
  3. In-flight work drains, bounded by a deadline — consumers first (Worker, then the modules it uses).
  4. Remaining cancellable work is cancelled. Cancellation stops work; it does not undo side effects that already happened.
  5. Participants stop in reverse dependency order — providers last.
  6. Final diagnostics are flushed, within a bound.
  7. Infrastructure closes; the process exits.

What the prototype proves

The lifecycle prototype freezes and validates a Worker projection (Worker → Users → a fake Database capability) before running any lifecycle operation, then derives order from Kernel's resolved requirements. Its eight tests cover:

  • Initialization and startup order derived from dependencies; cleanup in reverse.
  • No readiness after a startup failure or a failed required health check.
  • Cleanup of only the resources that were actually acquired.
  • Cleanup that continues after injected errors.
  • Drain deadlines, optional degradation, programmatic shutdown, and a bounded final flush.

Status keeps started, ready, alive, accepting_work and health as separate values rather than one boolean.

Health vocabulary

SignalQuestion it answers
LivenessIs the process alive?
ReadinessShould new work be sent to this process?
HealthHow is each component doing? Per component, not a single yes or no.