Skip to content

Commit c07e15a

Browse files
frawarecursoragent
andcommitted
PCS benchmark suite aligned with pcs-core, reproducibility benchmark, and smoke packet.
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 186c65b commit c07e15a

250 files changed

Lines changed: 5581 additions & 1425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pcs.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,33 @@ jobs:
8383
run: python examples/pcs_qc_release/scripts/ci_validate_formalization.py
8484
- name: Generate and validate benchmark cases
8585
run: |
86+
labtrust generate-benchmark-cases \
87+
--workflow hospital_lab.qc_release \
88+
--out /tmp/labtrust-bench \
89+
--release-dir examples/pcs_qc_release/release \
90+
--seed 42
91+
labtrust verify-benchmark-cases --benchmark-dir /tmp/labtrust-bench
8692
labtrust generate-benchmark-cases \
8793
--workflow hospital_lab.qc_release \
8894
--out examples/pcs_qc_release/benchmark \
8995
--release-dir examples/pcs_qc_release/release \
9096
--seed 42
9197
python examples/pcs_qc_release/scripts/ci_validate_benchmark_cases.py
92-
- name: Reproducibility benchmark (hash stability)
98+
python examples/pcs_qc_release/scripts/ci_validate_benchmark_pcs_core.py
99+
- name: pcs-bench validate fixtures (when pcs-core checkout present)
100+
continue-on-error: true
93101
run: |
94-
labtrust benchmark-reproducibility \
95-
--pcs-core pcs-core/examples/labtrust-release \
96-
--release-dir examples/pcs_qc_release/release \
97-
--runs 3 \
98-
--seed 42 \
99-
--out /tmp/labtrust_repro_benchmark
102+
if command -v pcs >/dev/null 2>&1; then
103+
pcs benchmark validate
104+
elif [ -d pcs-core/python ]; then
105+
python -m pcs_core.cli benchmark validate
106+
else
107+
echo "skip pcs-bench validate (no pcs-core CLI)"
108+
fi
109+
- name: Reproducibility benchmark
110+
run: python examples/pcs_qc_release/scripts/ci_benchmark_reproducibility.py
111+
- name: Benchmark packet fixtures
112+
run: python examples/pcs_qc_release/scripts/generate_benchmark_packet.py
100113
- name: Verify LabTrust release protocol package
101114
run: |
102115
labtrust verify-release-protocol \

