Skip to content

library-identity-consumer writes the main-row release from LML and keeps it on null (BS#3809) - #3810

Merged
jakebromberg merged 1 commit into
mainfrom
picker-b1c
Nov 15, 2026
Merged

jakebromberg merged 1 commit into
mainfrom
picker-b1c

Conversation

@jakebromberg

Copy link
Copy Markdown
Member

Closes #3809

Slice B1c of the Discogs release picker (#3790): the library-identity-consumer writes the main-row release an MD pin decided, and keeps it when LML later sends null.

Changes

  • projectMainRow takes discogs_release_id and discogs_master_id from the bulk-resolve result instead of hard-coding null. These are the nullable pin fields in @wxyc/shared 12.22.0, mirrored into the job's inlined lml-types.ts. It now takes the whole single_artist result, since the fields sit on the result and not on main. A 0 sentinel maps to null.
  • Main-row upsert: "discogs_release_id" = COALESCE(EXCLUDED."discogs_release_id", library_identity."discogs_release_id"), so a row without a pin is never wiped and B2's picker write survives the next run.
  • The master follows its release: CASE WHEN EXCLUDED."discogs_release_id" IS NULL THEN <stored master> ELSE EXCLUDED."discogs_master_id" END. A plain COALESCE on the master would keep release A's master after a re-pin to release B when B has no master, because the contract sends null for that case. Pinning B now clears it.
  • No other column in the ON CONFLICT clause changes. notes, agreement_sources, method, confidence, last_verified_at and the artist-level ids still follow LML on every run, as the plan's B2 step expects.
  • writer.ts also builds to dist/writer.cjs (the same mechanism as album-metadata-extended-fill) so the Postgres spec runs the real upsert.

Not in this PR: the @wxyc/shared bump

The ticket asks for a bump to 12.22.0. It is left out because 12.20.0 also lets music directors grant reviews_beta (canAssignCapability), which is #3783's behavior change. It fails tests/unit/authentication/capability-assign-guard.test.ts, and it would ship an auth change inside a picker slice. This job never imports @wxyc/shared, since it inlines the contract types, so B1c does not need the bump. The bump should land with #3783, or before B2 as its own PR that adopts that change.

Tests

  • Unit (tests/unit/jobs/library-identity-consumer/writer.test.ts): a parameterized projectMainRow table covering a pin with a master, a pin without one, null, absent (an older producer) and 0, plus a check of the upsert's COALESCE/CASE shape.
  • Postgres (tests/integration/library-identity-consumer-release-keep.spec.js): a release is written, a later null keeps it, and a later different release replaces it; a release without a master clears the old master; an unpinned row stays empty. Against the pre-change writer, 2 of its 3 tests fail.

Local verification

  • Job tsc --noEmit, eslint and prettier --check on the changed files: clean. Workspace npm run typecheck: clean. Job unit suites: 157/157.
  • The Postgres spec ran against a throwaway Homebrew PostgreSQL with every real migration and seed_db.sql applied: 3/3 pass. This was not the full integration harness (no global setup, auth or other specs); CI runs that.

Part of #3790.

…eps it on null (BS#3809)

projectMainRow now takes discogs_release_id and discogs_master_id from the bulk-resolve result (the nullable pin fields of @wxyc/shared 12.22.0, mirrored into the job's inlined lml-types) instead of hard-coding null, and maps the 0 sentinel to null. The main-row upsert keeps the stored release when LML sends null (COALESCE(EXCLUDED, stored)), so a row without a pin is never wiped and a picker write survives the next run. The master follows its release: it is kept with a kept release and replaced, even by null, with a replaced one, so a new release without a master never keeps the previous release's master. Every other column in the ON CONFLICT clause, notes and agreement_sources included, still follows LML.

writer.ts also builds to dist/writer.cjs so a new Postgres spec runs the real upsert: a release is written, a later null keeps it, a later different release replaces it, a release without a master clears the old master, and an unpinned row stays empty.

Part of #3790
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.

library-identity-consumer writes the main-row release from LML and keeps it on null (release picker B1c)

1 participant