Skip to content

feat(lml-client): add resolveIdentity wrapper (BS#1380 PR 2/5)#1418

Open
jakebromberg wants to merge 1 commit into
mainfrom
feature/bs-1380-2-resolve-identity
Open

feat(lml-client): add resolveIdentity wrapper (BS#1380 PR 2/5)#1418
jakebromberg wants to merge 1 commit into
mainfrom
feature/bs-1380-2-resolve-identity

Conversation

@jakebromberg

Copy link
Copy Markdown
Member

Second in a 5-PR chain implementing #1380.

Summary

  • New resolveIdentity({kind, source, external_id}) wrapper in @wxyc/lml-client for LML#526's POST /api/v1/identity/resolve. Idempotent on (source, external_id) — same triple always returns the same identity_id.
  • Honors LML_RESOLVE_TIMEOUT_MS (default 2000 ms) via AbortController. Default matches user-visible read paths (BS#992 picker budget); the BS#1380 plan commits to it in prose. Consumers (PR 4 + PR 5) fast-fail to NULL and the daily backfill catches up.
  • Wire types defined locally (ReleaseIdentityResolveRequest / ReleaseIdentityResolveResponse / ReleaseIdentityResolveSource) mirroring wxyc-shared/api.yaml. Same approach as EntityResolveResponse during its own ramp-up; types move to @wxyc/shared/dtos once OpenAPI codegen catches up.

Independent of PR 1

This PR has no DB dependency and can land in any order relative to PR 1 (schema). Chained to PR 1 only for sequencing convenience.

Test plan

  • @wxyc/lml-client build + DTS generation
  • Consumers exercise the wrapper in PR 4 + PR 5 (unit tests for classifyLmlResolveError cover every catch-block branch the wrapper documents)

Refs #1380

…solve (BS#1380 PR 2/5)

Adds `resolveIdentity({kind, source, external_id})` to `@wxyc/lml-client`
for LML#526's `POST /api/v1/identity/resolve` endpoint. Returns a stable
`identity_id` for a release-shaped (source, external_id) pair; idempotent
on the triple — the same triple always returns the same identity_id.

Wrapper layer details:
- Honors `LML_RESOLVE_TIMEOUT_MS` (default 2000 ms) via the shared
  `lmlFetch` AbortController. The default budget matches the user-visible
  read paths (BS#992 picker budget) — sufficient because every BS consumer
  fast-fails to NULL and a daily backfill catches up.
- Wire types defined locally (`ReleaseIdentityResolveRequest` /
  `ReleaseIdentityResolveResponse` / `ReleaseIdentityResolveSource`)
  mirroring `wxyc-shared/api.yaml`. Same approach used by the original
  `EntityResolveResponse` during its ramp-up; types move to
  `@wxyc/shared/dtos` once OpenAPI codegen catches up.
- Errors documented exhaustively in the JSDoc so the caller's
  classifier (BS#1380 PR 4) maps each bucket cleanly:
    * Timeout → LmlClientError 504 (translated by lmlFetch from AbortError)
    * 5xx → LmlClientError 502 (translated by lmlFetch)
    * 4xx (incl. 422 sentinel rejection) → LmlClientError <status>
    * Network → LmlClientError 502 (fetch-threw, distinguished by message)

No consumer in this PR. Consumed by PR 4 (`addToRotation`) and PR 5
(`rotation-lml-identity-backfill` cron). Independent of PR 1 (schema)
— the wrapper has no DB dependency.

Refs #1380
@jakebromberg

jakebromberg commented Jun 14, 2026

Copy link
Copy Markdown
Member Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Notes verified:

  • Wire shape matches wxyc-shared/api.yaml ReleaseIdentityResolve{Request,Response} (kind/source enums, external_id: string, identity_id, minted).
  • 2s default timeout matches the BS#1380 plan and is overridable via options.timeoutMs / LML_RESOLVE_TIMEOUT_MS.
  • Skipping the LmlLimiter is correct — only /lookup fans out to Discogs and needs the chokepoint (see comment at the top of shared/lml-client/src/index.ts lines 79-81).
  • Skipping Sentry instrumentation is intentional per the chained-PR spec; callers wrap in higher-level spans.
  • Local type definitions (rather than @wxyc/shared/dtos import) follow the same ramp-up pattern as EntityResolveResponse.

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