---
title: "digital-twin-sync-loop"
description: "Run the digital twin sync loop to synchronize real-world signals with a digital model."
canonical: "https://acs.synapti.ai/guides/skills/digital-twin-sync-loop/"
last_updated: "2026-11-16T02:24:08Z"
---

# digital-twin-sync-loop

Source: [skills/digital-twin-sync-loop/SKILL.md](https://github.com/synaptiai/agent-capability-standard/blob/main/skills/digital-twin-sync-loop/SKILL.md), commit 18c38b74ac21.

## Intent

Run the composed workflow **digital_twin_sync_loop** (`reference/workflow_catalog.yaml`) to synchronize a **digital twin** with incoming signals and keep it **grounded, safe, and auditable**: detect drift, decide and execute safe actions, and record provenance.

This workflow is designed to **model both real and digital systems** using the canonical world-state schema:
- `reference/world_state_schema.yaml`

**Success criteria:**
- Twin snapshot updated and grounded
- Drift assessed with risk score
- Any actions are approved/checkpointed/verified
- Audit trail produced
- Rollback runs only when verification fails

**Compatible schemas:**
- `reference/world_state_schema.yaml`
- `reference/event_schema.yaml`
- `reference/workflow_catalog.yaml`

## Inputs

| Parameter | Required | Type | Description |
|-----------|----------|------|-------------|
| `user_input` | No | object | `domain` and `constraints`. The catalog accepts both but no step binds them: the policy check uses the fixed constraints `least_privilege` and `change_policy`, and no drift threshold gates any step |
| `previous_world_state` | No | object | The twin snapshot before this sync (`reference/world_state_schema.yaml#/world_state`). Merged with the new events and diffed against the updated snapshot; without it there is no baseline (run `/digital-twin-bootstrap` instead) |

## Preconditions (hard gates)

**Figure: The guarded steps of digital_twin_sync_loop: conditions, gates, checkpoint and approval.** 5 steps of 21 are guarded in the catalog: step 16 runs only when a condition holds; steps 1, 16, 17, 18 and 19 have gates; steps 16 and 19 need a checkpoint before them; and steps 16 and 17 need approval.

| Step | Needs | Runs only when | Gates |
| --- | --- | --- | --- |
| 1. `receive` |  |  | end when `${receive_out.data} == []` |
| 16. `mutate` | a checkpoint first, approval | `${constrain_out.compliant} == true` | stop when `${checkpoint_out.checkpoint_id} == null` |
| 17. `execute` | approval |  | skip when `${mutate_out} == null` |
| 18. `verify` |  |  | skip when `${mutate_out} == null` |
| 19. `rollback` | a checkpoint first |  | skip when `${mutate_out} == null \|\| ${verify_out.passed} == true` |

1. **Policy constraints must pass** (`/constrain`): `mutate` runs only if `${constrain_out.compliant} == true`
2. **Checkpoint before mutation** (`/checkpoint`): `mutate` stops if `${checkpoint_out.checkpoint_id} == null`
3. Any external side effects require explicit approval (do not `send` without approval); `mutate` and `execute` require approval

## Procedure

**Figure: Steps of digital_twin_sync_loop: 21 steps, checkpoint at step 15, rollback at step 19.** Read top to bottom: step 16 makes the change after the checkpoint at step 15; steps 1, 16, 17, 18 and 19 have gates; steps 1, 16, 17 and 18 say what to do on failure; and the highest step risk is high, at step 16.

| # | Capability | Layer | Role | Gates | On failure | Reads from | Risk |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | `receive` | PERCEIVE |  | end | stop |  | low |
| 2 | `search` | PERCEIVE |  |  |  | 1 | low |
| 3 | `transform` | SYNTHESIZE |  |  |  | 1 | low |
| 4 | `integrate` | SYNTHESIZE |  |  |  | 3 | low |
| 5 | `detect` | UNDERSTAND |  |  |  | 4 | low |
| 6 | `classify` | UNDERSTAND |  |  |  | 5 | low |
| 7 | `state` | MODEL |  |  |  | 4 | low |
| 8 | `compare` | UNDERSTAND |  |  |  | 7 | low |
| 9 | `transition` | MODEL |  |  |  | 7 | low |
| 10 | `detect` | UNDERSTAND |  |  |  | 7, 8, 9 | low |
| 11 | `measure` | UNDERSTAND |  |  |  | 10 | low |
| 12 | `predict` | UNDERSTAND |  |  |  | 9, 10, 11 | low |
| 13 | `plan` | REASON |  |  |  | 2, 6, 8, 12 | low |
| 14 | `constrain` | VERIFY | verify |  |  | 13 | low |
| 15 | `checkpoint` | VERIFY | checkpoint |  |  |  | medium |
| 16 | `mutate` | EXECUTE | mutating | stop | rollback | 13, 14, 15 | high |
| 17 | `execute` | EXECUTE |  | skip | rollback | 16 | medium |
| 18 | `verify` | VERIFY | verify | skip | rollback | 16, 17 | medium |
| 19 | `rollback` | VERIFY | rollback | skip |  | 15, 16, 18 | medium |
| 20 | `audit` | VERIFY |  |  |  | 16, 18, 19 | medium |
| 21 | `explain` | REASON |  |  |  | 10, 11, 12, 13, 16, 18, 19 | low |

Each step's card is on the [`digital_twin_sync_loop`](https://acs.synapti.ai/workflows/digital-twin-sync-loop/index.md) page.

0) **Ensure baseline exists**: If no twin snapshot exists, run `/digital-twin-bootstrap` instead: it builds the world model and then runs this loop

