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-watch3id: drift-watch4version: 2.0.05description: >6 Source-vs-runtime drift detection + live baseline comparison. Detect drift between7 federation source and runtime. Reads organ topology from canonical SOT, probes live8 health endpoints, compares git SHAs, and compares live state against saved baselines9 across tool manifests, agent cards, skill registries, and runtime-injected files.10owner: AAA11risk_tier: low12autonomy_tier: T013floor_scope: [F1, F2, F4, F7, F11]14tags: [drift, watch, runtime, source, baseline, manifest, registry, probe, health]15capability_tier: fed-agent-subagent16ecology_state: WARM17---1819# Drift Watch — Source-vs-Runtime & Baseline Comparison2021> **A service running is not the same as a service running what you think.**22> **DITEMPA BUKAN DIBERI** — Drift is invisible until it causes a bug.2324## What This Skill Is2526A unified drift detection skill covering two modes:27281. **Source-vs-Runtime Drift** — probe-based comparison of git source SHAs against deployed runtime SHAs using live organ registry data292. **Baseline Drift Detection** — compare live state against saved baselines across tool manifests, agent cards, skill registries, and runtime-injected files3031## When to Use3233- After deploy, when organ behavior surprises you34- Weekly health audit, before any "is it running what I think?" question35- "Check drift", "verify registry", "detect manifest drift", "tool surface audit"36- "Runtime injection detection", "drift watch", "source vs runtime"3738## When NOT to Use3940- Curiosity probes without a specific concern41- When the task is about skill inventory (use `skill-inventory`)42- When the task is about incident response (use `incident-response`)4344## §1. SOURCE-VS-RUNTIME DRIFT4546### Canonical SOT4748The 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.4950```bash51python3 -c "52import yaml53with open('/root/AAA/federation/organs.yaml') as f:54 reg = yaml.safe_load(f)55for o in reg.get('organs', []):56 print(f'{o[\"id\"]} src={o.get(\"source_path\",\"?\")} runtime={o.get(\"runtime_path\",\"?\")} port={o.get(\"port\",\"?\")}')57"58```5960### Steps61621. **Read organ registry** — gives source_path, runtime_path, and port for every organ63642. **For each organ** with a source_path:65 - `git -C <source_path> rev-parse HEAD` → source SHA66 - `cat <runtime_path>/.git_commit 2>/dev/null` → runtime SHA67 - Compare → if mismatch → DRIFT68693. **For each organ** with a port:70 - `curl -sf --max-time 2 http://localhost:<port>/health` → probe live health71 - Parse the software_release block for deployed_commit72 - Cross-reference with source SHA73744. **If DRIFT detected:**75 - Source newer than runtime → `make deploy-local` candidate76 - Runtime newer than source → runtime patch not in source → 888 HOLD77 - Runtime `.git_commit` missing → warn, treat source as truth78795. **Also check (from registry, not hardcoded):**80 - Caddy port map: `/etc/caddy/Caddyfile`81 - systemd units: `systemctl list-units --type=service | grep -E 'arifos|aforge|geox|wealth|well|aaa|arifflow'`82 - env file presence: `/root/.secrets/kunci-mas.env` (mode 600)8384### Verification Loop8586- Match → no action87- Mismatch → log + 888 HOLD with both SHAs + recommended action88- `.git_commit` missing → log warning, treat source as truth89- Organ DOWN → skip SHA comparison, flag in report9091## §2. BASELINE DRIFT DETECTION9293### Drift Dimensions94951. **Build vs Runtime Manifest Drift** — Canonical check via `arifOS/runtime/manifest.py`962. **Tool Manifest Drift** — Live MCP tools vs registered tools vs agent card references973. **Skill Registry Drift** — SKILL_ALIAS_TABLE vs actual directories vs agent card skill IDs984. **Agent Card Drift** — Card skill IDs vs existing skill directories995. **Schema Drift** — Tool input schemas vs documented schemas1006. **Floor Drift** — Declared floor_scope vs actual floor enforcement1017. **Verdict Taxonomy Drift** — Verdict emissions vs closed 6-value set102103### Detection Pipeline1041051. **Snapshot** — Capture current state of all registries1062. **Compare** — Diff against saved baseline (or last-known-good)1073. **Classify** — Each mismatch: CRITICAL (breaks routing), WARNING (orphan), INFO (cosmetic)1084. **Report** — Structured drift report with fix recommendations1095. **Escalate** — CRITICAL drift → 888_HOLD before any SEAL operation110111### Runtime-Injected Files112113Some organ services modify files at runtime:114- **WELL `index.html`**: WebMCP adapter injected on service start115- **arifOS session-state**: Runtime state files that change during operation116117When dirty after clean commit: check if injected content was already committed → if yes, re-commit; if no, actual drift.118119### Baselines120121- **Canonical drift check**: `arifOS/runtime/manifest.py`122- Tool registry: `/root/arifOS/tool_registry.json`123- Agent cards: `/root/AAA/a2a-server/agent-cards/`124- Skill alias: `/root/AAA/skills/SKILL_ALIAS_TABLE.json`125- MCP surface: Live `tools/list` from each organ126- Verdict taxonomy: `arifOS/runtime/verdict.py`127128## Failure Modes129130- Runtime file missing → assume source is truth, surface to operator131- Mismatch in `.git_commit` only (cosmetic) → warn, don't HOLD132- Source repo not on `main` → flag, ask if intentional133- Registry unreachable → fall back to filesystem inspection of known paths134135## Floors136137- F1 AMANAH: Reversible-first. Drift correction must be reversible.138- F2 TRUTH: Report only what is actually observed. No inference without evidence.139- F4 CLARITY: Drift report must be actionable, not noise.140- F7 HUMILITY: Confidence cap. Uncertain drift → flag, don't assert.141- F11 AUDITABILITY: Every drift check logged with timestamp and findings.