@piagent/platform 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +17 -14
  3. package/README.vi.md +26 -1
  4. package/benchmarks/production-v1/spend-control.v1.json +27 -3
  5. package/benchmarks/production-v1/suite.json +5 -1
  6. package/catalog/capabilities.json +16 -16
  7. package/docs/authority-manifest.md +1 -1
  8. package/docs/auto-delegation-policy.md +38 -73
  9. package/docs/command-reference-vietnamese.md +23 -31
  10. package/docs/context-engine.md +5 -3
  11. package/docs/context-window-policy.md +37 -1
  12. package/docs/distribution-standard.md +7 -7
  13. package/docs/en/architecture.md +26 -13
  14. package/docs/languages.json +4 -4
  15. package/docs/operator-manual-vietnamese.md +21 -41
  16. package/docs/publishing-for-teams.md +5 -0
  17. package/docs/quality-benchmark.md +179 -23
  18. package/docs/release-install-policy.md +6 -6
  19. package/docs/runtime-harness-standard.md +3 -3
  20. package/docs/security-threat-model.md +1 -1
  21. package/docs/subagent-orchestration-capabilities.md +19 -51
  22. package/docs/subagents-and-multiagent.md +21 -47
  23. package/docs/task-implementation-contract.md +3 -3
  24. package/docs/task-lifecycle-vietnamese.md +1 -1
  25. package/docs/team-onboarding.md +2 -2
  26. package/docs/vi/architecture.md +26 -13
  27. package/docs-site/architecture.html +1 -1
  28. package/docs-site/benchmark.html +89 -95
  29. package/docs-site/commands.html +1 -1
  30. package/docs-site/content/benchmark.html +88 -94
  31. package/docs-site/content/en/benchmark.html +134 -90
  32. package/docs-site/content/en/index.html +19 -19
  33. package/docs-site/content/en/runtime.html +4 -4
  34. package/docs-site/content/en/whats-new.html +12 -1
  35. package/docs-site/content/en/workflows.html +2 -2
  36. package/docs-site/content/index.html +19 -19
  37. package/docs-site/content/runtime.html +4 -4
  38. package/docs-site/content/whats-new.html +12 -1
  39. package/docs-site/content/workflows.html +2 -2
  40. package/docs-site/context-engine.html +1 -1
  41. package/docs-site/en/architecture.html +1 -1
  42. package/docs-site/en/benchmark.html +135 -91
  43. package/docs-site/en/commands.html +1 -1
  44. package/docs-site/en/context-engine.html +1 -1
  45. package/docs-site/en/index.html +20 -20
  46. package/docs-site/en/mcp-approval.html +1 -1
  47. package/docs-site/en/mcp-auth.html +1 -1
  48. package/docs-site/en/mcp-servers.html +1 -1
  49. package/docs-site/en/mcp.html +1 -1
  50. package/docs-site/en/permissions.html +1 -1
  51. package/docs-site/en/profiles.html +1 -1
  52. package/docs-site/en/quickstart.html +1 -1
  53. package/docs-site/en/runtime.html +5 -5
  54. package/docs-site/en/scope.html +1 -1
  55. package/docs-site/en/security.html +1 -1
  56. package/docs-site/en/team.html +1 -1
  57. package/docs-site/en/whats-new.html +13 -2
  58. package/docs-site/en/workflows.html +3 -3
  59. package/docs-site/index.html +20 -20
  60. package/docs-site/mcp-approval.html +1 -1
  61. package/docs-site/mcp-auth.html +1 -1
  62. package/docs-site/mcp-servers.html +1 -1
  63. package/docs-site/mcp.html +1 -1
  64. package/docs-site/permissions.html +1 -1
  65. package/docs-site/profiles.html +1 -1
  66. package/docs-site/quickstart.html +1 -1
  67. package/docs-site/runtime.html +5 -5
  68. package/docs-site/scope.html +1 -1
  69. package/docs-site/security.html +1 -1
  70. package/docs-site/team.html +1 -1
  71. package/docs-site/whats-new.html +13 -2
  72. package/docs-site/workflows.html +3 -3
  73. package/evals/fixtures/benchmark-assurance-evidence.invalid.json +1 -1
  74. package/evals/fixtures/benchmark-assurance-evidence.valid.json +1 -1
  75. package/evals/fixtures/codex-relative-efficiency-v1.invalid.json +4 -0
  76. package/evals/fixtures/codex-relative-efficiency-v1.valid.json +94 -0
  77. package/evals/fixtures/helper-request.invalid.json +1 -1
  78. package/evals/fixtures/helper-request.valid.json +1 -1
  79. package/evals/fixtures/piagent-webui/subagent-tree-v1.valid.json +7 -0
  80. package/evals/fixtures/task-authority-snapshot.valid.json +4 -4
  81. package/evals/fs4-readiness-matrix.v1.json +2 -2
  82. package/evals/fs5-causal-arm.v1.json +2 -2
  83. package/evals/fs5-pilot-protocol.v1.json +3 -3
  84. package/evals/fs5-pilot-protocol.v2.json +8 -8
  85. package/evals/fs5-pilot-protocol.v3.json +8 -8
  86. package/evals/fs5-pilot-protocol.v4.json +6 -6
  87. package/evals/fs5-pilot-protocol.v5.json +7 -6
  88. package/evals/private-holdout-v1/public-exposure.v1.json +1 -1
  89. package/evals/runtime-conformance-v1/README.md +43 -0
  90. package/evals/runtime-conformance-v1/evaluate-paid-canary.mjs +198 -0
  91. package/evals/runtime-conformance-v1/lane.json +57 -0
  92. package/evals/runtime-conformance-v1/paid-canary.json +31 -0
  93. package/evals/runtime-conformance-v1/runner.mjs +456 -0
  94. package/package.json +1 -1
  95. package/packages/piagent-core/README.md +13 -4
  96. package/packages/piagent-core/benchmark/benchmark-codex-relative-efficiency.js +698 -0
  97. package/packages/piagent-core/benchmark/benchmark-core.js +4 -3
  98. package/packages/piagent-core/benchmark/benchmark-forensics.js +4 -2
  99. package/packages/piagent-core/benchmark/benchmark-preflight.js +3 -1
  100. package/packages/piagent-core/benchmark/benchmark-provider-free-evidence.js +345 -0
  101. package/packages/piagent-core/benchmark/benchmark-record-validation.js +74 -5
  102. package/packages/piagent-core/benchmark/benchmark-report.js +15 -1
  103. package/packages/piagent-core/benchmark/benchmark-runtime-causal.js +244 -0
  104. package/packages/piagent-core/benchmark/benchmark-stage-diagnostic.js +201 -4
  105. package/packages/piagent-core/benchmark/benchmark-suite.js +22 -1
  106. package/packages/piagent-core/benchmark/benchmark-summary-support.js +4 -0
  107. package/packages/piagent-core/benchmark/benchmark-usage.js +15 -4
  108. package/packages/piagent-core/capabilities/runtime-integrity.js +3 -0
  109. package/packages/piagent-core/extensions/acceptance-behavior-proof.js +806 -0
  110. package/packages/piagent-core/extensions/acceptance-receipt.js +89 -48
  111. package/packages/piagent-core/extensions/context-engine.js +1 -11
  112. package/packages/piagent-core/extensions/context-index-policy.js +4 -0
  113. package/packages/piagent-core/extensions/context-query-paths.js +57 -0
  114. package/packages/piagent-core/extensions/criterion-context-pack.js +16 -3
  115. package/packages/piagent-core/extensions/criterion-graph.js +4 -1
  116. package/packages/piagent-core/extensions/fallback-base-policy.ts +101 -0
  117. package/packages/piagent-core/extensions/guard-types.ts +4 -0
  118. package/packages/piagent-core/extensions/piagent-guard.ts +194 -226
  119. package/packages/piagent-core/extensions/task-lifecycle.js +32 -0
  120. package/packages/piagent-core/extensions/task-state.js +69 -8
  121. package/packages/piagent-core/extensions/verification-intelligence.js +49 -12
  122. package/packages/piagent-core/extensions/workspace-evidence-roots.js +52 -16
  123. package/packages/piagent-core/package.json +1 -1
  124. package/packages/piagent-core/policies/base-policy.json +42 -2
  125. package/packages/piagent-core/policy/authority-manifest.v1.json +3 -3
  126. package/packages/piagent-core/prompts/be-to-fe.md +2 -8
  127. package/packages/piagent-core/prompts/plan.md +1 -1
  128. package/packages/piagent-core/prompts/platform-improve.md +2 -6
  129. package/packages/piagent-core/prompts/review.md +2 -7
  130. package/packages/piagent-core/prompts/scout.md +1 -1
  131. package/packages/piagent-core/prompts/task.md +4 -3
  132. package/packages/piagent-core/runtime/hooks/completion-hook.ts +7 -6
  133. package/packages/piagent-core/runtime/hooks/input-hook.ts +6 -0
  134. package/packages/piagent-core/runtime/hooks/session-start-hook.ts +100 -1
  135. package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +58 -72
  136. package/packages/piagent-core/runtime/hooks/tool-result-value-helpers.ts +66 -0
  137. package/packages/piagent-core/runtime/inspection/bounded-emission-guard.ts +286 -0
  138. package/packages/piagent-core/runtime/inspection/runtime-event-store.ts +37 -7
  139. package/packages/piagent-core/runtime/inspection/task-subagent-tree.ts +27 -4
  140. package/packages/piagent-core/runtime/inspection/tool-failure-classification.ts +20 -3
  141. package/packages/piagent-core/runtime/inspection/webui-snapshot.ts +47 -11
  142. package/packages/piagent-core/runtime/orchestration/helper-lifecycle.ts +16 -12
  143. package/packages/piagent-core/runtime/orchestration/minimal-delegation-policy.ts +71 -0
  144. package/packages/piagent-core/runtime/orchestration/owned-work-budget.ts +28 -20
  145. package/packages/piagent-core/runtime/orchestration/role-policy.ts +27 -9
  146. package/packages/piagent-core/runtime/orchestration/subagent-tool-policy.ts +329 -0
  147. package/packages/piagent-core/runtime/policy/block-remedy.ts +0 -4
  148. package/packages/piagent-core/runtime/product/efficiency-metrics.ts +3 -0
  149. package/packages/piagent-core/runtime/quality/edit-freshness-guard.ts +102 -0
  150. package/packages/piagent-core/runtime/quality/exact-output-contract.ts +20 -10
  151. package/packages/piagent-core/runtime/quality/performance-assurance.ts +3 -3
  152. package/packages/piagent-core/runtime/recovery/continuation-budget.ts +1 -1
  153. package/packages/piagent-core/runtime/recovery/handoff-projection.ts +4 -1
  154. package/packages/piagent-core/runtime/recovery/pristine-task-policy-refresh.ts +91 -0
  155. package/packages/piagent-core/runtime/recovery/recovery-policy.ts +7 -4
  156. package/packages/piagent-core/runtime/recovery/resume-state.ts +112 -14
  157. package/packages/piagent-core/runtime/recovery/semantic-repair-handshake.ts +7 -13
  158. package/packages/piagent-core/runtime/recovery/task-evidence-coverage-refresh.ts +217 -0
  159. package/packages/piagent-core/runtime/registration/context-commands.ts +16 -2
  160. package/packages/piagent-core/runtime/registration/knowledge-tools.ts +9 -5
  161. package/packages/piagent-core/runtime/registration/operator-request-intake.ts +49 -0
  162. package/packages/piagent-core/runtime/registration/policy-tools.ts +4 -4
  163. package/packages/piagent-core/runtime/registration/session-commands.ts +1 -1
  164. package/packages/piagent-core/runtime/registration/task-completion-tools.ts +12 -9
  165. package/packages/piagent-core/runtime/registration/task-evidence-tools.ts +21 -12
  166. package/packages/piagent-core/runtime/registration/task-start-guidance.ts +19 -13
  167. package/packages/piagent-core/runtime/registration/task-start-manifest.ts +54 -0
  168. package/packages/piagent-core/runtime/registration/task-start-tool.ts +57 -57
  169. package/packages/piagent-core/runtime/runtime-limits.ts +16 -2
  170. package/packages/piagent-core/runtime/session/adaptive-context-analysis.ts +461 -0
  171. package/packages/piagent-core/runtime/session/adaptive-context-governor.ts +464 -0
  172. package/packages/piagent-core/runtime/session/adaptive-context-ledger.ts +265 -0
  173. package/packages/piagent-core/runtime/session/message-signals.ts +7 -3
  174. package/packages/piagent-core/runtime/session/operator-request-carry.ts +44 -0
  175. package/packages/piagent-core/runtime/session/runtime-state.ts +11 -7
  176. package/packages/piagent-core/runtime/session/source-checkout-read-grants.ts +35 -0
  177. package/packages/piagent-core/runtime/session/system-prompt.ts +76 -14
  178. package/packages/piagent-core/runtime/session/task-contract-presentation.ts +39 -0
  179. package/packages/piagent-core/runtime/tools/phase-tools.ts +8 -8
  180. package/packages/piagent-core/runtime/tools/tool-groups.ts +12 -2
  181. package/packages/piagent-core/runtime/verification/exact-verifier-reuse.ts +101 -0
  182. package/packages/piagent-core/runtime/workflows/runtime-intake-compaction.ts +164 -0
  183. package/packages/piagent-core/runtime/workflows/task-intake.ts +167 -39
  184. package/packages/piagent-core/subagents/piagent-oracle.md +5 -3
  185. package/packages/piagent-core/subagents/piagent-planner.md +6 -4
  186. package/packages/piagent-core/subagents/piagent-reviewer.md +5 -3
  187. package/packages/piagent-core/subagents/piagent-scout.md +4 -2
  188. package/packages/piagent-core/subagents/piagent-worker.md +6 -4
  189. package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-CxeZqTte.js → MarkdownMessage-B4XehTCU.js} +1 -1
  190. package/packages/piagent-webui/dist/client/assets/{index-DynIMe8I.js → index-CgOEyRPG.js} +4 -4
  191. package/packages/piagent-webui/dist/client/index.html +1 -1
  192. package/packages/piagent-webui/extension/piagent-webui.ts +3 -1
  193. package/packages/piagent-webui/extension/same-session-bridge.ts +1 -1
  194. package/packages/piagent-webui/extension/session-stream-adapter.ts +33 -10
  195. package/packages/piagent-webui/gateway/gateway-session-stream.ts +37 -21
  196. package/packages/piagent-webui/gateway/session-operation-lifecycle.ts +237 -0
  197. package/packages/piagent-webui/gateway/session-operation-retry-control.ts +38 -0
  198. package/packages/piagent-webui/gateway/session-operation-watchdog.ts +9 -2
  199. package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +8 -7
  200. package/packages/piagent-webui/ownership/session-lease-store.ts +5 -2
  201. package/packages/piagent-webui/server/core-inspection-provider.ts +2 -1
  202. package/packages/piagent-webui/server/transcript-projection.ts +91 -5
  203. package/schemas/codex-relative-efficiency-v1.schema.json +155 -0
  204. package/schemas/piagent-webui/runtime-event-v2.schema.json +15 -5
  205. package/schemas/piagent-webui/subagent-tree-v1.schema.json +11 -1
  206. package/schemas/project-profile.schema.json +1 -1
  207. package/schemas/task-contract.schema.json +15 -0
  208. package/scripts/benchmark-runner-core.mjs +14 -6
  209. package/scripts/benchmark-runner-finalization.mjs +4 -0
  210. package/scripts/configure-subagents.sh +42 -34
  211. package/scripts/helper-evaluation.mjs +1 -1
  212. package/scripts/team-doctor.sh +1 -1
  213. package/scripts/verify-local.sh +5 -0
