Drop @atproto/api runtime dependency from bsky - #5422
Open
bigmoves wants to merge 2 commits into
Open
Conversation
Two production files were pinning the legacy client stack into bsky's shipped artifact: the age assurance region/rule helpers were imported from @atproto/api, whose `age-assurance.ts` is hand-written logic that happens to live alongside the legacy generated client. Port those helpers into `api/age-assurance/util.ts`, typed against the generated `app.bsky.ageassurance.defs` schemas. The legacy `isConfigRegionRuleX()` guards become `$isTypeOf`, and `AgeAssuranceRuleID` is derived from the schemas' `$type` constants rather than hand-built NSID strings. Rule ordering and comparisons are unchanged. @atproto/api moves to devDependencies — the 58 test files still drive the services through AtpAgent, which dev-env hands them, so it can't go away entirely until dev-env migrates. The `../api` project reference moves to tsconfig.test.json accordingly, mirroring packages/pds. Also converts the age-assurance-v2 config fixture to `$build` so it is checked against the same schema the production code consumes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
bigmoves
marked this pull request as ready for review
August 17, 2026 21:41
devinivy
reviewed
Aug 18, 2026
| * provided platform is included in that list. If no platform filter is | ||
| * provided, platform restrictions are ignored. | ||
| */ | ||
| export function getAgeAssuranceRegionConfig( |
Collaborator
There was a problem hiding this comment.
We should be able to use @bsky/sdk for this and other age assurance helpers.
devinivy
reviewed
Aug 18, 2026
| @@ -0,0 +1,267 @@ | |||
| import { describe, expect, it } from 'vitest' | |||
Collaborator
There was a problem hiding this comment.
I think we can nix this once we move to @bsky/sdk for the age assurance utils.
Per review feedback: rather than porting the age assurance region/rule helpers into this repo, take them from @bsky/sdk, which already ships `getAgeAssuranceRegionConfig`, `computeAgeAssuranceRegionAccess`, and `AgeAssuranceRuleID` typed against @atproto/lex. The SDK declares @atproto/lex as a peer dependency, so it resolves to the workspace copy and its generated `app.bsky.ageassurance.defs` types are compatible with this package's own tree — including AGE_ASSURANCE_CONFIG, which is still built locally. Drops the ported implementation and its unit tests; `util.ts` keeps only the bsky-specific wrappers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@devinivy I updated to use bsky/sdk |
devinivy
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
packages/bskycarried@atproto/apias a runtime dependency because of exactly two production files. Both imported the age assurance region/rule helpers —getAgeAssuranceRegionConfig,computeAgeAssuranceRegionAccess,AgeAssuranceRuleID— from@atproto/api:src/api/age-assurance/util.tssrc/api/app/bsky/ageassurance/begin.tsThose helpers live in
packages/api/src/age-assurance.ts, which is hand-written logic that happens to sit alongside the legacy generated client. So two imports were pinning the whole legacy client stack into bsky's shipped artifact and into theservices/bskyimage.Per review, this sources them from
@bsky/sdk(@bsky/sdk/utils), which already shipsgetAgeAssuranceRegionConfig,computeAgeAssuranceRegionAccess, andAgeAssuranceRuleIDtyped against@atproto/lex— so no logic is duplicated into this repo.src/api/age-assurance/util.tskeeps only the two bsky-specific wrappers (computeAgeAssuranceAccessOrThrow,createLocationString);begin.tsimportsgetAgeAssuranceRegionConfigstraight from the SDK.This works because the SDK declares
@atproto/lexas a peer dependency, so it resolves tolink:../lex/lexin this workspace. The branded types (l.UnknownStringinsideAccess) therefore come from the same instance, and the SDK'sConfig/ConfigRegionare structurally compatible with this package's own generatedapp.bsky.ageassurance.defstree — includingAGE_ASSURANCE_CONFIG, which is still built from the local tree.@atproto/apimoves todevDependencies, and the../apiproject reference moves fromtsconfig.build.jsontotsconfig.test.json— mirroring howpackages/pdsis already set up.pnpm why @atproto/api --filter @atproto/bsky --prodnow returns nothing.Also converts the
age-assurance-v2mocked config fixture to$build, so it is checked against the same schema the production code consumes rather than the structurally-compatible legacy type.What this does not do
@atproto/apistays indevDependencies. All 58 bsky test files drive the services throughAtpAgent, whichdev-envhands them (packages/dev-env/src/bsky.ts:148,pds.ts:75), and pass legacyids.*NSID constants tonetwork.serviceHeaders(). That can't go away untildev-envitself migrates — a separate, much larger change that would also unblock pds and ozone shedding their test-side dep.packages/apikeeps its own copy of these helpers, since it is a published package and they are public API for external clients. That copy is now the redundant one and can go with the rest of@atproto/api.Checklist
pnpm build --force && pnpm verifypassesWritten with Claude Code (Claude Opus 5).
Test evidence
tests/views/age-assurance.test.ts+tests/views/age-assurance-v2.test.ts— 29 passed, 1 skipped