@piagent/platform 1.5.5 → 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.
- package/CHANGELOG.md +166 -0
- package/README.md +25 -21
- package/README.vi.md +34 -5
- package/adapters/web-frontend/profile.json +2 -4
- package/architecture/layers.json +18 -3
- package/benchmarks/deep-logic-v1/SPECIALIST_PROTOCOL.vi.md +122 -0
- package/benchmarks/deep-logic-v1/grade.mjs +272 -10
- package/benchmarks/deep-logic-v1/project/apps/admin/src/billing-summary.js +3 -0
- package/benchmarks/deep-logic-v1/project/benchmark-contract/public-smoke.test.js +166 -0
- package/benchmarks/deep-logic-v1/project/package.json +1 -1
- package/benchmarks/deep-logic-v1/project/packages/billing/src/close-period.js +3 -0
- package/benchmarks/deep-logic-v1/project/packages/billing/src/plan-timeline.js +3 -0
- package/benchmarks/deep-logic-v1/project/test/smoke.test.js +7 -1
- package/benchmarks/deep-logic-v1/prompts/budgeted-context-graph.md +2 -0
- package/benchmarks/deep-logic-v1/prompts/fair-dependency-scheduler.md +2 -0
- package/benchmarks/deep-logic-v1/prompts/layered-policy-resolution.md +2 -0
- package/benchmarks/deep-logic-v1/prompts/resumable-stream-assembly.md +3 -1
- package/benchmarks/deep-logic-v1/prompts/revision-event-reconciliation.md +2 -0
- package/benchmarks/deep-logic-v1/prompts/temporal-usage-billing-close.md +123 -0
- package/benchmarks/deep-logic-v1/prompts/transactional-config-merge.md +2 -0
- package/benchmarks/deep-logic-v1/suite.json +51 -3
- package/benchmarks/deep-logic-v1/variant.mjs +22 -1
- package/benchmarks/production-v1/spend-control.v1.json +92 -0
- package/benchmarks/production-v1/suite.json +46 -3
- package/catalog/capabilities.json +18 -18
- package/docs/authority-manifest.md +1 -1
- package/docs/auto-delegation-policy.md +38 -73
- package/docs/command-reference-vietnamese.md +27 -35
- package/docs/context-engine.md +12 -4
- package/docs/context-window-policy.md +37 -1
- package/docs/distribution-standard.md +7 -7
- package/docs/en/architecture.md +27 -13
- package/docs/languages.json +4 -4
- package/docs/model-options.md +8 -5
- package/docs/operator-manual-vietnamese.md +27 -45
- package/docs/project-adapters.md +2 -2
- package/docs/publishing-for-teams.md +10 -0
- package/docs/quality-benchmark.md +427 -62
- package/docs/release-install-policy.md +10 -9
- package/docs/runtime-harness-standard.md +3 -3
- package/docs/runtime-policy-design.md +4 -4
- package/docs/runtime-quality-baseline.md +13 -6
- package/docs/security-threat-model.md +2 -2
- package/docs/subagent-orchestration-capabilities.md +19 -51
- package/docs/subagents-and-multiagent.md +21 -47
- package/docs/task-implementation-contract.md +3 -3
- package/docs/task-lifecycle-vietnamese.md +3 -3
- package/docs/team-onboarding.md +2 -2
- package/docs/usage-observability.md +7 -2
- package/docs/vi/architecture.md +27 -13
- package/docs-site/architecture.html +1 -1
- package/docs-site/benchmark.html +89 -95
- package/docs-site/commands.html +1 -1
- package/docs-site/content/benchmark.html +88 -94
- package/docs-site/content/en/benchmark.html +134 -90
- package/docs-site/content/en/index.html +19 -19
- package/docs-site/content/en/runtime.html +4 -4
- package/docs-site/content/en/whats-new.html +12 -1
- package/docs-site/content/en/workflows.html +2 -2
- package/docs-site/content/index.html +19 -19
- package/docs-site/content/runtime.html +4 -4
- package/docs-site/content/whats-new.html +12 -1
- package/docs-site/content/workflows.html +2 -2
- package/docs-site/context-engine.html +1 -1
- package/docs-site/en/architecture.html +1 -1
- package/docs-site/en/benchmark.html +135 -91
- package/docs-site/en/commands.html +1 -1
- package/docs-site/en/context-engine.html +1 -1
- package/docs-site/en/index.html +20 -20
- package/docs-site/en/mcp-approval.html +1 -1
- package/docs-site/en/mcp-auth.html +1 -1
- package/docs-site/en/mcp-servers.html +1 -1
- package/docs-site/en/mcp.html +1 -1
- package/docs-site/en/permissions.html +1 -1
- package/docs-site/en/profiles.html +1 -1
- package/docs-site/en/quickstart.html +1 -1
- package/docs-site/en/runtime.html +5 -5
- package/docs-site/en/scope.html +1 -1
- package/docs-site/en/security.html +1 -1
- package/docs-site/en/team.html +1 -1
- package/docs-site/en/whats-new.html +13 -2
- package/docs-site/en/workflows.html +3 -3
- package/docs-site/index.html +20 -20
- package/docs-site/mcp-approval.html +1 -1
- package/docs-site/mcp-auth.html +1 -1
- package/docs-site/mcp-servers.html +1 -1
- package/docs-site/mcp.html +1 -1
- package/docs-site/permissions.html +1 -1
- package/docs-site/profiles.html +1 -1
- package/docs-site/quickstart.html +1 -1
- package/docs-site/runtime.html +5 -5
- package/docs-site/scope.html +1 -1
- package/docs-site/security.html +1 -1
- package/docs-site/team.html +1 -1
- package/docs-site/whats-new.html +13 -2
- package/docs-site/workflows.html +3 -3
- package/evals/fixtures/benchmark-assurance-evidence.invalid.json +1 -1
- package/evals/fixtures/benchmark-assurance-evidence.valid.json +1 -1
- package/evals/fixtures/codex-relative-efficiency-v1.invalid.json +4 -0
- package/evals/fixtures/codex-relative-efficiency-v1.valid.json +94 -0
- package/evals/fixtures/helper-request.invalid.json +1 -1
- package/evals/fixtures/helper-request.valid.json +1 -1
- package/evals/fixtures/piagent-webui/session-live-state-v1.invalid.json +18 -0
- package/evals/fixtures/piagent-webui/session-live-state-v1.valid.json +27 -0
- package/evals/fixtures/piagent-webui/subagent-tree-v1.valid.json +7 -0
- package/evals/fixtures/task-authority-snapshot.valid.json +4 -4
- package/evals/fs4-readiness-matrix.v1.json +2 -2
- package/evals/fs5-causal-arm.v1.json +3 -3
- package/evals/fs5-pilot-protocol.v1.json +3 -3
- package/evals/fs5-pilot-protocol.v2.json +8 -8
- package/evals/fs5-pilot-protocol.v3.json +8 -8
- package/evals/fs5-pilot-protocol.v4.json +7 -6
- package/evals/fs5-pilot-protocol.v5.json +9 -7
- package/evals/private-holdout-v1/public-exposure.v1.json +1 -1
- package/evals/runtime-conformance-v1/README.md +43 -0
- package/evals/runtime-conformance-v1/evaluate-paid-canary.mjs +198 -0
- package/evals/runtime-conformance-v1/lane.json +57 -0
- package/evals/runtime-conformance-v1/paid-canary.json +31 -0
- package/evals/runtime-conformance-v1/runner.mjs +456 -0
- package/package.json +3 -1
- package/packages/piagent-core/README.md +13 -4
- package/packages/piagent-core/benchmark/benchmark-assurance.js +4 -1
- package/packages/piagent-core/benchmark/benchmark-bootstrap.js +91 -9
- package/packages/piagent-core/benchmark/benchmark-claim-restrictions.js +38 -7
- package/packages/piagent-core/benchmark/benchmark-cli.js +7 -7
- package/packages/piagent-core/benchmark/benchmark-codex-relative-efficiency.js +698 -0
- package/packages/piagent-core/benchmark/benchmark-codex.js +3 -1
- package/packages/piagent-core/benchmark/benchmark-comparison.js +271 -2
- package/packages/piagent-core/benchmark/benchmark-core.js +736 -664
- package/packages/piagent-core/benchmark/benchmark-execution-guard.js +7 -5
- package/packages/piagent-core/benchmark/benchmark-forensics.js +441 -4
- package/packages/piagent-core/benchmark/benchmark-host-readiness.js +639 -0
- package/packages/piagent-core/benchmark/benchmark-matrix.js +22 -4
- package/packages/piagent-core/benchmark/benchmark-normalized-cost.js +317 -0
- package/packages/piagent-core/benchmark/benchmark-preflight.js +5 -1
- package/packages/piagent-core/benchmark/benchmark-process.js +6 -5
- package/packages/piagent-core/benchmark/benchmark-provider-free-evidence.js +345 -0
- package/packages/piagent-core/benchmark/benchmark-provider-wire.js +126 -0
- package/packages/piagent-core/benchmark/benchmark-record-validation.js +252 -0
- package/packages/piagent-core/benchmark/benchmark-report.js +130 -12
- package/packages/piagent-core/benchmark/benchmark-resume-recovery.js +14 -0
- package/packages/piagent-core/benchmark/benchmark-runner-policy.js +26 -0
- package/packages/piagent-core/benchmark/benchmark-runtime-causal.js +244 -0
- package/packages/piagent-core/benchmark/benchmark-stage-diagnostic.js +979 -0
- package/packages/piagent-core/benchmark/benchmark-statistics.js +64 -0
- package/packages/piagent-core/benchmark/benchmark-stop-policy.js +8 -5
- package/packages/piagent-core/benchmark/benchmark-suite-identity.js +31 -0
- package/packages/piagent-core/benchmark/benchmark-suite-runtime.js +13 -9
- package/packages/piagent-core/benchmark/benchmark-suite.js +149 -2
- package/packages/piagent-core/benchmark/benchmark-summary-support.js +380 -0
- package/packages/piagent-core/benchmark/benchmark-timing-diagnostics.js +971 -0
- package/packages/piagent-core/benchmark/benchmark-usage.js +322 -0
- package/packages/piagent-core/benchmark/benchmark-workflow.js +166 -0
- package/packages/piagent-core/capabilities/runtime-integrity.js +3 -0
- package/packages/piagent-core/docs/context-efficiency-improvement-plan.md +1080 -0
- package/packages/piagent-core/extensions/acceptance-behavior-proof.js +806 -0
- package/packages/piagent-core/extensions/acceptance-contract-semantics.js +83 -69
- package/packages/piagent-core/extensions/acceptance-error-classes.js +160 -0
- package/packages/piagent-core/extensions/acceptance-executable-evidence.js +12 -9
- package/packages/piagent-core/extensions/acceptance-receipt.js +123 -59
- package/packages/piagent-core/extensions/acceptance-state-machine-evidence.js +518 -0
- package/packages/piagent-core/extensions/acceptance-test-binding-evidence.js +60 -0
- package/packages/piagent-core/extensions/context-efficiency-metrics.js +302 -0
- package/packages/piagent-core/extensions/context-efficiency-report.js +167 -0
- package/packages/piagent-core/extensions/context-engine.js +149 -156
- package/packages/piagent-core/extensions/context-evidence.js +48 -0
- package/packages/piagent-core/extensions/context-import-links.js +296 -0
- package/packages/piagent-core/extensions/context-index-policy.js +4 -0
- package/packages/piagent-core/extensions/context-query-paths.js +57 -0
- package/packages/piagent-core/extensions/context-telemetry-integrity.js +65 -0
- package/packages/piagent-core/extensions/criterion-context-pack.js +435 -7
- package/packages/piagent-core/extensions/criterion-graph.js +82 -9
- package/packages/piagent-core/extensions/fallback-base-policy.ts +101 -0
- package/packages/piagent-core/extensions/guard-types.ts +6 -0
- package/packages/piagent-core/extensions/javascript-regex-evidence.js +32 -0
- package/packages/piagent-core/extensions/piagent-guard.ts +420 -260
- package/packages/piagent-core/extensions/task-contract-view.js +17 -3
- package/packages/piagent-core/extensions/task-lifecycle.js +39 -2
- package/packages/piagent-core/extensions/task-state.js +109 -142
- package/packages/piagent-core/extensions/verification-intelligence.js +52 -13
- package/packages/piagent-core/extensions/workspace-evidence-roots.js +193 -0
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-core/policies/base-policy.json +44 -2
- package/packages/piagent-core/policy/authority-manifest.v1.json +3 -3
- package/packages/piagent-core/prompts/be-to-fe.md +2 -8
- package/packages/piagent-core/prompts/plan.md +1 -1
- package/packages/piagent-core/prompts/platform-improve.md +2 -6
- package/packages/piagent-core/prompts/review.md +2 -7
- package/packages/piagent-core/prompts/scout.md +1 -1
- package/packages/piagent-core/prompts/task.md +4 -3
- package/packages/piagent-core/runtime/context/context-delivery.ts +103 -0
- package/packages/piagent-core/runtime/context/context-delta-shadow.ts +53 -0
- package/packages/piagent-core/runtime/context/context-efficiency-format.ts +47 -0
- package/packages/piagent-core/runtime/context/context-evidence-qualification.ts +32 -0
- package/packages/piagent-core/runtime/context/prefix-telemetry.ts +47 -0
- package/packages/piagent-core/runtime/context/repository-memory-hints.ts +27 -0
- package/packages/piagent-core/runtime/hooks/agent-prompt-telemetry.ts +56 -0
- package/packages/piagent-core/runtime/hooks/agent-start-hook.ts +162 -102
- package/packages/piagent-core/runtime/hooks/completion-hook.ts +12 -12
- package/packages/piagent-core/runtime/hooks/input-hook.ts +17 -1
- package/packages/piagent-core/runtime/hooks/session-hooks.ts +22 -2
- package/packages/piagent-core/runtime/hooks/session-start-hook.ts +107 -3
- package/packages/piagent-core/runtime/hooks/tool-result-content-guards.ts +95 -0
- package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +134 -166
- package/packages/piagent-core/runtime/hooks/tool-result-value-helpers.ts +66 -0
- package/packages/piagent-core/runtime/inspection/activity-event-adapter.ts +4 -2
- package/packages/piagent-core/runtime/inspection/activity-recovery.ts +104 -0
- package/packages/piagent-core/runtime/inspection/bounded-emission-guard.ts +286 -0
- package/packages/piagent-core/runtime/inspection/runtime-event-store.ts +37 -7
- package/packages/piagent-core/runtime/inspection/task-compaction-history.ts +1 -1
- package/packages/piagent-core/runtime/inspection/task-handoff-history.ts +1 -1
- package/packages/piagent-core/runtime/inspection/task-subagent-tree.ts +27 -4
- package/packages/piagent-core/runtime/inspection/tool-failure-classification.ts +70 -0
- package/packages/piagent-core/runtime/inspection/webui-snapshot.ts +73 -9
- package/packages/piagent-core/runtime/model/authenticated-catalog.ts +17 -9
- package/packages/piagent-core/runtime/model/openai-codex-reasoning.ts +83 -0
- package/packages/piagent-core/runtime/model/provider-wire-fingerprint.ts +238 -0
- package/packages/piagent-core/runtime/orchestration/helper-lifecycle.ts +16 -12
- package/packages/piagent-core/runtime/orchestration/minimal-delegation-policy.ts +71 -0
- package/packages/piagent-core/runtime/orchestration/owned-work-budget.ts +28 -20
- package/packages/piagent-core/runtime/orchestration/role-policy.ts +27 -9
- package/packages/piagent-core/runtime/orchestration/subagent-tool-policy.ts +329 -0
- package/packages/piagent-core/runtime/policy/block-remedy.ts +0 -4
- package/packages/piagent-core/runtime/product/activity-inspector.ts +7 -2
- package/packages/piagent-core/runtime/product/efficiency-metrics.ts +7 -2
- package/packages/piagent-core/runtime/quality/edit-freshness-guard.ts +102 -0
- package/packages/piagent-core/runtime/quality/exact-output-contract.ts +22 -11
- package/packages/piagent-core/runtime/quality/performance-assurance-signals.ts +23 -0
- package/packages/piagent-core/runtime/quality/performance-assurance.ts +9 -5
- package/packages/piagent-core/runtime/recovery/continuation-budget.ts +1 -1
- package/packages/piagent-core/runtime/recovery/edit-recovery-context.ts +113 -0
- package/packages/piagent-core/runtime/recovery/edit-recovery-delivery.ts +42 -0
- package/packages/piagent-core/runtime/recovery/handoff-projection.ts +4 -1
- package/packages/piagent-core/runtime/recovery/pristine-task-policy-refresh.ts +91 -0
- package/packages/piagent-core/runtime/recovery/recovery-policy.ts +7 -4
- package/packages/piagent-core/runtime/recovery/resume-state.ts +112 -14
- package/packages/piagent-core/runtime/recovery/semantic-repair-handshake.ts +60 -13
- package/packages/piagent-core/runtime/recovery/semantic-repair-runtime.ts +55 -2
- package/packages/piagent-core/runtime/recovery/task-evidence-coverage-refresh.ts +217 -0
- package/packages/piagent-core/runtime/registration/context-commands.ts +82 -7
- package/packages/piagent-core/runtime/registration/knowledge-tools.ts +9 -5
- package/packages/piagent-core/runtime/registration/operator-request-intake.ts +49 -0
- package/packages/piagent-core/runtime/registration/policy-tools.ts +50 -15
- package/packages/piagent-core/runtime/registration/session-commands.ts +1 -1
- package/packages/piagent-core/runtime/registration/task-completion-tools.ts +61 -25
- package/packages/piagent-core/runtime/registration/task-evidence-tools.ts +21 -12
- package/packages/piagent-core/runtime/registration/task-start-guidance.ts +169 -0
- package/packages/piagent-core/runtime/registration/task-start-manifest.ts +54 -0
- package/packages/piagent-core/runtime/registration/task-start-retry-helpers.ts +37 -0
- package/packages/piagent-core/runtime/registration/task-start-tool.ts +108 -103
- package/packages/piagent-core/runtime/runtime-limits.ts +16 -2
- package/packages/piagent-core/runtime/session/adaptive-context-analysis.ts +461 -0
- package/packages/piagent-core/runtime/session/adaptive-context-governor.ts +464 -0
- package/packages/piagent-core/runtime/session/adaptive-context-ledger.ts +265 -0
- package/packages/piagent-core/runtime/session/message-signals.ts +7 -3
- package/packages/piagent-core/runtime/session/operator-request-carry.ts +44 -0
- package/packages/piagent-core/runtime/session/runtime-state.ts +161 -5
- package/packages/piagent-core/runtime/session/source-checkout-read-grants.ts +35 -0
- package/packages/piagent-core/runtime/session/system-prompt.ts +76 -14
- package/packages/piagent-core/runtime/session/task-contract-presentation.ts +39 -0
- package/packages/piagent-core/runtime/tools/apply-patch-tool.ts +500 -0
- package/packages/piagent-core/runtime/tools/phase-tools.ts +8 -8
- package/packages/piagent-core/runtime/tools/tool-groups.ts +12 -2
- package/packages/piagent-core/runtime/trajectory/trajectory-runtime.ts +2 -1
- package/packages/piagent-core/runtime/verification/exact-verifier-reuse.ts +101 -0
- package/packages/piagent-core/runtime/workflows/runtime-intake-compaction.ts +164 -0
- package/packages/piagent-core/runtime/workflows/task-intake.ts +207 -38
- package/packages/piagent-core/security/sensitive-data.js +13 -218
- package/packages/piagent-core/security/sensitive-project-file.js +42 -0
- package/packages/piagent-core/security/sensitive-source-expression.js +330 -0
- package/packages/piagent-core/security/sensitive-source-formats.js +394 -0
- package/packages/piagent-core/security/sensitive-text.js +234 -0
- package/packages/piagent-core/subagents/piagent-oracle.md +5 -3
- package/packages/piagent-core/subagents/piagent-planner.md +6 -4
- package/packages/piagent-core/subagents/piagent-reviewer.md +5 -3
- package/packages/piagent-core/subagents/piagent-scout.md +4 -2
- package/packages/piagent-core/subagents/piagent-worker.md +7 -5
- package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-rD9WJKxs.js → MarkdownMessage-B4XehTCU.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/index-CgOEyRPG.js +176 -0
- package/packages/piagent-webui/dist/client/index.html +1 -1
- package/packages/piagent-webui/extension/piagent-webui.ts +3 -1
- package/packages/piagent-webui/extension/same-session-bridge.ts +1 -1
- package/packages/piagent-webui/extension/session-stream-adapter.ts +33 -10
- package/packages/piagent-webui/gateway/gateway-events.ts +109 -5
- package/packages/piagent-webui/gateway/gateway-service.ts +3 -0
- package/packages/piagent-webui/gateway/gateway-session-stream.ts +122 -20
- package/packages/piagent-webui/gateway/session-command-controller.ts +18 -3
- package/packages/piagent-webui/gateway/session-effective-options.ts +47 -0
- package/packages/piagent-webui/gateway/session-live-state.ts +21 -0
- package/packages/piagent-webui/gateway/session-operation-lifecycle.ts +237 -0
- package/packages/piagent-webui/gateway/session-operation-retry-control.ts +38 -0
- package/packages/piagent-webui/gateway/session-operation-start.ts +5 -1
- package/packages/piagent-webui/gateway/session-operation-watchdog.ts +165 -0
- package/packages/piagent-webui/gateway/session-runtime-factory.ts +45 -0
- package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +141 -125
- package/packages/piagent-webui/ownership/session-lease-store.ts +5 -2
- package/packages/piagent-webui/server/core-inspection-provider.ts +2 -1
- package/packages/piagent-webui/server/loopback-server.ts +8 -0
- package/packages/piagent-webui/server/transcript-projection.ts +113 -9
- package/packages/piagent-webui/shared/text-visibility.ts +10 -0
- package/schemas/codex-relative-efficiency-v1.schema.json +155 -0
- package/schemas/piagent-webui/catalog-v1.json +9 -0
- package/schemas/piagent-webui/gateway-protocol-v1.schema.json +53 -3
- package/schemas/piagent-webui/runtime-event-v2.schema.json +15 -5
- package/schemas/piagent-webui/session-live-state-v1.schema.json +76 -0
- package/schemas/piagent-webui/subagent-tree-v1.schema.json +11 -1
- package/schemas/project-profile.schema.json +1 -1
- package/schemas/task-contract.schema.json +27 -1
- package/scripts/benchmark-runner-core.mjs +367 -363
- package/scripts/benchmark-runner-finalization.mjs +313 -0
- package/scripts/benchmark-runner-host-readiness.mjs +94 -0
- package/scripts/benchmark-runner-support.mjs +200 -0
- package/scripts/benchmark-session.mjs +95 -41
- package/scripts/configure-model-scope.sh +4 -3
- package/scripts/configure-subagents.sh +42 -34
- package/scripts/helper-evaluation.mjs +2 -2
- package/scripts/install-global.sh +2 -2
- package/scripts/pi-usage-history.mjs +37 -10
- package/scripts/setup.sh +2 -2
- package/scripts/team-doctor.sh +1 -1
- package/scripts/verify-local.sh +10 -1
- package/templates/global/settings.json +2 -1
- package/packages/piagent-webui/dist/client/assets/index-BZRFw1u6.js +0 -174
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const SHA256 = /^[a-f0-9]{64}$/;
|
|
2
|
+
|
|
3
|
+
function requestedProviderModelId(requestedModel) {
|
|
4
|
+
const value = typeof requestedModel === "string" ? requestedModel.trim() : "";
|
|
5
|
+
if (!value) return null;
|
|
6
|
+
const separator = value.indexOf("/");
|
|
7
|
+
const modelId = separator >= 0 ? value.slice(separator + 1) : value;
|
|
8
|
+
return modelId && !modelId.includes("/") ? modelId : null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function requestedProviderReasoningEffort(requestedThinking) {
|
|
12
|
+
const value = typeof requestedThinking === "string" ? requestedThinking.trim() : "";
|
|
13
|
+
if (!value) return null;
|
|
14
|
+
if (value === "off") return "none";
|
|
15
|
+
if (value === "minimal") return "low";
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function sortedUnique(values) {
|
|
20
|
+
return [...new Set(values)].sort();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Reduces privacy-safe provider request fingerprints into per-run release
|
|
25
|
+
* evidence. Deferred tool-search batches are observed separately: changes to
|
|
26
|
+
* those hashes do not count as base system/tool prefix drift.
|
|
27
|
+
*/
|
|
28
|
+
export function buildBenchmarkProviderWireEvidence({
|
|
29
|
+
events,
|
|
30
|
+
requestedModel,
|
|
31
|
+
requestedThinking,
|
|
32
|
+
telemetryTruncated = false
|
|
33
|
+
}) {
|
|
34
|
+
const expectedModelId = requestedProviderModelId(requestedModel);
|
|
35
|
+
const expectedReasoningEffort = requestedProviderReasoningEffort(requestedThinking);
|
|
36
|
+
const wireEvents = (Array.isArray(events) ? events : [])
|
|
37
|
+
.filter((event) => event?.event === "provider_request_wire_surface");
|
|
38
|
+
const knownEvents = wireEvents.filter((event) => event.state === "known");
|
|
39
|
+
const instructionHashes = sortedUnique(knownEvents
|
|
40
|
+
.map((event) => event.instructionsHash)
|
|
41
|
+
.filter((value) => SHA256.test(value ?? "")));
|
|
42
|
+
const baseInstructionHashes = sortedUnique(knownEvents
|
|
43
|
+
.map((event) => event.baseInstructionsHash)
|
|
44
|
+
.filter((value) => SHA256.test(value ?? "")));
|
|
45
|
+
const orderedToolSurfaceHashes = sortedUnique(knownEvents
|
|
46
|
+
.map((event) => event.orderedToolSurfaceHash)
|
|
47
|
+
.filter((value) => SHA256.test(value ?? "")));
|
|
48
|
+
const deferredToolSurfaceHashes = sortedUnique(knownEvents
|
|
49
|
+
.map((event) => event.deferredToolSurfaceHash)
|
|
50
|
+
.filter((value) => SHA256.test(value ?? "")));
|
|
51
|
+
const unknownEvents = wireEvents.length - knownEvents.length;
|
|
52
|
+
const missingBaseHashEvents = knownEvents.filter((event) => (
|
|
53
|
+
!SHA256.test(event.instructionsHash ?? "")
|
|
54
|
+
|| !SHA256.test(event.baseInstructionsHash ?? "")
|
|
55
|
+
|| !SHA256.test(event.orderedToolSurfaceHash ?? "")
|
|
56
|
+
)).length;
|
|
57
|
+
const modelMismatchEvents = knownEvents.filter((event) => (
|
|
58
|
+
expectedModelId === null || event.providerModelId !== expectedModelId
|
|
59
|
+
)).length;
|
|
60
|
+
const reasoningMismatchEvents = knownEvents.filter((event) => (
|
|
61
|
+
expectedReasoningEffort === null || event.providerReasoningEffort !== expectedReasoningEffort
|
|
62
|
+
)).length;
|
|
63
|
+
const deferredToolBatchEvents = knownEvents.filter((event) => Number(event.deferredToolBatchCount ?? 0) > 0).length;
|
|
64
|
+
const checks = {
|
|
65
|
+
"telemetry-complete": telemetryTruncated !== true,
|
|
66
|
+
"wire-events-observed": wireEvents.length > 0,
|
|
67
|
+
"wire-events-known": wireEvents.length > 0 && unknownEvents === 0,
|
|
68
|
+
"requested-model-exact": wireEvents.length > 0 && modelMismatchEvents === 0,
|
|
69
|
+
"requested-reasoning-effort-exact": wireEvents.length > 0 && reasoningMismatchEvents === 0,
|
|
70
|
+
"base-instructions-available-and-stable": wireEvents.length > 0
|
|
71
|
+
&& missingBaseHashEvents === 0
|
|
72
|
+
&& instructionHashes.length === 1
|
|
73
|
+
&& baseInstructionHashes.length === 1,
|
|
74
|
+
"base-tool-surface-available-and-stable": wireEvents.length > 0 && missingBaseHashEvents === 0 && orderedToolSurfaceHashes.length === 1
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
schemaVersion: 1,
|
|
78
|
+
state: Object.values(checks).every(Boolean) ? "verified" : wireEvents.length > 0 ? "failed" : "unavailable",
|
|
79
|
+
passed: Object.values(checks).every(Boolean),
|
|
80
|
+
expectedModelId,
|
|
81
|
+
expectedReasoningEffort,
|
|
82
|
+
telemetryTruncated: telemetryTruncated === true,
|
|
83
|
+
wireEvents: wireEvents.length,
|
|
84
|
+
knownEvents: knownEvents.length,
|
|
85
|
+
unknownEvents,
|
|
86
|
+
missingBaseHashEvents,
|
|
87
|
+
modelMismatchEvents,
|
|
88
|
+
reasoningMismatchEvents,
|
|
89
|
+
instructionHashes,
|
|
90
|
+
baseInstructionHashes,
|
|
91
|
+
orderedToolSurfaceHashes,
|
|
92
|
+
deferred: {
|
|
93
|
+
toolSurfaceHashes: deferredToolSurfaceHashes,
|
|
94
|
+
toolBatchEvents: deferredToolBatchEvents,
|
|
95
|
+
maximumBatchCount: knownEvents.reduce((maximum, event) => Math.max(maximum, Number(event.deferredToolBatchCount ?? 0)), 0),
|
|
96
|
+
maximumToolCount: knownEvents.reduce((maximum, event) => Math.max(maximum, Number(event.deferredToolCount ?? 0)), 0)
|
|
97
|
+
},
|
|
98
|
+
checks
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function benchmarkProviderWireEvidenceMatchesRequest(evidence, requestedModel, requestedThinking) {
|
|
103
|
+
const expectedModelId = requestedProviderModelId(requestedModel);
|
|
104
|
+
const expectedReasoningEffort = requestedProviderReasoningEffort(requestedThinking);
|
|
105
|
+
return evidence?.schemaVersion === 1
|
|
106
|
+
&& evidence.passed === true
|
|
107
|
+
&& evidence.state === "verified"
|
|
108
|
+
&& evidence.expectedModelId === expectedModelId
|
|
109
|
+
&& evidence.expectedReasoningEffort === expectedReasoningEffort
|
|
110
|
+
&& expectedModelId !== null
|
|
111
|
+
&& expectedReasoningEffort !== null
|
|
112
|
+
&& evidence.telemetryTruncated === false
|
|
113
|
+
&& Number.isInteger(evidence.wireEvents) && evidence.wireEvents > 0
|
|
114
|
+
&& evidence.knownEvents === evidence.wireEvents
|
|
115
|
+
&& evidence.unknownEvents === 0
|
|
116
|
+
&& evidence.missingBaseHashEvents === 0
|
|
117
|
+
&& evidence.modelMismatchEvents === 0
|
|
118
|
+
&& evidence.reasoningMismatchEvents === 0
|
|
119
|
+
&& Array.isArray(evidence.instructionHashes) && evidence.instructionHashes.length === 1 && SHA256.test(evidence.instructionHashes[0])
|
|
120
|
+
&& Array.isArray(evidence.baseInstructionHashes) && evidence.baseInstructionHashes.length === 1 && SHA256.test(evidence.baseInstructionHashes[0])
|
|
121
|
+
&& Array.isArray(evidence.orderedToolSurfaceHashes) && evidence.orderedToolSurfaceHashes.length === 1 && SHA256.test(evidence.orderedToolSurfaceHashes[0]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function benchmarkRequestedProviderReasoningEffort(requestedThinking) {
|
|
125
|
+
return requestedProviderReasoningEffort(requestedThinking);
|
|
126
|
+
}
|