Skip to content

Add rubric evaluation engine with crJSON and untrusted-cert support#7

Open
erik-sv wants to merge 3 commits into
contentauth:mainfrom
encypherai:upstream/feat/rubric-evaluation
Open

Add rubric evaluation engine with crJSON and untrusted-cert support#7
erik-sv wants to merge 3 commits into
contentauth:mainfrom
encypherai:upstream/feat/rubric-evaluation

Conversation

@erik-sv
Copy link
Copy Markdown

@erik-sv erik-sv commented May 5, 2026

Summary

The conformance tool can extract crJSON from binary assets but has no way to evaluate that crJSON against a rubric. This PR adds a rubric evaluation engine with two modes: conformance (whole-document) and signals (per-manifest), plus support for evaluating pre-existing crJSON files directly.

Three capabilities:

  • Rubric evaluation (--rubric, --rubric-dir, --rubric-mode). Evaluate assets or crJSON against YAML rubric files. Conformance mode checks whole-document traits (spec version, signature, trust). Signals mode iterates per-manifest to detect provenance patterns across ingredient chains.

  • crJSON read path (--crjson). Treat input files as pre-existing crJSON rather than binary assets. This supports preliminary conformance testing for formats not yet supported by c2pa-rs - the submitter extracts crJSON through their own tooling, then evaluates manifest-level conformance without requiring native container support.

  • Untrusted certificate fallback. When --rubric is used with binary assets, the CLI attempts trust verification first, then falls back to reading with verify_trust disabled. Conformance program applicants using self-signed certificates can evaluate all rubric traits except trusted_success without requiring a program-issued certificate. The crJSON validationResults still reflects the untrusted state.

Includes five rubric YAML files (conformance 0.1 and 0.2 for spec 2.2, conformance 0.2 for spec 2.4, integrity, and signals) with golden-file tests covering 14 provenance scenarios.

Also updates json-formula-rs and profile-evaluator-rs submodules. Expression parameter injection ($argN) and bare-keyword normalization (true/false/null to function form) now run in the evaluator layer rather than the formula engine, keeping json-formula-rs upstream-compatible.

Usage

# Evaluate a signed asset against a conformance rubric
c2pa-validate photo.jpg --rubric rubrics/conformance0.2-spec2.2.yml

# Evaluate pre-existing crJSON (for formats c2pa-rs cannot read)
c2pa-validate manifest.json --crjson --rubric rubrics/conformance0.2-spec2.2.yml

# Extract crJSON without evaluation
c2pa-validate photo.jpg --emit-crjson

# Run all rubrics in a directory
c2pa-validate photo.jpg --rubric-dir rubrics/

# Per-manifest signal detection
c2pa-validate photo.jpg --rubric rubrics/signals.yml --rubric-mode signals

Test plan

  • cargo test passes for all new integration tests (crjson_validation, asset_validation, schema_validation)
  • Golden-file tests match expected output for all 14 provenance scenarios in both conformance and signals modes
  • Untrusted fallback produces correct validationResults (trust fails, other traits evaluate)
  • --crjson mode correctly evaluates pre-existing crJSON without attempting binary asset read
  • --emit-crjson extracts crJSON from binary assets without rubric evaluation

erik-sv and others added 3 commits May 5, 2026 20:26
Add full rubric evaluation pipeline for the C2PA asset conformance
program's composable rubric framework.

json-formula-rs:
- Add normalize_expression() for bare true/false/null keyword rewriting
- Add arg_count() helper and $argN parameterized named expression support
  in register_expression() with globals injection and save/restore pattern

profile-evaluator-rs:
- Add evaluate_rubric_conformance() for whole-crJSON conformance evaluation
  with failIfMatched support and true/false trait bucketing
- Add evaluate_rubric_signals() for per-manifest signal detection with
  inception/transformation grouping, ingredient index resolution,
  assertedBy extraction, and mimeType derivation
- Support both report_text (profiles) and reportText (rubrics) field names
- 36 golden fixture tests matching upstream Python reference evaluator
  output (1 documented deviation: startsWith array projection in ii2i)

c2pa-validate CLI:
- Add -rubric, -rubric-dir, -rubric-mode (conformance/signals),
  -emit-crjson, -crjson, -rubric-strict flags
- Remove crJSON evaluation bail that blocked rubric eval on crJSON inputs
- Add rubric_results to CrJsonValidationReport for structured output

Test fixtures:
- 5 rubric YAML files from c2pa-org/conformance PR #324
- 18 golden test scenarios (54 files) from upstream test suite
When --rubric is used with binary assets, the CLI now extracts crJSON
and runs rubric evaluation even when trust verification fails. This
supports the conformance program onboarding workflow where products
use self-signed certificates before receiving program-issued certs.

The pipeline attempts trust verification first, then falls back to
reading with verify_trust disabled. The crJSON validationResults still
reflect the untrusted state, so the trusted_success trait fails as
expected while all other conformance traits can be evaluated.

Also fix structured JSON output for CrJsonValidation report items so
rubric results are properly serialized instead of null.
…andling

Move $argN injection and bare-keyword normalization from json-formula-rs
to profile-evaluator-rs. This keeps json-formula-rs upstream-compatible
while supporting parameterized named expressions in rubric evaluation.

json-formula-rs retains only register_function() and globals_mut() as
additions over upstream. All expression preprocessing now runs in the
evaluator layer at registration time.
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