Then execute the sync loop:

1) **Invoke `/receive`** and store output as `receive_out`
   - Ingest new signals/events from sources (logs/APIs/messages); retry up to 3 times

2) **Invoke `/search`** for `receive_out.source` and store output as `search_out`
   - Parallel enrichment (`parallel_group: context_gathering`): search for the existing twin snapshot or relevant context

3) **Invoke `/transform`** on `receive_out.data` to `canonical_event` and store output as `transform_out`
   - Normalize raw signals into canonical events (`reference/transform_mapping_rawlog_to_observation.yaml`; the step's `output` is one event of `reference/event_schema.yaml#/event`)

4) **Invoke `/integrate`** with `transform_out.output` and `previous_world_state`, and store output as `integrate_out`
   - Merge canonical events with the existing twin snapshot; resolve conflicts with `prefer_authoritative_sources`

5) **Invoke `/detect`** (domain: entity) on `integrate_out.merged` and store output as `detect_entity_out`
   - Detect entities in integrated data

6) **Invoke `/classify`** on `detect_entity_out.matches` and store output as `classify_out`
   - Classify and resolve entity identities

7) **Invoke `/state`** with `integrate_out.merged.observations`, scoped to `integrate_out.merged.meta.world_id`, and store output as `state_out`
   - Produce the updated canonical world-state snapshot with uncertainty + provenance: the output wraps the snapshot (`reference/world_state_schema.yaml#/world_state`) in its `state` field, so later steps read `state_out.state`

8) **Invoke `/compare`** (domain: state_diff) on `previous_world_state` and `state_out.state`, and store output as `compare_state_out`
   - Compute the diff between the previous and the updated snapshot

9) **Invoke `/transition`** from `state_out.state` and store output as `transition_out`
   - Apply transition rules triggered by new observations; compute next states

10) **Invoke `/detect`** (domain: anomaly) for `drift` on the observed state (`state_out.state`), the expected effects (`transition_out.effects`) and the diff (`compare_state_out`), and store output as `detect_anomaly_out`
    - Detect drift/anomalies between expected and observed state

11) **Invoke `/measure`** (domain: risk) on `detect_anomaly_out` and store output as `measure_risk_out`
    - Estimate risk impact/probability from drift and transitions

12) **Invoke `/predict`** (domain: risk) for `near_term_risk`, conditioned on the risk score (`measure_risk_out.value`, `.uncertainty`), the drift (`detect_anomaly_out.detected`, `.matches`) and the transition rules (`transition_out.rules`), and store output as `predict_out`
    - Forecast near-term risk trajectory and triggers

13) **Invoke `/plan`** with the forecast (`predict_out`), the state diff (`compare_state_out`), the entity labels (`classify_out.labels`) and the search context (`search_out.results`) as context, and store output as `plan_out`
    - Plan safe action(s) to reduce the detected drift and risk, with verification criteria and rollback plan

