Skip to content

test(spaces): close the one-sided tests and checks - #260

Merged
ascorbic merged 7 commits into
mainfrom
spaces-test-gaps
Nov 21, 2026
Merged

ascorbic merged 7 commits into
mainfrom
spaces-test-gaps

Conversation

@ascorbic

Copy link
Copy Markdown
Owner

This closes the tests and checks that would pass against a broken implementation. The motivating case is the attestation bug fixed in #258: verification always failed on workerd, yet every test and conformance check passed. The unit test's fake fetch ignored redirect, and no check ever sent a valid attestation.

Builds on #258. This branch contains #258's commits (the direct-call test helper and the attestation redirect fix). Merge #258 first and this diff shrinks to its own changes.

PDS host adapter (packages/pds/test/spaces-adapter.test.ts, new)

The PDS's spaces adapter had no tests of its own: the engine's route tests use test doubles, and the PDS conformance run has no foreign identities. Breaking any of these left all 355 PDS tests passing:

  • verifyForeignServiceJwt accepting any signature
  • the OAuth space: scope check allowing everything
  • the deactivated-account gate removed
  • foreign DID resolution always failing

The new tests serve foreign DID documents and a managing app from a stubbed fetch:

  • a signed notifyRepoUpdate gets 200, while a forged one and a wrong lxm get 401;
  • key rotation verifies through forceRefresh;
  • a foreign member's delegation token issues a credential, and a forged one is InvalidDelegationToken;
  • a managing app's did#service endpoint is resolved and called with service auth (aud is the managing app);
  • an OAuth space: grant allows its type and collection, and refuses another type or collection;
  • a deactivated account gets RepoDeactivated.

Each of the four breaks above now fails a test, and so does swapping && for || in the signature check.

Fakes that behave like workerd (packages/spaces)

  • The route tests' fake fetch builds a real Request, so unsupported init options throw as they do on workerd, and it follows 3xx unless redirect is "manual".
  • checkAccess and the outbound notifyRepoUpdate now use redirect: "manual", as confirmRegistration and attestation already did (changeset). Each of the four outbound calls has a test whose redirect target would succeed if it were followed. Switching any one of them to "follow" fails its test.
  • The space-DO tests restore the global fetch they stub; with isolate: false the old fakes leaked into later files. There's a new test for a successful syncer delivery: no service auth, redirect: "manual", token in the body, queue emptied.
  • notifyRepoUpdate refusals assert which guard refused, not just a 403.
  • The engine looks up the global fetch per call, so host tests can stub it after the routes are built. No change in production.

Conformance suite (packages/space-conformance)

  • Attestations: the syncer inbox now also acts as an OAuth client. It serves client-metadata.json with an ES256 JWKS, and inbox.attest() mints attestations.
    • New checks: credential.valid-attestation-issues and credential.valid-attestation-unlisted-refused.
    • The attestation refusal checks and allowed-apps-gate first require a valid attestation to issue whenever an inbox is available, through a new optional uses capability. Without an inbox, their detail says the success path wasn't checked.
  • Registration and managing app: confirmation and the managing-app fail-closed checks get success controls. notify.renewal-not-reconfirmed now requires the first registration to have been confirmed.
  • Stricter answers: checks that accepted anything but 200 now require a 4xx or the named error:
    • request.invalid-space-uri-rejected is sent authenticated and requires a 400 with an error name.
    • revocation.non-authority-refused requires 401/403.
    • bare-did-rejected requires InvalidRequest, after a control that a well-formed did#service is accepted.
    • cross-space-refused, published-collections-refused and owner-state-not-by-credential require a 4xx.
  • More success controls: applywrites-update-missing first updates an existing record, space-blob-not-public checks that a public blob is served, and there's a new check policy.personalspace-owner-admitted.
  • The original bug: with it put back, five attestation checks now fail against Cirrus. Before this change, none did.

