Skip to content

Enrichment: DOI lookup warnings, cap marker, and stage deadline - #1556

Merged
neuromechanist merged 5 commits into
devfrom
fix/enrich-doi-lookup-followups
Sep 29, 2026
Merged

neuromechanist merged 5 commits into
devfrom
fix/enrich-doi-lookup-followups

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Follow-up to #1550 and #1549, from the production-safety review of main...dev. The bulk reindex cap is tracked in #1555.

What changed

  1. Failed DOI lookups become a reindex warning (backend/src/services/dataset-reindex.ts).
    • The doi_resolution comment no longer claims the backend retries. It now says nothing in the backend retries, and re-running the reindex is up to the operator or the sweep script.
    • New pure doiLookupWarnings(summary). When failed > 0, runEnrichmentForDataset appends one warning to the same warnings list the Phase 5: Real-name DOI attribution #1255 DOI-sync skip uses, for example doi_resolution: 2 of 12 DOI lookup(s) got no registry answer; reindex this dataset again to label them with registry metadata.
    • The run stays ok: true; the failure branch never carries it. The bulk route passes enr.warnings through unchanged.
  2. DOIs past the cap are marked in the prompt (backend/src/services/doi-metadata.ts).
    • formatResolvedDoiBlock lists each skipped DOI as not looked up (over the per-run cap), so the model is told when a DOI's metadata was not checked.
    • The cap stays at 15: two registries per DOI keeps the stage at 30 subrequests or fewer. Candidates are ordered BIDS fields first, where a data paper is usually cited. I found no dataset-level evidence for a different number.
  3. Stage 1d deadline (doi-registry.ts, doi-metadata.ts).
    • resolveDoisForEnrichment takes a deadline signal, 25 s by default (RESOLVE_DEADLINE_MS). It is combined with each request's 10 s timeout through AbortSignal.any.
    • Why 25 s: one chunk's worst case is a DataCite timeout followed by a Crossref timeout (20 s), so a single slow chunk can finish, while three hung chunks no longer take about 60 s. A live cold-cache run on nm000275's ten DOIs took 0.5 to 1.1 s.
    • Lookups the deadline cuts short, or that start after it, count as failed. Nothing throws out of enrichment.
    • A settled answer already in the run cache (from ORCID discovery) still counts after the deadline.
    • A lookup the deadline cut short is evicted from the cache, so a later stage can ask again. It logs one summary line instead of a warning per request.
  4. CLI (src/commands/admin.ts, src/lib/api/admin.ts).
    • nemar admin reindex now prints the result's warnings (the failed-lookup warning, and the Phase 5: Real-name DOI attribution #1255 DOI-sync skip, which the CLI never showed before). It also prints a line when skipped > 0.
    • The line formatting moved into a pure, exported reindexLines, which printReindexLine now calls.
  5. Bulk reindex cap: not changed here. It is tracked in Bulk reindex needs a per-request dataset cap #1555, which proposes keyset paging (limit/after, as /admin/vectorize/reindex-all does) with the CLI looping over pages.
  6. ADR 0075 now notes the deadline, the warning, and Bulk reindex needs a per-request dataset cap #1555.

Verification

  • bun run typecheck: clean
  • bun run lint (src/) and Biome on every changed file: clean
  • Offline unit-pure tier, same file classification as test.yml: 7311 pass, 26 skip, 0 fail across 417 files (local, at a9fdafee)
  • Live DataCite and Crossref integration tests: 19 pass, 0 fail, including a live deadline that fires mid-request
  • Each commit typechecks and passes the enrichment, reindex, and source-guard test files on its own, enrich-doi-sync-skip.test.ts included
  • Mutation-checked, one line at a time; each was caught by a failing test:
    • the warning returning nothing;
    • the warning not merged on the ok branch;
    • the skipped marker removed;
    • the deadline not passed to the fetch;
    • AbortSignal.any replaced by the per-request timeout alone;
    • cache eviction removed;
    • the CLI cap line removed;
    • the CLI warnings loop removed.

Tests added:

  • doiLookupWarnings unit tests.
  • An offline deadline test. A pre-aborted signal makes every uncached fetch reject before it reaches the network; the cache holds a recorded real DataCite response standing in for stage 1b. It asserts that the cached DOI resolves, the rest are failed, it finishes in under 1 s, and the cut-short lookups are evicted.
  • An entry-path cap test: 17 real candidates, and the two past the cap appear as not looked up in the prompt block.
  • A live mid-request deadline test.
  • reindexLines output tests, which use the backend's own warning text.

Pinned source-shape tests:

  • enrich-doi-sync-skip.test.ts now pins const warnings = [...skips, and ...(warnings.length > 0 && { warnings }) instead of warnings: skips. The intent is unchanged: the skip path returns ok: true and carries the skips as warnings.
  • enrich-relation-guard-wiring.test.ts additionally pins that the lookup warning is merged on the ok branch only.

Not covered by a test: the default value of the deadline. A test would need a registry that hangs for more than 25 s. The mechanism is exercised with an explicit signal, offline and live.

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1556

Version: 0.10.10-PR1556.a9fdafe
Commit: a9fdafe


🤖 Updated on each push.

neuromechanist added a commit that referenced this pull request Sep 29, 2026
Failed-lookup warnings, the lookup-stage deadline, the over-cap marker,
and the summary now printing warnings. Changelog format test passes.
@neuromechanist
neuromechanist merged commit ec7fa1d into dev Sep 29, 2026
12 checks passed
@neuromechanist
neuromechanist deleted the fix/enrich-doi-lookup-followups branch September 29, 2026 17:52
neuromechanist added a commit that referenced this pull request Sep 29, 2026
* docs: CHANGELOG entry for 0.10.10

Covers #1550 (Sonnet 5.5 enrichment, DOI lookups, relation guard) and
#1552 (biosigio 1.2.10 case-only sidecar matches). Claims checked against
the merged code.

* docs: add #1556 to the 0.10.10 entry

Failed-lookup warnings, the lookup-stage deadline, the over-cap marker,
and the summary now printing warnings. Changelog format test passes.
neuromechanist added a commit that referenced this pull request Sep 29, 2026
* fix: start no DOI lookup after the deadline

fetchRegistryRecord returns failed at once once the stage deadline has
passed, instead of issuing requests that reject immediately; a cached
answer still counts. Header and docstring now say what is logged and what
is evicted. Tested: doi-metadata offline deadline test, typecheck, Biome.

* fix: cue a reindex on failed DOI lookups

The DOI lookup line turns yellow when lookups failed, and says to reindex
again when the backend sent no lookup warning (a backend before #1556).
Tested: reindex-lines unit tests.

* docs: scope the DOI lookup warning

Comments no longer say a sweep retries; ADR 0075 and the 0.10.10 entry
say the warning is reindex-only (push-triggered runs log instead), that a
push to README.md or dataset_description.json also re-enriches, that only
model-written IsDerivedFrom is gated, and where demoted_dois appears.
Tested: changelog format test.

This branch was previously deployed

1 inactive deployment
npm — a9fdafee Deployed Sep 29, 2026 by neuromechanist via publish #2975
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant