Skip to content

refactor(trace): single discovery path; relocate self-trace to cert/trace/#116

Merged
luofang34 merged 1 commit into
mainfrom
pr/trace-roots-unify
May 1, 2026
Merged

refactor(trace): single discovery path; relocate self-trace to cert/trace/#116
luofang34 merged 1 commit into
mainfrom
pr/trace-roots-unify

Conversation

@luofang34
Copy link
Copy Markdown
Owner

Summary

Closes the silent-under-counting bug a downstream project hit: traces under cert/trace/ produced floors current=0 because count_trace_per_layer hardcoded tool/trace/ while every other verb (check, trace --validate) used a discovery chain. Three changes drive toward "every `cargo evidence` verb sees the same trace location."

1. cert/trace/ is the canonical project layout, period

Discovery chain is now: <workspace>/cert/trace/ → `boundary.toml`'s `scope.trace_roots`. No `tool/trace/` fallback. `tool/trace/` was a transitional path that confused the exclusion in three different walker tests; collapsing on one location removes the asymmetry that caused the bug.

2. One discovery function, library-side

`evidence_core::trace::default_trace_roots(workspace_root)` is the single source of truth. `evidence_core::floors::count_trace_per_layer` uses it directly; `cargo_evidence::cli::trace::default_trace_roots` is a thin re-export.

A downstream project with traces under `cert/trace/` now sees the right floor counts — `cargo evidence floors`, `cargo evidence trace --validate`, and `cargo evidence check` all reach the same root.

3. Self-trace relocated

`git mv tool/trace cert/trace`. `cert/boundary.toml` updated to `trace_roots = ["cert/trace"]`. CI workflow paths, integration-test fixture builders, walker-exclusion logic in `rot_prone_markers_locked` + `trace_id_refs_locked`, and every doc comment that mentioned the old location all swept across.

Test

  • New `crates/evidence-core/tests/floors_trace_discovery.rs` — pins both the canonical layout (`cert/trace/`) and the `scope.trace_roots` fallback. The bug would have been caught here pre-0.1.3.

Floors ratchet

Floor Was Now
`per_crate.evidence-core.test_count` 351 354

All other dimensions unchanged.

Backward compat

None for the on-disk layout. The canonical layout is documented by `cargo evidence init` (which already scaffolds `cert/trace/`), so new projects pick it up automatically. Existing internal-tool projects on `tool/trace/` must:

  1. `git mv tool/trace cert/trace`
  2. Update their `cert/boundary.toml`: `trace_roots = ["cert/trace"]`

Stacking note

This is the third of the three v0.1.3 cleanup items. PR #114 (doc honesty pass) is merged; PR #115 (DAL-A MC/DC fail-loud) is green and ready to merge. Recommend merging #115 before this so the floor baseline doesn't drift mid-flight.

🤖 Generated with Claude Code

…race/

Three things, all driving toward "every cargo evidence verb sees
the same trace location":

1. **`cert/trace/` is the canonical project layout, period.**
   The discovery chain looks at `<workspace>/cert/trace/`; if
   absent it falls back to `boundary.toml`'s `scope.trace_roots`.
   No `tool/trace/` fallback. `tool/trace/` was a transitional
   path that confused the exclusion in three different walker
   tests; collapsing on one location removes the asymmetry that
   caused the original silent-under-counting bug.

2. **One discovery function, library-side.**
   `evidence_core::trace::default_trace_roots(workspace_root)` is
   the single source of truth. `evidence_core::floors::count_trace_per_layer`
   uses it directly; the CLI's `cargo_evidence::cli::trace::default_trace_roots`
   is a thin re-export. A downstream project with traces under
   `cert/trace/` now sees the right floor counts — `cargo
   evidence floors`, `cargo evidence trace --validate`, and
   `cargo evidence check` all reach the same trace root.

3. **Self-trace relocated.**
   `git mv tool/trace cert/trace`. `cert/boundary.toml` updated to
   `trace_roots = ["cert/trace"]`. CI workflow paths, integration-
   test fixture builders, walker-exclusion logic in
   `rot_prone_markers_locked` + `trace_id_refs_locked`, and every
   doc comment that mentioned the old location all swept across.

Test:
  - New `crates/evidence-core/tests/floors_trace_discovery.rs`
    integration test fixtures both the canonical `cert/trace/`
    layout and the `boundary.toml` `scope.trace_roots` fallback,
    asserting `count_trace_per_layer` returns the real counts.

Floors ratchet:
  - `evidence-core/test_count` 351 → 354 (+3 integration tests).
  - All other dimensions unchanged.

Backward compat: there is none for the on-disk layout. The
canonical layout is documented by `cargo evidence init` (the
template scaffolds `cert/trace/`), so new projects pick it up
automatically; existing internal-tool projects on `tool/trace/`
must `git mv tool/trace cert/trace` and update their
`scope.trace_roots`.
@luofang34 luofang34 force-pushed the pr/trace-roots-unify branch from cc048a4 to 94c1c87 Compare May 1, 2026 22:18
@luofang34 luofang34 merged commit b1e1400 into main May 1, 2026
15 checks passed
@luofang34 luofang34 deleted the pr/trace-roots-unify branch May 1, 2026 22:26
luofang34 pushed a commit that referenced this pull request May 2, 2026
…rface claim, CHANGELOG

- **Blocker 1**: CONTRIBUTING.md's UUID workflow now points at the
  established `cargo evidence trace --backfill-uuids` policy and
  cross-references `cert/trace/README.md`'s rationale. The
  python3 one-liner the prior draft suggested was the exact
  hand-crafting form the existing policy bans (collision risk,
  weakens the "UUIDs are opaque" contract, tempts reading meaning
  into digits). Two contradictory authority docs on the same
  workflow is a quality-of-process regression — fixed.

- **Blocker 2**: Sharpened the negative dogfood. The previous test
  used `mcdc_2024.rs`, which fails the duplicate regex for two
  independent reasons (no leading space + 4 digits exceeds the
  2-digit cap). A regression that drops only the leading-space
  anchor would still pass. Added `mcdc_24.rs` (2 digits, no
  leading space) so each anchor is isolated by its own fixture.

- **Minor 3**: HLR-069 now claims `surfaces = ["editor-duplicate
  gate"]`, matching the convention HLR-044 / HLR-046 / HLR-047
  established for sibling hygiene gates. New entry in
  `KNOWN_SURFACES`. `cert/floors.toml` known_surfaces 21→22.

- **Minor 5**: 0.1.4 hygiene-track entry added to CHANGELOG. Bundles
  the changes already in main from PRs #115 / #116 / #117 plus the
  changes landing in this PR. Per-PR cadence rather than batched
  release-prep PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants