Repository navigation
Upstream license lineage resolver and license-check - #2372
Merged
neuromechanist merged 10 commits intoNov 25, 2026
Merged
neuromechanist merged 10 commits into
neuromechanist merged 10 commits into
Conversation
Resolver, compatibility lattice and copy tables (epic #2182 card D1), with recorded DataCite, Crossref, OpenAlex, OpenNeuro and PhysioNet fixtures. Tested: bun test test/license-lineage.test.ts; live DOI test passed locally.
An unrecognized source license now needs permission instead of passing. Tested: bun test test/license-provenance.test.ts test/license-tier.test.ts.
GET /admin/datasets/:id/license-lineage, read-only, Worker-cached per DOI. Tested: route test and admin route inventory.
nemar dataset license-check <path> and nemar admin dataset license-lineage <id>. Tested: CLI spawn test against a recorded stand-in, export surface pin.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2372Version: 🤖 Updated on each push. |
ADR 0135 caps admin dataset at twelve visible children (test/admin-write-flag.unit.test.ts). Adds spawn tests for the admin command. Tested: license-check-spawn, admin-write-flag.
MIT, BSD-2/3-Clause and Apache-2.0 become permissive-attribution (compatible_attribution); the Public Domain Mark becomes cc0 (lead ruling 2026-11-25). Tested: license-lineage, license-provenance, license-tier, spawn and route tests.
Review round 1 item 10. Tested: bun test test/license-lineage.test.ts.
Review round 1 items 1-8: read states for the description and metadata (422 and CLI exit 1 when unparseable), CLI path checks, unparseable 200 bodies, strict SA version, PhysioNet access policy, own-DOI exclusion, cache validation, read lines and anchors. Tested: lineage, spawn, route tests.
Review round 1 item 9. Tested: bun test test/license-provenance.test.ts.
Review round 2: license-check exits outside every try, an unreadable description leaves target_license null (printed unknown), and the fixtures README explains the kept curator names. Tested: targeted lineage files.
Contributor
Author
|
Merge gate (lead, local per the plan's phase rule): head 8c2b0de; typecheck clean; biome clean; targeted tests 184 pass, 0 fail. Review: round 1 panel (code+tests; errors+comments+types), 3 important and 6 suggestions fixed, 1 rejected (ODbL version, consistent with the card); round 2 delta review clean, 2 suggestions fixed in 8c2b0de. Remote CI: 19 pass; unit-pure shard 2 fails on unrelated timeouts (different files on the first run and on the rerun, none touched by this diff, all passing locally on this head), filed as #2377. |
neuromechanist
merged commit Nov 25, 2026
442ce5c
into
feature/issue-2182-epic-pq-decide
48 of 53 checks passed
This was referenced Nov 26, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2361, epic #2182 (card D1; ADR 0139 decision 7).
What
shared/license-lineage.ts: one resolver, shared by the CLI and the Worker. It finds a dataset's upstream sources (SourceDatasets, enrichmentIsDerivedFrom/IsIdenticalTo, the attestation's upstream source, the README), reads each source's license and resource type (DataCite, then Crossref, then OpenAlex; 8 s per fetch, at most 10 sources), normalizes it into the closed set, and combines the sources on a restriction lattice into one closed outcome. Every outcome and source status has a statement, what was read, a remedy and a docs anchor inLINEAGE_COPY/SOURCE_STATUS_COPY; a missing entry fails the typecheck. User-Agentnemar-license-check/1, no contact details. A fetch error isunresolved, never compatible, never cached, and never falls through to the next registry.GET /admin/datasets/:id/license-lineage: read-only, computed on demand, registry answers cached per DOI for 24 hours in the Worker cache. No migration.nemar dataset license-check <path>(exit 0 forcompatible,compatible_attribution,compatible_nc; 2 otherwise; 1 for an unreadable path) andnemar admin dataset publish license-lineage <id>, printing the same lines from the copy table.src/lib/provenance.tsnow uses the shared rule. Behavior change: an unrecognized source license needs permission instead of passing with a warning.Deviations from the card (lead ruling, 2026-11-25)
rightsListfor every OpenNeuro and PhysioNet record sampled, Crossref has neither, and OpenAlex has no license for them. When DataCite returns a Dataset record with no usable rights and the DOI or landing URL is OpenNeuro or PhysioNet, the resolver asks that repository's own API (OpenNeuro GraphQL snapshotdescription.License; PhysioNet/api/v1/project/published/<slug>/<ver>/license name andaccess_policy). Resolver idsopenneuroandphysionet; same timeout, cache and unresolved-on-failure. A PhysioNet access policy other than Open maps tophysionet-credentialedorphysionet-restrictedwhatever the license name. PhysioNet URLs go to the PhysioNet API directly, which also returns the project's DOI.nemar admin dataset license-lineage; ADR 0135 capsadmin datasetat twelve visible children (test/admin-write-flag.unit.test.ts), so the command isnemar admin dataset publish license-lineage <id>, beside the other publication-request commands.shared/openapi.jsonentry. That document is the public catalog surface only, andbackend/test/openapi-document.test.tspins exactly its four paths.License classes (lead ruling 2026-11-25): MIT, BSD-2-Clause, BSD-3-Clause and Apache-2.0 normalize to
permissive-attribution, which behaves like CC BY (compatible_attribution; the copy says these are software licenses applied to data and still require attribution); the Creative Commons Public Domain Mark normalizes tocc0. Other versions and clauses (BSD-4-Clause, Apache-1.1, GPL) stayother.Lattice, most restrictive first:
redistribution_prohibited>needs_permission>source_is_publication>unresolved>share_alike_mismatch>compatible_nc>compatible_attribution>compatible(no_upstream_declaredonly stands alone). More than 10 sources: the extra ones are listednot_checked, which counts as unresolved.Tests
test/license-lineage.test.ts: every outcome, normalization, the DataCite access-rights and Crossref content-version/TDM filters, source extraction and URL mapping, two-source combinations, a timeout and a 5xx givingunresolved, caching, all against a local stand-in serving responses recorded on 2026-11-25 (test/fixtures/license-lineage/, with a README naming each DOI, URL and fetch date).backend/test/license-lineage-route.test.ts: the real admin router over D1, a GitHub contents stand-in and the recorded registries (other hosts refused).test/license-check-spawn.test.ts(process tier): the real CLI on a fixture BIDS directory; outcome, sources, evidence URLs, remedy, docs link, JSON form and exit codes.test/license-lineage.integration.test.ts(live tier by name): one real OpenNeuro DOI through DataCite and OpenNeuro.account-copy-parity(2),git-annex-remoteandpr-review-calibratefail identically on the basec7c8fe2c,repull-pipeline-runpasses alone (a 5 s timeout under load), and the ADR 0135 cap failure was fixed by the last commit.bun run typecheck,bun run lint, biome on touched files, the pure unit tier, and the targeted tests above. The remote live tier is not awaited for this phase PR.Review round 1 fixes
result.inputs): a missingdataset_description.jsonis distinct from an unparseable one, and likewise.nemar/metadata.json. A missing or unparseable description givesunresolvedwith source statusdescription_unreadable(neverno_upstream_declared); an unparseable metadata file addsmetadata_unreadable. The route answers 422 for an unparseable file (502 stays for a repository read failure); the CLI exits 1 naming the file.dataset_description.json; every read failure is one line and exit 1, no stack trace.{}, an array, or GraphQL{errors, data: null}givesunparseableandunresolved; a PhysioNet record without a stringaccess_policyisunparseable.DatasetDOI, and NEMAR's prefix10.82901in the README) are not sources.lineageLinesprints the copy's read line, per resolver (RESOLVER_READ).index.jsonlist both edits.Docs anchors for A10
All on https://docs.nemar.org/policies/contributor-terms/ (
LINEAGE_ANCHORSinshared/license-lineage.ts; a test fails if a copy entry uses any other):#license-lineage,#license-lineage-compatible,#license-lineage-compatible-attribution,#license-lineage-compatible-nc,#license-lineage-share-alike-mismatch,#license-lineage-needs-permission,#license-lineage-redistribution-prohibited,#license-lineage-source-is-publication,#license-lineage-no-upstream-declared,#license-lineage-unresolved.