14) **Invoke `/constrain`** on `plan_out.steps` (`least_privilege`, `change_policy`) and store output as `constrain_out`
    - Enforce policy and least privilege for planned actions

15) **Invoke `/checkpoint`** on `twin_state` and store output as `checkpoint_out`
    - Create the checkpoint marker before any mutation/side-effect step

16) **Invoke `/mutate`** on `twin_state`, applying `plan_out.steps`, if `constrain_out.compliant` is true, and store output as `mutate_out`
    - Execute mutations from the action plan (if approved); stop if no checkpoint was created
    - If the mutation fails or times out (R401/R402), roll back to `checkpoint_out` and end the run with that error

17) **Invoke `/execute`** with `run_verification_suite` if a mutation was applied (`mutate_out` is not null), and store output as `execute_out`
    - Run verification tests and commands; skip this step when nothing was mutated
    - If the verification suite fails or times out (R401/R402), roll back to `checkpoint_out` so the unverified mutation does not stay in place, and end the run with that error (the audit step does not run; the run record the host keeps, STANDARD v1.2 §5.19.8, records the failure)

18) **Invoke `/verify`** on `execute_out` (`drift_resolved`, `no_policy_violation`) if a mutation was applied, and store output as `verify_out`
    - Verify outcome: PASS/FAIL with evidence; skip this step when nothing was mutated. On FAIL, carry on: step 19 rolls back, once, and `audit` records the verdict and the rollback
    - If verification cannot run (R401/R402 after its retries), roll back to `checkpoint_out` and end the run with that error

19) **Invoke `/rollback`** to `checkpoint_out.checkpoint_id` if a mutation was applied (`mutate_out` is not null) and `verify_out.passed` is false, and store output as `rollback_out`
    - The step is skipped when nothing was mutated or verification passes
    - The step does not take a checkpoint of its own (`requires_checkpoint: false`): it restores the one taken at step 15

20) **Invoke `/audit`** and store output as `audit_out`
    - Record provenance, tool usage, diffs, decision rationale, and whether the twin was rolled back (`rollback_out.restored`; null when the rollback was skipped)

21) **Invoke `/explain`** and store output as `explain_out`
    - Produce a decision-ready sync report: drift, actions, verification, next steps

## Output Contract

**Figure: Which step reads which stored output.** 19 steps read the output of earlier steps, 39 reads in all; step 21 (explain) reads the most, from 7 steps.

- Step 2 reads from step 1.
- Step 3 reads from step 1.
- Step 4 reads from step 3.
- Step 5 reads from step 4.
- Step 6 reads from step 5.
- Step 7 reads from step 4.
- Step 8 reads from step 7.
- Step 9 reads from step 7.
- Step 10 reads from steps 7, 8 and 9.
- Step 11 reads from step 10.
- Step 12 reads from steps 9, 10 and 11.
- Step 13 reads from steps 2, 6, 8 and 12.
- Step 14 reads from step 13.
- Step 16 reads from steps 13, 14 and 15.
- Step 17 reads from step 16.
- Step 18 reads from steps 16 and 17.
- Step 19 reads from steps 15, 16 and 18.
- Step 20 reads from steps 16, 18 and 19.
- Step 21 reads from steps 10, 11, 12, 13, 16, 18 and 19.

Return a structured object:

