Drift Watch — Source-vs-Runtime & Baseline Comparison
A service running is not the same as a service running what you think.
DITEMPA BUKAN DIBERI — Drift is invisible until it causes a bug.
What This Skill Is
A unified drift detection skill covering two modes:
- Source-vs-Runtime Drift — probe-based comparison of git source SHAs against deployed runtime SHAs using live organ registry data
- Baseline Drift Detection — compare live state against saved baselines across tool manifests, agent cards, skill registries, and runtime-injected files
When to Use
- After deploy, when organ behavior surprises you
- Weekly health audit, before any "is it running what I think?" question
- "Check drift", "verify registry", "detect manifest drift", "tool surface audit"
- "Runtime injection detection", "drift watch", "source vs runtime"
When NOT to Use
- Curiosity probes without a specific concern
- When the task is about skill inventory (use
skill-inventory)
- When the task is about incident response (use
incident-response)
§1. SOURCE-VS-RUNTIME DRIFT
Canonical SOT
The organ registry at /root/AAA/federation/organs.yaml is the single source of truth for organ names, source paths, runtime locations, ports, and health endpoints. Read it FIRST.
python3 -c "
import yaml
with open('/root/AAA/federation/organs.yaml') as f:
reg = yaml.safe_load(f)
for o in reg.get('organs', []):
print(f'{o[\"id\"]} src={o.get(\"source_path\",\"?\")} runtime={o.get(\"runtime_path\",\"?\")} port={o.get(\"port\",\"?\")}')
"
Steps
Read organ registry — gives source_path, runtime_path, and port for every organ
For each organ with a source_path:
git -C <source_path> rev-parse HEAD → source SHA
cat <runtime_path>/.git_commit 2>/dev/null → runtime SHA
- Compare → if mismatch → DRIFT
For each organ with a port:
curl -sf --max-time 2 http://localhost:<port>/health → probe live health
- Parse the software_release block for deployed_commit
- Cross-reference with source SHA
If DRIFT detected:
- Source newer than runtime →
make deploy-local candidate
- Runtime newer than source → runtime patch not in source → 888 HOLD
- Runtime
.git_commit missing → warn, treat source as truth
Also check (from registry, not hardcoded):
- Caddy port map:
/etc/caddy/Caddyfile
- systemd units:
systemctl list-units --type=service | grep -E 'arifos|aforge|geox|wealth|well|aaa|arifflow'
- env file presence:
/root/.secrets/kunci-mas.env (mode 600)
Verification Loop
- Match → no action
- Mismatch → log + 888 HOLD with both SHAs + recommended action
.git_commit missing → log warning, treat source as truth
- Organ DOWN → skip SHA comparison, flag in report
§2. BASELINE DRIFT DETECTION
Drift Dimensions
- Build vs Runtime Manifest Drift — Canonical check via
arifOS/runtime/manifest.py
- Tool Manifest Drift — Live MCP tools vs registered tools vs agent card references
- Skill Registry Drift — SKILL_ALIAS_TABLE vs actual directories vs agent card skill IDs
- Agent Card Drift — Card skill IDs vs existing skill directories
- Schema Drift — Tool input schemas vs documented schemas
- Floor Drift — Declared floor_scope vs actual floor enforcement
- Verdict Taxonomy Drift — Verdict emissions vs closed 6-value set
Detection Pipeline
- Snapshot — Capture current state of all registries
- Compare — Diff against saved baseline (or last-known-good)
- Classify — Each mismatch: CRITICAL (breaks routing), WARNING (orphan), INFO (cosmetic)
- Report — Structured drift report with fix recommendations
- Escalate — CRITICAL drift → 888_HOLD before any SEAL operation
Runtime-Injected Files
Some organ services modify files at runtime:
- WELL
index.html: WebMCP adapter injected on service start
- arifOS session-state: Runtime state files that change during operation
When dirty after clean commit: check if injected content was already committed → if yes, re-commit; if no, actual drift.
Baselines
- Canonical drift check:
arifOS/runtime/manifest.py
- Tool registry:
/root/arifOS/tool_registry.json
- Agent cards:
/root/AAA/a2a-server/agent-cards/
- Skill alias:
/root/AAA/skills/SKILL_ALIAS_TABLE.json
- MCP surface: Live
tools/list from each organ
- Verdict taxonomy:
arifOS/runtime/verdict.py
Failure Modes
- Runtime file missing → assume source is truth, surface to operator
- Mismatch in
.git_commit only (cosmetic) → warn, don't HOLD
- Source repo not on
main → flag, ask if intentional
- Registry unreachable → fall back to filesystem inspection of known paths
Floors
- F1 AMANAH: Reversible-first. Drift correction must be reversible.
- F2 TRUTH: Report only what is actually observed. No inference without evidence.
- F4 CLARITY: Drift report must be actionable, not noise.
- F7 HUMILITY: Confidence cap. Uncertain drift → flag, don't assert.
- F11 AUDITABILITY: Every drift check logged with timestamp and findings.
1---2name: drift-watch3description: Source-vs-runtime drift detection + live baseline comparison. Detect drift between federation source and runtime. Reads organ topology from canonical SOT, probes live health endpoints, compares git SHAs, and compares live state against saved baselines across tool manifests, agent cards, skill registries, and runtime-injected files.4---56# Drift Watch — Source-vs-Runtime & Baseline Comparison78> **A service running is not the same as a service running what you think.**9> **DITEMPA BUKAN DIBERI** — Drift is invisible until it causes a bug.1011## What This Skill Is1213A unified drift detection skill covering two modes:14151. **Source-vs-Runtime Drift** — probe-based comparison of git source SHAs against deployed runtime SHAs using live organ registry data162. **Baseline Drift Detection** — compare live state against saved baselines across tool manifests, agent cards, skill registries, and runtime-injected files1718## When to Use1920- After deploy, when organ behavior surprises you21- Weekly health audit, before any "is it running what I think?" question22- "Check drift", "verify registry", "detect manifest drift", "tool surface audit"23- "Runtime injection detection", "drift watch", "source vs runtime"2425## When NOT to Use2627- Curiosity probes without a specific concern28- When the task is about skill inventory (use `skill-inventory`)29- When the task is about incident response (use `incident-response`)3031## §1. SOURCE-VS-RUNTIME DRIFT3233### Canonical SOT3435The organ registry at `/root/AAA/federation/organs.yaml` is the single source of truth for organ names, source paths, runtime locations, ports, and health endpoints. Read it FIRST.3637```bash38python3 -c "39import yaml40with open('/root/AAA/federation/organs.yaml') as f:41 reg = yaml.safe_load(f)42for o in reg.get('organs', []):43 print(f'{o[\"id\"]} src={o.get(\"source_path\",\"?\")} runtime={o.get(\"runtime_path\",\"?\")} port={o.get(\"port\",\"?\")}')44"45```4647### Steps48491. **Read organ registry** — gives source_path, runtime_path, and port for every organ50512. **For each organ** with a source_path:52 - `git -C <source_path> rev-parse HEAD` → source SHA53 - `cat <runtime_path>/.git_commit 2>/dev/null` → runtime SHA54 - Compare → if mismatch → DRIFT55563. **For each organ** with a port:57 - `curl -sf --max-time 2 http://localhost:<port>/health` → probe live health58 - Parse the software_release block for deployed_commit59 - Cross-reference with source SHA60614. **If DRIFT detected:**62 - Source newer than runtime → `make deploy-local` candidate63 - Runtime newer than source → runtime patch not in source → 888 HOLD64 - Runtime `.git_commit` missing → warn, treat source as truth65665. **Also check (from registry, not hardcoded):**67 - Caddy port map: `/etc/caddy/Caddyfile`68 - systemd units: `systemctl list-units --type=service | grep -E 'arifos|aforge|geox|wealth|well|aaa|arifflow'`69 - env file presence: `/root/.secrets/kunci-mas.env` (mode 600)7071### Verification Loop7273- Match → no action74- Mismatch → log + 888 HOLD with both SHAs + recommended action75- `.git_commit` missing → log warning, treat source as truth76- Organ DOWN → skip SHA comparison, flag in report7778## §2. BASELINE DRIFT DETECTION7980### Drift Dimensions81821. **Build vs Runtime Manifest Drift** — Canonical check via `arifOS/runtime/manifest.py`832. **Tool Manifest Drift** — Live MCP tools vs registered tools vs agent card references843. **Skill Registry Drift** — SKILL_ALIAS_TABLE vs actual directories vs agent card skill IDs854. **Agent Card Drift** — Card skill IDs vs existing skill directories865. **Schema Drift** — Tool input schemas vs documented schemas876. **Floor Drift** — Declared floor_scope vs actual floor enforcement887. **Verdict Taxonomy Drift** — Verdict emissions vs closed 6-value set8990### Detection Pipeline91921. **Snapshot** — Capture current state of all registries932. **Compare** — Diff against saved baseline (or last-known-good)943. **Classify** — Each mismatch: CRITICAL (breaks routing), WARNING (orphan), INFO (cosmetic)954. **Report** — Structured drift report with fix recommendations965. **Escalate** — CRITICAL drift → 888_HOLD before any SEAL operation9798### Runtime-Injected Files99100Some organ services modify files at runtime:101- **WELL `index.html`**: WebMCP adapter injected on service start102- **arifOS session-state**: Runtime state files that change during operation103104When dirty after clean commit: check if injected content was already committed → if yes, re-commit; if no, actual drift.105106### Baselines107108- **Canonical drift check**: `arifOS/runtime/manifest.py`109- Tool registry: `/root/arifOS/tool_registry.json`110- Agent cards: `/root/AAA/a2a-server/agent-cards/`111- Skill alias: `/root/AAA/skills/SKILL_ALIAS_TABLE.json`112- MCP surface: Live `tools/list` from each organ113- Verdict taxonomy: `arifOS/runtime/verdict.py`114115## Failure Modes116117- Runtime file missing → assume source is truth, surface to operator118- Mismatch in `.git_commit` only (cosmetic) → warn, don't HOLD119- Source repo not on `main` → flag, ask if intentional120- Registry unreachable → fall back to filesystem inspection of known paths121122## Floors123124- F1 AMANAH: Reversible-first. Drift correction must be reversible.125- F2 TRUTH: Report only what is actually observed. No inference without evidence.126- F4 CLARITY: Drift report must be actionable, not noise.127- F7 HUMILITY: Confidence cap. Uncertain drift → flag, don't assert.128- F11 AUDITABILITY: Every drift check logged with timestamp and findings.