1.9 KiB
AIOS Codex automatic command watcher
The watcher polls the governed commands/active queue without a chat trigger. It uses SQLite transactions for exclusive leases, records the exact command digest, rejects contract drift, retries transient failures, dead-letters exhausted work, and resumes from the last durable phase so an end-event retry does not execute a work unit twice.
Commands are JSON documents validated by schemas/codex-command.schema.json. acceptance_probe is the only built-in action and has no external side effect. Production codex work requires an administrator-provisioned absolute executor path; the instruction is passed on standard input, never argv or environment. The executor receives a sanitized environment and must obtain credentials through its approved file or exec provider. If the executor is absent, the task fails closed and follows the retry/dead-letter policy.
The watcher provides at-most-once execution. It writes the EXECUTING phase before launching an external executor; if the host dies after an external effect but before a result is durably recorded, recovery does not replay the work and instead dead-letters the ambiguity for human review. Start and end event JSON is persisted before transmission, so response-loss retries reuse the exact event ID and payload and are deduplicated by the Gateway.
Lifecycle evidence is appended to /var/log/aios-codex-watcher/audit.jsonl as CODEX_AUTO_CLAIM, TASK_STARTED, TASK_EXECUTED, TASK_ENDED, and EVENT_POSTED. Inputs, tokens, stdout, and stderr are not logged; only result digests are retained.
Install from a reviewed commit with sudo scripts/install_aios_codex_watcher.sh. The installer creates a content-addressed release, atomically updates current, writes a receipt, and enables the five-second systemd timer. The existing Gateway inbound token file is referenced in place and never copied.