~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Proxying to the AppView and other services, service auth, preferences, and records checked against their lexicons

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:appw

The PDS as an app's server: forwarding to the AppView and other services, and checking records against their lexicons. Each was specified by an agent that probed the reference, checked by a harness against stub services, and built from the spec alone.

Spec pages (new)

  • PROXY.md
    • atproto-proxy routing: any method the PDS doesn't serve is forwarded. The target is resolved from a DID and service id (did:plc via the directory, did:web), with the never-forwarded list and a service-auth JWT signed with the account's key. The forwarded and returned headers are exactly as listed, with the reference's status mapping.
    • The default AppView: PDS_BSKY_APP_VIEW_URL/DID/CDN_URL_PATTERN.
    • getServiceAuth: aud, lxm, exp and app-password rules.
    • Preferences: getPreferences/putPreferences, durable, with personal details limited to full sessions.
    • Read-after-write: for getProfile(s), getAuthorFeed, getTimeline and getActorLikes, with Atproto-Upstream-Lag.
    • Repos not held here, and push: getRecord of a repo not held here, getFeed, registerPush/unregisterPush.
    • SSRF: every outbound fetch is guarded unless PDS_DISABLE_SSRF_PROTECTION.
  • VALIDATION.md
    • Records are checked against the 36 record lexicons the reference knows, vendored under spec/lexicons (app.bsky, chat.bsky declarations, label and lexicon records, and the third-party ones the reference ships).
    • validate and validationStatus: validate may be undefined, true or false; validationStatus is valid or unknown.
    • Where the check sits: after the repo and $type checks.
    • Rules: record keys, open and closed unions, string formats, grapheme limits, blob constraints, and language tags exactly as the reference parses them.
    • The follow/block/like/repost dedup: a create deletes the account's other records of the same subject in the same commit.
    • Interop vectors: atproto's syntax vectors are vendored in spec/interop/syntax, with the reference's cid and uri differences noted.

Server

  • New modules: proxy.rs, read_after_write.rs, preferences.rs (a new accounts.log entry, byte-cut tested), outbound.rs, validation.rs, and the validator extended in pds-lexicon (graphemes via unicode-segmentation).
  • Outbound calls: bounded and timed out, with no lock held across them.
  • Hardening applies: forwarded calls pay the global rate limit, and putPreferences is under the free-space floor.
  • OAuth:
    • rpc: scopes gate forwarded calls and getServiceAuth;
    • OAuth's client-document fetch uses the same SSRF-safe client.

Harness

  • Stub services: lib/services.mjs, an AppView and a chat service that record what each side sends.
  • checks/proxy.mjs: headers, JWT claims, statuses, read-after-write and preferences.
  • checks/validation.mjs:
    • random app.bsky records, valid and broken in every rule family, under each validate value;
    • the dedup, with collection listings compared;
    • applyWrites.
  • --limits checks of forwarded calls.

Checked: plain seeds 1–3, --commands 31, crash seed 21 with --firehose, --limits, --invites, the spaces run, and cargo test --workspace. The merge queue runs the full gates.

🤖 Generated with Claude Code

Approved

This pull adds proxying and service auth, preferences, read-after-write, SSRF-guarded outbound calls, and record validation against the vendored lexicons. I found nothing that must change, but I did not read all of it. The diff is 15,276 lines in 149 files.

What I read:

  • Dependencies: the only new crate is unicode-segmentation, and bs58 is added to pds-repo. No atproto or MCP crates were added.
  • Spec and README: the README and spec/PDS.md link the new PROXY.md and VALIDATION.md and list the new methods. The README says what is built, with no history in it. The "no proxying to an appview" gap is removed from "Known gaps", which matches the change.
  • Preferences: preferences.rs appends one accounts.log entry per put, under the account's lock, and waits for the entry to be durable only after releasing the lock. Personal details are limited to full sessions, and an app-password session cannot overwrite them.
  • Harness: the new compare.mjs steps are wired in. I did not read the checks in proxy.mjs, validation.mjs or services.mjs, so I cannot say whether any check is weaker than it should be.
  • Conformance excuses: harness/conformance.yaml is unchanged by this pull, so no new excuses need checking.

What I did not read: proxy.rs, read_after_write.rs, validation.rs, the outbound.rs rewrite, lib.rs, the pds-lexicon and pds-repo changes, the proxy.mjs, validation.mjs and services.mjs harness checks, the PROXY.md and VALIDATION.md text, the vendored lexicons and the interop vectors. The merge queue's full gates remain the check on those.

The queue ejected this on a real difference, crash seed 23 step 413. An OAuth session with transition:chat.bsky sent chat.bsky.convo.sendMessage with atproto-proxy naming the AppView: the reference forwarded it, the server answered 403 ScopeMissingError. The server let transition:chat.bsky allow chat methods only together with transition:generic. Fixed in 1898490: transition:chat.bsky allows rpc of any chat.bsky.* method to any target (and nothing else, not *); transition:generic allows every other method. OAUTH-SCOPES.md says so, with unit tests for chat to the AppView, * under each scope, and getServiceAuth with chat only. Crash seed 23 and plain seed 1 now agree.

Approved

I read the change since my approval at c9aaaddacb35. It only changes how OAuth scopes gate chat.bsky. calls. transition:chat.bsky now allows those methods on its own, to any service, and never allows *. transition:generic allows every other method, * included, and no chat.bsky. method.

The code in scopes.rs, the unit test and the service_auth test all match this. spec/OAUTH-SCOPES.md is updated to the same rules in both places that state them. The case-sensitive prefix match is stated in the spec and is what starts_with does. Nothing in this change breaks what I approved earlier.

Merged as 97a3406