fluncle 0.256.0 → 0.257.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/fluncle.mjs +1193 -1142
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -622,7 +622,7 @@ function parseVersion(version) {
622
622
  var currentVersion;
623
623
  var init_version = __esm(() => {
624
624
  init_output();
625
- currentVersion = "0.256.0".trim() ? "0.256.0".trim() : "0.1.0";
625
+ currentVersion = "0.257.0".trim() ? "0.257.0".trim() : "0.1.0";
626
626
  });
627
627
 
628
628
  // src/update-notifier.ts
@@ -2335,7 +2335,7 @@ function parseVersion2(version) {
2335
2335
  var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
2336
2336
  var init_version2 = __esm(() => {
2337
2337
  init_output();
2338
- currentVersion2 = "0.256.0".trim() ? "0.256.0".trim() : "0.1.0";
2338
+ currentVersion2 = "0.257.0".trim() ? "0.257.0".trim() : "0.1.0";
2339
2339
  });
2340
2340
 
2341
2341
  // ../../packages/registry/src/index.ts
@@ -3469,6 +3469,18 @@ var init_src = __esm(() => {
3469
3469
  title: "Freshness tap",
3470
3470
  weights: { status: "hidden" }
3471
3471
  },
3472
+ {
3473
+ exposedContent: [
3474
+ "checks pipeline yield against measured backlog and alerts the operator on sustained stalls"
3475
+ ],
3476
+ kind: "cron",
3477
+ name: "cron.pipeline-watch",
3478
+ operatorNotes: "Every 15m from a host calendar timer. Reads sweep markers and agent-tier status/worklist counters; alerts Discord on incident open, reminders, and recovery. Source: docs/agents/hermes/scripts/pipeline-watch.*.",
3479
+ probeConfig: { cadenceMs: 15 * MINUTE_MS, cronName: "fluncle-pipeline-watch", kind: "cron" },
3480
+ statusDescription: "watches for stalled track processing",
3481
+ title: "Track watch",
3482
+ weights: { status: "hidden" }
3483
+ },
3472
3484
  {
3473
3485
  command: "fluncle admin catalogue rank",
3474
3486
  exposedContent: [
@@ -4428,6 +4440,7 @@ var SOURCE_LABELS;
4428
4440
  var init_admin_attention = __esm(() => {
4429
4441
  init_api();
4430
4442
  SOURCE_LABELS = {
4443
+ "anchor-failure": "anchor failure",
4431
4444
  "anchor-review": "version check",
4432
4445
  "artist-review": "artist links",
4433
4446
  "attach-cues": "cues",
@@ -10149,89 +10162,760 @@ var init_zod = __esm(() => {
10149
10162
  init_external();
10150
10163
  });
10151
10164
 
10152
- // ../../packages/contracts/src/orpc/admin-albums.ts
10153
- var DescribeAlbumBodySchema, describeAlbum, draftAlbumBio, AlbumBioWorkItemSchema, listAlbumsMissingBio, adminAlbumsContract;
10154
- var init_admin_albums = __esm(() => {
10165
+ // ../../packages/contracts/src/orpc/admin-catalogue.ts
10166
+ var CatalogueLensSchema, CapturePriorityReasonSchema, CatalogueMatchSchema, CatalogueTrackItemSchema, CatalogueSummarySchema, listCatalogueTracks, rankCatalogue, recordDemand, clearWrongAudio, requeueUnmatchedCaptures, requeueAnchor, requeueIsrcRecovery, flagWrongAudio, forceCapture, certifyTrack, setTrackDismissed, CaptureVerifyItemSchema, listUnverifiedCaptures, verifyCapture, CrawlPassSchema, CrawlPhaseInitializationSchema, MAX_CRAWL_PREPARE_LIMIT = 6, CrawlFetchPlanSchema, SuppliedCrawlBodySchema, MAX_CRAWL_COMMIT_BATCH, CRAWL_COMMIT_TOKEN_MAX_BYTES, CRAWL_COMMIT_BATCH_MAX_TOTAL_BYTES, CrawlCommitItemSchema, CrawlCommitReceiptSchema, CrawlPhaseCapabilitiesSchema, CrawlPhaseInputSchema, CrawlPhaseOutputSchema, CrawlStatusSchema, CrawlPipelineSummarySchema, crawlCatalogue, commitCrawlNodes, getCrawlStatus, ANCHOR_CANDIDATE_LIMIT = 100, ANCHOR_ARTIST_LIMIT = 20, ANCHOR_TEXT_MAX = 300, ANCHOR_ISRC_MAX = 64, ANCHOR_ID_MAX = 64, ANCHOR_URL_MAX = 2048, AnchorCandidateSchema, anchorTrack, recordAnchorFailure, DEEZER_CANDIDATE_LIMIT = 5, DEEZER_TEXT_MAX = 300, DEEZER_ISRC_MAX = 64, DEEZER_TRACK_ID_MAX = 32, DeezerIsrcCandidateSchema, resolveAnchor, resolveAnchorReview, setAnchorSearch, setAnchorApify, CaptureBudgetStateSchema, getCaptureBudget, setCaptureBudget, AnchorApifyBudgetSchema, getAnchorApifyBudget, setAnchorApifyBudget, SpotifyAnchorBreakerStateSchema, AnchorRungFlagsSchema, getSpotifyAnchorBreaker, resetSpotifyAnchorBreaker, AppleBreakerStateSchema, resetAppleBreaker, adminCatalogueContract;
10167
+ var init_admin_catalogue = __esm(() => {
10155
10168
  init_dist3();
10156
10169
  init_zod();
10157
- DescribeAlbumBodySchema = looseObject({
10158
- bio: unknown().optional(),
10159
- dryRun: unknown().optional(),
10160
- finalAttempt: boolean2().optional(),
10161
- promptVersion: number2().int().min(0).optional()
10162
- });
10163
- describeAlbum = oc.route({
10170
+ CatalogueLensSchema = _enum(["capture", "dismissed", "ear", "failed", "quarantine", "unmatched"]).meta({ id: "CatalogueLens" });
10171
+ CapturePriorityReasonSchema = object({
10172
+ kind: _enum(["artist", "label", "none", "seed-label", "skipped-label", "unauthorized"]),
10173
+ name: string2().nullable()
10174
+ }).meta({ id: "CapturePriorityReason" });
10175
+ CatalogueMatchSchema = object({
10176
+ artists: array(string2()),
10177
+ logId: string2().nullable(),
10178
+ title: string2(),
10179
+ trackId: string2()
10180
+ }).meta({ id: "CatalogueMatch" });
10181
+ CatalogueTrackItemSchema = object({
10182
+ albumImageUrl: string2().nullable(),
10183
+ appleMusicUrl: string2().nullable(),
10184
+ artists: array(string2()),
10185
+ bpm: number2().nullable(),
10186
+ capturePriority: number2().nullable(),
10187
+ captureReason: CapturePriorityReasonSchema.nullable(),
10188
+ captureStatus: string2().nullable(),
10189
+ captureVerification: string2().nullable(),
10190
+ dismissedAt: string2().nullable(),
10191
+ duplicateOf: CatalogueMatchSchema.nullable(),
10192
+ hasCapturedAudio: boolean2(),
10193
+ hasPreview: boolean2(),
10194
+ isrc: string2().nullable(),
10195
+ key: string2().nullable(),
10196
+ label: string2().nullable(),
10197
+ nearestFinding: CatalogueMatchSchema.nullable(),
10198
+ nearestFindingScore: number2().nullable(),
10199
+ rankedAt: string2().nullable(),
10200
+ releaseDate: string2().nullable(),
10201
+ sourceAudioAttemptedAt: string2().nullable().optional(),
10202
+ spotifyUrl: string2().nullable(),
10203
+ title: string2(),
10204
+ trackId: string2()
10205
+ }).meta({ id: "CatalogueTrackItem" });
10206
+ CatalogueSummarySchema = object({
10207
+ awaitingCapture: number2(),
10208
+ awaitingRank: number2(),
10209
+ dismissed: number2(),
10210
+ quarantined: number2(),
10211
+ ranked: number2(),
10212
+ total: number2()
10213
+ }).meta({ id: "CatalogueSummary" });
10214
+ listCatalogueTracks = oc.route({
10215
+ method: "GET",
10216
+ operationId: "listCatalogueTracks",
10217
+ path: "/admin/catalogue",
10218
+ summary: "The ranked catalogue: closest to a finding (`ear`), or next to capture (`capture`)",
10219
+ tags: ["Admin"]
10220
+ }).input(object({
10221
+ lens: CatalogueLensSchema.default("ear"),
10222
+ limit: number3().int().min(1).max(200).default(50)
10223
+ })).output(object({
10224
+ ok: literal(true),
10225
+ summary: CatalogueSummarySchema,
10226
+ tracks: array(CatalogueTrackItemSchema)
10227
+ }));
10228
+ rankCatalogue = oc.route({
10164
10229
  method: "POST",
10165
- operationId: "describeAlbum",
10166
- path: "/admin/albums/{slug}/bio",
10167
- summary: "Auto-author an album's voiced bio (fills an empty bio only)",
10230
+ operationId: "rankCatalogue",
10231
+ path: "/admin/catalogue/rank",
10232
+ summary: "One tick of the catalogue ranking sweep (nearest finding + capture priority)",
10168
10233
  tags: ["Admin"]
10169
- }).input(DescribeAlbumBodySchema.extend({ slug: string2() })).output(object({
10170
- bio: string2(),
10171
- dryRun: literal(true).optional(),
10172
- gateBypassed: literal(true).optional(),
10234
+ }).input(object({
10235
+ countRemaining: boolean3().default(false),
10236
+ limit: number3().int().min(1).max(1000).default(250)
10237
+ })).output(object({
10173
10238
  ok: literal(true),
10174
- skipped: boolean2().optional(),
10175
- slug: string2(),
10176
- voiceViolations: array(string2()).optional()
10239
+ summary: object({
10240
+ catalogueDuplicates: number2(),
10241
+ corpus: string2(),
10242
+ embeddedFindings: number2(),
10243
+ findings: number2(),
10244
+ prioritized: number2(),
10245
+ quarantined: number2(),
10246
+ remaining: number2(),
10247
+ scored: number2()
10248
+ }),
10249
+ telescope: union([
10250
+ object({ changed: boolean2(), ok: literal(true), size: number2() }),
10251
+ object({ ok: literal(false), reason: string2() })
10252
+ ]).optional()
10177
10253
  }));
10178
- draftAlbumBio = oc.route({
10179
- method: "GET",
10180
- operationId: "draftAlbumBio",
10181
- path: "/admin/albums/{slug}/bio-draft",
10182
- summary: "Assemble a ready-to-author bio prompt for an album (Worker-side grounding)",
10254
+ recordDemand = oc.route({
10255
+ method: "POST",
10256
+ operationId: "recordDemand",
10257
+ path: "/admin/catalogue/demand",
10258
+ summary: "One demand tick: reorder crawl/capture priority from Simple Analytics pageviews",
10183
10259
  tags: ["Admin"]
10184
- }).input(object({ slug: string2() })).output(object({
10185
- findingCount: number2(),
10186
- found: boolean2(),
10187
- hasFacts: boolean2(),
10188
- name: string2(),
10189
- prompt: string2(),
10190
- promptVersion: number2()
10260
+ }).input(object({})).output(object({
10261
+ ok: literal(true),
10262
+ summary: object({
10263
+ configured: boolean2(),
10264
+ demandedArtists: number2(),
10265
+ demandedLabels: number2(),
10266
+ frontierPromoted: number2(),
10267
+ pagesRead: number2(),
10268
+ totalPageviews: number2(),
10269
+ tracksScored: number2(),
10270
+ unknownSlugs: number2(),
10271
+ window: object({ end: string2(), start: string2() })
10272
+ })
10191
10273
  }));
10192
- AlbumBioWorkItemSchema = object({ id: string2(), name: string2(), slug: string2() }).meta({ id: "AlbumBioWorkItem" });
10193
- listAlbumsMissingBio = oc.route({
10274
+ clearWrongAudio = oc.route({
10275
+ method: "POST",
10276
+ operationId: "clearWrongAudio",
10277
+ path: "/admin/catalogue/wrong-audio/clear",
10278
+ summary: "Overrule the wrong-audio quarantine on one catalogue row (operator)",
10279
+ tags: ["Admin"]
10280
+ }).input(object({ trackId: string2().min(1) })).output(object({ cleared: boolean2(), ok: literal(true) }));
10281
+ requeueUnmatchedCaptures = oc.route({
10282
+ method: "POST",
10283
+ operationId: "requeueUnmatchedCaptures",
10284
+ path: "/admin/catalogue/captures/requeue-unmatched",
10285
+ summary: "Re-queue terminal-unmatched catalogue captures after a matcher improvement (operator)",
10286
+ tags: ["Admin"]
10287
+ }).input(object({})).output(object({ ok: literal(true), requeued: number2(), skippedVetoed: number2() }));
10288
+ requeueAnchor = oc.route({
10289
+ method: "POST",
10290
+ operationId: "requeueAnchor",
10291
+ path: "/admin/catalogue/anchor/requeue",
10292
+ summary: "Clear named rows' anchor re-ask backoff or terminal validation error (operator)",
10293
+ tags: ["Admin"]
10294
+ }).input(object({ trackIds: array(string2().min(1)).min(1).max(250) })).output(object({ ok: literal(true), requeued: number2() }));
10295
+ requeueIsrcRecovery = oc.route({
10296
+ method: "POST",
10297
+ operationId: "requeueIsrcRecovery",
10298
+ path: "/admin/catalogue/isrc-recovery/requeue",
10299
+ summary: "Clear Deezer-empty ISRC-recovery stamps from a named window (operator)",
10300
+ tags: ["Admin"]
10301
+ }).input(object({
10302
+ dryRun: boolean2().default(true),
10303
+ since: string2().regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z)?$/, "since must be an ISO date (2026-09-09) or instant (2026-09-09T00:00:00.000Z)")
10304
+ })).output(object({
10305
+ dryRun: boolean2(),
10306
+ matched: number2(),
10307
+ ok: literal(true),
10308
+ requeued: number2()
10309
+ }));
10310
+ flagWrongAudio = oc.route({
10311
+ method: "POST",
10312
+ operationId: "flagWrongAudio",
10313
+ path: "/admin/catalogue/wrong-audio/flag",
10314
+ summary: "Flag a finding's captured audio as the wrong recording (operator)",
10315
+ tags: ["Admin"]
10316
+ }).input(object({ trackId: string2().min(1) })).output(object({ flagged: boolean2(), ok: literal(true) }));
10317
+ forceCapture = oc.route({
10318
+ method: "POST",
10319
+ operationId: "forceCapture",
10320
+ path: "/admin/catalogue/force-capture",
10321
+ summary: "Overrule the duplicate veto on one catalogue row so it can be captured (operator)",
10322
+ tags: ["Admin"]
10323
+ }).input(object({ trackId: string2().min(1) })).output(object({ forced: boolean2(), ok: literal(true) }));
10324
+ certifyTrack = oc.route({
10325
+ method: "POST",
10326
+ operationId: "certifyTrack",
10327
+ path: "/admin/catalogue/certify",
10328
+ summary: "Certify an existing catalogue track in place — mint its finding (operator)",
10329
+ tags: ["Admin"]
10330
+ }).input(object({ note: string2().optional(), trackId: string2().min(1) })).output(object({ logId: string2(), ok: literal(true) }));
10331
+ setTrackDismissed = oc.route({
10332
+ method: "PUT",
10333
+ operationId: "setTrackDismissed",
10334
+ path: "/admin/catalogue/dismissed",
10335
+ summary: "Dismiss a catalogue track ('not for me') or restore it (operator)",
10336
+ tags: ["Admin"]
10337
+ }).input(object({ dismissed: boolean2(), trackId: string2().min(1) })).output(object({ changed: boolean2(), ok: literal(true) }));
10338
+ CaptureVerifyItemSchema = object({
10339
+ artists: array(string2()),
10340
+ certified: boolean2(),
10341
+ durationMs: number2(),
10342
+ isrc: string2().nullable(),
10343
+ logId: string2().nullable(),
10344
+ sourceAudioKey: string2(),
10345
+ title: string2(),
10346
+ trackId: string2()
10347
+ }).meta({ id: "CaptureVerifyItem" });
10348
+ listUnverifiedCaptures = oc.route({
10194
10349
  method: "GET",
10195
- operationId: "listAlbumsMissingBio",
10196
- path: "/admin/albums/bio-queue",
10197
- summary: "List albums with findings but no bio yet, oldest first (the bio worklist)",
10350
+ operationId: "listUnverifiedCaptures",
10351
+ path: "/admin/catalogue/captures/unverified",
10352
+ summary: "Captured rows not yet fingerprint-verified against their preview (the backfill worklist)",
10198
10353
  tags: ["Admin"]
10199
- }).input(object({ limit: string2().optional() })).output(object({ albums: array(AlbumBioWorkItemSchema), ok: literal(true) }));
10200
- adminAlbumsContract = {
10201
- describe_album: describeAlbum,
10202
- draft_album_bio: draftAlbumBio,
10203
- list_albums_missing_bio: listAlbumsMissingBio
10204
- };
10205
- });
10206
-
10207
- // ../../packages/contracts/src/orpc/admin-artifacts.ts
10208
- var ARTIFACT_CHANGE_API_MAX_LIMIT = 500, ARTIFACT_SNAPSHOT_API_MAX_LIMIT = 200, ARTIFACT_COMPACTION_API_MAX_LIMIT = 1000, ARTIFACT_SUPPORTED_CONTRACTS, ArtifactStreamSchema, ArtifactContractSchema, ConsumerIdSchema, DigestSchema, SequenceSchema, ArtifactRebuildCheckpointSchema, ArtifactConsumerStatusSchema, ArtifactChangeEventSchema, ArtifactSnapshotItemSchema, ArtifactSnapshotPageSchema, ArtifactChangePageSchema, ArtifactCompactionResultSchema, registerArtifactConsumer, getArtifactConsumer, listArtifactSnapshot, checkpointArtifactRebuild, activateArtifactConsumer, listArtifactChanges, acknowledgeArtifactChanges, inactivateArtifactConsumer, compactArtifactChanges, adminArtifactsContract;
10209
- var init_admin_artifacts = __esm(() => {
10210
- init_dist3();
10211
- init_zod();
10212
- ARTIFACT_SUPPORTED_CONTRACTS = [
10213
- { formatVersion: 1, stream: "device.album", streamVersion: 1 },
10214
- { formatVersion: 1, stream: "device.artist", streamVersion: 1 },
10215
- { formatVersion: 1, stream: "device.finding", streamVersion: 1 },
10216
- { formatVersion: 1, stream: "device.label", streamVersion: 1 },
10217
- { formatVersion: 1, stream: "device.track", streamVersion: 1 },
10218
- { formatVersion: 1, stream: "device.track-artist", streamVersion: 1 },
10219
- { formatVersion: 1, stream: "sonar.track", streamVersion: 1 }
10220
- ];
10221
- ArtifactStreamSchema = _enum([
10222
- "device.album",
10223
- "device.artist",
10224
- "device.finding",
10225
- "device.label",
10226
- "device.track",
10227
- "device.track-artist",
10228
- "sonar.track"
10229
- ]);
10230
- ArtifactContractSchema = strictObject({
10231
- formatVersion: number2().int().positive(),
10232
- stream: ArtifactStreamSchema,
10233
- streamVersion: number2().int().positive()
10234
- });
10354
+ }).input(object({
10355
+ count: boolean3().default(false),
10356
+ limit: number3().int().min(1).max(200).default(50)
10357
+ })).output(object({
10358
+ ok: literal(true),
10359
+ queued: number2().optional(),
10360
+ tracks: array(CaptureVerifyItemSchema)
10361
+ }));
10362
+ verifyCapture = oc.route({
10363
+ method: "POST",
10364
+ operationId: "verifyCapture",
10365
+ path: "/admin/catalogue/captures/verify",
10366
+ summary: "Record a capture's fingerprint verdict against its preview, and route it",
10367
+ tags: ["Admin"]
10368
+ }).input(object({
10369
+ trackId: string2().min(1),
10370
+ verdict: _enum(["match", "mismatch", "no-preview"])
10371
+ })).output(object({
10372
+ action: _enum([
10373
+ "flagged-finding",
10374
+ "not-captured",
10375
+ "operator-verified",
10376
+ "preview-match",
10377
+ "quarantined-catalogue",
10378
+ "unverified"
10379
+ ]),
10380
+ ok: literal(true)
10381
+ }));
10382
+ CrawlPassSchema = object({
10383
+ artistsRearmed: number2().optional(),
10384
+ dryRun: boolean2(),
10385
+ expanded: number2(),
10386
+ failed: number2(),
10387
+ frontierPending: number2(),
10388
+ labelsDiscovered: array(string2()),
10389
+ maxHop: number2(),
10390
+ nodesEnqueued: number2(),
10391
+ rateLimited: boolean2(),
10392
+ releaseDetailsStored: number2().optional(),
10393
+ releasesRearmed: number2(),
10394
+ seeded: number2(),
10395
+ seedsRearmed: number2(),
10396
+ tracksAllowedIn: number2().optional(),
10397
+ tracksFound: number2(),
10398
+ tracksSkipped: number2(),
10399
+ tracksSkippedArtistRule: number2().optional(),
10400
+ tracksSkippedHeld: number2().optional(),
10401
+ tracksSkippedLabelGate: number2().optional(),
10402
+ tracksWritten: number2()
10403
+ }).meta({ id: "CrawlPass" });
10404
+ CrawlPhaseInitializationSchema = object({
10405
+ artistsRearmed: number2(),
10406
+ releasesRearmed: number2(),
10407
+ seeded: number2(),
10408
+ seedsRearmed: number2()
10409
+ });
10410
+ CrawlFetchPlanSchema = discriminatedUnion("kind", [
10411
+ object({ kind: literal("none") }),
10412
+ object({ kind: literal("single"), url: string2().max(2048) }),
10413
+ object({
10414
+ countField: literal("release-count"),
10415
+ kind: literal("tail"),
10416
+ pageSize: number2().int().positive(),
10417
+ pageUrlTemplate: string2().max(2048),
10418
+ probeUrl: string2().max(2048)
10419
+ })
10420
+ ]);
10421
+ SuppliedCrawlBodySchema = object({
10422
+ body: json().optional(),
10423
+ outcome: _enum(["body", "empty", "invalid", "oversize", "throttled"]),
10424
+ url: string2().max(2048)
10425
+ });
10426
+ MAX_CRAWL_COMMIT_BATCH = MAX_CRAWL_PREPARE_LIMIT;
10427
+ CRAWL_COMMIT_TOKEN_MAX_BYTES = 2 * 1024 * 1024;
10428
+ CRAWL_COMMIT_BATCH_MAX_TOTAL_BYTES = 8 * 1024 * 1024;
10429
+ CrawlCommitItemSchema = strictObject({
10430
+ commitToken: string2().max(CRAWL_COMMIT_TOKEN_MAX_BYTES),
10431
+ operationId: literal("catalogue.crawl"),
10432
+ operationKey: string2().max(128),
10433
+ requestDigest: string2().regex(/^[0-9a-f]{64}$/)
10434
+ });
10435
+ CrawlCommitReceiptSchema = object({
10436
+ elapsedMs: number2().int().min(0).optional(),
10437
+ error: string2().max(500).optional(),
10438
+ operationKey: string2().max(128),
10439
+ outcome: _enum([
10440
+ "committed",
10441
+ "conflict",
10442
+ "failed",
10443
+ "in-progress",
10444
+ "lookup-failed",
10445
+ "rejected",
10446
+ "safely-retryable"
10447
+ ]),
10448
+ replayed: boolean2(),
10449
+ result: json().optional(),
10450
+ resultIdentity: string2().optional(),
10451
+ state: _enum(["accepted", "committed", "rejected"]).optional()
10452
+ }).meta({ id: "CrawlCommitReceipt" });
10453
+ CrawlPhaseCapabilitiesSchema = strictObject({
10454
+ commitBatchLimit: number2().int().min(1).max(MAX_CRAWL_COMMIT_BATCH),
10455
+ commitBatchMaxTotalBytes: number2().int().min(1)
10456
+ });
10457
+ CrawlPhaseInputSchema = discriminatedUnion("phase", [
10458
+ object({ phase: literal("initialize") }),
10459
+ object({
10460
+ limit: number2().int().min(1).max(MAX_CRAWL_PREPARE_LIMIT).default(2),
10461
+ maxHop: number2().int().min(0).max(3).default(2),
10462
+ phase: literal("prepare"),
10463
+ sampleStorableRepair: boolean2().optional()
10464
+ }),
10465
+ object({
10466
+ phase: literal("fetch"),
10467
+ preparedToken: string2().max(2 * 1024 * 1024),
10468
+ supplied: array(SuppliedCrawlBodySchema).max(2).optional()
10469
+ }),
10470
+ object({
10471
+ commitToken: string2().max(2 * 1024 * 1024),
10472
+ operationId: literal("catalogue.crawl"),
10473
+ operationKey: string2().max(128),
10474
+ phase: literal("commit"),
10475
+ requestDigest: string2().regex(/^[0-9a-f]{64}$/)
10476
+ })
10477
+ ]);
10478
+ CrawlPhaseOutputSchema = discriminatedUnion("phase", [
10479
+ object({
10480
+ initialization: CrawlPhaseInitializationSchema,
10481
+ kind: _enum(["initialized", "unavailable"]),
10482
+ ok: literal(true),
10483
+ phase: literal("initialize")
10484
+ }),
10485
+ object({
10486
+ boxFetch: boolean2(),
10487
+ capabilities: CrawlPhaseCapabilitiesSchema.optional(),
10488
+ frontierPending: number2(),
10489
+ initialization: CrawlPhaseInitializationSchema,
10490
+ items: array(object({
10491
+ fetchPlan: CrawlFetchPlanSchema,
10492
+ nodeId: string2(),
10493
+ nodeKind: _enum(["artist", "label", "release"]).optional(),
10494
+ preparedToken: string2()
10495
+ })).max(MAX_CRAWL_PREPARE_LIMIT),
10496
+ kind: _enum(["drained", "prepared", "unavailable"]),
10497
+ ok: literal(true),
10498
+ phase: literal("prepare"),
10499
+ storableReady: boolean2().nullable().optional()
10500
+ }),
10501
+ object({
10502
+ commitToken: string2(),
10503
+ ok: literal(true),
10504
+ operationId: literal("catalogue.crawl"),
10505
+ operationKey: string2(),
10506
+ phase: literal("fetch"),
10507
+ rateLimited: boolean2().optional(),
10508
+ requestDigest: string2()
10509
+ }),
10510
+ object({
10511
+ ok: literal(true),
10512
+ phase: literal("commit"),
10513
+ receipt: object({
10514
+ outcome: _enum([
10515
+ "committed",
10516
+ "conflict",
10517
+ "in-progress",
10518
+ "lookup-failed",
10519
+ "rejected",
10520
+ "safely-retryable"
10521
+ ]),
10522
+ replayed: boolean2(),
10523
+ result: json().optional(),
10524
+ resultIdentity: string2().optional(),
10525
+ state: _enum(["accepted", "committed", "rejected"]).optional()
10526
+ })
10527
+ })
10528
+ ]);
10529
+ CrawlStatusSchema = object({
10530
+ anchorsPending: number2(),
10531
+ catalogueTracks: number2(),
10532
+ frontier: object({
10533
+ done: number2(),
10534
+ failed: number2(),
10535
+ pending: number2(),
10536
+ skipped: number2()
10537
+ }),
10538
+ frontierByKind: object({
10539
+ artist: number2(),
10540
+ label: number2(),
10541
+ release: number2()
10542
+ }),
10543
+ labelsUndecided: number2(),
10544
+ seedLabels: array(string2()),
10545
+ storablePending: number2(),
10546
+ undecidedLabelsQueued: number2(),
10547
+ unstorablePending: number2()
10548
+ }).meta({ id: "CrawlStatus" });
10549
+ CrawlPipelineSummarySchema = object({
10550
+ anchorsPending: number2(),
10551
+ frontier: object({ pending: number2() }),
10552
+ storablePending: number2(),
10553
+ summary: literal(true),
10554
+ unstorablePending: number2()
10555
+ }).meta({ id: "CrawlPipelineSummary" });
10556
+ crawlCatalogue = oc.route({
10557
+ inputStructure: "detailed",
10558
+ method: "POST",
10559
+ operationId: "crawlCatalogue",
10560
+ path: "/admin/catalogue/crawl",
10561
+ summary: "Run one bounded, resumable pass of the catalogue crawler",
10562
+ tags: ["Admin"]
10563
+ }).input(object({
10564
+ body: CrawlPhaseInputSchema.optional(),
10565
+ query: object({
10566
+ dryRun: string2().optional(),
10567
+ limit: string2().optional(),
10568
+ maxHop: string2().optional()
10569
+ })
10570
+ })).output(union([CrawlPassSchema.extend({ ok: literal(true) }), CrawlPhaseOutputSchema]));
10571
+ commitCrawlNodes = oc.route({
10572
+ method: "POST",
10573
+ operationId: "commitCrawlNodes",
10574
+ path: "/admin/catalogue/crawl/commits",
10575
+ summary: "Commit one claim's fetched crawl nodes in a single admitted phase",
10576
+ tags: ["Admin"]
10577
+ }).input(strictObject({
10578
+ items: array(CrawlCommitItemSchema).min(1).max(MAX_CRAWL_COMMIT_BATCH)
10579
+ })).output(strictObject({
10580
+ deferred: number2().int().min(0),
10581
+ ok: literal(true),
10582
+ receipts: array(CrawlCommitReceiptSchema).max(MAX_CRAWL_COMMIT_BATCH)
10583
+ }));
10584
+ getCrawlStatus = oc.route({
10585
+ method: "GET",
10586
+ operationId: "getCrawlStatus",
10587
+ path: "/admin/catalogue/crawl",
10588
+ summary: "The crawl frontier's state, the catalogue size, and the seed set",
10589
+ tags: ["Admin"]
10590
+ }).input(object({ summary: string2().optional() })).output(union([
10591
+ CrawlStatusSchema.extend({ ok: literal(true) }),
10592
+ CrawlPipelineSummarySchema.extend({ ok: literal(true) })
10593
+ ]));
10594
+ AnchorCandidateSchema = object({
10595
+ albumImageUrl: string2().max(ANCHOR_URL_MAX).nullish(),
10596
+ artists: array(object({
10597
+ id: string2().max(ANCHOR_ID_MAX).nullish(),
10598
+ name: string2().max(ANCHOR_TEXT_MAX)
10599
+ })).max(ANCHOR_ARTIST_LIMIT).default([]),
10600
+ durationMs: number2().nullish(),
10601
+ isrc: string2().max(ANCHOR_ISRC_MAX).nullish(),
10602
+ spotifyTrackId: string2().max(ANCHOR_ID_MAX).optional(),
10603
+ title: string2().max(ANCHOR_TEXT_MAX).default(""),
10604
+ uri: string2().max(ANCHOR_URL_MAX).optional(),
10605
+ url: string2().max(ANCHOR_URL_MAX).optional()
10606
+ }).refine((candidate) => Boolean(candidate.spotifyTrackId ?? candidate.uri ?? candidate.url), {
10607
+ error: "a candidate must carry a spotifyTrackId, uri, or url"
10608
+ }).meta({ id: "AnchorCandidate" });
10609
+ anchorTrack = oc.route({
10610
+ method: "POST",
10611
+ operationId: "anchorTrack",
10612
+ path: "/admin/catalogue/anchor",
10613
+ summary: "Verify box-supplied Spotify candidates against a catalogue row and write its anchor",
10614
+ tags: ["Admin"]
10615
+ }).input(object({
10616
+ candidates: array(AnchorCandidateSchema).max(ANCHOR_CANDIDATE_LIMIT).default([]),
10617
+ trackId: string2().min(1)
10618
+ })).output(object({
10619
+ anchored: boolean2(),
10620
+ ok: literal(true),
10621
+ verifiedBy: _enum(["isrc", "search", "search-subset"]).nullable()
10622
+ }));
10623
+ recordAnchorFailure = oc.route({
10624
+ method: "POST",
10625
+ operationId: "recordAnchorFailure",
10626
+ path: "/admin/catalogue/anchor/failure",
10627
+ summary: "Record a deterministic anchor candidate rejection",
10628
+ tags: ["Admin"]
10629
+ }).input(object({ status: union([literal(400), literal(422)]), trackId: string2().min(1) })).output(object({ attempts: number2().int(), ok: literal(true), terminal: boolean2() }));
10630
+ DeezerIsrcCandidateSchema = object({
10631
+ artistName: string2().max(DEEZER_TEXT_MAX),
10632
+ deezerTrackId: string2().max(DEEZER_TRACK_ID_MAX).optional(),
10633
+ durationMs: number2().positive().finite(),
10634
+ isrc: string2().max(DEEZER_ISRC_MAX),
10635
+ title: string2().max(DEEZER_TEXT_MAX)
10636
+ }).meta({ id: "DeezerIsrcCandidate" });
10637
+ resolveAnchor = oc.route({
10638
+ method: "POST",
10639
+ operationId: "resolveAnchor",
10640
+ path: "/admin/catalogue/anchor/resolve",
10641
+ summary: "Resolve a catalogue row's Spotify anchor from the free rungs (ListenBrainz + dark Spotify search)",
10642
+ tags: ["Admin"]
10643
+ }).input(object({
10644
+ deezerCandidates: array(DeezerIsrcCandidateSchema).max(DEEZER_CANDIDATE_LIMIT).optional(),
10645
+ spotifySearch: boolean2().optional(),
10646
+ trackId: string2().min(1)
10647
+ })).output(object({
10648
+ anchored: boolean2(),
10649
+ apifyBudgetRemaining: number2().int().nonnegative(),
10650
+ apifyEligible: boolean2(),
10651
+ apifyEnabled: boolean2(),
10652
+ apifyIneligibleReason: _enum(["apify_budget_spent", "awaiting_free_ask"]).nullable(),
10653
+ freeDurationMsOmitted: number2().int().nonnegative(),
10654
+ isrcRecoveredByDeezer: boolean2(),
10655
+ listenbrainzOutcome: _enum([
10656
+ "anchored",
10657
+ "empty-ids",
10658
+ "gate-rejected",
10659
+ "metadata-failed",
10660
+ "no-map",
10661
+ "no-mbid",
10662
+ "not-attempted",
10663
+ "request-failed",
10664
+ "yielded-on-breaker"
10665
+ ]),
10666
+ ok: literal(true),
10667
+ source: _enum(["listenbrainz", "spotify-isrc", "spotify-search"]).nullable(),
10668
+ spotifyIsrcAsked: boolean2(),
10669
+ spotifySearchDone: boolean2(),
10670
+ spotifySearchEnabled: boolean2(),
10671
+ spotifyThrottled: boolean2(),
10672
+ stamped: boolean2(),
10673
+ verifiedBy: _enum(["isrc", "search", "search-subset"]).nullable()
10674
+ }));
10675
+ resolveAnchorReview = oc.route({
10676
+ method: "POST",
10677
+ operationId: "resolveAnchorReview",
10678
+ path: "/admin/catalogue/anchor/reviews/{trackId}/resolve",
10679
+ summary: "Rule on a suspected version mismatch: anchor to the candidate, or dismiss (operator)",
10680
+ tags: ["Admin"]
10681
+ }).input(object({
10682
+ resolution: _enum(["accepted", "dismissed"]),
10683
+ trackId: string2().min(1)
10684
+ })).output(object({
10685
+ anchored: boolean2(),
10686
+ ok: literal(true),
10687
+ review: object({
10688
+ candidateTitle: string2(),
10689
+ spotifyTrackId: string2().optional()
10690
+ })
10691
+ }));
10692
+ setAnchorSearch = oc.route({
10693
+ method: "PUT",
10694
+ operationId: "setAnchorSearch",
10695
+ path: "/admin/catalogue/anchor/search",
10696
+ summary: "Flip the dark flag for the Spotify anchor-search rungs (operator)",
10697
+ tags: ["Admin"]
10698
+ }).input(object({ enabled: boolean2() })).output(object({ enabled: boolean2(), ok: literal(true) }));
10699
+ setAnchorApify = oc.route({
10700
+ method: "PUT",
10701
+ operationId: "setAnchorApify",
10702
+ path: "/admin/catalogue/anchor/apify",
10703
+ summary: "Flip the Apify anchor-fallback kill-flag — off = no-budget graceful state (operator)",
10704
+ tags: ["Admin"]
10705
+ }).input(object({ enabled: boolean2() })).output(object({ enabled: boolean2(), ok: literal(true), requeued: number2() }));
10706
+ CaptureBudgetStateSchema = object({
10707
+ budget: object({ dailyBytes: number2(), dailyTracks: number2() }),
10708
+ closedReason: _enum(["bytes_spent", "paused", "tracks_spent"]).nullable(),
10709
+ open: boolean2(),
10710
+ paused: boolean2(),
10711
+ remainingBytes: number2(),
10712
+ remainingTracks: number2(),
10713
+ spend: object({ bytes: number2(), tracks: number2() }),
10714
+ windowHours: number2()
10715
+ }).meta({ id: "CaptureBudgetState" });
10716
+ getCaptureBudget = oc.route({
10717
+ method: "GET",
10718
+ operationId: "getCaptureBudget",
10719
+ path: "/admin/catalogue/capture-budget",
10720
+ summary: "The catalogue capture budget: the switch, the caps, the 24h spend, what is left",
10721
+ tags: ["Admin"]
10722
+ }).input(object({})).output(CaptureBudgetStateSchema.extend({ ok: literal(true) }));
10723
+ setCaptureBudget = oc.route({
10724
+ method: "PUT",
10725
+ operationId: "setCaptureBudget",
10726
+ path: "/admin/catalogue/capture-budget",
10727
+ summary: "Set the catalogue capture budget / flip its kill switch (operator)",
10728
+ tags: ["Admin"]
10729
+ }).input(object({
10730
+ dailyBytes: number2().int().min(0).optional(),
10731
+ dailyTracks: number2().int().min(0).optional(),
10732
+ paused: boolean2().optional()
10733
+ })).output(CaptureBudgetStateSchema.extend({ ok: literal(true) }));
10734
+ AnchorApifyBudgetSchema = object({
10735
+ dailyRows: number2(),
10736
+ day: string2(),
10737
+ remainingRows: number2(),
10738
+ rowsSent: number2(),
10739
+ spent: boolean2()
10740
+ }).meta({ id: "AnchorApifyBudget" });
10741
+ getAnchorApifyBudget = oc.route({
10742
+ method: "GET",
10743
+ operationId: "getAnchorApifyBudget",
10744
+ path: "/admin/catalogue/anchor/apify-budget",
10745
+ summary: "The metered Apify anchor rung's daily row cap, today's spend, and what is left",
10746
+ tags: ["Admin"]
10747
+ }).input(object({})).output(AnchorApifyBudgetSchema.extend({ ok: literal(true) }));
10748
+ setAnchorApifyBudget = oc.route({
10749
+ method: "PUT",
10750
+ operationId: "setAnchorApifyBudget",
10751
+ path: "/admin/catalogue/anchor/apify-budget",
10752
+ summary: "Set the metered Apify anchor rung's daily row cap (operator)",
10753
+ tags: ["Admin"]
10754
+ }).input(object({ dailyRows: number2().int().min(0) })).output(AnchorApifyBudgetSchema.extend({ ok: literal(true) }));
10755
+ SpotifyAnchorBreakerStateSchema = object({
10756
+ cooldownRemainingMs: number2(),
10757
+ reason: string2().nullable(),
10758
+ throttlesInWindow: number2(),
10759
+ tripped: boolean2(),
10760
+ trippedAt: string2().nullable()
10761
+ }).meta({ id: "SpotifyAnchorBreakerState" });
10762
+ AnchorRungFlagsSchema = object({
10763
+ apifyBudget: AnchorApifyBudgetSchema,
10764
+ apifyEnabled: boolean2(),
10765
+ gateReason: _enum([
10766
+ "friday_window",
10767
+ "flag_off",
10768
+ "breaker_quota",
10769
+ "breaker_throttle",
10770
+ "shared_meter",
10771
+ "open"
10772
+ ]),
10773
+ nextEligibleAt: string2().nullable(),
10774
+ spotifySearchEnabled: boolean2()
10775
+ }).meta({ id: "AnchorRungFlags" });
10776
+ getSpotifyAnchorBreaker = oc.route({
10777
+ method: "GET",
10778
+ operationId: "getSpotifyAnchorBreaker",
10779
+ path: "/admin/catalogue/anchor/breaker",
10780
+ summary: "The Spotify anchor-search throttle breaker: tripped, why, how long left, and the rungs",
10781
+ tags: ["Admin"]
10782
+ }).input(object({})).output(SpotifyAnchorBreakerStateSchema.extend({ ok: literal(true), rungs: AnchorRungFlagsSchema }));
10783
+ resetSpotifyAnchorBreaker = oc.route({
10784
+ method: "POST",
10785
+ operationId: "resetSpotifyAnchorBreaker",
10786
+ path: "/admin/catalogue/anchor/breaker/reset",
10787
+ summary: "Clear the Spotify anchor-search throttle breaker (operator)",
10788
+ tags: ["Admin"]
10789
+ }).input(object({})).output(SpotifyAnchorBreakerStateSchema.extend({ ok: literal(true) }));
10790
+ AppleBreakerStateSchema = object({
10791
+ consecutiveAuthFailures: number2(),
10792
+ cooldownRemainingMs: number2(),
10793
+ tripped: boolean2(),
10794
+ trippedAt: string2().nullable()
10795
+ }).meta({ id: "AppleBreakerState" });
10796
+ resetAppleBreaker = oc.route({
10797
+ method: "POST",
10798
+ operationId: "resetAppleBreaker",
10799
+ path: "/admin/catalogue/apple-breaker/reset",
10800
+ summary: "Clear the Apple failure-regime breaker (operator)",
10801
+ tags: ["Admin"]
10802
+ }).input(object({})).output(AppleBreakerStateSchema.extend({ ok: literal(true) }));
10803
+ adminCatalogueContract = {
10804
+ anchor_track: anchorTrack,
10805
+ certify_track: certifyTrack,
10806
+ clear_wrong_audio: clearWrongAudio,
10807
+ commit_crawl_nodes: commitCrawlNodes,
10808
+ crawl_catalogue: crawlCatalogue,
10809
+ flag_wrong_audio: flagWrongAudio,
10810
+ force_capture: forceCapture,
10811
+ get_anchor_apify_budget: getAnchorApifyBudget,
10812
+ get_capture_budget: getCaptureBudget,
10813
+ get_crawl_status: getCrawlStatus,
10814
+ get_spotify_anchor_breaker: getSpotifyAnchorBreaker,
10815
+ list_catalogue_tracks: listCatalogueTracks,
10816
+ list_unverified_captures: listUnverifiedCaptures,
10817
+ rank_catalogue: rankCatalogue,
10818
+ record_anchor_failure: recordAnchorFailure,
10819
+ record_demand: recordDemand,
10820
+ requeue_anchor: requeueAnchor,
10821
+ requeue_isrc_recovery: requeueIsrcRecovery,
10822
+ requeue_unmatched_captures: requeueUnmatchedCaptures,
10823
+ reset_apple_breaker: resetAppleBreaker,
10824
+ reset_spotify_anchor_breaker: resetSpotifyAnchorBreaker,
10825
+ resolve_anchor: resolveAnchor,
10826
+ resolve_anchor_review: resolveAnchorReview,
10827
+ set_anchor_apify: setAnchorApify,
10828
+ set_anchor_apify_budget: setAnchorApifyBudget,
10829
+ set_anchor_search: setAnchorSearch,
10830
+ set_capture_budget: setCaptureBudget,
10831
+ set_track_dismissed: setTrackDismissed,
10832
+ verify_capture: verifyCapture
10833
+ };
10834
+ });
10835
+
10836
+ // ../../packages/contracts/src/orpc/admin-albums.ts
10837
+ var DescribeAlbumBodySchema, describeAlbum, draftAlbumBio, AlbumBioWorkItemSchema, listAlbumsMissingBio, adminAlbumsContract;
10838
+ var init_admin_albums = __esm(() => {
10839
+ init_dist3();
10840
+ init_zod();
10841
+ DescribeAlbumBodySchema = looseObject({
10842
+ bio: unknown().optional(),
10843
+ dryRun: unknown().optional(),
10844
+ finalAttempt: boolean2().optional(),
10845
+ promptVersion: number2().int().min(0).optional()
10846
+ });
10847
+ describeAlbum = oc.route({
10848
+ method: "POST",
10849
+ operationId: "describeAlbum",
10850
+ path: "/admin/albums/{slug}/bio",
10851
+ summary: "Auto-author an album's voiced bio (fills an empty bio only)",
10852
+ tags: ["Admin"]
10853
+ }).input(DescribeAlbumBodySchema.extend({ slug: string2() })).output(object({
10854
+ bio: string2(),
10855
+ dryRun: literal(true).optional(),
10856
+ gateBypassed: literal(true).optional(),
10857
+ ok: literal(true),
10858
+ skipped: boolean2().optional(),
10859
+ slug: string2(),
10860
+ voiceViolations: array(string2()).optional()
10861
+ }));
10862
+ draftAlbumBio = oc.route({
10863
+ method: "GET",
10864
+ operationId: "draftAlbumBio",
10865
+ path: "/admin/albums/{slug}/bio-draft",
10866
+ summary: "Assemble a ready-to-author bio prompt for an album (Worker-side grounding)",
10867
+ tags: ["Admin"]
10868
+ }).input(object({ slug: string2() })).output(object({
10869
+ findingCount: number2(),
10870
+ found: boolean2(),
10871
+ hasFacts: boolean2(),
10872
+ name: string2(),
10873
+ prompt: string2(),
10874
+ promptVersion: number2()
10875
+ }));
10876
+ AlbumBioWorkItemSchema = object({ id: string2(), name: string2(), slug: string2() }).meta({ id: "AlbumBioWorkItem" });
10877
+ listAlbumsMissingBio = oc.route({
10878
+ method: "GET",
10879
+ operationId: "listAlbumsMissingBio",
10880
+ path: "/admin/albums/bio-queue",
10881
+ summary: "List albums with findings but no bio yet, oldest first (the bio worklist)",
10882
+ tags: ["Admin"]
10883
+ }).input(object({ limit: string2().optional() })).output(object({ albums: array(AlbumBioWorkItemSchema), ok: literal(true) }));
10884
+ adminAlbumsContract = {
10885
+ describe_album: describeAlbum,
10886
+ draft_album_bio: draftAlbumBio,
10887
+ list_albums_missing_bio: listAlbumsMissingBio
10888
+ };
10889
+ });
10890
+
10891
+ // ../../packages/contracts/src/orpc/admin-artifacts.ts
10892
+ var ARTIFACT_CHANGE_API_MAX_LIMIT = 500, ARTIFACT_SNAPSHOT_API_MAX_LIMIT = 200, ARTIFACT_COMPACTION_API_MAX_LIMIT = 1000, ARTIFACT_SUPPORTED_CONTRACTS, ArtifactStreamSchema, ArtifactContractSchema, ConsumerIdSchema, DigestSchema, SequenceSchema, ArtifactRebuildCheckpointSchema, ArtifactConsumerStatusSchema, ArtifactChangeEventSchema, ArtifactSnapshotItemSchema, ArtifactSnapshotPageSchema, ArtifactChangePageSchema, ArtifactCompactionResultSchema, registerArtifactConsumer, getArtifactConsumer, listArtifactSnapshot, checkpointArtifactRebuild, activateArtifactConsumer, listArtifactChanges, acknowledgeArtifactChanges, inactivateArtifactConsumer, compactArtifactChanges, adminArtifactsContract;
10893
+ var init_admin_artifacts = __esm(() => {
10894
+ init_dist3();
10895
+ init_zod();
10896
+ ARTIFACT_SUPPORTED_CONTRACTS = [
10897
+ { formatVersion: 1, stream: "device.album", streamVersion: 1 },
10898
+ { formatVersion: 1, stream: "device.artist", streamVersion: 1 },
10899
+ { formatVersion: 1, stream: "device.finding", streamVersion: 1 },
10900
+ { formatVersion: 1, stream: "device.label", streamVersion: 1 },
10901
+ { formatVersion: 1, stream: "device.track", streamVersion: 1 },
10902
+ { formatVersion: 1, stream: "device.track-artist", streamVersion: 1 },
10903
+ { formatVersion: 1, stream: "sonar.track", streamVersion: 1 }
10904
+ ];
10905
+ ArtifactStreamSchema = _enum([
10906
+ "device.album",
10907
+ "device.artist",
10908
+ "device.finding",
10909
+ "device.label",
10910
+ "device.track",
10911
+ "device.track-artist",
10912
+ "sonar.track"
10913
+ ]);
10914
+ ArtifactContractSchema = strictObject({
10915
+ formatVersion: number2().int().positive(),
10916
+ stream: ArtifactStreamSchema,
10917
+ streamVersion: number2().int().positive()
10918
+ });
10235
10919
  ConsumerIdSchema = string2().min(1).max(128).regex(/^[a-z0-9][a-z0-9._:-]*$/);
10236
10920
  DigestSchema = string2().length(64).regex(/^[a-f0-9]{64}$/);
10237
10921
  SequenceSchema = number2().int().nonnegative();
@@ -10764,6 +11448,7 @@ var init_admin_attention2 = __esm(() => {
10764
11448
  init_dist3();
10765
11449
  init_zod();
10766
11450
  AttentionSourceSchema = _enum([
11451
+ "anchor-failure",
10767
11452
  "anchor-review",
10768
11453
  "artist-review",
10769
11454
  "attach-cues",
@@ -10892,465 +11577,132 @@ var init_admin_backfills = __esm(() => {
10892
11577
  images: array(DiscogsLabelDetailImageSchema).max(DISCOGS_LABEL_DETAIL_IMAGE_LIMIT)
10893
11578
  }),
10894
11579
  discogsLabelId: DiscogsIdSchema,
10895
- image: DiscogsLabelImageBytesSchema.optional(),
10896
- slug: string2().min(1).max(DISCOGS_TEXT_MAX)
10897
- }).superRefine((candidate, context) => {
10898
- if (candidate.detail.id !== candidate.discogsLabelId) {
10899
- context.addIssue({
10900
- code: "custom",
10901
- message: "Discogs label detail id must match its work id"
10902
- });
10903
- }
10904
- }).meta({ id: "DiscogsLabelCandidate" });
10905
- DiscogsLabelCandidateBatchSchema = array(DiscogsLabelCandidateSchema).max(DISCOGS_LABEL_WORK_LIMIT).superRefine((entries, context) => {
10906
- const slugs = new Set;
10907
- const base64Chars = entries.reduce((total, entry) => total + (entry.image?.bytesBase64.length ?? 0), 0);
10908
- if (base64Chars > MAX_LABEL_IMAGE_BASE64_CHARS * DISCOGS_LABEL_WORK_LIMIT) {
10909
- context.addIssue({
10910
- code: "custom",
10911
- message: "Discogs label-image candidate batch exceeds its decoded-image budget"
10912
- });
10913
- }
10914
- for (const entry of entries) {
10915
- if (slugs.has(entry.slug)) {
10916
- context.addIssue({
10917
- code: "custom",
10918
- message: "Discogs label candidate slugs must be unique"
10919
- });
10920
- return;
10921
- }
10922
- slugs.add(entry.slug);
10923
- }
10924
- });
10925
- DiscogsLabelWorkSchema = object({
10926
- discogsLabelId: DiscogsIdSchema,
10927
- slug: string2().min(1).max(DISCOGS_TEXT_MAX)
10928
- }).meta({ id: "DiscogsLabelWork" });
10929
- DiscogsResolvedSchema = object({
10930
- logId: string2(),
10931
- masterId: number2().optional(),
10932
- releaseId: number2(),
10933
- source: string2()
10934
- }).meta({ id: "DiscogsBackfillResolved" });
10935
- LastfmFailedSchema = object({
10936
- error: string2(),
10937
- logId: string2()
10938
- }).meta({ id: "LastfmBackfillFailed" });
10939
- AppleMusicResolvedSchema = object({
10940
- logId: string2(),
10941
- url: string2()
10942
- }).meta({ id: "AppleMusicBackfillResolved" });
10943
- AppleMusicFailedSchema = object({
10944
- error: string2(),
10945
- logId: string2()
10946
- }).meta({ id: "AppleMusicBackfillFailed" });
10947
- backfillDiscogs = oc.route({
10948
- inputStructure: "detailed",
10949
- method: "POST",
10950
- operationId: "backfillDiscogs",
10951
- path: "/admin/backfill/discogs",
10952
- summary: "Back-fill Discogs release ids over published findings (batched)",
10953
- tags: ["Admin"]
10954
- }).input(object({
10955
- body: object({
10956
- discogsCandidates: DiscogsReleaseCandidateBatchSchema.optional()
10957
- }).optional(),
10958
- query: object({
10959
- boxFetch: string2().optional(),
10960
- cursor: string2().optional(),
10961
- dryRun: string2().optional(),
10962
- limit: string2().optional()
10963
- })
10964
- })).output(object({
10965
- discogsWork: array(DiscogsReleaseWorkSchema).max(DISCOGS_RELEASE_WORK_LIMIT),
10966
- dryRun: boolean2(),
10967
- nextCursor: string2().nullable(),
10968
- ok: literal(true),
10969
- rateLimited: boolean2(),
10970
- rateLimitedBy: _enum(["discogs", "musicbrainz"]).nullable(),
10971
- resolved: array(DiscogsResolvedSchema),
10972
- resolvedCount: number2(),
10973
- skipped: array(string2()),
10974
- skippedCount: number2(),
10975
- unresolved: array(string2()),
10976
- unresolvedCount: number2()
10977
- }));
10978
- DiscogsFactsResolvedSchema = object({
10979
- catno: string2(),
10980
- slug: string2()
10981
- }).meta({ id: "DiscogsFactsResolved" });
10982
- DiscogsFactsFailedSchema = object({
10983
- error: string2(),
10984
- slug: string2()
10985
- }).meta({ id: "DiscogsFactsFailed" });
10986
- backfillDiscogsFacts = oc.route({
10987
- inputStructure: "detailed",
10988
- method: "POST",
10989
- operationId: "backfillDiscogsFacts",
10990
- path: "/admin/backfill/discogs-facts",
10991
- summary: "Back-fill album catalogue numbers + styles from already-resolved Discogs releases",
10992
- tags: ["Admin"]
10993
- }).input(object({
10994
- body: object({
10995
- discogsCandidates: DiscogsFactsCandidateBatchSchema.optional()
10996
- }).optional(),
10997
- query: object({
10998
- boxFetch: string2().optional(),
10999
- dryRun: string2().optional(),
11000
- limit: string2().optional()
11001
- })
11002
- })).output(object({
11003
- configured: boolean2(),
11004
- discogsWork: array(DiscogsFactsWorkSchema).max(DISCOGS_FACTS_WORK_LIMIT),
11005
- dryRun: boolean2(),
11006
- failed: array(DiscogsFactsFailedSchema),
11007
- failedCount: number2(),
11008
- none: array(string2()),
11009
- noneCount: number2(),
11010
- ok: literal(true),
11011
- rateLimited: boolean2(),
11012
- resolved: array(DiscogsFactsResolvedSchema),
11013
- resolvedCount: number2()
11014
- }));
11015
- backfillLastfm = oc.route({
11016
- inputStructure: "detailed",
11017
- method: "POST",
11018
- operationId: "backfillLastfm",
11019
- path: "/admin/backfill/lastfm",
11020
- summary: "Back-fill Last.fm loves over published findings (batched)",
11021
- tags: ["Admin"]
11022
- }).input(object({
11023
- query: object({
11024
- cursor: string2().optional(),
11025
- dryRun: string2().optional(),
11026
- limit: string2().optional()
11027
- })
11028
- })).output(object({
11029
- dryRun: boolean2(),
11030
- failed: array(LastfmFailedSchema),
11031
- failedCount: number2(),
11032
- loved: array(string2()),
11033
- lovedCount: number2(),
11034
- nextCursor: string2().nullable(),
11035
- ok: literal(true),
11036
- rateLimited: boolean2(),
11037
- skipped: array(string2()),
11038
- skippedCount: number2()
11039
- }));
11040
- backfillAppleMusic = oc.route({
11041
- inputStructure: "detailed",
11042
- method: "POST",
11043
- operationId: "backfillAppleMusic",
11044
- path: "/admin/backfill/apple-music",
11045
- summary: "Back-fill Apple Music URLs over published findings by exact ISRC (batched)",
11046
- tags: ["Admin"]
11047
- }).input(object({
11048
- query: object({
11049
- cursor: string2().optional(),
11050
- dryRun: string2().optional(),
11051
- limit: string2().optional()
11052
- })
11053
- })).output(object({
11054
- albumFactsWritten: number2(),
11055
- breakerTripped: boolean2(),
11056
- configured: boolean2(),
11057
- dryRun: boolean2(),
11058
- failed: array(AppleMusicFailedSchema),
11059
- failedCount: number2(),
11060
- nextCursor: string2().nullable(),
11061
- ok: literal(true),
11062
- rateLimited: boolean2(),
11063
- resolved: array(AppleMusicResolvedSchema),
11064
- resolvedCount: number2(),
11065
- skipped: array(string2()),
11066
- skippedCount: number2(),
11067
- unresolved: array(string2()),
11068
- unresolvedCount: number2()
11069
- }));
11070
- AppleCatalogueResolvedSchema = object({
11071
- trackId: string2(),
11072
- url: string2()
11073
- }).meta({ id: "AppleCatalogueResolved" });
11074
- AppleCatalogueFailedSchema = object({
11075
- error: string2(),
11076
- trackId: string2()
11077
- }).meta({ id: "AppleCatalogueFailed" });
11078
- backfillAppleCatalogue = oc.route({
11079
- inputStructure: "detailed",
11080
- method: "POST",
11081
- operationId: "backfillAppleCatalogue",
11082
- path: "/admin/backfill/apple-catalogue",
11083
- summary: "Back-fill Apple URLs + album facts over catalogue tracks by exact ISRC (batched)",
11084
- tags: ["Admin"]
11085
- }).input(object({
11086
- query: object({
11087
- dryRun: string2().optional(),
11088
- limit: string2().optional()
11089
- })
11090
- })).output(object({
11091
- albumFactsWritten: number2(),
11092
- breakerTripped: boolean2(),
11093
- configured: boolean2(),
11094
- dryRun: boolean2(),
11095
- failed: array(AppleCatalogueFailedSchema),
11096
- failedCount: number2(),
11097
- ok: literal(true),
11098
- rateLimited: boolean2(),
11099
- resolved: array(AppleCatalogueResolvedSchema),
11100
- resolvedCount: number2(),
11101
- unresolved: array(string2()),
11102
- unresolvedCount: number2()
11103
- }));
11104
- BeatportResolvedSchema = object({
11580
+ image: DiscogsLabelImageBytesSchema.optional(),
11581
+ slug: string2().min(1).max(DISCOGS_TEXT_MAX)
11582
+ }).superRefine((candidate, context) => {
11583
+ if (candidate.detail.id !== candidate.discogsLabelId) {
11584
+ context.addIssue({
11585
+ code: "custom",
11586
+ message: "Discogs label detail id must match its work id"
11587
+ });
11588
+ }
11589
+ }).meta({ id: "DiscogsLabelCandidate" });
11590
+ DiscogsLabelCandidateBatchSchema = array(DiscogsLabelCandidateSchema).max(DISCOGS_LABEL_WORK_LIMIT).superRefine((entries, context) => {
11591
+ const slugs = new Set;
11592
+ const base64Chars = entries.reduce((total, entry) => total + (entry.image?.bytesBase64.length ?? 0), 0);
11593
+ if (base64Chars > MAX_LABEL_IMAGE_BASE64_CHARS * DISCOGS_LABEL_WORK_LIMIT) {
11594
+ context.addIssue({
11595
+ code: "custom",
11596
+ message: "Discogs label-image candidate batch exceeds its decoded-image budget"
11597
+ });
11598
+ }
11599
+ for (const entry of entries) {
11600
+ if (slugs.has(entry.slug)) {
11601
+ context.addIssue({
11602
+ code: "custom",
11603
+ message: "Discogs label candidate slugs must be unique"
11604
+ });
11605
+ return;
11606
+ }
11607
+ slugs.add(entry.slug);
11608
+ }
11609
+ });
11610
+ DiscogsLabelWorkSchema = object({
11611
+ discogsLabelId: DiscogsIdSchema,
11612
+ slug: string2().min(1).max(DISCOGS_TEXT_MAX)
11613
+ }).meta({ id: "DiscogsLabelWork" });
11614
+ DiscogsResolvedSchema = object({
11105
11615
  logId: string2(),
11106
- url: string2()
11107
- }).meta({ id: "BeatportResolved" });
11108
- BeatportFailedSchema = object({
11616
+ masterId: number2().optional(),
11617
+ releaseId: number2(),
11618
+ source: string2()
11619
+ }).meta({ id: "DiscogsBackfillResolved" });
11620
+ LastfmFailedSchema = object({
11109
11621
  error: string2(),
11110
11622
  logId: string2()
11111
- }).meta({ id: "BeatportFailed" });
11112
- BeatportCatalogueResolvedSchema = object({
11113
- trackId: string2(),
11623
+ }).meta({ id: "LastfmBackfillFailed" });
11624
+ AppleMusicResolvedSchema = object({
11625
+ logId: string2(),
11114
11626
  url: string2()
11115
- }).meta({ id: "BeatportCatalogueResolved" });
11116
- BeatportCatalogueFailedSchema = object({
11627
+ }).meta({ id: "AppleMusicBackfillResolved" });
11628
+ AppleMusicFailedSchema = object({
11117
11629
  error: string2(),
11118
- trackId: string2()
11119
- }).meta({ id: "BeatportCatalogueFailed" });
11120
- backfillBeatport = oc.route({
11630
+ logId: string2()
11631
+ }).meta({ id: "AppleMusicBackfillFailed" });
11632
+ backfillDiscogs = oc.route({
11121
11633
  inputStructure: "detailed",
11122
11634
  method: "POST",
11123
- operationId: "backfillBeatport",
11124
- path: "/admin/backfill/beatport",
11125
- summary: "Back-fill Beatport URLs over published findings by exact ISRC",
11635
+ operationId: "backfillDiscogs",
11636
+ path: "/admin/backfill/discogs",
11637
+ summary: "Back-fill Discogs release ids over published findings (batched)",
11126
11638
  tags: ["Admin"]
11127
11639
  }).input(object({
11640
+ body: object({
11641
+ discogsCandidates: DiscogsReleaseCandidateBatchSchema.optional()
11642
+ }).optional(),
11128
11643
  query: object({
11644
+ boxFetch: string2().optional(),
11129
11645
  cursor: string2().optional(),
11130
11646
  dryRun: string2().optional(),
11131
11647
  limit: string2().optional()
11132
11648
  })
11133
11649
  })).output(object({
11134
- catalogueFailed: array(BeatportCatalogueFailedSchema),
11135
- catalogueFailedCount: number2(),
11136
- catalogueResolved: array(BeatportCatalogueResolvedSchema),
11137
- catalogueResolvedCount: number2(),
11138
- catalogueUnresolved: array(string2()),
11139
- catalogueUnresolvedCount: number2(),
11140
- configured: boolean2(),
11650
+ discogsWork: array(DiscogsReleaseWorkSchema).max(DISCOGS_RELEASE_WORK_LIMIT),
11141
11651
  dryRun: boolean2(),
11142
- failed: array(BeatportFailedSchema),
11143
- failedCount: number2(),
11144
11652
  nextCursor: string2().nullable(),
11145
11653
  ok: literal(true),
11146
- resolved: array(BeatportResolvedSchema),
11654
+ rateLimited: boolean2(),
11655
+ rateLimitedBy: _enum(["discogs", "musicbrainz"]).nullable(),
11656
+ resolved: array(DiscogsResolvedSchema),
11147
11657
  resolvedCount: number2(),
11148
11658
  skipped: array(string2()),
11149
11659
  skippedCount: number2(),
11150
11660
  unresolved: array(string2()),
11151
11661
  unresolvedCount: number2()
11152
11662
  }));
11153
- DeezerResolvedSchema = object({
11154
- trackId: string2(),
11155
- url: string2()
11156
- }).meta({ id: "DeezerResolved" });
11157
- DeezerFailedSchema = object({
11158
- error: string2(),
11159
- trackId: string2()
11160
- }).meta({ id: "DeezerFailed" });
11161
- backfillDeezer = oc.route({
11162
- inputStructure: "detailed",
11163
- method: "POST",
11164
- operationId: "backfillDeezer",
11165
- path: "/admin/backfill/deezer",
11166
- summary: "Back-fill Deezer track ids over certified + catalogue rows by exact ISRC",
11167
- tags: ["Admin"]
11168
- }).input(object({
11169
- query: object({
11170
- dryRun: string2().optional(),
11171
- limit: string2().optional()
11172
- })
11173
- })).output(object({
11174
- dryRun: boolean2(),
11175
- failed: array(DeezerFailedSchema),
11176
- failedCount: number2(),
11177
- ok: literal(true),
11178
- rateLimited: boolean2(),
11179
- resolved: array(DeezerResolvedSchema),
11180
- resolvedCount: number2(),
11181
- unresolved: array(string2()),
11182
- unresolvedCount: number2(),
11183
- unvouchable: array(string2()),
11184
- unvouchableCount: number2()
11185
- }));
11186
- backfillLabelReleases = oc.route({
11187
- method: "POST",
11188
- operationId: "backfillLabelReleases",
11189
- path: "/admin/backfill/label-releases",
11190
- summary: "Tap Spotify's fresh releases for enabled seed labels into catalogue rows (bounded)",
11191
- tags: ["Admin"]
11192
- }).input(object({
11193
- dryRun: boolean2().default(false),
11194
- limit: number3().int().min(1).max(200).default(5)
11195
- })).output(object({
11196
- albumsMatched: number2(),
11197
- albumsSeen: number2(),
11198
- budgetPaused: boolean2(),
11199
- configured: boolean2(),
11200
- dryRun: boolean2(),
11201
- failedFetches: number2(),
11202
- failedLabels: array(string2()),
11203
- fetchCeilingHit: boolean2(),
11204
- labelSlugs: array(string2()),
11205
- labelsProbed: number2(),
11206
- newRows: number2(),
11207
- newTrackIds: array(string2()),
11208
- ok: literal(true),
11209
- rateLimited: boolean2(),
11210
- skippedKnown: number2(),
11211
- skippedUndated: number2(),
11212
- skippedUngrounded: number2(),
11213
- tracksSkippedArtistRule: number2().optional()
11214
- }));
11215
- LabelImagesBackfillFailedSchema = object({
11216
- error: string2(),
11217
- slug: string2()
11218
- }).meta({ id: "LabelImagesBackfillFailed" });
11219
- backfillLabelImages = oc.route({
11220
- inputStructure: "detailed",
11221
- method: "POST",
11222
- operationId: "backfillLabelImages",
11223
- path: "/admin/backfill/label-images",
11224
- summary: "Resolve label logos (Discogs → Wikidata) into R2 for existing labels (batched)",
11225
- tags: ["Admin"]
11226
- }).input(object({
11227
- body: object({
11228
- discogsCandidates: DiscogsLabelCandidateBatchSchema.optional()
11229
- }).optional(),
11230
- query: object({
11231
- boxFetch: string2().optional(),
11232
- cursor: string2().optional(),
11233
- dryRun: string2().optional(),
11234
- limit: string2().optional()
11235
- })
11236
- })).output(object({
11237
- discogsWork: array(DiscogsLabelWorkSchema).max(DISCOGS_LABEL_WORK_LIMIT),
11238
- dryRun: boolean2(),
11239
- failed: array(LabelImagesBackfillFailedSchema),
11240
- failedCount: number2(),
11241
- nextCursor: string2().nullable(),
11242
- none: array(string2()),
11243
- noneCount: number2(),
11244
- ok: literal(true),
11245
- rateLimited: boolean2(),
11246
- resolved: array(string2()),
11247
- resolvedCount: number2()
11248
- }));
11249
- LabelLineageBackfillFailedSchema = object({
11250
- error: string2(),
11663
+ DiscogsFactsResolvedSchema = object({
11664
+ catno: string2(),
11251
11665
  slug: string2()
11252
- }).meta({ id: "LabelLineageBackfillFailed" });
11253
- backfillLabelLineage = oc.route({
11254
- inputStructure: "detailed",
11255
- method: "POST",
11256
- operationId: "backfillLabelLineage",
11257
- path: "/admin/backfill/label-lineage",
11258
- summary: "Resolve label lineage (founding date, place, parent imprint) from MusicBrainz (batched)",
11259
- tags: ["Admin"]
11260
- }).input(object({
11261
- query: object({
11262
- cursor: string2().optional(),
11263
- dryRun: string2().optional(),
11264
- limit: string2().optional()
11265
- })
11266
- })).output(object({
11267
- dryRun: boolean2(),
11268
- failed: array(LabelLineageBackfillFailedSchema),
11269
- failedCount: number2(),
11270
- nextCursor: string2().nullable(),
11271
- none: array(string2()),
11272
- noneCount: number2(),
11273
- ok: literal(true),
11274
- rateLimited: boolean2(),
11275
- resolved: array(string2()),
11276
- resolvedCount: number2(),
11277
- unmatchedParents: number2()
11278
- }));
11279
- CoverMastersFailedSchema = object({
11666
+ }).meta({ id: "DiscogsFactsResolved" });
11667
+ DiscogsFactsFailedSchema = object({
11280
11668
  error: string2(),
11281
11669
  slug: string2()
11282
- }).meta({ id: "CoverMastersFailed" });
11283
- backfillCoverMasters = oc.route({
11284
- inputStructure: "detailed",
11285
- method: "POST",
11286
- operationId: "backfillCoverMasters",
11287
- path: "/admin/backfill/cover-masters",
11288
- summary: "Resolve owned ≤1200² cover masters (album/artist) into R2 (batched)",
11289
- tags: ["Admin"]
11290
- }).input(object({
11291
- query: object({
11292
- cursor: string2().optional(),
11293
- dryRun: string2().optional(),
11294
- kind: string2().optional(),
11295
- limit: string2().optional(),
11296
- retry: string2().optional()
11297
- })
11298
- })).output(object({
11299
- dryRun: boolean2(),
11300
- failed: array(CoverMastersFailedSchema),
11301
- failedCount: number2(),
11302
- kind: _enum(["album", "artist"]),
11303
- nextCursor: string2().nullable(),
11304
- none: array(string2()),
11305
- noneCount: number2(),
11306
- ok: literal(true),
11307
- rateLimited: boolean2(),
11308
- requeued: array(string2()).optional(),
11309
- requeuedCount: number2().optional(),
11310
- resolved: array(string2()),
11311
- resolvedCount: number2()
11312
- }));
11313
- RecordingMbidsFailedSchema = object({
11314
- error: string2(),
11315
- trackId: string2()
11316
- }).meta({ id: "RecordingMbidsBackfillFailed" });
11317
- backfillRecordingMbids = oc.route({
11318
- inputStructure: "detailed",
11319
- method: "POST",
11320
- operationId: "backfillRecordingMbids",
11321
- path: "/admin/backfill/recording-mbids",
11322
- summary: "Fill MusicBrainz recording MBIDs (crawler PK strip + ISRC resolve) over tracks (batched)",
11670
+ }).meta({ id: "DiscogsFactsFailed" });
11671
+ backfillDiscogsFacts = oc.route({
11672
+ inputStructure: "detailed",
11673
+ method: "POST",
11674
+ operationId: "backfillDiscogsFacts",
11675
+ path: "/admin/backfill/discogs-facts",
11676
+ summary: "Back-fill album catalogue numbers + styles from already-resolved Discogs releases",
11323
11677
  tags: ["Admin"]
11324
11678
  }).input(object({
11679
+ body: object({
11680
+ discogsCandidates: DiscogsFactsCandidateBatchSchema.optional()
11681
+ }).optional(),
11325
11682
  query: object({
11326
- cursor: string2().optional(),
11683
+ boxFetch: string2().optional(),
11327
11684
  dryRun: string2().optional(),
11328
- isrcRefreshLimit: string2().optional(),
11329
11685
  limit: string2().optional()
11330
11686
  })
11331
11687
  })).output(object({
11688
+ configured: boolean2(),
11689
+ discogsWork: array(DiscogsFactsWorkSchema).max(DISCOGS_FACTS_WORK_LIMIT),
11332
11690
  dryRun: boolean2(),
11333
- failed: array(RecordingMbidsFailedSchema),
11691
+ failed: array(DiscogsFactsFailedSchema),
11334
11692
  failedCount: number2(),
11335
- isrcRefreshMissed: array(string2()),
11336
- isrcRefreshMissedCount: number2(),
11337
- isrcRefreshed: array(string2()),
11338
- isrcRefreshedCount: number2(),
11339
- missed: array(string2()),
11340
- missedCount: number2(),
11341
- nextCursor: string2().nullable(),
11693
+ none: array(string2()),
11694
+ noneCount: number2(),
11342
11695
  ok: literal(true),
11343
- prefixStripped: number2(),
11344
11696
  rateLimited: boolean2(),
11345
- resolved: array(string2()),
11697
+ resolved: array(DiscogsFactsResolvedSchema),
11346
11698
  resolvedCount: number2()
11347
11699
  }));
11348
- backfillArtistEdges = oc.route({
11700
+ backfillLastfm = oc.route({
11349
11701
  inputStructure: "detailed",
11350
11702
  method: "POST",
11351
- operationId: "backfillArtistEdges",
11352
- path: "/admin/backfill/artist-edges",
11353
- summary: "Fold artists_json names onto existing artist identities → track_artists (batched)",
11703
+ operationId: "backfillLastfm",
11704
+ path: "/admin/backfill/lastfm",
11705
+ summary: "Back-fill Last.fm loves over published findings (batched)",
11354
11706
  tags: ["Admin"]
11355
11707
  }).input(object({
11356
11708
  query: object({
@@ -11360,25 +11712,22 @@ var init_admin_backfills = __esm(() => {
11360
11712
  })
11361
11713
  })).output(object({
11362
11714
  dryRun: boolean2(),
11363
- edgesWritten: number2(),
11364
- fullyMatched: array(string2()),
11365
- fullyMatchedCount: number2(),
11715
+ failed: array(LastfmFailedSchema),
11716
+ failedCount: number2(),
11717
+ loved: array(string2()),
11718
+ lovedCount: number2(),
11366
11719
  nextCursor: string2().nullable(),
11367
11720
  ok: literal(true),
11368
- partiallyMatched: array(string2()),
11369
- partiallyMatchedCount: number2(),
11370
- queueDepth: number2(),
11371
- scanned: number2(),
11372
- unmatchedNames: number2(),
11373
- zeroMatched: array(string2()),
11374
- zeroMatchedCount: number2()
11721
+ rateLimited: boolean2(),
11722
+ skipped: array(string2()),
11723
+ skippedCount: number2()
11375
11724
  }));
11376
- backfillArtistCredits = oc.route({
11725
+ backfillAppleMusic = oc.route({
11377
11726
  inputStructure: "detailed",
11378
11727
  method: "POST",
11379
- operationId: "backfillArtistCredits",
11380
- path: "/admin/backfill/artist-credits",
11381
- summary: "Mint identity-true artists from MusicBrainz credits for slice 0's zero-matched residual (batched)",
11728
+ operationId: "backfillAppleMusic",
11729
+ path: "/admin/backfill/apple-music",
11730
+ summary: "Back-fill Apple Music URLs over published findings by exact ISRC (batched)",
11382
11731
  tags: ["Admin"]
11383
11732
  }).input(object({
11384
11733
  query: object({
@@ -11387,699 +11736,395 @@ var init_admin_backfills = __esm(() => {
11387
11736
  limit: string2().optional()
11388
11737
  })
11389
11738
  })).output(object({
11390
- adoptedArtists: number2(),
11739
+ albumFactsWritten: number2(),
11740
+ breakerTripped: boolean2(),
11741
+ configured: boolean2(),
11391
11742
  dryRun: boolean2(),
11392
- edgesWritten: number2(),
11393
- matchedArtists: number2(),
11394
- mintedArtists: number2(),
11743
+ failed: array(AppleMusicFailedSchema),
11744
+ failedCount: number2(),
11395
11745
  nextCursor: string2().nullable(),
11396
11746
  ok: literal(true),
11397
11747
  rateLimited: boolean2(),
11398
- scanned: number2(),
11399
- skippedNoIdentity: number2()
11400
- }));
11401
- adminBackfillsContract = {
11402
- backfill_apple_catalogue: backfillAppleCatalogue,
11403
- backfill_apple_music: backfillAppleMusic,
11404
- backfill_artist_credits: backfillArtistCredits,
11405
- backfill_artist_edges: backfillArtistEdges,
11406
- backfill_beatport: backfillBeatport,
11407
- backfill_cover_masters: backfillCoverMasters,
11408
- backfill_deezer: backfillDeezer,
11409
- backfill_discogs: backfillDiscogs,
11410
- backfill_discogs_facts: backfillDiscogsFacts,
11411
- backfill_label_images: backfillLabelImages,
11412
- backfill_label_lineage: backfillLabelLineage,
11413
- backfill_label_releases: backfillLabelReleases,
11414
- backfill_lastfm: backfillLastfm,
11415
- backfill_recording_mbids: backfillRecordingMbids
11416
- };
11417
- });
11418
-
11419
- // ../../packages/contracts/src/orpc/admin-bios.ts
11420
- var BioEntityKindSchema, resolveBioReview, adminBiosContract;
11421
- var init_admin_bios = __esm(() => {
11422
- init_dist3();
11423
- init_zod();
11424
- BioEntityKindSchema = _enum(["album", "artist", "label"]).meta({ id: "BioEntityKind" });
11425
- resolveBioReview = oc.route({
11426
- method: "POST",
11427
- operationId: "resolveBioReview",
11428
- path: "/admin/bio-reviews/{kind}/{slug}/resolve",
11429
- summary: "Rule on a bio that landed past the voice gate: keep it or send it back (operator)",
11430
- tags: ["Admin"]
11431
- }).input(object({
11432
- kind: BioEntityKindSchema,
11433
- resolution: _enum(["keep", "rewrite"]),
11434
- slug: string2()
11435
- })).output(object({
11436
- kind: BioEntityKindSchema,
11437
- ok: literal(true),
11438
- resolution: _enum(["keep", "rewrite"]),
11439
- slug: string2()
11748
+ resolved: array(AppleMusicResolvedSchema),
11749
+ resolvedCount: number2(),
11750
+ skipped: array(string2()),
11751
+ skippedCount: number2(),
11752
+ unresolved: array(string2()),
11753
+ unresolvedCount: number2()
11440
11754
  }));
11441
- adminBiosContract = {
11442
- resolve_bio_review: resolveBioReview
11443
- };
11444
- });
11445
-
11446
- // ../../packages/contracts/src/orpc/admin-catalogue.ts
11447
- var CatalogueLensSchema, CapturePriorityReasonSchema, CatalogueMatchSchema, CatalogueTrackItemSchema, CatalogueSummarySchema, listCatalogueTracks, rankCatalogue, recordDemand, clearWrongAudio, requeueUnmatchedCaptures, requeueAnchor, requeueIsrcRecovery, flagWrongAudio, forceCapture, certifyTrack, setTrackDismissed, CaptureVerifyItemSchema, listUnverifiedCaptures, verifyCapture, CrawlPassSchema, CrawlPhaseInitializationSchema, MAX_CRAWL_PREPARE_LIMIT = 6, CrawlFetchPlanSchema, SuppliedCrawlBodySchema, MAX_CRAWL_COMMIT_BATCH, CRAWL_COMMIT_TOKEN_MAX_BYTES, CRAWL_COMMIT_BATCH_MAX_TOTAL_BYTES, CrawlCommitItemSchema, CrawlCommitReceiptSchema, CrawlPhaseCapabilitiesSchema, CrawlPhaseInputSchema, CrawlPhaseOutputSchema, CrawlStatusSchema, crawlCatalogue, commitCrawlNodes, getCrawlStatus, ANCHOR_CANDIDATE_LIMIT = 100, ANCHOR_ARTIST_LIMIT = 20, ANCHOR_TEXT_MAX = 300, ANCHOR_ISRC_MAX = 64, ANCHOR_ID_MAX = 64, ANCHOR_URL_MAX = 2048, AnchorCandidateSchema, anchorTrack, DEEZER_CANDIDATE_LIMIT = 5, DEEZER_TEXT_MAX = 300, DEEZER_ISRC_MAX = 64, DEEZER_TRACK_ID_MAX = 32, DeezerIsrcCandidateSchema, resolveAnchor, resolveAnchorReview, setAnchorSearch, setAnchorApify, CaptureBudgetStateSchema, getCaptureBudget, setCaptureBudget, AnchorApifyBudgetSchema, getAnchorApifyBudget, setAnchorApifyBudget, SpotifyAnchorBreakerStateSchema, AnchorRungFlagsSchema, getSpotifyAnchorBreaker, resetSpotifyAnchorBreaker, AppleBreakerStateSchema, resetAppleBreaker, adminCatalogueContract;
11448
- var init_admin_catalogue = __esm(() => {
11449
- init_dist3();
11450
- init_zod();
11451
- CatalogueLensSchema = _enum(["capture", "dismissed", "ear", "failed", "quarantine", "unmatched"]).meta({ id: "CatalogueLens" });
11452
- CapturePriorityReasonSchema = object({
11453
- kind: _enum(["artist", "label", "none", "seed-label", "skipped-label", "unauthorized"]),
11454
- name: string2().nullable()
11455
- }).meta({ id: "CapturePriorityReason" });
11456
- CatalogueMatchSchema = object({
11457
- artists: array(string2()),
11458
- logId: string2().nullable(),
11459
- title: string2(),
11460
- trackId: string2()
11461
- }).meta({ id: "CatalogueMatch" });
11462
- CatalogueTrackItemSchema = object({
11463
- albumImageUrl: string2().nullable(),
11464
- appleMusicUrl: string2().nullable(),
11465
- artists: array(string2()),
11466
- bpm: number2().nullable(),
11467
- capturePriority: number2().nullable(),
11468
- captureReason: CapturePriorityReasonSchema.nullable(),
11469
- captureStatus: string2().nullable(),
11470
- captureVerification: string2().nullable(),
11471
- dismissedAt: string2().nullable(),
11472
- duplicateOf: CatalogueMatchSchema.nullable(),
11473
- hasCapturedAudio: boolean2(),
11474
- hasPreview: boolean2(),
11475
- isrc: string2().nullable(),
11476
- key: string2().nullable(),
11477
- label: string2().nullable(),
11478
- nearestFinding: CatalogueMatchSchema.nullable(),
11479
- nearestFindingScore: number2().nullable(),
11480
- rankedAt: string2().nullable(),
11481
- releaseDate: string2().nullable(),
11482
- sourceAudioAttemptedAt: string2().nullable().optional(),
11483
- spotifyUrl: string2().nullable(),
11484
- title: string2(),
11755
+ AppleCatalogueResolvedSchema = object({
11756
+ trackId: string2(),
11757
+ url: string2()
11758
+ }).meta({ id: "AppleCatalogueResolved" });
11759
+ AppleCatalogueFailedSchema = object({
11760
+ error: string2(),
11485
11761
  trackId: string2()
11486
- }).meta({ id: "CatalogueTrackItem" });
11487
- CatalogueSummarySchema = object({
11488
- awaitingCapture: number2(),
11489
- awaitingRank: number2(),
11490
- dismissed: number2(),
11491
- quarantined: number2(),
11492
- ranked: number2(),
11493
- total: number2()
11494
- }).meta({ id: "CatalogueSummary" });
11495
- listCatalogueTracks = oc.route({
11496
- method: "GET",
11497
- operationId: "listCatalogueTracks",
11498
- path: "/admin/catalogue",
11499
- summary: "The ranked catalogue: closest to a finding (`ear`), or next to capture (`capture`)",
11500
- tags: ["Admin"]
11501
- }).input(object({
11502
- lens: CatalogueLensSchema.default("ear"),
11503
- limit: number3().int().min(1).max(200).default(50)
11504
- })).output(object({
11505
- ok: literal(true),
11506
- summary: CatalogueSummarySchema,
11507
- tracks: array(CatalogueTrackItemSchema)
11508
- }));
11509
- rankCatalogue = oc.route({
11510
- method: "POST",
11511
- operationId: "rankCatalogue",
11512
- path: "/admin/catalogue/rank",
11513
- summary: "One tick of the catalogue ranking sweep (nearest finding + capture priority)",
11514
- tags: ["Admin"]
11515
- }).input(object({
11516
- countRemaining: boolean3().default(false),
11517
- limit: number3().int().min(1).max(1000).default(250)
11518
- })).output(object({
11519
- ok: literal(true),
11520
- summary: object({
11521
- catalogueDuplicates: number2(),
11522
- corpus: string2(),
11523
- embeddedFindings: number2(),
11524
- findings: number2(),
11525
- prioritized: number2(),
11526
- quarantined: number2(),
11527
- remaining: number2(),
11528
- scored: number2()
11529
- }),
11530
- telescope: union([
11531
- object({ changed: boolean2(), ok: literal(true), size: number2() }),
11532
- object({ ok: literal(false), reason: string2() })
11533
- ]).optional()
11534
- }));
11535
- recordDemand = oc.route({
11536
- method: "POST",
11537
- operationId: "recordDemand",
11538
- path: "/admin/catalogue/demand",
11539
- summary: "One demand tick: reorder crawl/capture priority from Simple Analytics pageviews",
11540
- tags: ["Admin"]
11541
- }).input(object({})).output(object({
11542
- ok: literal(true),
11543
- summary: object({
11544
- configured: boolean2(),
11545
- demandedArtists: number2(),
11546
- demandedLabels: number2(),
11547
- frontierPromoted: number2(),
11548
- pagesRead: number2(),
11549
- totalPageviews: number2(),
11550
- tracksScored: number2(),
11551
- unknownSlugs: number2(),
11552
- window: object({ end: string2(), start: string2() })
11553
- })
11554
- }));
11555
- clearWrongAudio = oc.route({
11556
- method: "POST",
11557
- operationId: "clearWrongAudio",
11558
- path: "/admin/catalogue/wrong-audio/clear",
11559
- summary: "Overrule the wrong-audio quarantine on one catalogue row (operator)",
11560
- tags: ["Admin"]
11561
- }).input(object({ trackId: string2().min(1) })).output(object({ cleared: boolean2(), ok: literal(true) }));
11562
- requeueUnmatchedCaptures = oc.route({
11563
- method: "POST",
11564
- operationId: "requeueUnmatchedCaptures",
11565
- path: "/admin/catalogue/captures/requeue-unmatched",
11566
- summary: "Re-queue terminal-unmatched catalogue captures after a matcher improvement (operator)",
11567
- tags: ["Admin"]
11568
- }).input(object({})).output(object({ ok: literal(true), requeued: number2(), skippedVetoed: number2() }));
11569
- requeueAnchor = oc.route({
11570
- method: "POST",
11571
- operationId: "requeueAnchor",
11572
- path: "/admin/catalogue/anchor/requeue",
11573
- summary: "Clear named rows' anchor re-ask backoff so the next tick retries them (operator)",
11574
- tags: ["Admin"]
11575
- }).input(object({ trackIds: array(string2().min(1)).min(1).max(250) })).output(object({ ok: literal(true), requeued: number2() }));
11576
- requeueIsrcRecovery = oc.route({
11762
+ }).meta({ id: "AppleCatalogueFailed" });
11763
+ backfillAppleCatalogue = oc.route({
11764
+ inputStructure: "detailed",
11577
11765
  method: "POST",
11578
- operationId: "requeueIsrcRecovery",
11579
- path: "/admin/catalogue/isrc-recovery/requeue",
11580
- summary: "Clear Deezer-empty ISRC-recovery stamps from a named window (operator)",
11766
+ operationId: "backfillAppleCatalogue",
11767
+ path: "/admin/backfill/apple-catalogue",
11768
+ summary: "Back-fill Apple URLs + album facts over catalogue tracks by exact ISRC (batched)",
11581
11769
  tags: ["Admin"]
11582
11770
  }).input(object({
11583
- dryRun: boolean2().default(true),
11584
- since: string2().regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z)?$/, "since must be an ISO date (2026-09-09) or instant (2026-09-09T00:00:00.000Z)")
11771
+ query: object({
11772
+ dryRun: string2().optional(),
11773
+ limit: string2().optional()
11774
+ })
11585
11775
  })).output(object({
11776
+ albumFactsWritten: number2(),
11777
+ breakerTripped: boolean2(),
11778
+ configured: boolean2(),
11586
11779
  dryRun: boolean2(),
11587
- matched: number2(),
11780
+ failed: array(AppleCatalogueFailedSchema),
11781
+ failedCount: number2(),
11588
11782
  ok: literal(true),
11589
- requeued: number2()
11783
+ rateLimited: boolean2(),
11784
+ resolved: array(AppleCatalogueResolvedSchema),
11785
+ resolvedCount: number2(),
11786
+ unresolved: array(string2()),
11787
+ unresolvedCount: number2()
11590
11788
  }));
11591
- flagWrongAudio = oc.route({
11592
- method: "POST",
11593
- operationId: "flagWrongAudio",
11594
- path: "/admin/catalogue/wrong-audio/flag",
11595
- summary: "Flag a finding's captured audio as the wrong recording (operator)",
11596
- tags: ["Admin"]
11597
- }).input(object({ trackId: string2().min(1) })).output(object({ flagged: boolean2(), ok: literal(true) }));
11598
- forceCapture = oc.route({
11599
- method: "POST",
11600
- operationId: "forceCapture",
11601
- path: "/admin/catalogue/force-capture",
11602
- summary: "Overrule the duplicate veto on one catalogue row so it can be captured (operator)",
11603
- tags: ["Admin"]
11604
- }).input(object({ trackId: string2().min(1) })).output(object({ forced: boolean2(), ok: literal(true) }));
11605
- certifyTrack = oc.route({
11606
- method: "POST",
11607
- operationId: "certifyTrack",
11608
- path: "/admin/catalogue/certify",
11609
- summary: "Certify an existing catalogue track in place — mint its finding (operator)",
11610
- tags: ["Admin"]
11611
- }).input(object({ note: string2().optional(), trackId: string2().min(1) })).output(object({ logId: string2(), ok: literal(true) }));
11612
- setTrackDismissed = oc.route({
11613
- method: "PUT",
11614
- operationId: "setTrackDismissed",
11615
- path: "/admin/catalogue/dismissed",
11616
- summary: "Dismiss a catalogue track ('not for me') or restore it (operator)",
11617
- tags: ["Admin"]
11618
- }).input(object({ dismissed: boolean2(), trackId: string2().min(1) })).output(object({ changed: boolean2(), ok: literal(true) }));
11619
- CaptureVerifyItemSchema = object({
11620
- artists: array(string2()),
11621
- certified: boolean2(),
11622
- durationMs: number2(),
11623
- isrc: string2().nullable(),
11624
- logId: string2().nullable(),
11625
- sourceAudioKey: string2(),
11626
- title: string2(),
11789
+ BeatportResolvedSchema = object({
11790
+ logId: string2(),
11791
+ url: string2()
11792
+ }).meta({ id: "BeatportResolved" });
11793
+ BeatportFailedSchema = object({
11794
+ error: string2(),
11795
+ logId: string2()
11796
+ }).meta({ id: "BeatportFailed" });
11797
+ BeatportCatalogueResolvedSchema = object({
11798
+ trackId: string2(),
11799
+ url: string2()
11800
+ }).meta({ id: "BeatportCatalogueResolved" });
11801
+ BeatportCatalogueFailedSchema = object({
11802
+ error: string2(),
11627
11803
  trackId: string2()
11628
- }).meta({ id: "CaptureVerifyItem" });
11629
- listUnverifiedCaptures = oc.route({
11630
- method: "GET",
11631
- operationId: "listUnverifiedCaptures",
11632
- path: "/admin/catalogue/captures/unverified",
11633
- summary: "Captured rows not yet fingerprint-verified against their preview (the backfill worklist)",
11804
+ }).meta({ id: "BeatportCatalogueFailed" });
11805
+ backfillBeatport = oc.route({
11806
+ inputStructure: "detailed",
11807
+ method: "POST",
11808
+ operationId: "backfillBeatport",
11809
+ path: "/admin/backfill/beatport",
11810
+ summary: "Back-fill Beatport URLs over published findings by exact ISRC",
11634
11811
  tags: ["Admin"]
11635
11812
  }).input(object({
11636
- count: boolean3().default(false),
11637
- limit: number3().int().min(1).max(200).default(50)
11813
+ query: object({
11814
+ cursor: string2().optional(),
11815
+ dryRun: string2().optional(),
11816
+ limit: string2().optional()
11817
+ })
11638
11818
  })).output(object({
11819
+ catalogueFailed: array(BeatportCatalogueFailedSchema),
11820
+ catalogueFailedCount: number2(),
11821
+ catalogueResolved: array(BeatportCatalogueResolvedSchema),
11822
+ catalogueResolvedCount: number2(),
11823
+ catalogueUnresolved: array(string2()),
11824
+ catalogueUnresolvedCount: number2(),
11825
+ configured: boolean2(),
11826
+ dryRun: boolean2(),
11827
+ failed: array(BeatportFailedSchema),
11828
+ failedCount: number2(),
11829
+ nextCursor: string2().nullable(),
11639
11830
  ok: literal(true),
11640
- queued: number2().optional(),
11641
- tracks: array(CaptureVerifyItemSchema)
11831
+ resolved: array(BeatportResolvedSchema),
11832
+ resolvedCount: number2(),
11833
+ skipped: array(string2()),
11834
+ skippedCount: number2(),
11835
+ unresolved: array(string2()),
11836
+ unresolvedCount: number2()
11642
11837
  }));
11643
- verifyCapture = oc.route({
11838
+ DeezerResolvedSchema = object({
11839
+ trackId: string2(),
11840
+ url: string2()
11841
+ }).meta({ id: "DeezerResolved" });
11842
+ DeezerFailedSchema = object({
11843
+ error: string2(),
11844
+ trackId: string2()
11845
+ }).meta({ id: "DeezerFailed" });
11846
+ backfillDeezer = oc.route({
11847
+ inputStructure: "detailed",
11644
11848
  method: "POST",
11645
- operationId: "verifyCapture",
11646
- path: "/admin/catalogue/captures/verify",
11647
- summary: "Record a capture's fingerprint verdict against its preview, and route it",
11849
+ operationId: "backfillDeezer",
11850
+ path: "/admin/backfill/deezer",
11851
+ summary: "Back-fill Deezer track ids over certified + catalogue rows by exact ISRC",
11648
11852
  tags: ["Admin"]
11649
11853
  }).input(object({
11650
- trackId: string2().min(1),
11651
- verdict: _enum(["match", "mismatch", "no-preview"])
11854
+ query: object({
11855
+ dryRun: string2().optional(),
11856
+ limit: string2().optional()
11857
+ })
11652
11858
  })).output(object({
11653
- action: _enum([
11654
- "flagged-finding",
11655
- "not-captured",
11656
- "operator-verified",
11657
- "preview-match",
11658
- "quarantined-catalogue",
11659
- "unverified"
11660
- ]),
11661
- ok: literal(true)
11662
- }));
11663
- CrawlPassSchema = object({
11664
- artistsRearmed: number2().optional(),
11665
11859
  dryRun: boolean2(),
11666
- expanded: number2(),
11667
- failed: number2(),
11668
- frontierPending: number2(),
11669
- labelsDiscovered: array(string2()),
11670
- maxHop: number2(),
11671
- nodesEnqueued: number2(),
11860
+ failed: array(DeezerFailedSchema),
11861
+ failedCount: number2(),
11862
+ ok: literal(true),
11672
11863
  rateLimited: boolean2(),
11673
- releasesRearmed: number2(),
11674
- seeded: number2(),
11675
- seedsRearmed: number2(),
11676
- tracksAllowedIn: number2().optional(),
11677
- tracksFound: number2(),
11678
- tracksSkipped: number2(),
11679
- tracksSkippedArtistRule: number2().optional(),
11680
- tracksSkippedHeld: number2().optional(),
11681
- tracksSkippedLabelGate: number2().optional(),
11682
- tracksWritten: number2()
11683
- }).meta({ id: "CrawlPass" });
11684
- CrawlPhaseInitializationSchema = object({
11685
- artistsRearmed: number2(),
11686
- releasesRearmed: number2(),
11687
- seeded: number2(),
11688
- seedsRearmed: number2()
11689
- });
11690
- CrawlFetchPlanSchema = discriminatedUnion("kind", [
11691
- object({ kind: literal("none") }),
11692
- object({ kind: literal("single"), url: string2().max(2048) }),
11693
- object({
11694
- countField: literal("release-count"),
11695
- kind: literal("tail"),
11696
- pageSize: number2().int().positive(),
11697
- pageUrlTemplate: string2().max(2048),
11698
- probeUrl: string2().max(2048)
11699
- })
11700
- ]);
11701
- SuppliedCrawlBodySchema = object({
11702
- body: json().optional(),
11703
- outcome: _enum(["body", "empty", "invalid", "oversize", "throttled"]),
11704
- url: string2().max(2048)
11705
- });
11706
- MAX_CRAWL_COMMIT_BATCH = MAX_CRAWL_PREPARE_LIMIT;
11707
- CRAWL_COMMIT_TOKEN_MAX_BYTES = 2 * 1024 * 1024;
11708
- CRAWL_COMMIT_BATCH_MAX_TOTAL_BYTES = 8 * 1024 * 1024;
11709
- CrawlCommitItemSchema = strictObject({
11710
- commitToken: string2().max(CRAWL_COMMIT_TOKEN_MAX_BYTES),
11711
- operationId: literal("catalogue.crawl"),
11712
- operationKey: string2().max(128),
11713
- requestDigest: string2().regex(/^[0-9a-f]{64}$/)
11714
- });
11715
- CrawlCommitReceiptSchema = object({
11716
- elapsedMs: number2().int().min(0).optional(),
11717
- error: string2().max(500).optional(),
11718
- operationKey: string2().max(128),
11719
- outcome: _enum([
11720
- "committed",
11721
- "conflict",
11722
- "failed",
11723
- "in-progress",
11724
- "lookup-failed",
11725
- "rejected",
11726
- "safely-retryable"
11727
- ]),
11728
- replayed: boolean2(),
11729
- result: json().optional(),
11730
- resultIdentity: string2().optional(),
11731
- state: _enum(["accepted", "committed", "rejected"]).optional()
11732
- }).meta({ id: "CrawlCommitReceipt" });
11733
- CrawlPhaseCapabilitiesSchema = strictObject({
11734
- commitBatchLimit: number2().int().min(1).max(MAX_CRAWL_COMMIT_BATCH),
11735
- commitBatchMaxTotalBytes: number2().int().min(1)
11736
- });
11737
- CrawlPhaseInputSchema = discriminatedUnion("phase", [
11738
- object({ phase: literal("initialize") }),
11739
- object({
11740
- limit: number2().int().min(1).max(MAX_CRAWL_PREPARE_LIMIT).default(2),
11741
- maxHop: number2().int().min(0).max(3).default(2),
11742
- phase: literal("prepare")
11743
- }),
11744
- object({
11745
- phase: literal("fetch"),
11746
- preparedToken: string2().max(2 * 1024 * 1024),
11747
- supplied: array(SuppliedCrawlBodySchema).max(2).optional()
11748
- }),
11749
- object({
11750
- commitToken: string2().max(2 * 1024 * 1024),
11751
- operationId: literal("catalogue.crawl"),
11752
- operationKey: string2().max(128),
11753
- phase: literal("commit"),
11754
- requestDigest: string2().regex(/^[0-9a-f]{64}$/)
11864
+ resolved: array(DeezerResolvedSchema),
11865
+ resolvedCount: number2(),
11866
+ unresolved: array(string2()),
11867
+ unresolvedCount: number2(),
11868
+ unvouchable: array(string2()),
11869
+ unvouchableCount: number2()
11870
+ }));
11871
+ backfillLabelReleases = oc.route({
11872
+ method: "POST",
11873
+ operationId: "backfillLabelReleases",
11874
+ path: "/admin/backfill/label-releases",
11875
+ summary: "Tap Spotify's fresh releases for enabled seed labels into catalogue rows (bounded)",
11876
+ tags: ["Admin"]
11877
+ }).input(object({
11878
+ dryRun: boolean2().default(false),
11879
+ limit: number3().int().min(1).max(200).default(5)
11880
+ })).output(object({
11881
+ albumsMatched: number2(),
11882
+ albumsSeen: number2(),
11883
+ budgetPaused: boolean2(),
11884
+ configured: boolean2(),
11885
+ dryRun: boolean2(),
11886
+ failedFetches: number2(),
11887
+ failedLabels: array(string2()),
11888
+ fetchCeilingHit: boolean2(),
11889
+ labelSlugs: array(string2()),
11890
+ labelsProbed: number2(),
11891
+ newRows: number2(),
11892
+ newTrackIds: array(string2()),
11893
+ ok: literal(true),
11894
+ rateLimited: boolean2(),
11895
+ skippedKnown: number2(),
11896
+ skippedUndated: number2(),
11897
+ skippedUngrounded: number2(),
11898
+ tracksSkippedArtistRule: number2().optional()
11899
+ }));
11900
+ LabelImagesBackfillFailedSchema = object({
11901
+ error: string2(),
11902
+ slug: string2()
11903
+ }).meta({ id: "LabelImagesBackfillFailed" });
11904
+ backfillLabelImages = oc.route({
11905
+ inputStructure: "detailed",
11906
+ method: "POST",
11907
+ operationId: "backfillLabelImages",
11908
+ path: "/admin/backfill/label-images",
11909
+ summary: "Resolve label logos (Discogs → Wikidata) into R2 for existing labels (batched)",
11910
+ tags: ["Admin"]
11911
+ }).input(object({
11912
+ body: object({
11913
+ discogsCandidates: DiscogsLabelCandidateBatchSchema.optional()
11914
+ }).optional(),
11915
+ query: object({
11916
+ boxFetch: string2().optional(),
11917
+ cursor: string2().optional(),
11918
+ dryRun: string2().optional(),
11919
+ limit: string2().optional()
11755
11920
  })
11756
- ]);
11757
- CrawlPhaseOutputSchema = discriminatedUnion("phase", [
11758
- object({
11759
- initialization: CrawlPhaseInitializationSchema,
11760
- kind: _enum(["initialized", "unavailable"]),
11761
- ok: literal(true),
11762
- phase: literal("initialize")
11763
- }),
11764
- object({
11765
- boxFetch: boolean2(),
11766
- capabilities: CrawlPhaseCapabilitiesSchema.optional(),
11767
- frontierPending: number2(),
11768
- initialization: CrawlPhaseInitializationSchema,
11769
- items: array(object({
11770
- fetchPlan: CrawlFetchPlanSchema,
11771
- nodeId: string2(),
11772
- preparedToken: string2()
11773
- })).max(MAX_CRAWL_PREPARE_LIMIT),
11774
- kind: _enum(["drained", "prepared", "unavailable"]),
11775
- ok: literal(true),
11776
- phase: literal("prepare")
11777
- }),
11778
- object({
11779
- commitToken: string2(),
11780
- ok: literal(true),
11781
- operationId: literal("catalogue.crawl"),
11782
- operationKey: string2(),
11783
- phase: literal("fetch"),
11784
- rateLimited: boolean2().optional(),
11785
- requestDigest: string2()
11786
- }),
11787
- object({
11788
- ok: literal(true),
11789
- phase: literal("commit"),
11790
- receipt: object({
11791
- outcome: _enum([
11792
- "committed",
11793
- "conflict",
11794
- "in-progress",
11795
- "lookup-failed",
11796
- "rejected",
11797
- "safely-retryable"
11798
- ]),
11799
- replayed: boolean2(),
11800
- result: json().optional(),
11801
- resultIdentity: string2().optional(),
11802
- state: _enum(["accepted", "committed", "rejected"]).optional()
11803
- })
11921
+ })).output(object({
11922
+ discogsWork: array(DiscogsLabelWorkSchema).max(DISCOGS_LABEL_WORK_LIMIT),
11923
+ dryRun: boolean2(),
11924
+ failed: array(LabelImagesBackfillFailedSchema),
11925
+ failedCount: number2(),
11926
+ nextCursor: string2().nullable(),
11927
+ none: array(string2()),
11928
+ noneCount: number2(),
11929
+ ok: literal(true),
11930
+ rateLimited: boolean2(),
11931
+ resolved: array(string2()),
11932
+ resolvedCount: number2()
11933
+ }));
11934
+ LabelLineageBackfillFailedSchema = object({
11935
+ error: string2(),
11936
+ slug: string2()
11937
+ }).meta({ id: "LabelLineageBackfillFailed" });
11938
+ backfillLabelLineage = oc.route({
11939
+ inputStructure: "detailed",
11940
+ method: "POST",
11941
+ operationId: "backfillLabelLineage",
11942
+ path: "/admin/backfill/label-lineage",
11943
+ summary: "Resolve label lineage (founding date, place, parent imprint) from MusicBrainz (batched)",
11944
+ tags: ["Admin"]
11945
+ }).input(object({
11946
+ query: object({
11947
+ cursor: string2().optional(),
11948
+ dryRun: string2().optional(),
11949
+ limit: string2().optional()
11804
11950
  })
11805
- ]);
11806
- CrawlStatusSchema = object({
11807
- anchorsPending: number2(),
11808
- catalogueTracks: number2(),
11809
- frontier: object({
11810
- done: number2(),
11811
- failed: number2(),
11812
- pending: number2(),
11813
- skipped: number2()
11814
- }),
11815
- frontierByKind: object({
11816
- artist: number2(),
11817
- label: number2(),
11818
- release: number2()
11819
- }),
11820
- labelsUndecided: number2(),
11821
- seedLabels: array(string2()),
11822
- storablePending: number2(),
11823
- undecidedLabelsQueued: number2(),
11824
- unstorablePending: number2()
11825
- }).meta({ id: "CrawlStatus" });
11826
- crawlCatalogue = oc.route({
11951
+ })).output(object({
11952
+ dryRun: boolean2(),
11953
+ failed: array(LabelLineageBackfillFailedSchema),
11954
+ failedCount: number2(),
11955
+ nextCursor: string2().nullable(),
11956
+ none: array(string2()),
11957
+ noneCount: number2(),
11958
+ ok: literal(true),
11959
+ rateLimited: boolean2(),
11960
+ resolved: array(string2()),
11961
+ resolvedCount: number2(),
11962
+ unmatchedParents: number2()
11963
+ }));
11964
+ CoverMastersFailedSchema = object({
11965
+ error: string2(),
11966
+ slug: string2()
11967
+ }).meta({ id: "CoverMastersFailed" });
11968
+ backfillCoverMasters = oc.route({
11827
11969
  inputStructure: "detailed",
11828
11970
  method: "POST",
11829
- operationId: "crawlCatalogue",
11830
- path: "/admin/catalogue/crawl",
11831
- summary: "Run one bounded, resumable pass of the catalogue crawler",
11971
+ operationId: "backfillCoverMasters",
11972
+ path: "/admin/backfill/cover-masters",
11973
+ summary: "Resolve owned ≤1200² cover masters (album/artist) into R2 (batched)",
11832
11974
  tags: ["Admin"]
11833
11975
  }).input(object({
11834
- body: CrawlPhaseInputSchema.optional(),
11835
11976
  query: object({
11977
+ cursor: string2().optional(),
11836
11978
  dryRun: string2().optional(),
11979
+ kind: string2().optional(),
11837
11980
  limit: string2().optional(),
11838
- maxHop: string2().optional()
11981
+ retry: string2().optional()
11839
11982
  })
11840
- })).output(union([CrawlPassSchema.extend({ ok: literal(true) }), CrawlPhaseOutputSchema]));
11841
- commitCrawlNodes = oc.route({
11983
+ })).output(object({
11984
+ dryRun: boolean2(),
11985
+ failed: array(CoverMastersFailedSchema),
11986
+ failedCount: number2(),
11987
+ kind: _enum(["album", "artist"]),
11988
+ nextCursor: string2().nullable(),
11989
+ none: array(string2()),
11990
+ noneCount: number2(),
11991
+ ok: literal(true),
11992
+ rateLimited: boolean2(),
11993
+ requeued: array(string2()).optional(),
11994
+ requeuedCount: number2().optional(),
11995
+ resolved: array(string2()),
11996
+ resolvedCount: number2()
11997
+ }));
11998
+ RecordingMbidsFailedSchema = object({
11999
+ error: string2(),
12000
+ trackId: string2()
12001
+ }).meta({ id: "RecordingMbidsBackfillFailed" });
12002
+ backfillRecordingMbids = oc.route({
12003
+ inputStructure: "detailed",
11842
12004
  method: "POST",
11843
- operationId: "commitCrawlNodes",
11844
- path: "/admin/catalogue/crawl/commits",
11845
- summary: "Commit one claim's fetched crawl nodes in a single admitted phase",
12005
+ operationId: "backfillRecordingMbids",
12006
+ path: "/admin/backfill/recording-mbids",
12007
+ summary: "Fill MusicBrainz recording MBIDs (crawler PK strip + ISRC resolve) over tracks (batched)",
11846
12008
  tags: ["Admin"]
11847
- }).input(strictObject({
11848
- items: array(CrawlCommitItemSchema).min(1).max(MAX_CRAWL_COMMIT_BATCH)
11849
- })).output(strictObject({
11850
- deferred: number2().int().min(0),
12009
+ }).input(object({
12010
+ query: object({
12011
+ cursor: string2().optional(),
12012
+ dryRun: string2().optional(),
12013
+ isrcRefreshLimit: string2().optional(),
12014
+ limit: string2().optional()
12015
+ })
12016
+ })).output(object({
12017
+ dryRun: boolean2(),
12018
+ failed: array(RecordingMbidsFailedSchema),
12019
+ failedCount: number2(),
12020
+ isrcRefreshMissed: array(string2()),
12021
+ isrcRefreshMissedCount: number2(),
12022
+ isrcRefreshed: array(string2()),
12023
+ isrcRefreshedCount: number2(),
12024
+ missed: array(string2()),
12025
+ missedCount: number2(),
12026
+ nextCursor: string2().nullable(),
11851
12027
  ok: literal(true),
11852
- receipts: array(CrawlCommitReceiptSchema).max(MAX_CRAWL_COMMIT_BATCH)
12028
+ prefixStripped: number2(),
12029
+ rateLimited: boolean2(),
12030
+ resolved: array(string2()),
12031
+ resolvedCount: number2()
11853
12032
  }));
11854
- getCrawlStatus = oc.route({
11855
- method: "GET",
11856
- operationId: "getCrawlStatus",
11857
- path: "/admin/catalogue/crawl",
11858
- summary: "The crawl frontier's state, the catalogue size, and the seed set",
11859
- tags: ["Admin"]
11860
- }).input(object({})).output(CrawlStatusSchema.extend({ ok: literal(true) }));
11861
- AnchorCandidateSchema = object({
11862
- albumImageUrl: string2().max(ANCHOR_URL_MAX).nullish(),
11863
- artists: array(object({
11864
- id: string2().max(ANCHOR_ID_MAX).nullish(),
11865
- name: string2().max(ANCHOR_TEXT_MAX)
11866
- })).max(ANCHOR_ARTIST_LIMIT).default([]),
11867
- durationMs: number2().nullish(),
11868
- isrc: string2().max(ANCHOR_ISRC_MAX).nullish(),
11869
- spotifyTrackId: string2().max(ANCHOR_ID_MAX).optional(),
11870
- title: string2().max(ANCHOR_TEXT_MAX).default(""),
11871
- uri: string2().max(ANCHOR_URL_MAX).optional(),
11872
- url: string2().max(ANCHOR_URL_MAX).optional()
11873
- }).refine((candidate) => Boolean(candidate.spotifyTrackId ?? candidate.uri ?? candidate.url), {
11874
- error: "a candidate must carry a spotifyTrackId, uri, or url"
11875
- }).meta({ id: "AnchorCandidate" });
11876
- anchorTrack = oc.route({
12033
+ backfillArtistEdges = oc.route({
12034
+ inputStructure: "detailed",
11877
12035
  method: "POST",
11878
- operationId: "anchorTrack",
11879
- path: "/admin/catalogue/anchor",
11880
- summary: "Verify box-supplied Spotify candidates against a catalogue row and write its anchor",
12036
+ operationId: "backfillArtistEdges",
12037
+ path: "/admin/backfill/artist-edges",
12038
+ summary: "Fold artists_json names onto existing artist identities → track_artists (batched)",
11881
12039
  tags: ["Admin"]
11882
12040
  }).input(object({
11883
- candidates: array(AnchorCandidateSchema).max(ANCHOR_CANDIDATE_LIMIT).default([]),
11884
- trackId: string2().min(1)
12041
+ query: object({
12042
+ cursor: string2().optional(),
12043
+ dryRun: string2().optional(),
12044
+ limit: string2().optional()
12045
+ })
11885
12046
  })).output(object({
11886
- anchored: boolean2(),
12047
+ dryRun: boolean2(),
12048
+ edgesWritten: number2(),
12049
+ fullyMatched: array(string2()),
12050
+ fullyMatchedCount: number2(),
12051
+ nextCursor: string2().nullable(),
11887
12052
  ok: literal(true),
11888
- verifiedBy: _enum(["isrc", "search", "search-subset"]).nullable()
12053
+ partiallyMatched: array(string2()),
12054
+ partiallyMatchedCount: number2(),
12055
+ queueDepth: number2(),
12056
+ scanned: number2(),
12057
+ unmatchedNames: number2(),
12058
+ zeroMatched: array(string2()),
12059
+ zeroMatchedCount: number2()
11889
12060
  }));
11890
- DeezerIsrcCandidateSchema = object({
11891
- artistName: string2().max(DEEZER_TEXT_MAX),
11892
- deezerTrackId: string2().max(DEEZER_TRACK_ID_MAX).optional(),
11893
- durationMs: number2().positive().finite(),
11894
- isrc: string2().max(DEEZER_ISRC_MAX),
11895
- title: string2().max(DEEZER_TEXT_MAX)
11896
- }).meta({ id: "DeezerIsrcCandidate" });
11897
- resolveAnchor = oc.route({
12061
+ backfillArtistCredits = oc.route({
12062
+ inputStructure: "detailed",
11898
12063
  method: "POST",
11899
- operationId: "resolveAnchor",
11900
- path: "/admin/catalogue/anchor/resolve",
11901
- summary: "Resolve a catalogue row's Spotify anchor from the free rungs (ListenBrainz + dark Spotify search)",
12064
+ operationId: "backfillArtistCredits",
12065
+ path: "/admin/backfill/artist-credits",
12066
+ summary: "Mint identity-true artists from MusicBrainz credits for slice 0's zero-matched residual (batched)",
11902
12067
  tags: ["Admin"]
11903
12068
  }).input(object({
11904
- deezerCandidates: array(DeezerIsrcCandidateSchema).max(DEEZER_CANDIDATE_LIMIT).optional(),
11905
- spotifySearch: boolean2().optional(),
11906
- trackId: string2().min(1)
12069
+ query: object({
12070
+ cursor: string2().optional(),
12071
+ dryRun: string2().optional(),
12072
+ limit: string2().optional()
12073
+ })
11907
12074
  })).output(object({
11908
- anchored: boolean2(),
11909
- apifyBudgetRemaining: number2().int().nonnegative(),
11910
- apifyEligible: boolean2(),
11911
- apifyEnabled: boolean2(),
11912
- apifyIneligibleReason: _enum(["apify_budget_spent", "awaiting_free_ask"]).nullable(),
11913
- freeDurationMsOmitted: number2().int().nonnegative(),
11914
- isrcRecoveredByDeezer: boolean2(),
11915
- listenbrainzOutcome: _enum([
11916
- "anchored",
11917
- "empty-ids",
11918
- "gate-rejected",
11919
- "metadata-failed",
11920
- "no-map",
11921
- "no-mbid",
11922
- "not-attempted",
11923
- "request-failed",
11924
- "yielded-on-breaker"
11925
- ]),
12075
+ adoptedArtists: number2(),
12076
+ dryRun: boolean2(),
12077
+ edgesWritten: number2(),
12078
+ matchedArtists: number2(),
12079
+ mintedArtists: number2(),
12080
+ nextCursor: string2().nullable(),
11926
12081
  ok: literal(true),
11927
- source: _enum(["listenbrainz", "spotify-isrc", "spotify-search"]).nullable(),
11928
- spotifyIsrcAsked: boolean2(),
11929
- spotifySearchDone: boolean2(),
11930
- spotifySearchEnabled: boolean2(),
11931
- spotifyThrottled: boolean2(),
11932
- stamped: boolean2(),
11933
- verifiedBy: _enum(["isrc", "search", "search-subset"]).nullable()
12082
+ rateLimited: boolean2(),
12083
+ scanned: number2(),
12084
+ skippedNoIdentity: number2()
11934
12085
  }));
11935
- resolveAnchorReview = oc.route({
12086
+ adminBackfillsContract = {
12087
+ backfill_apple_catalogue: backfillAppleCatalogue,
12088
+ backfill_apple_music: backfillAppleMusic,
12089
+ backfill_artist_credits: backfillArtistCredits,
12090
+ backfill_artist_edges: backfillArtistEdges,
12091
+ backfill_beatport: backfillBeatport,
12092
+ backfill_cover_masters: backfillCoverMasters,
12093
+ backfill_deezer: backfillDeezer,
12094
+ backfill_discogs: backfillDiscogs,
12095
+ backfill_discogs_facts: backfillDiscogsFacts,
12096
+ backfill_label_images: backfillLabelImages,
12097
+ backfill_label_lineage: backfillLabelLineage,
12098
+ backfill_label_releases: backfillLabelReleases,
12099
+ backfill_lastfm: backfillLastfm,
12100
+ backfill_recording_mbids: backfillRecordingMbids
12101
+ };
12102
+ });
12103
+
12104
+ // ../../packages/contracts/src/orpc/admin-bios.ts
12105
+ var BioEntityKindSchema, resolveBioReview, adminBiosContract;
12106
+ var init_admin_bios = __esm(() => {
12107
+ init_dist3();
12108
+ init_zod();
12109
+ BioEntityKindSchema = _enum(["album", "artist", "label"]).meta({ id: "BioEntityKind" });
12110
+ resolveBioReview = oc.route({
11936
12111
  method: "POST",
11937
- operationId: "resolveAnchorReview",
11938
- path: "/admin/catalogue/anchor/reviews/{trackId}/resolve",
11939
- summary: "Rule on a suspected version mismatch: anchor to the candidate, or dismiss (operator)",
12112
+ operationId: "resolveBioReview",
12113
+ path: "/admin/bio-reviews/{kind}/{slug}/resolve",
12114
+ summary: "Rule on a bio that landed past the voice gate: keep it or send it back (operator)",
11940
12115
  tags: ["Admin"]
11941
12116
  }).input(object({
11942
- resolution: _enum(["accepted", "dismissed"]),
11943
- trackId: string2().min(1)
12117
+ kind: BioEntityKindSchema,
12118
+ resolution: _enum(["keep", "rewrite"]),
12119
+ slug: string2()
11944
12120
  })).output(object({
11945
- anchored: boolean2(),
12121
+ kind: BioEntityKindSchema,
11946
12122
  ok: literal(true),
11947
- review: object({
11948
- candidateTitle: string2(),
11949
- spotifyTrackId: string2().optional()
11950
- })
12123
+ resolution: _enum(["keep", "rewrite"]),
12124
+ slug: string2()
11951
12125
  }));
11952
- setAnchorSearch = oc.route({
11953
- method: "PUT",
11954
- operationId: "setAnchorSearch",
11955
- path: "/admin/catalogue/anchor/search",
11956
- summary: "Flip the dark flag for the Spotify anchor-search rungs (operator)",
11957
- tags: ["Admin"]
11958
- }).input(object({ enabled: boolean2() })).output(object({ enabled: boolean2(), ok: literal(true) }));
11959
- setAnchorApify = oc.route({
11960
- method: "PUT",
11961
- operationId: "setAnchorApify",
11962
- path: "/admin/catalogue/anchor/apify",
11963
- summary: "Flip the Apify anchor-fallback kill-flag — off = no-budget graceful state (operator)",
11964
- tags: ["Admin"]
11965
- }).input(object({ enabled: boolean2() })).output(object({ enabled: boolean2(), ok: literal(true), requeued: number2() }));
11966
- CaptureBudgetStateSchema = object({
11967
- budget: object({ dailyBytes: number2(), dailyTracks: number2() }),
11968
- closedReason: _enum(["bytes_spent", "paused", "tracks_spent"]).nullable(),
11969
- open: boolean2(),
11970
- paused: boolean2(),
11971
- remainingBytes: number2(),
11972
- remainingTracks: number2(),
11973
- spend: object({ bytes: number2(), tracks: number2() }),
11974
- windowHours: number2()
11975
- }).meta({ id: "CaptureBudgetState" });
11976
- getCaptureBudget = oc.route({
11977
- method: "GET",
11978
- operationId: "getCaptureBudget",
11979
- path: "/admin/catalogue/capture-budget",
11980
- summary: "The catalogue capture budget: the switch, the caps, the 24h spend, what is left",
11981
- tags: ["Admin"]
11982
- }).input(object({})).output(CaptureBudgetStateSchema.extend({ ok: literal(true) }));
11983
- setCaptureBudget = oc.route({
11984
- method: "PUT",
11985
- operationId: "setCaptureBudget",
11986
- path: "/admin/catalogue/capture-budget",
11987
- summary: "Set the catalogue capture budget / flip its kill switch (operator)",
11988
- tags: ["Admin"]
11989
- }).input(object({
11990
- dailyBytes: number2().int().min(0).optional(),
11991
- dailyTracks: number2().int().min(0).optional(),
11992
- paused: boolean2().optional()
11993
- })).output(CaptureBudgetStateSchema.extend({ ok: literal(true) }));
11994
- AnchorApifyBudgetSchema = object({
11995
- dailyRows: number2(),
11996
- day: string2(),
11997
- remainingRows: number2(),
11998
- rowsSent: number2(),
11999
- spent: boolean2()
12000
- }).meta({ id: "AnchorApifyBudget" });
12001
- getAnchorApifyBudget = oc.route({
12002
- method: "GET",
12003
- operationId: "getAnchorApifyBudget",
12004
- path: "/admin/catalogue/anchor/apify-budget",
12005
- summary: "The metered Apify anchor rung's daily row cap, today's spend, and what is left",
12006
- tags: ["Admin"]
12007
- }).input(object({})).output(AnchorApifyBudgetSchema.extend({ ok: literal(true) }));
12008
- setAnchorApifyBudget = oc.route({
12009
- method: "PUT",
12010
- operationId: "setAnchorApifyBudget",
12011
- path: "/admin/catalogue/anchor/apify-budget",
12012
- summary: "Set the metered Apify anchor rung's daily row cap (operator)",
12013
- tags: ["Admin"]
12014
- }).input(object({ dailyRows: number2().int().min(0) })).output(AnchorApifyBudgetSchema.extend({ ok: literal(true) }));
12015
- SpotifyAnchorBreakerStateSchema = object({
12016
- cooldownRemainingMs: number2(),
12017
- reason: string2().nullable(),
12018
- throttlesInWindow: number2(),
12019
- tripped: boolean2(),
12020
- trippedAt: string2().nullable()
12021
- }).meta({ id: "SpotifyAnchorBreakerState" });
12022
- AnchorRungFlagsSchema = object({
12023
- apifyBudget: AnchorApifyBudgetSchema,
12024
- apifyEnabled: boolean2(),
12025
- spotifySearchEnabled: boolean2()
12026
- }).meta({ id: "AnchorRungFlags" });
12027
- getSpotifyAnchorBreaker = oc.route({
12028
- method: "GET",
12029
- operationId: "getSpotifyAnchorBreaker",
12030
- path: "/admin/catalogue/anchor/breaker",
12031
- summary: "The Spotify anchor-search throttle breaker: tripped, why, how long left, and the rungs",
12032
- tags: ["Admin"]
12033
- }).input(object({})).output(SpotifyAnchorBreakerStateSchema.extend({ ok: literal(true), rungs: AnchorRungFlagsSchema }));
12034
- resetSpotifyAnchorBreaker = oc.route({
12035
- method: "POST",
12036
- operationId: "resetSpotifyAnchorBreaker",
12037
- path: "/admin/catalogue/anchor/breaker/reset",
12038
- summary: "Clear the Spotify anchor-search throttle breaker (operator)",
12039
- tags: ["Admin"]
12040
- }).input(object({})).output(SpotifyAnchorBreakerStateSchema.extend({ ok: literal(true) }));
12041
- AppleBreakerStateSchema = object({
12042
- consecutiveAuthFailures: number2(),
12043
- cooldownRemainingMs: number2(),
12044
- tripped: boolean2(),
12045
- trippedAt: string2().nullable()
12046
- }).meta({ id: "AppleBreakerState" });
12047
- resetAppleBreaker = oc.route({
12048
- method: "POST",
12049
- operationId: "resetAppleBreaker",
12050
- path: "/admin/catalogue/apple-breaker/reset",
12051
- summary: "Clear the Apple failure-regime breaker (operator)",
12052
- tags: ["Admin"]
12053
- }).input(object({})).output(AppleBreakerStateSchema.extend({ ok: literal(true) }));
12054
- adminCatalogueContract = {
12055
- anchor_track: anchorTrack,
12056
- certify_track: certifyTrack,
12057
- clear_wrong_audio: clearWrongAudio,
12058
- commit_crawl_nodes: commitCrawlNodes,
12059
- crawl_catalogue: crawlCatalogue,
12060
- flag_wrong_audio: flagWrongAudio,
12061
- force_capture: forceCapture,
12062
- get_anchor_apify_budget: getAnchorApifyBudget,
12063
- get_capture_budget: getCaptureBudget,
12064
- get_crawl_status: getCrawlStatus,
12065
- get_spotify_anchor_breaker: getSpotifyAnchorBreaker,
12066
- list_catalogue_tracks: listCatalogueTracks,
12067
- list_unverified_captures: listUnverifiedCaptures,
12068
- rank_catalogue: rankCatalogue,
12069
- record_demand: recordDemand,
12070
- requeue_anchor: requeueAnchor,
12071
- requeue_isrc_recovery: requeueIsrcRecovery,
12072
- requeue_unmatched_captures: requeueUnmatchedCaptures,
12073
- reset_apple_breaker: resetAppleBreaker,
12074
- reset_spotify_anchor_breaker: resetSpotifyAnchorBreaker,
12075
- resolve_anchor: resolveAnchor,
12076
- resolve_anchor_review: resolveAnchorReview,
12077
- set_anchor_apify: setAnchorApify,
12078
- set_anchor_apify_budget: setAnchorApifyBudget,
12079
- set_anchor_search: setAnchorSearch,
12080
- set_capture_budget: setCaptureBudget,
12081
- set_track_dismissed: setTrackDismissed,
12082
- verify_capture: verifyCapture
12126
+ adminBiosContract = {
12127
+ resolve_bio_review: resolveBioReview
12083
12128
  };
12084
12129
  });
12085
12130
 
@@ -15295,15 +15340,18 @@ var init_admin_tracks = __esm(() => {
15295
15340
  summary: "The audio pipeline's worklist for one stage, in capture-priority order",
15296
15341
  tags: ["Admin"]
15297
15342
  }).input(object({
15343
+ age: string2().optional(),
15298
15344
  count: string2().optional(),
15299
15345
  debtAware: string2().optional(),
15300
15346
  kind: TrackWorkKindSchema,
15301
15347
  limit: number3().int().min(1).max(250).default(50),
15348
+ paidMode: _enum(["quota", "prior"]).optional(),
15302
15349
  scope: TrackWorkScopeSchema.default("all")
15303
15350
  })).output(object({
15304
15351
  capabilities: TrackWorkCapabilitiesSchema.optional(),
15305
15352
  debtPending: boolean2().optional(),
15306
15353
  ok: literal(true),
15354
+ oldestQueuedCaptureOver24h: boolean2().optional(),
15307
15355
  queued: number2().optional(),
15308
15356
  tracks: array(TrackWorkItemSchema)
15309
15357
  }));
@@ -16413,6 +16461,7 @@ var init_search2 = __esm(() => {
16413
16461
  bpmMin: number2().optional(),
16414
16462
  key: string2().optional(),
16415
16463
  label: string2().optional(),
16464
+ sound: string2().optional(),
16416
16465
  soundsLike: string2().optional(),
16417
16466
  soundsLikeArtists: array(string2()).max(6).optional(),
16418
16467
  text: string2().optional(),
@@ -16432,6 +16481,7 @@ var init_search2 = __esm(() => {
16432
16481
  logId: string2().optional(),
16433
16482
  previewable: boolean2().optional(),
16434
16483
  releaseDate: string2().optional(),
16484
+ similar: boolean2().optional(),
16435
16485
  spotifyUrl: string2().optional(),
16436
16486
  title: string2(),
16437
16487
  trackId: string2()
@@ -16694,6 +16744,7 @@ var init_tracks = __esm(() => {
16694
16744
  var contract, CONTRACT_OPERATION_NAMES, CONTRACT_OPERATION_ROUTES;
16695
16745
  var init_orpc = __esm(() => {
16696
16746
  init_dist3();
16747
+ init_admin_catalogue();
16697
16748
  init_admin_albums();
16698
16749
  init_admin_artifacts();
16699
16750
  init_admin_artist_rules();