```yaml
workflow_id: string  # Unique sync execution ID
user_input: object  # The input as given
status: synced | action_taken | rolled_back | failed
steps:
  receive_out:
    data: array[object]  # Received items, each with its sender
    source: string
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  search_out:
    results: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  transform_out:
    output: object  # One canonical event (reference/event_schema.yaml#/event)
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  integrate_out:
    merged: object  # Includes observations and meta.world_id
    conflicts: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  detect_entity_out:
    detected: boolean
    matches: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  classify_out:
    labels: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  state_out:
    state: object  # Canonical world state
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  compare_state_out:
    ranking: array[object]
    tradeoffs: array[object]  # Differences between the snapshots
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  transition_out:
    rules: array[object]
    effects: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  detect_anomaly_out:
    detected: boolean
    matches: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  measure_risk_out:
    value: number  # 0.0-1.0
    uncertainty: object  # lower, upper
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  predict_out:
    prediction: object
    probability: number
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  plan_out:
    steps: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  constrain_out:
    compliant: boolean
    violations: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  checkpoint_out:
    checkpoint_id: string
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  mutate_out:  # null when the step was skipped (constrain_out.compliant was false)
    success: boolean
    previous_state: object
    new_state: object
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  execute_out:  # null when nothing was mutated (the step was skipped)
    result: any
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  verify_out:  # null when nothing was mutated (the step was skipped)
    passed: boolean
    violations: array[object]
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  rollback_out:  # null when nothing was mutated or verification passed (the step was skipped)
    restored: boolean
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  audit_out:
    audit_id: string
    recorded: boolean
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
  explain_out:
    explanation: string
    evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
verification: PASS | FAIL
audit_log_pointer: string  # Where the audit step appended its record (.claude/audit/records.jsonl)
next_sync:
  recommended_interval: string  # e.g., "5m", "1h"
  triggers: array[string]  # Conditions for immediate resync
confidence: number  # 0.0-1.0
evidence_anchors: array[EvidenceAnchor]  # each {ref, kind, digest?} (STANDARD v1.2 §6.5)
assumptions: array[string]
```

### Field Definitions

| Field | Type | Description |
|-------|------|-------------|
| `workflow_id` | string | Unique identifier for this sync execution |
| `status` | enum | Final workflow status |
| `steps` | object | Each step's output, keyed by its `store_as`; a skipped step is null |
| `verification` | enum | Final PASS/FAIL |
| `audit_log_pointer` | string | Where the audit trail was written |
| `next_sync` | object | Recommended timing for next synchronization |
| `confidence` | number | 0.0-1.0 based on evidence quality |
| `evidence_anchors` | array of evidence anchors (§6.5) | All evidence references collected |
| `assumptions` | array | Explicit assumptions made during sync |

## Examples

### Example 1: IoT Sensor Sync with Drift Correction

**Input:**
```yaml
user_input:
  domain: "building floor 3 HVAC"
previous_world_state:
  meta:
    world_id: "building-floor-3-twin"
    as_of: "2024-01-15T15:55:00Z"
    timezone: "UTC"
    version_id: "v46"
    lineage: []
  entities:
    - id: "hvac-unit-3a"
      type: "hvac_controller"
  # relationships, state_variables, observations, transition_rules, actions, indexes elided
```

