Skip to content

feat(op): gate-as-fact in the local executor — a gate ends the run pending chant approve (#2119) - #2139

Merged
lex00 merged 4 commits into
mainfrom
feat/2119-gate-as-fact
Sep 6, 2026
Merged

lex00 merged 4 commits into
mainfrom
feat/2119-gate-as-fact

Conversation

@lex00

@lex00 lex00 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #2119. Sub-issue 3 of #2114. Stacked on #2137 (retarget to main once that merges).

A gate is a fact, not a wait. Reaching one, the local executor reads the gate ledger: a resolution newer than the gate's newest pending fact lets the step pass carrying the approver; otherwise the run records a pending fact, ends gated (exit 3), runs no later phase and no onFailure. chant approve <op> <gate> writes the counterpart fact, and the next run walks through. The same decision (packages/core/src/op/gate.ts) drives the component driver, so chant run --components behaves identically. chant approve --expire clears a standing fact; chant operator status lists pending facts for any op.

Merged over #2121's runtime seam by the orchestrator: the progress callback rides RunOpOptions.onRecord, the local runtime maps the three-state result and no longer refuses gates, and chant run exits 3 for a gated run on any runtime.

Acceptance

  • chant run <gated-op> with no resolution ends gated, exit code 3, appends a PendingGateRecord, prints the approve line and expiry, and runs no phase after the gate.
  • chant approve <op> <gate> followed by chant run <op> completes the op; the step record carries the approver and url.
  • A resolution dated before the pending fact is ignored; an expired pending fact is ignored and re-recorded.
  • onFailure phases do not run on gated.
  • chant run --components <name> with a gate behaves the same way; driver.test.ts covers it.
  • LocalGateUnsupportedError and findGate are gone from core and from the op/index.ts barrel; nothing in packages/ prints --temporal as a hint for a gate.
  • chant operator status shows pending facts for a non-converge op; local-executor.test.ts and gate-ledger.test.ts cover the three-state outcome.
  • The operator guide's "Gate-as-fact" section and its caution aside are updated to describe the closed loop.

Gates

  • npx vitest run packages/core lexicons/temporal lexicons/terraform lexicons/fly: 452 files passed, 2 skipped.
  • npx tsx scripts/typecheck.ts: 44 known failures, no regressions.
  • npx tsx scripts/check-lexicons.ts: no untracked tier-1 failures.
  • node scripts/lint-docs-sentences.mjs: 4218 findings, 3 below baseline, no regressions.
  • node scripts/check-docs-diataxis.mjs: no failures.

Note for #2122: TMP014's rationale ("the local executor refuses any gated op outright") is now stale; the port to OPS014 re-argues the refusal.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JH1b63nCr6fXETJYMvL4xK

lex00 and others added 4 commits September 6, 2026 10:04
…nding chant approve (#2119)

A gate was a wait, which meant a runtime that cannot wait had to refuse the
whole op before its first step. It is a fact now. Reaching a `gate`, the
executor reads the gate ledger: a resolution newer than the gate's newest
pending fact lets the step pass and lands the approver on its record;
otherwise the pending fact is recorded and the run ends with status `gated`.
No later phase runs, and no `onFailure` phase runs either — nothing failed, so
there is nothing to compensate for. The next run re-evaluates from the ledger,
so `chant approve <op> <gate>` followed by `chant run <op>` is the whole loop.

- `lifecycle/gate-ledger.ts` gains `PendingGateRecord`, written to the same
  `_gates/<op>.jsonl` as the resolutions and told apart by `kind`. A live
  pending fact is reused rather than re-appended, so an operator ticking every
  minute against an unapproved gate does not grow the ledger by a line a
  minute; past its expiry (the gate's `timeout`, 48h default) it is stale and
  the next run records a fresh one.
- `op/gate.ts` is the one place that decides a gate, shared by the Op executor
  and the component driver so the two cannot drift. Ledger access goes through
  a `GateLedgerPort`, so a test drives the decision without an orphan branch.
- `OpRunResult.ok` becomes a three-state `status: "ok" | "fail" | "gated"`
  with `startedAt` and the pending fact on `gate`. #2118: written to the run
  ledger.
- `renderHuman`/`renderJson` print the gate, its description, the
  `chant approve` line and the expiry; the CLI exits 3 for a gated run so CI
  can tell "waiting on a human" from "broken".
- `LocalGateUnsupportedError`, `findGate` and `DriverGateUnsupportedError` are
  deleted along with the `--temporal` hints they printed. `isGated` walks the
  phases itself; `findPolicyGateStep` stays.
- `chant run --components` behaves identically: a gate stops the component
  pending approval, with no saga unwind and no `rollback` phase.
- `chant approve --expire` clears a standing pending fact without approving it,
  and `chant operator status` lists pending facts from every discovered op, not
  only from a converge tick's `gated` outcomes.
- `convergeTick` reads the gate off `chant run --json`'s exit-3 result instead
  of matching a refusal message, and no longer writes the pending fact the
  executor already wrote.
- COMP004's message says a gate ends the run pending approval rather than
  needing another backend (the rename is #2116).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JH1b63nCr6fXETJYMvL4xK
…eleted ok boolean (#2119)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JH1b63nCr6fXETJYMvL4xK
@lex00
lex00 force-pushed the feat/2119-gate-as-fact branch from 0d3c5ff to 03ae984 Compare September 6, 2026 16:04
@lex00
lex00 merged commit 252bff5 into main Sep 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core(op): gate-as-fact in the local executor — a gate ends the run pending chant approve, and the next run passes it

1 participant