Skip to content

merge(repo): share the test tree helpers in one dev crate - #50

Merged
LittleCoinCoin merged 1 commit into
mainfrom
refactor/testkit
Nov 17, 2026
Merged

LittleCoinCoin merged 1 commit into
mainfrom
refactor/testkit

Conversation

@LittleCoinCoin

Copy link
Copy Markdown
Member

PR A2 of the pre-M6a cleanup round (ruling A-R3): the test crates' copied tree helpers move into one dev-only crate, crates/candler-testkit (publish = false, std only, never depends on candler-core).

Shapes and helpers

helper shape links modes separator order returns
copy_tree(from, to) recursive copy a link to a file is read through (fs::copy) file modes kept (fs::copy) n/a n/a ()
snapshot(root) recursive, regular files not followed, not listed none read / sorted (BTreeMap) BTreeMap<String, Vec<u8>>
file_list(root) recursive, regular files not followed, not listed none / sorted Vec<String>
file_set(root) same as file_list same none / set BTreeSet<String>
file_paths(root) recursive, regular files not followed, not listed none absolute (starts with root) sorted Vec<PathBuf>

All panic with the path on an I/O error (test failure), as the copies did.

Per-site semantics, and what was done

site recursive links modes separator order returns action
core guard_store copy_tree yes file read through kept n/a n/a () rewired copy_tree
core guard_registry copy_tree yes same kept n/a n/a () rewired
candler guard_cli_observe copy_tree yes same kept n/a n/a () rewired
core support/legacy_import copy_tree yes same kept n/a n/a () rewired (pub use, so guard_import_mini imports unchanged)
core guard_legacy_mapping copy_dir yes same kept n/a n/a () rewired copy_tree
core guard_store files_of yes file_type().is_file(), links skipped none / (lossy) sorted map BTreeMap<String, Vec<u8>> rewired snapshot
candler guard_inspect snapshot yes is_dir() follows dir links none native, PathBuf keys sorted map BTreeMap<PathBuf, Vec<u8>> rewired snapshot (String keys; compared before/after only)
candler guard_cli_surface files_below yes is_dir() follows none PathBuf keys sorted map BTreeMap<PathBuf, Vec<u8>> rewired snapshot (two trees compared with each other)
core guard_seams walk yes is_file(), links skipped none native, lossy sorted Vec<String> rewired file_list
core guard_session files_under yes is_dir() follows none native, lossy sorted Vec<String> rewired file_list
core guard_run_context files_below yes is_dir() follows none \ to / set BTreeSet<String> rewired file_set
core guard_run_exec run_files yes is_file(), links skipped none lossy prefix filter on a vec BTreeSet<String> rewired: the walk is file_list; the manifest-prefix logic stays
core guard_legacy_mapping walk yes is_dir() follows none absolute paths sorted Vec<PathBuf> rewired file_paths
candler guard_cli walk yes is_dir() follows none absolute paths unsorted Vec<PathBuf> rewired file_paths (now sorted; the caller iterates and does not depend on order)
harness-claude-code guard_claude_code_driver walk yes is_dir() follows none joined with / sorted by caller Vec<String>, Res rewired file_list
harness-claude-code guard_fixture_provenance walk yes is_dir() follows none \ to / set BTreeSet<String>, Res rewired file_set

The sites differ on links only (is_dir() follows a directory link and lists a file link; file_type() lists neither). No rewired test plants a link under a walked root, and the helpers take the strictest reading (a link is never followed or listed); every rewired test passes.

Left in place, with the reason

site reason
core support/legacy_import snapshot lists directories too (value None); unique
core support/run_plan snapshot rooted at <store>/runs, keys relative to the store, tolerates a missing directory; unique
core support/mod.rs scan, scan_segments gunzip, symlink refusal, per-file reads with io::Result; not a tree listing
core guard_container_e2e/gateway_e2e read_tree concatenates bytes in directory order; used once
core guard_container_e2e/env_image_e2e copy_files one level deep, files only; unique
core guard_signal rust_files, guard_platform_seam rust_files_under, guard_refusal_codes sources/source_files, guard_layering_i22, guard_layering_i1 copy_renamed/relative_to source scans with an extension filter, a skip list or a rename; each one purpose
core oracle grading_files, candler guard_cli_evaluate files_by_run/outcome_files, guard_golden_parity files_of/files_of_evaluator/tree_digest oracle-specific listings; the golden-parity digest (D9) stays as it is by rule
candler guard_ingest listing skips hidden entries, returns digests; unique
core guard_tree_walk, guard_build_context, frozen-digest guards independent expectation of the production walker; they must not share a helper with it (the testkit does not use candler_core::tree, but these keep their own expectation)

Bite

In candler-testkit, the walk's recursion into directories was removed. Two rewired tests went red, guard_store::a_copied_store_reads_byte_equal and guard_store::the_layout_of_a_run_with_two_outcome_files_is_the_frozen_path_set. The change was then reverted.

Gates

cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings and cargo nextest run --workspace (740 passed, 31 skipped) are green.

Plumbing touched

  • Cargo.toml: workspace dependency candler-testkit; candler, candler-core, candler-harness-claude-code take it under [dev-dependencies] only.
  • release-plz.toml: [[package]] name = "candler-testkit" with release = false and changelog_update = false, so the release job skips it (the local release-plz run is not reproducible here; CI's release job is the check).
  • CI changed-paths filter: ** already covers crates/candler-testkit/; no change.
  • platform_inventory.toml: not touched; the testkit uses no platform-specific call.
  • Refusal-codes guard: the testkit declares no error enum; codes.toml untouched.
  • clippy::panic is allowed in the testkit alone (with a reason): a failing test helper panics.
  • No golden or DIGEST fixture moved: git diff --stat origin/main -- crates/candler-schemas/tests/fixtures __reports__/m2a-evaluation-parity/golden_parity is empty. No test added or removed.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@LittleCoinCoin
LittleCoinCoin merged commit 9bacbf1 into main Nov 17, 2026
8 checks passed
@LittleCoinCoin
LittleCoinCoin deleted the refactor/testkit branch November 17, 2026 09:44
LittleCoinCoin added a commit that referenced this pull request Nov 18, 2026
`main` has been red since 9560cd3 (#51, roadmap-only): 20 candler-core
guards fail on CI with "`.claude/skills/htn/SKILL.md` is not in commit
<main's HEAD>". The code at #50, the last green run, is the same.

## Cause

`Swatinem/rust-cache` saves `target/` after deleting every file outside
the build profiles. It keeps the directories (cleanup rule: "Files other
than `CACHEDIR.TAG` are removed").

So the cache restores the shared fixture `target/tmp/job_skill_repo` as
empty folders, `.git` included. `skill_repo()` only checked that `.git`
exists, so it reused the skeleton. git did not recognise the skeleton as
a repository and searched upward until it reached the checkout's own
repository.

## Fix (test support only)

- The fixture is reused only when `.git/HEAD` is a file.
- A skeleton is pruned by removing empty directories only, deepest
first, so a repository that another nextest process has just placed is
never deleted.
- git runs with `GIT_CEILING_DIRECTORIES` set to the scratch directory,
so a missing repository fails at once instead of reading the checkout's.

## Evidence

With a planted skeleton in an in-repo `target/`:
- the old fixture fails with CI's exact error (2 of 3 sampled guards);
- the fixed one passes 16 of 16 sampled guards;
- the full candler-core suite passes 329 of 329;
- fmt and clippy (`-D warnings`) are clean.

This also unblocks #52, whose 21 failures share
this cause.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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