Skip to content

feat(migrate): new names of the Archive (rules, res keys, decisions, guards) - #21

Merged
oesteban merged 5 commits into
masterfrom
feat/migrate-names
Dec 4, 2026
Merged

oesteban merged 5 commits into
masterfrom
feat/migrate-names

Conversation

@oesteban

@oesteban oesteban commented Dec 4, 2026

Copy link
Copy Markdown
Member

Summary

The new names of the Archive for TemplateFlow 2.0 (WP4, PR 4 of 7; after #20). Nothing renames files yet: PR 6 applies plans.

plan_names(snapshot, config, headers)
  plan_res                                  # res.py
    keys of the description: 01 -> 1 (R16), iso4mm -> 4 (R11)
    each key's block: kept | rebuilt from its files | new
    volume off its block -> key of its grid (R19); volume without res -> R12
    new key = voxel size when integer and free, else smallest free index
  for each file, in byte order
    decisions of migrate/config/2.0.0.yaml  # set entities, suffix, extension, or remove
    R01 ... R20                              # R12 writes the planned res
    R99                                      # entity order of the rule set
  guards: M102 to M107, M108 counts, M113 decisions that would apply again
  strict names validation of the result -> M101, with a decision to fill in
 tfmanager/
 ├── migrate/
+│   ├── config.py           # load and check the decisions (JSON Schema + rule set)
+│   ├── config/2.0.0.yaml   # atlas labels, renames of single templates, res_assign
+│   ├── config/schema.json
+│   ├── findings.py         # M101 to M113
+│   ├── names.py            # Name, rules, guards, archive_table
+│   ├── renames.py          # merge_fragment, check_fragment (as the template action)
+│   ├── res.py              # res keys and blocks from header facts
 │   └── headers.py          # needed(): every volume
 ├── schema/
 │   ├── rules.yaml          # + TF118 redundant-entity
 │   └── suffixes.yaml       # probseg and midthickness take .shape.gii
 ├── validate/names.py       # + check_redundant
 └── tests/
+    ├── data/renames-2.0.0.tsv   # golden: old_path, new_path, rules
+    └── test_migrate_names.py

The decisions in 2.0.0.yaml are the ones agreed for WP4:

  • Atlas labels: WHS v3 becomes Osen2019, Fischer344 v4 becomes Goerzen2020 (evidence cited), and the typo CerebA becomes CerebrA.
  • Tissue maps are desc-tissues, never atlases: RESILIENT, Fischer344, NMT31Sym, NKI, and desc-tissues4 and desc-tissues6 in OASIS30ANTs.
  • Dropped desc values that tell no file apart: fMRIPrep, DC, reg and avgseg. Their meaning moves to the JSON sidecars in PR 5.
  • dhcpAsym surfaces: _label.gii becomes _dseg.label.gii, and _roi.shape.gii becomes _label-cortex_probseg.shape.gii.
  • NMT31Sym's 5D stacks are removed (n/a), since the level images hold the same data.
  • Fischer344's hemisphere masks stay on res-1 until their data fix.
  • Cortex masks (dparc) become mask.label.gii (R17).

TF118 is a new warning for a desc, seg or label that tells its file apart from no other file. Masks keep desc, probabilistic segmentations keep label, and desc-brain and desc-tissues are always kept.

Evidence

  • Before: no plan of the new names.
    After: archive_table(plans) from the pinned v2 skeleton (python-client 45755e5), the bundled header facts and the config:

    Files
    Renamed 1560
    Removed (n/a) 6
    Unchanged 999
    Findings 0
  • Tests on the whole Archive:

    • The golden table is pinned byte for byte, along with the count of every rule and decision.
    • The new names are unique, also ignoring case, and each file stays in its directory.
    • No name falls into a path the legacy skeleton drops.
    • Each template is clean under strict names validation.
    • Every merged .renames.tsv passes check_fragment, and the root table passes TF804.
    • Planning the result again renames nothing.
  • The idempotence test caught a real bug. A decision written for the old stack names also matched the migrated level files, so planning twice would have removed them. M113 now blocks any decision that matches a name it gives.

  • Header facts now cover all 1599 files the rules read, and agree with a range-read scan of the S3 copies.

  • TF118: 54 warnings on the legacy Archive (pinned in test_archive.py), and 31 after the migration, all on names kept on purpose (seg-aparc, desc-vaavg, desc-SPM12, seg-aseg, desc-cerebrum, desc-carpet).

  • Local CI: pytest -o addopts="" --doctest-modules tfmanager passes (287 tests) on Python 3.13.7 and 3.15.0rc2; ruff is clean; the sdist and wheel include migrate/config/*.

Merge Danger

Door: two-way

The rename plan is library code and test data. Nothing writes to a template until PR 6, and the golden table is reviewed before any template PR.

Blast Radius: validator

tfmgr validate reports a new warning (TF118) and accepts probseg and midthickness with .shape.gii. Neither changes an exit code, since warnings never fail validation.

oesteban and others added 4 commits December 4, 2026 14:30
A desc, seg or label must tell its file apart from another file of the template
(res, den, hemi and cohort aside). TF118 warns about those that do not, with the
exceptions the migration keeps: masks keep desc, probabilistic segmentations
keep label, and desc-brain and desc-tissues are always kept.

probseg and midthickness take .shape.gii (suffixes.yaml `more_extensions`):
probabilities on a surface, and the vertex areas of HCP's va_avg files.

TF701 compares grids with numpy's tolerance written out (no numpy), and
`effective_grid` (the template's block with its cohort's fields over it)
becomes public for the migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The res keys of the migration follow the grid of each volume, so `needed()`
lists every volume (and GIFTI files whose suffix the rules must check), not
only volumes without res. The bundled table is regenerated from a local
checkout of the Archive: 1599 files, every row of the previous table kept
(the vertex areas of fsLR and fsaverage are no longer needed), and the grids
agree with a range-read scan of the S3 copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…guards)

`plan_names` renames the files of a template: the decisions of
`migrate/config/2.0.0.yaml` first, then rules R01 to R20 and R99. Every
volume takes the res key of its grid (`res.py`): a block that no file
matches is rebuilt from its files, a volume off its block takes the key of
its grid or a new one (its voxel size when free, else an index), and
cohorts that differ only in their origin share a key.

The config holds the atlas labels (Osen2019, Goerzen2020, CerebrA, with
evidence), renames of single templates (dhcpAsym surfaces, tissue maps as
desc-tissues, dropped desc values, NMT31Sym's 5D stacks) and res keys
pinned by hand, each with a count the engine checks (M108).

Findings block a plan: names the naming checks reject (M101, with a
decision to fill in), entities already set (M102), collisions (M103,
M104), old names reused (M105), names the legacy skeleton drops (M106),
moves across directories (M107), ambiguous or unknown grids (M109 to
M111), GIFTI content that does not fit (M112), and decisions that would
apply again to the names they give (M113).

`merge_fragment` and `check_fragment` write and check a .renames.tsv as
the template action reads it. Tests pin the 1566 rows of the Archive
(tests/data/renames-2.0.0.tsv) and check that the result is unique, valid
in strict mode, accepted by the action and TF804, and planned again to no
renames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oesteban
oesteban marked this pull request as ready for review December 4, 2026 13:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T13:52:33.434875Z 1961c18 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1961c188f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tfmanager/migrate/config.py Resolved
…sion

`set: {extension: null}` passed the schema and the config checks, and the
first file it matched crashed planning (TypeError while writing the name).
The schema now requires a string for `suffix` and `extension` in `set`,
and the config check rejects an extension that no suffix of the rule set
takes, as it already did for suffixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oesteban
oesteban merged commit dfa4bc3 into master Dec 4, 2026
6 checks passed
@oesteban
oesteban deleted the feat/migrate-names branch December 4, 2026 13:59
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