Skip to content

feat(cli): add the outbound webhook outbox store - #926

Merged
ajianaz merged 1 commit into
developfrom
feat/webhook-outbox-store
Nov 18, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/webhook-outbox-store

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 4a of #911: webhook_out::store, the only code that opens <cron dir>/outbox.jsonl. Nothing calls it yet; the sender (next PR) and the tick wiring follow.

Why

The outbox is a file other processes of the same account can also write, and the sender signs whatever it finds. Keeping the file I/O in one small, independently reviewed module, with its own tests, keeps the sender PR focused on sending. The sender part was split out of this PR to keep each one small for review.

Changes

  • Outbox::append: one write per call under the blocking outbox.lock; a torn tail is ended with a newline before the next line.
  • Outbox::enqueue: atomic check-then-append under the lock. A duplicate (destination, id) is skipped in any state; refused at 10 000 pending per destination or 64 MiB.
  • Outbox::lease_due: takes the lock with try_lock (a second drainer does nothing), marks past-deadline events dead:expired, and leases one due event per destination. A destination that is not configured is never leased.
  • The file is untrusted: mode 0600, never followed through a symlink, never blocked on (a planted FIFO), read only as a regular file, and refused when far over its cap instead of read into memory.
  • A ledger row is only offered for a fire whose event id matches the body (cron_event_id is a pure function of the fire id), so a forged line cannot name another run.
  • Destination gains a key source: the name of the variable or the path, never the secret, so the sender can re-read it per attempt.
  • The fold bounds a result line's next_at like a lease, so a forged far-future value cannot park an event.
  • CHANGELOG entry.

Testing

  • 17 new unit tests: enqueue and duplicates, torn tail, 0600 and symlink refusal, leasing per destination and its expiry, unconfigured destination, past-deadline events, lock contention, missing file, forged and cut fire ids, FIFO / symlink / sparse-huge file, Debug shows no body, and the next_at bound.
  • Full cargo test -p tole-cli passes, clippy clean, layering test passes.
  • Independent read-only review of the combined store and sender (as the design asks for the outbox data path). It found two major defects: an unbounded, symlink-following read of the file (fixed here) and a double-send window between a result line and its terminal line (fixed in the sender PR), plus minor ones; all are applied.

Part 4a of #911. webhook_out::store is the only code that opens the
outbox file. Appends take the blocking lock for the short write; enqueue
is an atomic check-then-append that refuses a duplicate and refuses at
the queue and file caps; lease_due takes the lock with try_lock and
leases one due event per destination, marking past-deadline events dead.

The file is untrusted: private, never followed through a symlink, never
blocked on, read only as a regular file and refused far over its cap, and
a torn tail is ended before the next line. A ledger row is only offered
for a fire whose event id matches the body.

Destination gains a key source (the name of a variable or a path, never
the secret) and the fold bounds a result line next_at like a lease.

Nothing calls the store yet.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit e830887 into develop Nov 18, 2026
27 checks passed
@ajianaz
ajianaz deleted the feat/webhook-outbox-store branch November 20, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant