This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build
cargo build
cargo build --release
# Run
cargo run --bin c2pa-validate -- [OPTIONS] INPUT...
# Test (all)
cargo test -p c2pa-validate
# Test (single test, serial to avoid network races)
cargo test -p c2pa-validate -- test_name --test-threads=1
# Run a specific test file
cargo test -p c2pa-validate --test output_formatsSingle Rust workspace with one application crate (crates/c2pa-validate) and three vendored git submodules:
vendor/c2pa-rs— C2PA SDK (asset reading, manifest extraction)vendor/profile-evaluator-rs— Evaluates YAML profiles against asset indicatorsvendor/json-formula-rs— JSON formula evaluation (used by profile evaluator)
cli.rs— Clap derive-based CLI:OutputFormat(Json/Yaml/Markdown/Html),TrustMode(Default/Itl/Custom)validator.rs— Core validation engine: input type detection, trust scenario orchestration, profile evaluationreport.rs— Report data structures (CrJsonReport,AssetReport, etc.) and rendering (Markdown/HTML)lib.rs— Orchestration: callsValidator, routes output (file vs. stdout, per-file vs. aggregate), renders final reportmain.rs— Thin entry point callingc2pa_validate::run()
- Input classification: file extension + JSON
schemafield → Asset, SidecarManifest (.c2pa), or CrJson - Trust scenarios: build ordered list based on
--trust-mode; try each in order, return first Trusted result or last Validdefault: fetch official C2PA trust list from GitHubitl: try official, then ITLcustom: use user-supplied PEM file/URL
- crJSON generation:
Reader::to_crjson_value()from c2pa-rs SDK - Profile evaluation:
profile_evaluator_rs::evaluate(profile, indicators)against crJSON indicators - Report aggregation: all results →
CrJsonReportwith summary counters; exit code fromsummary.errors + summary.invalid
- Single asset + structured format → write to
-o FILE - Multiple assets + structured format → write per-file to
-o DIR(collision:_2,_3suffixes) - Profile evaluation → writes both crJSON file and
_reportfile - Markdown/HTML → single comprehensive report file
Tests use run_with_cli(cli) for programmatic invocation. Fixtures in testfiles/:
assets/— JPEG, PNG, MP4, PDF samplesmanifests/—.c2pasidecar filescrjson/— valid/invalid crJSON fixturesprofiles/— YAML asset profiles
Known coverage gaps: offline trust modes, custom trust PEM, strict mode, settings overlay.
- No
unwrap()/expect()on fallible values in production paths - Use
?for error propagation withanyhowcontext - No
unsafeblocks without justification - Logs → stderr via
tracing; machine-readable output → stdout only - Exit codes: 0 for success, non-zero for failure
- Validate all external input (files, env, network) at boundaries