@@ -1,4 +1,5 @@
1
1
  import { benchmarkClaimEligibility } from "./benchmark-assurance.js";
2
+ import { integrateCodexRelativeEfficiencyReport } from "./benchmark-codex-relative-efficiency.js";
2
3
  import {
3
4
  comparableAttemptUsage,
4
5
  comparableDuration,
@@ -42,13 +43,13 @@ import {
42
43
  surfaceSummary,
43
44
  workflowContinuityEvidenceComplete
44
45
  } from "./benchmark-summary-support.js";
45
-
46
46
  export { renderBenchmarkHtml, renderBenchmarkText } from "./benchmark-report.js";
47
47
  export { benchmarkAssuranceEvidenceValidationErrors, benchmarkClaimEligibility } from "./benchmark-assurance.js";
48
48
  export { median } from "./benchmark-statistics.js";
49
49
  export { benchmarkSuiteValidationErrors, validateBenchmarkSuite } from "./benchmark-suite.js";
50
50
  export { aggregateSessionUsage, benchmarkTokenAccounting, createCodexExecJsonlCollector, parseCodexExecJsonl } from "./benchmark-usage.js";
51
51
  export { benchmarkPricingSnapshotValidationErrors, normalizeBenchmarkUsageCost } from "./benchmark-normalized-cost.js";
52
+ export { CODEX_RELATIVE_EFFICIENCY_POLICY, PRODUCTION_SUBAGENT_BUDGET_POLICY, evaluateCodexRelativeEfficiency, summarizeBenchmarkSubagentBudget } from "./benchmark-codex-relative-efficiency.js";
52
53
  export { evaluateWorkflowEvidence } from "./benchmark-workflow.js";
53
54
  const SURFACE_LABELS = Object.freeze({
54
55
  "raw-pi": "Raw Pi",
@@ -737,7 +738,7 @@ export function summarizeBenchmark({
737
738
  protocolPassed: protocol.passed,
738
739
  tokenClaimAllowed
739
740
  });
740
- return {
741
+ return integrateCodexRelativeEfficiencyReport({
741
742
  schemaVersion: 2,
742
743
  measurementSchemaVersion: BENCHMARK_MEASUREMENT_SCHEMA_VERSION,
743
744
  runId,
@@ -1029,5 +1030,5 @@ export function summarizeBenchmark({
1029
1030
  note: `Raw metrics and hidden verifier results are authoritative. Fixed-workload efficiency includes every predeclared paired attempt, including exact provider-started failed-attempt usage, without conditioning token measurement on task outcome; quality and continuity remain independent hard gates. Successful-pair efficiency uses matched ${benchmarkSurfaceLabel(candidateSurface)}/${benchmarkSurfaceLabel(baselineSurface)} resolved-outcome ratios; failure-aware effort divides every comparable attempt by resolved outcomes. Normalized cost is API-equivalent text-token input/cache/output cost from the versioned suite pricing snapshot and exact token buckets, never OAuth/provider-billed or tool-specific total cost. Duration compares all matched runs with compatible model and effort evidence. Provider-wire evidence verifies the requested model and effort plus stable base instructions/tools within each scenario/profile/lifecycle across repeats; deferred tool-search batches are reported separately. Confidence intervals cluster repeats by scenario family. Claim scope is ${claimEligibility.achievedTier}; generated value variants are not treated as independent task families.`
1030
1031
  },
1031
1032
  runs: reportRuns
1032
- };
1033
+ }, suite);
1033
1034
  }
@@ -10,6 +10,7 @@ import {
10
10
  } from "./benchmark-candidate.js";
11
11
  import { assertBenchmarkLedgerBinding, inspectBenchmarkLedger } from "./benchmark-ledger.js";
12
12
  import { benchmarkPhaseAttribution } from "./benchmark-phase-attribution.js";
13
+ import { causalRuntimeEvidence } from "./benchmark-runtime-causal.js";
13
14
 
14
15
  export { materializeBenchmarkCandidate } from "./benchmark-candidate.js";
15
16
 
@@ -709,8 +710,8 @@ export function benchmarkCausalContextReceipt(events, {
709
710
  ? "uncompacted"
710
711
  : compactedPrompts === prompts.length ? "compacted" : "mixed";
711
712
  return {
712
- schemaVersion: 2,
713
- evidenceSource: "context-telemetry-closed-aggregate-v2",
713
+ schemaVersion: 3,
714
+ evidenceSource: "context-telemetry-closed-aggregate-v3",
714
715
  applicability: "piagent",
715
716
  available,
716
717
  coverage: {
@@ -754,6 +755,7 @@ export function benchmarkCausalContextReceipt(events, {
754
755
  },
755
756
  definition: "matched-edit-recovery-context-receipt-v1"
756
757
  },
758
+ runtimeCausal: causalRuntimeEvidence(visible),
757
759
  compaction: { eventsObserved: compactions, state: compactions > 0 ? "observed" : "not-observed" },
758
760
  managedPrefix: { promptsObserved: prompts.length, compactedPrompts, state: managedPrefixState }
759
761
  } : null
@@ -59,7 +59,8 @@ function publicCommandIdentity(value) {
59
59
  export function benchmarkPreflightReceipt({
60
60
  packageVersion, source, candidateProvenance, suite, suiteDigest,
61
61
  runtimeDependencies, runtimeCommands, environmentPolicy, configurationDigest,
62
- rootSeedDigest, options, runtime, hostReadinessPolicyDigest = null, hostReadiness = null
62
+ rootSeedDigest, options, runtime, hostReadinessPolicyDigest = null, hostReadiness = null,
63
+ providerFreeEvidence = null
63
64
  }) {
64
65
  return {
65
66
  schemaVersion: 1,
@@ -89,6 +90,7 @@ export function benchmarkPreflightReceipt({
89
90
  stopAfterFailedPair: options.stopAfterFailedPair
90
91
  },
91
92
  ...(hostReadiness ? { hostReadiness } : {}),
93
+ ...(providerFreeEvidence ? { providerFreeEvidence } : {}),
92
94
  runtime: {
93
95
  gitVersion: runtime.gitVersion,
94
96
  piVersion: runtime.piVersion,
@@ -0,0 +1,345 @@
1
+ import crypto from "node:crypto";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+
6
+ const HASH = /^[a-f0-9]{64}$/;
7
+ const COMMIT = /^[a-f0-9]{40,64}$/;
8
+ const LANE_DEFINITIONS = Object.freeze([
9
+ Object.freeze({
10
+ id: "runtime-conformance-v1",
11
+ configuration: "evals/runtime-conformance-v1/lane.json",
12
+ runner: "evals/runtime-conformance-v1/runner.mjs",
13
+ timeoutMilliseconds: 5 * 60_000
14
+ }),
15
+ Object.freeze({
16
+ id: "long-horizon-v1",
17
+ configuration: "evals/long-horizon-v1/lane.json",
18
+ runner: "evals/long-horizon-v1/runner.mjs",
19
+ timeoutMilliseconds: 40 * 60_000
20
+ }),
21
+ Object.freeze({
22
+ id: "webui-parity-v1",
23
+ configuration: "packages/piagent-webui/benchmark/parity-lane.v1.json",
24
+ runner: "packages/piagent-webui/benchmark/parity-benchmark.mjs",
25
+ timeoutMilliseconds: 20 * 60_000
26
+ })
27
+ ]);
28
+
29
+ function digestBytes(bytes) {
30
+ return crypto.createHash("sha256").update(bytes).digest("hex");
31
+ }
32
+
33
+ function fileDigest(root, relative) {
34
+ return digestBytes(fs.readFileSync(path.join(root, relative)));
35
+ }
36
+
37
+ function receiptDigest(value) {
38
+ const copy = structuredClone(value);
39
+ delete copy.digest;
40
+ return digestBytes(JSON.stringify(copy));
41
+ }
42
+
43
+ function validCompletionTime(value) {
44
+ const milliseconds = typeof value === "string" ? Date.parse(value) : Number.NaN;
45
+ return Number.isFinite(milliseconds)
46
+ && new Date(milliseconds).toISOString() === value
47
+ && milliseconds <= Date.now() + 60_000;
48
+ }
49
+
50
+ function expectedLaneBindings(packageRoot) {
51
+ return LANE_DEFINITIONS.map((lane) => ({
52
+ id: lane.id,
53
+ configurationPath: lane.configuration,
54
+ configurationDigest: fileDigest(packageRoot, lane.configuration),
55
+ runnerPath: lane.runner,
56
+ runnerDigest: fileDigest(packageRoot, lane.runner)
57
+ }));
58
+ }
59
+
60
+ export function productionProviderFreeEvidenceBinding({
61
+ packageRoot,
62
+ source,
63
+ candidateProvenance,
64
+ configurationDigest
65
+ }) {
66
+ if (source?.kind !== "git-working-tree" || source.dirty !== false || !COMMIT.test(String(source.commit ?? ""))) {
67
+ throw new Error("Production provider-free evidence requires an exact clean Git commit");
68
+ }
69
+ if (!HASH.test(String(candidateProvenance?.contentDigest ?? ""))) {
70
+ throw new Error("Production provider-free evidence requires an exact candidate tree digest");
71
+ }
72
+ if (!HASH.test(String(configurationDigest ?? ""))) {
73
+ throw new Error("Production provider-free evidence requires the frozen production configuration digest");
74
+ }
75
+ const binding = {
76
+ schemaVersion: 1,
77
+ source: {
78
+ kind: source.kind,
79
+ commit: source.commit,
80
+ clean: true,
81
+ treeDigest: candidateProvenance.contentDigest,
82
+ treeAlgorithm: candidateProvenance.algorithm
83
+ },
84
+ productionConfigurationDigest: configurationDigest,
85
+ lanes: expectedLaneBindings(packageRoot)
86
+ };
87
+ return { ...binding, digest: receiptDigest(binding) };
88
+ }
89
+
90
+ function lanePassed(id, result) {
91
+ if (id === "runtime-conformance-v1") {
92
+ return result?.summary?.passed === true
93
+ && result?.provider?.used === false
94
+ && result.provider.calls === 0
95
+ && result.provider.modelInputTokens === 0
96
+ && result.provider.modelOutputTokens === 0
97
+ && Object.values(result?.gates ?? {}).every((value) => value === true);
98
+ }
99
+ if (id === "long-horizon-v1") {
100
+ return result?.evidenceClass === "provider-free-long-horizon"
101
+ && result?.providerUsed === false
102
+ && result?.wallClockQualified === true
103
+ && result?.completedFromResume === true
104
+ && result?.context?.withinCeiling === true
105
+ && result?.stateGrowth?.withinCeiling === true
106
+ && result?.continuation?.enforcementSafe === true
107
+ && result?.verification?.stableCurrentTree === true;
108
+ }
109
+ return result?.benchmark === "webui-parity-v1"
110
+ && result?.passed === true
111
+ && result?.providerCalls === 0
112
+ && result?.modelTokens === 0
113
+ && result?.invariants?.uiStability === "deterministic-current-state"
114
+ && result?.invariants?.uiStabilitySuites === 7;
115
+ }
116
+
117
+ function laneSummary(id, result) {
118
+ if (id === "runtime-conformance-v1") return {
119
+ passed: result.summary.passed,
120
+ configuredCases: result.summary.configuredCases,
121
+ executedCases: result.summary.executedCases,
122
+ failedCases: result.summary.failedCases,
123
+ gates: result.gates
124
+ };
125
+ if (id === "long-horizon-v1") return {
126
+ evidenceClass: result.evidenceClass,
127
+ wallClockQualified: result.wallClockQualified,
128
+ completedFromResume: result.completedFromResume,
129
+ contextWithinCeiling: result.context.withinCeiling,
130
+ stateGrowthWithinCeiling: result.stateGrowth.withinCeiling,
131
+ continuationEnforcementSafe: result.continuation.enforcementSafe,
132
+ stableCurrentTree: result.verification.stableCurrentTree
133
+ };
134
+ return {
135
+ benchmark: result.benchmark,
136
+ passed: result.passed,
137
+ uiStability: result.invariants.uiStability,
138
+ uiStabilitySuites: result.invariants.uiStabilitySuites,
139
+ deterministicStabilityStepPassed: result.steps.some((step) => step.name === "deterministic-ui-stability" && step.passed === true)
140
+ };
141
+ }
142
+
143
+ function summaryPassed(id, summary) {
144
+ if (id === "runtime-conformance-v1") return summary?.passed === true
145
+ && summary.configuredCases === summary.executedCases && summary.failedCases === 0
146
+ && Object.values(summary.gates ?? {}).every((value) => value === true);
147
+ if (id === "long-horizon-v1") return summary?.evidenceClass === "provider-free-long-horizon"
148
+ && summary.wallClockQualified === true && summary.completedFromResume === true
149
+ && summary.contextWithinCeiling === true && summary.stateGrowthWithinCeiling === true
150
+ && summary.continuationEnforcementSafe === true && summary.stableCurrentTree === true;
151
+ return summary?.benchmark === "webui-parity-v1" && summary.passed === true
152
+ && summary.uiStability === "deterministic-current-state"
153
+ && summary.uiStabilitySuites === 7
154
+ && summary.deterministicStabilityStepPassed === true;
155
+ }
156
+
157
+ function privateWrite(file, value) {
158
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
159
+ const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
160
+ fs.writeFileSync(temporary, value, { mode: 0o600 });
161
+ fs.renameSync(temporary, file);
162
+ try { fs.chmodSync(file, 0o600); } catch { /* Non-POSIX filesystem. */ }
163
+ }
164
+
165
+ export function productionProviderFreeEvidenceValidationErrors(receipt, expectedBinding) {
166
+ const errors = [];
167
+ if (receipt?.schemaVersion !== 1 || receipt?.kind !== "production-provider-free-evidence-v1") {
168
+ return ["missing-or-unsupported-provider-free-evidence"];
169
+ }
170
+ if (!validCompletionTime(receipt.completedAt)) errors.push("provider-free-completion-time-invalid-or-future");
171
+ const validExpectedBinding = expectedBinding?.schemaVersion === 1
172
+ && expectedBinding?.source?.kind === "git-working-tree"
173
+ && expectedBinding.source.clean === true
174
+ && COMMIT.test(String(expectedBinding.source.commit ?? ""))
175
+ && HASH.test(String(expectedBinding.source.treeDigest ?? ""))
176
+ && HASH.test(String(expectedBinding.productionConfigurationDigest ?? ""))
177
+ && Array.isArray(expectedBinding.lanes)
178
+ && expectedBinding.lanes.length === LANE_DEFINITIONS.length
179
+ && LANE_DEFINITIONS.every((definition, index) => {
180
+ const lane = expectedBinding.lanes[index];
181
+ return lane?.id === definition.id
182
+ && lane.configurationPath === definition.configuration
183
+ && lane.runnerPath === definition.runner
184
+ && HASH.test(String(lane.configurationDigest ?? ""))
185
+ && HASH.test(String(lane.runnerDigest ?? ""));
186
+ })
187
+ && expectedBinding.digest === receiptDigest(expectedBinding);
188
+ if (!validExpectedBinding) return ["invalid-provider-free-expected-binding"];
189
+ if (receipt?.binding?.digest !== expectedBinding?.digest
190
+ || JSON.stringify(receipt.binding) !== JSON.stringify(expectedBinding)) errors.push("provider-free-binding-mismatch");
191
+ if (!Array.isArray(receipt.lanes) || receipt.lanes.length !== LANE_DEFINITIONS.length) {
192
+ errors.push("provider-free-lane-count-mismatch");
193
+ } else {
194
+ for (const expected of expectedBinding.lanes) {
195
+ const lane = receipt.lanes.find((item) => item?.id === expected.id);
196
+ if (!lane) { errors.push(`provider-free-lane-missing:${expected.id}`); continue; }
197
+ if (lane.passed !== true || lane.providerUsed !== false || lane.providerCalls !== 0 || lane.modelTokens !== 0) {
198
+ errors.push(`provider-free-lane-failed:${expected.id}`);
199
+ }
200
+ if (!summaryPassed(expected.id, lane.summary)) errors.push(`provider-free-lane-summary-invalid:${expected.id}`);
201
+ if (lane.configurationDigest !== expected.configurationDigest
202
+ || lane.runnerDigest !== expected.runnerDigest
203
+ || !HASH.test(String(lane.resultDigest ?? ""))) errors.push(`provider-free-lane-binding-mismatch:${expected.id}`);
204
+ }
205
+ }
206
+ if (receipt.digest !== receiptDigest(receipt)) errors.push("provider-free-receipt-digest-mismatch");
207
+ return errors;
208
+ }
209
+
210
+ export function productionProviderFreeEvidenceContextValidationErrors(receipt, {
211
+ source,
212
+ candidateProvenance,
213
+ configurationDigest
214
+ } = {}) {
215
+ const errors = productionProviderFreeEvidenceValidationErrors(receipt, receipt?.binding);
216
+ const binding = receipt?.binding;
217
+ if (binding?.source?.kind !== source?.kind
218
+ || binding?.source?.commit !== source?.commit
219
+ || binding?.source?.clean !== (source?.dirty === false)) errors.push("provider-free-source-binding-mismatch");
220
+ if (binding?.source?.treeDigest !== candidateProvenance?.contentDigest
221
+ || binding?.source?.treeAlgorithm !== candidateProvenance?.algorithm) errors.push("provider-free-tree-binding-mismatch");
222
+ if (binding?.productionConfigurationDigest !== configurationDigest) errors.push("provider-free-production-configuration-binding-mismatch");
223
+ return [...new Set(errors)];
224
+ }
225
+
226
+ export function assertProductionProviderFreeEvidence(receipt, expectedBinding, label = "production provider-free evidence") {
227
+ const errors = productionProviderFreeEvidenceValidationErrors(receipt, expectedBinding);
228
+ if (errors.length > 0) throw new Error(`${label} is missing or changed (${errors.join(", ")})`);
229
+ return receipt;
230
+ }
231
+
232
+ export async function collectProductionProviderFreeEvidence({
233
+ packageRoot,
234
+ liveRoot,
235
+ runCommand,
236
+ source,
237
+ candidateProvenance,
238
+ configurationDigest
239
+ }) {
240
+ const binding = productionProviderFreeEvidenceBinding({ packageRoot, source, candidateProvenance, configurationDigest });
241
+ const cacheRoot = path.join(liveRoot, ".pi", "benchmarks", "provider-free-evidence", binding.digest);
242
+ const cachePath = path.join(cacheRoot, "receipt.json");
243
+ if (fs.existsSync(cachePath)) {
244
+ const cached = JSON.parse(fs.readFileSync(cachePath, "utf8"));
245
+ if (productionProviderFreeEvidenceValidationErrors(cached, binding).length === 0) return cached;
246
+ }
247
+
248
+ const assertLiveSource = async (stage) => {
249
+ const commit = await runCommand("git", ["-C", liveRoot, "rev-parse", "HEAD"], { cwd: liveRoot, timeoutMs: 15_000 });
250
+ const status = await runCommand("git", ["-C", liveRoot, "status", "--porcelain=v1", "--untracked-files=all"], { cwd: liveRoot, timeoutMs: 15_000 });
251
+ if (commit.code !== 0 || commit.stdout.trim() !== source.commit || status.code !== 0 || status.stdout.trim()) {
252
+ throw new Error(`Production provider-free evidence source changed at ${stage}`);
253
+ }
254
+ for (const lane of binding.lanes) {
255
+ if (fileDigest(liveRoot, lane.configurationPath) !== lane.configurationDigest
256
+ || fileDigest(liveRoot, lane.runnerPath) !== lane.runnerDigest) {
257
+ throw new Error(`Production provider-free lane assets changed at ${stage}: ${lane.id}`);
258
+ }
259
+ }
260
+ };
261
+
262
+ const temporaryRoot = fs.mkdtempSync(path.join(os.tmpdir(), "piagent-provider-free-evidence-"));
263
+ const lanes = [];
264
+ try {
265
+ await assertLiveSource("before-lanes");
266
+ for (const definition of LANE_DEFINITIONS) {
267
+ const output = path.join(temporaryRoot, `${definition.id}.json`);
268
+ const result = await runCommand(process.execPath, [path.join(liveRoot, definition.runner), "--output", output], {
269
+ cwd: liveRoot,
270
+ timeoutMs: definition.timeoutMilliseconds
271
+ });
272
+ if (result.code !== 0) {
273
+ throw new Error(`Required provider-free lane failed: ${definition.id} (${result.stderr.trim() || result.signal || `exit ${result.code}`})`);
274
+ }
275
+ const bytes = fs.readFileSync(output);
276
+ const parsed = JSON.parse(bytes.toString("utf8"));
277
+ if (!lanePassed(definition.id, parsed)) throw new Error(`Required provider-free lane returned an incomplete receipt: ${definition.id}`);
278
+ const expected = binding.lanes.find((lane) => lane.id === definition.id);
279
+ lanes.push({
280
+ schemaVersion: 1,
281
+ id: definition.id,
282
+ passed: true,
283
+ providerUsed: false,
284
+ providerCalls: 0,
285
+ modelTokens: 0,
286
+ configurationDigest: expected.configurationDigest,
287
+ runnerDigest: expected.runnerDigest,
288
+ resultDigest: digestBytes(bytes),
289
+ summary: laneSummary(definition.id, parsed)
290
+ });
291
+ await assertLiveSource(`after-${definition.id}`);
292
+ }
293
+ const receipt = {
294
+ schemaVersion: 1,
295
+ kind: "production-provider-free-evidence-v1",
296
+ completedAt: new Date().toISOString(),
297
+ binding,
298
+ lanes
299
+ };
300
+ receipt.digest = receiptDigest(receipt);
301
+ assertProductionProviderFreeEvidence(receipt, binding);
302
+ privateWrite(cachePath, `${JSON.stringify(receipt, null, 2)}\n`);
303
+ return receipt;
304
+ } finally {
305
+ fs.rmSync(temporaryRoot, { recursive: true, force: true });
306
+ }
307
+ }
308
+
309
+ export function productionProviderFreeLaneDefinitions() {
310
+ return LANE_DEFINITIONS.map((lane) => ({ ...lane }));
311
+ }
312
+
313
+ export async function prepareProductionProviderFreeEvidence({
314
+ required,
315
+ packageRoot,
316
+ bootstrapMetadata,
317
+ candidateProvenance,
318
+ configurationDigest,
319
+ runCommand,
320
+ resumedReceipt = undefined
321
+ }) {
322
+ if (!required) return { receipt: null, binding: null };
323
+ const binding = productionProviderFreeEvidenceBinding({
324
+ packageRoot,
325
+ source: bootstrapMetadata.sourceIdentity,
326
+ candidateProvenance,
327
+ configurationDigest
328
+ });
329
+ const receipt = resumedReceipt !== undefined
330
+ ? assertProductionProviderFreeEvidence(resumedReceipt, binding, "resumed production provider-free evidence")
331
+ : await collectProductionProviderFreeEvidence({
332
+ packageRoot,
333
+ liveRoot: bootstrapMetadata.liveRoot,
334
+ runCommand,
335
+ source: bootstrapMetadata.sourceIdentity,
336
+ candidateProvenance,
337
+ configurationDigest
338
+ });
339
+ return { receipt, binding };
340
+ }
341
+
342
+ export function productionProviderFreeEvidenceError(receipt, binding, label) {
343
+ try { assertProductionProviderFreeEvidence(receipt, binding, label); return null; }
344
+ catch (error) { return error; }
345
+ }
@@ -3,6 +3,7 @@ const causalCoverageLanesV1 = new Set([
3
3
  "telemetry-window", "session-lifecycle", "criterion-initial-pack", "pack-lifecycle", "direct-fallback-rereads", "managed-prefix"
4
4
  ]);
5
5
  const causalCoverageLanesV2 = new Set([...causalCoverageLanesV1, "edit-recovery-context"]);
6
+ const causalCoverageLanesV3 = causalCoverageLanesV2;
6
7
  const causalMaximumAggregate = 1_000_000_000;
7
8
 
8
9
  function exactKeys(value, keys) {
@@ -53,9 +54,75 @@ function validEditRecoveryAggregate(value) {
53
54
  : value.injectedChars > 0 && value.injectedEstimatedTokens > 0;
54
55
  }
55
56
 
57
+ function validRuntimeSection(value, evidenceSource) {
58
+ return exactKeys(value, ["coverageStatus", "observedEvents", "evidenceSource", "aggregate"])
59
+ && ["not-observed", "partial", "complete"].includes(value.coverageStatus)
60
+ && boundedInteger(value.observedEvents)
61
+ && value.evidenceSource === evidenceSource
62
+ && (value.coverageStatus === "not-observed"
63
+ ? value.observedEvents === 0 && value.aggregate === null
64
+ : value.observedEvents > 0 && (value.coverageStatus === "partial") === (value.aggregate === null));
65
+ }
66
+
67
+ function validAdaptiveContextRuntime(value) {
68
+ if (!validRuntimeSection(value, "context-telemetry")) return false;
69
+ if (value.coverageStatus !== "complete") return true;
70
+ const aggregate = value.aggregate;
71
+ const fields = ["projected", "noOp", "cancelled", "deterministicCompactions", "hostSummaryFallbacks",
72
+ "estimatedSavingsTokens", "minimumSavingsTokens", "minimumSavingsMet", "minimumSavingsNotMet",
73
+ "governorProviderCalls", "deterministicCompactionProviderCalls", "protocolIntegrity", "definition"];
74
+ if (!exactKeys(aggregate, fields)
75
+ || !fields.slice(0, -2).every((field) => boundedInteger(aggregate[field]))
76
+ || aggregate.definition !== "adaptive-context-runtime-receipt-v1"
77
+ || !exactKeys(aggregate.protocolIntegrity, ["checks", "intact", "failed", "orphanCalls", "orphanResults"])
78
+ || !Object.values(aggregate.protocolIntegrity).every(boundedInteger)) return false;
79
+ const eventCount = aggregate.projected + aggregate.noOp + aggregate.cancelled
80
+ + aggregate.deterministicCompactions + aggregate.hostSummaryFallbacks;
81
+ const savingsDecisions = aggregate.minimumSavingsMet + aggregate.minimumSavingsNotMet;
82
+ const protocol = aggregate.protocolIntegrity;
83
+ return eventCount === value.observedEvents
84
+ && savingsDecisions <= eventCount
85
+ && aggregate.deterministicCompactionProviderCalls === 0
86
+ && protocol.intact + protocol.failed === protocol.checks
87
+ && (protocol.failed > 0 || protocol.orphanCalls + protocol.orphanResults === 0);
88
+ }
89
+
90
+ function validEditFreshnessRuntime(value) {
91
+ if (!validRuntimeSection(value, "context-telemetry")) return false;
92
+ if (value.coverageStatus !== "complete") return true;
93
+ const aggregate = value.aggregate;
94
+ const fields = ["snapshotObservations", "readSnapshots", "mutationSnapshots", "staleDetections",
95
+ "enforcedStaleDetections", "staleBlocks", "rereadRecoveries", "mutationRecoveries",
96
+ "incompleteRecoveries", "definition"];
97
+ if (!exactKeys(aggregate, fields)
98
+ || !fields.slice(0, -1).every((field) => boundedInteger(aggregate[field]))
99
+ || aggregate.definition !== "edit-freshness-runtime-receipt-v1") return false;
100
+ return aggregate.snapshotObservations + aggregate.staleDetections === value.observedEvents
101
+ && aggregate.readSnapshots + aggregate.mutationSnapshots === aggregate.snapshotObservations
102
+ && aggregate.enforcedStaleDetections <= aggregate.staleDetections
103
+ && aggregate.staleBlocks === aggregate.enforcedStaleDetections
104
+ && aggregate.rereadRecoveries === aggregate.enforcedStaleDetections
105
+ && aggregate.mutationRecoveries <= aggregate.rereadRecoveries
106
+ && aggregate.incompleteRecoveries === 0;
107
+ }
108
+
109
+ function validDelegatedRuntimeSection(value) {
110
+ return validRuntimeSection(value, "provider-free-runtime-conformance")
111
+ && value.coverageStatus === "not-observed";
112
+ }
113
+
114
+ function validRuntimeCausalAggregate(value) {
115
+ return exactKeys(value, ["adaptiveContext", "operationLifecycle", "boundedEmission", "editFreshness"])
116
+ && validAdaptiveContextRuntime(value.adaptiveContext)
117
+ && validDelegatedRuntimeSection(value.operationLifecycle)
118
+ && validDelegatedRuntimeSection(value.boundedEmission)
119
+ && validEditFreshnessRuntime(value.editFreshness);
120
+ }
121
+
56
122
  function validCausalAggregates(value, criterionExpected, schemaVersion) {
57
123
  const expectedKeys = ["packCounts", "estimatedTokens", "selectedItemEstimatedTokens", "selectedItemCounts", "criterionInitialPack", "directFallbackRereads", "compaction", "managedPrefix"];
58
- if (schemaVersion === 2) expectedKeys.splice(6, 0, "editRecoveryContext");
124
+ if (schemaVersion >= 2) expectedKeys.splice(6, 0, "editRecoveryContext");
125
+ if (schemaVersion >= 3) expectedKeys.splice(7, 0, "runtimeCausal");
59
126
  if (!exactKeys(value, expectedKeys)
60
127
  || !validCausalTriplet(value.packCounts)
61
128
  || !validCausalTriplet(value.estimatedTokens)
@@ -74,7 +141,8 @@ function validCausalAggregates(value, criterionExpected, schemaVersion) {
74
141
  || !boundedInteger(value.managedPrefix.compactedPrompts)
75
142
  || value.managedPrefix.compactedPrompts > value.managedPrefix.promptsObserved
76
143
  || !["compacted", "uncompacted", "mixed"].includes(value.managedPrefix.state)
77
- || (schemaVersion === 2 && !validEditRecoveryAggregate(value.editRecoveryContext))) return false;
144
+ || (schemaVersion >= 2 && !validEditRecoveryAggregate(value.editRecoveryContext))
145
+ || (schemaVersion >= 3 && !validRuntimeCausalAggregate(value.runtimeCausal))) return false;
78
146
  const compacted = value.managedPrefix.compactedPrompts;
79
147
  const prompts = value.managedPrefix.promptsObserved;
80
148
  const expectedState = compacted === 0 ? "uncompacted" : compacted === prompts ? "compacted" : "mixed";
@@ -85,7 +153,7 @@ function validCausalAggregates(value, criterionExpected, schemaVersion) {
85
153
 
86
154
  export function validBenchmarkCausalContextReceipt(receipt, surface) {
87
155
  if (!exactKeys(receipt, ["schemaVersion", "evidenceSource", "applicability", "available", "coverage", "aggregates"])
88
- || ![1, 2].includes(receipt.schemaVersion) || typeof receipt.available !== "boolean"
156
+ || ![1, 2, 3].includes(receipt.schemaVersion) || typeof receipt.available !== "boolean"
89
157
  || !exactKeys(receipt.coverage, ["status", "telemetryTruncated", "telemetryIntegrityFailures", "recoverableTailBytes", "criterionExpected", "sessionEventsObserved", "observedLanes", "requiredLanes", "missingLanes"])) return false;
90
158
  const coverage = receipt.coverage;
91
159
  if (surface !== "piagent") return receipt.schemaVersion === 1 && receipt.evidenceSource === "not-applicable"
@@ -95,7 +163,8 @@ export function validBenchmarkCausalContextReceipt(receipt, surface) {
95
163
  && coverage.criterionExpected === false && coverage.sessionEventsObserved === 0
96
164
  && coverage.observedLanes === 0 && coverage.requiredLanes === 0
97
165
  && Array.isArray(coverage.missingLanes) && coverage.missingLanes.length === 0;
98
- const coverageLanes = receipt.schemaVersion === 2 ? causalCoverageLanesV2 : causalCoverageLanesV1;
166
+ const coverageLanes = receipt.schemaVersion === 3 ? causalCoverageLanesV3
167
+ : receipt.schemaVersion === 2 ? causalCoverageLanesV2 : causalCoverageLanesV1;
99
168
  const evidenceSource = `context-telemetry-closed-aggregate-v${receipt.schemaVersion}`;
100
169
  if (receipt.evidenceSource !== evidenceSource || receipt.applicability !== "piagent"
101
170
  || typeof coverage.telemetryTruncated !== "boolean" || typeof coverage.criterionExpected !== "boolean"
@@ -120,7 +189,7 @@ export function summarizeBenchmarkCausalContextEvidence(runs, { required = false
120
189
  && run.causalContextReceipt.coverage.status === "complete"
121
190
  && run.causalContextReceipt.aggregates);
122
191
  const fullyCovered = piagentRuns.length > 0 && complete.length === piagentRuns.length;
123
- const recoveryComplete = complete.filter((run) => run.causalContextReceipt.schemaVersion === 2);
192
+ const recoveryComplete = complete.filter((run) => run.causalContextReceipt.schemaVersion >= 2);
124
193
  const recoveryFullyCovered = fullyCovered && recoveryComplete.length === piagentRuns.length;
125
194
  const sum = (select) => complete.reduce((total, run) => total + select(run.causalContextReceipt.aggregates), 0);
126
195
  const sumRecovery = (select) => recoveryComplete.reduce((total, run) => total + select(run.causalContextReceipt.aggregates.editRecoveryContext), 0);
@@ -17,6 +17,10 @@ function displayPercent(value) {
17
17
  return Number.isFinite(value) ? `${display(value)}%` : "n/a";
18
18
  }
19
19
 
20
+ function displayRatioPercent(value) {
21
+ return Number.isFinite(value) ? displayPercent(value * 100) : "n/a";
22
+ }
23
+
20
24
  function topToolSummary(toolNames, limit = 8) {
21
25
  const entries = Object.entries(toolNames ?? {}).slice(0, limit);
22
26
  return entries.length ? entries.map(([name, count]) => `${name}:${count}`).join(", ") : "none";
@@ -107,6 +111,9 @@ export function renderBenchmarkText(report) {
107
111
  const durationConfidence = report.comparison.durationRatioConfidence95;
108
112
  const normalizedCost = report.comparison.normalizedCost;
109
113
  const normalizedCostConfidence = normalizedCost?.ratioConfidence95;
114
+ const codexRelative = report.comparison.codexRelativeEfficiency;
115
+ const codexRelativeTrafficConfidence = codexRelative?.totalTokenTraffic?.ratioConfidence95;
116
+ const codexRelativeCostConfidence = codexRelative?.apiEquivalentCost?.ratioConfidence95;
110
117
  const causalContext = report.comparison.causalContextEvidence;
111
118
  const causalAggregates = causalContext?.aggregates;
112
119
  const hostReadiness = report.environment.hostReadinessHistory;
@@ -164,6 +171,10 @@ export function renderBenchmarkText(report) {
164
171
  `All-successful-pairs descriptive ratio: ${display(report.comparison.allSuccessfulPairsFreshTokenRatio, 4)}`,
165
172
  `Normalized API-equivalent text-token cost: ${display(normalizedCost?.ratio, 4)} | 95% CI ${normalizedCostConfidence ? `${display(normalizedCostConfidence.lower, 4)}..${display(normalizedCostConfidence.upper, 4)}` : "n/a"} | delta ${displayPercent(normalizedCost?.deltaPercent)}`,
166
173
  `Normalized-cost source: ${normalizedCost?.pricingSnapshot?.id ?? "n/a"} | billed/provider-reported cost: no | exact/applicable pairs ${normalizedCost?.comparablePairs ?? 0}/${normalizedCost?.expectedPairs ?? 0}`,
174
+ `Codex-relative total token traffic: ${display(codexRelative?.totalTokenTraffic?.ratio, 4)} | 95% CI ${codexRelativeTrafficConfidence ? `${display(codexRelativeTrafficConfidence.lower, 4)}..${display(codexRelativeTrafficConfidence.upper, 4)}` : "n/a"} | required upper <= ${display(codexRelative?.policy?.maximumTotalTokenTrafficRatioUpper95, 2)}`,
175
+ `Codex-relative API-equivalent cost: ${display(codexRelative?.apiEquivalentCost?.ratio, 4)} | 95% CI ${codexRelativeCostConfidence ? `${display(codexRelativeCostConfidence.lower, 4)}..${display(codexRelativeCostConfidence.upper, 4)}` : "n/a"} | required upper <= ${display(codexRelative?.policy?.maximumApiEquivalentCostRatioUpper95, 2)}`,
176
+ `Codex-relative subagent budget: ${codexRelative?.subagents?.sessions ?? "n/a"} sessions | ${displayRatioPercent(codexRelative?.subagents?.trafficShare)} traffic share | max ${codexRelative?.policy?.maximumSubagentSessionsPerAttempt ?? "n/a"}/attempt and ${displayRatioPercent(codexRelative?.policy?.maximumSubagentTrafficShare)}`,
177
+ `Codex-relative efficiency gate: ${report.comparison.codexRelativeEfficiencyGate === null ? "n/a" : report.comparison.codexRelativeEfficiencyGate ? "pass" : `fail (${(codexRelative?.failures ?? []).join(", ") || "missing evidence"})`} | subscription-billed claim: no`,
167
178
  `Duration pair wins: ${candidateLabel} ${report.comparison.pairedDurationWins?.[candidateKey] ?? 0} | ${baselineLabel} ${report.comparison.pairedDurationWins?.[baselineKey] ?? 0} | ties ${report.comparison.pairedDurationWins?.ties ?? 0}`,
168
179
  `Median paired duration delta: ${display(report.comparison.medianPairedDurationDeltaSeconds, 2)}s (negative favors ${candidateLabel})`,
169
180
  `Duration ratio 95% CI: ${durationConfidence ? `${display(durationConfidence.lower, 4)}..${display(durationConfidence.upper, 4)}` : "n/a"}`,
@@ -261,6 +272,9 @@ export function renderBenchmarkHtml(report) {
261
272
  const durationConfidence = report.comparison.durationRatioConfidence95;
262
273
  const normalizedCost = report.comparison.normalizedCost;
263
274
  const normalizedCostConfidence = normalizedCost?.ratioConfidence95;
275
+ const codexRelative = report.comparison.codexRelativeEfficiency;
276
+ const codexRelativeTrafficConfidence = codexRelative?.totalTokenTraffic?.ratioConfidence95;
277
+ const codexRelativeCostConfidence = codexRelative?.apiEquivalentCost?.ratioConfidence95;
264
278
  const causalContext = report.comparison.causalContextEvidence;
265
279
  const causalAggregates = causalContext?.aggregates;
266
280
  const hostReadiness = report.environment.hostReadinessHistory;
@@ -271,7 +285,7 @@ export function renderBenchmarkHtml(report) {
271
285
  <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Piagent Benchmark ${htmlEscape(report.runId)}</title>
272
286
  <style>body{font:14px system-ui,sans-serif;color:#202124;max-width:1180px;margin:32px auto;padding:0 20px}h1{font-size:24px}h2{font-size:17px;margin-top:28px}.table-wrap{overflow-x:auto}table{border-collapse:collapse;width:100%;white-space:nowrap}th,td{border:1px solid #d8dadd;padding:8px;text-align:left}thead th{background:#f4f5f6}.metric{display:inline-block;margin:0 24px 8px 0}.note{color:#5f6368}</style></head><body>
273
287
  <h1>Piagent Benchmark</h1><p>${htmlEscape(report.suite.title)} · ${htmlEscape(report.runId)}</p><p class="note">Platform v${htmlEscape(report.environment.platformVersion ?? "unknown")} · Pi ${htmlEscape(report.environment.piVersion ?? "unknown")}${report.environment.codexVersion ? ` · Codex ${htmlEscape(report.environment.codexVersion)}` : ""} · Node ${htmlEscape(report.environment.nodeVersion ?? "unknown")} · Baseline ${htmlEscape(report.environment.treatmentBaseline ?? "unknown")} · Piagent treatment ${htmlEscape(report.environment.piagentTreatment?.id ?? "unrecorded")} · Suite ${htmlEscape(report.environment.suiteDigest ?? "unknown")}</p>
274
- <p class="metric"><strong>Comparison:</strong> ${htmlEscape(candidateLabel)} vs ${htmlEscape(baselineLabel)}</p><p class="metric"><strong>Purpose:</strong> ${htmlEscape(report.comparison.purpose ?? "unspecified")}</p><p class="metric"><strong>Claim tier:</strong> ${htmlEscape(report.comparison.claimEligibility?.achievedTier ?? "unavailable")}</p><p class="metric"><strong>Token claim scope:</strong> ${htmlEscape(report.comparison.claimEligibility?.tokenClaimScope ?? "unavailable")}</p>${report.comparison.tokenClaimUnavailableReason ? `<p class="metric"><strong>Token claim restriction:</strong> ${htmlEscape(report.comparison.tokenClaimUnavailableReason)}</p>` : ""}<p class="metric"><strong>Verdict:</strong> ${htmlEscape(report.verdict.status)}</p><p class="metric"><strong>Protocol:</strong> ${report.comparison.comparisonProtocolGate?.passed ? "PASS" : `FAIL (${htmlEscape((report.comparison.comparisonProtocolGate?.failedChecks ?? []).join(", ") || "missing evidence")})`}</p><p class="metric"><strong>Provider wire:</strong> ${report.comparison.providerWireSurfaceGate === null ? "n/a" : report.comparison.providerWireSurfaceGate ? "PASS" : "FAIL"} (${report.comparison.providerWireEvidence?.verifiedRuns ?? 0}/${report.comparison.providerWireEvidence?.runs ?? 0} runs, ${(report.comparison.providerWireEvidence?.driftGroups ?? []).length} drift groups)</p><p class="metric"><strong>Causal receipt:</strong> ${report.comparison.causalContextEvidenceGate === null ? "n/a" : report.comparison.causalContextEvidenceGate ? "PASS" : "FAIL"} (current v${causalContext?.requiredSchemaVersion ?? "?"} ${causalContext?.currentAvailableRuns ?? 0}/${causalContext?.runs ?? 0} runs)</p><p class="metric"><strong>Host readiness:</strong> ${report.comparison.hostReadinessGate === null ? "n/a" : report.comparison.hostReadinessGate ? "PASS" : "FAIL"} (${hostReadiness?.validReceiptCount ?? 0}/${hostReadiness?.receiptCount ?? 0} valid receipts · ${htmlEscape(hostReadiness?.windowCoverage ?? "n/a")} coverage)</p><p class="metric"><strong>Causal packs:</strong> ${causalAggregates ? `${causalAggregates.packCounts.offered}/${causalAggregates.packCounts.delivered}/${causalAggregates.packCounts.injected} offered/delivered/injected · ${causalAggregates.estimatedTokens.injected} injected estimated tokens · ${causalAggregates.selectedItemCounts.injected} selected items` : "unavailable"}</p><p class="metric"><strong>Causal direct rereads:</strong> ${causalAggregates ? `${causalAggregates.directFallbackRereads.successfulCalls} successful direct-path calls · ${causalAggregates.directFallbackRereads.shellToolCallsObserved} shell calls after injection` : "unavailable"}</p><p class="metric"><strong>Causal edit recovery:</strong> ${causalAggregates?.editRecoveryContext ? `${causalAggregates.editRecoveryContext.count ?? "n/a"} contexts · ${causalAggregates.editRecoveryContext.injectedChars ?? "n/a"} chars · ${causalAggregates.editRecoveryContext.injectedEstimatedTokens ?? "n/a"} estimated tokens · ${htmlEscape(causalAggregates.editRecoveryContext.evidenceCoverage?.status ?? "unavailable")} evidence` : "unavailable"}</p><p class="metric"><strong>Suite gate:</strong> ${report.comparison.suiteGate ? report.comparison.suiteGate.passed ? "PASS" : "FAIL" : "n/a"}</p><p class="metric"><strong>Infrastructure retries:</strong> ${report.infrastructure?.retries ?? 0}</p><p class="metric"><strong>Stability gate:</strong> ${report.comparison.stabilityGate === null ? "n/a" : report.comparison.stabilityGate ? "PASS" : "FAIL"}</p><p class="metric"><strong>Primary estimand:</strong> ${htmlEscape(report.comparison.primaryEfficiencyEstimand ?? "unavailable")}</p><p class="metric"><strong>Primary token delta:</strong> ${displayPercent(report.comparison.primaryEfficiencyDeltaPercent)}</p><p class="metric"><strong>Primary ratio 95% CI:</strong> ${primaryConfidence ? `${display(primaryConfidence.lower, 4)}–${display(primaryConfidence.upper, 4)}` : "n/a"}</p><p class="metric"><strong>Fixed-workload ratio:</strong> ${display(report.comparison.fixedWorkloadFamilyFreshTokenRatio, 4)}${fixedWorkloadConfidence ? ` (${display(fixedWorkloadConfidence.lower, 4)}–${display(fixedWorkloadConfidence.upper, 4)})` : ""}</p><p class="metric"><strong>Fixed-workload coverage:</strong> ${report.comparison.fixedWorkloadFamilyCoverage?.usableScenarioFamilies ?? 0}/${report.comparison.fixedWorkloadFamilyCoverage?.expectedScenarioFamilies ?? 0} families</p><p class="metric"><strong>Successful-pair diagnostic role:</strong> ${htmlEscape(report.comparison.successfulPairEfficiencyRole ?? "blocking")}</p><p class="metric"><strong>Successful-pair token delta:</strong> ${displayPercent(report.comparison.freshTokenDeltaPercent)}</p><p class="metric"><strong>Successful-pair ratio 95% CI:</strong> ${confidence ? `${display(confidence.lower, 4)}–${display(confidence.upper, 4)}` : "n/a"}</p><p class="metric"><strong>Normalized API-equivalent text-token cost ratio:</strong> ${display(normalizedCost?.ratio, 4)}${normalizedCostConfidence ? ` (${display(normalizedCostConfidence.lower, 4)}–${display(normalizedCostConfidence.upper, 4)})` : ""}</p><p class="metric"><strong>Normalized-cost gate:</strong> ${report.comparison.normalizedCostGate === null ? "n/a" : report.comparison.normalizedCostGate ? "PASS" : "FAIL"}</p><p class="metric"><strong>Failure-aware family ratio:</strong> ${display(report.comparison.failureAwareFamilyFreshTokenRatio, 4)}${failureAwareFamilyConfidence ? ` (${display(failureAwareFamilyConfidence.lower, 4)}–${display(failureAwareFamilyConfidence.upper, 4)})` : ""}</p><p class="metric"><strong>Failure-aware pooled ratio:</strong> ${display(report.comparison.failureAwareFreshTokenRatio, 4)}</p><p class="metric"><strong>Duration-ratio delta:</strong> ${displayPercent(report.comparison.durationDeltaPercent)}</p><p class="metric"><strong>Duration ratio 95% CI:</strong> ${durationConfidence ? `${display(durationConfidence.lower, 4)}–${display(durationConfidence.upper, 4)}` : "n/a"}</p><p class="metric"><strong>Performance gate:</strong> ${report.comparison.performanceGate === null ? "n/a" : report.comparison.performanceGate ? "PASS" : "FAIL"}</p><p class="metric"><strong>Provider-reported cost-ratio delta:</strong> ${displayPercent(report.comparison.costDeltaPercent)}</p><p class="metric"><strong>Comparable pairs:</strong> ${report.comparison.pairedUsageRuns}</p><p class="metric"><strong>Scenario families:</strong> ${report.comparison.pairedUsageScenarios ?? 0}</p><p class="metric"><strong>Complete families:</strong> ${report.comparison.pairedCompleteScenarios ?? 0}</p><p class="metric"><strong>Duration families:</strong> ${report.comparison.pairedCompleteDurationScenarios ?? 0}</p><p class="metric"><strong>Outcome families:</strong> ${report.comparison.pairedOutcomeScenarios ?? 0}</p><p class="metric"><strong>Pair wins:</strong> ${htmlEscape(candidateLabel)} ${report.comparison.pairedFreshTokenWins[candidateKey]} · ${htmlEscape(baselineLabel)} ${report.comparison.pairedFreshTokenWins[baselineKey]} · ties ${report.comparison.pairedFreshTokenWins.ties}</p>
288
+ <p class="metric"><strong>Comparison:</strong> ${htmlEscape(candidateLabel)} vs ${htmlEscape(baselineLabel)}</p><p class="metric"><strong>Purpose:</strong> ${htmlEscape(report.comparison.purpose ?? "unspecified")}</p><p class="metric"><strong>Claim tier:</strong> ${htmlEscape(report.comparison.claimEligibility?.achievedTier ?? "unavailable")}</p><p class="metric"><strong>Token claim scope:</strong> ${htmlEscape(report.comparison.claimEligibility?.tokenClaimScope ?? "unavailable")}</p>${report.comparison.tokenClaimUnavailableReason ? `<p class="metric"><strong>Token claim restriction:</strong> ${htmlEscape(report.comparison.tokenClaimUnavailableReason)}</p>` : ""}<p class="metric"><strong>Verdict:</strong> ${htmlEscape(report.verdict.status)}</p><p class="metric"><strong>Protocol:</strong> ${report.comparison.comparisonProtocolGate?.passed ? "PASS" : `FAIL (${htmlEscape((report.comparison.comparisonProtocolGate?.failedChecks ?? []).join(", ") || "missing evidence")})`}</p><p class="metric"><strong>Codex-relative gate:</strong> ${report.comparison.codexRelativeEfficiencyGate === null ? "n/a" : report.comparison.codexRelativeEfficiencyGate ? "PASS" : "FAIL"}</p><p class="metric"><strong>Total token traffic:</strong> ${display(codexRelative?.totalTokenTraffic?.ratio, 4)}${codexRelativeTrafficConfidence ? ` (${display(codexRelativeTrafficConfidence.lower, 4)}–${display(codexRelativeTrafficConfidence.upper, 4)})` : ""} · upper ≤ ${display(codexRelative?.policy?.maximumTotalTokenTrafficRatioUpper95, 2)}</p><p class="metric"><strong>API-equivalent cost:</strong> ${display(codexRelative?.apiEquivalentCost?.ratio, 4)}${codexRelativeCostConfidence ? ` (${display(codexRelativeCostConfidence.lower, 4)}–${display(codexRelativeCostConfidence.upper, 4)})` : ""} · upper ≤ ${display(codexRelative?.policy?.maximumApiEquivalentCostRatioUpper95, 2)}</p><p class="metric"><strong>Subagent traffic:</strong> ${displayRatioPercent(codexRelative?.subagents?.trafficShare)} · ${codexRelative?.subagents?.sessions ?? "n/a"} sessions</p><p class="metric"><strong>Provider wire:</strong> ${report.comparison.providerWireSurfaceGate === null ? "n/a" : report.comparison.providerWireSurfaceGate ? "PASS" : "FAIL"} (${report.comparison.providerWireEvidence?.verifiedRuns ?? 0}/${report.comparison.providerWireEvidence?.runs ?? 0} runs, ${(report.comparison.providerWireEvidence?.driftGroups ?? []).length} drift groups)</p><p class="metric"><strong>Causal receipt:</strong> ${report.comparison.causalContextEvidenceGate === null ? "n/a" : report.comparison.causalContextEvidenceGate ? "PASS" : "FAIL"} (current v${causalContext?.requiredSchemaVersion ?? "?"} ${causalContext?.currentAvailableRuns ?? 0}/${causalContext?.runs ?? 0} runs)</p><p class="metric"><strong>Host readiness:</strong> ${report.comparison.hostReadinessGate === null ? "n/a" : report.comparison.hostReadinessGate ? "PASS" : "FAIL"} (${hostReadiness?.validReceiptCount ?? 0}/${hostReadiness?.receiptCount ?? 0} valid receipts · ${htmlEscape(hostReadiness?.windowCoverage ?? "n/a")} coverage)</p><p class="metric"><strong>Causal packs:</strong> ${causalAggregates ? `${causalAggregates.packCounts.offered}/${causalAggregates.packCounts.delivered}/${causalAggregates.packCounts.injected} offered/delivered/injected · ${causalAggregates.estimatedTokens.injected} injected estimated tokens · ${causalAggregates.selectedItemCounts.injected} selected items` : "unavailable"}</p><p class="metric"><strong>Causal direct rereads:</strong> ${causalAggregates ? `${causalAggregates.directFallbackRereads.successfulCalls} successful direct-path calls · ${causalAggregates.directFallbackRereads.shellToolCallsObserved} shell calls after injection` : "unavailable"}</p><p class="metric"><strong>Causal edit recovery:</strong> ${causalAggregates?.editRecoveryContext ? `${causalAggregates.editRecoveryContext.count ?? "n/a"} contexts · ${causalAggregates.editRecoveryContext.injectedChars ?? "n/a"} chars · ${causalAggregates.editRecoveryContext.injectedEstimatedTokens ?? "n/a"} estimated tokens · ${htmlEscape(causalAggregates.editRecoveryContext.evidenceCoverage?.status ?? "unavailable")} evidence` : "unavailable"}</p><p class="metric"><strong>Suite gate:</strong> ${report.comparison.suiteGate ? report.comparison.suiteGate.passed ? "PASS" : "FAIL" : "n/a"}</p><p class="metric"><strong>Infrastructure retries:</strong> ${report.infrastructure?.retries ?? 0}</p><p class="metric"><strong>Stability gate:</strong> ${report.comparison.stabilityGate === null ? "n/a" : report.comparison.stabilityGate ? "PASS" : "FAIL"}</p><p class="metric"><strong>Primary estimand:</strong> ${htmlEscape(report.comparison.primaryEfficiencyEstimand ?? "unavailable")}</p><p class="metric"><strong>Primary token delta:</strong> ${displayPercent(report.comparison.primaryEfficiencyDeltaPercent)}</p><p class="metric"><strong>Primary ratio 95% CI:</strong> ${primaryConfidence ? `${display(primaryConfidence.lower, 4)}–${display(primaryConfidence.upper, 4)}` : "n/a"}</p><p class="metric"><strong>Fixed-workload ratio:</strong> ${display(report.comparison.fixedWorkloadFamilyFreshTokenRatio, 4)}${fixedWorkloadConfidence ? ` (${display(fixedWorkloadConfidence.lower, 4)}–${display(fixedWorkloadConfidence.upper, 4)})` : ""}</p><p class="metric"><strong>Fixed-workload coverage:</strong> ${report.comparison.fixedWorkloadFamilyCoverage?.usableScenarioFamilies ?? 0}/${report.comparison.fixedWorkloadFamilyCoverage?.expectedScenarioFamilies ?? 0} families</p><p class="metric"><strong>Successful-pair diagnostic role:</strong> ${htmlEscape(report.comparison.successfulPairEfficiencyRole ?? "blocking")}</p><p class="metric"><strong>Successful-pair token delta:</strong> ${displayPercent(report.comparison.freshTokenDeltaPercent)}</p><p class="metric"><strong>Successful-pair ratio 95% CI:</strong> ${confidence ? `${display(confidence.lower, 4)}–${display(confidence.upper, 4)}` : "n/a"}</p><p class="metric"><strong>Normalized API-equivalent text-token cost ratio:</strong> ${display(normalizedCost?.ratio, 4)}${normalizedCostConfidence ? ` (${display(normalizedCostConfidence.lower, 4)}–${display(normalizedCostConfidence.upper, 4)})` : ""}</p><p class="metric"><strong>Normalized-cost gate:</strong> ${report.comparison.normalizedCostGate === null ? "n/a" : report.comparison.normalizedCostGate ? "PASS" : "FAIL"}</p><p class="metric"><strong>Failure-aware family ratio:</strong> ${display(report.comparison.failureAwareFamilyFreshTokenRatio, 4)}${failureAwareFamilyConfidence ? ` (${display(failureAwareFamilyConfidence.lower, 4)}–${display(failureAwareFamilyConfidence.upper, 4)})` : ""}</p><p class="metric"><strong>Failure-aware pooled ratio:</strong> ${display(report.comparison.failureAwareFreshTokenRatio, 4)}</p><p class="metric"><strong>Duration-ratio delta:</strong> ${displayPercent(report.comparison.durationDeltaPercent)}</p><p class="metric"><strong>Duration ratio 95% CI:</strong> ${durationConfidence ? `${display(durationConfidence.lower, 4)}–${display(durationConfidence.upper, 4)}` : "n/a"}</p><p class="metric"><strong>Performance gate:</strong> ${report.comparison.performanceGate === null ? "n/a" : report.comparison.performanceGate ? "PASS" : "FAIL"}</p><p class="metric"><strong>Provider-reported cost-ratio delta:</strong> ${displayPercent(report.comparison.costDeltaPercent)}</p><p class="metric"><strong>Comparable pairs:</strong> ${report.comparison.pairedUsageRuns}</p><p class="metric"><strong>Scenario families:</strong> ${report.comparison.pairedUsageScenarios ?? 0}</p><p class="metric"><strong>Complete families:</strong> ${report.comparison.pairedCompleteScenarios ?? 0}</p><p class="metric"><strong>Duration families:</strong> ${report.comparison.pairedCompleteDurationScenarios ?? 0}</p><p class="metric"><strong>Outcome families:</strong> ${report.comparison.pairedOutcomeScenarios ?? 0}</p><p class="metric"><strong>Pair wins:</strong> ${htmlEscape(candidateLabel)} ${report.comparison.pairedFreshTokenWins[candidateKey]} · ${htmlEscape(baselineLabel)} ${report.comparison.pairedFreshTokenWins[baselineKey]} · ties ${report.comparison.pairedFreshTokenWins.ties}</p>
275
289
  <p class="metric"><strong>Observational timing (${htmlEscape(baselineLabel)}):</strong> ${htmlEscape(timingSummary(report.timingDiagnostics, baselineSurface))}</p><p class="metric"><strong>Observational timing (${htmlEscape(candidateLabel)}):</strong> ${htmlEscape(timingSummary(report.timingDiagnostics, candidateSurface))}</p>
276
290
  <p class="note">Timing uses privacy-safe monotonic JSONL receipt boundaries only. Missing boundaries remain unavailable; these diagnostics do not alter authoritative duration or any release/spend gate.</p>
277
291
  <p class="metric"><strong>Edit-recovery failures:</strong> ${causalAggregates?.editRecoveryContext?.failuresObserved ?? "n/a"} observed · ${causalAggregates?.editRecoveryContext?.suppressedFailures ?? "n/a"} safely suppressed</p>