Skip to content

merge(library): walk and digest trees through one module - #49

Merged
LittleCoinCoin merged 4 commits into
mainfrom
refactor/tree-walk
Nov 17, 2026
Merged

LittleCoinCoin merged 4 commits into
mainfrom
refactor/tree-walk

Conversation

@LittleCoinCoin

Copy link
Copy Markdown
Member

PR A1 of the pre-M6a cleanup round: one directory walker and one build-context digest, owned by a new core module candler_core::tree.

What moved

tree.rs holds Walk (one recursive walker, sorted by the /-joined string, with the link policy named by each caller: Links::Record, Skip, Refuse; names Strict or Lossy; an optional name rule Screen), BuildContext (ex-BuildInputs, same JSON and keys) and Listing::stage (ex-copy_tree, which now makes links again so the staged tree is the tree the digest covers). Walk has no order or on_error option: nothing needs another order or a collecting walk (the import readers, which would, stay separate), so they were left out rather than added unused.

Sites rewired:

  • W1 and BuildInputs in resolve/steps/image.rs (Record, Strict). Same bytes into the cell digest.
  • W5 experiment/inputs.rs walk/walk_dir (Refuse, Strict, unmountable as a Screen). InputError texts and codes kept.
  • W6 runner/exec/gather.rs walk (Skip, Strict).
  • W4 resolve/steps/ground_truth.rs walk_files (Skip, Lossy); context_exposures reads through BuildContext.
  • W2/W3 and D2/D3 in isolation/image.rs (tree_digest, collect_files, copy_tree, extension_digest): gone, see the tag change below.

Left alone, as the map says: W7/W8 import readers, W9 candler ls, the flat listers, D7, D9 and the test walkers (R3 is A2), skill_files in candler-harness. D5 (store_input) and D6 (collect_files digests) keep their hashing; only their walk moved.

Digest evidence

Commit 1 pins guard_build_context (nested dirs, a-b and a/b, a file link, a dir link, a non-ASCII name, a hidden file) before any move. Its BUILD_INPUT_DIGEST literal is unchanged through commits 2 and 3. Unchanged and green: guard_cell_digest, guard_context_digest, guard_run_context, guard_import_mini, guard_engine and the oracles cell_digest.toml, context_inputs.toml, live_context_runs.toml, context_digest_runs.toml. git diff --stat origin/main -- crates/candler-schemas/tests/fixtures __reports__/m2a-evaluation-parity/golden_parity is empty. No candler-schemas file is touched.

The one-time tag change (R1, commit 3)

Image tags now derive from the BuildContext digest: base_tag, context_digest and the extension tag. The pin BASE_TAG in guard_build_context moves from candler-base:src-31c20597ffe9 to candler-base:src-610940524574 in that commit only (and the guard writes the base context's own Dockerfile, which the new digest covers). Effect: one rebuild of the base, env and extension images. Image ids and cell digests are unaffected. Behaviour changes that come with it: a link in an extension context is staged as a link, where copy_tree followed a file link and failed on a directory link; an empty directory in a context is no longer staged (the limit below); the extension layer is staged from the listing that was digested.

R2: D1 still ignores file modes and empty directories (no schema tag change). It is written as a limit in the tree module doc.

Other changes

  • docs/contract/codes.toml: candler_core::tree::WalkError goes in [internal] with a one-line reason; no code renamed.
  • platform_inventory.toml: tree.rs is listed for std::os::unix::fs::symlink (staging a link).
  • The tests that named BuildInputs (guard_treatment_context) use BuildContext.
  • resolve/steps/image.rs: only the build-context code was touched, not prune_name_ok.

Bites (each: break, see red, revert)

guard break red
a_listing_is_sorted_by_the_joined_string sort by path components in Walk::list red
guard_build_context, a_staged_copy_has_the_digest_of_its_listing BuildContext::walk Record to Skip both red
declared_input_refused_names_kind_and_path declared inputs: Refuse to Record red
the_files_of_a_run_leave_out_links run outputs: Skip to Record (planted link enters) red
a_staged_copy_has_the_digest_of_its_listing stage drops links red
guard_build_context base tag from the directory name, not the content red

The first W6 bite was green against the existing guards, so the_files_of_a_run_leave_out_links was added.

Gates

cargo fmt --check and cargo clippy --workspace --all-targets -- -D warnings are clean. cargo nextest run --workspace: 733 run, 730 passed; the 3 failures were guard_image guards that hard-code the base tag, which is the tag change above. Their literal (src-12bee9345901 to src-83c18228eddb) moved in commit 3 and the five guard_image tests pass; the rest of the workspace was green on that run. No container test flaked.

🤖 Generated with Claude Code

LittleCoinCoin and others added 4 commits November 17, 2026 17:54
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One Walk with the link policy named by each caller (Record, Skip, Refuse),
BuildContext (ex-BuildInputs, same JSON), and Listing::stage. The image
step, the ground-truth check, declared inputs and the run's outputs read
their trees through it; every digest is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The base and extension tags derive from the BuildContext digest, and the
extension layer is staged from the listing that was digested. This is the
one-time tag change: the base, env and extension images build once more.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@LittleCoinCoin
LittleCoinCoin merged commit cc6268f into main Nov 17, 2026
8 checks passed
@LittleCoinCoin
LittleCoinCoin deleted the refactor/tree-walk branch November 17, 2026 09:26
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