Skip to content

Coverage claims verify measured source identities - #875

Merged
zlareb1 merged 6 commits into
mainfrom
fix/coverage-evidence-freshness
Nov 18, 2026
Merged

zlareb1 merged 6 commits into
mainfrom
fix/coverage-evidence-freshness

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Coverage claims verify source, symbol-span, and test identities before applying imported line ranges. Unverified measurements remain historical file associations; a current nonexecution claim requires a measurement at the repository watermark.

Why

An imported run's line numbers can overlap different code after a file changes, or miss the same symbol after its lines move. Applying those ranges to current symbol spans can falsely report both coverage and nonexecution.

A run's commit must match the source file, selected symbol spans, and measured test indexing commits, with a known repository watermark. Unchanged indexed files keep their parsing commit when the head advances, so moving the repository head alone does not discard valid evidence. Different or missing identities remain unverified because the serving read does not fetch historical file objects. Every selected symbol definition needs complete, ordered line bounds. A current negative additionally requires a measurement at the repository watermark, because later tests can execute unchanged source.

Scope and risk

The coverage claim separates verified execution from historical file associations, including deleted or changed tests and lagging compiler spans. Per-file measurement identities prevent mixed runs from borrowing the first file's commit. The reads use existing tenant-scoped point queries. Stored coverage rows are retained.

The conservative identity check can leave unchanged files unverified when coverage was measured at a different commit from their last parse. Symbols with missing or lagging revision metadata also stay unverified. Other strong evidence can still establish coverage; partial or unverified measurements cannot establish nonexecution.

Compatibility, rollout and rollback

  • Wire: no declared fields or settings change. The existing measured dictionary adds freshness, commits, index_commit, files, unverified_paths, unmeasured_paths, and run_current; commit is empty for mixed commits. Per-file details also include selected symbol_commits. Its execution fields include verified source and span identities only. Historical test rows use method coverage_history and existing tier file_reference.
  • Operator steps: none. Verified line evidence requires matching measurement, source, selected symbol-span, and measured-test indexing commits.
  • Rollback: reverting restores the earlier read behavior. No stored rows or schema change.

Tests

The regression tests fail before the fix for stale overlapping ranges, shifted symbols, missing identities, and mixed-run reporting. Current nonexecution remains a passing control. Focused coverage, imports, conventions, documentation, and package-contract tests pass: 429 tests. The added regressions cover stale or missing symbol spans, deleted or edited tests, historical negatives, file-only symbol associations, missing or inverted line extents, partial symbol definitions, and execution without a specific attributed test. An unresolved end bound remains unverified; the span-helper regression excludes that path instead of fabricating a one-line extent. The helper passes strict type checking; make lint passes.

make format-check, make lint, and make typecheck pass on the reviewed head. Full CI passes on that head: 47 successful checks, two skipped checks, and all five workflows successful. Local test execution stays focused. Reproduce the source-identity regressions with .venv/bin/python -m pytest tests/unit/test_code_coverage_freshness.py -q.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex wrote the implementation and tests. The diagnosis, source identity check, and focused regression results were checked against the code.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checking and focused tests pass; required CI, including the full unit and integration suites, passes on the reviewed head.
  • Generated files are regenerated in this PR, not by hand.
  • No migration is added.
  • No plugin behavior changes.
  • No frontend changes.
  • Docs describe source identity checks, conservative limits, and the measurement dictionary.
  • Repository text contains no private deployment details.
  • Commits are signed off.

Imported line numbers describe the measured source. Keep unverified coverage as historical file associations so changed files cannot inherit execution or nonexecution claims from older runs.

Signed-off-by: zlareb1 <[email protected]>
Matching source markers do not establish compiler-span or test freshness. Verify their identities before exact execution claims and require a run at the current watermark before ruling out execution.

Signed-off-by: zlareb1 <[email protected]>
Clamping incomplete spans can turn an unresolved symbol into measured execution. Keep its file association historical until the line bounds and source revision are verified.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 995b330 into main Nov 18, 2026
49 checks passed
@zlareb1 zlareb1 mentioned this pull request Nov 18, 2026
6 tasks done
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