@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
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { hardenPrivateRetentionRoot, retainedWorkspaceMarker, writeBenchmarkRunManifest, writePrivateAtomic } from "./benchmark-forensics.js";
|
|
5
5
|
import { appendBenchmarkLedger, assertBenchmarkLedgerBinding, validateBenchmarkLedgerPrefix } from "./benchmark-ledger.js";
|
|
6
6
|
import { expectedBenchmarkRecord, pairedBenchmarkVariantMatched } from "./benchmark-record-validation.js";
|
|
7
|
+
import { canonicalBenchmarkTimingDiagnostics } from "./benchmark-timing-diagnostics.js";
|
|
7
8
|
|
|
8
9
|
function fail(message) {
|
|
9
10
|
const error = new Error(message);
|
|
@@ -29,6 +30,14 @@ function exactUsage(usage, usageStatus) {
|
|
|
29
30
|
&& usage.total === usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
function omitInvalidTimingDiagnostics(record) {
|
|
34
|
+
if (!record || typeof record !== "object") return record;
|
|
35
|
+
const timing = canonicalBenchmarkTimingDiagnostics(record.timingDiagnostics, record.surface, record.durationSeconds);
|
|
36
|
+
if (timing === undefined) delete record.timingDiagnostics;
|
|
37
|
+
else record.timingDiagnostics = timing;
|
|
38
|
+
return record;
|
|
39
|
+
}
|
|
40
|
+
|
|
32
41
|
export function persistUnacceptedBenchmarkAttempt({ runRoot, manifest, record, reason, forceTokenUnavailable = false }) {
|
|
33
42
|
const attempt = {
|
|
34
43
|
schemaVersion: 1,
|
|
@@ -63,6 +72,7 @@ export function clearRecoveredBenchmarkAttempts(manifest, record) {
|
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
export function stageMeasuredBenchmarkRecord({ runRoot, manifest, ledgerBinding, record, infrastructureFailures, index, expected, runId, suite, configurationDigest, runs }) {
|
|
75
|
+
omitInvalidTimingDiagnostics(record);
|
|
66
76
|
record.infrastructureAttempts = record.infrastructureAttempt ?? 1;
|
|
67
77
|
record.infrastructureRetries = Math.max(0, record.infrastructureAttempts - 1);
|
|
68
78
|
record.infrastructureFailures = infrastructureFailures;
|
|
@@ -91,6 +101,7 @@ export function promoteMeasuredBenchmarkRecord({ runRoot, ledgerBinding, record,
|
|
|
91
101
|
export function recoverPendingBenchmarkRecord({ runRoot, manifest, ledgerBinding, completedRuns, pending, measuredReady, fullOrder, suite }) {
|
|
92
102
|
let binding = ledgerBinding;
|
|
93
103
|
const runs = completedRuns;
|
|
104
|
+
let pendingRecordSanitized = false;
|
|
94
105
|
if (pending) {
|
|
95
106
|
if (pending.schemaVersion !== 2 || !pending.previousLedger || !pending.record || pending.postSessionGuard?.matched !== true
|
|
96
107
|
|| !String(pending.postSessionGuard.stage ?? "").startsWith("after-session:")) fail("Benchmark pending record is missing its post-session execution guard receipt");
|
|
@@ -100,6 +111,8 @@ export function recoverPendingBenchmarkRecord({ runRoot, manifest, ledgerBinding
|
|
|
100
111
|
}
|
|
101
112
|
if (binding.records === pending.previousLedger.records) {
|
|
102
113
|
assertBenchmarkLedgerBinding(pending.previousLedger, binding, "pending-record previous ledger");
|
|
114
|
+
omitInvalidTimingDiagnostics(pending.record);
|
|
115
|
+
pendingRecordSanitized = true;
|
|
103
116
|
binding = appendBenchmarkLedger(path.join(runRoot, "runs.jsonl"), pending.record, binding);
|
|
104
117
|
runs.push(pending.record);
|
|
105
118
|
} else if (binding.records === pending.previousLedger.records + 1) {
|
|
@@ -123,6 +136,7 @@ export function recoverPendingBenchmarkRecord({ runRoot, manifest, ledgerBinding
|
|
|
123
136
|
fail("Measured benchmark record WAL does not match the frozen execution order");
|
|
124
137
|
}
|
|
125
138
|
if (pending) {
|
|
139
|
+
if (pendingRecordSanitized) omitInvalidTimingDiagnostics(measuredReady.record);
|
|
126
140
|
assertBenchmarkLedgerBinding(measuredReady.previousLedger, pending.previousLedger, "measured/pending previous ledger");
|
|
127
141
|
if (JSON.stringify(measuredReady.record) !== JSON.stringify(pending.record)) fail("Measured and post-guard pending records differ");
|
|
128
142
|
} else {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function applyBenchmarkExecutionDefaults(options, suite) {
|
|
2
|
+
options.repeats ??= suite.defaultRepeats;
|
|
3
|
+
options.infrastructureRetries ??= suite.releaseGate?.maximumInfrastructureRetries
|
|
4
|
+
?? (suite.schemaVersion === 2 ? 2 : 0);
|
|
5
|
+
options.retryDelaySeconds ??= suite.schemaVersion === 2 && options.infrastructureRetries > 0 ? 60 : 0;
|
|
6
|
+
options.timeoutSeconds ??= suite.timeoutSeconds;
|
|
7
|
+
const contract = suite.executionContract;
|
|
8
|
+
if (!contract) return;
|
|
9
|
+
for (const [field, expected] of [
|
|
10
|
+
["surfaces", contract.surfaces], ["model", contract.model], ["thinking", contract.thinking], ["codexMode", contract.codexMode]
|
|
11
|
+
]) {
|
|
12
|
+
const actual = options[field];
|
|
13
|
+
if (actual === undefined) options[field] = Array.isArray(expected) ? [...expected] : expected;
|
|
14
|
+
else if (JSON.stringify(actual) !== JSON.stringify(expected)) {
|
|
15
|
+
throw new Error(`Suite ${suite.id} locks ${field} to ${Array.isArray(expected) ? expected.join(",") : expected}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function benchmarkSuiteCoverage(declaredScenarios, selectedScenarios) {
|
|
21
|
+
return {
|
|
22
|
+
declaredScenarios,
|
|
23
|
+
selectedScenarios,
|
|
24
|
+
fullSuite: selectedScenarios === declaredScenarios
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
const MAXIMUM_AGGREGATE = 1_000_000_000;
|
|
4
|
+
const adaptiveContextEvents = new Set([
|
|
5
|
+
"context_governor_projection",
|
|
6
|
+
"context_governor_projection_noop",
|
|
7
|
+
"context_governor_compaction_cancelled",
|
|
8
|
+
"context_governor_deterministic_compaction",
|
|
9
|
+
"context_governor_deterministic_compaction_skipped"
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
function boundedInteger(value) {
|
|
13
|
+
return Number.isSafeInteger(value) && value >= 0 && value <= MAXIMUM_AGGREGATE;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function normalizePath(value) {
|
|
17
|
+
if (typeof value !== "string" || !value || value.length > 4_096) return null;
|
|
18
|
+
const normalized = path.posix.normalize(value.replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/+/g, "/"));
|
|
19
|
+
if (!normalized || normalized === "." || path.posix.isAbsolute(normalized)
|
|
20
|
+
|| normalized === ".." || normalized.startsWith("../")) return null;
|
|
21
|
+
return normalized;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function section(coverageStatus, observedEvents, aggregate, evidenceSource = "context-telemetry") {
|
|
25
|
+
return { coverageStatus, observedEvents, evidenceSource, aggregate };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function unavailableWebUiSection() {
|
|
29
|
+
return section("not-observed", 0, null, "provider-free-runtime-conformance");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function savingsAccounting(event) {
|
|
33
|
+
const accounting = event?.accounting;
|
|
34
|
+
if (!accounting || typeof accounting !== "object" || Array.isArray(accounting)
|
|
35
|
+
|| !boundedInteger(accounting.estimatedSavingsTokens)
|
|
36
|
+
|| !boundedInteger(accounting.minimumSavingsTokens)
|
|
37
|
+
|| typeof accounting.minimumSavingsMet !== "boolean") return null;
|
|
38
|
+
return {
|
|
39
|
+
estimated: accounting.estimatedSavingsTokens,
|
|
40
|
+
minimum: accounting.minimumSavingsTokens,
|
|
41
|
+
met: accounting.minimumSavingsMet
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function projectionAccounting(event) {
|
|
46
|
+
if (!boundedInteger(event?.estimatedSavingsTokens)
|
|
47
|
+
|| !boundedInteger(event?.minimumSavingsTokens)
|
|
48
|
+
|| !boundedInteger(event?.accounting?.billedTraffic?.governorProviderCalls)) return null;
|
|
49
|
+
return {
|
|
50
|
+
estimated: event.estimatedSavingsTokens,
|
|
51
|
+
minimum: event.minimumSavingsTokens,
|
|
52
|
+
met: event.estimatedSavingsTokens >= event.minimumSavingsTokens,
|
|
53
|
+
providerCalls: event.accounting.billedTraffic.governorProviderCalls
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function protocolFailure(event) {
|
|
58
|
+
const protocol = event?.protocol;
|
|
59
|
+
if (protocol && typeof protocol === "object" && !Array.isArray(protocol)
|
|
60
|
+
&& protocol.intact === false && Array.isArray(protocol.orphanCallIds) && Array.isArray(protocol.orphanResultIds)
|
|
61
|
+
&& protocol.orphanCallIds.length <= MAXIMUM_AGGREGATE
|
|
62
|
+
&& protocol.orphanResultIds.length <= MAXIMUM_AGGREGATE) {
|
|
63
|
+
return { calls: protocol.orphanCallIds.length, results: protocol.orphanResultIds.length };
|
|
64
|
+
}
|
|
65
|
+
const codes = Array.isArray(event?.reasonCodes) ? event.reasonCodes : [];
|
|
66
|
+
const count = (prefix) => {
|
|
67
|
+
const match = codes.find((code) => typeof code === "string" && code.startsWith(prefix));
|
|
68
|
+
const value = match ? Number.parseInt(match.slice(prefix.length), 10) : 0;
|
|
69
|
+
return boundedInteger(value) ? value : null;
|
|
70
|
+
};
|
|
71
|
+
const calls = count("orphan-calls:"), results = count("orphan-results:");
|
|
72
|
+
return calls === null || results === null ? null : { calls, results };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function adaptiveContextSection(visible) {
|
|
76
|
+
const events = visible.filter((event) => adaptiveContextEvents.has(event.event));
|
|
77
|
+
if (events.length === 0) return section("not-observed", 0, null);
|
|
78
|
+
const aggregate = {
|
|
79
|
+
projected: 0,
|
|
80
|
+
noOp: 0,
|
|
81
|
+
cancelled: 0,
|
|
82
|
+
deterministicCompactions: 0,
|
|
83
|
+
hostSummaryFallbacks: 0,
|
|
84
|
+
estimatedSavingsTokens: 0,
|
|
85
|
+
minimumSavingsTokens: 0,
|
|
86
|
+
minimumSavingsMet: 0,
|
|
87
|
+
minimumSavingsNotMet: 0,
|
|
88
|
+
governorProviderCalls: 0,
|
|
89
|
+
deterministicCompactionProviderCalls: 0,
|
|
90
|
+
protocolIntegrity: { checks: 0, intact: 0, failed: 0, orphanCalls: 0, orphanResults: 0 },
|
|
91
|
+
definition: "adaptive-context-runtime-receipt-v1"
|
|
92
|
+
};
|
|
93
|
+
let complete = true;
|
|
94
|
+
const add = (key, value) => {
|
|
95
|
+
const next = aggregate[key] + value;
|
|
96
|
+
if (!boundedInteger(value) || !boundedInteger(next)) complete = false;
|
|
97
|
+
else aggregate[key] = next;
|
|
98
|
+
};
|
|
99
|
+
const addProtocol = (intact, failure = { calls: 0, results: 0 }, checks = 1) => {
|
|
100
|
+
const protocol = aggregate.protocolIntegrity;
|
|
101
|
+
for (const [key, value] of Object.entries({
|
|
102
|
+
checks,
|
|
103
|
+
intact: intact ? checks : 0,
|
|
104
|
+
failed: intact ? 0 : checks,
|
|
105
|
+
orphanCalls: failure.calls,
|
|
106
|
+
orphanResults: failure.results
|
|
107
|
+
})) {
|
|
108
|
+
const next = protocol[key] + value;
|
|
109
|
+
if (!boundedInteger(value) || !boundedInteger(next)) complete = false;
|
|
110
|
+
else protocol[key] = next;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const addSavings = (accounting) => {
|
|
114
|
+
add("estimatedSavingsTokens", accounting.estimated);
|
|
115
|
+
add("minimumSavingsTokens", accounting.minimum);
|
|
116
|
+
add(accounting.met ? "minimumSavingsMet" : "minimumSavingsNotMet", 1);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
for (const event of events) {
|
|
120
|
+
if (event.event === "context_governor_projection") {
|
|
121
|
+
const accounting = projectionAccounting(event);
|
|
122
|
+
if (!accounting || event.action !== "project" || !accounting.met) { complete = false; continue; }
|
|
123
|
+
aggregate.projected += 1;
|
|
124
|
+
addSavings(accounting);
|
|
125
|
+
add("governorProviderCalls", accounting.providerCalls);
|
|
126
|
+
addProtocol(true, undefined, 2);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (event.event === "context_governor_projection_noop") {
|
|
130
|
+
const accounting = projectionAccounting(event);
|
|
131
|
+
if (!accounting || event.action !== "passthrough"
|
|
132
|
+
|| !["no-safe-boundary", "insufficient-savings", "unsafe-tool-protocol"].includes(event.fallback)) {
|
|
133
|
+
complete = false; continue;
|
|
134
|
+
}
|
|
135
|
+
aggregate.noOp += 1;
|
|
136
|
+
addSavings(accounting);
|
|
137
|
+
add("governorProviderCalls", accounting.providerCalls);
|
|
138
|
+
if (event.fallback === "unsafe-tool-protocol") {
|
|
139
|
+
const failure = protocolFailure(event);
|
|
140
|
+
if (!failure) complete = false;
|
|
141
|
+
else addProtocol(false, failure);
|
|
142
|
+
} else addProtocol(true, undefined, event.fallback === "insufficient-savings" ? 2 : 1);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (event.event === "context_governor_compaction_cancelled") {
|
|
146
|
+
aggregate.cancelled += 1;
|
|
147
|
+
if (event.fallback === "no-op-unsafe-tool-boundary") {
|
|
148
|
+
const failure = protocolFailure(event);
|
|
149
|
+
if (!failure) complete = false;
|
|
150
|
+
else addProtocol(false, failure);
|
|
151
|
+
} else if (event.fallback === "no-op-insufficient-savings") {
|
|
152
|
+
const accounting = savingsAccounting(event);
|
|
153
|
+
if (!accounting || accounting.met) complete = false;
|
|
154
|
+
else addSavings(accounting);
|
|
155
|
+
addProtocol(true);
|
|
156
|
+
} else complete = false;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (event.event === "context_governor_deterministic_compaction") {
|
|
160
|
+
const accounting = savingsAccounting(event), billed = event?.accounting?.billedTraffic;
|
|
161
|
+
const zeroBilled = billed?.measured === true && billed?.inputTokens === 0 && billed?.outputTokens === 0
|
|
162
|
+
&& billed?.cacheReadTokens === 0 && billed?.scope === "local-deterministic-summary-generation";
|
|
163
|
+
if (!accounting || (!accounting.met && event.minimumSavingsOverride !== "overflow-recovery") || !zeroBilled) {
|
|
164
|
+
complete = false; continue;
|
|
165
|
+
}
|
|
166
|
+
aggregate.deterministicCompactions += 1;
|
|
167
|
+
addSavings(accounting);
|
|
168
|
+
addProtocol(true);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (event.event === "context_governor_deterministic_compaction_skipped") {
|
|
172
|
+
if (!["host-model-directed-summary", "host-model-overflow-recovery"].includes(event.fallback)) complete = false;
|
|
173
|
+
else aggregate.hostSummaryFallbacks += 1;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return section(complete ? "complete" : "partial", events.length, complete ? aggregate : null);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function freshnessPaths(event) {
|
|
180
|
+
if (!Array.isArray(event?.paths) || event.paths.length === 0 || event.paths.length > 10_000) return null;
|
|
181
|
+
const paths = event.paths.map(normalizePath);
|
|
182
|
+
return paths.some((item) => item === null) ? null : [...new Set(paths)];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function editFreshnessSection(visible) {
|
|
186
|
+
const observations = visible.map((event, index) => ({ event, index }))
|
|
187
|
+
.filter(({ event }) => ["edit_freshness_snapshot_observed", "edit_freshness_stale"].includes(event.event));
|
|
188
|
+
if (observations.length === 0) return section("not-observed", 0, null);
|
|
189
|
+
const snapshots = [], stale = [];
|
|
190
|
+
let complete = true;
|
|
191
|
+
for (const item of observations) {
|
|
192
|
+
const paths = freshnessPaths(item.event);
|
|
193
|
+
const taskRunId = typeof item.event.taskRunId === "string" && item.event.taskRunId ? item.event.taskRunId : null;
|
|
194
|
+
if (!paths || !taskRunId) { complete = false; continue; }
|
|
195
|
+
if (item.event.event === "edit_freshness_snapshot_observed") {
|
|
196
|
+
if (!["read", "mutation"].includes(item.event.source)) { complete = false; continue; }
|
|
197
|
+
snapshots.push({ ...item, paths, taskRunId, source: item.event.source });
|
|
198
|
+
} else {
|
|
199
|
+
if (typeof item.event.toolCallId !== "string" || !item.event.toolCallId
|
|
200
|
+
|| typeof item.event.enforce !== "boolean") { complete = false; continue; }
|
|
201
|
+
stale.push({ ...item, paths, taskRunId, toolCallId: item.event.toolCallId, enforce: item.event.enforce });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
let staleBlocks = 0, rereadRecoveries = 0, mutationRecoveries = 0;
|
|
205
|
+
const enforced = stale.filter((item) => item.enforce);
|
|
206
|
+
for (const item of enforced) {
|
|
207
|
+
const initialSnapshot = item.paths.every((target) => snapshots.some((snapshot) => snapshot.index < item.index
|
|
208
|
+
&& snapshot.taskRunId === item.taskRunId && snapshot.source === "read" && snapshot.paths.includes(target)));
|
|
209
|
+
if (!initialSnapshot) complete = false;
|
|
210
|
+
const decisionIndex = visible.findIndex((event, index) => index > item.index && event.event === "tool_decision"
|
|
211
|
+
&& event.toolCallId === item.toolCallId && event.decision === "blocked");
|
|
212
|
+
if (decisionIndex >= 0) staleBlocks += 1;
|
|
213
|
+
const reread = decisionIndex >= 0 && item.paths.every((target) => snapshots.some((snapshot) => snapshot.index > decisionIndex
|
|
214
|
+
&& snapshot.taskRunId === item.taskRunId && snapshot.source === "read" && snapshot.paths.includes(target)));
|
|
215
|
+
if (reread) rereadRecoveries += 1;
|
|
216
|
+
const mutation = reread && item.paths.every((target) => snapshots.some((snapshot) => snapshot.index > decisionIndex
|
|
217
|
+
&& snapshot.taskRunId === item.taskRunId && snapshot.source === "mutation" && snapshot.paths.includes(target)));
|
|
218
|
+
if (mutation) mutationRecoveries += 1;
|
|
219
|
+
}
|
|
220
|
+
const incompleteRecoveries = enforced.length - rereadRecoveries;
|
|
221
|
+
if (incompleteRecoveries > 0 || staleBlocks !== enforced.length) complete = false;
|
|
222
|
+
const aggregate = {
|
|
223
|
+
snapshotObservations: snapshots.length,
|
|
224
|
+
readSnapshots: snapshots.filter((item) => item.source === "read").length,
|
|
225
|
+
mutationSnapshots: snapshots.filter((item) => item.source === "mutation").length,
|
|
226
|
+
staleDetections: stale.length,
|
|
227
|
+
enforcedStaleDetections: enforced.length,
|
|
228
|
+
staleBlocks,
|
|
229
|
+
rereadRecoveries,
|
|
230
|
+
mutationRecoveries,
|
|
231
|
+
incompleteRecoveries,
|
|
232
|
+
definition: "edit-freshness-runtime-receipt-v1"
|
|
233
|
+
};
|
|
234
|
+
return section(complete ? "complete" : "partial", observations.length, complete ? aggregate : null);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function causalRuntimeEvidence(visible) {
|
|
238
|
+
return {
|
|
239
|
+
adaptiveContext: adaptiveContextSection(visible),
|
|
240
|
+
operationLifecycle: unavailableWebUiSection(),
|
|
241
|
+
boundedEmission: unavailableWebUiSection(),
|
|
242
|
+
editFreshness: editFreshnessSection(visible)
|
|
243
|
+
};
|
|
244
|
+
}
|