Skip to content

ConvergeOp: an executable runbook composite for per-environment convergence #1484

Closed

Description

@lex00

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.md as prose a human executes at 2am.
  • It re-runs chant build and 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:

  1. 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.
  2. Classify. Evaluate rules against the typed symptom record.
  3. Act. Dispatch to a declared op, subject to verb class × lifecycle dial (below). Or report(...) — never act on a hole.
  4. Record. Append one ledger fact and emit one line: converge: drifted=1 remediated=1 gated=1 unobserved=2(no-credentials).
  5. 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 observe environment 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

  • unknown never 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 blame answers "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 report and 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 observe environment is a report generator. Authority comes only from the dial.

Where this lives (implementation sketch)

  • Composite: lexicons/temporal/src/composites/converge-op.ts, alongside apply-op.ts / reconcile-op.ts / watch-op.ts. Returns { op, schedule } like its peers.
  • Symptoms: a small packages/core/src/lifecycle/symptoms.ts joining status.ts, live-diff.ts/change-set.ts, and release-ledger.ts into one typed record. No LexiconPlugin interface 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 to ops.mdx.

Acceptance criteria

  • ConvergeOp composite with when / run / report builders and a typed symptom record
  • Build fails on: unknown op in a rule; mutating op free-running in an observe env; destructive op without a gate; symptom field nothing produces
  • Tick semantics: skip-and-report when a prior remediation is in flight; unknown never 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

  1. Rule evaluation: first-match-wins per symptom family, or evaluate all and dispatch a set? Leaning: all-match across families, first-match within.
  2. 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.
  3. Where do rules live — inline in the *.op.ts as above, or a discovered *.converge.ts beside the runbook they implement? Inline first; discovery is additive later.
  4. Is describeStackStatus + ledger enough symptom surface for v1, or does this eventually want an optional LexiconPlugin.symptoms?()? Leaning: derive-only for v1.
  5. report(...) destinations: log-and-ledger only, or reuse ReconcileOp's onDrift: "pull-request" | "issue" | "report" channels? Reuse seems obviously right.
  6. Ledger record shape: one record per tick with embedded actions, or one per action keyed to the tick?

Activity

  1. added
    area:ops
    enhancement
    on Aug 23, 2026
  2. lex00 commented on Aug 26, 2026

    @lex00
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:opsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions