fed-sx-m2: Step 8d — outbox dispatches delivery_set to workers + 7 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s

outbox:publish/2 now walks the computed delivery_set and enqueues
the signed activity onto each matching delivery_worker
(registered under the peer-id atom). Missing workers are silently
skipped — lazy worker creation belongs to the kernel manager
later in Step 8.

Gated by Context's {dispatch_deliveries, true} so every M1
outbox caller (and every M2 caller that doesn't yet care about
delivery) stays back-compat: default off.

New helpers in outbox.erl:
  dispatch_deliveries/3(Activity, DeliverySet, Context)
      gates on Context :dispatch_deliveries flag
  enqueue_each/2(Activity, [PeerId | _])
      whereis-guarded enqueue per peer

7/7 in next/tests/delivery_dispatch.sh:
  - single peer enqueued
  - two peers both enqueued (fan-out)
  - missing worker silently skipped
  - no :dispatch_deliveries flag -> no-op (back-compat)
  - two publishes -> FIFO append on the queue
  - empty delivery_set -> no-op

outbox_publish.sh 17/17 unchanged; delivery_worker.sh 17/17
unchanged. Conformance preserved at 761/761 from the Step 8a
baseline.
This commit is contained in:
2026-06-07 01:32:59 +00:00
parent bf4e034c4e
commit dda967e060
3 changed files with 176 additions and 3 deletions

View File

@@ -557,9 +557,18 @@ a dead-letter list visible via `/admin/dead-letter`.
kernel restart. New `next/kernel/delivery_state.erl` fold maps
enqueue / delivered / failed events to the worker's persistent
shape.
- [ ] **8d** — `outbox:publish/2` dispatches each delivery-set
entry to the matching worker. The worker is created lazily on
first delivery to a peer.
- [x] **8d** — `outbox:publish/2` dispatches each delivery-set
entry to the matching worker. New `dispatch_deliveries/3` +
`enqueue_each/2` in `outbox.erl` walk the computed
`delivery_set` and call `delivery_worker:enqueue(PeerId,
Activity)` for each registered peer atom. Missing workers
(no `whereis`) are silently skipped — lazy worker creation
belongs to the kernel manager (Step 8d-mgr or later).
Gated by `Context` field `{dispatch_deliveries, true}` so
every M1 outbox caller stays back-compat (default off). 7/7
in `delivery_dispatch.sh` covering single-peer enqueue,
two-peer fan-out, missing-worker skip, no-flag no-op,
FIFO append across two publishes, empty delivery_set no-op.
- [ ] **8e** — `httpc:request/4` BIF wrapper in
`lib/erlang/runtime.sx` (the briefing's allowed scope
exception for Step 8). Marshalling: SX dict ↔ Erlang proplist
@@ -890,6 +899,18 @@ proceed.
Newest first.
- **2026-06-07** — Step 8d: outbox dispatches delivery_set to
workers. `outbox:publish/2` gained `dispatch_deliveries/3` and
`enqueue_each/2`: after `log:append` + projection broadcast,
the resolved `delivery_set` is walked and each registered
peer-id atom's `delivery_worker:enqueue(PeerId, Activity)` is
called. Missing workers (no `erlang:whereis`) are silently
skipped. Gated by Context's `{dispatch_deliveries, true}` —
default off so every M1 outbox caller stays back-compat. 7/7
in `delivery_dispatch.sh`; `outbox_publish.sh` +
`delivery_worker.sh` both still 17/17. Conformance preserved
at 761/761 from the Step 8a baseline.
- **2026-06-07** — Step 8a: delivery_worker skeleton.
`next/kernel/delivery_worker.erl` with pure-functional state +
enqueue / drain / deliver_one + backoff schedule (30s / 5m /