Skip to content

SSR cache: name parked nodes to the consumer, keep found profile lists longer - #134

Merged
feruzm merged 3 commits into
mainfrom
feat/ssr-cache-ttl-node-parks
Nov 26, 2026
Merged

feruzm merged 3 commits into
mainfrom
feat/ssr-cache-ttl-node-parks

Conversation

@feruzm

@feruzm feruzm commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

What

Two changes to the internal SSR read-through cache (/private-api/ssr/rpc):

  1. Rate-limited nodes are named to the consumer. Every answer now carries X-Ssr-Node-Parks: authority=ms,..., listing the nodes the cache's own client has parked for rate limiting and for how long. Failure parks are left out, because they follow the cache's own short per-node timeouts, and a consumer with longer timeouts may still get an answer from that node. The web tier falls back to its own node pool when the cache cannot answer. With this header, that fallback can skip nodes the cache already knows are throttling, instead of learning it again with a request of its own. The route is secret-gated, and the header is absent when every node is available.
  2. Found profile lists live longer. bridge.get_profiles answers that contain the account are cached for an hour instead of a minute. A post render reads its author's profile list, and the same author repeats across renders well past a minute. An empty answer (an account a node does not know yet) keeps the short TTL.

What does not change

  • bridge.get_profile stays short, because the full-account read cross-checks it against condenser_api.get_accounts, and the two must stay equally fresh.
  • Post reads stay short at any post age, because a post can be edited after payout.

Tests

  • The header is present for a throttled pool and absent for a healthy one. A failure-parked node is not reported.
  • The long TTL applies only to a non-empty get_profiles answer.
  • Only get_profiles has a long TTL.
  • Each guard was mutation-checked. The full suite passes.

Summary by CodeRabbit

  • New Features
    • Complete profile lists are now cached for up to one hour, while incomplete or empty results retain the shorter cache period.
    • RPC responses can include an X-Ssr-Node-Parks header showing nodes temporarily parked due to rate limits and their remaining park durations. The header is omitted when no nodes are rate-limit parked.
  • Bug Fixes
    • Failure-related node parks are no longer included in rate-limit park duration reporting.

…s longer

Every /private-api/ssr/rpc answer now carries X-Ssr-Node-Parks with the
nodes the cache's client is keeping out of rotation and for how long, so
the web tier's fallback can skip them instead of drawing its own 429s
from the same nodes.

bridge.get_profiles answers that found the account are kept for an hour
instead of a minute: a post render reads the author's profile list, and
the same author repeats across renders well beyond a minute. An empty
list keeps the short TTL. get_profile and the post reads stay short.
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T08:07:32.700734Z 32ce5e3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Expose parked SSR nodes and extend TTL for found profile lists

✨ Enhancement 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Expose parked node authorities and remaining park times so consumers can avoid them during
 fallback.
• Cache non-empty bridge.get_profiles results for an hour while keeping empty results and other
 reads short-lived.
• Test parked-node headers, conditional profile-list expiry, and the scope of the longer TTL.
Merge Risk 🟡 Medium

Blast radius 🟡 Medium 💥 2 capabilities

  • 2 affected capabilities within one bounded functional scope: SSR Hive read caching integration.
  • The changed profile-list cache policy directly controls the end-to-end profile metadata read used by SSR rendering; the predicate and cache write are implementation hops of that same outcome.
  • The changed health snapshot, serialization, and response header together form one end-to-end fallback-coordination behavior for SSR callers; they are not independent capabilities merely because they span classes.
Behavioral complexity 🟡 Medium 🧩 Interacting branches

  • Before, every get_profiles result used the same short TTL.
  • After, cache lifetime depends on both request account names and the returned profile objects.
  • New correctness condition: a long-lived entry is allowed only when every requested account is represented by a valid matching name; incomplete results must remain short-lived.
  • The set comparison and cache pipeline are existing mechanisms, but the request/result-dependent freshness state is newly introduced.
Potential damage 🟡 Medium 🩹 Recoverable

  • If the new coordination behavior regresses, a fallback consumer may retry a node already rate-limit parked by the cache client, causing avoidable 429s, latency, or temporary fallback failure.
  • The source establishes the park data and header format, but the external consumer is not present for verification.
  • Reverting the header behavior restores the prior contract, but callers that do not receive usable park information may need to retry or wait for rate-limit windows to expire.
Assessed commit c412ee7
Diagram

graph TD
  Renderer["Web renderer"] --> Route["SSR RPC route"] --> Cache["Read-through cache"] --> Client["Hive RPC client"] --> Nodes["Hive nodes"]
  Client --> Health["Node health"] -->|park durations| Route
  Route -->|parks header| Renderer
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Poll the existing health stats endpoint
  • ➕ Avoids adding a header to each SSR RPC response.
  • ➖ Requires separate requests and may give the consumer stale park information.

Recommendation: Keep the response-header approach: it gives the consumer park information alongside the read that may trigger fallback, without another request. The existing health tracker is also the right source for both rate-limit and failure parks.

Files changed (4) +119 / -3

Enhancement (3) +73 / -3
SsrRpc.csApply result-dependent profile TTL and emit node parks +28/-3

Apply result-dependent profile TTL and emit node parks

• Adds a conditional long-TTL policy for non-empty 'bridge.get_profiles' results while leaving other reads on their existing TTLs. Authorized, allowlisted RPC responses now include 'X-Ssr-Node-Parks' when the client has parked nodes.

dotnet/EcencyApi/Handlers/SsrRpc.cs

HiveRpcClient.csFormat unavailable nodes for the SSR response header +25/-0

Format unavailable nodes for the SSR response header

• Adds a method that converts positive per-node park durations into comma-separated 'authority=ms' pairs. It returns null when no node is parked.

dotnet/EcencyApi/Infrastructure/HiveRpcClient.cs

NodeHealthTracker.csExpose remaining rate-limit and failure park durations +20/-0

Expose remaining rate-limit and failure park durations

• Adds a locked snapshot of each node's remaining unavailable time, using the later of its rate-limit and failure-park deadlines.

dotnet/EcencyApi/Infrastructure/NodeHealthTracker.cs

Tests (1) +46 / -0
SsrRpcTests.csCover parked-node headers and conditional profile-list TTLs +46/-0

Cover parked-node headers and conditional profile-list TTLs

• Tests that a throttled node appears in the response header and a healthy pool produces no header. Verifies that non-empty profile lists outlive the short TTL, empty lists do not, and no other allowlisted method gains a long TTL.

dotnet/EcencyApi.Tests/SsrRpcTests.cs

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues remain in the reviewed changes.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain in the reviewed changes.

Summary

The PR adds X-Ssr-Node-Parks and keeps complete bridge.get_profiles answers for an hour.

  • SSR RPC responses name nodes that are parked for rate limits.
  • Complete profile lists stay cached for an hour.

Reviews (3) · Last reviewed commit: "Keep a profile list long only when it na..." · Reviewed by Greptile

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (1) 📜 Skill insights (0)

Grey Divider


Action required

1. Fallback retries parked nodes 🔗 Cross-repo conflict ≡ Correctness
Description
SsrRpc.Rpc adds X-Ssr-Node-Parks, but vision-web reads only X-Ssr-Cache from a failed proxy
response and never applies the parked-node list. When the cache reports an upstream rate limit or
failure, the web fallback can select the same node from its own pool.
Code

dotnet/EcencyApi/Handlers/SsrRpc.cs[512]

+        if (Client.UnavailableNodesHeader() is { } parks) ctx.Response.Headers["X-Ssr-Node-Parks"] = parks;
Evidence
The API emits the header, whereas the web SDK reads a different response header and chooses fallback
nodes solely from its local health order.

vision-api -> vision-web
dotnet/EcencyApi/Handlers/SsrRpc.cs[510-512]
dotnet/EcencyApi/Infrastructure/HiveRpcClient.cs[98-111]
External repo: ecency/vision-web, packages/sdk/src/hive-tx/helpers/call.ts [150-155]
External repo: ecency/vision-web, packages/sdk/src/hive-tx/helpers/call.ts [1855-1873]
External repo: ecency/vision-web, packages/sdk/src/hive-tx/helpers/call.ts [1889-1900]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The API sends parked-node authorities and remaining durations, but vision-web discards the header before selecting fallback nodes.
## Fix Focus Areas
- dotnet/EcencyApi/Handlers/SsrRpc.cs[510-512]
- dotnet/EcencyApi/Infrastructure/HiveRpcClient.cs[98-111]
- /cross_repos/vision-web/packages/sdk/src/hive-tx/helpers/call.ts[150-155]
- /cross_repos/vision-web/packages/sdk/src/hive-tx/helpers/call.ts[1885-1900]
## Recommended Fix
Update vision-web’s SSR proxy path to parse `X-Ssr-Node-Parks` on proxy responses, retain each authority’s remaining park time, and exclude matching nodes during fallback selection while the park lasts. Coordinate deployment so the consumer can use the API’s new header.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Fallback can skip the whole node pool ✓ Resolved
Description
UnavailableForMs() reports every active failure park even when OrderedNodeIndices() deliberately
offers all nodes again because the entire pool is failure-parked. If the web tier skips every
authority named by X-Ssr-Node-Parks, it has no fallback candidate in precisely the outage state
where the cache still attempts recovery.