**Output:**
```yaml
workflow_id: "sync_20240115_160000_floor3"
user_input:
  domain: "building floor 3 HVAC"
status: action_taken
steps:
  receive_out:
    data:
      - sender: "gateway-floor-3"
        topic: "floor-3/hvac-unit-3a"
        payload:
          sensor-temp-301: 24.1
          hvac-unit-3a: {temperature: 23.5, setpoint: 22.0, status: "cooling"}
    source: "mqtt://sensors.example.com/floor-3"
    evidence_anchors:
      - {ref: "tool:mqtt:sensors.example.com/floor-3", kind: tool}
  search_out:
    results:
      - {path: "state/floor-3-twin-v46.yaml", version_id: "v46"}
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v46.yaml", kind: file}
  transform_out:
    output:
      event_id: "evt_7f3a91"
      timestamp: "2024-01-15T16:00:00Z"
      source: {kind: "sensor", name: "gateway-floor-3", channel: "floor-3/hvac-unit-3a"}
      event_type: "hvac_telemetry"
      entity_refs: [{entity_id: "sensor:acme/floor-3/temp-301"}, {entity_id: "asset:acme/floor-3/hvac-unit-3a"}]
      raw:
        sensor-temp-301: 24.1
        hvac-unit-3a: {temperature: 23.5, setpoint: 22.0, status: "cooling"}
      canonical:
        readings:
          - {entity: "sensor-temp-301", variable: "reading", value: 24.1}
          - {entity: "hvac-unit-3a", variable: "temperature", value: 23.5}
      anchors: [{ref: "mqtt://sensors.example.com/floor-3", kind: "sensor"}]
      provenance: {transformer: "transform", transform_version: "1.0.0", ruleset_id: "raw_log_to_observation_event"}
    evidence_anchors:
      - {ref: "file:reference/transform_mapping_rawlog_to_observation.yaml", kind: file}
  integrate_out:
    merged:
      meta: {world_id: "building-floor-3-twin"}
      observations:
        - event_id: "evt_5c20d4"  # carried over from v46
          timestamp: "2024-01-15T15:55:00Z"
          source: "sensor"
          payload:
            readings:
              - {entity: "sensor-temp-301", variable: "reading", value: 23.0}
              - {entity: "hvac-unit-3a", variable: "temperature", value: 22.4}
          anchors: [{ref: "file:state/floor-3-twin-v46.yaml", kind: "file"}]
        - event_id: "evt_7f3a91"  # new, from transform_out.output
          timestamp: "2024-01-15T16:00:00Z"
          source: "sensor"
          payload:
            readings:
              - {entity: "sensor-temp-301", variable: "reading", value: 24.1}
              - {entity: "hvac-unit-3a", variable: "temperature", value: 23.5}
          anchors: [{ref: "mqtt://sensors.example.com/floor-3", kind: "sensor"}]
    conflicts: []
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v46.yaml", kind: file}
  detect_entity_out:
    detected: true
    matches: [{id: "hvac-unit-3a"}, {id: "sensor-temp-301"}]
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v46.yaml", kind: file}
  classify_out:
    labels:
      - {id: "hvac-unit-3a", type: "hvac_controller"}
      - {id: "sensor-temp-301", type: "temperature_sensor"}
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v46.yaml", kind: file}
  state_out:
    state:
      meta: {world_id: "building-floor-3-twin", version_id: "v47", parent_version_id: "v46"}
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v47.yaml", kind: file}
  compare_state_out:
    ranking: [{option: "v47", changed_entities: 2}]
    tradeoffs:
      - {field: "sensor-temp-301.reading", from: 23.0, to: 24.1}
      - {field: "hvac-unit-3a.temperature", from: 22.4, to: 23.5}
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v46.yaml", kind: file}
      - {ref: "file:state/floor-3-twin-v47.yaml", kind: file}
  transition_out:
    rules: [{trigger: "temperature > setpoint for 10m", next: "cooling_degraded"}]
    effects: [{entity: "hvac-unit-3a", status: "cooling_degraded"}]
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v47.yaml", kind: file}
  detect_anomaly_out:
    detected: true
    matches:
      - entity: "hvac-unit-3a"
        pattern: "drift"
        description: "Temperature 1.5°C above setpoint for >10 minutes"
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v46.yaml:temperature_history", kind: file}
  measure_risk_out:
    value: 0.35
    uncertainty: {lower: 0.3, upper: 0.4}
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v47.yaml", kind: file}
  predict_out:
    prediction: {risk: 0.45, horizon: "1h", trigger: "comfort threshold breach"}
    probability: 0.6
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v46.yaml:temperature_history", kind: file}
  plan_out:
    steps:
      - action: "Lower hvac-unit-3a setpoint to 21.5°C"
        verification: "Zone temperature within 0.5°C of setpoint in 15m"
        rollback: "Restore setpoint 22.0°C"
    evidence_anchors:
      - {ref: "file:state/floor-3-twin-v47.yaml", kind: file}
  constrain_out:
    compliant: true
    violations: []
    evidence_anchors:
      - {ref: "policy:change_policy:setpoint_bounds", kind: record}
  checkpoint_out:
    checkpoint_id: "chk_20240115_160500"
    evidence_anchors:
      - {ref: "file:.checkpoints/chk_20240115_160500/manifest.json", kind: file}
  mutate_out:
    success: true
    previous_state: {setpoint: 22.0}
    new_state: {setpoint: 21.5}
    evidence_anchors:
      - {ref: "tool:api:building.api/hvac/hvac-unit-3a/setpoint", kind: tool}
  execute_out:
    result: "verification suite: 6 passed"
    evidence_anchors:
      - {ref: "tool:bash:run_verification_suite", kind: tool}
  verify_out:
    passed: true
    violations: []
    evidence_anchors:
      - {ref: "tool:bash:run_verification_suite", kind: tool}
  rollback_out: null  # skipped: verification passed
  audit_out:
    audit_id: "audit_20240115_162000"
    recorded: true
    evidence_anchors:
      - {ref: "file:.claude/audit/records.jsonl", kind: file}
  explain_out:
    explanation: "Drift of 1.5°C detected on zone 3a; setpoint lowered to 21.5°C after policy check and checkpoint; verification passed"
    evidence_anchors:
      - {ref: "file:.claude/audit/records.jsonl", kind: file}
verification: PASS
audit_log_pointer: ".claude/audit/records.jsonl"
next_sync:
  recommended_interval: "5m"
  triggers:
    - "Temperature exceeds 25°C"
    - "HVAC status changes"
confidence: 0.88
evidence_anchors:
  - {ref: "tool:mqtt:sensors.example.com/floor-3", kind: tool}
  - {ref: "file:state/floor-3-twin-v47.yaml", kind: file}
  - {ref: "file:.claude/audit/records.jsonl", kind: file}
assumptions:
  - "Sensor readings are accurate within ±0.1°C"
  - "MQTT connection is reliable"
  - "Building API returns real-time status"
```

