Skip to content

feat(op): labels for discovery, a run ledger for outcomes, Chant::Op (#2118) - #2147

Merged
lex00 merged 3 commits into
mainfrom
feat/2118-op-model-run-ledger
Sep 6, 2026
Merged

lex00 merged 3 commits into
mainfrom
feat/2118-op-model-run-ledger

Conversation

@lex00

@lex00 lex00 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #2118. Sub-issue 2 of #2114. Stacked on #2146 (#2117), which stacks on #2139 and #2137; retarget to main as those merge.

OpConfig loses taskQueue, namespace and searchAttributes. Discovery keys become labels, read by discoverConvergeOps and printed by chant run list. Run outcomes (Phase, Drift, Approver, the outcomeAttribute captures) become facts on a new run ledger, one record per settled run on the chant/lifecycle branch at <env>/runs__<op>.jsonl, and chant operator log interleaves them. The record shape is the one OpRuntimeProvider (#2121) reads back, so the local runtime's status, log and list now survive the process. OpResource becomes Chant::Op in lexicon chant, and chant build writes dist/ops/<name>/op.json from core (formatVersion 2.0) with nothing else generated under dist/ops/.

Two consequences, both commented on #2118: the ledger path uses a runs__ prefix rather than a runs/ directory because writeBlobToPath builds the orphan tree with git mktree over a flat layout; and taking Op entities out of the temporal serializer's partition means chant run --temporal has no generated worker until #2130 deletes that path, which is what the issue asks for and what epic #2116 completes.

Acceptance

  • OpConfig has labels and no taskQueue, namespace, or searchAttributes; the workspace typechecks with the composites and the operator switched to labels.
  • discoverConvergeOps finds a ConvergeOp by labels.Converge and scopes --env by labels.Env; operator.test.ts covers both.
  • run-ledger.ts appends one OpRunRecord per runOpLocally completion (ok, fail, gated) with a test on the same git fixture converge-ledger.test.ts uses. Path is <env>/runs__<op>.jsonl (see above).
  • chant operator log shows run records interleaved with tick records; chant run <op> --json output equals the appended record.
  • op.json is written by core with formatVersion 2.0, labels present, and the three deleted fields absent; the round-trip test is ported.
  • No Temporal::Op string remains in packages/ or lexicons/ outside lexicons/temporal.
  • Repo-wide typecheck and the suite pass.

Gates

  • npx vitest run packages/core lexicons/temporal lexicons/terraform lexicons/github: 507 files passed, 1 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: 4217 findings, 4 below baseline, no regressions.
  • node scripts/check-docs-diataxis.mjs: no failures.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JH1b63nCr6fXETJYMvL4xK

@lex00
lex00 force-pushed the feat/2117-activities-into-core branch from 66ac07f to 6142bcc Compare September 6, 2026 15:39
@lex00
lex00 force-pushed the feat/2118-op-model-run-ledger branch from cd3f6c2 to d666cec Compare September 6, 2026 15:40
@lex00
lex00 force-pushed the feat/2117-activities-into-core branch from 6142bcc to cbcfc5b Compare September 6, 2026 16:00
@lex00
lex00 force-pushed the feat/2118-op-model-run-ledger branch from fd78217 to 1355646 Compare September 6, 2026 16:00
@lex00
lex00 force-pushed the feat/2117-activities-into-core branch from cbcfc5b to e4c5fb5 Compare September 6, 2026 16:35
@lex00
lex00 force-pushed the feat/2118-op-model-run-ledger branch from 1355646 to 9586ab4 Compare September 6, 2026 16:35
@lex00
lex00 changed the base branch from feat/2117-activities-into-core to main September 6, 2026 17:10
lex00 and others added 3 commits September 6, 2026 11:11
…2118)

`OpConfig` carried three fields only a workflow engine reads. `taskQueue` and
`namespace` are gone. `searchAttributes` split by what it was actually doing:

- Discovery keys become `labels: Record<string, string>`. `ConvergeOp` sets
  `Converge` and `Env`, `WatchOp` sets `Watch`, `discoverConvergeOps` reads
  both, and `chant run list` prints them where the task queue used to sit.
- Run outcomes become ledger facts. `packages/core/src/lifecycle/run-ledger.ts`
  appends one `OpRunRecord` per settled run to `<env>/runs__<op>.jsonl` on the
  lifecycle branch, carrying the run id, the start and end instants, the
  status, the Op's labels, every captured `outcomeAttribute`, and each phase's
  per-step verdict. `chant operator log` merges those into its timeline;
  `chant run <op> --json` prints the same record it writes.

The path is `runs__<op>.jsonl`, not `runs/<op>.jsonl`: `writeBlobToPath`
assembles the orphan branch with `git mktree` over a flat `<env>/<file>`
layout, and mktree rejects a slash in an entry name. `__` is the separator
`snapshotKey` already uses for the same reason. Noted on the issue.

The record is the shape #2121's `OpRuntimeProvider` reads back, so it lives in
`packages/core/src/op/runtime.ts` beside the contract rather than in the ledger
module, replacing that issue's placeholder. The built-in local runtime's
`status`, `log` and `list` answer from the ledger — a run started by cron, CI
or another machine is visible, and an answer survives the process — keeping
its in-memory history only as the fallback for a project with no ledger to
read. `start` is where the append happens, the one seam every local run passes
through. `status` is #2119's three-state outcome, `gated` included, and a
gated record names the gate it stopped on.

`OpResource` becomes `("Chant::Op", "chant", {})`. That moves Op entities out
of the temporal partition, so `op-ir.ts` moves to core (taking the activity
contract registry as a parameter, defaulting to empty, so core imports no
lexicon; profiles come from #2117's `ACTIVITY_PROFILES`), `chant build` writes
`dist/ops/<name>/op.json` itself at `formatVersion` 2.0, and Ops are held out
of `partitionByLexicon` the way secret declarations and plan scenarios already
are. `lexicons/temporal/src/op/op-ir.ts` stays as a shim binding this lexicon's
contracts, until epic C deletes it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JH1b63nCr6fXETJYMvL4xK
…on the Op (#2118)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JH1b63nCr6fXETJYMvL4xK
@lex00
lex00 force-pushed the feat/2118-op-model-run-ledger branch from 9586ab4 to fa9338c Compare September 6, 2026 17:11
@lex00
lex00 merged commit 10712d9 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): OpConfig drops taskQueue, namespace and searchAttributes; labels for discovery, a run ledger for outcomes, Chant::Op entity type

1 participant