@piagent/platform 1.6.0 → 1.7.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 +104 -0
- package/README.md +24 -15
- package/README.vi.md +36 -2
- package/adapters/common/assurance-producers.json +109 -0
- package/adapters/common/structured-assurance-facts.mjs +153 -0
- package/adapters/node-typescript/contract-families.json +2811 -0
- package/adapters/node-typescript/contract-families.md +90 -0
- package/benchmarks/production-v1/grade.mjs +20 -0
- package/benchmarks/production-v1/spend-control.v1.json +27 -3
- package/benchmarks/production-v1/suite.json +5 -1
- package/benchmarks/production-v2/grade.mjs +892 -0
- package/benchmarks/production-v2/project/README.md +7 -0
- package/benchmarks/production-v2/project/config/service.json +4 -0
- package/benchmarks/production-v2/project/data/audit-ledger.jsonl +1 -0
- package/benchmarks/production-v2/project/docs/ops.md +3 -0
- package/benchmarks/production-v2/project/logs/incident.log +2 -0
- package/benchmarks/production-v2/project/package.json +11 -0
- package/benchmarks/production-v2/project/scripts/check.mjs +21 -0
- package/benchmarks/production-v2/project/src/backend/auth.js +3 -0
- package/benchmarks/production-v2/project/src/backend/billing-window.js +4 -0
- package/benchmarks/production-v2/project/src/backend/cache.js +15 -0
- package/benchmarks/production-v2/project/src/backend/invoice.js +4 -0
- package/benchmarks/production-v2/project/src/backend/revocation-cache.js +3 -0
- package/benchmarks/production-v2/project/src/data/csv.js +3 -0
- package/benchmarks/production-v2/project/src/data/dedup.js +5 -0
- package/benchmarks/production-v2/project/src/data/migration.js +9 -0
- package/benchmarks/production-v2/project/src/data/ndjson-stream.js +5 -0
- package/benchmarks/production-v2/project/src/data/versioned-replay.js +8 -0
- package/benchmarks/production-v2/project/src/frontend/chat-events.js +7 -0
- package/benchmarks/production-v2/project/src/frontend/pagination.js +8 -0
- package/benchmarks/production-v2/project/src/frontend/request-lifecycle.js +15 -0
- package/benchmarks/production-v2/project/src/frontend/search-state.js +8 -0
- package/benchmarks/production-v2/project/src/frontend/unicode-search.js +7 -0
- package/benchmarks/production-v2/project/src/fullstack/contract-sync.js +10 -0
- package/benchmarks/production-v2/project/src/platform/args.js +10 -0
- package/benchmarks/production-v2/project/src/platform/config.js +7 -0
- package/benchmarks/production-v2/project/src/platform/workflow-session.js +9 -0
- package/benchmarks/production-v2/project/src/platform/workspace.js +13 -0
- package/benchmarks/production-v2/project/src/reliability/checkpoint.js +5 -0
- package/benchmarks/production-v2/project/src/reliability/expiry.js +5 -0
- package/benchmarks/production-v2/project/src/reliability/retry.js +15 -0
- package/benchmarks/production-v2/project/test/smoke.test.js +21 -0
- package/benchmarks/production-v2/project/vendor/README.md +1 -0
- package/benchmarks/production-v2/prompts/abort-reconnect-supersession.md +11 -0
- package/benchmarks/production-v2/prompts/backend-frontend-contract-sync.md +12 -0
- package/benchmarks/production-v2/prompts/billing-cutoff-clock-skew.md +11 -0
- package/benchmarks/production-v2/prompts/bounded-retry.md +7 -0
- package/benchmarks/production-v2/prompts/chunked-record-boundary.md +9 -0
- package/benchmarks/production-v2/prompts/cli-double-dash.md +7 -0
- package/benchmarks/production-v2/prompts/config-precedence.md +6 -0
- package/benchmarks/production-v2/prompts/destructive-history-refusal.md +3 -0
- package/benchmarks/production-v2/prompts/expiry-boundary.md +7 -0
- package/benchmarks/production-v2/prompts/idempotent-replay-conflict.md +11 -0
- package/benchmarks/production-v2/prompts/incident-diagnosis.md +4 -0
- package/benchmarks/production-v2/prompts/invoice-rounding.md +9 -0
- package/benchmarks/production-v2/prompts/journeys/config-precedence-scout.md +3 -0
- package/benchmarks/production-v2/prompts/journeys/expiry-boundary-scout.md +3 -0
- package/benchmarks/production-v2/prompts/journeys/quoted-csv-scout.md +3 -0
- package/benchmarks/production-v2/prompts/journeys/recover-after-uncertain-send.md +4 -0
- package/benchmarks/production-v2/prompts/journeys/repository-prompt-injection-scout.md +4 -0
- package/benchmarks/production-v2/prompts/journeys/resumable-checkpoint-partial-failure-scout.md +4 -0
- package/benchmarks/production-v2/prompts/journeys/stable-dedup-scout.md +3 -0
- package/benchmarks/production-v2/prompts/journeys/stale-search-response-scout.md +3 -0
- package/benchmarks/production-v2/prompts/journeys/tenant-cache-isolation-scout.md +4 -0
- package/benchmarks/production-v2/prompts/journeys/verify-current-contract.md +4 -0
- package/benchmarks/production-v2/prompts/journeys/workflow-switch-same-session-scout.md +4 -0
- package/benchmarks/production-v2/prompts/pagination-boundary.md +7 -0
- package/benchmarks/production-v2/prompts/protected-env-refusal.md +2 -0
- package/benchmarks/production-v2/prompts/quoted-csv.md +6 -0
- package/benchmarks/production-v2/prompts/reconnect-chat-event-order.md +19 -0
- package/benchmarks/production-v2/prompts/repository-prompt-injection.md +5 -0
- package/benchmarks/production-v2/prompts/resumable-checkpoint-partial-failure.md +11 -0
- package/benchmarks/production-v2/prompts/revoked-session-cache.md +10 -0
- package/benchmarks/production-v2/prompts/schema-migration.md +6 -0
- package/benchmarks/production-v2/prompts/stable-dedup.md +6 -0
- package/benchmarks/production-v2/prompts/stale-search-response.md +6 -0
- package/benchmarks/production-v2/prompts/tenant-cache-isolation.md +6 -0
- package/benchmarks/production-v2/prompts/tenant-role-authorization.md +6 -0
- package/benchmarks/production-v2/prompts/unicode-search.md +6 -0
- package/benchmarks/production-v2/prompts/workflow-switch-same-session.md +30 -0
- package/benchmarks/production-v2/prompts/workspace-order.md +7 -0
- package/benchmarks/production-v2/spend-control.v1.json +115 -0
- package/benchmarks/production-v2/suite.json +1009 -0
- package/benchmarks/production-v2/variant.mjs +169 -0
- package/benchmarks/production-v3/CONTRACT-REVISION-20260922.md +31 -0
- package/benchmarks/production-v3/calibration/corpus.v1.json +63 -0
- package/benchmarks/production-v3/calibration/human-review-rubric.v1.json +36 -0
- package/benchmarks/production-v3/grade.mjs +1017 -0
- package/benchmarks/production-v3/project/README.md +7 -0
- package/benchmarks/production-v3/project/config/service.json +4 -0
- package/benchmarks/production-v3/project/data/audit-ledger.jsonl +1 -0
- package/benchmarks/production-v3/project/docs/ops.md +3 -0
- package/benchmarks/production-v3/project/logs/incident.log +2 -0
- package/benchmarks/production-v3/project/package.json +11 -0
- package/benchmarks/production-v3/project/scripts/check.mjs +21 -0
- package/benchmarks/production-v3/project/src/backend/auth.js +3 -0
- package/benchmarks/production-v3/project/src/backend/billing-window.js +4 -0
- package/benchmarks/production-v3/project/src/backend/cache.js +15 -0
- package/benchmarks/production-v3/project/src/backend/invoice.js +4 -0
- package/benchmarks/production-v3/project/src/backend/revocation-cache.js +12 -0
- package/benchmarks/production-v3/project/src/data/csv.js +3 -0
- package/benchmarks/production-v3/project/src/data/dedup.js +5 -0
- package/benchmarks/production-v3/project/src/data/migration.js +9 -0
- package/benchmarks/production-v3/project/src/data/ndjson-stream.js +5 -0
- package/benchmarks/production-v3/project/src/data/versioned-replay.js +8 -0
- package/benchmarks/production-v3/project/src/frontend/chat-events.js +7 -0
- package/benchmarks/production-v3/project/src/frontend/pagination.js +8 -0
- package/benchmarks/production-v3/project/src/frontend/request-lifecycle.js +23 -0
- package/benchmarks/production-v3/project/src/frontend/search-state.js +8 -0
- package/benchmarks/production-v3/project/src/frontend/unicode-search.js +7 -0
- package/benchmarks/production-v3/project/src/fullstack/contract-sync.js +10 -0
- package/benchmarks/production-v3/project/src/platform/args.js +10 -0
- package/benchmarks/production-v3/project/src/platform/config.js +7 -0
- package/benchmarks/production-v3/project/src/platform/workflow-session.js +9 -0
- package/benchmarks/production-v3/project/src/platform/workspace.js +13 -0
- package/benchmarks/production-v3/project/src/reliability/checkpoint.js +5 -0
- package/benchmarks/production-v3/project/src/reliability/expiry.js +14 -0
- package/benchmarks/production-v3/project/src/reliability/retry.js +15 -0
- package/benchmarks/production-v3/project/test/smoke.test.js +21 -0
- package/benchmarks/production-v3/project/vendor/README.md +1 -0
- package/benchmarks/production-v3/prompts/abort-reconnect-supersession.md +11 -0
- package/benchmarks/production-v3/prompts/backend-frontend-contract-sync.md +20 -0
- package/benchmarks/production-v3/prompts/billing-cutoff-clock-skew.md +11 -0
- package/benchmarks/production-v3/prompts/bounded-retry.md +7 -0
- package/benchmarks/production-v3/prompts/chunked-record-boundary.md +11 -0
- package/benchmarks/production-v3/prompts/cli-double-dash.md +7 -0
- package/benchmarks/production-v3/prompts/config-precedence.md +6 -0
- package/benchmarks/production-v3/prompts/destructive-history-refusal.md +9 -0
- package/benchmarks/production-v3/prompts/expiry-boundary.md +14 -0
- package/benchmarks/production-v3/prompts/idempotent-replay-conflict.md +13 -0
- package/benchmarks/production-v3/prompts/incident-diagnosis.md +4 -0
- package/benchmarks/production-v3/prompts/invoice-rounding.md +9 -0
- package/benchmarks/production-v3/prompts/journeys/config-precedence-scout.md +3 -0
- package/benchmarks/production-v3/prompts/journeys/expiry-boundary-scout.md +3 -0
- package/benchmarks/production-v3/prompts/journeys/quoted-csv-scout.md +3 -0
- package/benchmarks/production-v3/prompts/journeys/recover-after-uncertain-send.md +4 -0
- package/benchmarks/production-v3/prompts/journeys/repository-prompt-injection-scout.md +4 -0
- package/benchmarks/production-v3/prompts/journeys/resumable-checkpoint-partial-failure-scout.md +4 -0
- package/benchmarks/production-v3/prompts/journeys/stable-dedup-scout.md +3 -0
- package/benchmarks/production-v3/prompts/journeys/stale-search-response-scout.md +3 -0
- package/benchmarks/production-v3/prompts/journeys/tenant-cache-isolation-scout.md +4 -0
- package/benchmarks/production-v3/prompts/journeys/verify-current-contract.md +4 -0
- package/benchmarks/production-v3/prompts/journeys/workflow-switch-same-session-scout.md +4 -0
- package/benchmarks/production-v3/prompts/pagination-boundary.md +9 -0
- package/benchmarks/production-v3/prompts/protected-env-refusal.md +8 -0
- package/benchmarks/production-v3/prompts/quoted-csv.md +6 -0
- package/benchmarks/production-v3/prompts/reconnect-chat-event-order.md +20 -0
- package/benchmarks/production-v3/prompts/repository-prompt-injection.md +5 -0
- package/benchmarks/production-v3/prompts/resumable-checkpoint-partial-failure.md +15 -0
- package/benchmarks/production-v3/prompts/revoked-session-cache.md +10 -0
- package/benchmarks/production-v3/prompts/schema-migration.md +6 -0
- package/benchmarks/production-v3/prompts/stable-dedup.md +6 -0
- package/benchmarks/production-v3/prompts/stale-search-response.md +6 -0
- package/benchmarks/production-v3/prompts/tenant-cache-isolation.md +6 -0
- package/benchmarks/production-v3/prompts/tenant-role-authorization.md +6 -0
- package/benchmarks/production-v3/prompts/unicode-search.md +6 -0
- package/benchmarks/production-v3/prompts/workflow-switch-same-session.md +30 -0
- package/benchmarks/production-v3/prompts/workspace-order.md +7 -0
- package/benchmarks/production-v3/public-checks/abort-reconnect-supersession.js +34 -0
- package/benchmarks/production-v3/public-checks/expiry-boundary.js +29 -0
- package/benchmarks/production-v3/public-checks/revoked-session-cache.js +20 -0
- package/benchmarks/production-v3/spend-control.v1.json +121 -0
- package/benchmarks/production-v3/suite.json +1010 -0
- package/benchmarks/production-v3/variant.mjs +178 -0
- package/catalog/capabilities.json +16 -16
- package/docs/authority-manifest.md +1 -1
- package/docs/auto-delegation-policy.md +38 -73
- package/docs/benchmark-codex-mcp-metadata-contract-v1.md +159 -0
- package/docs/benchmark-codex-mcp-metadata-contract-v2.md +182 -0
- package/docs/benchmark-codex-mcp-metadata-contract-v3.md +194 -0
- package/docs/benchmark-public-contract-addendum-v2.md +85 -0
- package/docs/benchmark-public-contract-addendum-v3.md +116 -0
- package/docs/command-reference-vietnamese.md +30 -35
- package/docs/context-engine.md +5 -3
- package/docs/context-window-policy.md +37 -1
- package/docs/distribution-standard.md +9 -9
- package/docs/en/architecture.md +26 -13
- package/docs/languages.json +4 -4
- package/docs/operator-manual-vietnamese.md +26 -46
- package/docs/piagent-codex-benchmark-recovery-plan.md +1817 -0
- package/docs/piagent-core-evaluation-specs-2026-09-06.json +706 -0
- package/docs/piagent-core-improvement-plan.md +528 -0
- package/docs/piagent-core-offline-implementation-2026-09-06.md +219 -0
- package/docs/piagent-core-plan-checkpoint-2026-09-06.json +69 -0
- package/docs/piagent-core-reasoning-research-2026-09-06.md +225 -0
- package/docs/piagent-core-research-sources-2026-09-06.json +416 -0
- package/docs/piagent-open-session-wait.md +19 -0
- package/docs/piagent-runtime-benchmark-execution-plan.md +685 -0
- package/docs/publishing-for-teams.md +7 -0
- package/docs/quality-benchmark.md +299 -23
- package/docs/quickstart-vietnamese.md +2 -2
- package/docs/release-install-policy.md +32 -9
- package/docs/research/harness-next-evidence-review.md +113 -0
- package/docs/runtime-harness-standard.md +3 -3
- package/docs/security-threat-model.md +1 -1
- 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 +1 -1
- package/docs/team-onboarding.md +7 -7
- package/docs/third-party-neutrality.md +7 -0
- package/docs/usage-observability.md +1 -1
- package/docs/vi/architecture.md +26 -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 +5 -5
- package/docs-site/content/en/whats-new.html +23 -1
- package/docs-site/content/en/workflows.html +2 -2
- package/docs-site/content/index.html +19 -19
- package/docs-site/content/runtime.html +6 -6
- package/docs-site/content/whats-new.html +23 -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 +6 -6
- 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 +24 -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 +7 -7
- 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 +24 -2
- package/docs-site/workflows.html +3 -3
- package/evals/architecture-conformance-v1/lane.json +18 -0
- package/evals/architecture-conformance-v1/runner.mjs +77 -0
- package/evals/fixtures/approved-host-contracts.invalid.json +43 -0
- package/evals/fixtures/approved-host-contracts.valid.json +43 -0
- package/evals/fixtures/benchmark-assurance-evidence.invalid.json +1 -1
- package/evals/fixtures/benchmark-assurance-evidence.valid.json +1 -1
- package/evals/fixtures/benchmark-attempt-outcome.invalid.json +42 -0
- package/evals/fixtures/benchmark-attempt-outcome.valid.json +42 -0
- package/evals/fixtures/benchmark-independent-verification-plan.invalid.json +7 -0
- package/evals/fixtures/benchmark-independent-verification-plan.valid.json +21 -0
- 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/composite-criterion.invalid.json +10 -0
- package/evals/fixtures/composite-criterion.valid.json +33 -0
- package/evals/fixtures/contract-family-library.invalid.json +42 -0
- package/evals/fixtures/contract-family-library.valid.json +41 -0
- package/evals/fixtures/contract-selection-recipe.invalid.json +29 -0
- package/evals/fixtures/contract-selection-recipe.valid.json +29 -0
- package/evals/fixtures/helper-request.invalid.json +1 -1
- package/evals/fixtures/helper-request.valid.json +1 -1
- package/evals/fixtures/host-contract-plan.invalid.json +42 -0
- package/evals/fixtures/host-contract-plan.valid.json +41 -0
- package/evals/fixtures/piagent-webui/subagent-tree-v1.valid.json +7 -0
- package/evals/fixtures/scoped-project-verification-receipt-v2.invalid.json +42 -0
- package/evals/fixtures/scoped-project-verification-receipt-v2.valid.json +42 -0
- package/evals/fixtures/scoped-project-verification-receipt-v3.invalid.json +57 -0
- package/evals/fixtures/scoped-project-verification-receipt-v3.valid.json +57 -0
- package/evals/fixtures/scoped-verification-receipt-v1.invalid.json +40 -0
- package/evals/fixtures/scoped-verification-receipt-v1.valid.json +40 -0
- package/evals/fixtures/task-authority-snapshot.valid.json +4 -4
- package/evals/fs4-readiness-matrix.v1.json +2 -2
- package/evals/fs5-artifact-archive/README.md +32 -0
- package/evals/fs5-artifact-archive/manifest.json +148 -0
- package/evals/fs5-artifact-archive/sha256/1f073f6d42c093a3182685e0e096144c8b3befd87594aeea1af05ce17653860c.txt +380 -0
- package/evals/fs5-artifact-archive/sha256/1ff46984c5ff668647dfad94248cd9dcfb72384a8aa529279345582f90d7486a.txt +331 -0
- package/evals/fs5-artifact-archive/sha256/20a5e1ef1cab3234a888b876b3cec52e702a05bc5ac000b691f94c651beed9ca.txt +800 -0
- package/evals/fs5-artifact-archive/sha256/29bb79e96b047d79056626d747baa0b3a6ca9d4da7ad80b9668c0085e5581706.txt +116 -0
- package/evals/fs5-artifact-archive/sha256/2bcc0cf6c18eee0c080c30e727610b0f10a278f5862855d920ba5797f07a2f2d.txt +252 -0
- package/evals/fs5-artifact-archive/sha256/37ecc65febe2c5947ac9288ad958bc149e0f08c6beda137edb1c660908853832.txt +324 -0
- package/evals/fs5-artifact-archive/sha256/5d937632d2cfff34dbbb781dd367bb78feb64c36d571c36ca15f2cc40c576af8.txt +142 -0
- package/evals/fs5-artifact-archive/sha256/6057c7bf2f40f8e3db7e293f08d745133c05293b75e9f363fb4e2e53bd09a76a.txt +244 -0
- package/evals/fs5-artifact-archive/sha256/62ea354afb6816b148ae9bd95ffb1ee5e29580eb4a22473e1ae19dbb471ec36b.txt +930 -0
- package/evals/fs5-artifact-archive/sha256/8987775b742f3b3650d75cce84e6d58fcdd3dfb835d03dac4c2bfe6d9eea3a2e.txt +903 -0
- package/evals/fs5-artifact-archive/sha256/902e886d0920b66811f54d0d1d933d70f8fab8704813b46d578bee6af1f21eef.txt +942 -0
- package/evals/fs5-artifact-archive/sha256/976a9908adfd765ee7be0655616f39a44fff64824f5e8535d726082e550b02eb.txt +910 -0
- package/evals/fs5-artifact-archive/sha256/9c07bda5bfe7bb7b0959844ccea6790735cc9f154d8d5972e18785148cea6d9a.txt +101 -0
- package/evals/fs5-artifact-archive/sha256/b936a604db87a697bf69581c33d753e26d9e5e2ccce40bf9c9b2070948f49919.txt +931 -0
- package/evals/fs5-artifact-archive/sha256/bf91f69473f48fc3de7c7c55e7ce893ba0511074c4ec930d9f3bcb9615d8e9d5.txt +950 -0
- package/evals/fs5-artifact-archive/sha256/ce4ed1b4a033f2a8cb4632d1336b0867edb3454ce1380f0642c4055149e6ac59.txt +784 -0
- package/evals/fs5-artifact-archive/sha256/db97f444db8ba604512daf0aa26b3fe1e2a120ace2b21d4730db5b18aa0c528f.txt +950 -0
- package/evals/fs5-causal-arm.v1.json +10 -6
- 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 -7
- package/evals/fs5-pilot-protocol.v5.json +10 -8
- package/evals/harness-next/development-corpus.mjs +106 -0
- package/evals/harness-next/resource-budget-probe.mjs +38 -0
- package/evals/harness-next/run-calibration.mjs +83 -0
- package/evals/harness-next/run-resource-probe.mjs +55 -0
- package/evals/harness-next/selected-development-corpus.mjs +27 -0
- package/evals/harness-next.v1.json +51 -0
- package/evals/long-horizon-v1/README.md +19 -0
- package/evals/long-horizon-v1/runner.mjs +116 -48
- package/evals/long-horizon-v1/worker.mjs +77 -30
- package/evals/private-holdout-v1/CURRENT_BOUNDARY.md +53 -0
- package/evals/private-holdout-v1/README.md +5 -2
- package/evals/private-holdout-v1/public-exposure.v1.json +1 -1
- package/evals/private-holdout-v1/public-exposure.v2.json +273 -0
- 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 +9 -4
- package/packages/piagent-core/README.md +15 -6
- package/packages/piagent-core/benchmark/benchmark-all-attempt-efficiency.js +55 -0
- package/packages/piagent-core/benchmark/benchmark-artifact-binding.js +49 -0
- package/packages/piagent-core/benchmark/benchmark-bootstrap.js +265 -14
- package/packages/piagent-core/benchmark/benchmark-budget-governor.js +271 -0
- package/packages/piagent-core/benchmark/benchmark-campaign.js +592 -0
- package/packages/piagent-core/benchmark/benchmark-candidate.js +8 -3
- package/packages/piagent-core/benchmark/benchmark-checkpoint.js +67 -0
- package/packages/piagent-core/benchmark/benchmark-claim-restrictions.js +269 -2
- package/packages/piagent-core/benchmark/benchmark-cli.js +120 -3
- package/packages/piagent-core/benchmark/benchmark-codex-events.js +235 -0
- package/packages/piagent-core/benchmark/benchmark-codex-outcome.js +20 -0
- package/packages/piagent-core/benchmark/benchmark-codex-relative-efficiency.js +699 -0
- package/packages/piagent-core/benchmark/benchmark-codex-rollout.js +521 -0
- package/packages/piagent-core/benchmark/benchmark-codex.js +104 -8
- package/packages/piagent-core/benchmark/benchmark-comparison.js +284 -1
- package/packages/piagent-core/benchmark/benchmark-core.js +111 -110
- package/packages/piagent-core/benchmark/benchmark-diagnostic-source-evidence.js +40 -0
- package/packages/piagent-core/benchmark/benchmark-diagnostic-treatment.js +104 -0
- package/packages/piagent-core/benchmark/benchmark-evaluator-v3.js +226 -0
- package/packages/piagent-core/benchmark/benchmark-execution-guard.js +23 -1
- package/packages/piagent-core/benchmark/benchmark-forensics.js +67 -52
- package/packages/piagent-core/benchmark/benchmark-goal-assessment.js +193 -0
- package/packages/piagent-core/benchmark/benchmark-goal-report.js +87 -0
- package/packages/piagent-core/benchmark/benchmark-independent-verification-observation.js +64 -0
- package/packages/piagent-core/benchmark/benchmark-matrix-summary.js +141 -0
- package/packages/piagent-core/benchmark/benchmark-matrix.js +1 -0
- package/packages/piagent-core/benchmark/benchmark-normalized-cost.js +62 -0
- package/packages/piagent-core/benchmark/benchmark-pi-home.js +1 -0
- package/packages/piagent-core/benchmark/benchmark-preflight.js +70 -7
- package/packages/piagent-core/benchmark/benchmark-process.js +23 -9
- package/packages/piagent-core/benchmark/benchmark-production-completion.js +84 -0
- package/packages/piagent-core/benchmark/benchmark-production-stage-validation.js +209 -0
- package/packages/piagent-core/benchmark/benchmark-provider-free-evidence.js +462 -0
- package/packages/piagent-core/benchmark/benchmark-provider-free-owner.js +24 -0
- package/packages/piagent-core/benchmark/benchmark-provider-wire.js +378 -0
- package/packages/piagent-core/benchmark/benchmark-record-validation.d.ts +2 -0
- package/packages/piagent-core/benchmark/benchmark-record-validation.js +343 -8
- package/packages/piagent-core/benchmark/benchmark-release-claim-controls.js +132 -0
- package/packages/piagent-core/benchmark/benchmark-report.js +94 -5
- package/packages/piagent-core/benchmark/benchmark-resume-recovery.js +280 -10
- package/packages/piagent-core/benchmark/benchmark-runner-policy.js +88 -1
- package/packages/piagent-core/benchmark/benchmark-runtime-causal.js +244 -0
- package/packages/piagent-core/benchmark/benchmark-runtime-identity.js +50 -1
- package/packages/piagent-core/benchmark/benchmark-runtime.js +102 -10
- package/packages/piagent-core/benchmark/benchmark-safety-evidence.js +74 -0
- package/packages/piagent-core/benchmark/benchmark-service-tier.js +189 -0
- package/packages/piagent-core/benchmark/benchmark-stage-diagnostic.js +246 -33
- package/packages/piagent-core/benchmark/benchmark-suite-identity.js +264 -1
- package/packages/piagent-core/benchmark/benchmark-suite-runtime.js +4 -0
- package/packages/piagent-core/benchmark/benchmark-suite.js +232 -4
- package/packages/piagent-core/benchmark/benchmark-summary-support.js +33 -1
- package/packages/piagent-core/benchmark/benchmark-timing-contract.js +189 -0
- package/packages/piagent-core/benchmark/benchmark-timing-diagnostics.js +110 -139
- package/packages/piagent-core/benchmark/benchmark-transport-evidence.js +203 -0
- package/packages/piagent-core/benchmark/benchmark-transport-observation.js +147 -0
- package/packages/piagent-core/benchmark/benchmark-tree-identity.js +2 -1
- package/packages/piagent-core/benchmark/benchmark-usage.js +410 -37
- package/packages/piagent-core/benchmark/benchmark-workflow.js +136 -38
- package/packages/piagent-core/benchmark/fs5-pilot-protocol.js +21 -2
- package/packages/piagent-core/capabilities/runtime-integrity.js +6 -0
- package/packages/piagent-core/extensions/acceptance-api-baseline.js +24 -0
- package/packages/piagent-core/extensions/acceptance-assessment.js +153 -0
- package/packages/piagent-core/extensions/acceptance-authenticated-admission.d.ts +41 -0
- package/packages/piagent-core/extensions/acceptance-authenticated-admission.js +120 -0
- package/packages/piagent-core/extensions/acceptance-behavior-proof.js +1000 -0
- package/packages/piagent-core/extensions/acceptance-boundary-binding.js +31 -0
- package/packages/piagent-core/extensions/acceptance-boundary-guidance.js +214 -0
- package/packages/piagent-core/extensions/acceptance-callable-scanner.js +244 -0
- package/packages/piagent-core/extensions/acceptance-clause-group.js +45 -0
- package/packages/piagent-core/extensions/acceptance-composite-contract.js +334 -0
- package/packages/piagent-core/extensions/acceptance-contract-conjunction.js +78 -0
- package/packages/piagent-core/extensions/acceptance-contract-selection.js +161 -0
- package/packages/piagent-core/extensions/acceptance-contract-semantics.js +211 -211
- package/packages/piagent-core/extensions/acceptance-declared-api.js +126 -0
- package/packages/piagent-core/extensions/acceptance-diagnostic-policy.ts +14 -0
- package/packages/piagent-core/extensions/acceptance-document-content.js +73 -0
- package/packages/piagent-core/extensions/acceptance-durable-execution.d.ts +59 -0
- package/packages/piagent-core/extensions/acceptance-durable-execution.js +139 -0
- package/packages/piagent-core/extensions/acceptance-error-classes.js +1 -1
- package/packages/piagent-core/extensions/acceptance-evidence-store.js +223 -0
- package/packages/piagent-core/extensions/acceptance-executable-evidence.js +490 -88
- package/packages/piagent-core/extensions/acceptance-execution-diagnostics.js +34 -0
- package/packages/piagent-core/extensions/acceptance-execution-snapshot.js +174 -0
- package/packages/piagent-core/extensions/acceptance-executor/.dockerignore +21 -0
- package/packages/piagent-core/extensions/acceptance-executor/Dockerfile +5 -0
- package/packages/piagent-core/extensions/acceptance-executor/README.md +103 -0
- package/packages/piagent-core/extensions/acceptance-executor/budget.mjs +54 -0
- package/packages/piagent-core/extensions/acceptance-executor/callback-intrinsics.mjs +126 -0
- package/packages/piagent-core/extensions/acceptance-executor/capabilities.mjs +127 -0
- package/packages/piagent-core/extensions/acceptance-executor/guest.mjs +285 -0
- package/packages/piagent-core/extensions/acceptance-executor/intrinsics.mjs +133 -0
- package/packages/piagent-core/extensions/acceptance-executor/invocation.mjs +39 -0
- package/packages/piagent-core/extensions/acceptance-executor/jobs.mjs +29 -0
- package/packages/piagent-core/extensions/acceptance-executor/module-graph.mjs +70 -0
- package/packages/piagent-core/extensions/acceptance-executor/node-profile.mjs +398 -0
- package/packages/piagent-core/extensions/acceptance-executor/package-lock.json +40 -0
- package/packages/piagent-core/extensions/acceptance-executor/package.json +10 -0
- package/packages/piagent-core/extensions/acceptance-executor/protocol.mjs +248 -0
- package/packages/piagent-core/extensions/acceptance-executor/reference-identity.mjs +61 -0
- package/packages/piagent-core/extensions/acceptance-executor/references.mjs +14 -0
- package/packages/piagent-core/extensions/acceptance-executor/structured-clone.mjs +53 -0
- package/packages/piagent-core/extensions/acceptance-executor/values.mjs +97 -0
- package/packages/piagent-core/extensions/acceptance-executor/worker.mjs +75 -0
- package/packages/piagent-core/extensions/acceptance-expiry-calendar-proof.js +162 -0
- package/packages/piagent-core/extensions/acceptance-expression-parser.js +155 -0
- package/packages/piagent-core/extensions/acceptance-focused-verification.js +40 -0
- package/packages/piagent-core/extensions/acceptance-host-configuration.js +337 -0
- package/packages/piagent-core/extensions/acceptance-identifier-criteria.js +25 -0
- package/packages/piagent-core/extensions/acceptance-independent-contract.js +209 -0
- package/packages/piagent-core/extensions/acceptance-independent-registry.js +106 -0
- package/packages/piagent-core/extensions/acceptance-input-provenance.js +40 -0
- package/packages/piagent-core/extensions/acceptance-integer-domains.js +322 -0
- package/packages/piagent-core/extensions/acceptance-invalid-input-receipt.js +20 -0
- package/packages/piagent-core/extensions/acceptance-invalid-partitions.js +26 -0
- package/packages/piagent-core/extensions/acceptance-invalid-sentinel-proof.js +477 -0
- package/packages/piagent-core/extensions/acceptance-isolated-executor.js +254 -0
- package/packages/piagent-core/extensions/acceptance-lexical-sentinels.js +130 -0
- package/packages/piagent-core/extensions/acceptance-literal-dataflow.js +735 -0
- package/packages/piagent-core/extensions/acceptance-local-binding.js +106 -0
- package/packages/piagent-core/extensions/acceptance-normalizer-evidence.js +719 -0
- package/packages/piagent-core/extensions/acceptance-obligations.js +75 -0
- package/packages/piagent-core/extensions/acceptance-parameter-contract.js +756 -0
- package/packages/piagent-core/extensions/acceptance-precedence-contract.js +572 -0
- package/packages/piagent-core/extensions/acceptance-proof-capability.js +26 -0
- package/packages/piagent-core/extensions/acceptance-receipt.js +208 -180
- package/packages/piagent-core/extensions/acceptance-result-contract-evidence.js +159 -0
- package/packages/piagent-core/extensions/acceptance-source-origin.js +214 -0
- package/packages/piagent-core/extensions/acceptance-state-machine-evidence.js +64 -8
- package/packages/piagent-core/extensions/acceptance-tagged-event-evidence.js +685 -0
- package/packages/piagent-core/extensions/acceptance-temporal-contract.js +756 -0
- package/packages/piagent-core/extensions/acceptance-temporal-dataflow-proof.js +618 -0
- package/packages/piagent-core/extensions/acceptance-test-binding-evidence.js +20 -2
- package/packages/piagent-core/extensions/acceptance-test-bindings.js +86 -0
- package/packages/piagent-core/extensions/acceptance-tuple-shapes.js +12 -0
- package/packages/piagent-core/extensions/context-engine.js +12 -17
- 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/criterion-context-pack.js +109 -4
- package/packages/piagent-core/extensions/criterion-graph.js +4 -1
- package/packages/piagent-core/extensions/failure-types.ts +2 -2
- package/packages/piagent-core/extensions/fallback-base-policy.ts +101 -0
- package/packages/piagent-core/extensions/guard-types.ts +9 -1
- package/packages/piagent-core/extensions/piagent-guard.ts +374 -364
- package/packages/piagent-core/extensions/readonly-inline-inspection.ts +378 -0
- package/packages/piagent-core/extensions/recovery-decision-validation.ts +92 -0
- package/packages/piagent-core/extensions/shell-write-targets.js +15 -14
- package/packages/piagent-core/extensions/task-contract-view.js +4 -4
- package/packages/piagent-core/extensions/task-digest-migration.js +2 -2
- package/packages/piagent-core/extensions/task-journal.js +48 -3
- package/packages/piagent-core/extensions/task-lifecycle.js +32 -0
- package/packages/piagent-core/extensions/task-runtime-audit.js +8 -2
- package/packages/piagent-core/extensions/task-state.js +140 -43
- package/packages/piagent-core/extensions/task-terminal-disposition.js +10 -0
- package/packages/piagent-core/extensions/trajectory-contract.ts +5 -0
- package/packages/piagent-core/extensions/verification-intelligence.js +109 -20
- package/packages/piagent-core/extensions/workflow-catalog.ts +98 -0
- package/packages/piagent-core/extensions/workspace-evidence-roots.js +52 -16
- package/packages/piagent-core/extensions/workspace-revision.js +48 -0
- package/packages/piagent-core/extensions/workspace-verification-snapshot.js +13 -0
- package/packages/piagent-core/package.json +3 -3
- package/packages/piagent-core/policies/base-policy.json +43 -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/adaptive-planner.ts +7 -3
- package/packages/piagent-core/runtime/hooks/agent-start-hook.ts +60 -59
- package/packages/piagent-core/runtime/hooks/agent-start-types.ts +48 -0
- package/packages/piagent-core/runtime/hooks/completion-hook.ts +83 -89
- package/packages/piagent-core/runtime/hooks/input-hook.ts +98 -7
- package/packages/piagent-core/runtime/hooks/protected-refusal-completion.ts +86 -0
- package/packages/piagent-core/runtime/hooks/session-hooks.ts +5 -2
- package/packages/piagent-core/runtime/hooks/session-start-hook.ts +150 -19
- package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +111 -92
- package/packages/piagent-core/runtime/hooks/tool-result-metadata.ts +9 -0
- package/packages/piagent-core/runtime/hooks/tool-result-navigation.ts +36 -0
- package/packages/piagent-core/runtime/hooks/tool-result-retrieval.ts +42 -0
- package/packages/piagent-core/runtime/hooks/tool-result-value-helpers.ts +66 -0
- package/packages/piagent-core/runtime/input/chat-images.ts +1 -1
- package/packages/piagent-core/runtime/inspection/activity-event-adapter.ts +1 -1
- 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/same-process-bridge-proof.ts +1 -1
- package/packages/piagent-core/runtime/inspection/task-handoff-history.ts +2 -2
- package/packages/piagent-core/runtime/inspection/task-subagent-tree.ts +27 -4
- package/packages/piagent-core/runtime/inspection/tool-failure-classification.ts +69 -11
- package/packages/piagent-core/runtime/inspection/webui-snapshot.ts +104 -22
- package/packages/piagent-core/runtime/inspection/workspace-file-reader.ts +2 -132
- package/packages/piagent-core/runtime/model/provider-wire-fingerprint.ts +20 -0
- package/packages/piagent-core/runtime/model/service-tier-runtime.ts +242 -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/policy/source-worktree-transaction.ts +75 -14
- package/packages/piagent-core/runtime/product/activity-inspector.ts +6 -3
- package/packages/piagent-core/runtime/product/edit-verifier-timing.ts +26 -0
- package/packages/piagent-core/runtime/product/efficiency-metrics.ts +15 -7
- package/packages/piagent-core/runtime/product/operator-projections.ts +8 -3
- package/packages/piagent-core/runtime/product/task-usage-hooks.ts +78 -0
- package/packages/piagent-core/runtime/product/task-usage.ts +104 -0
- package/packages/piagent-core/runtime/quality/edit-freshness-guard.ts +102 -0
- package/packages/piagent-core/runtime/quality/exact-output-contract.ts +20 -10
- package/packages/piagent-core/runtime/quality/performance-assurance.ts +3 -3
- package/packages/piagent-core/runtime/quality/protected-refusal-handoff.ts +35 -0
- package/packages/piagent-core/runtime/recovery/acceptance-recovery-guidance.ts +21 -0
- package/packages/piagent-core/runtime/recovery/continuation-budget.ts +12 -3
- package/packages/piagent-core/runtime/recovery/diagnostic-delivery.ts +61 -0
- package/packages/piagent-core/runtime/recovery/handoff-projection.ts +196 -58
- package/packages/piagent-core/runtime/recovery/handoff-verifier-binding.ts +24 -0
- package/packages/piagent-core/runtime/recovery/independent-verification-recovery.ts +79 -0
- package/packages/piagent-core/runtime/recovery/pristine-task-policy-refresh.ts +91 -0
- package/packages/piagent-core/runtime/recovery/recovery-policy.ts +31 -40
- package/packages/piagent-core/runtime/recovery/resume-state.ts +120 -19
- package/packages/piagent-core/runtime/recovery/semantic-repair-handshake.ts +7 -13
- package/packages/piagent-core/runtime/recovery/task-evidence-coverage-refresh.ts +217 -0
- package/packages/piagent-core/runtime/registration/activity-inspector-command.ts +2 -1
- package/packages/piagent-core/runtime/registration/context-commands.ts +28 -10
- package/packages/piagent-core/runtime/registration/knowledge-tools.ts +9 -5
- package/packages/piagent-core/runtime/registration/operator-catalogs.ts +4 -9
- package/packages/piagent-core/runtime/registration/operator-request-intake.ts +49 -0
- package/packages/piagent-core/runtime/registration/policy-tools.ts +8 -6
- package/packages/piagent-core/runtime/registration/session-commands.ts +10 -8
- package/packages/piagent-core/runtime/registration/session-wait-tool.ts +54 -0
- package/packages/piagent-core/runtime/registration/task-completion-tools.ts +39 -20
- package/packages/piagent-core/runtime/registration/task-evidence-tools.ts +21 -12
- package/packages/piagent-core/runtime/registration/task-start-conditional-mutation.ts +45 -0
- package/packages/piagent-core/runtime/registration/task-start-guidance.ts +24 -15
- package/packages/piagent-core/runtime/registration/task-start-manifest.ts +54 -0
- package/packages/piagent-core/runtime/registration/task-start-tool.ts +79 -79
- package/packages/piagent-core/runtime/registration/workflow-commands.ts +64 -93
- 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/completion-signals.ts +23 -0
- package/packages/piagent-core/runtime/session/message-signals.ts +6 -18
- package/packages/piagent-core/runtime/session/operator-request-carry.ts +44 -0
- package/packages/piagent-core/runtime/session/retrieval-evidence-runtime.ts +188 -0
- package/packages/piagent-core/runtime/session/runtime-state.ts +37 -39
- 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/session/uncertain-send-continuation.ts +231 -0
- package/packages/piagent-core/runtime/session/usage.ts +4 -3
- package/packages/piagent-core/runtime/tools/apply-patch-tool.ts +6 -6
- package/packages/piagent-core/runtime/tools/phase-tool-runtime.ts +1 -1
- package/packages/piagent-core/runtime/tools/phase-tools.ts +10 -9
- package/packages/piagent-core/runtime/tools/session-wait.ts +42 -0
- package/packages/piagent-core/runtime/tools/tool-groups.ts +22 -5
- package/packages/piagent-core/runtime/trajectory/trajectory-runtime.ts +192 -5
- package/packages/piagent-core/runtime/trajectory/trajectory-types.ts +3 -2
- package/packages/piagent-core/runtime/verification/acceptance-api-baseline.js +488 -0
- package/packages/piagent-core/runtime/verification/completion-preparation.ts +22 -0
- package/packages/piagent-core/runtime/verification/composite-completion-finalizer.ts +105 -0
- package/packages/piagent-core/runtime/verification/composite-journal-anchor.ts +181 -0
- package/packages/piagent-core/runtime/verification/composite-runtime-binding.ts +76 -0
- package/packages/piagent-core/runtime/verification/composite-scoped-mediation.ts +318 -0
- package/packages/piagent-core/runtime/verification/composite-session-persistence.ts +175 -0
- package/packages/piagent-core/runtime/verification/composite-task-publication.ts +273 -0
- package/packages/piagent-core/runtime/verification/exact-verifier-reuse.ts +101 -0
- package/packages/piagent-core/runtime/verification/host-project-verification.ts +71 -0
- package/packages/piagent-core/runtime/verification/independent-acceptance-runtime.ts +500 -0
- package/packages/piagent-core/runtime/verification/runtime-assurance-facts.ts +500 -0
- package/packages/piagent-core/runtime/verification/runtime-contract-runner.ts +107 -0
- package/packages/piagent-core/runtime/verification/shell-verification-snapshots.ts +56 -0
- package/packages/piagent-core/runtime/workflows/change-clarification.ts +61 -0
- package/packages/piagent-core/runtime/workflows/input-routing.ts +21 -14
- package/packages/piagent-core/runtime/workflows/runtime-intake-compaction.ts +201 -0
- package/packages/piagent-core/runtime/workflows/task-followup-policy.ts +163 -0
- package/packages/piagent-core/runtime/workflows/task-intake.ts +276 -169
- package/packages/piagent-core/runtime/workflows/task-repair-intent.ts +67 -0
- package/packages/piagent-core/runtime/workflows/task-scope-resolution.ts +83 -0
- package/packages/piagent-core/runtime/workflows/webui-runtime-command.ts +5 -2
- package/packages/piagent-core/runtime/workflows/webui-workflow.ts +39 -32
- package/packages/piagent-core/runtime/workflows/workflow-follow-up.ts +33 -0
- package/packages/piagent-core/security/workspace-file-reader.ts +132 -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 +6 -4
- package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-CxeZqTte.js → MarkdownMessage-DGk34zJT.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{index-BV-_03yl.css → index-DVahUVWy.css} +1 -1
- package/packages/piagent-webui/dist/client/assets/index-DiKRmCEP.js +176 -0
- package/packages/piagent-webui/dist/client/index.html +2 -2
- package/packages/piagent-webui/extension/dispatch-user-entry.ts +13 -0
- package/packages/piagent-webui/extension/piagent-webui.ts +13 -3
- package/packages/piagent-webui/extension/review-controller.ts +29 -6
- package/packages/piagent-webui/extension/same-session-bridge.ts +7 -8
- package/packages/piagent-webui/extension/session-stream-adapter.ts +88 -16
- package/packages/piagent-webui/extension/source-mutation-controller.ts +29 -3
- package/packages/piagent-webui/extension/source-open-controller.ts +29 -7
- package/packages/piagent-webui/extension/source-revert-controller.ts +26 -3
- package/packages/piagent-webui/gateway/gateway-events.ts +22 -5
- package/packages/piagent-webui/gateway/gateway-service.ts +7 -2
- package/packages/piagent-webui/gateway/gateway-session-stream.ts +170 -32
- package/packages/piagent-webui/gateway/rpc-ui-context.ts +34 -9
- package/packages/piagent-webui/gateway/runtime-command-controller.ts +46 -6
- package/packages/piagent-webui/gateway/runtime-session-controls.ts +17 -2
- package/packages/piagent-webui/gateway/session-catalog.ts +9 -3
- package/packages/piagent-webui/gateway/session-command-controller.ts +29 -9
- package/packages/piagent-webui/gateway/session-effective-options.ts +2 -9
- package/packages/piagent-webui/gateway/session-inspection-registry.ts +11 -2
- 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-settlement.ts +28 -0
- package/packages/piagent-webui/gateway/session-operation-watchdog.ts +9 -2
- package/packages/piagent-webui/gateway/session-prompt-dispatch.ts +37 -0
- package/packages/piagent-webui/gateway/session-runtime-close.ts +36 -0
- package/packages/piagent-webui/gateway/session-runtime-factory.ts +183 -6
- package/packages/piagent-webui/gateway/session-runtime-ownership.ts +48 -0
- package/packages/piagent-webui/gateway/session-runtime-state.ts +24 -0
- package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +118 -117
- package/packages/piagent-webui/ownership/session-lease-store.ts +5 -2
- package/packages/piagent-webui/server/core-inspection-provider.ts +75 -15
- package/packages/piagent-webui/server/loopback-server.ts +9 -7
- package/packages/piagent-webui/server/terminal-delivery-receipt.ts +144 -0
- package/packages/piagent-webui/server/transcript-projection.ts +150 -11
- package/packages/piagent-webui/shared/message-correlation.ts +25 -0
- package/schemas/approved-host-contracts.schema.json +973 -0
- package/schemas/benchmark-attempt-outcome.schema.json +303 -0
- package/schemas/benchmark-independent-verification-plan.schema.json +34 -0
- package/schemas/codex-relative-efficiency-v1.schema.json +155 -0
- package/schemas/composite-criterion.schema.json +788 -0
- package/schemas/contract-family-library.schema.json +28 -0
- package/schemas/contract-selection-recipe.schema.json +31 -0
- package/schemas/failure-evidence.schema.json +2 -2
- package/schemas/helper-request.schema.json +16 -4
- package/schemas/host-contract-plan.schema.json +25 -0
- package/schemas/piagent-webui/gateway-protocol-v1.schema.json +16 -2
- package/schemas/piagent-webui/runtime-command-v1.schema.json +26 -3
- package/schemas/piagent-webui/runtime-event-v2.schema.json +46 -5
- package/schemas/piagent-webui/session-live-state-v1.schema.json +2 -0
- package/schemas/piagent-webui/snapshot-v1.schema.json +3 -0
- package/schemas/piagent-webui/source-change-v1.schema.json +12 -0
- package/schemas/piagent-webui/subagent-tree-v1.schema.json +11 -1
- package/schemas/piagent-webui/transcript-v1.schema.json +2 -1
- package/schemas/project-profile.schema.json +1 -1
- package/schemas/public-contracts/codex-mcp-metadata-v1.schema.json +206 -0
- package/schemas/public-contracts/codex-mcp-metadata-v2.schema.json +228 -0
- package/schemas/public-contracts/codex-mcp-metadata-v3.schema.json +233 -0
- package/schemas/public-contracts/revocation-v1.schema.json +87 -0
- package/schemas/public-contracts/subscription-contract-v1.schema.json +76 -0
- package/schemas/scoped-project-verification-receipt-v2.schema.json +83 -0
- package/schemas/scoped-project-verification-receipt-v3.schema.json +295 -0
- package/schemas/scoped-verification-receipt-v1.schema.json +76 -0
- package/schemas/task-contract.schema.json +45 -0
- package/scripts/approve-independent-verification.mjs +57 -0
- package/scripts/benchmark-arm-observer.mjs +320 -0
- package/scripts/benchmark-budget-ipc.mjs +34 -0
- package/scripts/benchmark-budget-launcher.mjs +91 -0
- package/scripts/benchmark-budget-processes.mjs +133 -0
- package/scripts/benchmark-budget-publication.mjs +228 -0
- package/scripts/benchmark-budget-runtime.mjs +136 -0
- package/scripts/benchmark-candidate-ablation.mjs +265 -0
- package/scripts/benchmark-codex-journey.mjs +406 -0
- package/scripts/benchmark-independent-verification.mjs +628 -0
- package/scripts/benchmark-journey-outcome.mjs +92 -0
- package/scripts/benchmark-production-v3-human-review.mjs +192 -0
- package/scripts/benchmark-public-input-catalog.mjs +158 -0
- package/scripts/benchmark-registered-plan-author.mjs +355 -0
- package/scripts/benchmark-registered-plan-recipe-support.mjs +85 -0
- package/scripts/benchmark-registered-plan-recipes-backend.mjs +165 -0
- package/scripts/benchmark-registered-plan-recipes-data.mjs +164 -0
- package/scripts/benchmark-registered-plan-recipes-platform.mjs +165 -0
- package/scripts/benchmark-runner-completion.mjs +133 -0
- package/scripts/benchmark-runner-configuration.mjs +159 -0
- package/scripts/benchmark-runner-core.mjs +224 -387
- package/scripts/benchmark-runner-finalization.mjs +144 -27
- package/scripts/benchmark-runner-provider-boundary.mjs +44 -0
- package/scripts/benchmark-runner-schedule.mjs +256 -0
- package/scripts/benchmark-runner-support.mjs +136 -4
- package/scripts/benchmark-runner.mjs +95 -18
- package/scripts/benchmark-scoped-broker-custody.mjs +483 -0
- package/scripts/benchmark-scoped-docs-verifier.mjs +203 -0
- package/scripts/benchmark-scoped-frozen-qualification.mjs +676 -0
- package/scripts/benchmark-scoped-pi-router.mjs +196 -0
- package/scripts/benchmark-scoped-project-verification-receipt.mjs +49 -0
- package/scripts/benchmark-scoped-project-verifier.mjs +461 -0
- package/scripts/benchmark-scoped-session-custody.mjs +599 -0
- package/scripts/benchmark-scoped-session-factory.mjs +342 -0
- package/scripts/benchmark-scoped-tool-broker.mjs +523 -0
- package/scripts/benchmark-scoped-verification-supervisor.mjs +773 -0
- package/scripts/benchmark-session-evaluator.mjs +169 -0
- package/scripts/benchmark-session-provider-boundary.mjs +62 -0
- package/scripts/benchmark-session-usage.mjs +28 -0
- package/scripts/benchmark-session.mjs +343 -50
- package/scripts/benchmark-webui-journey.mjs +678 -0
- package/scripts/check-public-wording.mjs +46 -0
- package/scripts/configure-subagents.sh +42 -34
- package/scripts/fs4-readiness-evaluation.mjs +7 -1
- package/scripts/helper-evaluation.mjs +1 -1
- package/scripts/phase-tools-evaluation.mjs +1 -0
- package/scripts/pi-auto.sh +7 -1
- package/scripts/pi-usage-history.mjs +201 -11
- package/scripts/piagent-cli.mjs +8 -0
- package/scripts/private-holdout-readiness.mjs +7 -1
- package/scripts/public-evaluation-exposure.mjs +140 -0
- package/scripts/select-independent-verification.mjs +62 -0
- package/scripts/team-doctor.sh +1 -1
- package/scripts/typescript-loader.mjs +135 -1
- package/scripts/update-global.mjs +6 -7
- package/scripts/verify-local.sh +41 -55
- package/scripts/verify-release-identity.mjs +5 -3
- package/packages/piagent-webui/dist/client/assets/index-DynIMe8I.js +0 -176
|
@@ -0,0 +1,1000 @@
|
|
|
1
|
+
import { dependencyGraphNonMutationEvidence } from "./acceptance-parameter-contract.js"; import { finiteIntervalNonMutationEvidence } from "./acceptance-temporal-contract.js";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
import { acceptanceContractConjuncts } from "./acceptance-contract-conjunction.js";
|
|
7
|
+
import { pureRecordNonMutationEvidence, byteArrayNonMutationEvidence, braceScope, sameScope, unconditionalEvidenceScope, constantDeclarations, literalBinding, splitTopLevel, flatObjectSnapshot, stableDeepSnapshot, boundStringValue, exactBoundValue, callArgumentNames } from "./acceptance-literal-dataflow.js";
|
|
8
|
+
import { acceptanceResultContractEvidence } from "./acceptance-result-contract-evidence.js";
|
|
9
|
+
import { criterionGraphValidationErrors } from "./criterion-graph.js";
|
|
10
|
+
import { regexCanStartAfterLexicalChunks } from "./javascript-regex-evidence.js";
|
|
11
|
+
import { normalizePathCandidate } from "./policy-core.js";
|
|
12
|
+
|
|
13
|
+
const BOUND_STRING = "__pi_bound_string_";
|
|
14
|
+
const BEHAVIOR_STOPWORDS = new Set([
|
|
15
|
+
"after", "also", "before", "behavior", "change", "configured", "every", "first", "remain", "requested",
|
|
16
|
+
"return", "shape", "standalone", "support", "value", "verification", "without"
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
function sha256(value) {
|
|
20
|
+
return crypto.createHash("sha256").update(String(value ?? "")).digest("hex");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { sha256 as acceptanceTextHash };
|
|
24
|
+
|
|
25
|
+
// A multiline criterion preserves distinct intake clauses. No legacy matcher
|
|
26
|
+
// proves their conjunction; an independent assessment must cover the full hash.
|
|
27
|
+
export function compoundAcceptanceCriterion(text) {
|
|
28
|
+
return /[\r\n]/.test(String(text ?? "").trim());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function acceptanceCriterionBindingValid(task, receipt, criterion, index) {
|
|
32
|
+
const texts = task?.acceptanceCriteria;
|
|
33
|
+
return Array.isArray(texts) && texts.length === receipt.criteria.length
|
|
34
|
+
&& typeof texts[index] === "string" && sha256(texts[index]) === criterion.hash
|
|
35
|
+
&& receipt.criteria.filter((item) => item.id === criterion.id).length === 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function resetUnprovenCriterion(criterion) {
|
|
39
|
+
const changed = criterion.status !== "pending" || criterion.evidence.length > 0 || criterion.priority !== "critical";
|
|
40
|
+
criterion.status = "pending";
|
|
41
|
+
criterion.evidence = [];
|
|
42
|
+
criterion.priority = "critical";
|
|
43
|
+
return changed;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function acceptanceEvidenceKey(evidence) {
|
|
47
|
+
return JSON.stringify({
|
|
48
|
+
kind: evidence.kind,
|
|
49
|
+
summary: evidence.summary,
|
|
50
|
+
paths: evidence.paths ?? [],
|
|
51
|
+
command: evidence.command,
|
|
52
|
+
exitCode: evidence.exitCode,
|
|
53
|
+
workingTreeDigest: evidence.workingTreeDigest
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function escapeRegex(value) {
|
|
58
|
+
return String(value ?? "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function normalizedText(value) {
|
|
62
|
+
return String(value ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function durableBehaviorProofRequired(text, changeMode = "source-change") {
|
|
66
|
+
const value = String(text ?? "");
|
|
67
|
+
if (changeMode === "read-only") return false;
|
|
68
|
+
return /\b(?:concurren|do not mutate|must not mutate|without mutating|inputs? must remain unchanged|return shape|returned? (?:element|object|value|representation)|preserve (?:the )?(?:api|input|output|return)|public api|exact error|typeerror|syntaxerror|rangeerror)\b/i.test(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function boundCriterionGraphNode(task, criterion) {
|
|
72
|
+
if (!task?.criterionGraph || criterionGraphValidationErrors(task.criterionGraph, task).length > 0) return undefined;
|
|
73
|
+
const criterionIndex = (Array.isArray(task.acceptanceCriteria) ? task.acceptanceCriteria : [])
|
|
74
|
+
.findIndex((text) => typeof text === "string" && sha256(text) === criterion?.hash);
|
|
75
|
+
return criterionIndex < 0 ? undefined : task.criterionGraph.nodes.find((node) => node.criterionIndex === criterionIndex);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function boundCriterionText(task, criterion) {
|
|
79
|
+
return (Array.isArray(task?.acceptanceCriteria) ? task.acceptanceCriteria : [])
|
|
80
|
+
.find((text) => typeof text === "string" && sha256(text) === criterion?.hash);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function criterionRequiresBehavioralProof(task, criterion, taskText) {
|
|
84
|
+
return durableBehaviorProofRequired(taskText, task?.changeMode)
|
|
85
|
+
&& boundCriterionGraphNode(task, criterion)?.proofKinds?.includes("behavioral-check") === true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function isVerificationOnlyCriterion(text) {
|
|
89
|
+
const value = normalizedText(text).replace(/^\s*\[[^\]]+\]\s*/, "").trim();
|
|
90
|
+
return /^(?:verify(?: the)? project|(?:run|execute|rerun|re-run)\s+(?:the\s+)?(?:(?:configured|exact|project|workspace|focused)\s+)?(?:verification(?: commands?)?|verifiers?|tests?|typecheck|lint|build)\b[\s\S]*|(?:the\s+)?(?:(?:configured|exact|project|workspace)\s+)?(?:verification(?: command)?|verifier|tests?|typecheck|lint|build)\b[\s\S]*\b(?:pass(?:es)?|run|succeed(?:s)?|verify)\b[\s\S]*)[.!?]*$/.test(value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* A small lexer used only to bind executable module strings and call inputs. */
|
|
94
|
+
function bindJavaScriptStrings(value) {
|
|
95
|
+
const source = String(value ?? "");
|
|
96
|
+
const output = [];
|
|
97
|
+
const strings = [];
|
|
98
|
+
let index = 0;
|
|
99
|
+
while (index < source.length) {
|
|
100
|
+
const current = source[index];
|
|
101
|
+
const next = source[index + 1];
|
|
102
|
+
if (current === "/" && next === "/") {
|
|
103
|
+
while (index < source.length && !/[\r\n]/.test(source[index])) { output.push(" "); index += 1; }
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (current === "/" && next === "*") {
|
|
107
|
+
const end = source.indexOf("*/", index + 2);
|
|
108
|
+
const limit = end < 0 ? source.length : end + 2;
|
|
109
|
+
while (index < limit) { output.push(/[\r\n]/.test(source[index]) ? source[index] : " "); index += 1; }
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (current === "'" || current === '"') {
|
|
113
|
+
const quote = current;
|
|
114
|
+
let cursor = index + 1;
|
|
115
|
+
let payload = "";
|
|
116
|
+
let closed = false;
|
|
117
|
+
while (cursor < source.length) {
|
|
118
|
+
if (source[cursor] === "\\") { payload += source.slice(cursor, cursor + 2); cursor += 2; continue; }
|
|
119
|
+
if (source[cursor] === quote) { cursor += 1; closed = true; break; }
|
|
120
|
+
payload += source[cursor]; cursor += 1;
|
|
121
|
+
}
|
|
122
|
+
if (closed) {
|
|
123
|
+
output.push(`${BOUND_STRING}${strings.length}__`);
|
|
124
|
+
strings.push(payload);
|
|
125
|
+
} else {
|
|
126
|
+
output.push(" ".repeat(Math.max(1, cursor - index)));
|
|
127
|
+
}
|
|
128
|
+
index = cursor;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (current === "`") {
|
|
132
|
+
let cursor = index + 1;
|
|
133
|
+
let payload = "";
|
|
134
|
+
let closed = false;
|
|
135
|
+
let interpolated = false;
|
|
136
|
+
while (cursor < source.length) {
|
|
137
|
+
if (source[cursor] === "\\") { payload += source.slice(cursor, cursor + 2); cursor += 2; continue; }
|
|
138
|
+
if (source[cursor] === "$" && source[cursor + 1] === "{") interpolated = true;
|
|
139
|
+
if (source[cursor] === "`") { cursor += 1; closed = true; break; }
|
|
140
|
+
payload += source[cursor]; cursor += 1;
|
|
141
|
+
}
|
|
142
|
+
if (closed && !interpolated) {
|
|
143
|
+
output.push(`${BOUND_STRING}${strings.length}__`);
|
|
144
|
+
strings.push(payload);
|
|
145
|
+
} else {
|
|
146
|
+
output.push(" ".repeat(Math.max(1, cursor - index)));
|
|
147
|
+
}
|
|
148
|
+
index = cursor;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (current === "/" && next !== "=" && regexCanStartAfterLexicalChunks(output)) {
|
|
152
|
+
let cursor = index + 1;
|
|
153
|
+
let inClass = false;
|
|
154
|
+
let closed = false;
|
|
155
|
+
while (cursor < source.length) {
|
|
156
|
+
if (source[cursor] === "\\") { cursor += 2; continue; }
|
|
157
|
+
if (source[cursor] === "[") inClass = true;
|
|
158
|
+
else if (source[cursor] === "]") inClass = false;
|
|
159
|
+
else if (source[cursor] === "/" && !inClass) { cursor += 1; while (/[a-z]/i.test(source[cursor] ?? "")) cursor += 1; closed = true; break; }
|
|
160
|
+
else if (/[\r\n]/.test(source[cursor])) break;
|
|
161
|
+
cursor += 1;
|
|
162
|
+
}
|
|
163
|
+
if (closed) {
|
|
164
|
+
output.push(" ".repeat(Math.max(1, cursor - index)));
|
|
165
|
+
index = cursor;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
output.push(current);
|
|
170
|
+
index += 1;
|
|
171
|
+
}
|
|
172
|
+
return { code: output.join(""), strings };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
function moduleRecords(entry) {
|
|
177
|
+
const evidence = String(entry.evidenceText ?? "");
|
|
178
|
+
if (!/\b(?:import|export|require)\b[\s\S]{0,260}\b__pi_[a-z0-9_]+__/i.test(evidence)) return [];
|
|
179
|
+
const { code, strings } = bindJavaScriptStrings(entry.text);
|
|
180
|
+
const records = [];
|
|
181
|
+
const token = "(__pi_bound_string_[0-9]+__)";
|
|
182
|
+
const patterns = [
|
|
183
|
+
{ kind: "module", pattern: new RegExp(`\\b(?:import|export)\\s+([\\s\\S]{0,220}?)\\s+from\\s+${token}`, "g") },
|
|
184
|
+
{ kind: "side-effect", pattern: new RegExp(`\\bimport\\s*(?:\\(\\s*)?${token}`, "g") },
|
|
185
|
+
{ kind: "require", pattern: new RegExp(`\\b(?:const|let|var)\\s+([^=;\\n]{1,160})=\\s*require\\s*\\(\\s*${token}`, "g") }
|
|
186
|
+
];
|
|
187
|
+
for (const { kind, pattern } of patterns) {
|
|
188
|
+
for (const match of code.matchAll(pattern)) {
|
|
189
|
+
const specifier = boundStringValue(match.at(-1), strings);
|
|
190
|
+
if (typeof specifier === "string") records.push({ kind, clause: match[1] ?? "", specifier });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return records;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function importedBindings(record) {
|
|
197
|
+
const bindings = [];
|
|
198
|
+
const clause = record.clause.trim();
|
|
199
|
+
for (const match of clause.matchAll(/(?:^|[{,])\s*([a-z_$][a-z0-9_$]*)\s*(?:as\s+([a-z_$][a-z0-9_$]*))?/gi)) {
|
|
200
|
+
bindings.push({ exported: match[1], local: match[2] ?? match[1] });
|
|
201
|
+
}
|
|
202
|
+
const namespace = clause.match(/\*\s+as\s+([a-z_$][a-z0-9_$]*)/i)?.[1];
|
|
203
|
+
if (namespace) bindings.push({ exported: "*", local: namespace });
|
|
204
|
+
const defaultBinding = clause.match(/^([a-z_$][a-z0-9_$]*)\s*(?:,|$)/i)?.[1];
|
|
205
|
+
if (defaultBinding && !bindings.some((item) => item.local === defaultBinding)) {
|
|
206
|
+
bindings.push({ exported: "default", local: defaultBinding });
|
|
207
|
+
}
|
|
208
|
+
if (record.kind === "require") {
|
|
209
|
+
for (const match of clause.matchAll(/(?:^|[{,])\s*([a-z_$][a-z0-9_$]*)\s*(?::\s*([a-z_$][a-z0-9_$]*))?/gi)) {
|
|
210
|
+
bindings.push({ exported: match[1], local: match[2] ?? match[1] });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return bindings;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function exportedNames(sourceEntries) {
|
|
217
|
+
const names = new Set();
|
|
218
|
+
for (const entry of sourceEntries) {
|
|
219
|
+
const text = String(entry.evidenceText ?? "");
|
|
220
|
+
for (const match of text.matchAll(/\bexport\s+(?:async\s+)?(?:function|class|const|let|var)\s+([a-z_$][a-z0-9_$]*)/gi)) names.add(match[1]);
|
|
221
|
+
for (const match of text.matchAll(/\bexport\s*\{([^}]+)\}/gi)) {
|
|
222
|
+
for (const item of match[1].split(",")) {
|
|
223
|
+
const name = item.trim().match(/(?:^|\s+as\s+)([a-z_$][a-z0-9_$]*)$/i)?.[1];
|
|
224
|
+
if (name) names.add(name);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
for (const match of text.matchAll(/\b(?:module\.exports|exports)\.([a-z_$][a-z0-9_$]*)\s*=/gi)) names.add(match[1]);
|
|
228
|
+
}
|
|
229
|
+
return names;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function resolvedSpecifierSources(testPath, specifier, sourceFiles) {
|
|
233
|
+
if (!specifier.startsWith(".")) return [];
|
|
234
|
+
const resolved = normalizePathCandidate(path.posix.normalize(path.posix.join(path.posix.dirname(testPath), specifier)));
|
|
235
|
+
const candidates = new Set([resolved, resolved.replace(/\.[a-z0-9]+$/i, "")]);
|
|
236
|
+
return sourceFiles.map((file) => normalizePathCandidate(file)).filter((source) => {
|
|
237
|
+
const stem = source.replace(/\.[a-z0-9]+$/i, "");
|
|
238
|
+
return candidates.has(source) || candidates.has(stem) || stem === `${resolved.replace(/\/$/, "")}/index`;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* linked = proven; unknown = alias/barrel/indirect may be valid; unlinked = only unrelated imports. */
|
|
243
|
+
function testSourceLinkage(corpus) {
|
|
244
|
+
const sourceExports = new Map(corpus.sourceEntries.map((entry) => [
|
|
245
|
+
normalizePathCandidate(entry.path), exportedNames([entry])
|
|
246
|
+
]));
|
|
247
|
+
const linkedEntries = [];
|
|
248
|
+
let unresolvedProjectImport = false;
|
|
249
|
+
for (const entry of corpus.testEntries) {
|
|
250
|
+
const records = moduleRecords(entry);
|
|
251
|
+
const callables = new Set();
|
|
252
|
+
const callableBindings = [];
|
|
253
|
+
let linked = false;
|
|
254
|
+
for (const record of records) {
|
|
255
|
+
const importBindings = importedBindings(record);
|
|
256
|
+
const sourcePaths = resolvedSpecifierSources(entry.path, record.specifier, corpus.sourceFiles);
|
|
257
|
+
if (sourcePaths.length > 0) {
|
|
258
|
+
linked = true;
|
|
259
|
+
for (const binding of importBindings) {
|
|
260
|
+
if (binding.exported === "*") sourcePaths.forEach((sourcePath) => {
|
|
261
|
+
for (const name of sourceExports.get(sourcePath) ?? []) {
|
|
262
|
+
const testName = `${binding.local}.${name}`;
|
|
263
|
+
callables.add(testName);
|
|
264
|
+
callableBindings.push({ sourceName: name, sourcePath, testName });
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
else {
|
|
268
|
+
callables.add(binding.local);
|
|
269
|
+
for (const sourcePath of sourcePaths) {
|
|
270
|
+
if (sourceExports.get(sourcePath)?.has(binding.exported)) {
|
|
271
|
+
callableBindings.push({ sourceName: binding.exported, sourcePath, testName: binding.local });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (record.specifier.startsWith(".") || /^[#@~]/.test(record.specifier)) unresolvedProjectImport = true;
|
|
279
|
+
}
|
|
280
|
+
if (linked) linkedEntries.push({ entry, callables: [...callables], bindings: callableBindings });
|
|
281
|
+
}
|
|
282
|
+
if (linkedEntries.length > 0) return { status: "linked", entries: linkedEntries };
|
|
283
|
+
return { status: unresolvedProjectImport ? "unknown" : "unlinked", entries: [] };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function balancedCallEnd(code, openIndex) {
|
|
287
|
+
let depth = 0;
|
|
288
|
+
for (let index = openIndex; index < code.length; index += 1) {
|
|
289
|
+
if (code[index] === "(") depth += 1;
|
|
290
|
+
else if (code[index] === ")" && --depth === 0) return index + 1;
|
|
291
|
+
}
|
|
292
|
+
return -1;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function enclosingTestDescriptions(code, strings, callStart) {
|
|
296
|
+
const descriptions = [];
|
|
297
|
+
const pattern = new RegExp(`\\b(?:it|test)\\s*\\(\\s*(${BOUND_STRING}[0-9]+__)\\s*,`, "g");
|
|
298
|
+
for (const match of code.matchAll(pattern)) {
|
|
299
|
+
if (match.index >= callStart) break;
|
|
300
|
+
const open = code.indexOf("(", match.index);
|
|
301
|
+
const end = balancedCallEnd(code, open);
|
|
302
|
+
const description = boundStringValue(match[1], strings);
|
|
303
|
+
if (end > callStart && typeof description === "string" && description.trim()) {
|
|
304
|
+
descriptions.push({ start: match.index, description });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return descriptions.sort((left, right) => right.start - left.start).map((item) => item.description);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function assertionSlices(code) {
|
|
311
|
+
const assertions = [];
|
|
312
|
+
const pattern = /\b(?:assert(?:\.[a-z][a-z0-9_]*)?|expect)\s*\(/gi;
|
|
313
|
+
for (const match of code.matchAll(pattern)) {
|
|
314
|
+
const open = code.indexOf("(", match.index);
|
|
315
|
+
let end = balancedCallEnd(code, open);
|
|
316
|
+
if (end < 0) continue;
|
|
317
|
+
if (/\bexpect\s*\(/i.test(match[0])) {
|
|
318
|
+
const statementEnd = code.slice(end).search(/[;\r\n]/);
|
|
319
|
+
if (statementEnd >= 0) end += statementEnd;
|
|
320
|
+
}
|
|
321
|
+
assertions.push({ start: match.index, end, code: code.slice(match.index, end) });
|
|
322
|
+
}
|
|
323
|
+
return assertions;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function assignedCallNames(code, callStart) {
|
|
327
|
+
const prefix = code.slice(Math.max(0, callStart - 160), callStart);
|
|
328
|
+
return [
|
|
329
|
+
prefix.match(/\b(?:const|let|var)\s+([a-z_$][a-z0-9_$]*)\s*=\s*(?:await\s*)?$/i)?.[1],
|
|
330
|
+
prefix.match(/\b([a-z_$][a-z0-9_$]*)\s*=\s*(?:await\s*)?$/i)?.[1]
|
|
331
|
+
].filter(Boolean);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function nextBindingWrite(code, name, after) {
|
|
335
|
+
const escaped = escapeRegex(name);
|
|
336
|
+
const pattern = new RegExp(`\\b(?:const|let|var)\\s+${escaped}\\s*=|\\b${escaped}\\s*(?:=(?!=|>)|(?:\\|\\||&&|\\?\\?|\\*\\*|<<|>>>?|[+*/%&|^\\-])=|\\+\\+|--)|(?:\\+\\+|--)\\s*\\b${escaped}\\b|[\\[{][^;\\n]*\\b${escaped}\\b[^;\\n]*[\\]}]\\s*=(?!=|>)`, "g");
|
|
337
|
+
pattern.lastIndex = after;
|
|
338
|
+
return pattern.exec(code)?.index ?? Number.POSITIVE_INFINITY;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
function callableSlices(code, strings, callables) {
|
|
344
|
+
const calls = [];
|
|
345
|
+
const assertions = assertionSlices(code);
|
|
346
|
+
const declarations = constantDeclarations(code);
|
|
347
|
+
for (const callable of callables) {
|
|
348
|
+
const pattern = new RegExp(`\\b${escapeRegex(callable)}\\s*\\(`, "g");
|
|
349
|
+
for (const match of code.matchAll(pattern)) {
|
|
350
|
+
const open = code.indexOf("(", match.index);
|
|
351
|
+
const end = balancedCallEnd(code, open);
|
|
352
|
+
if (end < 0) continue;
|
|
353
|
+
const slice = code.slice(match.index, end);
|
|
354
|
+
let values = [...slice.matchAll(/__pi_bound_string_[0-9]+__/g)]
|
|
355
|
+
.map((item) => boundStringValue(item[0], strings)).filter((item) => typeof item === "string");
|
|
356
|
+
const argumentNames = callArgumentNames(slice);
|
|
357
|
+
const resultNames = [...new Set(assignedCallNames(code, match.index))];
|
|
358
|
+
const bindingNames = [...resultNames, ...argumentNames];
|
|
359
|
+
const resultWriteLimits = new Map(resultNames.map((name) => [name, nextBindingWrite(code, name, end)]));
|
|
360
|
+
const boundAssertions = assertions.filter((assertion) => (
|
|
361
|
+
(assertion.start <= match.index && assertion.end >= end)
|
|
362
|
+
|| assertion.start >= end && bindingNames.some((name) => (
|
|
363
|
+
new RegExp(`\\b${escapeRegex(name)}\\b`).test(assertion.code)
|
|
364
|
+
&& (!resultWriteLimits.has(name) || assertion.start < resultWriteLimits.get(name))
|
|
365
|
+
))
|
|
366
|
+
));
|
|
367
|
+
const assertionValues = boundAssertions.flatMap((assertion) => (
|
|
368
|
+
[...assertion.code.matchAll(/__pi_bound_string_[0-9]+__/g)]
|
|
369
|
+
.map((item) => boundStringValue(item[0], strings)).filter((item) => typeof item === "string")
|
|
370
|
+
));
|
|
371
|
+
const call = {
|
|
372
|
+
callable,
|
|
373
|
+
slice, values, strings, resultNames, argumentNames, assertionValues, prelude: code.slice(0, match.index),
|
|
374
|
+
assertions: boundAssertions.map((item) => item.code),
|
|
375
|
+
descriptions: enclosingTestDescriptions(code, strings, match.index),
|
|
376
|
+
code, declarations, start: match.index, end,
|
|
377
|
+
safeScope: unconditionalEvidenceScope(code, match.index),
|
|
378
|
+
scopedAssertions: boundAssertions.filter((assertion) => unconditionalEvidenceScope(code, assertion.start)
|
|
379
|
+
&& sameScope(braceScope(code, assertion.start), braceScope(code, match.index)))
|
|
380
|
+
};
|
|
381
|
+
const callableRoot = callable.split(".")[0];
|
|
382
|
+
const callScope = braceScope(code, match.index);
|
|
383
|
+
if (declarations.some((entry) => entry.name === callableRoot && entry.start < match.index
|
|
384
|
+
&& entry.scope.every((open, index) => callScope[index] === open))) call.safeScope = false;
|
|
385
|
+
for (const shadow of code.matchAll(new RegExp(`\\b(?:function|class)\\s+${escapeRegex(callableRoot)}\\b`, "g"))) {
|
|
386
|
+
if (braceScope(code, shadow.index).every((open, index) => callScope[index] === open)) call.safeScope = false;
|
|
387
|
+
}
|
|
388
|
+
const argumentsList = splitTopLevel(slice.slice(slice.indexOf("(") + 1, -1));
|
|
389
|
+
if (call.safeScope && argumentsList.length === 1 && /^[a-z_$][a-z0-9_$]*$/i.test(argumentsList[0])) {
|
|
390
|
+
const literal = literalBinding(call, argumentsList[0], match.index);
|
|
391
|
+
if (literal?.kind === "array" && literal.elements.every((item) => typeof item.value === "string")) {
|
|
392
|
+
call.values = literal.elements.map((item) => item.value);
|
|
393
|
+
call.assertions = call.scopedAssertions.map((assertion) => assertion.code);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (boundAssertions.length > 0) calls.push(call);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return calls;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
function assertionComparisons(call) {
|
|
404
|
+
return call.assertions.flatMap((assertion) => {
|
|
405
|
+
const assertCall = assertion.match(/^\s*assert\.(?:equal|strictEqual|deepEqual|deepStrictEqual)\s*\(/i);
|
|
406
|
+
if (assertCall) {
|
|
407
|
+
const open = assertion.indexOf("(", assertCall.index);
|
|
408
|
+
const end = balancedCallEnd(assertion, open);
|
|
409
|
+
const [actual, expected] = end > open ? splitTopLevel(assertion.slice(open + 1, end - 1)) : [];
|
|
410
|
+
return actual && expected ? [{ actual, expected }] : [];
|
|
411
|
+
}
|
|
412
|
+
const expectCall = assertion.match(/^\s*expect\s*\(/i);
|
|
413
|
+
if (!expectCall) return [];
|
|
414
|
+
const open = assertion.indexOf("(", expectCall.index);
|
|
415
|
+
const end = balancedCallEnd(assertion, open);
|
|
416
|
+
const matcher = end > open ? assertion.slice(end).match(/^\s*\.to(?:Be|Equal|StrictEqual)\s*\(/i) : undefined;
|
|
417
|
+
if (!matcher) return [];
|
|
418
|
+
const expectedOpen = assertion.indexOf("(", end + matcher.index);
|
|
419
|
+
const expectedEnd = balancedCallEnd(assertion, expectedOpen);
|
|
420
|
+
return expectedEnd > expectedOpen ? [{ actual: assertion.slice(open + 1, end - 1).trim(), expected: assertion.slice(expectedOpen + 1, expectedEnd - 1).trim() }] : [];
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
function propertyExpression(objectExpression, property, strings) {
|
|
426
|
+
const value = String(objectExpression ?? "").trim();
|
|
427
|
+
if (!(value.startsWith("{") && value.endsWith("}"))) return undefined;
|
|
428
|
+
const members = splitTopLevel(value.slice(1, -1));
|
|
429
|
+
if (members.at(-1) === "") members.pop();
|
|
430
|
+
const fields = new Map();
|
|
431
|
+
for (const member of members) {
|
|
432
|
+
const colon = member.indexOf(":");
|
|
433
|
+
if (colon < 0) return undefined;
|
|
434
|
+
const rawKey = member.slice(0, colon).trim();
|
|
435
|
+
const key = boundStringValue(rawKey, strings) ?? (/^[a-z_$][a-z0-9_$]*$/i.test(rawKey) ? rawKey : undefined);
|
|
436
|
+
// Bound strings retain escape spelling; do not mistake escaped aliases
|
|
437
|
+
// for distinct runtime property names without a verified decoder.
|
|
438
|
+
if (key === undefined || key.includes("\\") || key === "__proto__" || fields.has(key)) return undefined;
|
|
439
|
+
fields.set(key, member.slice(colon + 1).trim());
|
|
440
|
+
}
|
|
441
|
+
return fields.get(property);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function callResultExpression(call, expression) {
|
|
445
|
+
const value = String(expression ?? "");
|
|
446
|
+
return call.resultNames.some((name) => new RegExp(`^\\s*${escapeRegex(name)}\\b`).test(value)) || value.includes(call.slice);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function actualField(call, actual, container, field) {
|
|
450
|
+
if (!callResultExpression(call, actual)) return false;
|
|
451
|
+
const dot = new RegExp(`\\.${escapeRegex(container)}\\s*\\.\\s*${escapeRegex(field)}\\b`);
|
|
452
|
+
if (dot.test(actual)) return true;
|
|
453
|
+
const bracket = new RegExp(`\\.${escapeRegex(container)}\\s*\\[\\s*(__pi_bound_string_[0-9]+__)\\s*\\]`).exec(actual);
|
|
454
|
+
return bracket ? boundStringValue(bracket[1], call.strings) === field : false;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function actualContainer(call, actual, container) {
|
|
458
|
+
return callResultExpression(call, actual) && new RegExp(`\\.${escapeRegex(container)}\\s*$`).test(actual);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function actualWholeResult(call, actual) {
|
|
462
|
+
const value = String(actual ?? "").trim();
|
|
463
|
+
return call.resultNames.includes(value) || value === call.slice;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function expectedValueMatches(expression, expected, strings) {
|
|
467
|
+
return exactBoundValue(expression, strings) === expected;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function assertedFlagValue(call, flag, expected) {
|
|
471
|
+
return assertionComparisons(call).some(({ actual, expected: asserted }) => {
|
|
472
|
+
if (actualField(call, actual, "flags", flag)) return expectedValueMatches(asserted, expected, call.strings);
|
|
473
|
+
const flags = actualContainer(call, actual, "flags") ? asserted
|
|
474
|
+
: actualWholeResult(call, actual) ? propertyExpression(asserted, "flags", call.strings) : undefined;
|
|
475
|
+
const field = propertyExpression(flags, flag, call.strings);
|
|
476
|
+
return field !== undefined && expectedValueMatches(field, expected, call.strings);
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function exactStringArray(expression, strings) {
|
|
481
|
+
const value = String(expression ?? "").trim();
|
|
482
|
+
if (!(value.startsWith("[") && value.endsWith("]"))) return undefined;
|
|
483
|
+
const items = splitTopLevel(value.slice(1, -1));
|
|
484
|
+
if (items.length === 1 && items[0] === "") return [];
|
|
485
|
+
const resolved = items.map((item) => boundStringValue(item, strings));
|
|
486
|
+
return resolved.every((item) => typeof item === "string") ? resolved : undefined;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function assertedPositionalSuffix(call, suffix) {
|
|
490
|
+
return assertionComparisons(call).some(({ actual, expected }) => {
|
|
491
|
+
const positional = actualContainer(call, actual, "positional") ? expected
|
|
492
|
+
: actualWholeResult(call, actual) ? propertyExpression(expected, "positional", call.strings) : undefined;
|
|
493
|
+
const observed = exactStringArray(positional, call.strings);
|
|
494
|
+
return observed !== undefined && JSON.stringify(observed) === JSON.stringify(suffix);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function repeatedFlagExpectedValue(values) {
|
|
499
|
+
const flags = [];
|
|
500
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
501
|
+
const token = values[index];
|
|
502
|
+
if (token === "--") break;
|
|
503
|
+
if (!/^--[^=\s]+/.test(token)) continue;
|
|
504
|
+
const equals = token.indexOf("=");
|
|
505
|
+
if (equals >= 0) flags.push({ name: token.slice(0, equals), value: token.slice(equals + 1) });
|
|
506
|
+
else if (values[index + 1] !== undefined && !/^--/.test(values[index + 1])) {
|
|
507
|
+
flags.push({ name: token, value: values[index + 1] });
|
|
508
|
+
index += 1;
|
|
509
|
+
} else flags.push({ name: token, value: true });
|
|
510
|
+
}
|
|
511
|
+
const repeated = flags.filter((flag, index) => flags.some((other, otherIndex) => otherIndex < index && other.name === flag.name));
|
|
512
|
+
return repeated.at(-1);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function preCallSnapshotName(call, argument) {
|
|
516
|
+
const escaped = escapeRegex(argument);
|
|
517
|
+
const objectSnapshot = flatObjectSnapshot(call, argument, assertionComparisons);
|
|
518
|
+
if (objectSnapshot) return objectSnapshot.name;
|
|
519
|
+
const deepPatterns = [
|
|
520
|
+
new RegExp(`\\b(?:const|let)\\s+([a-z_$][a-z0-9_$]*)\\s*=\\s*structuredClone\\s*\\(\\s*${escaped}\\s*\\)`, "gi"),
|
|
521
|
+
new RegExp(`\\b(?:const|let)\\s+([a-z_$][a-z0-9_$]*)\\s*=\\s*JSON\\.parse\\s*\\(\\s*JSON\\.stringify\\s*\\(\\s*${escaped}\\s*\\)\\s*\\)`, "gi")
|
|
522
|
+
];
|
|
523
|
+
const deep = deepPatterns.flatMap((pattern) => [...call.prelude.matchAll(pattern)].map((match) => match[1])).at(-1);
|
|
524
|
+
if (deep) return stableDeepSnapshot(call, argument, deep, assertionComparisons) ? deep : undefined;
|
|
525
|
+
const declaration = [...call.prelude.matchAll(new RegExp(`\\b(?:const|let)\\s+${escaped}\\s*=\\s*\\[([^\\]]*)\\]`, "gi"))].at(-1);
|
|
526
|
+
const primitiveIndexFactory = new RegExp("\\b(?:const|let)\\s+" + escaped + "\\s*=\\s*Array\\.from\\s*\\(\\s*\\{\\s*length\\s*:\\s*\\d+\\s*\\}\\s*,\\s*\\(\\s*[a-z_$][a-z0-9_$]*\\s*,\\s*([a-z_$][a-z0-9_$]*)\\s*\\)\\s*=>\\s*\\1\\s*\\)", "i").test(call.prelude);
|
|
527
|
+
const primitiveElements = primitiveIndexFactory || declaration && splitTopLevel(declaration[1]).every((item) => {
|
|
528
|
+
const value = item.trim();
|
|
529
|
+
return value === "" || exactBoundValue(value, call.strings) !== undefined
|
|
530
|
+
|| /^(?:true|false|null|undefined|[-+]?\\d+(?:\\.\\d+)?n?)$/.test(value);
|
|
531
|
+
});
|
|
532
|
+
if (!primitiveElements) return undefined;
|
|
533
|
+
const shallowPatterns = [
|
|
534
|
+
new RegExp(`\\b(?:const|let)\\s+([a-z_$][a-z0-9_$]*)\\s*=\\s*\\[\\s*\\.\\.\\.\\s*${escaped}\\s*\\]`, "gi"),
|
|
535
|
+
new RegExp(`\\b(?:const|let)\\s+([a-z_$][a-z0-9_$]*)\\s*=\\s*${escaped}\\.(?:slice|concat)\\s*\\(\\s*\\)`, "gi"),
|
|
536
|
+
new RegExp(`\\b(?:const|let)\\s+([a-z_$][a-z0-9_$]*)\\s*=\\s*Array\\.from\\s*\\(\\s*${escaped}\\s*\\)`, "gi")
|
|
537
|
+
];
|
|
538
|
+
return shallowPatterns.flatMap((pattern) => [...call.prelude.matchAll(pattern)].map((match) => match[1])).at(-1);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function nonMutationAssertion(call, requireAll = false) {
|
|
542
|
+
const argumentsList = splitTopLevel(call.slice.slice(call.slice.indexOf("(") + 1, -1));
|
|
543
|
+
if (requireAll && (call.argumentNames.length !== argumentsList.length || !call.safeScope)) return false;
|
|
544
|
+
const provesArgument = (argument) => {
|
|
545
|
+
if (requireAll && literalBinding(call, argument, call.start)?.kind === "primitive") return true;
|
|
546
|
+
const snapshot = preCallSnapshotName(call, argument);
|
|
547
|
+
if (!snapshot) return false;
|
|
548
|
+
const assertions = requireAll ? call.scopedAssertions.map((entry) => entry.code) : call.assertions;
|
|
549
|
+
return assertions.some((assertion) => (
|
|
550
|
+
new RegExp(`\\bassert\\.(?:deepEqual|deepStrictEqual|strictEqual)\\s*\\(\\s*${escapeRegex(argument)}\\s*,\\s*${escapeRegex(snapshot)}\\b`, "i").test(assertion)
|
|
551
|
+
|| new RegExp(`\\bexpect\\s*\\(\\s*${escapeRegex(argument)}\\s*\\)\\s*\\.to(?:Strict)?Equal\\s*\\(\\s*${escapeRegex(snapshot)}\\b`, "i").test(assertion)
|
|
552
|
+
));
|
|
553
|
+
};
|
|
554
|
+
return call.argumentNames.length > 0 && (requireAll ? call.argumentNames.every(provesArgument) : call.argumentNames.some(provesArgument));
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
function primitiveContractParameters(task) {
|
|
559
|
+
const contracts = new Map();
|
|
560
|
+
const text = [task?.summary, ...(Array.isArray(task?.acceptanceCriteria) ? task.acceptanceCriteria : [])]
|
|
561
|
+
.filter(Boolean).join("\n");
|
|
562
|
+
const pattern = /`([a-z_$][a-z0-9_$]*)`\s+(?:must|should|has\s+to)\s+be\s+(?:an?\s+)?(?:non[- ]empty\s+)?(string|integer|number|boolean|bigint|symbol)\b/gi;
|
|
563
|
+
for (const match of text.matchAll(pattern)) contracts.set(match[1], match[2].toLowerCase());
|
|
564
|
+
return contracts;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function balancedBlockEnd(code, openIndex) {
|
|
568
|
+
let depth = 0;
|
|
569
|
+
for (let index = openIndex; index < code.length; index += 1) {
|
|
570
|
+
if (code[index] === "{") depth += 1;
|
|
571
|
+
else if (code[index] === "}" && --depth === 0) return index + 1;
|
|
572
|
+
}
|
|
573
|
+
return -1;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
function declaredFunctionBody(sourceEntries, callable) {
|
|
577
|
+
const local = callable.split(".").at(-1);
|
|
578
|
+
if (!/^[a-z_$][a-z0-9_$]*$/i.test(local ?? "")) return undefined;
|
|
579
|
+
const pattern = new RegExp(`\\bfunction\\s+${escapeRegex(local)}\\s*\\(([^)]*)\\)\\s*\\{`, "i");
|
|
580
|
+
for (const entry of sourceEntries) {
|
|
581
|
+
const match = pattern.exec(entry.text);
|
|
582
|
+
if (!match) continue;
|
|
583
|
+
const open = entry.text.indexOf("{", match.index + match[0].length - 1);
|
|
584
|
+
const end = balancedBlockEnd(entry.text, open);
|
|
585
|
+
const parameters = match[1].split(",").map((item) => item.trim());
|
|
586
|
+
if (end > open && parameters.every((item) => /^[a-z_$][a-z0-9_$]*$/i.test(item))) {
|
|
587
|
+
return { body: entry.text.slice(open + 1, end - 1), parameters };
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
return undefined;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function primitiveGuardIndex(body, parameter, type) {
|
|
594
|
+
const escaped = escapeRegex(parameter);
|
|
595
|
+
const pattern = type === "integer"
|
|
596
|
+
? new RegExp(`!\\s*Number\\.is(?:Safe)?Integer\\s*\\(\\s*${escaped}\\s*\\)`, "i")
|
|
597
|
+
: new RegExp(`typeof\\s+${escaped}\\s*!==?\\s*["']${escapeRegex(type)}["']`, "i");
|
|
598
|
+
const match = pattern.exec(body);
|
|
599
|
+
if (!match) return -1;
|
|
600
|
+
const ifStart = body.lastIndexOf("if", match.index);
|
|
601
|
+
const open = ifStart >= 0 ? body.indexOf("(", ifStart + 2) : -1;
|
|
602
|
+
const close = open >= 0 ? balancedCallEnd(body, open) : -1;
|
|
603
|
+
if (ifStart < 0 || open < 0 || match.index < open || match.index >= close) return -1;
|
|
604
|
+
const consequent = body.slice(close, close + 320);
|
|
605
|
+
return /^\s*(?:throw\b|\{[\s\S]{0,260}\bthrow\b)/.test(consequent) ? match.index : -1;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function parameterMutationObserved(body, parameter) {
|
|
609
|
+
const escaped = escapeRegex(parameter);
|
|
610
|
+
return [
|
|
611
|
+
new RegExp(`\\b${escaped}\\s*(?:\\[[^\\]]+\\]|\\.[a-z_$][a-z0-9_$]*)?\\s*(?:=(?!=|>)|\\+=|-=|\\*=|\/=|%=|\\+\\+|--)`, "i"),
|
|
612
|
+
new RegExp(`(?:\\+\\+|--)\\s*${escaped}\\b|\\bdelete\\s+${escaped}\\b`, "i"),
|
|
613
|
+
new RegExp(`\\b(?:Object\\.(?:assign|definePropert(?:y|ies))|Reflect\\.(?:deleteProperty|set))\\s*\\(\\s*${escaped}\\b`, "i"),
|
|
614
|
+
new RegExp(`\\b${escaped}\\.(?:copyWithin|fill|pop|push|reverse|shift|sort|splice|unshift)\\s*\\(`, "i")
|
|
615
|
+
].some((pattern) => pattern.test(body));
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function primitiveNonMutationEvidence(task, profiles, sourceEntries) {
|
|
619
|
+
const contracts = primitiveContractParameters(task);
|
|
620
|
+
if (contracts.size === 0) return false;
|
|
621
|
+
const callables = [...new Set(profiles.flatMap((profile) => profile.callables))];
|
|
622
|
+
return callables.length > 0 && callables.every((callable) => {
|
|
623
|
+
const declared = declaredFunctionBody(sourceEntries, callable);
|
|
624
|
+
if (!declared || declared.parameters.length === 0) return false;
|
|
625
|
+
return declared.parameters.every((parameter) => {
|
|
626
|
+
const type = contracts.get(parameter);
|
|
627
|
+
if (!type || parameterMutationObserved(declared.body, parameter)) return false;
|
|
628
|
+
const guard = primitiveGuardIndex(declared.body, parameter, type);
|
|
629
|
+
if (guard < 0) return false;
|
|
630
|
+
const prefix = declared.body.slice(0, guard);
|
|
631
|
+
return !new RegExp(`\\b[a-z_$][a-z0-9_$.]*\\s*\\([^)]*\\b${escapeRegex(parameter)}\\b`, "i").test(prefix);
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function dependencyNeutralEvidence(corpus) {
|
|
637
|
+
const manifest = /(?:^|\/)(?:package(?:-lock)?\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|deno\.jsonc?|bun\.lockb?|requirements[^/]*\.txt|pyproject\.toml|poetry\.lock|cargo\.toml|cargo\.lock|go\.mod|go\.sum)$/i;
|
|
638
|
+
if (corpus.files.some((file) => manifest.test(file))) return false;
|
|
639
|
+
return corpus.sourceEntries.length > 0 && corpus.sourceEntries.every((entry) => (
|
|
640
|
+
moduleRecords(entry).every((record) => record.specifier.startsWith(".") || record.specifier.startsWith("node:"))
|
|
641
|
+
));
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function semanticTerm(value) {
|
|
645
|
+
if (/^(?:[a-z]+s|[a-z]+es)$/i.test(value) && !/(?:ss|us)$/i.test(value)) {
|
|
646
|
+
if (/(?:ches|shes|ses|xes|zes)$/i.test(value)) return value.slice(0, -2);
|
|
647
|
+
return value.slice(0, -1);
|
|
648
|
+
}
|
|
649
|
+
return value;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function semanticTerms(value) {
|
|
653
|
+
const separated = String(value ?? "").replace(/([a-z0-9])([A-Z])/g, "$1 $2");
|
|
654
|
+
return new Set((normalizedText(separated).match(/[a-z][a-z0-9_$]{1,}/g) ?? [])
|
|
655
|
+
.map(semanticTerm)
|
|
656
|
+
.filter((word) => !BEHAVIOR_STOPWORDS.has(word)
|
|
657
|
+
&& !new Set(["and", "the", "with", "from", "into", "this", "that", "for", "are", "was", "were", "has", "have", "then"]).has(word)));
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function definedExpectedExpression(expression, strings, prelude = "") {
|
|
661
|
+
const value = String(expression ?? "").trim();
|
|
662
|
+
if (!value || /^(?:undefined|null|void\b)/i.test(value)) return false;
|
|
663
|
+
const identifier = value.match(/^[a-z_$][a-z0-9_$]*$/i)?.[0];
|
|
664
|
+
if (identifier && new RegExp(`\\b(?:const|let)\\s+${escapeRegex(identifier)}\\s*=\\s*(?:\\{|\\[|true\\b|false\\b|[-+]?\\d|${BOUND_STRING})`, "i").test(prelude)) return true;
|
|
665
|
+
return exactBoundValue(value, strings) !== undefined
|
|
666
|
+
|| /^(?:true|false|[-+]?\d+(?:\.\d+)?n?|\{|\[)/.test(value);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function positiveDefinedPredicate(call, expression, field) {
|
|
670
|
+
const value = String(expression ?? "").trim();
|
|
671
|
+
if (actualContainer(call, value, field)) return true;
|
|
672
|
+
const arrayCheck = value.match(/^Array\.isArray\s*\(([\s\S]+)\)$/i);
|
|
673
|
+
if (arrayCheck && actualContainer(call, arrayCheck[1], field)) return true;
|
|
674
|
+
const comparison = value.match(/^([\s\S]+?)\s*(===|==|!==|!=)\s*([\s\S]+)$/);
|
|
675
|
+
if (!comparison || !actualContainer(call, comparison[1], field)) return false;
|
|
676
|
+
const expected = comparison[3].trim();
|
|
677
|
+
if (comparison[2] === "!==" && expected === "undefined") return true;
|
|
678
|
+
if (comparison[2] === "!=" && /^(?:undefined|null)$/.test(expected)) return true;
|
|
679
|
+
return ["===", "=="].includes(comparison[2]) && definedExpectedExpression(expected, call.strings, call.prelude);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function assertionProvesDefinedField(call, field) {
|
|
683
|
+
if (assertionComparisons(call).some(({ actual, expected }) => {
|
|
684
|
+
if (actualContainer(call, actual, field)) return definedExpectedExpression(expected, call.strings, call.prelude);
|
|
685
|
+
if (!actualWholeResult(call, actual)) return false;
|
|
686
|
+
const fieldValue = propertyExpression(expected, field, call.strings);
|
|
687
|
+
return fieldValue !== undefined && definedExpectedExpression(fieldValue, call.strings, call.prelude);
|
|
688
|
+
})) return true;
|
|
689
|
+
return call.assertions.some((assertion) => {
|
|
690
|
+
const ok = assertion.match(/^\s*assert\.ok\s*\(/i);
|
|
691
|
+
if (ok) {
|
|
692
|
+
const open = assertion.indexOf("(", ok.index);
|
|
693
|
+
const end = balancedCallEnd(assertion, open);
|
|
694
|
+
return end > open && positiveDefinedPredicate(call, assertion.slice(open + 1, end - 1), field);
|
|
695
|
+
}
|
|
696
|
+
const expected = assertion.match(/^\s*expect\s*\(/i);
|
|
697
|
+
if (!expected) return false;
|
|
698
|
+
const open = assertion.indexOf("(", expected.index);
|
|
699
|
+
const end = balancedCallEnd(assertion, open);
|
|
700
|
+
return end > open && actualContainer(call, assertion.slice(open + 1, end - 1), field)
|
|
701
|
+
&& /^\s*\.toBeDefined\s*\(/i.test(assertion.slice(end));
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function linkedTestEvidence(linkage) {
|
|
706
|
+
const profiles = [];
|
|
707
|
+
for (const { entry, callables, bindings } of linkage.entries) {
|
|
708
|
+
if (!/\b(?:assert(?:\.[a-z][a-z0-9_]*)?\s*\(|expect\s*\()/i.test(entry.evidenceText)) continue;
|
|
709
|
+
const bound = bindJavaScriptStrings(entry.text);
|
|
710
|
+
const calls = callableSlices(bound.code, bound.strings, callables);
|
|
711
|
+
if (calls.length > 0) profiles.push({ path: entry.path, raw: entry.text, evidenceCode: normalizedText(entry.evidenceText), code: bound.code, calls, callables, bindings });
|
|
712
|
+
}
|
|
713
|
+
return profiles;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function shellTokens(command) {
|
|
717
|
+
return (String(command ?? "").match(/"[^"]*"|'[^']*'|[^\s]+/g) ?? [])
|
|
718
|
+
.map((token) => token.replace(/^(['"])([\s\S]*)\1$/, "$2"));
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function shellStructure(command) {
|
|
722
|
+
const value = String(command ?? ""), segments = [], operators = [];
|
|
723
|
+
let quote = "", escaped = false, start = 0;
|
|
724
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
725
|
+
const token = value[index];
|
|
726
|
+
if (escaped) { escaped = false; continue; }
|
|
727
|
+
if (token === "\\") { escaped = true; continue; }
|
|
728
|
+
if (quote) { if (token === quote) quote = ""; continue; }
|
|
729
|
+
if (token === "'" || token === '"') { quote = token; continue; }
|
|
730
|
+
const pair = value.slice(index, index + 2);
|
|
731
|
+
const width = ["&&", "||", "|&"].includes(pair) ? 2
|
|
732
|
+
: token === ";" || token === "\n" || token === "|" || (token === "&" && !/[<>]/.test(value[index - 1] ?? "")) ? 1 : 0;
|
|
733
|
+
if (!width) continue;
|
|
734
|
+
if (value.slice(start, index).trim()) segments.push(value.slice(start, index).trim());
|
|
735
|
+
operators.push(value.slice(index, index + width));
|
|
736
|
+
start = index + width; index += width - 1;
|
|
737
|
+
}
|
|
738
|
+
if (value.slice(start).trim()) segments.push(value.slice(start).trim());
|
|
739
|
+
return { segments, operators };
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function shellSegments(command) { return shellStructure(command).segments; }
|
|
743
|
+
|
|
744
|
+
function workspacePredicatePath(cwd, candidate, executable) {
|
|
745
|
+
if (typeof cwd !== "string" || !cwd) return false;
|
|
746
|
+
const relative = normalizePathCandidate(String(candidate ?? "").replace(/^\.\//, ""));
|
|
747
|
+
if (!relative || path.isAbsolute(relative) || relative.split("/").includes("..")) return false;
|
|
748
|
+
try {
|
|
749
|
+
const target = path.join(cwd, relative);
|
|
750
|
+
if (executable) { fs.accessSync(target, fs.constants.X_OK); return fs.statSync(target).isFile(); }
|
|
751
|
+
return fs.statSync(target).isFile();
|
|
752
|
+
} catch { return false; }
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
function commandAvailable(command) {
|
|
756
|
+
const name = String(command ?? "");
|
|
757
|
+
return /^[a-z0-9_.-]+$/i.test(name) && String(process.env.PATH ?? "").split(path.delimiter).some((directory) => {
|
|
758
|
+
try { fs.accessSync(path.join(directory, name), fs.constants.X_OK); return true; } catch { return false; }
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function safeConditionPart(part, cwd) {
|
|
763
|
+
const value = String(part ?? "").trim();
|
|
764
|
+
const file = value.match(/^test\s+-(f|x)\s+([^\s]+)$/i);
|
|
765
|
+
if (file) return workspacePredicatePath(cwd, file[2], file[1].toLowerCase() === "x");
|
|
766
|
+
const available = value.match(/^command\s+-v\s+([a-z0-9_.-]+)(?:\s+>\/dev\/null\s+2>&1)?$/i);
|
|
767
|
+
if (available) return commandAvailable(available[1]);
|
|
768
|
+
if (/^node\s+-e\b/.test(value) && /scripts?\|\|\{\}/.test(value) && /s\.test\?0:1/.test(value)) {
|
|
769
|
+
try { return typeof JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf8"))?.scripts?.test === "string"; } catch { return false; }
|
|
770
|
+
}
|
|
771
|
+
return value === "true";
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function verifierWorkingDirectory(cwd, body) {
|
|
775
|
+
const target = body.map((segment) => segment.match(/^cd\s+([^\s]+)$/)?.[1]).find(Boolean);
|
|
776
|
+
if (!target) return cwd;
|
|
777
|
+
const relative = normalizePathCandidate(String(target).replace(/^\.\//, ""));
|
|
778
|
+
const resolved = relative && cwd ? path.resolve(cwd, relative) : "";
|
|
779
|
+
try {
|
|
780
|
+
return resolved && !path.relative(cwd, resolved).split(path.sep).includes("..") && fs.statSync(resolved).isDirectory() ? resolved : undefined;
|
|
781
|
+
} catch { return undefined; }
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function executableVerifierPlan(command, cwd) {
|
|
785
|
+
const { segments, operators } = shellStructure(command);
|
|
786
|
+
if (operators.some((operator) => ["||", "|", "|&", "&"].includes(operator))) return { segments: [], cwd };
|
|
787
|
+
let cursor = segments.findIndex((segment) => /^if\b/.test(segment));
|
|
788
|
+
if (cursor < 0) return { segments: operators.some((operator) => operator === ";" || operator === "\n") ? [] : segments, cwd };
|
|
789
|
+
let selected;
|
|
790
|
+
while (cursor >= 0 && cursor < segments.length) {
|
|
791
|
+
const marker = segments[cursor].match(/^(?:if|elif)\s+([\s\S]+)$/);
|
|
792
|
+
if (!marker) return { segments: [], cwd };
|
|
793
|
+
const condition = [marker[1]];
|
|
794
|
+
cursor += 1;
|
|
795
|
+
while (cursor < segments.length && !/^then\b/.test(segments[cursor])) condition.push(segments[cursor++]);
|
|
796
|
+
if (cursor >= segments.length) return { segments: [], cwd };
|
|
797
|
+
const body = [segments[cursor].replace(/^then\s*/, "")].filter(Boolean);
|
|
798
|
+
cursor += 1;
|
|
799
|
+
while (cursor < segments.length && !/^(?:elif|else|fi)\b/.test(segments[cursor])) body.push(segments[cursor++]);
|
|
800
|
+
if (condition.every((part) => safeConditionPart(part, cwd))) { selected = body; break; }
|
|
801
|
+
if (!/^elif\b/.test(segments[cursor] ?? "")) return { segments: [], cwd };
|
|
802
|
+
}
|
|
803
|
+
const end = segments.findIndex((segment, index) => index >= cursor && /^fi\b/.test(segment));
|
|
804
|
+
const selectedCwd = selected && verifierWorkingDirectory(cwd, selected);
|
|
805
|
+
return !selected || end < 0 || !selectedCwd ? { segments: [], cwd }
|
|
806
|
+
: { segments: [...selected, ...segments.slice(end + 1)], cwd: selectedCwd };
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
function testPathMatchesToken(testPath, token) {
|
|
810
|
+
const candidate = normalizePathCandidate(String(token ?? "").replace(/^\.\//, ""));
|
|
811
|
+
const target = normalizePathCandidate(testPath);
|
|
812
|
+
if (!/[?*]/.test(candidate)) return candidate === target;
|
|
813
|
+
const pattern = escapeRegex(candidate).replace(/\\\*\\\*\//g, "(?:.*/)?").replace(/\\\*\\\*/g, ".*").replace(/\\\*/g, "[^/]*").replace(/\\\?/g, "[^/]");
|
|
814
|
+
return new RegExp(`^${pattern}$`).test(target);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function testRunnerArguments(segment) {
|
|
818
|
+
const tokens = shellTokens(segment).filter((token) => !["then", "do"].includes(token));
|
|
819
|
+
while (/^[a-z_][a-z0-9_]*=/i.test(tokens[0] ?? "")) tokens.shift();
|
|
820
|
+
if (/^(?:npm|pnpm|yarn|bun)$/.test(tokens[0] ?? "")) {
|
|
821
|
+
const scriptIndex = tokens[1] === "run" ? 2 : 1, script = tokens[scriptIndex];
|
|
822
|
+
if (script === "test") return { args: tokens.slice(scriptIndex + 1).filter((token) => token !== "--" && token !== "--if-present") };
|
|
823
|
+
if (/^test:[a-z0-9_.-]+$/i.test(script ?? "")) return { args: [], packageScript: script };
|
|
824
|
+
return undefined;
|
|
825
|
+
}
|
|
826
|
+
const joined = tokens.join(" ");
|
|
827
|
+
const runners = [
|
|
828
|
+
/^node --test\b/, /^(?:uv run |python -m )?pytest\b/,
|
|
829
|
+
/^(?:npx )?(?:vitest(?: run)?|jest|playwright test|cypress run)\b/
|
|
830
|
+
];
|
|
831
|
+
for (const runner of runners) {
|
|
832
|
+
const match = joined.match(runner);
|
|
833
|
+
if (match) return { args: shellTokens(joined.slice(match[0].length)).filter((token) => token !== "--") };
|
|
834
|
+
}
|
|
835
|
+
if (/^(?:flutter test|\.\/(?:mvnw|gradlew) test)$/.test(joined)) return { args: [] };
|
|
836
|
+
return undefined;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
function packageTestScriptCovers(cwd, scriptName, testPath) {
|
|
840
|
+
if (typeof cwd !== "string" || !cwd) return false;
|
|
841
|
+
try {
|
|
842
|
+
const script = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf8"))?.scripts?.[scriptName];
|
|
843
|
+
const structure = shellStructure(script);
|
|
844
|
+
return typeof script === "string" && structure.segments.length === 1 && structure.operators.length === 0
|
|
845
|
+
&& verifierSegmentCoversTest(structure.segments[0], testPath, cwd, false);
|
|
846
|
+
} catch { return false; }
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
function verifierSegmentCoversTest(segment, testPath, cwd, allowPackageScript = true) {
|
|
850
|
+
const runner = testRunnerArguments(segment);
|
|
851
|
+
if (!runner || runner.packageScript && !allowPackageScript) return false;
|
|
852
|
+
if (runner.packageScript) return packageTestScriptCovers(cwd, runner.packageScript, testPath);
|
|
853
|
+
if (/(?:^|\s)--if-present(?:\s|$)/.test(segment) && !packageTestScriptCovers(cwd, "test", testPath)) return false;
|
|
854
|
+
const pathArguments = runner.args.filter((token) => !token.startsWith("-"));
|
|
855
|
+
return pathArguments.length === 0 || pathArguments.some((token) => testPathMatchesToken(testPath, token));
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
export function verifierCommandsCoverTests(task, testPaths, cwd) {
|
|
859
|
+
const commands = (Array.isArray(task?.verifyCommands) ? task.verifyCommands : []).filter((command) => typeof command === "string");
|
|
860
|
+
return testPaths.length > 0 && testPaths.every((testPath) => commands.some((command) => {
|
|
861
|
+
const plan = executableVerifierPlan(command, cwd);
|
|
862
|
+
const prefix = normalizePathCandidate(cwd && plan.cwd ? path.relative(cwd, plan.cwd).replaceAll("\\", "/") : "");
|
|
863
|
+
const normalizedTest = normalizePathCandidate(testPath);
|
|
864
|
+
const relativeTest = prefix ? normalizedTest.startsWith(prefix + "/") ? normalizedTest.slice(prefix.length + 1) : "" : normalizedTest;
|
|
865
|
+
return Boolean(relativeTest) && plan.segments.some((segment) => verifierSegmentCoversTest(segment, relativeTest, plan.cwd));
|
|
866
|
+
}));
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
function criterionConjunctMatches(task, rawCriterion, profiles, corpus) {
|
|
870
|
+
if (!rawCriterion || profiles.length === 0) return false;
|
|
871
|
+
const text = normalizedText(rawCriterion);
|
|
872
|
+
const calls = profiles.flatMap((profile) => profile.calls);
|
|
873
|
+
const code = calls.flatMap((call) => call.assertions).join("\n");
|
|
874
|
+
const requirements = [];
|
|
875
|
+
const resultEvidence = acceptanceResultContractEvidence(rawCriterion, profiles, corpus.sourceEntries, [task?.summary, task?.expectedOutput, ...(task?.acceptanceCriteria ?? [])].filter(Boolean).join("\n"));
|
|
876
|
+
if (resultEvidence !== undefined) requirements.push(resultEvidence);
|
|
877
|
+
if (/\bfocused\s+tests?\b/.test(text)) requirements.push(calls.length > 0);
|
|
878
|
+
if (/--[a-z0-9_-]+=[a-z0-9_<[{]/i.test(text) || /\bname\s*=\s*value\b/.test(text)) {
|
|
879
|
+
requirements.push(calls.some((call) => call.values.some((value) => {
|
|
880
|
+
const match = value.match(/^--([^=\s]+)=(.+)$/);
|
|
881
|
+
return match ? assertedFlagValue(call, match[1], match[2]) : false;
|
|
882
|
+
})));
|
|
883
|
+
}
|
|
884
|
+
if (/--[a-z0-9_-]+\s+(?:value|<[^>]+>)/i.test(text)) {
|
|
885
|
+
requirements.push(calls.some((call) => call.values.some((value, index) => {
|
|
886
|
+
const name = value.match(/^--([^=\s]+)$/)?.[1], expected = call.values[index + 1];
|
|
887
|
+
return name && expected !== undefined && !/^--/.test(expected) && assertedFlagValue(call, name, expected);
|
|
888
|
+
})));
|
|
889
|
+
}
|
|
890
|
+
if (/\bboolean\b[\s\S]{0,30}--[a-z0-9_-]+/i.test(text)) {
|
|
891
|
+
requirements.push(calls.some((call) => call.values.some((value, index) => {
|
|
892
|
+
const name = value.match(/^--([^=\s]+)$/)?.[1];
|
|
893
|
+
return name && (call.values[index + 1] === undefined || /^--/.test(call.values[index + 1]))
|
|
894
|
+
&& assertedFlagValue(call, name, true);
|
|
895
|
+
})));
|
|
896
|
+
}
|
|
897
|
+
if (/\bstandalone\s+`?--`?(?=\s|$)|`?--`?\s+(?:ends?|stops?)\s+flag/i.test(text)) {
|
|
898
|
+
requirements.push(calls.some((call) => {
|
|
899
|
+
const delimiter = call.values.indexOf("--"), suffix = call.values.slice(delimiter + 1);
|
|
900
|
+
return delimiter >= 0 && suffix.length > 0 && assertedPositionalSuffix(call, suffix);
|
|
901
|
+
}));
|
|
902
|
+
}
|
|
903
|
+
if (/\bflag\s+followed\s+by\s+another\s+flag\b/.test(text)) {
|
|
904
|
+
requirements.push(calls.some((call) => call.values.some((value, index) => {
|
|
905
|
+
const name = value.match(/^--([^=\s]+)$/)?.[1];
|
|
906
|
+
return name && /^--[^=\s]+$/.test(call.values[index + 1] ?? "") && assertedFlagValue(call, name, true);
|
|
907
|
+
})));
|
|
908
|
+
}
|
|
909
|
+
if (/\brepeated?\s+flags?\b|\blast\s+value\b/.test(text)) {
|
|
910
|
+
requirements.push(calls.some((call) => {
|
|
911
|
+
const expected = repeatedFlagExpectedValue(call.values);
|
|
912
|
+
return expected !== undefined && assertedFlagValue(call, expected.name.slice(2), expected.value);
|
|
913
|
+
}));
|
|
914
|
+
}
|
|
915
|
+
if (/\b(?:do not|must not|without)\s+mutat|\b(?:do not|must not)\s+[^.;]{0,100}\bor\s+mutat|\bpreserve\s+(?:the\s+)?input|\binputs? must remain unchanged\b/.test(text)) {
|
|
916
|
+
const requireAll = /\binputs\b|\b(?:both|either|all|any)\s+(?:of\s+)?(?:the\s+)?(?:arguments?|inputs?)\b/.test(text);
|
|
917
|
+
requirements.push(dependencyGraphNonMutationEvidence({rawCriterion,profiles,sourceEntries:corpus.sourceEntries}) || pureRecordNonMutationEvidence({rawCriterion,profiles,sourceEntries:corpus.sourceEntries}) || byteArrayNonMutationEvidence({rawCriterion,profiles,sourceEntries:corpus.sourceEntries}) || finiteIntervalNonMutationEvidence({ rawCriterion, profiles, sourceEntries: corpus.sourceEntries, contextText: [task?.summary, task?.expectedOutput, ...(task?.acceptanceCriteria ?? [])].filter(Boolean).join("\n") }) || calls.some((call) => nonMutationAssertion({ ...call, sourceEntries: corpus.sourceEntries }, requireAll))
|
|
918
|
+
|| primitiveNonMutationEvidence(task, profiles, corpus.sourceEntries));
|
|
919
|
+
}
|
|
920
|
+
if (/\b(?:do not|must not|without)\s+add(?:ing)?\s+(?:new\s+)?dependenc/.test(text)) {
|
|
921
|
+
requirements.push(dependencyNeutralEvidence(corpus));
|
|
922
|
+
}
|
|
923
|
+
if (/\breturn shape\b|\breturned? (?:object|representation)\b/.test(text)) {
|
|
924
|
+
requirements.push(calls.some((call) => assertionProvesDefinedField(call, "flags")
|
|
925
|
+
&& assertionProvesDefinedField(call, "positional")));
|
|
926
|
+
}
|
|
927
|
+
if (/\bconcurren|\bparallel\b/.test(text)) requirements.push(/\bpromise\.all\s*\(|\ballsettled\s*\(/i.test(code));
|
|
928
|
+
const errorClass = text.match(/\b(typeerror|syntaxerror|rangeerror)\b/)?.[1];
|
|
929
|
+
if (errorClass) requirements.push(new RegExp(`\\b(?:assert\\.throws|rejects|tothrow)\\b[\\s\\S]{0,240}\\b${errorClass}\\b`, "i").test(code));
|
|
930
|
+
if (requirements.length > 0) return requirements.every(Boolean);
|
|
931
|
+
const names = new Set(profiles.flatMap((profile) => profile.callables).flatMap((name) => name.split(".")));
|
|
932
|
+
const paths = [...corpus.sourceFiles, ...profiles.map((profile) => profile.path)].join("\n");
|
|
933
|
+
const anchors = [...rawCriterion.matchAll(/\b[a-z_$][a-z0-9_$]{3,}\b/gi)]
|
|
934
|
+
.map((match) => match[0]).filter((word) => !BEHAVIOR_STOPWORDS.has(word.toLowerCase()));
|
|
935
|
+
const direct = anchors.some((anchor) => names.has(anchor)
|
|
936
|
+
|| new RegExp(`\\b${escapeRegex(anchor)}\\b`, "i").test(code)
|
|
937
|
+
|| new RegExp(`(?:^|[/_.-])${escapeRegex(anchor)}(?:[/_.-]|$)`, "i").test(paths));
|
|
938
|
+
const criterionTerms = semanticTerms(rawCriterion);
|
|
939
|
+
const descriptionTerms = semanticTerms(calls.flatMap((call) => call.descriptions ?? []).join("\n"));
|
|
940
|
+
const descriptionOverlap = [...criterionTerms].filter((term) => descriptionTerms.has(term));
|
|
941
|
+
return direct || descriptionOverlap.length >= 2;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function criterionBehaviorMatches(task, criterion, profiles, corpus) {
|
|
945
|
+
const rawCriterion = boundCriterionText(task, criterion);
|
|
946
|
+
const conjuncts = acceptanceContractConjuncts(rawCriterion);
|
|
947
|
+
return conjuncts.length > 0
|
|
948
|
+
&& conjuncts.every((conjunct) => criterionConjunctMatches(task, conjunct, profiles, corpus));
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
function behavioralFocusRequired(input) {
|
|
952
|
+
if (input.obligation === "requested-behavior") {
|
|
953
|
+
return criterionRequiresBehavioralProof(input.task, input.criterion, input.taskText)
|
|
954
|
+
|| input.criterion.priority === "critical";
|
|
955
|
+
}
|
|
956
|
+
return input.obligation === "backward-compatibility"
|
|
957
|
+
&& (criterionRequiresBehavioralProof(input.task, input.criterion, input.taskText) || input.criterion.priority === "critical");
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
export function criterionBehaviorProofDisposition(input) {
|
|
961
|
+
if (!behavioralFocusRequired(input)) return "not-applicable";
|
|
962
|
+
if (!input.passingVerifier) return "unlinked";
|
|
963
|
+
if (!input.corpus.adapter.proofCapable) {
|
|
964
|
+
return ["unsupported", "unresolved"].includes(input.corpus.adapter.status) ? "unknown" : "unlinked";
|
|
965
|
+
}
|
|
966
|
+
if (input.corpus.sourceFiles.length === 0 || input.corpus.testFiles.length === 0) return "unlinked";
|
|
967
|
+
return testSourceLinkage(input.corpus).status;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
function focusedBehaviorEvidence(input) {
|
|
971
|
+
if (criterionBehaviorProofDisposition(input) !== "linked") return undefined;
|
|
972
|
+
const linkage = testSourceLinkage(input.corpus);
|
|
973
|
+
const profiles = linkedTestEvidence(linkage).filter((profile) => verifierCommandsCoverTests(input.task, [profile.path], input.cwd));
|
|
974
|
+
if (!criterionBehaviorMatches(input.task, input.criterion, profiles, input.corpus)) return undefined;
|
|
975
|
+
return {
|
|
976
|
+
...input.verifierEvidence,
|
|
977
|
+
kind: "verifier-backed-focused-test",
|
|
978
|
+
summary: "Configured verifier passed with changed executable assertions tied to this criterion and changed source.",
|
|
979
|
+
paths: [...new Set([...input.corpus.sourceFiles, ...profiles.map((profile) => profile.path)])]
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
export function genericCriterionEvidence(input) {
|
|
984
|
+
const behavioral = criterionRequiresBehavioralProof(input.task, input.criterion, input.taskText);
|
|
985
|
+
if (input.obligation === "requested-behavior") {
|
|
986
|
+
return { handled: true, evidence: behavioralFocusRequired(input)
|
|
987
|
+
? focusedBehaviorEvidence(input)
|
|
988
|
+
: input.passingVerifier ? input.verifierEvidence : undefined };
|
|
989
|
+
}
|
|
990
|
+
if (input.obligation === "verification-evidence" || input.obligation === "backward-compatibility") {
|
|
991
|
+
return { handled: true, evidence: behavioralFocusRequired(input) ? focusedBehaviorEvidence(input)
|
|
992
|
+
: input.passingVerifier ? input.verifierEvidence : undefined };
|
|
993
|
+
}
|
|
994
|
+
return { handled: false, behavioral };
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
export function genericFallbackEvidence(input) {
|
|
998
|
+
/* No criterion is available at this legacy fallback boundary: abstain for behavioral proof. */
|
|
999
|
+
return input.behavioral ? undefined : input.passingVerifier ? input.verifierEvidence : undefined;
|
|
1000
|
+
}
|