Repository navigation
Drive the mirror chip from the API's mirror flag - #489
Merged
Merged
Conversation
LandingVersion gains mirror?: boolean | null. Once any version carries the key, listMirrorVersions lists only the versions flagged true, so a null N.0.0 (snapshot unknown) gets no chip and is not the toggle's mirror version. A payload with no key at all keeps the old vN.0.0 rule as a temporary fallback. VersionSwitcher and ProvenanceToggle already read allMirrorVersions through detectProvenance, so neither changes. Refs #478. Lint, typecheck, test and build pass; the existing tests pass unchanged and the new cases follow in the next commit.
Cases for true, false, null and an absent key on each version, driven by landing payloads recorded from nemar-cli's real route: a mirror with every value, a mirror with nothing but null, and a NEMAR dataset with nothing but false. A real production capture from before the flag covers the fallback. A null N.0.0 gets no chip and is not the toggle's mirror version, and one key anywhere in a payload turns the version-number rule off. Eleven wrong implementations of listMirrorVersions fail these tests; the one that survives (an in check for !== undefined) is equivalent on parsed JSON. Refs #478. Lint, typecheck, test and build pass.
Deploying nemar-website with
|
| Latest commit: |
5091a7f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5462a481.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-phase8c-mirror-flag.nemar-website.pages.dev |
Adds the hold to .context/handoff.md, where this repo records release gates: no staging to main promotion until the production upstream-backfill has run, because once the API sends the flag a mirror whose snapshot is not recorded reads null and has no chip. Docs only.
The fallback comment named "PR 8c2", a plan label the issue does not define. It now points at website#478, whose checklist states when the fallback is deleted. Comment only.
The comment said four recorded payloads drive the cases below, but several cases build their payloads by hand with flaggedLanding and versionEntry. It now says the four recordings drive the main flag cases and names the shapes the hand-built ones cover. Comment only.
This was referenced Oct 27, 2026
Merged
neuromechanist
added a commit
that referenced
this pull request
Nov 2, 2026
The toggle copy predates the mirror flag (#489); a null N.0.0 is no longer shown as a mirror. Say what the flag says instead. Lint and unit suite pass.
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.
Drives the mirror chip in the version switcher and the "View as-imported mirror" action in the source toggle from the
mirrorflag the API puts on each landing version (true,falseornull), instead of guessing fromvN.0.0. This is PR 8c of nemarOrg/nemar-cli#1914 (epic nemarOrg/nemar-cli#1046), following nemar-cli Architecture Decision Record (ADR) 0111, decision 5. It refs #478 rather than closing it, becausestagingis not the default branch.What changes
LandingVersiongainsmirror?: boolean | null, with a comment naming the three values and that an older backend omits the key.listMirrorVersionslists onlymirror === true, newest first, as soon as any version carries the key. AnullN.0.0 (snapshot unknown or not examined yet) gets no chip and is never the toggle's mirror version.vN.0.0rule stays as a documented temporary fallback. PR 8c2 deletes it later; this PR keeps it.VersionSwitcher.astroandProvenanceToggle.astroare unchanged. I read both: the page passes the switcherprovenance.allMirrorVersionsand the toggle readsprovenance.mirrorVersion, and both come fromdetectProvenance, so the one change inprovenance.tsreaches them. Nothing else undersrcderives a mirror from a version number.[Unreleased]entry inCHANGELOG.md(the file's convention for feature PRs), the one sentence in.context/research.mdthat stated the old rule, and the release gate in.context/handoff.md, where this repo records them.Behavior by backend
https://data.nemar.org/on005506/carries nomirroron its version, andhttps://api.nemar.org/healthreports 0.10.25.Ordering note for the release sequence
The fallback only covers a payload with no key at all. Once production sends the key, an
onN.0.0 whose snapshot is not recorded yet isnulland shows no chip, with or without the fallback, untilnemar admin upstream-backfill --executehas run. In a read-only sample of 27 productionondatasets (spread over the catalog by name, 2026-10-27 UTC), 26 are a lonev1.0.0, one hasv1.0.2andv1.0.0, and none carries the key yet, so a lonenullN.0.0 is the common case. The plan promotes the website after the backfill, which avoids a chip-less window; an unrelated website release between the nemar-cli release and the backfill would not.Differences from the plan
'mirror' in vto detect the key. I usedv.mirror !== undefined, which is the same on parsed JSON (it has noundefined) and also treats an explicitundefinedas absent. The one mutant that swaps them survives the tests for that reason.nullpayload is the common pre-backfill shape, and a payload with afalsein it hides an implementation that treatsnullas an absent key.Tests
backend/test/landing-mirror-flag.test.tsseeds it (commit 1abf9286 of the epic branch):landing-mirror-flag-on000001.json(v4.0.0true,v3.0.0null,v2.0.0null,v1.0.1false,v1.0.0true),landing-mirror-flag-on000001-unexamined.json(nothing but null) andlanding-mirror-flag-nm000200.json(nothing but false). They are not captures of production, which does not send the key. One seed differs from that test: the DOI of its stored-v4.0.0row reads...v4.0.0here, where the test builds...vv4.0.0. The existingjsonld-landing-on007753.json, a real production capture from before the flag, covers the fallback.v2.0.0true,v2.0.1false,v1.0.0null);pickMirrorVersionwith one version, whatever its flag; annmdataset (all false); one key anywhere turns the number rule off, wherever the bare entry sits; the flag path still sorts by version number. The cases assert on whatdetectProvenancehands the switcher and the toggle.listMirrorVersionsfail these tests: a per-version??fallback, a fallback whenever nothing is true, no fallback, the number only, null treated as a mirror, false listed as well, no sort on the flag path,everyforsome, only the first entry checked for the key, null treated as an absent key, and only booleans counted as the key. Each was applied one at a time, confirmed applied, and reverted.Gates
Each of the first two commits passes all four gates with exit code 0:
bun run lint;bun run typecheck(0 errors, 0 warnings, the same 14 hints as before);bun run test(161 files, 4381 tests, 18 more than before);bun run build. The test gate was run the wayci.ymlruns it, with the six nemar-clidevcontract files in the environment variables, because the local sibling nemar-cli checkout is stale (it pins validator 2.4.1,devpins 3.0.2) and failsvalidator-pin-drifton any branch. The three review-fix commits after them change only comments and.context/handoff.md; on the final head lint and typecheck exit 0, and the test gate, run the same way, exits 0 with all 4381 tests.The GitHub Actions run on the pull request head (5091a7f) also passed all four jobs (lint, typecheck, test, build) and the Cloudflare Pages preview built, so no check is red for lack of Actions minutes.
Checking it
test.nemar.orgruns against the nemar-clidevbackend, whose catalog holds onlyxxfixtures, so notrueornullchip can be looked at there. The recorded-payload tests prove them. After the release and the backfill,curl -s -H 'Accept: application/json' https://data.nemar.org/<on id>/ | jq '[.versions[].mirror]'shows the real values.stagingdeploys totest.nemar.orgonly and auto-bumps-devN. Check that runs started (website#374).