Repository navigation
Phase 5a: share the standard edits - #1925
Merged
neuromechanist merged 15 commits intoOct 24, 2026
Merged
neuromechanist merged 15 commits into
neuromechanist merged 15 commits into
Conversation
applyConceptDoiToDescription moves unchanged to shared/standard-edits/description.ts so the re-pull planner (ADR 0111, #1911) can recognize the edit publish makes. services/doi.ts re-exports it; the orchestrator and the #1386 repair keep their imports. Tested: concept-doi-description, repair-doi-metadata and doi-provider suites pass unedited; a new suite proves the two paths are one function and pins the non-array SourceDatasets cases; three one-line mutations of the shared body fail the old-path suite.
shared/standard-edits/readme.ts now holds buildDoiBadge and planReadmeBadgeCommit (moved unchanged; services/doi.ts re-exports them), decideReadme and readmeProvenanceStub (ensureReadmeMd's #642 rule, which ensureReadmeMd now applies), and selectPublishReadmes (the update_readme step's content-source and deletion rule), for the re-pull planner (ADR 0111, #1911). Tested: readme-badge-plan, import-openneuro and repair-doi-metadata pass unedited; a new suite proves the badge pair is the same functions, pins the stub's bytes, and checks ensureReadmeMd against decideReadme on nine real directory layouts; seven one-line mutations each fail a suite.
The orchestrator's update_readme step takes its content source and the files it deletes from selectPublishReadmes instead of an inline copy of the same loop, so the re-pull planner models the rule publish actually follows. Same order, same entries, same deletions. Tested: a source check pins the call and the absence of a README list in the orchestrator (no test drives the step itself, it reads GitHub); mutating the delete loop to readmes.found fails it; the orchestrator source-scan suites still pass.
withBidsignoreEntry in shared/standard-edits/bidsignore.ts is the .nemar/ line rule the backend's enrichment commit and the upload's metadata step each carry a copy of, for the re-pull planner (ADR 0111, #1911). Both callers are left unchanged. Tested: a parity suite runs the real writeNemarMetadata for eleven starting files (absent, empty, CRLF, trailing blanks, already present, non-ASCII) and compares bytes; mutating the shared rule or the upload's copy fails it.
importHeaderPatch(before, dates) in shared/identifier-scrub.ts is the importer's scrub-then-dates patch with both proofs, returning ok/not-edf/scrub-unverified instead of throwing, for the re-pull planner (ADR 0111, #1911). patchHeader in import-scrub.ts is now a thin wrapper: not-edf is null and scrub-unverified throws the same ImportScrubRefused as before. Tested: import-scrub, import-normalize, identifier-scrub and identifier-dates pass unedited; a new unit suite pins the result shapes; a new end-to-end case (no existing one reads a non-EDF header) drives prepareImportedTreeForCopy over two non-EDF recordings. Mutations of the shared body and of the wrapper each fail a suite.
RECORDING, JSON_FILE and SCANS_TABLE in import-scrub.ts become exported RECORDING_PATH, JSON_PATH and SCANS_TABLE_PATH, unchanged, so the re-pull planner (ADR 0111, #1911) forecasts the scrub over the same paths it runs on. Tested: import-scrub passes unedited (50/50); a new unit suite pins what each matches and that none is stateful; three one-line mutations of the patterns fail it, and dropping .bdf also fails the not-EDF end-to-end case.
git-lib.ts exports presentIn and adds readLocationLogsAt(repo, ref, keys): the location logs at one resolved commit of a git-annex branch, read with rev-parse and cat-file only, so the re-pull planner (ADR 0111, #1911) can read dead marks and nemar-s3 presence from a bare clone. It applies git-annex's keyFile escaping (& % : /), refuses a ref that does not resolve instead of answering no log, and refuses a ref or key that would break the batch read. Tested against real git-annex (add, copy to a directory remote, drop, dead, registerurl, bare clone): logs match git-annex's own, presence matches whereis, a URL key is found under its escaped name. Six one-line mutations each fail it; annex-registry still passes.
The suite's git-annex probe goes through toolOrFail, so NEMAR_REQUIRE_SCRUB_TOOLS=1 fails it instead of skipping, and the header says it drives the git-held header read, not the upstream ranged read (review round 1, #1925). Tested: passes with git-annex; skips without it; fails with the requirement set and no git-annex on PATH.
Review round 1 (#1925) found a header the scrub rewrites but cannot prove: a recording field leading with Startdate 99-ZZZ-9999. import-header-patch pins importHeaderPatch's scrub-unverified result for it with dates on and off and corrects the comment that called the branch unreachable (datesUnproven stays documented as unreached: 400,000 fuzzed patches found none). The not-EDF end-to-end file becomes import-scrub-header-outcomes and adds the same header through prepareImportedTreeForCopy: it refuses with scrub-unverified in patchHeader, before any write or commit. Tested: both files pass; flipping patchHeader's not-edf test fails both end-to-end cases, and dropping importHeaderPatch's verifyScrub guard fails the unit and end-to-end cases.
The orchestrator's update_metadata comment and repair-doi-metadata's header named services/doi.ts as where the rules live; they now name shared/standard-edits/, which doi.ts re-exports, so nobody adds a copy back in doi.ts. The readme.ts header also says doi.ts re-exports applyConceptDoiToDescription (review round 1, #1925). Comments only. Tested: the orchestrator source-scan suites, standard-edits-readme and repair-doi-metadata pass.
The orchestrator wiring check now parses publication-orchestrator.ts with the TypeScript compiler and compares comment-free code: the selectPublishReadmes import, readmes = selectPublishReadmes(tree) over main's tree, getBlobContent of contentSource.sha, contentSourcePath: contentSource?.path, and one deleteRepoFile inside the loop over readmes.remove. Any string literal in the file that spells a README name in any case, other than the README.md it writes, fails (review round 1, #1925). Tested: re-inlining a list (readme.md, Readme.md, README.rst), filtering the tree by an inline list, hard-coding contentSourcePath, deleting readmes.found and reading tree[0] each fail it; the expected text written only in a comment does not satisfy it.
readLocationLogsAt no longer reads "no log" for a reason other than the branch having none (review round 1, #1925). A ref whose tree has no uuid.log (HEAD, main, any non-git-annex branch) refuses with annex-ref-not-git-annex, and a log the tree names that this clone lacks (a partial or blobless clone), or a log path that is a directory, refuses with annex-log-unreadable. Paths are looked up with ls-tree and read by object id; a key named twice gets the same answer twice. A valid git-annex ref reads exactly as before. Tested against real git-annex plus branches built with git mktree --missing: HEAD, main and a branch without uuid.log refuse, the missing object and the directory refuse, absent logs stay empty, duplicates agree. Removing each guard, or returning one answer per unique path, fails a test; annex-registry and fresh-clone still pass.
The bidsignore parity suite now also runs the backend's own rule: the loop over bidsignoreEntriesToIgnore in commitEnrichmentWithBidsignore is taken from the parsed contents.ts without comments, compiled and run over the same eleven starting files, with one entry and with the admin route's two, and compared with withBidsignoreEntry byte for byte. It also reads the .nemar/ entry the enrichment pipeline and the admin route's v2 branch pass. The backend copy is unchanged; #1918 owns folding it in (review round 1, #1925). Tested: dropping trimEnd, matching by endsWith, never setting the updated flag in contents.ts, and changing either caller's entry each fail it.
The ensureReadmeMd parity block is retitled to say it proves the file I/O (decideReadme's own tests pin the rules), the lowercase bare readme case says from: "README" is the preserved legacy outcome, and ReadmeOutcome's doc says so too, with its consequence: on a case-sensitive filesystem the caller's git add README names an untracked path and the import fails at staging (checked: fatal, exit 128). No code changes (review round 1, #1925). Tested: standard-edits-readme and import-openneuro pass.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1925Version: 🤖 Updated on each push. |
Tested: location-logs-at suite passes.
neuromechanist
merged commit Oct 24, 2026
8a54cfc
into
feature/issue-1046-epic-upstream-freshness
18 checks passed
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.
Summary
Phase 5a of epic #1046 (ADR 0111): move the NEMAR standard edits to
shared/so the future re-pull planner (Phase 5b) and the Worker use the very functions the importer and the publisher use. No behavior change.New
shared/standard-edits/{description,readme,bidsignore}.tsholdapplyConceptDoiToDescription, the README badge pair and decision rule (decideReadme,readmeProvenanceStub,selectPublishReadmes) and the.bidsignorerule;doi.tsandensureReadmeMdre-export or wrap them so every old path still works unedited. The orchestrator'supdate_readmenow callsselectPublishReadmesinstead of keeping a second copy (a source check guards that wiring because nothing drivesupdate_readmeend to end).importHeaderPatchmoves intoshared/identifier-scrub.tswithpatchHeaderas a thin wrapper, the scrub path regexes are exported asRECORDING_PATH,JSON_PATHandSCANS_TABLE_PATH, andgit-lib.tsexportspresentInand a newreadLocationLogsAt(resolves a ref to one commit, refuses a missing ref, escapes key file names the way git-annex does, checked against real git-annex 10.20261006 with a URL key).Filed while building: #1918 (three copies of the
.bidsignorerule) and #1919 (locationLogsmisses escaped keys, so a dead URL key could be copied; predates this branch). Known and unchanged:applyConceptDoiToDescriptionthrows onSourceDatasets: [null], a lowercase barereadmerename is followed bygit add README, and an upstreamReadme.mdis kept on import but not found on publish. Phase 5b will account for each.Test plan
bun test: 18695 pass, 231 skip, 2 fail across 736 files; neither failure comes from this branch (website parity against a stale sibling checkout;admin-pr-reviews-clicrashed under load and passes alone, 168 pass)bun run test:scrub: 871 pass, 0 faillintandlint:scrubclean; the old-path suites pass uneditedwrangler deploy --dry-run, dev env) succeeds at 5399.67 KiB; nothing inshared/standard-editsoridentifier-scrub.tsimportsnode:First half of #1911; Phase 5b (the plan command) completes it.
Part of epic #1046