Skip to content

External-comms send-time ledger: agent.external_comms + outbox spill + pusher (laptop) #6130

Closed

Description

@dezren39

Implements Drew's ratified rule EXTERNAL COMMS ARE NEVER SILENT (2026-11-05; ~/AGENTS.md, ~/memory/topics/external-comms-rule-2026-11-05.md), from the 2026-11-05 external-comms audit. Drew's implementation direction: "use database spill to outbox or use outbox always ensure pusher. all on laptop."

Design

Pattern: database-first with spill to outbox — the proven pm-stack pattern (aggregator events.ts retry outbox: store first, durable JSONL outbox on failure, flush merged by stable id). Chosen over outbox-always because audits/dashboards read the DB, so the common path should land there instantly, while no record can be lost to a DB outage at send time.

  • Table: agent.external_comms in Supabase muse-dev2 (fleet ops schema beside agent.tasks/agent.quota_records). Columns: id (stable, PK), sent_at, recorded_at, identity (drew | fleet:<name>), channel, destination, item_ref, kind, approval_basis, approver, approval_evidence, summary, payload jsonb, source. Migration: pm-stack/external-comms/migration-0001-agent-external-comms.sql.
  • Writer: pm-stack/external-comms/record-external-send (laptop, deployed from the primary clone). Direct PostgREST insert; service-role key resolved by name via the secrets broker (supabase.muse-dev2.service-role-key), never on disk. On any failure: append to ~/.local/state/external-comms/outbox.jsonl (fsync) and still exit 0 — recording never blocks the send it logs.
  • Pusher: record-external-send push under systemd user timer external-comms-pusher.timer (every minute, units in pm-stack/external-comms/). Drains the outbox with ignore-duplicates on the id PK; failures keep _attempts/_last_error. Every run rewrites the health surface: ~/.local/state/external-comms/pusher-health.json (last_run_at, last_drain_ok_at, pending_count, last_error, total_landed) — a stuck pusher is a stale health file + pending > 0, readable by the stewardship visibility pass.
  • Recording contract: documented in pm-stack/external-comms/README.md and in the rule topic file; email approvals carry approver + evidence explicitly.

Backfill

The 68 sends enumerated by the audit are loaded from pm-stack/external-comms/backfill-2026-11-05.jsonl: opencode#176 (basis: none — unsanctioned at the time, surfaced retroactively), 3 Gmail sends (06:19 Crunchyroll = no recorded approval; 07:39 = Drew tapped Send; 1 personal = Drew's own), 9 Slack sends to Aster (Aster allowlist / Drew-directed), 55 OpenClaw Slack sends (52 autonomous heartbeat deliveries = standing-system-delivery, ratified unchanged by Drew 2026-11-05; 2 #alignment directed-test posts via queue task 7858; 1 reply to Drew). OpenClaw timestamps come from its own channel_ingress_events echo log, cross-checked against the audit's per-message times.

Proof

  • Blocked-path: record with the DB URL pointed at a dead port -> lands in outbox -> pusher (after restore) lands it in the table; test rows deleted after proof.
  • Normal-path: record lands directly in the DB.
  • Pusher health file updates every run; timer active on the laptop.

Activity

  1. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  2. added a commit that references this issue on Nov 5, 2026
  3. added a commit that references this issue on Nov 5, 2026
  4. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Built, deployed, proven (2026-11-05)

    PRs: #6131 (ledger: CLI + pusher units + migration + backfill data, merged 893f4b9) · #6138 (hardening found by the backfill itself, merged 835a072).

    Table: agent.external_comms applied to muse-dev2 via migration-0001-agent-external-comms.sql, verified: 14 columns, RLS on, service_role granted. Pattern chosen: database-first with spill to outbox (pm-stack events.ts precedent) over outbox-always — audits read the DB, so the common path lands there instantly; the outbox exists purely so a send-time record can't be lost to an outage.

    Blocked-path proof: record with the DB URL pointed at a dead port (127.0.0.1:9) -> {"landed": "outbox"}, exit 0, record fsync'd in ~/.local/state/external-comms/outbox.jsonl. Pusher (real config) then landed it: visible in the table with the spilled record's id. A second, normal-path record landed directly ("landed": "db"). Both test rows were deleted after proof (verified count back to 0 before backfill).

    Pusher: external-comms-pusher.timer active on the laptop, firing every minute (journal-verified), health file ~/.local/state/external-comms/pusher-health.json fresh: pending_count 0, last_error null, total_landed 11 (1 proof record + 10 backfill spills).

    Backfill: 68 rows — github/drew 1 · gmail/drew 3 · slack/drew 9 · slack/fleet:openclaw 55. By basis: standing-system-delivery (ratified unchanged) 52 · allowlist:aster-arrangement 5 · per-item (Drew-directed) 4 · directed test (task 7858) 2 · reply to Drew 1 · Drew's own 1 · per-item approval 1 (Gmail 07:39) · none-recorded 1 (Gmail 06:19) · none-unsanctioned 1 (#176). OpenClaw timestamps are from its own channel_ingress_events echo log, cross-checked per-message against the audit (Nov 1 split resolved exactly: 18 sends + 3 inbound notifications).

    Found + fixed en route: fleet secrets get fails transiently (exit 3) under burst — 10 of 68 backfill records spilled on secret-resolution failure (not DB failure) and waited in the outbox. Fix in #6138: secrets resolved once per process (136 broker calls -> 2 per batch) + 3x retry with backoff, mirroring the queue broker. The pusher then drained all 10.

    Contract: any lane records a send with one command —
    record-external-send --identity drew|fleet:<name> --channel <c> --destination <d> --kind <k> --approval-basis <b> --summary <s> [--item-ref <url>] [--approver <who>] [--approval-evidence <ref>]
    — full text in pm-stack/external-comms/README.md and the rule topic file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions