From fb95f2edfb43be088feba928cd56b497d74fe2df Mon Sep 17 00:00:00 2001 From: Archer Date: Thu, 5 Nov 2026 01:40:38 -0600 Subject: [PATCH] =?UTF-8?q?feat(pm-stack):=20external-comms=20send-time=20?= =?UTF-8?q?ledger=20=E2=80=94=20CLI,=20pusher=20units,=20migration,=20audi?= =?UTF-8?q?t=20backfill=20(#6130)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pm-stack/external-comms/README.md | 93 +++++ .../external-comms/backfill-2026-11-05.jsonl | 68 ++++ .../external-comms-pusher.service | 8 + .../external-comms-pusher.timer | 11 + .../migration-0001-agent-external-comms.sql | 33 ++ pm-stack/external-comms/record-external-send | 332 ++++++++++++++++++ 6 files changed, 545 insertions(+) create mode 100644 pm-stack/external-comms/README.md create mode 100644 pm-stack/external-comms/backfill-2026-11-05.jsonl create mode 100644 pm-stack/external-comms/external-comms-pusher.service create mode 100644 pm-stack/external-comms/external-comms-pusher.timer create mode 100644 pm-stack/external-comms/migration-0001-agent-external-comms.sql create mode 100755 pm-stack/external-comms/record-external-send diff --git a/pm-stack/external-comms/README.md b/pm-stack/external-comms/README.md new file mode 100644 index 0000000000..9bc38f478b --- /dev/null +++ b/pm-stack/external-comms/README.md @@ -0,0 +1,93 @@ +# External-comms ledger + +The send-time ledger for Drew's ratified rule **EXTERNAL COMMS ARE +NEVER SILENT** (2026-11-05; rule text: `~/AGENTS.md`, +`~/memory/topics/external-comms-rule-2026-11-05.md`; origin: the +external-comms audit of 2026-11-05). + +Every send outside our own repos/channels under Drew's identity or a +fleet identity — third-party email, issues/PRs/comments/reviews on +repos we don't own, public posts — is recorded here at send time, +with its approval basis: (a) per-item approval, (b) surfaced-with-link +(the narrow #176 shape), or (c) a written allowlist entry. + +## Where things live + +| Piece | Location | +|---|---| +| Table | `agent.external_comms` in Supabase project **muse-dev2** (fleet ops schema, beside `agent.tasks` / `agent.quota_records`) | +| Migration | `migration-0001-agent-external-comms.sql` (this directory) | +| Writer CLI + pusher | `record-external-send` (this directory; deployed from the primary clone `~/git/code` on the laptop) | +| Outbox (spill) | `~/.local/state/external-comms/outbox.jsonl` on the laptop | +| Pusher health | `~/.local/state/external-comms/pusher-health.json` on the laptop | +| Pusher supervision | systemd **user** units `external-comms-pusher.service` / `.timer` (this directory; installed to `~/.config/systemd/user/`, timer every minute) | +| Backfill | `backfill-2026-11-05.jsonl` — the 68 sends enumerated by the 2026-11-05 audit, loaded once via `record-many` | + +## Write pattern: database-first, spill to outbox, pusher drains + +Drew's direction (2026-11-05): *"use database spill to outbox or use +outbox always ensure pusher. all on laptop."* + +Chosen: **database-first with spill to outbox** — the proven pm-stack +pattern (the aggregator's `events.ts` retry outbox: write to the store +first; on failure append to a durable JSONL outbox; flush merged by +stable id on the next tick). It fits this ledger because the direct +path lands most records instantly (audits and dashboards read the DB, +not files), while no record can be lost to a DB/network outage at +send time: + +1. `record-external-send …` builds a record with a stable id and + tries a direct PostgREST insert into `agent.external_comms` + (service-role key resolved **by name** through the secrets broker: + `supabase.muse-dev2.service-role-key` + `…project-url` — the same + route the queue broker uses; values never touch disk or logs). +2. On any failure it appends the record to the local outbox + (fsync'd) and still exits 0 — recording never blocks the send it + logs. Exit is non-zero only when *both* paths fail. +3. The **pusher** (`record-external-send push`, timer every minute) + drains the outbox: insert with `resolution=ignore-duplicates` on + the id PK (safe retry after ambiguous failures), drop landed + lines, keep failures with `_attempts` / `_last_error`. Every run + rewrites `pusher-health.json` (`last_run_at`, `last_drain_ok_at`, + `pending_count`, `last_error`, `total_landed`) — a stuck pusher is + a stale health file plus a non-zero pending count, readable by the + stewardship visibility pass. + +Retention follows the #1258 durability tiers: the database is the +record; the laptop outbox is local spill only; the laptop state dir +rides the laptop's existing backup story. + +## Recording contract + +```sh +record-external-send \ + --identity drew|fleet: \ + --channel github|gmail|slack|facebook|... \ + --destination \ + --kind issue|pr|comment|review|email|post|dm \ + --approval-basis "per-item approval" | "surfaced-with-link" | "allowlist:" \ + --summary "one line: what was sent" \ + [--item-ref ] [--approver ] [--approval-evidence ] \ + [--sent-at ] [--payload ''] +# -> {"id": "…", "landed": "db"|"outbox"} + +record-external-send status # health + outbox depth + DB row count +record-external-send push # manual drain (normally the timer's job) +``` + +Email approvals are recorded explicitly: `--approver` names who +approved and `--approval-evidence` points at where (chat line, memory +entry, issue comment) — the gap the Oct 19 Crunchyroll 06:19 send +exposed. + +## Install (laptop) + +```sh +cp external-comms-pusher.{service,timer} ~/.config/systemd/user/ +systemctl --user daemon-reload +systemctl --user enable --now external-comms-pusher.timer +``` + +The units execute the script from the deployed primary clone +(`%h/git/code/pm-stack/external-comms/record-external-send`), so a +merge to main + pm-git-sync is the deploy. diff --git a/pm-stack/external-comms/backfill-2026-11-05.jsonl b/pm-stack/external-comms/backfill-2026-11-05.jsonl new file mode 100644 index 0000000000..f794813afa --- /dev/null +++ b/pm-stack/external-comms/backfill-2026-11-05.jsonl @@ -0,0 +1,68 @@ +{"id": "bf-2026-10-30-gh-nix-openclaw-176", "sent_at": "2026-10-30T02:21:31Z", "identity": "drew", "channel": "github", "destination": "openclaw/nix-openclaw", "item_ref": "https://github.com/openclaw/nix-openclaw/issues/176", "kind": "issue", "approval_basis": "none \u2014 unsanctioned at send time; surfaced retroactively by the 2026-11-05 audit", "approval_evidence": "audit report.md (i); code#2509 comment 6513378682 posted 5s after creation, inside the same pass", "summary": "Issue: 'Generated schema: agent runtime oneOf of submodules makes the acp branch unreachable' \u2014 verified root-cause report + repro + suggested fix, filed by the main-chat session mid deploy-chain; never mentioned to Drew. Upstream closed it 2026-11-05 (steipete, 'Fixed in #178').", "payload": {"audit_ref": "report.md (i)", "filed_by": "main-chat Muse", "upstream_fix": "openclaw/nix-openclaw#178"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-gmail-20261019-0619", "sent_at": "2026-10-19T11:19:00Z", "identity": "drew", "channel": "gmail", "destination": "support@crunchyroll.com", "kind": "email", "approval_basis": "none recorded \u2014 agent-drafted and agent-sent with no explicit pre-send approval on file (audit finding; contextual direction only)", "approval_evidence": "memory 2026-10-19.md logs the send (~06:20 CDT) but no approval; audit gmail.md flag 1", "summary": "Formal Escalation \u2014 Subscription Guidance and Goodwill Resolution | Case #02444135 (4 screenshots attached), sent from a prepared draft.", "payload": {"case": "02444135", "audit_ref": "gmail.md #1"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-gmail-20261019-0739", "sent_at": "2026-10-19T12:39:00Z", "identity": "drew", "channel": "gmail", "destination": "support@crunchyroll.com", "kind": "email", "approval_basis": "per-item approval", "approver": "Drew", "approval_evidence": "memory 2026-10-19.md: draft presented to Drew; 'Drew tapped Send it' with this message's Gmail ID recorded", "summary": "Re: Crunchyroll Support Update \u2014 in-thread reply to Crunchyroll's redirect response on Case #02444135.", "payload": {"case": "02444135", "audit_ref": "gmail.md #2"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-gmail-20261020-2151", "sent_at": "2026-10-21T02:51:00Z", "identity": "drew", "channel": "gmail", "destination": "support@mail.anthropic.com", "kind": "email", "approval_basis": "Drew's own send (no agent involvement)", "approver": "Drew", "summary": "Re: Accept \u2014 one-line personal reply to a support rating prompt.", "payload": {"audit_ref": "gmail.md #3"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-01", "sent_at": "2026-10-25T13:43:00Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "allowlist:aster-arrangement", "approver": "Drew", "approval_evidence": "standing arrangement of 2026-10-25 (Muse may message Aster as Drew via the connector); audit slack-facebook.md", "summary": "'How do you work' Q&A to Aster (receiving/tracking, where work happens, standing arrangement) \u2014 sent as Drew via the connector after Aster ignored the Archer bot.", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 1, "timestamp_approx": true}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-02", "sent_at": "2026-10-25T18:19:35Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "per-item approval (Drew-directed)", "approver": "Drew", "approval_evidence": "memory 2026-10-25.md; aster-usage-log.md", "summary": "Farewell / arrangement-closed message as Drew (Drew's order 13:13 CDT).", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 1, "slack_ts": "1792952375.245859"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-03", "sent_at": "2026-10-25T21:48:32Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "per-item approval (Drew-directed)", "approver": "Drew", "approval_evidence": "memory 2026-10-25.md; aster-usage-log.md", "summary": "Correction: the arrangement remains in force; only the Archer bot identity ended.", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 1, "slack_ts": "1792964912.998829"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-04", "sent_at": "2026-10-27T03:26:32Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "allowlist:aster-arrangement", "approver": "Drew", "approval_evidence": "standing arrangement of 2026-10-25 (Muse may message Aster as Drew via the connector); audit slack-facebook.md", "summary": "Cost-explorer retrieval ask (share URL/zip; 'Reflective Beam' side question).", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 1, "slack_ts": "1793071592.899289"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-05", "sent_at": "2026-10-27T03:54:46Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "allowlist:aster-arrangement", "approver": "Drew", "approval_evidence": "standing arrangement of 2026-10-25 (Muse may message Aster as Drew via the connector); audit slack-facebook.md", "summary": "'Reflective Beam' thread follow-up to Aster.", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 1, "slack_ts": "1793073286.982789"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-06", "sent_at": "2026-10-27T07:59:52Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "allowlist:aster-arrangement", "approver": "Drew", "approval_evidence": "standing arrangement of 2026-10-25 (Muse may message Aster as Drew via the connector); audit slack-facebook.md", "summary": "Ask: upload latest tabbed cost explorer to Google Drive + share link.", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 1, "slack_ts": "1793087992.192909"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-07", "sent_at": "2026-10-29T01:12:00Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "allowlist:aster-arrangement", "approver": "Drew", "approval_evidence": "standing arrangement of 2026-10-25 (Muse may message Aster as Drew via the connector); audit slack-facebook.md", "summary": "2026-10-28 program heads-up (epics code#2055/#2056, PR #2067) + placement-framework and OpenClaw-comms asks.", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 1}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-08", "sent_at": "2026-10-29T07:27:00Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "per-item approval (Drew-directed)", "approver": "Drew", "approval_evidence": "aster-usage-log.md (Drew's direction)", "summary": "TASK dispatch sched-placement-design-20261029 + in-thread @mention + addendum with Drew's measurement mandate (3 messages).", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 3, "slack_ts": "1793258820.847929"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-slack-claude-09", "sent_at": "2026-11-01T09:29:26Z", "identity": "drew", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL) \u2014 to Aster (U0CBQ5F9Z5K)", "kind": "post", "approval_basis": "per-item approval (Drew-directed)", "approver": "Drew", "approval_evidence": "aster-usage-log.md; memory 2026-11-01.md", "summary": "dsh-superagent design package handoff for Aster's review (code#3450/#3424/#3418).", "payload": {"audit_ref": "slack-facebook.md A2", "messages": 1, "slack_ts": "1793525366.856039"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793363713045", "sent_at": "2026-10-30T12:35:13Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'Couldn't sign in to the AI service\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793392577347", "sent_at": "2026-10-30T20:36:17Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793394379374", "sent_at": "2026-10-30T21:06:19Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793396154263", "sent_at": "2026-10-30T21:35:54Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793397977505", "sent_at": "2026-10-30T22:06:17Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793399791178", "sent_at": "2026-10-30T22:36:31Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793403501494", "sent_at": "2026-10-30T23:38:21Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793407222261", "sent_at": "2026-10-31T00:40:22Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793410920754", "sent_at": "2026-10-31T01:42:00Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793414637489", "sent_at": "2026-10-31T02:43:57Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793418370620", "sent_at": "2026-10-31T03:46:10Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793448396826", "sent_at": "2026-10-31T12:06:36Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793450194799", "sent_at": "2026-10-31T12:36:34Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793452000004", "sent_at": "2026-10-31T13:06:40Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793453778777", "sent_at": "2026-10-31T13:36:18Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793455590682", "sent_at": "2026-10-31T14:06:30Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793481018183", "sent_at": "2026-10-31T21:10:18Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'Couldn't sign in to the AI service\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793484633104", "sent_at": "2026-10-31T22:10:33Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793488254435", "sent_at": "2026-10-31T23:10:54Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793491878496", "sent_at": "2026-11-01T00:11:18Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The AI service reported a billing problem\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793495597018", "sent_at": "2026-11-01T01:13:17Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793499298136", "sent_at": "2026-11-01T02:14:58Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793503020836", "sent_at": "2026-11-01T03:17:00Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793624870255", "sent_at": "2026-11-02T13:07:50Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793626538181", "sent_at": "2026-11-02T13:35:38Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat alert (first delivered): workspace idle \u2014 no active task to continue", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793673330829", "sent_at": "2026-11-03T02:35:30Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793804592294", "sent_at": "2026-11-04T15:03:12Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793806299199", "sent_at": "2026-11-04T15:31:39Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793806578354", "sent_at": "2026-11-04T15:36:18Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793808360595", "sent_at": "2026-11-04T16:06:00Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793810166243", "sent_at": "2026-11-04T16:36:06Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793813828977", "sent_at": "2026-11-04T17:37:08Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat alert: fleet proxy on 127.0.0.1:18746 unreachable/down", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793819104661", "sent_at": "2026-11-04T19:05:04Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat alert: fleet proxy on 127.0.0.1:18746 unreachable/down", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793830030926", "sent_at": "2026-11-04T22:07:10Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat alert: fleet proxy on 127.0.0.1:18746 unreachable/down", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793538399126", "sent_at": "2026-11-01T13:06:39Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793540169370", "sent_at": "2026-11-01T13:36:09Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793542001901", "sent_at": "2026-11-01T14:06:41Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793543791832", "sent_at": "2026-11-01T14:36:31Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793545592808", "sent_at": "2026-11-01T15:06:32Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793549325897", "sent_at": "2026-11-01T16:08:45Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793553034820", "sent_at": "2026-11-01T17:10:34Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793556771638", "sent_at": "2026-11-01T18:12:51Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793560465471", "sent_at": "2026-11-01T19:14:25Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793564197026", "sent_at": "2026-11-01T20:16:37Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793567923193", "sent_at": "2026-11-01T21:18:43Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793571645811", "sent_at": "2026-11-01T22:20:45Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793575373716", "sent_at": "2026-11-01T23:22:53Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793579086054", "sent_at": "2026-11-02T00:24:46Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793582793746", "sent_at": "2026-11-02T01:26:33Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793586514698", "sent_at": "2026-11-02T02:28:34Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793590225346", "sent_at": "2026-11-02T03:30:25Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793593938373", "sent_at": "2026-11-02T04:32:18Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "standing-system-delivery \u2014 Drew ratified unchanged 2026-11-05", "approver": "Drew", "approval_evidence": "Drew chat 2026-11-05 01:28 CST 'openclaw noise ok' + 01:31 ratification (DM delivery stays as-is); audit openclaw.md", "summary": "OpenClaw heartbeat failure notice: 'The background check did not complete\u2026' \u2014 autonomous system delivery", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793718561567", "sent_at": "2026-11-03T15:09:21Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL)", "kind": "post", "approval_basis": "directed test \u2014 fleet queue task 7858 (issue #2170)", "approver": null, "approval_evidence": "audit openclaw.md \u00a72b", "summary": "OpenClaw \u2014 channel binding verification + sender registry post (queue task 7858 \u00b7 issue #2170); executed via the gateway/operator path, not OpenClaw's own agent.", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793718568696", "sent_at": "2026-11-03T15:09:28Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack #alignment (C0CBYQR65LL)", "kind": "post", "approval_basis": "directed test \u2014 fleet queue task 7858 (issue #2170)", "approver": null, "approval_evidence": "audit openclaw.md \u00a72b", "summary": "Receive-side check reply in the same thread: OpenClaw read the parent post back; threaded replies work (queue task 7858 \u00b7 #2170).", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} +{"id": "bf-openclaw-1793720312523", "sent_at": "2026-11-03T15:38:32Z", "identity": "fleet:openclaw", "channel": "slack", "destination": "Slack DM D0CBXTJB3PH (Drew U0CBX163G8Z)", "kind": "dm", "approval_basis": "reply to Drew", "approver": null, "approval_evidence": "Drew inbound DM 'status' 2026-11-03 09:37 CST; audit openclaw.md \u00a72a", "summary": "Status report (gateway/host/disk, one failed update-locatedb.service) replying to Drew's inbound DM.", "payload": {"timestamp_source": "openclaw channel_ingress_events echo received_at", "audit_ref": "openclaw.md \u00a72"}, "source": "backfill-2026-11-05-audit"} diff --git a/pm-stack/external-comms/external-comms-pusher.service b/pm-stack/external-comms/external-comms-pusher.service new file mode 100644 index 0000000000..86bc681eea --- /dev/null +++ b/pm-stack/external-comms/external-comms-pusher.service @@ -0,0 +1,8 @@ +[Unit] +Description=External-comms ledger pusher — drain the send-time outbox into Supabase agent.external_comms +After=network-online.target secrets-broker.service +Wants=secrets-broker.service + +[Service] +Type=oneshot +ExecStart=%h/git/code/pm-stack/external-comms/record-external-send push diff --git a/pm-stack/external-comms/external-comms-pusher.timer b/pm-stack/external-comms/external-comms-pusher.timer new file mode 100644 index 0000000000..d13e773b5d --- /dev/null +++ b/pm-stack/external-comms/external-comms-pusher.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Run the external-comms ledger pusher every minute + +[Timer] +OnBootSec=2min +OnUnitActiveSec=1min +Persistent=true +Unit=external-comms-pusher.service + +[Install] +WantedBy=timers.target diff --git a/pm-stack/external-comms/migration-0001-agent-external-comms.sql b/pm-stack/external-comms/migration-0001-agent-external-comms.sql new file mode 100644 index 0000000000..3675b2b2ac --- /dev/null +++ b/pm-stack/external-comms/migration-0001-agent-external-comms.sql @@ -0,0 +1,33 @@ +-- External-comms send-time ledger (Drew ratified 2026-11-05). +-- Rule: memory/topics/external-comms-rule-2026-11-05.md; design: +-- pm-stack/external-comms/README.md in developing-today/code. +-- Fleet ops data: lives in the `agent` schema beside tasks / +-- quota_records (canonical project muse-dev2). + +create table if not exists agent.external_comms ( + id text primary key, -- stable record id; pusher retries dedupe on it + sent_at timestamptz not null, -- when the send happened + recorded_at timestamptz not null default now(), + identity text not null, -- 'drew' | 'fleet:' (e.g. fleet:openclaw) + channel text not null, -- github | gmail | slack | facebook | ... + destination text not null, -- repo / addressee / channel the send went to + item_ref text, -- URL of the item, when one exists + kind text not null, -- issue | pr | comment | review | email | post | dm + approval_basis text not null, -- per-item approval | surfaced-with-link | allowlist: | honest backfill labels + approver text, -- who approved, when approval applies + approval_evidence text, -- where the approval is recorded (chat/memory/issue ref) + summary text not null, -- one line: what was sent + payload jsonb not null default '{}'::jsonb, -- channel detail (slack ts, case no, provenance) + source text not null default 'record-external-send' -- writer: CLI | backfill-2026-11-05-audit +); + +create index if not exists external_comms_sent_at_idx + on agent.external_comms (sent_at desc); +create index if not exists external_comms_channel_idx + on agent.external_comms (channel, sent_at desc); + +alter table agent.external_comms enable row level security; +grant select, insert, update, delete on agent.external_comms to service_role; + +comment on table agent.external_comms is + 'Send-time ledger for external comms under Drew''s or a fleet identity (rule ratified 2026-11-05). Writers: record-external-send CLI on the laptop (DB-first, spill to local outbox, pusher drains).'; diff --git a/pm-stack/external-comms/record-external-send b/pm-stack/external-comms/record-external-send new file mode 100755 index 0000000000..b234fd9092 --- /dev/null +++ b/pm-stack/external-comms/record-external-send @@ -0,0 +1,332 @@ +#!/usr/bin/env python3 +"""record-external-send — the external-comms ledger writer + pusher. + +Implements Drew's ratified rule (2026-11-05): EXTERNAL COMMS ARE NEVER +SILENT. Every send outside our own repos/channels under Drew's identity +or a fleet identity is recorded at send time in the ledger table +`agent.external_comms` (Supabase muse-dev2). + +Write pattern (the pm-stack durability pattern, cf. aggregator +events.ts): DATABASE-FIRST WITH SPILL TO OUTBOX. + + record Try a direct insert into agent.external_comms + (PostgREST, service-role key resolved by name through + `fleet secrets get`). On ANY failure — DB down, + network, secrets broker — the record is appended to + the local outbox (~/.local/state/external-comms/ + outbox.jsonl, fsync'd) and the command still exits 0: + recording must never block or fail the send it logs. + Exit is non-zero only when BOTH paths fail. + + push The pusher. Drains the outbox into the database: + each record is inserted with ignore-duplicates on its + stable id (so a retry after an ambiguous failure is + safe), landed lines are removed, failures stay with + _attempts/_last_error bookkeeping. Runs under the + systemd user timer external-comms-pusher.timer + (every minute) and always rewrites + pusher-health.json — the visible surface a stewardship + visibility pass reads to spot a stuck pusher. + + status Print pusher health + outbox depth + DB row count. + + record-many Batch form of record (one JSON object per line) — + used for the 2026-11-05 audit backfill. + +Secrets are referenced by NAME only and held in memory: + supabase.muse-dev2.project-url, supabase.muse-dev2.service-role-key +Test hooks (env): EXTERNAL_COMMS_SUPABASE_URL overrides the project +URL; EXTERNAL_COMMS_STATE_DIR overrides the state directory. +""" +import fcntl +import json +import os +import subprocess +import sys +import urllib.error +import urllib.request +import uuid +from datetime import datetime, timezone + +STATE_DIR = os.environ.get( + "EXTERNAL_COMMS_STATE_DIR", + os.path.expanduser("~/.local/state/external-comms")) +OUTBOX = os.path.join(STATE_DIR, "outbox.jsonl") +HEALTH = os.path.join(STATE_DIR, "pusher-health.json") +LOCK = os.path.join(STATE_DIR, "pusher.lock") +TABLE = "external_comms" +TIMEOUT = 8 # seconds; a send-time caller must never hang on the ledger + + +def now_iso(): + return datetime.now(timezone.utc).isoformat(timespec="seconds") + + +def find_fleet(): + for cand in (os.path.expanduser("~/.local/bin/fleet"), + "/run/current-system/sw/bin/fleet"): + if os.path.isfile(cand) and os.access(cand, os.X_OK): + return cand + from shutil import which + return which("fleet") + + +def secret(name): + fleet = find_fleet() + if not fleet: + raise RuntimeError("fleet binary not found (secrets route)") + out = subprocess.run([fleet, "secrets", "get", name], + capture_output=True, text=True, timeout=30) + if out.returncode != 0: + raise RuntimeError(f"fleet secrets get {name} failed " + f"(exit {out.returncode})") + return out.stdout.strip() + + +def db_config(): + base = os.environ.get("EXTERNAL_COMMS_SUPABASE_URL") or \ + secret("supabase.muse-dev2.project-url") + key = os.environ.get("EXTERNAL_COMMS_SERVICE_KEY") or \ + secret("supabase.muse-dev2.service-role-key") + return base.rstrip("/"), key + + +def insert_record(base, key, rec): + """One PostgREST insert, ignore-duplicates on the id PK. + Returns None on success; raises on failure.""" + row = {k: v for k, v in rec.items() if not k.startswith("_")} + req = urllib.request.Request( + f"{base}/rest/v1/{TABLE}", + data=json.dumps(row).encode(), + method="POST", + headers={ + "apikey": key, + "Authorization": f"Bearer {key}", + "Content-Type": "application/json", + "Content-Profile": "agent", + "Prefer": "resolution=ignore-duplicates,return=minimal", + }) + with urllib.request.urlopen(req, timeout=TIMEOUT) as resp: + if resp.status not in (200, 201, 204): + raise RuntimeError(f"PostgREST HTTP {resp.status}") + + +def spill(rec): + os.makedirs(STATE_DIR, exist_ok=True) + rec = dict(rec) + rec.setdefault("_spilled_at", now_iso()) + rec.setdefault("_attempts", 0) + with open(OUTBOX, "a") as f: + f.write(json.dumps(rec) + "\n") + f.flush() + os.fsync(f.fileno()) + + +def write_health(**fields): + os.makedirs(STATE_DIR, exist_ok=True) + health = {} + if os.path.exists(HEALTH): + try: + with open(HEALTH) as f: + health = json.load(f) + except Exception: + health = {} + health.update(fields) + health["updated_at"] = now_iso() + tmp = HEALTH + ".tmp" + with open(tmp, "w") as f: + json.dump(health, f, indent=1) + os.replace(tmp, HEALTH) + return health + + +def do_record(rec): + """Returns 'db' or 'outbox'. Raises only if both paths fail.""" + try: + base, key = db_config() + insert_record(base, key, rec) + return "db" + except Exception as db_err: + try: + spill(rec) + return "outbox" + except Exception as spill_err: + raise RuntimeError( + f"DB insert failed ({db_err}) and outbox spill failed " + f"({spill_err})") + + +def do_push(): + os.makedirs(STATE_DIR, exist_ok=True) + lockf = open(LOCK, "w") + try: + fcntl.flock(lockf, fcntl.LOCK_EX | fcntl.LOCK_NB) + except BlockingIOError: + print(json.dumps({"pusher": "already-running"})) + return 0 + run_at = now_iso() + pending, landed, last_error = [], 0, None + total_landed = 0 + if os.path.exists(HEALTH): + try: + with open(HEALTH) as f: + total_landed = json.load(f).get("total_landed", 0) + except Exception: + total_landed = 0 + lines = [] + if os.path.exists(OUTBOX): + with open(OUTBOX) as f: + lines = [ln for ln in f if ln.strip()] + if lines: + try: + base, key = db_config() + except Exception as e: + base, key, last_error = None, None, f"db config: {e}" + for ln in lines: + try: + rec = json.loads(ln) + except Exception: + continue # unparseable line: drop, it can never land + if base is None: + rec["_attempts"] = rec.get("_attempts", 0) + 1 + rec["_last_error"] = str(last_error) + rec["_last_attempt_at"] = run_at + pending.append(rec) + continue + try: + insert_record(base, key, rec) + landed += 1 + except Exception as e: + rec["_attempts"] = rec.get("_attempts", 0) + 1 + rec["_last_error"] = str(e)[:300] + rec["_last_attempt_at"] = run_at + last_error = str(e)[:300] + pending.append(rec) + tmp = OUTBOX + ".tmp" + with open(tmp, "w") as f: + for rec in pending: + f.write(json.dumps(rec) + "\n") + os.replace(tmp, OUTBOX) + total_landed += landed + health = write_health( + last_run_at=run_at, + pending_count=len(pending), + last_error=last_error, + total_landed=total_landed, + **({"last_drain_ok_at": run_at} if not pending else {})) + print(json.dumps({"pusher": "ran", "landed": landed, + "pending": len(pending), + "last_error": last_error})) + return 0 + + +def do_status(): + health = {} + if os.path.exists(HEALTH): + with open(HEALTH) as f: + health = json.load(f) + depth = 0 + if os.path.exists(OUTBOX): + with open(OUTBOX) as f: + depth = sum(1 for ln in f if ln.strip()) + count = None + try: + base, key = db_config() + req = urllib.request.Request( + f"{base}/rest/v1/{TABLE}?select=id", + headers={"apikey": key, "Authorization": f"Bearer {key}", + "Accept-Profile": "agent", + "Prefer": "count=exact", "Range": "0-0"}) + with urllib.request.urlopen(req, timeout=TIMEOUT) as resp: + count = resp.headers.get("Content-Range", "").split("/")[-1] + except Exception as e: + count = f"unreachable ({e})" + print(json.dumps({"health": health, "outbox_depth": depth, + "db_rows": count}, indent=1)) + return 0 + + +FIELDS = ("sent_at", "identity", "channel", "destination", "item_ref", + "kind", "approval_basis", "approver", "approval_evidence", + "summary", "payload", "source") + + +def build_record(args): + rec = {"id": args.get("id") or uuid.uuid4().hex, + "sent_at": args.get("sent_at") or now_iso(), + "source": args.get("source") or "record-external-send"} + for f in FIELDS: + if f in ("sent_at", "source"): + continue + v = args.get(f) + if v is not None: + rec[f] = v + missing = [f for f in ("identity", "channel", "destination", "kind", + "approval_basis", "summary") if not rec.get(f)] + if missing: + raise SystemExit(f"record-external-send: missing required " + f"field(s): {', '.join(missing)}") + if isinstance(rec.get("payload"), str): + rec["payload"] = json.loads(rec["payload"]) + return rec + + +def parse_flags(argv): + args = {} + i = 0 + while i < len(argv): + a = argv[i] + if not a.startswith("--"): + raise SystemExit(f"unexpected argument: {a}") + key = a[2:].replace("-", "_") + if i + 1 >= len(argv): + raise SystemExit(f"flag {a} needs a value") + args[key] = argv[i + 1] + i += 2 + return args + + +USAGE = """usage: + record-external-send --identity drew|fleet: --channel + --destination --kind --approval-basis --summary + [--item-ref ] [--approver ] [--approval-evidence ] + [--sent-at ] [--id ] [--payload ] + [--source ] + record-external-send record-many + record-external-send push # drain the outbox (the pusher) + record-external-send status # health + outbox depth + DB rows""" + + +def main(argv): + if not argv: + raise SystemExit(USAGE) + cmd = argv[0] + if cmd == "push": + return do_push() + if cmd == "status": + return do_status() + if cmd == "record-many": + if len(argv) != 2: + raise SystemExit(USAGE) + landed_db = landed_outbox = 0 + with open(argv[1]) as f: + for ln in f: + if not ln.strip(): + continue + rec = build_record(json.loads(ln)) + if do_record(rec) == "db": + landed_db += 1 + else: + landed_outbox += 1 + print(json.dumps({"recorded_db": landed_db, + "spilled_outbox": landed_outbox})) + return 0 + # default: a single record; argv are --flag value pairs + rec = build_record(parse_flags(argv)) + where = do_record(rec) + print(json.dumps({"id": rec["id"], "landed": where})) + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:]))