Results

  • Reference matrix: 109 checks. 107 pass, 1 pinned divergence (writes.delete-in-missing-space, unchanged) and 1 slow skip.
  • Cirrus: both runners pass.
  • Tests: PDS 361 unit and 128 CLI, spaces 86, space-conformance 48, oauth-provider 140, matrix 5, create-pds 4. All pass with no unhandled errors.
  • pnpm build, pnpm check and pnpm knip are clean. knip prints one configuration hint, which comes from main.

One small divergence noted, not changed: Cirrus answers a malformed space with 400 InvalidSpaceUri, which no lexicon declares. The reference answers XRPC's generic InvalidRequest.


Generated by Claude Code

It takes ~10s alone but ~25s after the rest of the suite in the shared
isolate, and CI is slower again: it passed in 58.7s against the 60s
limit on #257 and timed out on the release PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
Every call through exports.default.fetch left the next one slower: 1000
requests took a trivial 404 from ~1ms to ~190ms, and the slowdown
carried across test files. Calling the Hono app directly shows no
growth. The suite was quadratic in requests made: the conformance run
(~1000 requests) took ~3s alone, ~25s after the other files, and ~60s
on CI, where it timed out on the release PR.

The helper now calls app.fetch with a fresh ExecutionContext per request,
leaving waitUntil work running as in production. All 355 tests pass,
and the run's test time drops from ~60s to ~15s locally. The conformance
timeout goes back to 60s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
workerd refuses redirect: "error", so on a Worker every client metadata
and JWKS fetch threw, every attestation failed and a memberspace with
allowedApps refused every app. The unit tests' stub fetch ignored the
option, and the conformance checks only cover refusals.

Use "manual": a 3xx fails the existing ok check, so redirects are still
refused. The stub now rejects "error" as workerd does, and a test pins
that behaviour (via the Request constructor, which applies the same
check without a rejected promise for the pool to report twice).

Calling the PDS directly in tests (previous commit) surfaced this as an
unhandled rejection that failed the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
…e like workerd

The PDS's spaces adapter had no tests of its own: the engine's route
tests use doubles for it, and the PDS conformance run has no foreign
identities. Breaking its signature check, OAuth scope check, deactivation
gate or foreign DID resolution left all 355 tests passing. New
spaces-adapter tests serve foreign DID documents and a managing app from
a stubbed fetch and cover each: signed and forged notifyRepoUpdate, key
rotation through forceRefresh, a foreign delegation token, a managing
app's did#service endpoint and service auth, OAuth space: scopes by type
and collection, and RepoDeactivated. Each of those breaks now fails a
test.

The route tests' fake fetch builds a Request (so unsupported init
options throw, as on workerd) and follows 3xx unless redirect is
manual. checkAccess and the outbound notifyRepoUpdate now use
redirect: manual, and each outbound call has a test where following
the redirect would have succeeded. The space DO tests restore the
global fetch they stub, and gain a successful syncer delivery test.
notifyRepoUpdate refusals assert which guard refused.

The engine looks up the global fetch per call, so host tests can stub
it after the routes are built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
…rogress)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
The syncer inbox also serves client metadata and mints attestations, so
the attestation checks verify that a valid attestation issues before
treating a refusal as a pass. New checks: valid-attestation-issues,
valid-attestation-unlisted-refused, personalspace-owner-admitted.
Registration, managing-app and update checks get controls; status-only
refusals require a 4xx or the named error. With the redirect bug put
back, five attestation checks now fail against Cirrus (none did).

Matrix: 109 checks, 107 pass, 1 pinned divergence, 1 slow skip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/create-pds@260
npm i https://pkg.pr.new/@getcirrus/oauth-provider@260
npm i https://pkg.pr.new/@getcirrus/pds@260
npm i https://pkg.pr.new/@getcirrus/spaces@260

commit: fd2d978

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
pdscheck fd2d978 Nov 21 2026, 11:54 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
cirrusdocs fd2d978 Commit Preview URL

Branch Preview URL
Nov 21 2026, 11:55 AM

@ascorbic
ascorbic merged commit a8c4a9f into main Nov 21, 2026
6 checks passed
@ascorbic
ascorbic deleted the spaces-test-gaps branch November 21, 2026 11:56
@mixie-bot mixie-bot Bot mentioned this pull request Nov 21, 2026
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.

2 participants