fed-sx-m2: Step 4d — outbox listing from log + pagination + 8 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Per-actor GET /actors/<id>/outbox now reads the bucket's log via
new nx_kernel:log_state_for/1 gen_server export and renders the
paged CID list.
nx_kernel additions:
log_state_for/1 gen_server call returning {ok, LogState} for
the named actor (mirrors log_tip_for/1's shape).
http_server additions:
- with_request_query/2 bakes Req's :query binary into Cfg as
{request_query, Q} so sub-resource handlers can parse params
without taking the Req as another arg
- kernel_actor_log_data/2 -> {Tip, Entries} via
nx_kernel:log_tip_for + log_state_for + log:entries
- parse_page/1 reads ?page=N (default 1, non-digits -> 1)
- page_size/0 returns 5 (test-friendly; production picks 20+)
- page_slice/2 + drop_take/3 + take/2 for the page extraction
- entry_cids/1 maps entries to :id CID binaries via envelope
- actor_outbox_full_response_for/5 renders text / JSON / SX:
text: outbox: <id>\ntip: N\npage: P\nitem: <cid>\n...
json: {"outbox":"<id>","tip":N,"page":P,"items":[...]}
sx: (outbox "<id>" :tip N :page P :items (...))
Empty page degrades to actor_outbox_with_tip_response_for so
epochs 50-57 from Step 4c still pass — the prefix is preserved.
8 new cases in next/tests/http_multi_actor.sh (41/41 total):
- 1 publish -> body contains outbox/tip=1/page=1/item: prefix
- 3 publishes -> body contains tip=3/page=1/item: prefix
- page=2 with 3 items -> empty page degrades to tip-only body
- 6 publishes page=1 -> tip=6/page=1/item: prefix
- 6 publishes page=2 -> tip=6/page=2/item: prefix
- JSON body shape with items array (1 entry)
- SX body shape with :items list (1 entry)
- bad ?page=bad falls back to page 1
Conformance 761/761. 117/117 across 11 Step-4-adjacent suites
(http_multi_actor, http_route, http_publish, http_post_format,
http_marshal, http_publish_fold, http_listen_bif, http_server_start,
nx_kernel_multi, nx_kernel_server, bootstrap_start, actor_lifecycle).
Substrate gotcha logged: named recursive funs fun F(...) -> F(...)
end aren't supported by the parser ('fun-ref syntax not yet
supported'); binary:matches/2 and lists:foreach/2 aren't registered.
Tests prove behaviour via match_prefix substring checks rather than
counting occurrences.
This commit is contained in:
@@ -300,10 +300,19 @@ token; the token now maps to an `:actor_id` rather than a fixed `alice`.
|
||||
delivery); the live handler does a bare `nx_kernel:log_tip_for/1`
|
||||
+ integer guard instead. 8 new cases in `http_multi_actor.sh`
|
||||
(33/33 total).
|
||||
- [ ] **4d** — Per-actor outbox listing reads from the named
|
||||
bucket's log entries via `nx_kernel:actor_log_state/2`, content-
|
||||
negotiates as today (text / json / sx). `?page=N` pagination
|
||||
layered on top using `log:replay/3`.
|
||||
- [x] **4d** — Per-actor outbox listing reads from the named
|
||||
bucket's log entries via new `nx_kernel:log_state_for/1`
|
||||
gen_server export. `actor_outbox_full_response_for/5` renders
|
||||
text / JSON / SX bodies with `:tip`, `:page`, and the page's
|
||||
`:items` CID list. Empty pages degrade to the 4c tip-only body
|
||||
to preserve back-compat with epochs 50-57. `?page=N` pagination
|
||||
parsed at `route/2` time and threaded via Cfg as
|
||||
`{request_query, Q}`; `page_size/0` returns 5 (proof of concept
|
||||
— production picks 20+). 8 new cases in `http_multi_actor.sh`
|
||||
(41/41 total). Substrate gotcha: named recursive funs
|
||||
`fun F(...) -> ... F(...) end` not supported; `binary:matches/2`
|
||||
and `lists:foreach/2` not registered — tests prove behaviour
|
||||
via `match_prefix` substring checks rather than counting.
|
||||
- [ ] **4e** — POST /actors/<id>/inbox stays a 202 stub for 4a-4d.
|
||||
Step 5 lands the real ingestion pipeline (sig verify + inbox-
|
||||
bucket append + projection broadcast).
|
||||
@@ -749,6 +758,23 @@ proceed.
|
||||
|
||||
Newest first.
|
||||
|
||||
- **2026-06-06** — Step 4d: per-actor outbox listing + pagination.
|
||||
New `nx_kernel:log_state_for/1` gen_server export returns
|
||||
`{ok, LogState}` for an actor. `actor_outbox_response_for/3`
|
||||
now extracts `{Tip, Entries}` via `kernel_actor_log_data/2`,
|
||||
parses `?page=N` from the Req's `:query` field (threaded
|
||||
through Cfg as `{request_query, Q}`), and renders a paged
|
||||
body. Text body adds `page: N\nitem: <cid>\n...`; JSON adds
|
||||
`"page":N,"items":[...]`; SX adds `:page N :items (...)`.
|
||||
Empty pages (out-of-range or actor-with-no-publishes) degrade
|
||||
back to the 4c tip-only shape, preserving epochs 50-57.
|
||||
`page_size/0` is 5 for tests (production picks 20+). 8 new
|
||||
cases in `http_multi_actor.sh` (41/41 total). Conformance
|
||||
761/761. 117/117 across 11 Step-4-adjacent suites. **Gotcha**
|
||||
noted: named recursive funs `fun F(...) -> ... F(...) end`
|
||||
fail with "fun-ref syntax not yet supported"; `binary:matches/2`
|
||||
and `lists:foreach/2` aren't registered in this substrate.
|
||||
|
||||
- **2026-06-06** — Step 4c: route/3 with kernel access.
|
||||
`http_server:route/3(Req, Cfg, Kernel)` folds the kernel
|
||||
reference into Cfg as `{kernel, _}`. Dispatch chain refactored
|
||||
|
||||
Reference in New Issue
Block a user