3. New accounts stay missing in mixed lists ⊘ Outdated
Description
IsNonEmptyList() grants the one-hour TTL to any nonempty bridge.get_profiles result, without
checking whether it contains every requested account. A batch containing a known account and an
account the node does not yet know can therefore cache the partial answer under their shared request
key, delaying a retry for the missing account until expiry.

4. New posts stay unindexable longer ✓ Resolved
Description
bridge.get_profiles now caches any nonempty profile list for an hour, while vision-web uses that
list’s post_count and reputation to decide whether an entry emits noindex. If an author
crosses the posting-history or reputation threshold during that hour, subsequent renders can
continue using the old indexing decision.

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The SSR RPC cache uses a one-hour TTL for complete bridge.get_profiles results. RPC responses include X-Ssr-Node-Parks when nodes have positive remaining rate-limit park durations.

Changes: SSR RPC behavior

Layer / File(s) Summary
Profile-list cache TTLs
dotnet/EcencyApi/Handlers/SsrRpc.cs, dotnet/EcencyApi.Tests/SsrRpcTests.cs
bridge.get_profiles uses a one-hour TTL when the result contains every requested account. Other results use the regular TTL. Tests cover completeness, cache expiry, and TTLs for other allowlisted methods.
Rate-limit park response header
dotnet/EcencyApi/Infrastructure/NodeHealthTracker.cs, dotnet/EcencyApi/Infrastructure/HiveRpcClient.cs, dotnet/EcencyApi/Handlers/SsrRpc.cs, dotnet/EcencyApi.Tests/SsrRpcTests.cs
The health tracker returns remaining rate-limit park durations. The RPC client formats positive durations as authority-and-millisecond pairs, excluding failure parks. The handler adds X-Ssr-Node-Parks when those pairs exist. Tests check the header and its absence for a healthy pool.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SsrRpc
  participant HiveRpcClient
  participant NodeHealthTracker
  participant RPC caller
  SsrRpc->>HiveRpcClient: RateLimitedNodesHeader()
  HiveRpcClient->>NodeHealthTracker: RateLimitedForMsAll()
  NodeHealthTracker-->>HiveRpcClient: Remaining rate-limit park durations
  HiveRpcClient-->>SsrRpc: Authorities and positive durations, or null
  SsrRpc-->>RPC caller: X-Ssr-Node-Parks when header data exists
Loading

Possibly related PRs

  • ecency/vision-api#124: Changes rate-limit park classification and SSR RPC failure handling, which share park state with the header added here.
  • ecency/vision-api#132: Changes how NodeHealthTracker sets rate-limit parks, which this PR reports.
Merge Risk: Minimal · up to c412e

This change caches complete profile lists for longer and reports rate-limited nodes in a response header. No actionable merge risk was identified, and the change is covered by new tests.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two main changes in the PR: parked nodes are reported to the consumer through a response header, and found profile lists are cached longer. Both appear in the raw summary and the P…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main changes in the PR: parked nodes are reported to the consumer through a response header, and found profile lists are cached longer. Both appear in the raw summary and the PR objectives. The title is specific and matches the changeset. It is a long title, but it is accurate and readable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the profile list,
Complete names earn a longer stay.
Parked nodes share their times in headers,
While failure parks stay out of view.
The cache waits; empty lists expire.
I nibble, then hop on my way.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 01159b9f-c2d2-496b-97dc-acf0f1b2ab94
Commits

Reviewing files that changed from the base of the PR and between 32ce5e3 and c412ee7.

Files selected for processing: 4

  • dotnet/EcencyApi.Tests/SsrRpcTests.cs
  • dotnet/EcencyApi/Handlers/SsrRpc.cs
  • dotnet/EcencyApi/Infrastructure/HiveRpcClient.cs
  • dotnet/EcencyApi/Infrastructure/NodeHealthTracker.cs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

A failure park follows the cache's own short per-node timeouts; the web
tier falls back with longer ones and may still get an answer from that
node, so only nodes throttling this address are named.
A node leaves out an account it does not know yet; the list is cached
under one key, so a partial answer keeps the short TTL.
@feruzm
feruzm merged commit 7a79920 into main Nov 26, 2026
5 checks passed
@feruzm
feruzm deleted the feat/ssr-cache-ttl-node-parks branch November 26, 2026 09:19
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