Skip to content

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:

main.tf
resource "kubernetes_deployment_v1" "web" {
metadata { name = "web" }
spec {
replicas = 3
# …
}
}
✦Your agentin Claude Code
You
Watch this workspace, and put back anything that changes outside Turf.
Agent
  • 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?

You
Yes, daily is fine.
Agent
  • drift→configured
  • watch→waiting

Drift detection is on, with a sweep of one cycle a day, and I am watching. I will tell you when something drifts.

Agent
  • watch→drift
  • up→awaiting_plan
  • plan→awaiting_approval
  • apply→converged
  • watch→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 → 3

An 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: true
drift:
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: 1
next: { 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/config

In 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”.

drift({ workspace_alias, enabled: true, sweep: 86400 })
→ outcome: configured, settings: { settle: 30, sweep: 86400 }, next: watch

Drift 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: 86400 is one cycle a day.
  • A standing seal for the confirming read. The engine takes it from the last up that converged, so a workspace needs one converged run on this engine first. On a workspace with no state, drift is refused, except to turn detection off: a first deploy asks through its up.

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.

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.

drift({ workspace_alias, enabled: false })
→ outcome: disabled

Detection 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: false stands alone. A call that also names a setting is refused. Change a setting in a call of its own: with detection off, it is stored.
  • It wins over a run that asked. An up still running with drift: { … } leaves detection off when it converges, and ends kept_off. This works even before the workspace has state.
  • While it is off, watch returns unwatched and its note says when detection was turned off, and status carries no drift block.

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 }
  • notices has one entry per address, most severe class first: gone, configured, referenced, contended, unconfirmed, uncovered. It lists up to 20; omitted counts the rest.
  • paths are the attribute paths that changed. Values are never in a notice.
  • coverage is one line: how many objects are swept or uncovered, then the settings that explain it, such as settle 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.
  • next is the up to call, and note says 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.

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: up
watch({ 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 reading status.
  • quiet_for holds 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_on picks the classes. confirmed, the default, wakes on every class but unconfirmed, which the engine’s own read will settle. Where nothing will read it (no standing seal, or confirm off), unconfirmed wakes the watch too. any wakes on every class.
  • for bounds the whole watch in seconds, across calls. Past it with nothing new, the outcome is quiet and 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.

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 (or TURF_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 is MCP_TOOL_TIMEOUT, in milliseconds.
  • Without --watch-deadline, watch takes 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.

up({ workspace_alias })
→ awaiting_plan, next: plan
plan({ convergence_id, refresh_drift: true })
→ awaiting_approval, refresh_scope
apply({ 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 plan with refresh_drift: true. next is the plain plan, which reads every object.
  • refresh_drift is plan’s argument, at the plan gate of any up. 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_addresses names addresses yourself. With refresh_drift, the round reads both sets.
  • refresh_scope.skipped counts the rows planned from their records, unread. Drift on them was not looked for. The round’s refresh_skipped is the same count.
  • Uncovered objects are not read by a scoped plan, and the result’s note says how many there are. plan with neither argument reads everything. Use it when the coverage has gaps, or when a notice says signals were dropped.
  • With nothing open, refresh_drift reads every object, and the result says so.

Both arguments belong to an up’s plan and to that round alone. More in Refresh state.

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.

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.

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