fed-sx-m2: Step 9b — outbox ?since=Cid pagination + 3 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s

actor_outbox_response_for/3 in http_server.erl now reads ?since=
from the query string before paging:

  Q       = field(request_query, Cfg),
  Filtered = case parse_since(Q) of
      nil      -> Entries;
      SinceCid -> backfill:since_cid_entries(SinceCid, Entries)
  end,
  Slice = page_slice(Filtered, Page),
  ...

New helpers:
  parse_since/1   — scan query for since=<Cid>, value is the
                    binary up to next & or end-of-binary. nil
                    when absent.
  scan_param/2,3  — generic 'find Name=Value anywhere in &-sep
                    query'. Used for since= today; could be
                    factored over parse_page=.
  skip_to_amp/1   — walk past the next & for the iteration step.

Order-independent: ?since=X&page=2 and ?page=2&since=X both
work. Unknown cid -> backfill:since_cid_entries returns []
-> empty page -> body degrades to tip-only shape (Step 4d
back-compat).

Three new cases in http_multi_actor.sh (44/44 total):
  - ?since=<first cid> filters out the first publish, leaving
    2 of 3 items in the paged response
  - ?since=<unknown cid> -> empty page; body has tip but no
    item: lines (tip-only degrade)
  - ?since=<cid> + ?page=1 combined — pagination still applies
    to the filtered list

Latent issue surfaced + fixed in passing: http_multi_actor.sh
was missing follower_graph + delivery + backfill module loads
(outbox has depended on follower_graph + delivery since Step 7c
and now backfill from 9a). Added all three with epoch 100/101/
102 to match the c6b49200 fix-up pattern. 41 existing tests now
also exercise the live path through outbox:publish without
crashing on missing module deps.
This commit is contained in:
2026-06-07 06:28:47 +00:00
parent 9621599606
commit 3629b2923f
3 changed files with 99 additions and 8 deletions

View File

@@ -702,9 +702,14 @@ actor_outbox_response_for(Id, F, Cfg) ->
nil ->
actor_outbox_response_for(Id, F);
{Tip, Entries} ->
Page = parse_page(field(request_query, Cfg)),
Slice = page_slice(Entries, Page),
Cids = entry_cids(Slice),
Q = field(request_query, Cfg),
Page = parse_page(Q),
Filtered = case parse_since(Q) of
nil -> Entries;
SinceCid -> backfill:since_cid_entries(SinceCid, Entries)
end,
Slice = page_slice(Filtered, Page),
Cids = entry_cids(Slice),
actor_outbox_full_response_for(Id, F, Tip, Page, Cids)
end
end.
@@ -754,6 +759,45 @@ parse_page(Q) when is_binary(Q) ->
end;
parse_page(_) -> 1.
%% parse_since/1 — Step 9b. Look up the `?since=Cid` value anywhere
%% in the query string (handles `since=X&page=2` and `page=2&since=X`
%% identically). Returns the Cid binary or `nil` if absent.
parse_since(nil) -> nil;
parse_since(Q) when is_binary(Q) ->
Prefix = <<115,105,110,99,101,61>>, % "since="
case scan_param(Prefix, Q) of
{ok, V} -> V;
_ -> nil
end;
parse_since(_) -> nil.
%% scan_param/2 — find `Name=Value` anywhere in a `&`-separated
%% query string. Value runs to the next `&` or end-of-binary.
scan_param(Name, Q) -> scan_param(Name, Q, true).
scan_param(_, <<>>, _) -> not_found;
scan_param(Name, Bin, AtStart) ->
case AtStart of
true ->
case match_prefix(Name, Bin) of
{ok, Rest} -> {ok, take_until_amp(Rest)};
_ -> after_amp(Name, Bin)
end;
false -> after_amp(Name, Bin)
end.
after_amp(Name, Bin) ->
case skip_to_amp(Bin) of
{ok, Rest} -> scan_param(Name, Rest, true);
_ -> not_found
end.
skip_to_amp(<<>>) -> not_found;
skip_to_amp(<<38, Rest/binary>>) -> {ok, Rest};
skip_to_amp(<<_, Rest/binary>>) -> skip_to_amp(Rest).
parse_int(Bin) ->
L = binary_to_list(Bin),
case L of