Skip to content

feat(ops): subscribeChanges, a substrate change signal wakes an operator tick and is never trusted as a fact (#1981) - #2213

Merged
lex00 merged 7 commits into
mainfrom
feat/1981-subscribe-changes
Sep 7, 2026
Merged

lex00 merged 7 commits into
mainfrom
feat/1981-subscribe-changes

Conversation

@lex00

@lex00 lex00 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Closes #1981.

The problem

The operator loop woke on a timer only, so drift on a substrate that can say "something moved" was noticed one interval late. Kubernetes can say it through a watch, and nothing in chant listened.

What this lands

An optional plugin seam, subscribeChanges, that lets a lexicon signal that something moved so the operator wakes early. The signal is a trigger and never a fact: an early wake runs the ordinary observe tick, and nothing from the event is used as an observation. onChange() takes no argument and the gate's signal() takes none either, so no test can construct a diff line from a signal. A test runs one round on a timer and one woken by a fabricated event and asserts the two event lists are byte-identical.

A lexicon without the seam behaves exactly as before. The loop with no subscribers takes an early-return branch that is the old loop verbatim, and the CLI does not load config or build when no configured plugin implements the seam.

Coalescing is a rate limit, not a debounce: a pending signal wakes the sleep no earlier than five seconds after the last round started, signals collapse onto one boolean, and the interval stays the ceiling. A debounce would starve under a busy cluster. A killed watch is reported once and the loop continues on the timer; the next round re-subscribes. A subscription that cannot be established degrades to polling with one line. One AbortController covers all subscriptions, a finally aborts it on any loop exit, and every close() is awaited with allSettled.

The k8s implementation is a watch on the existing client, scoped to the group-versions the project declares, tested against the fake cluster. packages/k8s-client's ResponseContextLike.body gained an optional stream(), the one widening of that seam, because a watch cannot read a response to completion. The operator daemon now runs one build at startup to learn the declared entities that scope a subscription, guarded so a project with no such plugin pays nothing.

Docs

The per-lexicon verdict table from the issue is on the operator guide under a new "Change signals" section, and the lexicon-authoring optional-member table has the row. One deliberate deviation from the issue's table: it named the temporal lexicon, which no longer exists, so the row reads cedar, fountain, render, cpln.

OperatorStack needs no knob: subscriptions come from chant operator itself. If disabling them in-cluster is ever wanted, that is a CLI flag plus a stack field, neither of which exists yet.

Gates

Run alone on the rebased head.

npx vitest run test                    1196 files, 16501 passed, 39 skipped (includes test/no-egress.test.ts, 23 passed)
npx vitest run packages/core packages/k8s-client lexicons/k8s   470 files, 7912 passed
npx vitest run examples/fold-differential.test.ts   112 passed
npx tsc --noEmit                       clean
npx tsx scripts/typecheck.ts           37 known failure(s), no regressions (37 baselined)
npx tsx scripts/check-lexicons.ts      every lexicon 23/23 tier-1, no untracked failures
chant dev check-lexicon lexicons/k8s   23/23 tier 1
node scripts/lint-docs-sentences.mjs   no regressions, 3 below baseline
node scripts/check-docs-diataxis.mjs   clean

No egress catalogue row is needed: the watch reaches the network through the same client seam every existing call uses, and the catalogue's closure check passes.

Read first

packages/k8s-client/src/types.ts for the one seam widening, then collectOperatorSubscribers in packages/core/src/cli/handlers/operator.ts for the startup build and its three guards, then packages/core/src/op/change-signal.ts for the gate.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB

lex00 and others added 7 commits September 7, 2026 10:20
… tick and never becomes a fact (#1981)

The plugin seam gains `subscribeChanges?`, whose `onChange` takes no
arguments, so a substrate's change notification has no channel through
which it could reach a change set, a snapshot row or a diff line. It is a
reason to look again, never evidence of what is there.

`runOperatorForever` gains a second wake source behind a coalescing floor
(`./change-signal.ts`, default 5s): a storm of signals costs one early
round, the timer stays as the ceiling, a failing or dying subscription
degrades to polling with one logged line, and every subscription is closed
and its signal aborted when the loop stops.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
…n 410 Gone (#1981)

`GET <list path>?watch=1&resourceVersion=<rv>&allowWatchBookmarks=true`,
started from a LIST so it opens without a gap. Frame decoding, the
resume-version rule and the stream-to-lines adapter live in ./watch.ts;
the connection lives in the client, where discovery, credentials and the
one request seam already are.

`ResponseContextLike.body` gains an optional `stream()`, which
client-node's own HTTP library already exposes and `send`'s `text()`
cannot substitute for on a response that never completes. A transport
without it falls back to the complete body, which is what a fixture
returning canned NDJSON wants. `fakeWatchStream` in the testing harness
drives all of it without a cluster.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
…d estate (#1981)

One watch per (kind, namespace) the declared entities name, resolved
through the same connector a live read uses, capped at 32 connections so a
large estate refuses rather than opening a partial watch that would go
quiet for whatever was dropped. Every frame is consumed by calling a
no-argument onChange(); nothing a frame carries leaves the module.

The operator guide gains the per-lexicon verdict table, so the absence of a
signal on aws, gcp and azure is a stated position: subscribing there means
deploying infrastructure into the account being observed, which inverts the
property that makes a read-only watch safe to point at production. The
lexicon-authoring member table gains its row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
…tor's gate (#1981)

The k8s subscribeChanges bound the way `chant operator` binds it, driving
the real ChangeSignalGate: a frame on a declared Deployment's watch wakes a
60-second sleep in under a second, against the fake cluster.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
`temporal` is not a lexicon here, and the last `--temporal` bridge went in
#2206, so the row naming it described nothing. The catch-all row now names
cedar, fountain, render and cpln.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
Sixty-two of them across the doc comments, test titles, log lines and the
one authoring-table row this branch wrote. Each becomes a comma, a colon, a
period or a parenthetical; no wording changes beyond the joins.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
@lex00
lex00 merged commit c21148e into main Sep 7, 2026
6 checks passed
lex00 added a commit that referenced this pull request Sep 7, 2026
…2214)

Peer session dropped findings in #2198, #2203, #2206; this session dropped
findings in #2208, #2210, #2213. Each PR deferred the ratchet so the drops
would not conflict on the same baseline file, per PR #2174's precedent that
the baseline is ratcheted down rather than left slack.


Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
lex00 added a commit that referenced this pull request Oct 27, 2026
…eside a live root (#4557)

choudoufu stopped refusing a backend or cloud block beside a live
declaration in its #2213: it ignores the block with a warning. TF024 now
says so. A backend block is reported at info: no state is read or
written there, -migrate-state is refused, an apply publishes outputs to
it, and with no record_store the record store is derived from its bucket
(choudoufu#2293). A cloud block, which choudoufu drops entirely, is a
warning. Fixtures cover an explicit record_store and an estate.chdf.hcl
sidecar. Catalog title and remediation, lineage note, lint-rules page,
ops page and the audit-rules row follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

feat(ops): subscribeChanges — wake an operator tick on a substrate change signal, never trust it as a fact

1 participant