Skip to content

fix(piefed): normalize max_depth to canonical comment levels - #75

Merged
aeharding merged 2 commits into
mainfrom
piefed-max-depth
Jul 25, 2026
Merged

fix(piefed): normalize max_depth to canonical comment levels#75
aeharding merged 2 commits into
mainfrom
piefed-max-depth

Conversation

@aeharding

Copy link
Copy Markdown
Owner

max_depth is a canonical parameter, but the two servers count it from different places — so the same request returned a deeper tree on PieFed, and consumers had no way to know.

Verified live (my own probes, on piefed.social and the ds9.lemmy.ml v1 nightly), no parent_id:

max_depth Lemmy PieFed
0 nothing top-level
1 top-level top-level + children
2 2 levels 3 levels

With a parent_id they agree (0 → the parent alone, 1 → parent + children), so that path is untouched.

The PieFed adapter now requests one less when there's no parent_id. End-to-end through the client against both live servers after the change: max_depth: 1 → depth 1 on both, max_depth: 2 → depths 1–2 on both.

The fake's request decoder inverts the same adjustment so callsTo("getComments") payloads stay canonical — and the matrix test that previously had to pass mode === "piefed" ? 0 : 1 now passes 1 to both, which is the clearest statement that the divergence is gone. A new matrix test also pins that the canonical payload survives the wire adjustment.

Known edge: canonical max_depth: 0 ("no comments") has no PieFed equivalent — its minimum still returns top-level — so it clamps rather than going negative. Documented at the call site.

Consumer note: Voyager's e2e fixture currently encodes the old divergence (INITIAL_COMMENT_DEPTH 6 vs 7); that collapses to one value once this ships.

PieFed counts max_depth from below top-level while Lemmy counts from the
post, so the same canonical request reached a level deeper on PieFed —
consumers got comment trees one level bigger there, silently. Verified
live on piefed.social and ds9.lemmy.ml: max_depth=1 with no parent_id
returns top-level on Lemmy but top-level plus children on PieFed; with a
parent_id the two agree.

The piefed adapter now asks for one less when there's no parent_id, so
'levels of comments to return' means the same thing everywhere. Verified
end-to-end through the client against both live servers: max_depth=1 now
returns depth 1 on both, max_depth=2 returns depths 1-2 on both.

The fake's decoder inverts the same adjustment, keeping callsTo() payloads
canonical — and the matrix test that used to pass a provider-specific
depth now passes the same value to both.
…anches

Review catch: clamping canonical max_depth 0 onto piefed's wire 0
collapsed two inputs into one, so the fake's decoder — which has to
invert the adjustment — reported max_depth 1 for a request that asked for
0 (or -3). A decoder that can't be inverted breaks the promise that
callsTo() payloads are what the caller passed.

Zero levels now short-circuits: PieFed's shallowest response still
contains top-level comments, so there's nothing to ask it for. That also
makes the data uniform (Lemmy returns nothing for max_depth 0) and leaves
wire 0 unambiguously meaning canonical 1.

Coverage the review found missing: neither depth branch was round-trip
tested (the only getComments scenario passed no max_depth at all), and
nothing pinned the live semantics this rests on. Adds both decoder
scenarios, a matrix test for zero levels, and a live-smoke assertion that
max_depth 1 returns only top-level comments on every real instance.
@aeharding
aeharding merged commit 6437931 into main Jul 25, 2026
1 check passed
@aeharding
aeharding deleted the piefed-max-depth branch July 25, 2026 22:43
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