**Evidence pattern:** Multi-source signal ingestion, anomaly detection against historical baseline, risk forecasting with trend analysis, checkpointed and verified action.

## Verification

**Figure: The steps of digital_twin_sync_loop whose output each verification check names.** 7 of the 9 checks name a step's stored output as a word; together they name 8 of the 21 outputs the steps store (a match on the output's name, not a reading of the check).

| Check | Steps whose output it names |
| --- | --- |
| 1. Step Completeness | none |
| 2. Transform Success | 3 (`transform_out`) |
| 3. Identity Resolved | 6 (`classify_out`) |
| 4. Drift Detection | 10 (`detect_anomaly_out`) |
| 5. Risk Assessment | 11 (`measure_risk_out`), 12 (`predict_out`) |
| 6. Policy Compliance | 14 (`constrain_out`) |
| 7. Checkpoint Valid | 15 (`checkpoint_out`) |
| 8. Audit Complete | 20 (`audit_out`) |
| 9. Next Sync Scheduled | none |

- [ ] **Step Completeness**: All 21 workflow steps executed with output (mutate skipped if not compliant; execute and verify skipped when nothing was mutated; rollback skipped when nothing was mutated or verification passed)
- [ ] **Transform Success**: `transform_out.output` conforms to the canonical event schema
- [ ] **Identity Resolved**: No unresolved entity references in `classify_out`
- [ ] **Drift Detection**: `detect_anomaly_out` completed with evidence
- [ ] **Risk Assessment**: Both `measure_risk_out` and `predict_out` computed
- [ ] **Policy Compliance**: `constrain_out` evaluated before `mutate`
- [ ] **Checkpoint Valid**: `checkpoint_out.checkpoint_id` exists before `mutate`
- [ ] **Audit Complete**: `audit_out` recorded
- [ ] **Next Sync Scheduled**: Recommended interval provided

**Verification tools:** Web (for API checks), Bash (for MQTT), Read (for state files)

## Safety Constraints

Declared and highest step risk are both high; the catalog gives no computed risk; the highest-risk step is step 16 (mutate). The step map above gives each step's risk.

- `mutation`: true
- `requires_checkpoint`: true
- `requires_approval`: true (for `mutate` and `execute`)
- `risk`: high

**Capability-specific rules:**
- STOP on low confidence from any perception step
- NEVER execute mutation without checkpoint
- NEVER emit external side effects without explicit approval
- Validate all source data before integration
- Preserve previous snapshot for rollback
- Rate-limit sync frequency to prevent thrashing

## Composition Patterns

**Commonly follows:**
- `digital-twin-bootstrap` - Initial twin creation and first sync
- `receive` - When triggered by external event

**Commonly precedes:**
- `explain` - Create executive report after sync
- `send` - Notify stakeholders of drift or actions
- Self (recursive) - Next sync iteration

**Anti-patterns:**
- Never sync without prior world model established
- Never skip anomaly detection to proceed directly to action
- Never execute actions without policy constraint check
- Never delete audit logs before retention period

**Workflow references:**
- See `reference/workflow_catalog.yaml#digital_twin_sync_loop` for step definitions
- See `reference/world_state_schema.yaml` for canonical state format
- See `reference/composition_patterns.md#checkpoint-act-verify-rollback` for CAVR pattern
- See `reference/composition_patterns.md#digital-twin-sync-loop` for gates, data flow and recovery