docs/contracts/cli_contract.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ This document defines the contract for all LabTrust-Gym CLI commands: exit codes
7272
| regenerate-release-protocol | `--out <release-dir>`; `--certifyedge-bin`; optional `--pcs-core`; `--workflow-profile`; `--json-summary`; `--summary-out` | 0 | Full protocol package; writes `<out>/regeneration_report.json`, `proof_obligation_hints.json`, `proof_obligation_identifiers.json`, `formalization_readiness_report.json` (pcs-bench; Lean extraction inputs only) | examples/pcs_qc_release/RUNBOOK.md, schemas_or_docs/FormalizationReadinessReport.v0.md |
7373
| regenerate-release-chain | alias for `regenerate-release-protocol` | 0 | same as above | examples/pcs_qc_release/RUNBOOK.md |
7474
| generate-failure-gallery | `--workflow <id\|property_id>`; `--out <dir>`; optional `--release-dir`; `--workflow-profile` | 0 | Per-case `failure_case_manifest.json`, `README.md`, `artifacts/`, legacy `expected_failure.json` / `repair_hint.json` | examples/pcs_qc_release/failures/ |
75-
| generate-benchmark-cases | `--workflow <id\|property_id>`; `--out <dir>`; `--seed` (default 42); optional `--release-dir`; `--workflow-profile` | 0 | `benchmark_case.v0.json`, `input_artifacts/`, `expected_failure.json`, `expected_repair_hint.json`, `benchmark_index.json`, `coverage_report.v0.json` | docs/labtrust-benchmark-profile.md |
76-
| benchmark-reproducibility | `--out <dir>`; `--runs` (default 5); `--seed`; `--mode hash_stability\|full_regeneration`; optional `--pcs-core`, `--release-dir`, `--certifyedge-bin` | 0 | `benchmark_run.v0.json`, `coverage_report.v0.json` | docs/labtrust-benchmark-profile.md |
77-
| verify-benchmark-cases | `--benchmark-dir <dir>`; `--json` | 0 | (stderr OK labels) | docs/labtrust-benchmark-profile.md |
75+
| generate-benchmark-cases | `--workflow <id\|property_id>`; `--out <dir>`; `--seed` (default 42); optional `--release-dir`; `--workflow-profile` | 0 | `benchmark_case.v0.json`, `labtrust_benchmark_extension.v0.json`, `input_artifacts/`, `expected_failure.json`, `expected_repair_hint.json`, `benchmark_index.json`, `coverage_report.v0.json` | docs/labtrust-benchmark-profile.md |
76+
| benchmark-reproducibility | `--out <dir>`; `--runs` (default 5); `--seed`; `--mode full_regeneration` (default) or `hash_stability`; optional `--pcs-core`, `--release-dir`, `--certifyedge-bin` | 0 | `benchmark_run.v0.json`, `coverage_report.v0.json`, `regeneration_report.json` | docs/labtrust-benchmark-profile.md |
77+
| verify-benchmark-cases | `--benchmark-dir <dir>`; optional `--pcs-core` (auto-detect); `--json` | 0 | (stderr OK labels) | docs/labtrust-benchmark-profile.md |
7878

7979
**PCS CI scripts (not `labtrust` subcommands):** `run_pcs_ci_local.{sh,ps1}` runs `pytest tests/pcs`, `ci_validate_workflow_profile.py`, `ci_validate_formalization.py`, export/release validation, `check-status-policy`, failure gallery generate/verify, and optional `verify-release-protocol` (matches `.github/workflows/pcs.yml`). `materialize_workflow_profile.py` refreshes `workflow_profile.v0.json` digest. `materialize_formalization_artifacts.py` rebuilds formalization JSON from an existing `release/` tree. `generate_golden.py` regenerates `expected/` in deterministic mode.
8080

docs/labtrust-benchmark-profile.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,21 @@ deployment safety.
2323

2424
| Artifact | Role |
2525
|----------|------|
26-
| `benchmark_case.v0.json` | pcs-bench case descriptor (failure localization) |
27-
| `input_artifacts/` | Release-shaped inputs for the case |
26+
| `benchmark_case.v0.json` | pcs-core `BenchmarkCase.v0` (status, failure code, provenance, digest) |
27+
| `labtrust_benchmark_extension.v0.json` | LabTrust-only: detection layer, protocol failure code |
28+
| `input_artifacts/` | Release-shaped inputs (`input_artifacts.release_directory`) |
2829
| `expected_failure.json` | Protocol-level failing check and code |
29-
| `expected_repair_hint.json` | `hint_kind`, operator hint, `repair_command` |
30+
| `expected_repair_hint.json` | `responsible_component`, `repair_hint.kind`, `repair_command` |
3031
| `benchmark_index.json` | Suite index |
3132
| `coverage_report.v0.json` | Taxonomy coverage (case kinds, detection layers) |
32-
| `benchmark_run.v0.json` | Reproducibility aggregate (per-run hashes, duration) |
33+
| `benchmark_run.v0.json` | Reproducibility summary (pcs-bench compatible) |
34+
| `regeneration_report.json` | Full reproducibility report (`ReproducibilityBenchmarkReport.v0`) |
3335

