Skip to content

feat(ci): check benchmark cards against the expected source identity - #340

Merged
rng1995 merged 7 commits into
mainfrom
naren/port-benchmark-source-identity
Nov 5, 2026
Merged

rng1995 merged 7 commits into
mainfrom
naren/port-benchmark-source-identity

Conversation

@rng1995

@rng1995 rng1995 commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • scripts/ci/check_public_benchmarks.py gets three optional options: --expected-source-repository, --expected-source-revision and --expected-evaluator-container-revision. Each one checks one metadata line of every scanned card: Evaluated source, Evaluated source revision or Evaluator container revision.
  • A card fails when that line is missing, is a not recorded placeholder, is not a canonical value, appears more than once in Evaluation Metadata, or names a different value. New offender reasons:
    • <field> does not match the expected value
    • <field> not recorded, but an expected value was given (no line, an empty value or a not recorded placeholder)
    • <field> is not a canonical value, so it cannot match (the line is there but malformed)
    • <field> recorded more than once, so it cannot match
  • The check applies to cards of any verdict. A FAIL or INCOMPLETE card for another commit is as wrong to publish under a request as a PASS card.
  • Only the metadata line counts. A matching value in a code block or an HTML comment elsewhere on the card does not stand in for it.
  • That line must be a plain one-line list item, as BenchmarkReporter renders it. An item with a link or inline HTML, or one that continues onto a second line, is treated as missing: the new check reports it as not recorded, and --require-source-provenance reports a missing metadata field. The parser is not loosened. Only top-level items are read, so a nested item is ignored rather than counted as a duplicate, and a value padded with whitespace inside its code span is not canonical.
  • The expectation and the card value both go through skillevaluator.source_identity.normalized_evaluated_source, so hex case in the source revision does not cause a false mismatch.
  • Repository names and evaluator container revisions are compared exactly. The repository is compared the way merge_evaluated_sources compares it. A container digest or implementation commit must be lower case, as source_identity requires, and a registry host must be written as the card records it.
  • The revision line is the commit when the run supplied one and the content digest otherwise, so --expected-source-revision accepts either shape and matches that line.
  • A non-canonical expected value (short commit, wrong-width digest, URL instead of owner/name, untagged container name) is a usage error (exit 2) instead of a silent pass.
  • Any --expected-* option implies --require-files, so finding no card to check fails.
  • The same check is available from Python: ExpectedSource plus a new expected_source= keyword on scan_file and find_offenders.
  • Without the new options the scan is unchanged, including the CI run over tests/golden.
  • Documents the options in the publication gate step of docs/benchmark-rollout.mdx and adds a CHANGELOG entry under Unreleased > Added.

Why

Since #131, cards record the evaluated source and the evaluator container revision, and --require-source-provenance makes a PASS card name them. The gate still cannot tell whether that identity is the one the publishing pipeline asked for. A stale card, or one generated for a different commit or repository, passes the strict scan as long as it names some valid source. A publishing CI that knows the requested repository, revision and evaluator image can now bind each card to that request before it signs or copies the card.

Kept from public

  • source_identity.py is unchanged and is the only definition of a valid value: strict owner/name repository, full Git object ids, sha256/sha384/sha512 digests at their exact widths, and the container reference grammar.
  • --require-source-provenance stays opt-in and keeps its own checks (PASS needs a recorded source, digest-pinned container). The new options do not imply it; the runbook example uses both.
  • No new validate options, environment variables or dirty-snapshot marker. The identity still comes only from --evaluated-source-repository, --evaluated-source-revision and --evaluator-container-revision.
  • A PASS card without a source is not downgraded to INCOMPLETE. That stays a gate decision.
  • ruff format reformats four existing statements in check_public_benchmarks.py that fail ruff format --check on main: it wraps one and joins three. There are no other unrelated changes.
  • The first commit's message says ruff format wraps four lines and that hex case never causes a false mismatch. This description has the accurate wording: one wrap and three joins, and only the source revision is compared without regard to case.
  • Open PR feat(plugin): Add Plugin evaluation support across all tiers #28 also edits check_public_benchmarks.py (imports and the scan_file body) and docs/benchmark-rollout.mdx. Whichever lands second needs a small rebase.

Tests

  • New TestExpectedSourceBinding and TestExpectedSourceEntryPoints in tests/test_benchmark_source_provenance.py:
    • a matching card passes, with and without --require-source-provenance
    • a different repository, revision (commit or digest) or container revision fails, and so does a repository differing only in case
    • a card with not recorded placeholders, or without the lines, fails each expected field
    • an empty value or a not recorded placeholder is reported as not recorded
    • malformed recorded values (bare text, extra text after the code span, a doubled code span, short commit, untagged container) never match and are reported as not canonical
    • a duplicated line cannot match
    • a matching value in a code block or HTML comment does not count
    • an identity line with a link, inline HTML or a continuation line is reported as not recorded, and the strict provenance scan reports it as missing
    • uppercase hex in the source revision, on either side, still matches
    • container revisions are compared exactly: an uppercase container digest or commit is refused as an expectation, and a card with an uppercase registry host does not match the lowercase one
    • a content digest revision is matched, and a commit expectation against it fails
    • an unset field is not checked
    • an INCOMPLETE card for another commit fails too
    • a card rendered by BenchmarkReporter matches the identity it was given
    • non-canonical expectations raise ValueError, and the expectation is stored in canonical form
    • main() accepts the requested card, rejects another commit or a missing identity, fails an empty tree when an expectation is given, and exits 2 on a malformed flag; find_offenders() passes the expectation through
  • New test_rollout_runbook_documents_the_expected_source_options in tests/test_benchmark_rollout_docs.py pins the flags, the implied --require-files, the rule that only the source revision is compared without regard to case, and the rule that only a plain one-line list item counts.
  • Fail before: with main's gate script and runbook, those two modules give 43 failed, 160 passed. The 43 failures are exactly the 43 new tests, and every existing test passes.
  • On the branch: tests/test_benchmark_source_provenance.py, tests/test_public_benchmark_gate.py, tests/test_benchmark_rollout_docs.py, tests/test_ci_workflows.py, tests/test_oss_packaging.py, tests/test_ci_change_classifier.py, tests/test_publication_identity.py, tests/test_publication_evidence.py, tests/reporting/test_advisory_skip_verdict.py, tests/golden/test_benchmark_card.py, tests/ci/test_image_build.py, tests/tier3/test_private_loose_source.py, tests/test_accuracy_arithmetic.py and tests/test_tier3_public_runtime.py: 1988 passed, 2 skipped.
  • check_public_benchmarks.py --require-files tests/golden --require-source-provenance (the CI invocation) still passes.
  • ruff check and ruff format --check are clean on the changed Python files.
  • scripts/check_oss_boundary.py passed.

🤖 Generated with Claude Code

rng1995 and others added 4 commits November 4, 2026 04:06
Add --expected-source-repository, --expected-source-revision and
--expected-evaluator-container-revision to check_public_benchmarks.py.
A publishing pipeline can then fail a card, of any verdict, whose
Evaluated source, Evaluated source revision or Evaluator container
revision line is missing, not recorded, duplicated or different from
the source it asked to evaluate. Both sides are normalized through
skillevaluator.source_identity, so hex case does not cause a false
mismatch. An expectation implies --require-files, and a non-canonical
expected value is a usage error. The default scan is unchanged.

ruff format also wraps four existing lines in the gate script that
fail ruff format --check on main.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe the --expected-* options of check_public_benchmarks.py in the
publication gate step of the rollout runbook, add an Unreleased > Added
CHANGELOG entry, and pin the documented flags in the runbook test.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a card has the Evaluated source, Evaluated source revision or
Evaluator container revision line but its value is not canonical (bare
text, a doubled code span, text after the span, a short commit or an
untagged container), the expected-source check now reports
"<field> is not a canonical value, so it cannot match". The
"not recorded" reason is kept for a missing line, an empty value and a
"not recorded" placeholder, so an operator is pointed at the right
problem. The card still fails in every case.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The runbook said hex digits are compared without regard to case, but
only the Evaluated source revision is folded. An expected container
digest or implementation commit in upper case is a usage error, and a
registry host is compared as written. Say so, pin the wording in the
runbook test, and add a test for the exact container comparison.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: 3 findings (0 P1, 0 P2, 3 P3); 2 posted inline.

Findings outside the diff or about the description:

  • scripts/ci/check_public_benchmarks.py: P3: The message of commit 5c241de says ruff format 'wraps four existing lines'. The diff has one wrap (the _HTMLAttributeParser events.append) and three joins (the Environment skeleton concatenation, the semantic_document 'or', and _contains_disallowed_category_c). The PR text correctly says 'reformats four existing statements'. The author already reported this.

Suggested fix: No amend is allowed. Leave it, or record the correct wording in the PR description, which already has it.

Comment thread docs/benchmark-rollout.mdx Resolved
Comment thread scripts/ci/check_public_benchmarks.py Resolved
The gate reads metadata only from plain one-line list items. An item
with a link or inline HTML, or one that continues onto a second line,
is left out, so the expected-source check reports that field as not
recorded rather than as not canonical. The strict provenance scan
treats it as missing too, so the two checks agree and the card still
fails.

Say so in the runbook and in the check's docstring, pin the wording in
the runbook test, and add a test for the link, inline HTML and
continuation-line cases. The parser is unchanged.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 marked this pull request as ready for review November 5, 2026 17:50
rng1995 and others added 2 commits November 5, 2026 10:05
A code-span value with leading or trailing whitespace, including a
no-break space or a tab, matched the expected source after stripping.
The reporter never renders one, and a parser reading the raw value would
not see the canonical identity, so it is now reported as not canonical.

The runbook and the check's docstring also say that only top-level
Evaluation Metadata items are read, so a nested item is ignored rather
than counted as a duplicate.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: CHANGELOG.md (kept main's new Added entries, then this PR's).

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 merged commit 52c78cb into main Nov 5, 2026
19 checks passed
@rng1995
rng1995 deleted the naren/port-benchmark-source-identity branch November 5, 2026 21:38
@rng1995 rng1995 mentioned this pull request Nov 6, 2026
7 of 8 tasks
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