Skip to content

Contract Healthを索引化しResultを軽量化する - #25

Merged
piaro merged 1 commit into
mainfrom
perf/index-contract-health-and-compact-results
Aug 28, 2026
Merged

piaro merged 1 commit into
mainfrom
perf/index-contract-health-and-compact-results

Conversation

@piaro

@piaro piaro commented Aug 28, 2026 •

Copy link
Copy Markdown
Owner

Outcome

  • Contract Health no longer repeatedly scans all Evidence and Results for every clause.
  • New Results store shared input and freshness references once instead of duplicating them across outcomes.
  • Existing Results remain readable and are not rewritten.

Why this change was needed

Contract Health previously searched the complete Evidence and Result history for each Contract clause. It also validated and hashed records that could not affect Contract Health. In addition, Results duplicated the same reference maps across outcomes, causing files to grow with both the number of outcomes and the number of inputs.

Main changes

  • Index Evidence by Contract clause.
  • Index verification outcomes by referenced Evidence.
  • Validate only records that can affect Contract Health.
  • Hash only records and repository artifacts referenced by verification freshness manifests.
  • Omit outcome-level input and freshness references when they match the Result-level values.
  • Fall back to Result-level references during freshness and Evidence validation.
  • Add regression tests for compatibility, validation scope, indexing behavior, and Result size reduction.
  • Document the storage and compatibility behavior.

Verification

  • A regression test covering 70 outcomes and 512 shared references verifies that the compact Result is more than 20 times smaller than the expanded representation.
  • cargo fmt --check
  • cargo clippy --all-targets --locked -- -D warnings
  • cargo test --locked
  • sh scripts/tests/test-rust.sh

Compatibility

The outcome-level reference fields were already optional, so this change does not require a Schema version update. Existing Results are not migrated because rewriting them would change their Result IDs and could invalidate downstream freshness references.

@piaro
piaro merged commit 59dafa3 into main Aug 28, 2026
3 checks passed
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