3436
Schemas: `policy/schemas/pcs/BenchmarkCase.v0.schema.json`, `BenchmarkRun.v0.schema.json`,
35-
`CoverageReport.v0.schema.json`.
37+
`CoverageReport.v0.schema.json`, `ReproducibilityBenchmarkReport.v0.schema.json`.
38+
39+
Minimal smoke packet: `examples/pcs_qc_release/benchmark_packet/` (`valid_release`,
40+
`invalid_trace_hash_tamper`, `reproduce.sh`, `expected_report.json`).
3641

3742
## Failure case taxonomy
3843

@@ -86,11 +91,13 @@ labtrust benchmark-reproducibility \
8691
--seed 42
8792
```
8893

89-
Default mode `hash_stability` copies the committed `release/` tree and verifies identical
90-
hashes and validation across runs (CI-safe). `full_regeneration` is reserved for local benches
91-
with CertifyEdge.
94+
Default mode `full_regeneration` re-runs `regenerate-release-protocol` each iteration and
95+
records artifact/canonical hash stability, CertifyEdge success, release protocol validation,
96+
status policy, and pcs-core validation. CI falls back to `hash_stability` when CertifyEdge is
97+
unavailable (`examples/pcs_qc_release/scripts/ci_benchmark_reproducibility.py`).
9298

9399
## pcs-bench integration
94100

95-
Load `benchmark_index.json`, iterate `cases`, and for each case read `benchmark_case.v0.json`
96-
plus `input_artifacts/` — no LabTrust-specific adapters required beyond the published schemas.
101+
Suite id `labtrust-qc-release-v0`. Load `benchmark_index.json`, iterate `cases`, and for each
102+
case read `benchmark_case.v0.json` plus `input_artifacts/`. Use `labtrust_benchmark_extension.v0.json`
103+
for detection-layer assertions in simulate mode.

examples/pcs_qc_release/RUNBOOK.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,19 +306,29 @@ labtrust generate-failure-gallery \
306306
--workflow hospital_lab.qc_release \
307307
--out examples/pcs_qc_release/failures
308308

309-
# pcs-bench suite (BenchmarkCase.v0 — failure localization + repair hints):
309+
# Align release/ artifact bytes with pcs-core RC (when canonical tree drifts):
310+
python examples/pcs_qc_release/scripts/sync_release_from_pcs_core.py
311+
python examples/pcs_qc_release/scripts/materialize_downstream_release_artifacts.py
312+
313+
# pcs-bench suite (BenchmarkCase.v0 — pcs-core aligned + LabTrust extensions):
310314
labtrust generate-benchmark-cases \
311315
--workflow hospital_lab.qc_release \
312316
--out examples/pcs_qc_release/benchmark \
313317
--seed 42
314-
labtrust verify-benchmark-cases --benchmark-dir examples/pcs_qc_release/benchmark
318+
labtrust verify-benchmark-cases --benchmark-dir examples/pcs_qc_release/benchmark --pcs-core ../pcs-core
315319
python examples/pcs_qc_release/scripts/ci_validate_benchmark_cases.py
320+
python examples/pcs_qc_release/scripts/ci_validate_benchmark_pcs_core.py
321+
322+
# Minimal two-case packet for pcs-bench smoke (no full gallery):
323+
python examples/pcs_qc_release/scripts/generate_benchmark_packet.py
316324

317325
labtrust benchmark-reproducibility \
318326
--pcs-core ../pcs-core \
319327
--runs 5 \
328+
--mode full_regeneration \
320329
--out benchmark_runs/labtrust_reproducibility \
321330
--seed 42
331+
python examples/pcs_qc_release/scripts/ci_benchmark_reproducibility.py
322332

323333
labtrust check-status-policy \
324334
--release-dir examples/pcs_qc_release/release

examples/pcs_qc_release/benchmark/benchmark_index.json

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
{
2929
"benchmark_case_id": "labtrust-missing-qc-result-v0",
3030
"case_id": "missing_qc_result",
31-
"case_kind": "missing_qc_step",
31+
"case_kind": "invalid_render",
3232
"directory": "missing_qc_result",
33-
"expected_detection_layer": "LabTrust",
3433
"input_artifacts": [
3534
"run_meta.json",
3635
"trace.json",
@@ -40,9 +39,8 @@
4039
{
4140
"benchmark_case_id": "labtrust-unauthorized-release-v0",
4241
"case_id": "unauthorized_release",
43-
"case_kind": "unauthorized_actor",
42+
"case_kind": "invalid_render",
4443
"directory": "unauthorized_release",
45-
"expected_detection_layer": "LabTrust",
4644
"input_artifacts": [
4745
"run_meta.json",
4846
"trace.json",
@@ -54,7 +52,6 @@
5452
"case_id": "trace_hash_tamper",
5553
"case_kind": "invalid_hash_mismatch",
5654
"directory": "trace_hash_tamper",
57-
"expected_detection_layer": "LabTrust",
5855
"input_artifacts": [
5956
"trace.json",
6057
"runtime_receipt.json",
@@ -72,9 +69,8 @@
7269
{
7370
"benchmark_case_id": "labtrust-certificate-id-tamper-v0",
7471
"case_id": "certificate_id_tamper",
75-
"case_kind": "certificate_tamper",
72+
"case_kind": "invalid_certificate",
7673
"directory": "certificate_id_tamper",
77-
"expected_detection_layer": "CertifyEdge",
7874
"input_artifacts": [
7975
"trace.json",
8076
"runtime_receipt.json",
@@ -92,9 +88,8 @@
9288
{
9389
"benchmark_case_id": "labtrust-stale-trace-after-certificate-v0",
9490
"case_id": "stale_trace_after_certificate",
95-
"case_kind": "status_transition",
91+
"case_kind": "stale_release",
9692
"directory": "stale_trace_after_certificate",
97-
"expected_detection_layer": "LabTrust",
9893
"input_artifacts": [
9994
"trace.json",
10095
"runtime_receipt.json",
@@ -112,9 +107,8 @@
112107
{
113108
"benchmark_case_id": "labtrust-legacy-handoff-file-v0",
114109
"case_id": "legacy_handoff_file",
115-
"case_kind": "handoff_tamper",
110+
"case_kind": "invalid_handoff",
116111
"directory": "legacy_handoff_file",
117-
"expected_detection_layer": "LabTrust",
118112
"input_artifacts": [
119113
"trace.json",
120114
"runtime_receipt.json",
@@ -133,9 +127,8 @@
133127
{
134128
"benchmark_case_id": "labtrust-placeholder-commit-v0",
135129
"case_id": "placeholder_commit",
136-
"case_kind": "provenance_invalid",
130+
"case_kind": "invalid_registry",
137131
"directory": "placeholder_commit",
138-
"expected_detection_layer": "LabTrust",
139132
"input_artifacts": [
140133
"trace.json",
141134
"runtime_receipt.json",
@@ -153,9 +146,8 @@
153146
{
154147
"benchmark_case_id": "labtrust-lean-trace-hash-mismatch-v0",
155148
"case_id": "lean_trace_hash_mismatch",
156-
"case_kind": "formal_check_failure",
149+
"case_kind": "invalid_formal_check",
157150
"directory": "lean_trace_hash_mismatch",
158-
"expected_detection_layer": "Lean trust kernel",
159151
"input_artifacts": [
160152
"trace.json",
161153
"runtime_receipt.json",
@@ -173,9 +165,8 @@
173165
{
174166
"benchmark_case_id": "labtrust-lean-rejected-certificate-v0",
175167
"case_id": "lean_rejected_certificate",
176-
"case_kind": "formal_check_failure",
168+
"case_kind": "invalid_formal_check",
177169
"directory": "lean_rejected_certificate",
178-
"expected_detection_layer": "Lean trust kernel",
179170
"input_artifacts": [
180171
"trace.json",
181172
"runtime_receipt.json",
@@ -193,9 +184,8 @@
193184
{
194185
"benchmark_case_id": "labtrust-lean-stale-certificate-v0",
195186
"case_id": "lean_stale_certificate",
196-
"case_kind": "formal_check_failure",
187+
"case_kind": "invalid_formal_check",
197188
"directory": "lean_stale_certificate",
198-
"expected_detection_layer": "Lean trust kernel",
199189
"input_artifacts": [
200190
"trace.json",
201191
"runtime_receipt.json",
@@ -213,9 +203,8 @@
213203
{
214204
"benchmark_case_id": "labtrust-lean-signed-hash-mismatch-v0",
215205
"case_id": "lean_signed_hash_mismatch",
216-
"case_kind": "formal_check_failure",
206+
"case_kind": "invalid_formal_check",
217207
"directory": "lean_signed_hash_mismatch",
218-
"expected_detection_layer": "Provability Fabric",
219208
"input_artifacts": [
220209
"trace.json",
221210
"runtime_receipt.json",
@@ -235,9 +224,8 @@
235224
{
236225
"benchmark_case_id": "labtrust-scientific-memory-import-failure-v0",
237226
"case_id": "scientific_memory_import_failure",
238-
"case_kind": "scientific_memory_import_failure",
227+
"case_kind": "invalid_import",
239228
"directory": "scientific_memory_import_failure",
240-
"expected_detection_layer": "Scientific Memory",
241229
"input_artifacts": [
242230
"trace.json",
243231
"runtime_receipt.json",
@@ -258,6 +246,7 @@
258246
"out_dir": "benchmark",
259247
"pcs_bench": {
260248
"case_descriptor": "benchmark_case.v0.json",
249+
"case_extension": "labtrust_benchmark_extension.v0.json",
261250
"coverage_report": "coverage_report.v0.json",
262251
"expected_failure": "expected_failure.json",
263252
"expected_repair_hint": "expected_repair_hint.json",
@@ -269,7 +258,7 @@
269258
"schema_version": "v0",
270259
"seed": 42,
271260
"status": "passed",
272-
"task_id": "labtrust-qc-release-failure-localization-v0",
261+
"task_id": "labtrust-qc-release-v0",
273262
"workflow_id": "hospital_lab.qc_release",
274263
"workflow_profile": "examples/pcs_qc_release/workflow_profile.v0.json"
275264
}

examples/pcs_qc_release/benchmark/certificate_id_tamper/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Certificate id propagation fails after trace_certificate tampering.
44

55
- Benchmark case: `labtrust-certificate-id-tamper-v0`
66
- Detection layer: `CertifyEdge`
7-
- Case kind: `certificate_tamper`
7+
- Case kind: `invalid_certificate`
Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,74 @@
11
{
22
"case_id": "labtrust-certificate-id-tamper-v0",
3-
"case_kind": "certificate_tamper",
4-
"expected_detection_layer": "CertifyEdge",
5-
"expected_failing_check": "certificate_id_propagation",
3+
"case_kind": "invalid_certificate",
64
"expected_failure_code": "certificate_id_mismatch",
7-
"expected_protocol_failure_code": "CERTIFICATE_ID_MISMATCH",
8-
"expected_repair_command": "certifyedge emit-pcs-certificate ... && labtrust attach-certificate --bundle science_claim_bundle.pending.json --certificate trace_certificate.json",
9-
"expected_repair_hint_kind": "re_emit_certificate",
10-
"expected_responsible_component": "certifyedge.certificate",
11-
"expected_status": "Rejected",
12-
"gallery_case_id": "certificate_id_tamper",
13-
"profile_workflow_id": "labtrust.qc_release_v0.1",
5+
"expected_repair_hint_kind": "align_certificate_id",
6+
"expected_responsible_component": "certificate_producer",
7+
"expected_status": "failed",
8+
"input_artifacts": {
9+
"artifacts": [
10+
{
11+
"artifact_type": "HandoffManifest.v0",
12+
"path": "handoff_to_certifyedge.json",
13+
"role": "handoff_to_certifyedge_json"
14+
},
15+
{
16+
"artifact_type": "HandoffManifest.v0",
17+
"path": "handoff_to_pf.json",
18+
"role": "handoff_to_pf_json"
19+
},
20+
{
21+
"artifact_type": "ComponentReleaseFragment.v0",
22+
"path": "labtrust_release_fragment.json",
23+
"role": "labtrust_release_fragment_json"
24+
},
25+
{
26+
"artifact_type": "ReleaseManifest.v0",
27+
"path": "manifest.json",
28+
"role": "manifest_json"
29+
},
30+
{
31+
"artifact_type": "RuntimeReceipt.v0",
32+
"path": "runtime_receipt.json",
33+
"role": "runtime_receipt_json"
34+
},
35+
{
36+
"artifact_type": "ScienceClaimBundle.v0",
37+
"path": "science_claim_bundle.certified.json",
38+
"role": "science_claim_bundle_certified_json"
39+
},
40+
{
41+
"artifact_type": "ScienceClaimBundle.v0",
42+
"path": "science_claim_bundle.pending.json",
43+
"role": "science_claim_bundle_pending_json"
44+
},
45+
{
46+
"artifact_type": "LabTrustTrace.v0",
47+
"path": "trace.json",
48+
"role": "trace_json"
49+
},
50+
{
51+
"artifact_type": "TraceCertificate.v0",
52+
"path": "trace_certificate.json",
53+
"role": "trace_certificate_json"
54+
},
55+
{
56+
"artifact_type": "TraceHashAlignment.v0",
57+
"path": "trace_hash_alignment.json",
58+
"role": "trace_hash_alignment_json"
59+
},
60+
{
61+
"artifact_type": "WorkflowProfile.v0",
62+
"path": "workflow_profile.v0.json",
63+
"role": "workflow_profile_v0_json"
64+
}
65+
],
66+
"release_directory": "input_artifacts"
67+
},
1468
"schema_version": "v0",
15-
"task_id": "labtrust-qc-release-failure-localization-v0",
69+
"signature_or_digest": "sha256:5e3d37f28e5bbb97edf48e38ec746afdec64476f98a0f15b905a5758ef3e6e5d",
70+
"source_commit": "186c65b252bfaade6ee321b0a74c15980852cdd2",
71+
"source_repo": "https://github.com/fraware/LabTrust-Gym",
72+
"task_id": "labtrust-qc-release-v0",
1673
"workflow_id": "hospital_lab.qc_release"
1774
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"case_id": "certificate_id_tamper",
33
"expected_failing_check": "certificate_id_propagation",
4-
"expected_failure_code": "CERTIFICATE_ID_MISMATCH"
4+
"expected_failure_code": "certificate_id_mismatch",
5+
"expected_protocol_failure_code": "CERTIFICATE_ID_MISMATCH"
56
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
2-
"hint": "Re-run CertifyEdge emit-pcs-certificate and attach-certificate without editing certificate_id.",
3-
"hint_kind": "re_emit_certificate",
4-
"repair_command": "certifyedge emit-pcs-certificate ... && labtrust attach-certificate --bundle science_claim_bundle.pending.json --certificate trace_certificate.json"
2+
"expected_detection_layer": "CertifyEdge",
3+
"failure_code": "certificate_id_mismatch",
4+
"repair_hint": {
5+
"command": "certifyedge emit-pcs-certificate ... && labtrust attach-certificate --bundle science_claim_bundle.pending.json --certificate trace_certificate.json",
6+
"description": "Re-run CertifyEdge emit-pcs-certificate and attach-certificate without editing certificate_id.",
7+
"kind": "align_certificate_id"
8+
},
9+
"responsible_component": "certificate_producer"
510
}

0 commit comments

Comments
 (0)