Open source · IoT & Edge

Device Shadow Drift Detector

Compare device shadow state with reported state and desired state.

v0.1.0 · Node.js 22+ · MIT

Browse the public repository · View releases

device-shadow-drift-detector compares an exported desired shadow with separately exported reported and observed field evidence. It classifies reconciled, stale, conflicting, missing, and ambiguous fields without reading or writing a device. Node.js 22+; no dependencies.

This walkthrough uses the tool's public README and checked-in example files. Run the command from a repository checkout with Node.js 22+; inspect the source before using it on your own files.

Run the checked-in example

node bin/device-shadow-drift-detector.mjs --root examples --input passing.json
node bin/device-shadow-drift-detector.mjs --root examples --input failing.json
npm run check

Read the result

The passing example exits 0; the failing example exits 1 with field-stale. CLI configuration errors exit 2 with empty stdout. Unreadable, malformed, incomplete, or unsupported exports exit 2 with an incomplete JSON report. Stdout contains only that report. The real input path must remain inside the real --root, including through symlinks.

Where this check stops

Strict UTF-8 only. Maximum input 1,048,576 bytes, 200 records per array, JSON depth 3 (root at 0), 5,000 ms injected processing time. Exceeding any bound returns incomplete; exact N and N+1 tests cover each. Duplicate JSON keys (including escaped spelling) are refused. A read-only report has no --out and never sends device commands.

Before adapting the command to your own workflow, review the accepted inputs, exit codes and safety boundaries in the README.

Compiled with AI assistance from checked-in public documentation and example scripts. Run the example and review the repository's current documentation before relying on its result.