Skip to content

Phase 2: server-rendered Use-this-data section and .md mirror - #291

Merged
neuromechanist merged 10 commits into
feature/issue-284-epic-agent-readinessfrom
feature/issue-286-phase2-use-this-data
Sep 3, 2026
Merged

neuromechanist merged 10 commits into
feature/issue-284-epic-agent-readinessfrom
feature/issue-286-phase2-use-this-data

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Adds the "Use this data" section to the dataset detail page (#284 phase 2) and its markdown mirror at /dataset/<id>.md.

One model, two renderers. src/lib/use-this-data.ts builds a pure, markup-free model from the same SSR data [id].astro already fetches (landing, metadata, catalog row) — no new fetches. src/components/UseThisData.astro renders it as HTML; renderUseThisDataMarkdown renders the identical model as markdown for src/pages/dataset/[id].md.ts. Divergence between the two surfaces is impossible by construction: neither renderer holds a fact the model doesn't already carry.

The section covers what the dataset is (modalities, participants, size, BIDS version, tasks, HED version), license and terms (canonical license URL, restrictive-tier note, recommended citation, References papers only — never IsReferencedBy, which cites the dataset rather than the other way around), where the bytes are (data.nemar.org/<id>/latest/ and the pinned version, never an s3:// prefix since anonymous ListBucket on that prefix is denied), how to download, how to assess fit without downloading, and a Zarr recipe gated on the catalog row (zarr_status === "ready" and zarr_store_count > 0) with a fallback to zarrIndexUrl(id) when the row carries no zarr_index_url yet.

An unpublished dataset (no selected version) gets a reduced card: the bytes-location, download, assess, and Zarr sections are all omitted; the license section (self-citation) still renders. Every field degrades to omission, never to null/"undefined"/an empty heading, so a sparse row yields a shorter card, never a throw.

Base.astro gained a generic headLinks prop (an array of {rel, href, type?, title?}) so the dataset page can declare <link rel="alternate" type="text/markdown"> without adding dataset-specific mapping logic to the layout — the same seam phase 3's Signposting links will reuse.

Additive-only elsewhere: ccLicenseUrl and conditionsOfAccess are now exported from jsonld.ts (no behavior change) so the new module can reuse them rather than duplicate the license-mapping logic. zarr_status, zarr_store_count, and zarr_index_url are added as optional/nullable fields on the Dataset type — these are fields the API already serves, so this is descriptive, not a contract change.

No backend change was needed; nothing here alters an API response shape, the Zarr index contract, or the data.nemar.org layout.

No-JavaScript evidence

$ curl -s http://localhost:4321/dataset/nm000103 | grep -c 'application/ld+json'
1

$ curl -s http://localhost:4321/dataset/nm000103 | grep -o 'Use this data'
Use this data

$ curl -s http://localhost:4321/dataset/nm000103 | grep -o 'nemar dataset download nm000103'
nemar dataset download nm000103
nemar dataset download nm000103
nemar dataset download nm000103
nemar dataset download nm000103

$ curl -sI http://localhost:4321/dataset/nm000103.md
HTTP/1.1 200 OK
content-type: text/markdown; charset=utf-8
cache-control: public, max-age=60, s-maxage=300, stale-while-revalidate=86400
x-nemar-version: 0.2.6-dev3+dev

$ curl -s http://localhost:4321/dataset/nm000103.md | head -40
# Healthy Brain Network EEG - Not for Commercial Use (nm000103)

## Use this data

### What it is

- **Modalities:** EEG
- **Participants:** 447
- **Size:** 250 GB
- **Tasks:** DespicableMe, DiaryOfAWimpyKid, FunwithFractals, RestingState, ThePresent, contrastChangeDetection, seqLearning6target, seqLearning8target, surroundSupp, symbolSearch
- **HED version:** 8.3.0

### License and terms

- **License:** [CC-BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
- **Note:** Non-commercial use only (CC-BY-NC-SA 4.0).
- **Recommended citation:** Shirazi, S. Y., Franco, A., Hoffmann, M. S., Esper, N. B., Truong, D., Delorme, A., Milham, M., & Makeig, S. (2026). Healthy Brain Network EEG - Not for Commercial Use (Version v2.0.0) [Data set]. NEMAR. https://doi.org/10.82901/nemar.nm000103
- **Reference:** [https://doi.org/10.1038/sdata.2017.181](https://doi.org/10.1038/sdata.2017.181)
- **Reference 2:** [https://doi.org/10.1038/sdata.2017.40](https://doi.org/10.1038/sdata.2017.40)

### Where the bytes are

- **Latest version (always current):** [https://data.nemar.org/nm000103/latest/](https://data.nemar.org/nm000103/latest/)
- **This version (v2.0.0):** [https://data.nemar.org/nm000103/v2.0.0/](https://data.nemar.org/nm000103/v2.0.0/)

### How to download

- **Everything:** `nemar dataset download nm000103`
- **A subset:** nemar dataset clone nm000103 fetches git-annex pointers only, no file content; follow it with nemar dataset get <files> to pull the files you actually need.
- **One small file:** A direct HTTPS fetch works for any single file, e.g. https://data.nemar.org/nm000103/v2.0.0/participants.tsv.

### Assess fit without downloading

- **Participants table:** [https://data.nemar.org/nm000103/v2.0.0/participants.tsv](https://data.nemar.org/nm000103/v2.0.0/participants.tsv)
- **Dataset description:** [https://data.nemar.org/nm000103/v2.0.0/dataset_description.json](https://data.nemar.org/nm000103/v2.0.0/dataset_description.json)
- **Directory listing:** [https://data.nemar.org/nm000103/v2.0.0/?format=json](https://data.nemar.org/nm000103/v2.0.0/?format=json)
- **Catalog record:** [https://api.nemar.org/datasets/nm000103](https://api.nemar.org/datasets/nm000103)

$ curl -s -o /dev/null -w '%{http_code}\n' http://localhost:4321/dataset/nm099999.md
404

Route-collision precedence was verified empirically: curl http://localhost:4321/dataset/nm000103.md returns content-type: text/markdown (served by [id].md.ts), while curl http://localhost:4321/dataset/nm000103 (no extension) still returns content-type: text/html. The ds* -> canonical redirect also mirrors the page on this route: curl -sI http://localhost:4321/dataset/ds007753.md returns 301 to /dataset/on007753.md.

Test plan

  • bun run lint — 0 errors
  • bun run typecheck — 0 errors, 0 warnings (241 files)
  • bun run test — 1526/1526 passed (63 files), including 25 new tests in src/lib/use-this-data.test.ts covering the model/markdown parity guarantee, Zarr gating, an unpublished dataset, References-vs-IsReferencedBy, a sparse null-heavy dataset, and that no output ever presents openneuro.org as canonical
  • NEMAR_SKIP_OG_GENERATE=1 bun run build — completes cleanly

Closes #286
Part of epic #284

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review addressed. All findings acted on; one nice-to-have declined with a reason.

Critical, the page and the .md mirror disagreed for an unpublished dataset. Fixed in 6e9d2a4. This one was my fault as epic lead: the brief told the implementer both "do not render it in the unpublished branch" and "an unpublished dataset yields a reduced card", which are contradictory, and the implementation followed both literally. The result was the worst direction of parity failure, with the agent-facing mirror carrying an overview and a citation the human page never showed, while the page's head advertised rel=alternate to it. The component now renders unconditionally alongside the "Not yet published" banner, and buildUseThisData is the single gate for what an unpublished dataset shows.

Important, two independently-computed values asserted equal only by a comment. Fixed in 7ada710. unpublished and selectedVersion === null really can diverge: isUnpublished is !landing.latest || landing.versions.length === 0, while selectedVersion falls back to versions[0]?.version whenever latest is falsy, so a payload with a null latest and a non-empty versions array makes the first true and the second non-null. The page's unpublished is now authoritative, passed into the builder, and all four version-gated sections route through one publishedVersion helper instead of each null-checking selectedVersion. [id].md.ts computes it with the same isUnpublished rather than re-deriving. A test drives exactly that divergent state from the real captured fixture and asserts none of the four sections appear.

Suggestion, commands and URLs buried in prose. Fixed in 2c4eea2. UseThisDataItem gained an optional note, so an item can carry a short precise value plus its explanation. The download section is now four items each with a real code value, and the Zarr step whose entire sentence was the anchor text now has the bare index URL as its href with the sentence in the note. The load-bearing part: the parity test's allFactValues helper now flattens note as well as value, so adding a field a fact can live in did not silently weaken the one test that guarantees parity.

Nice-to-have, a thousands separator on the participant count. Declined deliberately. This section's primary consumer is a machine and a separator is a character an agent has to strip; the human-facing DetailRail already formats counts. Raw integers stay.

Evidence. There is exactly one unpublished public dataset in the catalog, on005691, found by paging all 755 rows and confirmed against data.nemar.org. Verified independently after the fixes: its page renders "What it is", "License and terms" and the "Not yet published" banner, and its .md renders exactly "What it is" and "License and terms" and nothing else. The published nm000103 renders all six sections in the mirror. The two surfaces now agree in both states.

Gates after the fixes: lint clean, typecheck 0 errors, 1529 tests green across 63 files (use-this-data.test.ts went 21 to 28), and NEMAR_SKIP_OG_GENERATE=1 bun run build completes.

@neuromechanist
neuromechanist merged commit 465b176 into feature/issue-284-epic-agent-readiness Sep 3, 2026
5 checks passed
neuromechanist added a commit that referenced this pull request Sep 3, 2026
…lms.txt (#294)

* Phase 1: AI crawler tokens in robots.txt and a real-lastmod sitemap (#290)

* Allow AI crawlers in robots.txt

* Add real-lastmod sitemap.xml route

* Add tests and fixture for robots/sitemap

* Move escapeXml to a neutral xml module

* Assert the crawler block stays contiguous

* Reuse isManagedDatasetId in the sitemap filter

* Skip the sitemap on noindex hosts

* Phase 2: server-rendered Use-this-data section and .md mirror (#291)

* lib: export license helpers from jsonld

* types: add zarr status fields to Dataset

* lib: add use-this-data model and tests

* add UseThisData section component

* layout: add generic headLinks to Base

* dataset: render Use this data section

* dataset: add markdown mirror endpoint

* fix: render Use this data outside unpublished ternary

* fix: make page unpublished flag authoritative

* fix: mark up commands and URLs, not sentences

* Phase 6: nemar.org llms.txt and a footer link (#293)

* Add /llms.txt endpoint with tests

* Link llms.txt from the footer

* Fix llms.txt license claim, was off by 10x

* Give llms.txt search link a working q example

* Require v prefix on llms.txt version placeholder

* Un-link llms.txt dataset-page placeholder

* Phase 3: Signposting Link headers and link elements (#292)

* lib: add signposting link model and tests

* dataset: emit Signposting Link header and tags

* Rewrite Zarr recipe to be index-agnostic

* Correct the download facts and add a cd step

* Check value/note discipline in every section

* Cite the published version, not the selected one

* Number both references; soften sparse access

* Escape interpolated text in the .md mirror

* Validate ORCIDs and reject unsafe Link hrefs

* Strip a trailing slash from the .md alternate

* Split Applebot out and pin robots groups

* Cache robots and llms.txt; noindex the mirror

* Add route tests for the four new routes

* Cite sources for the routing and ORCID notes
@neuromechanist
neuromechanist deleted the feature/issue-286-phase2-use-this-data branch September 30, 2026 19:25
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