Skip to content

refactor: archive collector, GitTree and run_git for generate and migrate - #18

Merged
oesteban merged 2 commits into
masterfrom
refactor/archive-collector
Dec 4, 2026
Merged

oesteban merged 2 commits into
masterfrom
refactor/archive-collector

Conversation

@oesteban

@oesteban oesteban commented Dec 4, 2026

Copy link
Copy Markdown
Member

Summary

First of seven PRs for WP4 of Archive 2.0 (tfmgr generate and tfmgr migrate). No change in what the validator reports: this moves code the coming generators and the migration engine share, and adds two readers they need.

 check_archive(root)
-  loop over templates: descriptions, atlases, transform targets (inline)
+  collect_archive(DirectoryTree(...) for each template)   # generate.py, reused by `tfmgr generate`
   TF803 transform targets
   TF801 templates.tsv
-  check_renames(root)        # reads files while checking
+  check_renames(root)
+    renames_problems(text, exists, installed)            # pure: a plan checks a simulated Archive
 tfmanager/
 ├── io.py         + run_git(repo, *args, input=None, env=None) -> bytes
 ├── tree.py       + GitTree(repo, treeish='HEAD', name=None)
 └── generate.py   + ArchiveIndex, collect_archive(trees)

GitTree reads a template from a commit without checking it out (ls-tree + one cat-file --batch), under the same rules as DirectoryTree: only symlinks into the annex count, submodules and other symlinks are left out, and annexed content is never read. tfmgr migrate apply will validate the commits it builds before checking them out.

Evidence

  • Before (master 81bec4b) / After (this branch): check_archive() on the Archive superdataset (30 templates installed), strict and legacy, gives byte-identical issue lists (676 bytes of JSON each; TF801 and TF803 as before).
  • New tests: GitTree against a real temporary repository (text, an executable, locked and unlocked annexed files, a plain symlink, a submodule), equal to DirectoryTree on the same checkout for every file; collect_archive; renames_problems (including uninstalled templates); run_git errors.
  • pytest -o addopts="" --doctest-modules tfmanager: 185 passed on Python 3.13 (178 on master). ruff check . clean.

Merge Danger

Door: two-way

Blast Radius: none

Internal APIs only; no CLI or rule changes. The new git test fixture isolates git from the user's and system configuration (no signing prompts, fixed identity).

…rate

Groundwork for `tfmgr generate` and `tfmgr migrate` (WP4), with no change in
what the checks report:

- generate.collect_archive() gathers the template descriptions, atlas labels
  and transform targets that check_archive used to collect inline; templates.tsv
  and the TF801/TF803 checks now share it with the coming generators.
- validate.archive.renames_problems() checks a root renames table from its
  text, given exists/installed callbacks, so a migration plan can check a
  simulated Archive. check_renames() wraps it.
- io.run_git() runs git without a shell and keeps its output binary.
- tree.GitTree reads a template from a commit without checking it out, under
  the same rules as DirectoryTree (only annex symlinks count, submodules and
  other symlinks are left out, annexed content is never read).

check_archive() gives identical issues on master and on this branch for the
Archive superdataset (all 30 templates installed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oesteban
oesteban marked this pull request as ready for review December 4, 2026 08:13
@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-04T08:17:31.952849Z 3ba4919 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: 3ba4919dc3

ℹ️ 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/tree.py Resolved
A GitTree read every git blob of up to MAX_TEXT_BYTES into its cache at the
first read_bytes, so a commit with many files in git (a submission that puts
images in git rather than in the annex) could take gigabytes.

- The smallest blobs are read ahead, in one git call, up to MAX_CACHE_BYTES
  (32 MiB); any other blob is read when asked and not kept. Validating a
  template of the Archive still takes one call: the largest keeps 0.93 MiB
  in git.
- Only link targets of up to MAX_LINK_BYTES (4 KiB) are read: annex links
  are about 140 bytes, so a longer link is not an annexed file.
- Only files of up to that size are opened to look for git-annex pointers.

Reported by the Codex review of #18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oesteban
oesteban merged commit 351db59 into master Dec 4, 2026
6 checks passed
@oesteban
oesteban deleted the refactor/archive-collector branch December 4, 2026 09:08
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