Watching for drift
Between runs, the engine can watch what a workspace manages and tell your agent when an object changes
outside Turf™. Detection is off until you turn it on, with drift. You read what is open with
status, and wait for what is new with watch. A change is put back by an ordinary run: up, whose
plan can read only what drifted. The plan and its approval point govern every change, as in any run.
The conversation below is shaped on one Deployment the configuration sets to three replicas:
resource "kubernetes_deployment_v1" "web" { metadata { name = "web" } spec { replicas = 3 # … }}watch→unwatched
Nothing watches this workspace between runs: drift detection has never been turned on for it. I can turn it on with a sweep: the engine would read every managed object once a day, unattended, against the provider’s API with its own credentials. Shall I?
drift→configuredwatch→waiting
Drift detection is on, with a sweep of one cycle a day, and I am watching. I will tell you when something drifts.
watch→driftup→awaiting_planplan→awaiting_approvalapply→convergedwatch→waiting
The sweep found one change: kubernetes_deployment_v1.web, class configured, at spec[0].replicas.
I started a run and planned it with only that object read:
~ kubernetes_deployment_v1.web spec.replicas: 5 → 3An in-place update back to what your files say, so I approved it. The other 41 objects planned from their records, unread. I am watching again.
TOOL RESULTwatch→drift
outcome: drift ended: truedrift: counts: { configured: 1 } notices: [ { address: "kubernetes_deployment_v1.web", class: "configured", paths: ["spec[0].replicas"], source: "sweep", new: true } ] coverage: "42 managed: 42 swept (each read within 23h); settle 30s, sweep cycle 24h"cursor: "w2.…"next: { tool: "up", args: { workspace_alias: "default" } }TOOL RESULTup→awaiting_plan
convergence_id: "…" kind: up round: 1next: { tool: "plan", args: { convergence_id: "…" } }note: "… 1 drift notice address(es) that an up can act on are open on this workspace: plan({ convergence_id: "…", refresh_drift: true }) reads only what drifted; next, the plain plan, reads every object."illustrative · the shape of a session, not a transcript
In Claude Code, the prompt is a slash command:
/turf:watch path/to/configIn any client, ask in words: “watch this workspace for drift and put back what changes”. The agent
loads its drift reference, opens the workspace, and loops: watch, and on drift up, plan with
refresh_drift: true, a review of the plan, apply with its digest, then watch again. The run is
an ordinary up: at its plan gate next is the plain plan, and the note names the one that reads
only what drifted.
The first watch returns what is already open. To act only on what drifts from now on, say so: “watch
from now on”.
Ask the CLI’s agent in the configuration directory:
cd path/to/config && turf chatThen type “watch this workspace for drift”. It calls the same tools.
Turn it on
Section titled “Turn it on”drift({ workspace_alias, enabled: true, sweep: 86400 })→ outcome: configured, settings: { settle: 30, sweep: 86400 }, next: watchDrift detection is off until you turn it on. drift is the control: enabled turns detection on or
off, and the call changes the settings it names and leaves the rest as they stand.
| Setting | Meaning |
|---|---|
enabled |
true turns detection on, with any settings named in the same call. false turns it off. |
settle |
Seconds an object marked as changed must be quiet before the engine reads it. The sweep’s own reads do not wait for it. 0 takes the engine’s default, 30. |
sweep |
Seconds for one cycle over every managed object. 0 turns the sweep off, which is where it starts. |
confirm |
false turns the confirming read off: every notice then stays unconfirmed, and the sweep, which is that read on a cycle, does not run. |
The result’s outcome says where detection stands:
| Outcome | Meaning |
|---|---|
configured |
Detection is on, with the settings the result shows. next is watch. |
stored |
The call named settings while detection is off. They are kept and take effect when it is turned on. There is no next: the note gives the call that turns it on. |
disabled |
Detection is off. See Turn it off. |
Detection needs two things besides being on, and the result’s note says which is still missing:
- Something to signal a change. The sweep. It is off until a call names a cycle, so name one as
you turn detection on:
sweep: 86400is one cycle a day. - A standing seal for the confirming read. The engine takes it from the last
upthat converged, so a workspace needs one converged run on this engine first. On a workspace with no state,driftis refused, except to turn detection off: a first deploy asks through itsup.
drift is listed only by a server at the full tier, and up
takes drift only there. watch and status are listed at every tier.
The sweep paces itself across the cycle and draws on the engine’s
read budget. It pauses while a run holds the
workspace, and an up that converges after reading every object starts its cycle over.
Choosing a cycle. The agent offers one cycle a day, sweep: 86400, and goes shorter only when you
ask. The sweep’s reads are unattended, and a day is the usual cadence for a scheduled drift check.
A shorter cycle has a floor. A swept read takes only what the read budget holds above its reserve, so
at the default budget the sweep reads about two objects a second, not five. A workspace of n objects
therefore needs a cycle of at least about n ÷ 2 seconds: 1,000 objects, about 500 seconds; 7,200
objects, about an hour. A day covers well over 100,000 objects. That is arithmetic to choose a setting
by, not a measured rate: a slower provider needs longer. A larger read burst on the engine,
TURF_DRIFT_READ_BURST, raises the sweep’s rate, as far as the budget’s own. A cycle too short for
the workspace cannot finish in time, and status says the sweep is
behind.
On a first deploy
Section titled “On a first deploy”A first deploy has no state for drift to watch yet. Pass the settings to that up as
drift: { … }, in the tool’s units, and detection turns on when the run converges:
up({ workspace_alias, drift: { sweep: 86400 } })→ every result: drift: { sweep: 86400, state: "pending" }→ at its end: state: enabled, kept_off, failed or not_applied| State | Meaning |
|---|---|
pending |
The run goes on. Detection turns on when it converges, unless it is turned off before then. |
enabled |
The run converged, and detection is on with the settings. |
kept_off |
Detection was turned off after the run began. That later choice stands. |
failed |
Turning detection on failed, and error says why. What the run applied is applied. |
not_applied |
The run did not converge, or a cancel was accepted on it before it did, so detection was not turned on. |
The agent passes drift to an up only on your words, as it calls the tool. status shows the same
block on the run holding the workspace. When a run ends not_applied and next is an up that takes
the work up again, that up carries the same drift unless detection was turned off in the meantime;
the note says when it does not.
drift on an up names at least one setting: drift: {} is refused, and so is a bare true. It is
refused with plan_only, whose run never converges. destroy, refresh, import and invoke take
no drift.
Turn it off
Section titled “Turn it off”drift({ workspace_alias, enabled: false })→ outcome: disabledDetection is off, and nothing watches the workspace. Its open notices are closed. The settings stand,
and take effect when detection is turned on again. The engine then takes up what it had reported: each
object is read again, and its notice reopens if the change still stands. With confirm off, or no
standing seal, nothing reads it, and the notice reopens unconfirmed.
enabled: falsestands alone. A call that also names a setting is refused. Change a setting in a call of its own: with detection off, it isstored.- It wins over a run that asked. An
upstill running withdrift: { … }leaves detection off when it converges, and endskept_off. This works even before the workspace has state. - While it is off,
watchreturnsunwatchedand its note says when detection was turned off, andstatuscarries no drift block.
See what drifted
Section titled “See what drifted”status carries each workspace’s open notices under drift:
drift: { counts: { configured: 1, gone: 1 }, notices: [ { address, class, paths, source, first_seen } ], omitted, coverage, next, note }noticeshas one entry per address, most severe class first:gone,configured,referenced,contended,unconfirmed,uncovered. It lists up to 20;omittedcounts the rest.pathsare the attribute paths that changed. Values are never in a notice.coverageis one line: how many objects are swept or uncovered, then the settings that explain it, such assettle 30s, sweep off. When the sweep is behind its cycle, the line ends by saying so and what limits it: the read budget, or the engine’s own cadence.nextis theupto call, andnotesays what each class present asks and names the plan that reads only what drifted.
With nothing open, the block is the coverage line alone, or absent when there is no coverage to report. A workspace whose detection is off, or was never turned on, has no block. What each class means: Drift.
Wait for it
Section titled “Wait for it”watch returns when there is something new to act on: an open notice it has not reported yet.
watch({ workspace_alias }) → outcome: drift, drift, cursor, next: upwatch({ workspace_alias, cursor }) → waits for what is new since- The cursor is what the last result reported. Pass it back exactly as it came, and the watch wakes only on what is new since. A notice clearing wakes nobody.
- No cursor is a catch-up: anything open is new, and the call returns at once. The note says which notices were already open before the call.
cursor: "now"takes what is open as reported and waits only for what opens after. Use it right after readingstatus.quiet_forholds new drift back until the open notices have been still that many seconds: no new mark, no new read. Use it when someone may be mid-change, or when a rollout touches many objects and you want one plan for all of it.wake_onpicks the classes.confirmed, the default, wakes on every class butunconfirmed, which the engine’s own read will settle. Where nothing will read it (no standing seal, orconfirmoff),unconfirmedwakes the watch too.anywakes on every class.forbounds the whole watch in seconds, across calls. Past it with nothing new, the outcome isquietand the watch has ended.
| Outcome | Meaning | Next |
|---|---|---|
drift |
Something new is open. The entries the cursor had not reported carry new: true. |
up, then at its plan gate plan with refresh_drift: true. Then watch with the new cursor. |
waiting |
The server’s deadline came first. Nothing is new. | The same watch, with the cursor the result carries. |
quiet |
for has passed with nothing new. |
Nothing. |
unwatched |
Nothing watches the workspace, so the watch would never wake. The note says why: no state yet, an engine without drift detection, detection never turned on, or turned off and when. | None. An up’s plan reads every object and is the drift report. |
watch only observes. It never turns detection on and never changes a setting, so unwatched
carries no next: the agent tells you why, and turns detection on with drift only if you ask.
While a run holds the workspace, a drift result has no next: finish or cancel that run first. A
server at the read or apply tier lists no up, so there too watch and status offer no next.
Their note says the up starts from a server at the plan or full tier, and the agent reports the
drift.
What an idle watch costs
Section titled “What an idle watch costs”A watch call waits inside the server until its deadline, then returns waiting. Each such return
costs your agent a turn and says nothing new.
- At the default deadline, 55 seconds, an idle watch is 3600 ÷ 55 ≈ 65 turns an hour.
--watch-deadline 30m(orTURF_WATCH_DEADLINE=30m) on the server makes it 2 an hour. Set it under your client’s limit on a tool call. In Claude Code that limit isMCP_TOOL_TIMEOUT, in milliseconds.- Without
--watch-deadline,watchtakes the server’s--deadline. - A call that carries a progress token gets a progress notification every 15 seconds while it waits, for a client that resets its timeout on progress.
The deadline is the operator’s setting, not an argument of the call. See The server.
Plan only what drifted
Section titled “Plan only what drifted”up({ workspace_alias }) → awaiting_plan, next: planplan({ convergence_id, refresh_drift: true }) → awaiting_approval, refresh_scopeapply({ convergence_id, plan_digest }) → converged
refresh_scope: { addresses: ["kubernetes_deployment_v1.web"], count: 1, from_drift: 1, skipped: 41 }The up that puts drift back is an ordinary run. Nothing marks it.
- When notices are open, the note at round 1’s plan gate says so and names
planwithrefresh_drift: true.nextis the plain plan, which reads every object. refresh_driftisplan’s argument, at the plan gate of anyup. It is the agent’s choice for that round, not something the run carries.- The engine records which run cleared each notice. The console shows it: see Decide.
- The plan, its digest and the approval rules are the ones every run has.
With refresh_drift: true, the round reads only the objects the open notices name. The server fills
that list in as the round plans, so anything that drifted since you looked is included. Every other
row plans from its record, and a row that then plans a change is read and planned again, so nothing
is applied over a stale record.
refresh_addressesnames addresses yourself. Withrefresh_drift, the round reads both sets.refresh_scope.skippedcounts the rows planned from their records, unread. Drift on them was not looked for. The round’srefresh_skippedis the same count.- Uncovered objects are not read by a scoped plan, and the result’s note says how many there are.
planwith neither argument reads everything. Use it when the coverage has gaps, or when a notice says signals were dropped. - With nothing open,
refresh_driftreads every object, and the result says so.
Both arguments belong to an up’s plan and to that round alone. More in
Refresh state.
Decide
Section titled “Decide”The notice says what changed. Which side wins is the agent’s decision, and often yours.
| Decision | What happens | Who approves |
|---|---|---|
| Remediate | up plans the object back to what the files say. |
The agent, when the plan is an in-place update that reverts a setting. You, for a replace, a delete, or a create of something that held data. |
| Adopt | The files change to match the world, then up. |
You. The files are yours, and the agent asks before it edits them. |
| Suppress | ignore_changes on the paths another controller owns. |
You. A contended notice has no next, because another up will not hold. |
The approval rules do not change because the plan came from drift: Approval.
A notice clears itself when a run commits its address, or when a later read finds the object as
recorded. The engine records which run cleared it: the console’s Drift tab names that run and links
to its round, and the Runs tab shows on the run how many notices it cleared. A gone object you meant
to delete clears when you remove it from the configuration and apply. A run that never touches an
address leaves its notice open. Turning detection off closes every open notice.
Arguments
Section titled “Arguments”up takes one argument for drift, beside its others:
| Argument | Meaning |
|---|---|
drift |
{ sweep, settle, confirm }, as the tool takes them, at least one named. Asks for detection to be turned on when the run converges; every result carries drift with the settings and a state. Never with plan_only. See On a first deploy. |
drift, the tool:
| Argument | Meaning |
|---|---|
workspace_alias |
The workspace. Omit it for the default. |
enabled |
true turns detection on; false turns it off, closes its open notices, and stands alone. |
settle |
Seconds of quiet before an object marked as changed is read; 0 takes the engine’s 30. |
sweep |
Seconds for one sweep cycle; 0 turns the sweep off. |
confirm |
false: no confirming read, and no sweep. true, the default: a settled object is read against the standing seal. |
Name at least one of the four. watch:
| Argument | Meaning |
|---|---|
workspace_alias |
The workspace. Omit it for the default. |
cursor |
The cursor from the last result; "now" to wait only for what opens after the call begins; omit to catch up. |
quiet_for |
Seconds the open notices must have been still before the watch returns them. Default 0. |
wake_on |
confirmed (default) or any. |
for |
Total seconds to keep watching, counted from the first call. Omit to watch until something drifts. |
plan’s refresh_drift and refresh_addresses are in
Plan and apply by hand.
Related
Section titled “Related”- Drift: the sweep, observations, classes and coverage.
- When something goes wrong: unwatched, stored, unconfirmed, uncovered, contended, a watch that never wakes.
watchanddriftin the reference.
Turf™ is a trademark of Turf LLC. Terraform® is a trademark of HashiCorp. Ansible® is a trademark of Red Hat, LLC, registered in the United States and other countries. Helm®, Kubernetes®, Prometheus® and OpenTelemetry® are registered trademarks, and Jaeger™ is a trademark, of the Linux Foundation. OpenTofu® and Model Context Protocol® are registered trademarks of LF Projects, LLC. All other trademarks are the property of their respective owners. Turf is not affiliated with, endorsed by, or sponsored by HashiCorp, IBM, Red Hat, the Linux Foundation, LF Projects or the OpenTofu project.
© 2026 Turf LLC. Free for individuals, education and small businesses within the Community limits, under the Turf Community Edition License 1.0. Government and larger organizations need a commerciallicense.turf.build · Discord ·GitHub