Skip to content

Phase 2: server-rendered Use-this-data section and .md mirror per dataset #286

Closed

Description

@neuromechanist

Add a section to src/pages/dataset/[id].astro rendered on the server from the same data the JSON-LD uses: what it is (name, modality, subjects, size), license and required citations, where the bytes are (data.nemar.org//latest/ and the S3 prefix), how to download (nemar dataset download, clone plus get, direct fetch of small files), how to assess fit without downloading (participants.tsv, dataset_description.json, the API), and, only when has_zarr is set, a Zarr block with the ten-line recipe from the research memo (start at index.json under contract_base, per-dataset data_base, stream by default, HEAD never redirected, filter on has_zarr_verified). Human-visible and identical for agents (OSCAR parity). Generate /dataset/.md from the same source and link it with . Tests: a plain fetch of the page without JavaScript contains the section; the .md route renders for a public dataset and 404s for a private one.

Part of #284. Constraint: descriptive only, no live contract changes. Evidence: nemarOrg/nemar-cli .context/research-agent-findability.md.

Activity

  1. added
    enhancement
    on Sep 3, 2026
  2. neuromechanist commented on Sep 3, 2026

    @neuromechanist
    ContributorAuthor

    Implementation brief (phase 2 of epic #284)

    Branch feature/issue-286-phase2-use-this-data, worktree /Users/yahya/Documents/git/nemar/phase2-use-this-data, PR targets the epic branch feature/issue-284-epic-agent-readiness.

    The shape: one model, two renderers

    The parity requirement in this issue is "human-visible and identical for agents", and the only way to guarantee that over time is to make divergence impossible rather than to check for it. So the section and the .md mirror are two renderers over one pure model.

    src/lib/use-this-data.ts (new, pure, no I/O) exports buildUseThisData(input): UseThisData and renderUseThisDataMarkdown(model): string. The input is the same data src/pages/dataset/[id].astro already has after its existing SSR fan-out, so nothing new is fetched on the critical path. src/components/UseThisData.astro renders the same model as HTML. src/pages/dataset/[id].md.ts renders it as markdown.

    Null-safety is the same discipline src/lib/jsonld.ts already documents: every field degrades to omission, never to null, "undefined" or an empty heading. A sparse on* row must produce a shorter card, never a throw, because Astro silently drops content whose render throws.

    Content

    What it is: name, modalities, participant count, size, BIDS version, tasks, and HED version when present.

    License and terms: the license string with its canonical URL, a note for a restrictive tier, the dataset's own recommended citation, and the papers the metadata marks References. Only References. Never IsReferencedBy, which records papers that cite the dataset and would misrepresent the relationship if presented as "cite these".

    Where the bytes are: the browsable BIDS tree at data.nemar.org/<id>/latest/ and at the selected version.

    How to download: nemar dataset download <id> for everything; nemar dataset clone <id> then nemar dataset get <files> for a subset, with the fact that clone alone fetches no content; a direct fetch for individual small files.

    How to assess fit without downloading: participants.tsv and dataset_description.json under the version path, the directory listing with ?format=json, and api.nemar.org/datasets/<id>.

    Zarr, only when the dataset has a Zarr copy: the ten-line recipe from section 5 of the research memo, verbatim in substance.

    Decisions already made

    The Zarr block is gated on the catalog row, not on a fetch of index.json. Production still serves format_version: 1 for the index (checked on nm000103), the index carries no contract_base there, and the dataset page's critical path is deliberately landing plus metadata plus catalog row only (see the #81 comment in the page). The row already carries the exact fields: zarr_status === "ready" with zarr_store_count > 0 is the documented definition of has_zarr, and zarr_index_url is derived server-side and non-null only when the status is ready. The recipe is documentation the page states, not data the page reads.

    The S3 prefix is deliberately not presented as a browsable location for the BIDS tree. Anonymous ListBucket on s3://nemar/<id>/ is denied (verified, 403), so telling an agent to list it would be telling it to do something that fails. Anonymous GET of a public dataset's Zarr object does work (verified, 200), so the S3 URI belongs in the Zarr block, sourced from what index.json declares, and nowhere else.

    The .md route mirrors the page's behaviour exactly, including the ds* canonical 301 and the 404/503 split from resolveDatasetPageStatus. A mirror that disagrees with the page it mirrors is precisely the bug this design exists to prevent. Private datasets need no special casing: they already 404 on both upstream signals.

    The <link rel="alternate" type="text/markdown"> goes through a new generic headLinks prop on Base.astro rather than a one-off. Phase 3 adds Signposting <link> elements to the same head and will reuse the seam.

    Tests

    src/lib/use-this-data.test.ts against the captured fixtures already in test/fixtures/ (jsonld-catalog-*, jsonld-landing-*, jsonld-metadata-* for nm000103, nm000154 and on007753). The load-bearing one is a parity test: build the model once, render both, and assert every fact the model carries appears in the markdown. Plus the Zarr block appearing only when the row says ready, an unpublished dataset producing a card with no download or bytes block instead of throwing, and no output anywhere containing openneuro.org as a canonical.

    Gates

    bun run lint, bun run typecheck, bun run test, NEMAR_SKIP_OG_GENERATE=1 bun run build, plus a plain non-JavaScript curl of a public dataset page against bun run dev showing the section and the JSON-LD in the returned HTML, and a curl of the .md route.

  3. neuromechanist commented on Sep 3, 2026

    @neuromechanist
    ContributorAuthor

    Shipped in #291, squash-merged into the epic branch feature/issue-284-epic-agent-readiness as 465b176.

    Closing by hand: the PR merged into the epic branch rather than the default branch, so GitHub's closing keyword does not fire.

    The dataset page now carries a server-rendered "Use this data" section, and /dataset/<id>.md serves the same content as markdown. Both render from ONE model built by buildUseThisData, with two renderers over it, so the two surfaces cannot drift. The HTML renderer iterates model.sections and hand-picks nothing, which makes parity structural rather than merely tested; the markdown direction is covered by a mechanical test that flattens every fact in the model and asserts each appears in the output.

    Content: what it is, license and required citations (only References relations, never IsReferencedBy, which would invert the relationship), where the bytes are, how to download, how to assess fit without downloading, and a Zarr block gated on the catalog row's zarr_status and zarr_store_count rather than on an SSR fetch of index.json. Nothing was added to the page's critical path.

    Review found one Critical and one Important, both real. The Critical was mine to own: the brief contradicted itself, telling the implementer both to omit the section in the unpublished branch and to render a reduced card for an unpublished dataset. The result was that an unpublished dataset's markdown mirror carried an overview and a citation the human page never showed, while the page's head still advertised rel=alternate to it, which is a parity failure in the worst direction. The Important was that unpublished and selectedVersion === null were computed independently and only asserted equal in a comment; they genuinely diverge when latest is null and versions is non-empty. Both fixed, with the page's unpublished now the single source of truth and a test driving exactly that divergent state.

    Verified against production before merge. There is exactly one unpublished public dataset in the catalog, on005691, found by paging all 755 rows. Its page and its .md mirror now render exactly the same two sections, "What it is" and "License and terms", with the "Not yet published" banner on the page; the published nm000103 renders all six in both. A plain no-JavaScript curl of a public dataset returns the section, the CLI commands, the JSON-LD and the rel=alternate link; a private dataset 404s on both the page and the mirror, through the existing upstream gate rather than a new visibility check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions