Repository navigation
Description
Summary
chant should be able to run the loop a good operator runs by hand: look at the environment, notice what's off, run the appropriate fix, write down what happened, go back to sleep. This proposes ConvergeOp, a composite that does exactly that on a schedule, driven by a typed rule table — the project's runbook made executable, and checked at build time so it can't rot.
There is deliberately no planner and no new goal language in this. The declaration is already the goal. Observation and the status join already tell us how reality differs from it. Ops are already the fixes. The one missing piece is the table that connects a symptom to a verb, and a scheduled loop to evaluate it.
Problem
chant decides three times, and then stops deciding. At build time the decision model refuses incoherent configurations. At reconcile time the change set classifies per-resource actions. At apply time the op runs its declared phases. Everything that happens between applies — the ongoing operation of an environment — has no home in the model, so in practice it ends up in a justfile and a prose runbook.
fountain-ops (the first downstream project built entirely on chant; it deploys and operates a fountain instance on Kubernetes) shows what that looks like at its best, and it still isn't good:
- Runtime orchestration is sequential bash: kubectl waits, retry loops, check-then-skip idempotence.
- Operational judgment — what a failure means, whether a step is safe to re-run, which remediation follows which symptom — lives in
docs/operations.mdas prose a human executes at 2am. - It re-runs
chant buildand awk-scrapes its own YAML output to recover a decision the seam resolver already made, because there is no runtime surface to ask. - One of its twelve planned ops verbs exists. The sequencing knowledge that would drive the other eleven has nowhere to live.
The fix follows the same instinct as fountain's docs test (a build fails when code reads a config variable the docs don't describe): make the runbook executable, and make it fail the build when it drifts from reality.
Shape
A ConvergeOp composite in the temporal lexicon, peer to WatchOp / ReconcileOp / ApplyOp:
// ops/converge.op.ts — one per environment
const { op, schedule } = ConvergeOp({
name: "fountain-converge",
env: "staging",
every: "10m",
rules: [
when(s => s.status === "drifted", run("fountain-apply")),
when(s => s.backupVerifiedAge > days(7), run("restore-drill")),
when(s => s.stuckConversations > 0, run("quota-reconcile")),
when(s => s.status === "unknown", report("unobserved", s.unobservedReasons)),
],
})Each tick:
- Observe. Tri-state, through the configured lexicons' observation surfaces plus the ledger. No new observation machinery; symptoms are derived from what
status,live-diff,describeStackStatus, and the release ledger already compute. - Classify. Evaluate rules against the typed symptom record.
- Act. Dispatch to a declared op, subject to verb class × lifecycle dial (below). Or
report(...)— never act on a hole. - Record. Append one ledger fact and emit one line:
converge: drifted=1 remediated=1 gated=1 unobserved=2(no-credentials). - Rest. Explicit resting state until the next tick. A quiet environment produces a quiet log.
The rule contract
Rules are typed and build-time checked. What is refused is incoherence:
- A rule that names an op that does not exist fails
chant build. - A rule that would free-run a mutating op in an
observeenvironment fails the build, not the tick. - A rule whose symptom reads a field no lexicon produces fails typecheck.
- A destructive op referenced without a gate fails the build regardless of dial.
Symptom fields come from three sources, all existing: the status join, change-set summaries (counts per ChangeAction), and ledger facts (age of last verified backup, last successful apply, last drill).
Autonomy: verb classes × lifecycle dial
ConvergeOp adds no authority an environment did not already grant. The dial stays per-environment; verb classes generalize delete: "never" | "owned-only" | "gated" upward one level:
| verb class | observe env | reconcile env | apply env |
|---|---|---|---|
| read-only / verification | free-run | free-run | free-run |
| mutating | report only | open PR | run, gated per op |
| destructive | refused | refused | always gated |
Honesty requirements
unknownnever remediates. An unobserved resource is reported with its total reason, same contract as observation (fix(core): observation contract — "not observed" is silently "not present" #1089).- Verification staleness is drift. Verification ops (
restore-drill, smoke tests) append ledger facts with timestamps; a rule may trigger on their age. "A backup nobody has restored is a hypothesis" becomes a symptom, not a README line. - Every remediation traces to a rule in source, every rule to a runbook entry.
git blameanswers "why did it do that." - Flap damping is mandatory, not optional: a rule that fires on N consecutive ticks without its symptom clearing escalates to
reportand stops acting (threshold declared per rule, with a default).
What this is deliberately not
- Not a search-based planner. No preconditions/effects/cost metadata, no A*. Rules-only, because classified states with total taxonomies is how this codebase already thinks. If a rule table ever grows combinatorial — remediations with prerequisites of their own, competing orderings — that is a separate issue, and the state of the art to mine is known (GOAP-family planners, e.g. embabel's, whose kernel is ~1k LOC and cleanly separable). Do not build it before a real rule table demands it.
- Not an event bus or controller runtime. It is a scheduled op like any other, durable under Temporal, one-shot runnable locally for a single tick (
chant run fountain-converge), which is also the test story. - Not autonomous by default. A ConvergeOp in an
observeenvironment is a report generator. Authority comes only from the dial.
Where this lives (implementation sketch)
- Composite:
lexicons/temporal/src/composites/converge-op.ts, alongsideapply-op.ts/reconcile-op.ts/watch-op.ts. Returns{ op, schedule }like its peers. - Symptoms: a small
packages/core/src/lifecycle/symptoms.tsjoiningstatus.ts,live-diff.ts/change-set.ts, andrelease-ledger.tsinto one typed record. NoLexiconPlugininterface change in v1 — derive-only. - Rule validation: ops are discovered declarables (
op/discover.ts), so unknown-op references are checkable at build. Verb class is derived from the referenced op's own config (read-only steps, gates, delete mode). - Flap-damping state: consecutive-fire counts go in the ledger (or the tick record), not process memory, so damping survives worker restarts.
- Docs: one page under
guide/, sibling toops.mdx.
Acceptance criteria
-
ConvergeOpcomposite withwhen/run/reportbuilders and a typed symptom record - Build fails on: unknown op in a rule; mutating op free-running in an
observeenv; destructive op without a gate; symptom field nothing produces - Tick semantics: skip-and-report when a prior remediation is in flight;
unknownnever remediates; one log line and one ledger record per tick - Flap damping with per-rule threshold and a default
- Local one-shot tick via
chant run; durable scheduled form under Temporal - Docs page with the runbook-to-rules framing
- First-consumer proof in fountain-ops: a converge op exercised in its k3d CI against one induced drift and one aged-out verification fact, asserting the log line and ledger records
Open questions
- Rule evaluation: first-match-wins per symptom family, or evaluate all and dispatch a set? Leaning: all-match across families, first-match within.
- Concurrency: what does a tick do when the previous tick's remediation op is still running? Proposal: skip-and-report (
converge: skipped=1(in-flight)), never queue. - Where do rules live — inline in the
*.op.tsas above, or a discovered*.converge.tsbeside the runbook they implement? Inline first; discovery is additive later. - Is
describeStackStatus+ ledger enough symptom surface for v1, or does this eventually want an optionalLexiconPlugin.symptoms?()? Leaning: derive-only for v1. report(...)destinations: log-and-ledger only, or reuseReconcileOp'sonDrift: "pull-request" | "issue" | "report"channels? Reuse seems obviously right.- Ledger record shape: one record per tick with embedded actions, or one per action keyed to the tick?
Activity
fix(ops): ConvergeOp honors the epic's autonomy table — no silent aut…
lex00 commentedon Aug 26, 2026
Landed via #1954: ConvergeOp({name, env, dial, budget, rules, schedule}) — a runbook composite peer to WatchOp/ReconcileOp/ApplyOp whose tick is observe → classify against a data-only rule table (when(predicate, action, {id, why, flapThreshold}) over a derived ConvergeSymptom) → dispatch within a per-tick budget → record to an append-only converge ledger. Honesty properties enforced, not aspirational: unknown never remediates (checked on the classification result), mutating dispatch requires dial "apply" (TMP014 build refusal + a runtime verb-class backstop that downgrades to report, fail-closed on unclassifiable targets — reconcile's "open PR" cell is explicitly not-yet-implemented per the epic's onDrift open question), destructive dispatch is refused outright in v1 (the local dispatch executor cannot honor gates; durable gated dispatch belongs to #1485), adopt-predicated mutating rules are refused, schedules set overlap Skip, and flap damping consults the ledger whose blob writes are now byte-safe after #1936's fix. Observe's diff threads into the tick as a typed step-output reference.
feat(k8s): OperatorStack — the operating loop as a declared estate (#…
feat(ops): chant operator — native durable ticks for ConvergeOp, no T…
feat(ops): ConvergeOp — an executable runbook composite for per-envir…