@resolveio/server-lib 22.3.174 → 22.3.176
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/.nodemon.json +5 -0
- package/.vscode/settings.json +21 -0
- package/AGENTS.md +195 -0
- package/README.md +22 -0
- package/build_package.sh +5 -0
- package/compileDTS.pl +64 -0
- package/docs/ai-assistant-nightly-eval.md +65 -0
- package/docs/ai-assistant-preflight-checklist.md +23 -0
- package/docs/ai-assistant-report-builder-bridge-playbook.md +115 -0
- package/eslint-plugin-custom/index.js +7 -0
- package/eslint-plugin-custom/rules/no-filter-zero-index.js +44 -0
- package/eslint.config.js +103 -0
- package/gulpfile.js +216 -0
- package/methodAndPublicationListGenerator.py +375 -0
- package/mongodbensurers.js +2 -0
- package/mongostop.js +3 -0
- package/package.json +1 -1
- package/scripts/cleanup-bypassed-callmethod-logs.js +616 -0
- package/settings.development.json +25 -0
- package/settings.development.redacted.json +25 -0
- package/src/.env +12 -0
- package/src/ai/assistant-core-heuristics.ts +379 -0
- package/src/ai/resolveio-platform-intelligence-memory-corpus.ts +185 -0
- package/src/ai/resolveio-platform-intelligence-memory.ts +325 -0
- package/{ai/resolveio-platform-intelligence-types.d.ts → src/ai/resolveio-platform-intelligence-types.ts} +20 -15
- package/src/ai/resolveio-platform-intelligence.ts +462 -0
- package/src/client-server-app.ts +12 -0
- package/src/collections/ai-run.collection.ts +117 -0
- package/src/collections/ai-terminal-conversation.collection.ts +91 -0
- package/src/collections/ai-terminal-issue-report.collection.ts +99 -0
- package/src/collections/ai-terminal-message.collection.ts +77 -0
- package/src/collections/app-setting.collection.ts +104 -0
- package/src/collections/app-status.collection.ts +58 -0
- package/src/collections/communication-metric.collection.ts +84 -0
- package/src/collections/counter.collection.ts +56 -0
- package/src/collections/cron-job-history.collection.ts +94 -0
- package/src/collections/cron-job.collection.ts +92 -0
- package/src/collections/customer-notification.collection.ts +131 -0
- package/src/collections/customer-portal-password.collection.ts +76 -0
- package/src/collections/email-history.collection.ts +134 -0
- package/src/collections/email-verified.collection.ts +62 -0
- package/src/collections/file.collection.ts +74 -0
- package/src/collections/flag-update.collection.ts +57 -0
- package/src/collections/flag.collection.ts +57 -0
- package/src/collections/log-method-latency.collection.ts +77 -0
- package/src/collections/log-subscription.collection.ts +80 -0
- package/src/collections/log.collection.ts +93 -0
- package/src/collections/logged-in-users.collection.ts +67 -0
- package/src/collections/monitor-cpu.collection.ts +65 -0
- package/src/collections/monitor-function.collection.ts +74 -0
- package/src/collections/monitor-memory.collection.ts +77 -0
- package/src/collections/monitor-mongo.collection.ts +71 -0
- package/src/collections/notification.collection.ts +57 -0
- package/src/collections/openai-usage-ledger.collection.ts +131 -0
- package/src/collections/report-builder-dashboard-builder.collection.ts +109 -0
- package/src/collections/report-builder-library.collection.ts +89 -0
- package/src/collections/report-builder-report.collection.ts +184 -0
- package/src/collections/user-group.collection.ts +89 -0
- package/src/collections/user-guide.collection.ts +57 -0
- package/src/collections/user.collection.ts +181 -0
- package/src/cron/cron.ts +117 -0
- package/src/fixtures/cron-jobs.ts +95 -0
- package/src/fixtures/init.ts +35 -0
- package/src/http/auth.ts +818 -0
- package/src/http/health.ts +7 -0
- package/src/http/home.ts +90 -0
- package/src/http/slow-query-publication.ts +49 -0
- package/src/index.ts +1 -0
- package/src/managers/ai-assistant-codex-manager.manager.ts +1131 -0
- package/src/managers/ai-run-evidence.manager.ts +264 -0
- package/src/managers/communication-metric.manager.ts +82 -0
- package/src/managers/cron.manager.ts +333 -0
- package/src/managers/customer-notification-content.manager.ts +236 -0
- package/src/managers/diagnostic-manager-bootstrap.ts +165 -0
- package/src/managers/error-auto-fix.manager.ts +2767 -0
- package/src/managers/local-log.manager.ts +113 -0
- package/src/managers/method.manager.ts +1857 -0
- package/src/managers/mongo.manager.ts +4575 -0
- package/src/managers/monitor.manager.ts +507 -0
- package/src/managers/openai-usage-ledger.manager.ts +112 -0
- package/src/managers/slow-query-verifier.manager.ts +3590 -0
- package/src/managers/slow-query.manager.ts +519 -0
- package/src/managers/subscription.manager.ts +3128 -0
- package/src/managers/websocket.manager.ts +746 -0
- package/src/managers/worker-dispatcher.manager.ts +1360 -0
- package/src/managers/worker-server.manager.ts +536 -0
- package/src/methods/accounts.ts +532 -0
- package/src/methods/ai-terminal.ts +23825 -0
- package/src/methods/app-settings.ts +114 -0
- package/src/methods/aws.ts +649 -0
- package/src/methods/collections.ts +641 -0
- package/src/methods/counters.ts +69 -0
- package/src/methods/cron-jobs.ts +2614 -0
- package/src/methods/customer-notifications.ts +458 -0
- package/src/methods/diagnostics.ts +616 -0
- package/src/methods/flag-updates.ts +7 -0
- package/src/methods/flags.ts +7 -0
- package/src/methods/logs.ts +657 -0
- package/src/methods/mongo-explorer.ts +1880 -0
- package/src/methods/monitor.ts +540 -0
- package/src/methods/pdf.ts +1236 -0
- package/src/methods/publications.ts +129 -0
- package/src/methods/report-builder.ts +3300 -0
- package/src/methods/support.ts +335 -0
- package/src/models/ai-run.model.ts +27 -0
- package/src/models/ai-terminal-conversation.model.ts +19 -0
- package/src/models/ai-terminal-issue-report.model.ts +21 -0
- package/src/models/ai-terminal-message.model.ts +24 -0
- package/src/models/app-setting.model.ts +17 -0
- package/{models/app-status.model.d.ts → src/models/app-status.model.ts} +3 -2
- package/{models/billing-logged-in-users.model.d.ts → src/models/billing-logged-in-users.model.ts} +5 -4
- package/src/models/collection-document.model.ts +24 -0
- package/src/models/communication-metric.model.ts +23 -0
- package/{models/counter.model.d.ts → src/models/counter.model.ts} +4 -3
- package/src/models/cron-job-history.model.ts +16 -0
- package/src/models/cron-job.model.ts +15 -0
- package/src/models/customer-notification.model.ts +28 -0
- package/src/models/customer-portal-password.model.ts +12 -0
- package/src/models/dialog.model.ts +25 -0
- package/{models/email-history.model.js → src/models/email-history.model.ts} +36 -4
- package/{models/email-verified.model.d.ts → src/models/email-verified.model.ts} +6 -5
- package/{models/file.model.d.ts → src/models/file.model.ts} +8 -7
- package/{models/flag-update.model.d.ts → src/models/flag-update.model.ts} +4 -3
- package/{models/flag.model.d.ts → src/models/flag.model.ts} +4 -3
- package/src/models/log-method-latency.model.ts +11 -0
- package/{models/log-subscription.model.d.ts → src/models/log-subscription.model.ts} +11 -9
- package/src/models/log.model.ts +19 -0
- package/{models/logged-in-users.model.d.ts → src/models/logged-in-users.model.ts} +6 -5
- package/{models/method-response.model.d.ts → src/models/method-response.model.ts} +7 -6
- package/src/models/method.model.ts +25 -0
- package/{models/monitor-cpu.model.d.ts → src/models/monitor-cpu.model.ts} +9 -7
- package/src/models/monitor-function.model.ts +16 -0
- package/src/models/monitor-memory.model.ts +17 -0
- package/src/models/monitor-mongo.model.ts +15 -0
- package/{models/notification.model.d.ts → src/models/notification.model.ts} +6 -4
- package/src/models/openai-usage-ledger.model.ts +56 -0
- package/src/models/pagination.model.ts +35 -0
- package/src/models/permission.model.ts +14 -0
- package/src/models/report-builder-dashboard-builder.model.ts +29 -0
- package/src/models/report-builder-library.model.ts +20 -0
- package/src/models/report-builder-report.model.ts +136 -0
- package/src/models/report-builder.model.ts +68 -0
- package/src/models/select-data-label.model.ts +9 -0
- package/src/models/server-message.model.ts +31 -0
- package/src/models/slow-query-report.model.ts +23 -0
- package/src/models/subscription.model.ts +73 -0
- package/src/models/support-ticket.model.ts +104 -0
- package/src/models/user-group.model.ts +24 -0
- package/{models/user-guide.model.d.ts → src/models/user-guide.model.ts} +5 -4
- package/src/models/user.model.ts +96 -0
- package/src/private/images/ResolveIO.png +0 -0
- package/src/publications/ai-terminal.ts +73 -0
- package/src/publications/app-settings.ts +25 -0
- package/src/publications/app-status.ts +13 -0
- package/src/publications/cron-jobs.ts +40 -0
- package/src/publications/customer-notifications.ts +101 -0
- package/src/publications/files.ts +33 -0
- package/src/publications/flags-update.ts +19 -0
- package/src/publications/flags.ts +19 -0
- package/src/publications/logs.ts +163 -0
- package/src/publications/notifications.ts +13 -0
- package/src/publications/report-builder-dashboard-builders.ts +39 -0
- package/src/publications/report-builder-libraries.ts +41 -0
- package/src/publications/report-builder-reports.ts +47 -0
- package/src/publications/super-admin.ts +13 -0
- package/src/publications/user-groups.ts +12 -0
- package/src/publications/user-guides.ts +12 -0
- package/src/resolveio-server-app.ts +617 -0
- package/src/server-app.ts +3354 -0
- package/src/services/codex-client.ts +1231 -0
- package/src/services/openai-client.ts +265 -0
- package/src/types/error-report.ts +26 -0
- package/src/types/js-tiktoken.d.ts +11 -0
- package/src/types/slow-query-report.ts +28 -0
- package/src/util/ai-qa-policy.ts +925 -0
- package/src/util/ai-run-evidence-adapters.ts +3292 -0
- package/src/util/ai-run-evidence-dashboard.ts +313 -0
- package/src/util/ai-run-evidence-eval.ts +1054 -0
- package/src/util/ai-run-evidence.ts +1124 -0
- package/src/util/ai-runner-artifacts.ts +586 -0
- package/src/util/ai-runner-manager-autopilot.ts +961 -0
- package/src/util/ai-runner-manager-policy.ts +4193 -0
- package/src/util/ai-runner-qa-auth.ts +821 -0
- package/src/util/ai-runner-qa-tools.ts +3045 -0
- package/src/util/aicoder-runner-v6.ts +2510 -0
- package/src/util/common.ts +649 -0
- package/src/util/customer-portal-password.ts +183 -0
- package/src/util/error-reporter.ts +332 -0
- package/src/util/error-tracking.ts +79 -0
- package/src/util/openai-usage-cost.ts +114 -0
- package/src/util/report-builder-unwinds.ts +180 -0
- package/src/util/runner-process-janitor.ts +219 -0
- package/src/util/schema-report-builder.ts +448 -0
- package/src/util/slow-query-reporter.ts +216 -0
- package/src/util/subscription-dependency-context.ts +1096 -0
- package/src/util/support-runner-v5.ts +4785 -0
- package/src/util/tokenizer.ts +38 -0
- package/src/workers/codex-runner.worker.ts +142 -0
- package/start_server.sh +5 -0
- package/tests/ai-assistant-corpus-build.ts +484 -0
- package/tests/ai-assistant-corpus-replay-e2e.ts +774 -0
- package/tests/ai-assistant-data-parity-e2e.ts +1989 -0
- package/tests/ai-assistant-eval-triage.ts +831 -0
- package/tests/ai-assistant-openai-e2e.ts +1061 -0
- package/tests/ai-assistant-openai-git-e2e.ts +155 -0
- package/tests/ai-assistant-preflight-matrix.ts +215 -0
- package/tests/ai-assistant-routing-eval.test.ts +560 -0
- package/tests/ai-assistant-snf-live-eval.ts +975 -0
- package/tests/ai-assistant-utils.test.ts +3057 -0
- package/tests/ai-manager-autopilot-snapshot.test.ts +193 -0
- package/tests/ai-manager-recovery-checkpoint.test.ts +1136 -0
- package/tests/ai-run-eval.test.ts +112 -0
- package/tests/ai-run-evidence.test.ts +1403 -0
- package/tests/ai-runner-contract.test.ts +488 -0
- package/tests/aicoder-runner-v6.test.ts +676 -0
- package/tests/error-reporter.test.ts +145 -0
- package/tests/method-publication-generator.test.ts +46 -0
- package/tests/report-builder-linking.test.ts +79 -0
- package/tests/resolveio-platform-intelligence.test.ts +352 -0
- package/tests/server-app-cron-owner.test.ts +127 -0
- package/tests/subscription-connect-race.test.ts +158 -0
- package/tests/subscription-dependency-context.test.ts +324 -0
- package/tests/subscription-manager-collection-tracking.test.ts +86 -0
- package/tests/subscription-manager-invalidation.test.ts +86 -0
- package/tests/support-runner-v5.test.ts +1166 -0
- package/tsconfig.json +34 -0
- package/ai/assistant-core-heuristics.d.ts +0 -11
- package/ai/assistant-core-heuristics.js +0 -356
- package/ai/assistant-core-heuristics.js.map +0 -1
- package/ai/resolveio-platform-intelligence-memory-corpus.d.ts +0 -3
- package/ai/resolveio-platform-intelligence-memory-corpus.js +0 -214
- package/ai/resolveio-platform-intelligence-memory-corpus.js.map +0 -1
- package/ai/resolveio-platform-intelligence-memory.d.ts +0 -20
- package/ai/resolveio-platform-intelligence-memory.js +0 -341
- package/ai/resolveio-platform-intelligence-memory.js.map +0 -1
- package/ai/resolveio-platform-intelligence-types.js +0 -4
- package/ai/resolveio-platform-intelligence-types.js.map +0 -1
- package/ai/resolveio-platform-intelligence.d.ts +0 -6
- package/ai/resolveio-platform-intelligence.js +0 -463
- package/ai/resolveio-platform-intelligence.js.map +0 -1
- package/client-server-app.d.ts +0 -1
- package/client-server-app.js +0 -68
- package/client-server-app.js.map +0 -1
- package/collections/ai-run.collection.d.ts +0 -3
- package/collections/ai-run.collection.js +0 -170
- package/collections/ai-run.collection.js.map +0 -1
- package/collections/ai-terminal-conversation.collection.d.ts +0 -2
- package/collections/ai-terminal-conversation.collection.js +0 -140
- package/collections/ai-terminal-conversation.collection.js.map +0 -1
- package/collections/ai-terminal-issue-report.collection.d.ts +0 -2
- package/collections/ai-terminal-issue-report.collection.js +0 -148
- package/collections/ai-terminal-issue-report.collection.js.map +0 -1
- package/collections/ai-terminal-message.collection.d.ts +0 -2
- package/collections/ai-terminal-message.collection.js +0 -121
- package/collections/ai-terminal-message.collection.js.map +0 -1
- package/collections/app-setting.collection.d.ts +0 -3
- package/collections/app-setting.collection.js +0 -103
- package/collections/app-setting.collection.js.map +0 -1
- package/collections/app-status.collection.d.ts +0 -3
- package/collections/app-status.collection.js +0 -57
- package/collections/app-status.collection.js.map +0 -1
- package/collections/communication-metric.collection.d.ts +0 -2
- package/collections/communication-metric.collection.js +0 -133
- package/collections/communication-metric.collection.js.map +0 -1
- package/collections/counter.collection.d.ts +0 -3
- package/collections/counter.collection.js +0 -56
- package/collections/counter.collection.js.map +0 -1
- package/collections/cron-job-history.collection.d.ts +0 -3
- package/collections/cron-job-history.collection.js +0 -137
- package/collections/cron-job-history.collection.js.map +0 -1
- package/collections/cron-job.collection.d.ts +0 -3
- package/collections/cron-job.collection.js +0 -92
- package/collections/cron-job.collection.js.map +0 -1
- package/collections/customer-notification.collection.d.ts +0 -3
- package/collections/customer-notification.collection.js +0 -130
- package/collections/customer-notification.collection.js.map +0 -1
- package/collections/customer-portal-password.collection.d.ts +0 -3
- package/collections/customer-portal-password.collection.js +0 -75
- package/collections/customer-portal-password.collection.js.map +0 -1
- package/collections/email-history.collection.d.ts +0 -3
- package/collections/email-history.collection.js +0 -134
- package/collections/email-history.collection.js.map +0 -1
- package/collections/email-verified.collection.d.ts +0 -3
- package/collections/email-verified.collection.js +0 -62
- package/collections/email-verified.collection.js.map +0 -1
- package/collections/file.collection.d.ts +0 -3
- package/collections/file.collection.js +0 -74
- package/collections/file.collection.js.map +0 -1
- package/collections/flag-update.collection.d.ts +0 -3
- package/collections/flag-update.collection.js +0 -57
- package/collections/flag-update.collection.js.map +0 -1
- package/collections/flag.collection.d.ts +0 -3
- package/collections/flag.collection.js +0 -57
- package/collections/flag.collection.js.map +0 -1
- package/collections/log-method-latency.collection.d.ts +0 -3
- package/collections/log-method-latency.collection.js +0 -77
- package/collections/log-method-latency.collection.js.map +0 -1
- package/collections/log-subscription.collection.d.ts +0 -3
- package/collections/log-subscription.collection.js +0 -80
- package/collections/log-subscription.collection.js.map +0 -1
- package/collections/log.collection.d.ts +0 -3
- package/collections/log.collection.js +0 -93
- package/collections/log.collection.js.map +0 -1
- package/collections/logged-in-users.collection.d.ts +0 -3
- package/collections/logged-in-users.collection.js +0 -67
- package/collections/logged-in-users.collection.js.map +0 -1
- package/collections/monitor-cpu.collection.d.ts +0 -3
- package/collections/monitor-cpu.collection.js +0 -65
- package/collections/monitor-cpu.collection.js.map +0 -1
- package/collections/monitor-function.collection.d.ts +0 -3
- package/collections/monitor-function.collection.js +0 -74
- package/collections/monitor-function.collection.js.map +0 -1
- package/collections/monitor-memory.collection.d.ts +0 -3
- package/collections/monitor-memory.collection.js +0 -77
- package/collections/monitor-memory.collection.js.map +0 -1
- package/collections/monitor-mongo.collection.d.ts +0 -3
- package/collections/monitor-mongo.collection.js +0 -71
- package/collections/monitor-mongo.collection.js.map +0 -1
- package/collections/notification.collection.d.ts +0 -3
- package/collections/notification.collection.js +0 -57
- package/collections/notification.collection.js.map +0 -1
- package/collections/openai-usage-ledger.collection.d.ts +0 -2
- package/collections/openai-usage-ledger.collection.js +0 -188
- package/collections/openai-usage-ledger.collection.js.map +0 -1
- package/collections/report-builder-dashboard-builder.collection.d.ts +0 -3
- package/collections/report-builder-dashboard-builder.collection.js +0 -109
- package/collections/report-builder-dashboard-builder.collection.js.map +0 -1
- package/collections/report-builder-library.collection.d.ts +0 -3
- package/collections/report-builder-library.collection.js +0 -87
- package/collections/report-builder-library.collection.js.map +0 -1
- package/collections/report-builder-report.collection.d.ts +0 -4
- package/collections/report-builder-report.collection.js +0 -184
- package/collections/report-builder-report.collection.js.map +0 -1
- package/collections/user-group.collection.d.ts +0 -4
- package/collections/user-group.collection.js +0 -89
- package/collections/user-group.collection.js.map +0 -1
- package/collections/user-guide.collection.d.ts +0 -3
- package/collections/user-guide.collection.js +0 -57
- package/collections/user-guide.collection.js.map +0 -1
- package/collections/user.collection.d.ts +0 -4
- package/collections/user.collection.js +0 -180
- package/collections/user.collection.js.map +0 -1
- package/cron/cron.d.ts +0 -14
- package/cron/cron.js +0 -216
- package/cron/cron.js.map +0 -1
- package/fixtures/cron-jobs.d.ts +0 -1
- package/fixtures/cron-jobs.js +0 -150
- package/fixtures/cron-jobs.js.map +0 -1
- package/fixtures/init.d.ts +0 -1
- package/fixtures/init.js +0 -91
- package/fixtures/init.js.map +0 -1
- package/http/auth.d.ts +0 -2
- package/http/auth.js +0 -951
- package/http/auth.js.map +0 -1
- package/http/health.d.ts +0 -1
- package/http/health.js +0 -11
- package/http/health.js.map +0 -1
- package/http/home.d.ts +0 -1
- package/http/home.js +0 -134
- package/http/home.js.map +0 -1
- package/http/slow-query-publication.d.ts +0 -2
- package/http/slow-query-publication.js +0 -99
- package/http/slow-query-publication.js.map +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -19
- package/index.js.map +0 -1
- package/managers/ai-assistant-codex-manager.manager.d.ts +0 -67
- package/managers/ai-assistant-codex-manager.manager.js +0 -1113
- package/managers/ai-assistant-codex-manager.manager.js.map +0 -1
- package/managers/ai-run-evidence.manager.d.ts +0 -36
- package/managers/ai-run-evidence.manager.js +0 -377
- package/managers/ai-run-evidence.manager.js.map +0 -1
- package/managers/communication-metric.manager.d.ts +0 -16
- package/managers/communication-metric.manager.js +0 -134
- package/managers/communication-metric.manager.js.map +0 -1
- package/managers/cron.manager.d.ts +0 -20
- package/managers/cron.manager.js +0 -534
- package/managers/cron.manager.js.map +0 -1
- package/managers/customer-notification-content.manager.d.ts +0 -55
- package/managers/customer-notification-content.manager.js +0 -158
- package/managers/customer-notification-content.manager.js.map +0 -1
- package/managers/diagnostic-manager-bootstrap.d.ts +0 -9
- package/managers/diagnostic-manager-bootstrap.js +0 -260
- package/managers/diagnostic-manager-bootstrap.js.map +0 -1
- package/managers/error-auto-fix.manager.d.ts +0 -149
- package/managers/error-auto-fix.manager.js +0 -3064
- package/managers/error-auto-fix.manager.js.map +0 -1
- package/managers/local-log.manager.d.ts +0 -18
- package/managers/local-log.manager.js +0 -88
- package/managers/local-log.manager.js.map +0 -1
- package/managers/method.manager.d.ts +0 -84
- package/managers/method.manager.js +0 -1964
- package/managers/method.manager.js.map +0 -1
- package/managers/mongo.manager.d.ts +0 -224
- package/managers/mongo.manager.js +0 -5000
- package/managers/mongo.manager.js.map +0 -1
- package/managers/monitor.manager.d.ts +0 -70
- package/managers/monitor.manager.js +0 -550
- package/managers/monitor.manager.js.map +0 -1
- package/managers/openai-usage-ledger.manager.d.ts +0 -30
- package/managers/openai-usage-ledger.manager.js +0 -142
- package/managers/openai-usage-ledger.manager.js.map +0 -1
- package/managers/slow-query-verifier.manager.d.ts +0 -144
- package/managers/slow-query-verifier.manager.js +0 -3857
- package/managers/slow-query-verifier.manager.js.map +0 -1
- package/managers/slow-query.manager.d.ts +0 -28
- package/managers/slow-query.manager.js +0 -468
- package/managers/slow-query.manager.js.map +0 -1
- package/managers/subscription.manager.d.ts +0 -169
- package/managers/subscription.manager.js +0 -3434
- package/managers/subscription.manager.js.map +0 -1
- package/managers/websocket.manager.d.ts +0 -73
- package/managers/websocket.manager.js +0 -673
- package/managers/websocket.manager.js.map +0 -1
- package/managers/worker-dispatcher.manager.d.ts +0 -120
- package/managers/worker-dispatcher.manager.js +0 -1266
- package/managers/worker-dispatcher.manager.js.map +0 -1
- package/managers/worker-server.manager.d.ts +0 -35
- package/managers/worker-server.manager.js +0 -582
- package/managers/worker-server.manager.js.map +0 -1
- package/methods/accounts.d.ts +0 -2
- package/methods/accounts.js +0 -624
- package/methods/accounts.js.map +0 -1
- package/methods/ai-terminal.d.ts +0 -338
- package/methods/ai-terminal.js +0 -23454
- package/methods/ai-terminal.js.map +0 -1
- package/methods/app-settings.d.ts +0 -2
- package/methods/app-settings.js +0 -169
- package/methods/app-settings.js.map +0 -1
- package/methods/aws.d.ts +0 -2
- package/methods/aws.js +0 -877
- package/methods/aws.js.map +0 -1
- package/methods/collections.d.ts +0 -2
- package/methods/collections.js +0 -719
- package/methods/collections.js.map +0 -1
- package/methods/counters.d.ts +0 -2
- package/methods/counters.js +0 -113
- package/methods/counters.js.map +0 -1
- package/methods/cron-jobs.d.ts +0 -2
- package/methods/cron-jobs.js +0 -2475
- package/methods/cron-jobs.js.map +0 -1
- package/methods/customer-notifications.d.ts +0 -2
- package/methods/customer-notifications.js +0 -528
- package/methods/customer-notifications.js.map +0 -1
- package/methods/diagnostics.d.ts +0 -2
- package/methods/diagnostics.js +0 -703
- package/methods/diagnostics.js.map +0 -1
- package/methods/flag-updates.d.ts +0 -2
- package/methods/flag-updates.js +0 -8
- package/methods/flag-updates.js.map +0 -1
- package/methods/flags.d.ts +0 -2
- package/methods/flags.js +0 -8
- package/methods/flags.js.map +0 -1
- package/methods/logs.d.ts +0 -2
- package/methods/logs.js +0 -751
- package/methods/logs.js.map +0 -1
- package/methods/mongo-explorer.d.ts +0 -2
- package/methods/mongo-explorer.js +0 -1808
- package/methods/mongo-explorer.js.map +0 -1
- package/methods/monitor.d.ts +0 -2
- package/methods/monitor.js +0 -543
- package/methods/monitor.js.map +0 -1
- package/methods/pdf.d.ts +0 -2
- package/methods/pdf.js +0 -1216
- package/methods/pdf.js.map +0 -1
- package/methods/publications.d.ts +0 -1
- package/methods/publications.js +0 -183
- package/methods/publications.js.map +0 -1
- package/methods/report-builder.d.ts +0 -2
- package/methods/report-builder.js +0 -3094
- package/methods/report-builder.js.map +0 -1
- package/methods/support.d.ts +0 -2
- package/methods/support.js +0 -430
- package/methods/support.js.map +0 -1
- package/models/ai-run.model.d.ts +0 -19
- package/models/ai-run.model.js +0 -4
- package/models/ai-run.model.js.map +0 -1
- package/models/ai-terminal-conversation.model.d.ts +0 -17
- package/models/ai-terminal-conversation.model.js +0 -4
- package/models/ai-terminal-conversation.model.js.map +0 -1
- package/models/ai-terminal-issue-report.model.d.ts +0 -19
- package/models/ai-terminal-issue-report.model.js +0 -4
- package/models/ai-terminal-issue-report.model.js.map +0 -1
- package/models/ai-terminal-message.model.d.ts +0 -22
- package/models/ai-terminal-message.model.js +0 -4
- package/models/ai-terminal-message.model.js.map +0 -1
- package/models/app-setting.model.d.ts +0 -16
- package/models/app-setting.model.js +0 -4
- package/models/app-setting.model.js.map +0 -1
- package/models/app-status.model.js +0 -4
- package/models/app-status.model.js.map +0 -1
- package/models/billing-logged-in-users.model.js +0 -4
- package/models/billing-logged-in-users.model.js.map +0 -1
- package/models/collection-document.model.d.ts +0 -21
- package/models/collection-document.model.js +0 -4
- package/models/collection-document.model.js.map +0 -1
- package/models/communication-metric.model.d.ts +0 -20
- package/models/communication-metric.model.js +0 -4
- package/models/communication-metric.model.js.map +0 -1
- package/models/counter.model.js +0 -4
- package/models/counter.model.js.map +0 -1
- package/models/cron-job-history.model.d.ts +0 -15
- package/models/cron-job-history.model.js +0 -4
- package/models/cron-job-history.model.js.map +0 -1
- package/models/cron-job.model.d.ts +0 -14
- package/models/cron-job.model.js +0 -4
- package/models/cron-job.model.js.map +0 -1
- package/models/customer-notification.model.d.ts +0 -26
- package/models/customer-notification.model.js +0 -4
- package/models/customer-notification.model.js.map +0 -1
- package/models/customer-portal-password.model.d.ts +0 -11
- package/models/customer-portal-password.model.js +0 -4
- package/models/customer-portal-password.model.js.map +0 -1
- package/models/dialog.model.d.ts +0 -23
- package/models/dialog.model.js +0 -4
- package/models/dialog.model.js.map +0 -1
- package/models/email-history.model.d.ts +0 -32
- package/models/email-history.model.js.map +0 -1
- package/models/email-verified.model.js +0 -4
- package/models/email-verified.model.js.map +0 -1
- package/models/file.model.js +0 -4
- package/models/file.model.js.map +0 -1
- package/models/flag-update.model.js +0 -4
- package/models/flag-update.model.js.map +0 -1
- package/models/flag.model.js +0 -4
- package/models/flag.model.js.map +0 -1
- package/models/log-method-latency.model.d.ts +0 -10
- package/models/log-method-latency.model.js +0 -4
- package/models/log-method-latency.model.js.map +0 -1
- package/models/log-subscription.model.js +0 -4
- package/models/log-subscription.model.js.map +0 -1
- package/models/log.model.d.ts +0 -17
- package/models/log.model.js +0 -4
- package/models/log.model.js.map +0 -1
- package/models/logged-in-users.model.js +0 -4
- package/models/logged-in-users.model.js.map +0 -1
- package/models/method-response.model.js +0 -4
- package/models/method-response.model.js.map +0 -1
- package/models/method.model.d.ts +0 -26
- package/models/method.model.js +0 -4
- package/models/method.model.js.map +0 -1
- package/models/monitor-cpu.model.js +0 -4
- package/models/monitor-cpu.model.js.map +0 -1
- package/models/monitor-function.model.d.ts +0 -14
- package/models/monitor-function.model.js +0 -4
- package/models/monitor-function.model.js.map +0 -1
- package/models/monitor-memory.model.d.ts +0 -15
- package/models/monitor-memory.model.js +0 -4
- package/models/monitor-memory.model.js.map +0 -1
- package/models/monitor-mongo.model.d.ts +0 -13
- package/models/monitor-mongo.model.js +0 -4
- package/models/monitor-mongo.model.js.map +0 -1
- package/models/notification.model.js +0 -4
- package/models/notification.model.js.map +0 -1
- package/models/openai-usage-ledger.model.d.ts +0 -30
- package/models/openai-usage-ledger.model.js +0 -4
- package/models/openai-usage-ledger.model.js.map +0 -1
- package/models/pagination.model.d.ts +0 -11
- package/models/pagination.model.js +0 -28
- package/models/pagination.model.js.map +0 -1
- package/models/permission.model.d.ts +0 -12
- package/models/permission.model.js +0 -4
- package/models/permission.model.js.map +0 -1
- package/models/report-builder-dashboard-builder.model.d.ts +0 -25
- package/models/report-builder-dashboard-builder.model.js +0 -4
- package/models/report-builder-dashboard-builder.model.js.map +0 -1
- package/models/report-builder-library.model.d.ts +0 -17
- package/models/report-builder-library.model.js +0 -4
- package/models/report-builder-library.model.js.map +0 -1
- package/models/report-builder-report.model.d.ts +0 -121
- package/models/report-builder-report.model.js +0 -4
- package/models/report-builder-report.model.js.map +0 -1
- package/models/report-builder.model.d.ts +0 -61
- package/models/report-builder.model.js +0 -4
- package/models/report-builder.model.js.map +0 -1
- package/models/select-data-label.model.d.ts +0 -9
- package/models/select-data-label.model.js +0 -4
- package/models/select-data-label.model.js.map +0 -1
- package/models/server-message.model.d.ts +0 -32
- package/models/server-message.model.js +0 -4
- package/models/server-message.model.js.map +0 -1
- package/models/slow-query-report.model.d.ts +0 -23
- package/models/slow-query-report.model.js +0 -4
- package/models/slow-query-report.model.js.map +0 -1
- package/models/subscription.model.d.ts +0 -31
- package/models/subscription.model.js +0 -4
- package/models/subscription.model.js.map +0 -1
- package/models/support-ticket.model.d.ts +0 -87
- package/models/support-ticket.model.js +0 -4
- package/models/support-ticket.model.js.map +0 -1
- package/models/user-group.model.d.ts +0 -20
- package/models/user-group.model.js +0 -4
- package/models/user-group.model.js.map +0 -1
- package/models/user-guide.model.js +0 -4
- package/models/user-guide.model.js.map +0 -1
- package/models/user.model.d.ts +0 -84
- package/models/user.model.js +0 -4
- package/models/user.model.js.map +0 -1
- package/private/images/ResolveIO.png +0 -0
- package/public_api.js +0 -127
- package/public_api.js.map +0 -1
- package/publications/ai-terminal.d.ts +0 -1
- package/publications/ai-terminal.js +0 -122
- package/publications/ai-terminal.js.map +0 -1
- package/publications/app-settings.d.ts +0 -2
- package/publications/app-settings.js +0 -28
- package/publications/app-settings.js.map +0 -1
- package/publications/app-status.d.ts +0 -2
- package/publications/app-status.js +0 -16
- package/publications/app-status.js.map +0 -1
- package/publications/cron-jobs.d.ts +0 -2
- package/publications/cron-jobs.js +0 -88
- package/publications/cron-jobs.js.map +0 -1
- package/publications/customer-notifications.d.ts +0 -2
- package/publications/customer-notifications.js +0 -161
- package/publications/customer-notifications.js.map +0 -1
- package/publications/files.d.ts +0 -2
- package/publications/files.js +0 -36
- package/publications/files.js.map +0 -1
- package/publications/flags-update.d.ts +0 -2
- package/publications/flags-update.js +0 -22
- package/publications/flags-update.js.map +0 -1
- package/publications/flags.d.ts +0 -2
- package/publications/flags.js +0 -22
- package/publications/flags.js.map +0 -1
- package/publications/logs.d.ts +0 -2
- package/publications/logs.js +0 -164
- package/publications/logs.js.map +0 -1
- package/publications/notifications.d.ts +0 -2
- package/publications/notifications.js +0 -16
- package/publications/notifications.js.map +0 -1
- package/publications/report-builder-dashboard-builders.d.ts +0 -2
- package/publications/report-builder-dashboard-builders.js +0 -42
- package/publications/report-builder-dashboard-builders.js.map +0 -1
- package/publications/report-builder-libraries.d.ts +0 -2
- package/publications/report-builder-libraries.js +0 -90
- package/publications/report-builder-libraries.js.map +0 -1
- package/publications/report-builder-reports.d.ts +0 -2
- package/publications/report-builder-reports.js +0 -50
- package/publications/report-builder-reports.js.map +0 -1
- package/publications/super-admin.d.ts +0 -2
- package/publications/super-admin.js +0 -16
- package/publications/super-admin.js.map +0 -1
- package/publications/user-groups.d.ts +0 -1
- package/publications/user-groups.js +0 -16
- package/publications/user-groups.js.map +0 -1
- package/publications/user-guides.d.ts +0 -1
- package/publications/user-guides.js +0 -16
- package/publications/user-guides.js.map +0 -1
- package/resolveio-server-app.d.ts +0 -70
- package/resolveio-server-app.js +0 -801
- package/resolveio-server-app.js.map +0 -1
- package/server-app.d.ts +0 -228
- package/server-app.js +0 -3566
- package/server-app.js.map +0 -1
- package/services/codex-client.d.ts +0 -128
- package/services/codex-client.js +0 -1629
- package/services/codex-client.js.map +0 -1
- package/services/openai-client.d.ts +0 -46
- package/services/openai-client.js +0 -318
- package/services/openai-client.js.map +0 -1
- package/types/error-report.d.ts +0 -25
- package/types/error-report.js +0 -4
- package/types/error-report.js.map +0 -1
- package/types/slow-query-report.d.ts +0 -27
- package/types/slow-query-report.js +0 -6
- package/types/slow-query-report.js.map +0 -1
- package/util/ai-qa-policy.d.ts +0 -124
- package/util/ai-qa-policy.js +0 -736
- package/util/ai-qa-policy.js.map +0 -1
- package/util/ai-run-evidence-adapters.d.ts +0 -73
- package/util/ai-run-evidence-adapters.js +0 -2986
- package/util/ai-run-evidence-adapters.js.map +0 -1
- package/util/ai-run-evidence-dashboard.d.ts +0 -84
- package/util/ai-run-evidence-dashboard.js +0 -336
- package/util/ai-run-evidence-dashboard.js.map +0 -1
- package/util/ai-run-evidence-eval.d.ts +0 -86
- package/util/ai-run-evidence-eval.js +0 -854
- package/util/ai-run-evidence-eval.js.map +0 -1
- package/util/ai-run-evidence.d.ts +0 -244
- package/util/ai-run-evidence.js +0 -778
- package/util/ai-run-evidence.js.map +0 -1
- package/util/ai-runner-artifacts.d.ts +0 -82
- package/util/ai-runner-artifacts.js +0 -713
- package/util/ai-runner-artifacts.js.map +0 -1
- package/util/ai-runner-manager-autopilot.d.ts +0 -210
- package/util/ai-runner-manager-autopilot.js +0 -642
- package/util/ai-runner-manager-autopilot.js.map +0 -1
- package/util/ai-runner-manager-policy.d.ts +0 -653
- package/util/ai-runner-manager-policy.js +0 -2880
- package/util/ai-runner-manager-policy.js.map +0 -1
- package/util/ai-runner-qa-auth.d.ts +0 -5
- package/util/ai-runner-qa-auth.js +0 -822
- package/util/ai-runner-qa-auth.js.map +0 -1
- package/util/ai-runner-qa-tools.d.ts +0 -26
- package/util/ai-runner-qa-tools.js +0 -3029
- package/util/ai-runner-qa-tools.js.map +0 -1
- package/util/aicoder-runner-v6.d.ts +0 -367
- package/util/aicoder-runner-v6.js +0 -1925
- package/util/aicoder-runner-v6.js.map +0 -1
- package/util/common.d.ts +0 -31
- package/util/common.js +0 -683
- package/util/common.js.map +0 -1
- package/util/customer-portal-password.d.ts +0 -13
- package/util/customer-portal-password.js +0 -209
- package/util/customer-portal-password.js.map +0 -1
- package/util/error-reporter.d.ts +0 -52
- package/util/error-reporter.js +0 -326
- package/util/error-reporter.js.map +0 -1
- package/util/error-tracking.d.ts +0 -13
- package/util/error-tracking.js +0 -120
- package/util/error-tracking.js.map +0 -1
- package/util/openai-usage-cost.d.ts +0 -6
- package/util/openai-usage-cost.js +0 -103
- package/util/openai-usage-cost.js.map +0 -1
- package/util/report-builder-unwinds.d.ts +0 -15
- package/util/report-builder-unwinds.js +0 -156
- package/util/report-builder-unwinds.js.map +0 -1
- package/util/runner-process-janitor.d.ts +0 -27
- package/util/runner-process-janitor.js +0 -208
- package/util/runner-process-janitor.js.map +0 -1
- package/util/schema-report-builder.d.ts +0 -6
- package/util/schema-report-builder.js +0 -481
- package/util/schema-report-builder.js.map +0 -1
- package/util/slow-query-reporter.d.ts +0 -28
- package/util/slow-query-reporter.js +0 -226
- package/util/slow-query-reporter.js.map +0 -1
- package/util/subscription-dependency-context.d.ts +0 -34
- package/util/subscription-dependency-context.js +0 -1283
- package/util/subscription-dependency-context.js.map +0 -1
- package/util/support-runner-v5.d.ts +0 -810
- package/util/support-runner-v5.js +0 -3497
- package/util/support-runner-v5.js.map +0 -1
- package/util/tokenizer.d.ts +0 -5
- package/util/tokenizer.js +0 -41
- package/util/tokenizer.js.map +0 -1
- package/workers/codex-runner.worker.d.ts +0 -1
- package/workers/codex-runner.worker.js +0 -192
- package/workers/codex-runner.worker.js.map +0 -1
- /package/{private → src/private}/email-templates/enrollment.html +0 -0
- /package/{private → src/private}/email-templates/forgot-password.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket-deleted.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket-modified.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket.html +0 -0
- /package/{public_api.d.ts → src/public_api.ts} +0 -0
|
@@ -0,0 +1,1403 @@
|
|
|
1
|
+
import * as assert from 'node:assert/strict';
|
|
2
|
+
import {
|
|
3
|
+
buildAIRun,
|
|
4
|
+
buildAIRunCost,
|
|
5
|
+
buildAIQaRun,
|
|
6
|
+
classifyAIRunOutcome,
|
|
7
|
+
normalizeOpenAIUsageRowsForCosting,
|
|
8
|
+
redactAIRunTrainingExample
|
|
9
|
+
} from '../src/util/ai-run-evidence';
|
|
10
|
+
import {
|
|
11
|
+
buildAICoderAIRunFromEvidence,
|
|
12
|
+
buildAssistantAIRunFromEvidence,
|
|
13
|
+
buildSupportAIRunFromEvidence
|
|
14
|
+
} from '../src/util/ai-run-evidence-adapters';
|
|
15
|
+
import {
|
|
16
|
+
classifyAIRunFailureClass,
|
|
17
|
+
decideAIRunRetry
|
|
18
|
+
} from '../src/util/ai-run-evidence-eval';
|
|
19
|
+
import { estimateOpenAIUsageCost } from '../src/util/openai-usage-cost';
|
|
20
|
+
|
|
21
|
+
const routeOnlyQa = buildAIQaRun({
|
|
22
|
+
infraChecks: [
|
|
23
|
+
{ name: 'puppeteer_require', status: 'pass' },
|
|
24
|
+
{ name: 'chrome_executable', status: 'pass' }
|
|
25
|
+
],
|
|
26
|
+
compile: { status: 'pass', artifactPath: '.build-output/build-client.log' },
|
|
27
|
+
routeProbes: [{
|
|
28
|
+
route: '/billing/dashboard',
|
|
29
|
+
status: 'pass',
|
|
30
|
+
screenshot: 'qa-artifacts/route-ready.jpg',
|
|
31
|
+
caption: 'Route loaded.'
|
|
32
|
+
}]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
assert.equal(routeOnlyQa.outcome, 'route_only_pass');
|
|
36
|
+
assert.equal(routeOnlyQa.gateResults.some((gate) => gate.key === 'qa_business_assertion' && gate.status === 'blocked'), true);
|
|
37
|
+
assert.equal(classifyAIRunOutcome({ qa: routeOnlyQa }).outcome, 'qa_incomplete');
|
|
38
|
+
assert.equal(classifyAIRunOutcome({ qa: routeOnlyQa, scorecardPassed: true }).outcome, 'false_pass');
|
|
39
|
+
|
|
40
|
+
const infraFailedQa = buildAIQaRun({
|
|
41
|
+
infraChecks: [
|
|
42
|
+
{ name: 'puppeteer_require', status: 'blocked', message: 'Unable to require puppeteer.' }
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
assert.equal(infraFailedQa.outcome, 'infra_failed');
|
|
46
|
+
assert.equal(classifyAIRunOutcome({ qa: infraFailedQa }).outcome, 'qa_infra_failed');
|
|
47
|
+
|
|
48
|
+
const compileFailedQa = buildAIQaRun({
|
|
49
|
+
infraChecks: [{ name: 'chrome_executable', status: 'pass' }],
|
|
50
|
+
compile: { status: 'stale', staleEvidence: true, artifactPath: '.build-output/build-client.log' }
|
|
51
|
+
});
|
|
52
|
+
assert.equal(compileFailedQa.outcome, 'compile_failed');
|
|
53
|
+
assert.equal(classifyAIRunOutcome({ qa: compileFailedQa }).outcome, 'build_failed');
|
|
54
|
+
|
|
55
|
+
const businessPassedQa = buildAIQaRun({
|
|
56
|
+
infraChecks: [{ name: 'chrome_launch', status: 'pass' }],
|
|
57
|
+
compile: { status: 'pass' },
|
|
58
|
+
routeProbes: [{ route: '/report', status: 'pass' }],
|
|
59
|
+
businessAssertions: [{
|
|
60
|
+
assertion: 'Report exports include seeded rows.',
|
|
61
|
+
status: 'pass',
|
|
62
|
+
dataProof: '3 seeded rows rendered and exported.',
|
|
63
|
+
artifactPaths: ['qa-artifacts/report-proof.json']
|
|
64
|
+
}]
|
|
65
|
+
});
|
|
66
|
+
assert.equal(businessPassedQa.outcome, 'business_assertion_passed');
|
|
67
|
+
assert.equal(classifyAIRunOutcome({
|
|
68
|
+
qa: businessPassedQa,
|
|
69
|
+
status: 'Passed',
|
|
70
|
+
phase: 'COMPLETE',
|
|
71
|
+
scorecardPassed: true,
|
|
72
|
+
deployStatus: 'pass',
|
|
73
|
+
publishStatus: 'published',
|
|
74
|
+
sampleDataStatus: 'pass'
|
|
75
|
+
}).outcome, 'accepted');
|
|
76
|
+
|
|
77
|
+
const releaseBlocked = classifyAIRunOutcome({
|
|
78
|
+
qa: businessPassedQa,
|
|
79
|
+
scorecardPassed: true,
|
|
80
|
+
deployStatus: 'Backend health smoke failed',
|
|
81
|
+
publishStatus: 'No such remote origin',
|
|
82
|
+
sampleDataStatus: 'empty collections detected'
|
|
83
|
+
});
|
|
84
|
+
assert.equal(releaseBlocked.outcome, 'release_blocked');
|
|
85
|
+
assert.ok(releaseBlocked.gates.some((gate) => gate.key === 'release' && gate.status === 'fail'));
|
|
86
|
+
|
|
87
|
+
const builtRun = buildAIRun({
|
|
88
|
+
source: 'aicoder_app',
|
|
89
|
+
sourceIds: { appId: 'app-1', jobId: 'job-1' },
|
|
90
|
+
title: 'Layflat Pressure Optimizer',
|
|
91
|
+
status: 'Passed',
|
|
92
|
+
phase: 'COMPLETE',
|
|
93
|
+
events: [],
|
|
94
|
+
qa: businessPassedQa,
|
|
95
|
+
scorecardPassed: true,
|
|
96
|
+
deployStatus: 'pass',
|
|
97
|
+
publishStatus: 'published',
|
|
98
|
+
sampleDataStatus: 'pass'
|
|
99
|
+
});
|
|
100
|
+
assert.equal(builtRun.outcome, 'accepted');
|
|
101
|
+
assert.equal(builtRun.sourceIds.appId, 'app-1');
|
|
102
|
+
|
|
103
|
+
const cost = buildAIRunCost([
|
|
104
|
+
{ model: 'gpt-5.3-codex', category: 'review', input_tokens: 1000, cached_input_tokens: 100, output_tokens: 250, cost_estimate: 1.23456789 },
|
|
105
|
+
{ model: 'gpt-5.4-mini', category: 'qa', inputTokens: 200, outputTokens: 50, estimatedUsd: 0.12 },
|
|
106
|
+
{
|
|
107
|
+
model: 'gpt-5.3-codex',
|
|
108
|
+
category: 'manual-monitoring',
|
|
109
|
+
usage_source: 'manual_codex',
|
|
110
|
+
usage_surface: 'aicoder',
|
|
111
|
+
cost_basis: 'manual_estimate',
|
|
112
|
+
is_manual: true,
|
|
113
|
+
is_untracked: true,
|
|
114
|
+
untracked_reason: 'Sidecar Codex session watched the Layflat builder.',
|
|
115
|
+
input_tokens: 3000,
|
|
116
|
+
output_tokens: 700,
|
|
117
|
+
cost_estimate: 7.5
|
|
118
|
+
}
|
|
119
|
+
]);
|
|
120
|
+
assert.equal(cost.inputTokens, 4200);
|
|
121
|
+
assert.equal(cost.cachedInputTokens, 100);
|
|
122
|
+
assert.equal(cost.outputTokens, 1000);
|
|
123
|
+
assert.equal(cost.categories.review.count, 1);
|
|
124
|
+
assert.deepEqual(cost.models, ['gpt-5.3-codex', 'gpt-5.4-mini']);
|
|
125
|
+
assert.equal(cost.sources?.manual_codex.estimatedUsd, 7.5);
|
|
126
|
+
assert.equal(cost.sources?.manual_codex.manualCount, 1);
|
|
127
|
+
assert.equal(cost.sources?.manual_codex.untrackedCount, 1);
|
|
128
|
+
assert.equal(cost.surfaces?.aicoder.estimatedUsd, 7.5);
|
|
129
|
+
assert.equal(cost.manualEstimatedUsd, 7.5);
|
|
130
|
+
assert.equal(cost.untrackedEstimatedUsd, 7.5);
|
|
131
|
+
assert.equal(cost.untrackedWarnings?.includes('Sidecar Codex session watched the Layflat builder.'), true);
|
|
132
|
+
|
|
133
|
+
const costOnlyManual = buildAIRunCost([
|
|
134
|
+
{
|
|
135
|
+
model: 'codex-manual',
|
|
136
|
+
category: 'manual-codex',
|
|
137
|
+
usage_source: 'manual_codex',
|
|
138
|
+
usage_surface: 'support',
|
|
139
|
+
cost_basis: 'manual_estimate',
|
|
140
|
+
is_manual: true,
|
|
141
|
+
is_untracked: true,
|
|
142
|
+
untracked_reason: 'Codex sidecar monitored support runner 004421.',
|
|
143
|
+
input_tokens: 0,
|
|
144
|
+
output_tokens: 0,
|
|
145
|
+
total_tokens: 0,
|
|
146
|
+
cost_estimate: 23.75
|
|
147
|
+
}
|
|
148
|
+
]);
|
|
149
|
+
assert.equal(costOnlyManual.totalTokens, 0);
|
|
150
|
+
assert.equal(costOnlyManual.estimatedUsd, 23.75);
|
|
151
|
+
assert.equal(costOnlyManual.manualEstimatedUsd, 23.75);
|
|
152
|
+
assert.equal(costOnlyManual.untrackedEstimatedUsd, 23.75);
|
|
153
|
+
assert.equal(costOnlyManual.sources?.manual_codex.count, 1);
|
|
154
|
+
assert.equal(costOnlyManual.surfaces?.support.estimatedUsd, 23.75);
|
|
155
|
+
|
|
156
|
+
const normalizedUsageRows = normalizeOpenAIUsageRowsForCosting([
|
|
157
|
+
{
|
|
158
|
+
model: 'gpt-5.5',
|
|
159
|
+
category: 'ai-dashboard-codex:master:file-body',
|
|
160
|
+
id_conversation: 'thread-1',
|
|
161
|
+
timestamp: '2026-06-13T10:00:00.000Z',
|
|
162
|
+
input_tokens: 1000,
|
|
163
|
+
cached_input_tokens: 800,
|
|
164
|
+
output_tokens: 100,
|
|
165
|
+
total_tokens: 1100,
|
|
166
|
+
cost_estimate: 1
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
model: 'gpt-5.5',
|
|
170
|
+
category: 'ai-dashboard-codex:master:file-body',
|
|
171
|
+
id_conversation: 'thread-1',
|
|
172
|
+
timestamp: '2026-06-13T10:01:00.000Z',
|
|
173
|
+
input_tokens: 1500,
|
|
174
|
+
cached_input_tokens: 1000,
|
|
175
|
+
output_tokens: 140,
|
|
176
|
+
total_tokens: 1640,
|
|
177
|
+
cost_estimate: 1.4
|
|
178
|
+
}
|
|
179
|
+
]);
|
|
180
|
+
assert.equal(normalizedUsageRows[1].input_tokens, 500);
|
|
181
|
+
assert.equal(normalizedUsageRows[1].cached_input_tokens, 200);
|
|
182
|
+
assert.equal(normalizedUsageRows[1].output_tokens, 40);
|
|
183
|
+
assert.equal(normalizedUsageRows[1].cost_estimate, 0.4);
|
|
184
|
+
|
|
185
|
+
const cumulativeCost = buildAIRunCost([
|
|
186
|
+
{
|
|
187
|
+
model: 'gpt-5.5',
|
|
188
|
+
category: 'ai-dashboard-codex:master:file-body',
|
|
189
|
+
id_conversation: 'thread-1',
|
|
190
|
+
timestamp: '2026-06-13T10:00:00.000Z',
|
|
191
|
+
input_tokens: 1000,
|
|
192
|
+
cached_input_tokens: 800,
|
|
193
|
+
output_tokens: 100,
|
|
194
|
+
total_tokens: 1100,
|
|
195
|
+
cost_estimate: 1
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
model: 'gpt-5.5',
|
|
199
|
+
category: 'ai-dashboard-codex:master:file-body',
|
|
200
|
+
id_conversation: 'thread-1',
|
|
201
|
+
timestamp: '2026-06-13T10:01:00.000Z',
|
|
202
|
+
input_tokens: 1500,
|
|
203
|
+
cached_input_tokens: 1000,
|
|
204
|
+
output_tokens: 140,
|
|
205
|
+
total_tokens: 1640,
|
|
206
|
+
cost_estimate: 1.4
|
|
207
|
+
}
|
|
208
|
+
]);
|
|
209
|
+
assert.equal(cumulativeCost.inputTokens, 1500);
|
|
210
|
+
assert.equal(cumulativeCost.cachedInputTokens, 1000);
|
|
211
|
+
assert.equal(cumulativeCost.outputTokens, 140);
|
|
212
|
+
assert.equal(cumulativeCost.estimatedUsd, 1.4);
|
|
213
|
+
assert.equal(estimateOpenAIUsageCost('gpt-5.4-2026-03-10', 1000, 100, 500), 0.002875);
|
|
214
|
+
assert.equal(estimateOpenAIUsageCost('gpt-5.3-codex', 1000, 100, 500), 0.00575);
|
|
215
|
+
assert.equal(estimateOpenAIUsageCost('gpt-5.4-codex', 1000, 100, 500), 0.002875);
|
|
216
|
+
assert.equal(estimateOpenAIUsageCost('codex-mini-latest', 1000, 100, 500), 0.000863);
|
|
217
|
+
|
|
218
|
+
const redacted = redactAIRunTrainingExample({
|
|
219
|
+
runId: 'run-1',
|
|
220
|
+
source: 'ai_assistant',
|
|
221
|
+
inputSummary: 'Mongo URL mongodb://user:password@host/db and email test@example.com',
|
|
222
|
+
actionSummary: 'Used key sk-12345678901234567890',
|
|
223
|
+
outcome: 'rejected',
|
|
224
|
+
evidence: ['ghp_12345678901234567890 appears here']
|
|
225
|
+
});
|
|
226
|
+
assert.match(redacted.inputSummary, /\[redacted-mongo-url\]/);
|
|
227
|
+
assert.match(redacted.inputSummary, /\[redacted-email\]/);
|
|
228
|
+
assert.match(redacted.actionSummary, /\[redacted-secret\]/);
|
|
229
|
+
assert.match(redacted.evidence[0], /\[redacted-secret\]/);
|
|
230
|
+
|
|
231
|
+
const supportRootCauseEntryContract = {
|
|
232
|
+
contract_id: 'support-root-cause-entry-test',
|
|
233
|
+
version: 'support_root_cause_entry_v1',
|
|
234
|
+
status: 'required',
|
|
235
|
+
required_output: {
|
|
236
|
+
object_key: 'support_diagnosis_gate',
|
|
237
|
+
status: 'passed',
|
|
238
|
+
required_fields: [
|
|
239
|
+
'issue_case',
|
|
240
|
+
'issue_class',
|
|
241
|
+
'accepted_hypothesis',
|
|
242
|
+
'rejected_alternatives',
|
|
243
|
+
'failing_path',
|
|
244
|
+
'owner_files',
|
|
245
|
+
'proof_plan',
|
|
246
|
+
'evidence'
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
owner_file_policy: {
|
|
250
|
+
max_files: 8,
|
|
251
|
+
exact_files_only: true,
|
|
252
|
+
edits_outside_owner_files_require_revised_diagnosis: true
|
|
253
|
+
},
|
|
254
|
+
business_proof_policy: {
|
|
255
|
+
requires_aiqa_business_assertion: true,
|
|
256
|
+
requires_before_action_after: true,
|
|
257
|
+
route_load_screenshot_scorecard_model_claim_not_acceptance: true,
|
|
258
|
+
required_artifacts: ['runner-evidence/diagnosis-gate.json', 'qa-artifacts/aiqa-business-assertion.json']
|
|
259
|
+
},
|
|
260
|
+
failure_policy: {
|
|
261
|
+
repeated_failure_without_new_evidence_parks_run: true,
|
|
262
|
+
infra_compile_puppeteer_startup_failures_route_to_infra_repair: true,
|
|
263
|
+
similar_tickets_and_commits_are_advisory_only: true
|
|
264
|
+
},
|
|
265
|
+
issue_class_probes: [
|
|
266
|
+
'no_op_submit',
|
|
267
|
+
'missing_wrong_data',
|
|
268
|
+
'filter_query_mismatch',
|
|
269
|
+
'invoice_pdf_export',
|
|
270
|
+
'upload_import',
|
|
271
|
+
'route_auth_hydration',
|
|
272
|
+
'slow_query_performance'
|
|
273
|
+
].map((issueClass) => ({
|
|
274
|
+
issue_class: issueClass,
|
|
275
|
+
required_paths: ['frontend_event', 'backend_method'],
|
|
276
|
+
required_evidence: ['before/action/after business state'],
|
|
277
|
+
false_pass_blockers: ['route loaded only']
|
|
278
|
+
}))
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const supportRun = buildSupportAIRunFromEvidence({
|
|
282
|
+
ticket: { _id: 'ticket-004421', ticketNumber: '004421', title: 'QA route only false pass' },
|
|
283
|
+
job: {
|
|
284
|
+
_id: 'support-job-1',
|
|
285
|
+
status: 'Running',
|
|
286
|
+
phase: 'QA',
|
|
287
|
+
supportRootCauseEntryContract,
|
|
288
|
+
supportV5DiagnosisGate: {
|
|
289
|
+
issue_case: {
|
|
290
|
+
customer_complaint: 'Support ticket list shows tickets from the wrong customer after applying a customer filter.',
|
|
291
|
+
expected_result: 'Only tickets for Customer B should appear when Customer B is selected.',
|
|
292
|
+
observed_result: 'A Customer A ticket remains visible while filtered to Customer B.',
|
|
293
|
+
route_module: '/support tickets list',
|
|
294
|
+
account_customer_context: 'Support admin reviewing ticket 004421 for Customer B.',
|
|
295
|
+
reproduction_status: 'reproduced'
|
|
296
|
+
},
|
|
297
|
+
issue_class: 'filter_query_mismatch',
|
|
298
|
+
status: 'passed',
|
|
299
|
+
accepted_hypothesis: {
|
|
300
|
+
statement: 'The ticket list query ignores the customer filter.',
|
|
301
|
+
falsifiable_test: 'Apply the Customer B filter and compare the returned rows with the persisted customer id for each ticket.',
|
|
302
|
+
evidence: ['QA artifact shows Customer A ticket visible while Customer B filter is active.']
|
|
303
|
+
},
|
|
304
|
+
rejected_alternatives: [
|
|
305
|
+
'Frontend select state was not the root cause because the network payload includes the selected Customer B filter.',
|
|
306
|
+
'Authentication was not the root cause because the affected support admin can load the ticket list route.'
|
|
307
|
+
],
|
|
308
|
+
failing_path: {
|
|
309
|
+
frontend: 'Support ticket customer filter submits selected customer id.',
|
|
310
|
+
backend: 'server/src/publications/support-tickets.ts ticket list publication',
|
|
311
|
+
data_query: 'Mongo ticket query does not constrain by selected customer id.',
|
|
312
|
+
description: 'Filter input reaches the backend, but the publication query returns rows outside the selected customer.'
|
|
313
|
+
},
|
|
314
|
+
owner_files: ['server/src/publications/support-tickets.ts'],
|
|
315
|
+
proof_plan: {
|
|
316
|
+
before: 'Customer A ticket appears while filtered to Customer B.',
|
|
317
|
+
action: 'Apply the Customer B filter and reload the ticket list.',
|
|
318
|
+
after: 'Only Customer B tickets are listed.',
|
|
319
|
+
business_assertion: 'The wrong-customer ticket is absent after filtering.',
|
|
320
|
+
data_assertion: 'Every returned ticket row has customerId equal to Customer B.',
|
|
321
|
+
artifact_expectation: 'QA stores before/action/after row snapshots and the filtered publication payload.',
|
|
322
|
+
business_proof_contract: {
|
|
323
|
+
issue_class: 'filter_query_mismatch',
|
|
324
|
+
setup_state: 'Seed or select one Customer A ticket and one Customer B ticket.',
|
|
325
|
+
action_under_test: 'Apply the Customer B filter on the support ticket list.',
|
|
326
|
+
expected_business_state_change: 'Rows outside Customer B are excluded while Customer B rows remain visible.',
|
|
327
|
+
prohibited_false_pass: 'Route load or non-empty table without row/customer proof.',
|
|
328
|
+
proof_artifacts: ['qa-artifacts/support-filter-before-after.json'],
|
|
329
|
+
data_or_dom_assertion: 'DOM rows and publication payload contain only Customer B ticket ids.'
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
evidence: [{
|
|
333
|
+
type: 'ticket',
|
|
334
|
+
summary: 'Ticket 004421 reports wrong-customer tickets appearing after a customer filter is applied.'
|
|
335
|
+
}, {
|
|
336
|
+
type: 'qa',
|
|
337
|
+
summary: 'Browser QA reproduced Customer A ticket visible while Customer B filter was active.',
|
|
338
|
+
artifactPath: 'qa-artifacts/support-filter-reproduction.json'
|
|
339
|
+
}, {
|
|
340
|
+
type: 'code',
|
|
341
|
+
summary: 'Publication owner file contains the query that returns support ticket rows.'
|
|
342
|
+
}]
|
|
343
|
+
},
|
|
344
|
+
supportV5AutonomousDecision: {
|
|
345
|
+
nextActionContract: {
|
|
346
|
+
contractId: 'support-next-action-safe-repair',
|
|
347
|
+
action: 'run_owner_scoped_repair',
|
|
348
|
+
label: 'Run owner-scoped repair',
|
|
349
|
+
primaryCommand: 'run_support_v5_owner_scoped_repair',
|
|
350
|
+
lane: 'build',
|
|
351
|
+
stepType: 'owner_scoped_repair',
|
|
352
|
+
safeToAutoRun: true,
|
|
353
|
+
requiresHumanApproval: false,
|
|
354
|
+
canRunWithoutCodexMonitor: true,
|
|
355
|
+
codexFallbackRequired: false,
|
|
356
|
+
rootCauseFirstSatisfied: true,
|
|
357
|
+
preconditions: ['SupportDiagnosisGate passed.'],
|
|
358
|
+
successEvidence: ['AIQaBusinessAssertion mapped to proof_plan.'],
|
|
359
|
+
stopConditions: ['Same failure class repeats without new evidence.'],
|
|
360
|
+
ownerFiles: ['server/src/publications/support-tickets.ts'],
|
|
361
|
+
decisionBasis: {
|
|
362
|
+
diagnosisValid: true,
|
|
363
|
+
ownerFilesReady: true,
|
|
364
|
+
proofPlanReady: true,
|
|
365
|
+
businessProofReady: false,
|
|
366
|
+
evidenceFreshnessStatus: 'fresh',
|
|
367
|
+
evidenceStrength: 'medium',
|
|
368
|
+
failureClass: 'product_code',
|
|
369
|
+
sameFailureCount: 0,
|
|
370
|
+
hotfixCommitRequired: true,
|
|
371
|
+
liveHotfixBlockedUntilCommit: false
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
taskEvents: [{ message: 'Route loaded in browser.', phase: 'qa' }],
|
|
377
|
+
qaEvidence: {
|
|
378
|
+
infraChecks: [{ name: 'puppeteer_require', status: 'pass' }],
|
|
379
|
+
compile: { status: 'pass' },
|
|
380
|
+
routeProbes: [{ route: '/support/004421', status: 'pass', screenshot: 'qa-artifacts/route.jpg' }],
|
|
381
|
+
hotfixEvidence: {
|
|
382
|
+
channel: 'backend_js',
|
|
383
|
+
target: {
|
|
384
|
+
host: 'backend.resolveio.com',
|
|
385
|
+
path: '/var/app/current/http/runner-manager-selftest.js'
|
|
386
|
+
},
|
|
387
|
+
compiledArtifactPath: 'dist/http/runner-manager-selftest.js',
|
|
388
|
+
remoteChecksumBefore: '1111111111111111111111111111111111111111111111111111111111111111',
|
|
389
|
+
remoteChecksumAfter: '2222222222222222222222222222222222222222222222222222222222222222',
|
|
390
|
+
sourceCommitSha: '6fd400e1d8c961c1e88820292c323e688fdcc0a4',
|
|
391
|
+
githubCommitUrl: 'https://github.com/resolveio/resolveio-all/commit/6fd400e1d8c961c1e88820292c323e688fdcc0a4',
|
|
392
|
+
gitPushStatus: 'passed',
|
|
393
|
+
restartEvidence: 'nodejs restarted on all support hosts',
|
|
394
|
+
healthCheckStatus: 'passed',
|
|
395
|
+
selfTestStatus: 'passed'
|
|
396
|
+
},
|
|
397
|
+
scorecardPassed: true
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
assert.equal(supportRun.source, 'support_ticket');
|
|
401
|
+
assert.equal(supportRun.sourceIds.ticketNumber, '004421');
|
|
402
|
+
assert.equal(supportRun.outcome, 'false_pass');
|
|
403
|
+
assert.equal(supportRun.metadata?.diagnosis?.issueClass, 'filter_query_mismatch');
|
|
404
|
+
assert.equal(supportRun.metadata?.rootCauseEntryContract?.contractId, 'support-root-cause-entry-test');
|
|
405
|
+
assert.equal(supportRun.metadata?.rootCauseEntryContract?.issueClassProbeCount, 7);
|
|
406
|
+
assert.deepEqual(supportRun.metadata?.diagnosis?.ownerFiles, ['server/src/publications/support-tickets.ts']);
|
|
407
|
+
assert.equal(supportRun.events.some((event) => event.category === 'support_diagnosis_evidence_pack'), true);
|
|
408
|
+
assert.equal(supportRun.gates.some((gate) => gate.key === 'support_diagnosis_evidence_pack' && gate.status === 'pass'), true);
|
|
409
|
+
assert.equal(supportRun.metadata?.diagnosisEvidencePack?.readOnly, true);
|
|
410
|
+
assert.equal(supportRun.metadata?.diagnosisEvidencePack?.sourceEditsAllowed, false);
|
|
411
|
+
assert.equal(supportRun.metadata?.diagnosisEvidencePack?.issueClassProbeCount, 7);
|
|
412
|
+
assert.equal(supportRun.events.some((event) => event.category === 'diagnosis_gate'), true);
|
|
413
|
+
assert.equal(supportRun.events.some((event) => event.category === 'support_root_cause_entry_contract'), true);
|
|
414
|
+
assert.equal(supportRun.gates.some((gate) => gate.key === 'support_root_cause_entry_contract' && gate.status === 'pass'), true);
|
|
415
|
+
assert.equal(supportRun.events.some((event) => event.category === 'support_next_action_contract'), true);
|
|
416
|
+
assert.equal(supportRun.gates.some((gate) => gate.key === 'support_next_action_contract' && gate.status === 'pass'), true);
|
|
417
|
+
assert.equal(supportRun.metadata?.nextActionContract?.canRunWithoutCodexMonitor, true);
|
|
418
|
+
assert.equal(supportRun.metadata?.nextActionContract?.hotfixCommitRequired, true);
|
|
419
|
+
assert.equal(supportRun.metadata?.nextActionContract?.liveHotfixBlockedUntilCommit, false);
|
|
420
|
+
assert.equal(supportRun.events.some((event) => event.type === 'hotfix' && event.category === 'backend_js'), true);
|
|
421
|
+
assert.equal(supportRun.gates.some((gate) => gate.key === 'hotfix_evidence' && gate.status === 'pass'), true);
|
|
422
|
+
assert.equal(supportRun.gates.some((gate) => gate.key === 'hotfix_commit_proof' && gate.status === 'pass'), true);
|
|
423
|
+
assert.equal(supportRun.events.some((event) => event.category === 'hotfix_commit_proof' && event.metadata?.passed === true), true);
|
|
424
|
+
assert.equal(supportRun.gates.some((gate) => gate.key === 'qa_business_assertion' && gate.status === 'blocked'), true);
|
|
425
|
+
|
|
426
|
+
const supportInvalidRootCauseContractRun = buildSupportAIRunFromEvidence({
|
|
427
|
+
ticket: { _id: 'ticket-invalid-root-cause', ticketNumber: '004422', title: 'Invalid root cause contract' },
|
|
428
|
+
job: {
|
|
429
|
+
_id: 'support-job-invalid-root-cause',
|
|
430
|
+
status: 'Running',
|
|
431
|
+
phase: 'Planning',
|
|
432
|
+
supportRootCauseEntryContract: {
|
|
433
|
+
contract_id: 'support-root-cause-entry-invalid',
|
|
434
|
+
required_output: {
|
|
435
|
+
object_key: 'support_diagnosis_gate',
|
|
436
|
+
required_fields: ['issue_case']
|
|
437
|
+
},
|
|
438
|
+
owner_file_policy: {
|
|
439
|
+
max_files: 50
|
|
440
|
+
},
|
|
441
|
+
business_proof_policy: {},
|
|
442
|
+
failure_policy: {},
|
|
443
|
+
issue_class_probes: [{ issue_class: 'no_op_submit' }]
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
const invalidRootCauseGate = supportInvalidRootCauseContractRun.gates.find((gate) => gate.key === 'support_root_cause_entry_contract');
|
|
448
|
+
assert.equal(invalidRootCauseGate?.status, 'fail');
|
|
449
|
+
assert.match(String(invalidRootCauseGate?.reason || ''), /missing required output fields|issue-class probes/i);
|
|
450
|
+
|
|
451
|
+
const supportHotfixBlockedUntilCommitRun = buildSupportAIRunFromEvidence({
|
|
452
|
+
ticket: { _id: 'ticket-hotfix-commit-blocked', ticketNumber: '004777', title: 'Hotfix must be committed' },
|
|
453
|
+
job: {
|
|
454
|
+
_id: 'support-hotfix-commit-blocked',
|
|
455
|
+
status: 'Running',
|
|
456
|
+
phase: 'Release',
|
|
457
|
+
support_v5_autonomous_decision: {
|
|
458
|
+
next_action_contract: {
|
|
459
|
+
contract_id: 'support-next-action-hotfix-blocked',
|
|
460
|
+
action: 'apply_live_hotfix',
|
|
461
|
+
label: 'Apply live hotfix',
|
|
462
|
+
primary_command: 'run_support_v5_live_hotfix',
|
|
463
|
+
lane: 'release',
|
|
464
|
+
step_type: 'hotfix',
|
|
465
|
+
safe_to_auto_run: false,
|
|
466
|
+
requires_human_approval: true,
|
|
467
|
+
can_run_without_codex_monitor: false,
|
|
468
|
+
codex_fallback_required: true,
|
|
469
|
+
codex_fallback_reason: 'Live hotfix cannot proceed until commit proof is pushed.',
|
|
470
|
+
success_evidence: ['sourceCommitSha', 'githubCommitUrl', 'gitPushStatus=passed'],
|
|
471
|
+
decision_basis: {
|
|
472
|
+
failure_class: 'release',
|
|
473
|
+
hotfix_commit_required: true,
|
|
474
|
+
live_hotfix_blocked_until_commit: true,
|
|
475
|
+
same_failure_count: 1
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
const supportHotfixBlockedGate = supportHotfixBlockedUntilCommitRun.gates.find((gate) => gate.key === 'support_next_action_contract');
|
|
482
|
+
assert.equal(supportHotfixBlockedGate?.status, 'blocked');
|
|
483
|
+
assert.match(String(supportHotfixBlockedGate?.reason || ''), /GitHub commit proof/i);
|
|
484
|
+
assert.equal(supportHotfixBlockedGate?.metadata?.codexFallbackRequired, true);
|
|
485
|
+
assert.equal(supportHotfixBlockedUntilCommitRun.metadata?.nextActionContract?.liveHotfixBlockedUntilCommit, true);
|
|
486
|
+
|
|
487
|
+
const supportMissingNextActionContractRun = buildSupportAIRunFromEvidence({
|
|
488
|
+
ticket: { _id: 'ticket-missing-next-action', ticketNumber: '004778', title: 'Support V5 missing next action' },
|
|
489
|
+
job: {
|
|
490
|
+
_id: 'support-missing-next-action',
|
|
491
|
+
status: 'Running',
|
|
492
|
+
phase: 'Manager',
|
|
493
|
+
supportWorkflowMode: 'support_v5',
|
|
494
|
+
supportV5SupervisorState: {
|
|
495
|
+
status: 'active',
|
|
496
|
+
activeStep: 'manager_recovery',
|
|
497
|
+
activeBlocker: 'Runner needs a structured next action.'
|
|
498
|
+
},
|
|
499
|
+
supportV5StepHistory: [{
|
|
500
|
+
lane: 'qa',
|
|
501
|
+
stepType: 'business_proof',
|
|
502
|
+
outcome: 'needs_repair',
|
|
503
|
+
failureClass: 'business',
|
|
504
|
+
blocker: 'Business proof missing after route-only QA.',
|
|
505
|
+
evidenceHash: 'route-only-no-next-action'
|
|
506
|
+
}]
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
const supportMissingNextActionGate = supportMissingNextActionContractRun.gates.find((gate) => gate.key === 'support_next_action_contract');
|
|
510
|
+
assert.equal(supportMissingNextActionGate?.status, 'blocked');
|
|
511
|
+
assert.equal(supportMissingNextActionGate?.metadata?.missingContract, true);
|
|
512
|
+
assert.equal(supportMissingNextActionGate?.metadata?.canRunWithoutCodexMonitor, false);
|
|
513
|
+
assert.equal(supportMissingNextActionGate?.metadata?.codexFallbackRequired, true);
|
|
514
|
+
assert.equal(supportMissingNextActionContractRun.outcome, 'manual_handoff');
|
|
515
|
+
assert.match(String(supportMissingNextActionContractRun.nextAction || ''), /validated next-action contract/i);
|
|
516
|
+
assert.equal(supportMissingNextActionContractRun.metadata?.nextActionContract?.status, 'blocked');
|
|
517
|
+
assert.equal(supportMissingNextActionContractRun.events.some((event) => event.category === 'support_next_action_contract'), true);
|
|
518
|
+
|
|
519
|
+
const supportRepairBeforeDiagnosisRun = buildSupportAIRunFromEvidence({
|
|
520
|
+
ticket: { _id: 'ticket-repair-before-diagnosis', ticketNumber: '004502', title: 'Repair started before diagnosis' },
|
|
521
|
+
job: {
|
|
522
|
+
_id: 'support-job-repair-before-diagnosis',
|
|
523
|
+
status: 'Running',
|
|
524
|
+
phase: 'Build',
|
|
525
|
+
supportV5StepHistory: [{
|
|
526
|
+
lane: 'build',
|
|
527
|
+
stepType: 'build_repair',
|
|
528
|
+
outcome: 'needs_repair',
|
|
529
|
+
failureClass: 'product_code',
|
|
530
|
+
blocker: 'Save action still fails.',
|
|
531
|
+
changedFiles: ['server/src/methods/support-ticket-save.ts'],
|
|
532
|
+
evidenceHash: 'repair-without-diagnosis'
|
|
533
|
+
}]
|
|
534
|
+
},
|
|
535
|
+
qaEvidence: {
|
|
536
|
+
compile: { status: 'pass' },
|
|
537
|
+
routeProbes: [{ route: '/support/004502', status: 'pass' }]
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
const supportRepairBeforeDiagnosisGate = supportRepairBeforeDiagnosisRun.gates.find((gate) => gate.key === 'support_diagnosis_before_repair');
|
|
541
|
+
assert.equal(supportRepairBeforeDiagnosisGate?.status, 'blocked');
|
|
542
|
+
assert.equal(supportRepairBeforeDiagnosisGate?.metadata?.diagnosisValid, false);
|
|
543
|
+
assert.equal(supportRepairBeforeDiagnosisGate?.metadata?.allowedDispatchAction, 'run_read_only_diagnosis');
|
|
544
|
+
assert.equal(supportRepairBeforeDiagnosisGate?.metadata?.productRepairAllowed, false);
|
|
545
|
+
assert.equal(supportRepairBeforeDiagnosisRun.outcome, 'manual_handoff');
|
|
546
|
+
assert.match(String(supportRepairBeforeDiagnosisGate?.reason || ''), /Support product repair is blocked/i);
|
|
547
|
+
assert.match(String(supportRepairBeforeDiagnosisRun.nextAction || ''), /read-only support diagnosis/i);
|
|
548
|
+
assert.equal(supportRepairBeforeDiagnosisRun.metadata?.diagnosisBeforeRepair?.allowedDispatchAction, 'run_read_only_diagnosis');
|
|
549
|
+
assert.deepEqual(supportRepairBeforeDiagnosisRun.metadata?.diagnosisBeforeRepair?.changedFiles, ['server/src/methods/support-ticket-save.ts']);
|
|
550
|
+
assert.equal(supportRepairBeforeDiagnosisRun.events.some((event) => event.category === 'support_diagnosis_before_repair'), true);
|
|
551
|
+
|
|
552
|
+
const supportUnpushedHotfixRun = buildSupportAIRunFromEvidence({
|
|
553
|
+
ticket: { _id: 'ticket-004421-hotfix', ticketNumber: '004421', title: 'Unpushed backend hotfix guard' },
|
|
554
|
+
job: {
|
|
555
|
+
_id: 'support-job-unpushed-hotfix',
|
|
556
|
+
status: 'Running',
|
|
557
|
+
phase: 'Release',
|
|
558
|
+
supportV5DiagnosisGate: supportRun.metadata?.diagnosis
|
|
559
|
+
},
|
|
560
|
+
qaEvidence: {
|
|
561
|
+
infraChecks: [{ name: 'puppeteer_require', status: 'pass' }],
|
|
562
|
+
compile: { status: 'pass' },
|
|
563
|
+
routeProbes: [{ route: '/support/004421', status: 'pass' }],
|
|
564
|
+
hotfixEvidence: {
|
|
565
|
+
channel: 'backend_js',
|
|
566
|
+
target: {
|
|
567
|
+
host: 'backend.resolveio.com',
|
|
568
|
+
path: '/var/app/current/http/runner-manager-selftest.js'
|
|
569
|
+
},
|
|
570
|
+
compiledArtifactPath: 'dist/http/runner-manager-selftest.js',
|
|
571
|
+
remoteChecksumBefore: '1111111111111111111111111111111111111111111111111111111111111111',
|
|
572
|
+
remoteChecksumAfter: '2222222222222222222222222222222222222222222222222222222222222222',
|
|
573
|
+
sourceCommitSha: '6fd400e1d8c961c1e88820292c323e688fdcc0a4',
|
|
574
|
+
githubCommitUrl: 'https://github.com/resolveio/resolveio-all/commit/6fd400e1d8c961c1e88820292c323e688fdcc0a4',
|
|
575
|
+
restartEvidence: 'nodejs restarted on all support hosts',
|
|
576
|
+
healthCheckStatus: 'passed',
|
|
577
|
+
selfTestStatus: 'passed'
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
const supportUnpushedHotfixGate = supportUnpushedHotfixRun.gates.find((gate) => gate.key === 'hotfix_evidence');
|
|
582
|
+
assert.equal(supportUnpushedHotfixGate?.status, 'fail');
|
|
583
|
+
assert.match(String(supportUnpushedHotfixGate?.reason || ''), /gitPushStatus|GitHub/i);
|
|
584
|
+
const supportUnpushedHotfixCommitGate = supportUnpushedHotfixRun.gates.find((gate) => gate.key === 'hotfix_commit_proof');
|
|
585
|
+
assert.equal(supportUnpushedHotfixCommitGate?.status, 'blocked');
|
|
586
|
+
assert.equal(supportUnpushedHotfixCommitGate?.metadata?.managerMustCommitBeforeHotfix, true);
|
|
587
|
+
assert.equal(supportUnpushedHotfixRun.outcome, 'release_blocked');
|
|
588
|
+
assert.equal(supportUnpushedHotfixRun.events.some((event) => event.type === 'hotfix' && event.metadata?.hotfixSatisfied === false), true);
|
|
589
|
+
assert.equal(supportUnpushedHotfixRun.events.some((event) => event.category === 'hotfix_commit_proof' && event.metadata?.managerMustCommitBeforeHotfix === true), true);
|
|
590
|
+
|
|
591
|
+
const supportRepeatedFailureRun = buildSupportAIRunFromEvidence({
|
|
592
|
+
ticket: { _id: 'ticket-repeated-failure', ticketNumber: '004500', title: 'Repeated support failure' },
|
|
593
|
+
job: {
|
|
594
|
+
_id: 'support-job-repeated-failure',
|
|
595
|
+
status: 'Running',
|
|
596
|
+
phase: 'Build',
|
|
597
|
+
supportV5Budget: { maxRepeatedNoProgress: 2 },
|
|
598
|
+
supportV5StepHistory: [
|
|
599
|
+
{
|
|
600
|
+
lane: 'repair',
|
|
601
|
+
stepType: 'workflow_build',
|
|
602
|
+
outcome: 'needs_repair',
|
|
603
|
+
failureClass: 'product_code',
|
|
604
|
+
blocker: 'Save action still throws TypeError.',
|
|
605
|
+
evidenceHash: 'save-typeerror-before',
|
|
606
|
+
artifactPaths: ['qa/save-before.log']
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
lane: 'repair',
|
|
610
|
+
stepType: 'workflow_build',
|
|
611
|
+
outcome: 'needs_repair',
|
|
612
|
+
failureClass: 'product_code',
|
|
613
|
+
blocker: 'Save action still throws TypeError.',
|
|
614
|
+
evidenceHash: 'save-typeerror-before',
|
|
615
|
+
artifactPaths: ['qa/save-before.log']
|
|
616
|
+
}
|
|
617
|
+
]
|
|
618
|
+
},
|
|
619
|
+
qaEvidence: {
|
|
620
|
+
compile: { status: 'pass' },
|
|
621
|
+
routeProbes: [{ route: '/support/004500', status: 'pass' }]
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
const repeatedFailureGate = supportRepeatedFailureRun.gates.find((gate) => gate.key === 'manager_no_blind_loop_policy');
|
|
625
|
+
assert.equal(repeatedFailureGate?.status, 'blocked');
|
|
626
|
+
assert.equal(repeatedFailureGate?.metadata?.action, 'park_repeated_failure');
|
|
627
|
+
assert.equal(repeatedFailureGate?.metadata?.requiresNewEvidence, true);
|
|
628
|
+
assert.equal(repeatedFailureGate?.metadata?.productRepairAllowed, false);
|
|
629
|
+
assert.equal(supportRepeatedFailureRun.outcome, 'manual_handoff');
|
|
630
|
+
assert.equal(supportRepeatedFailureRun.events.some((event) => event.category === 'manager_no_blind_loop_policy'), true);
|
|
631
|
+
assert.equal(supportRepeatedFailureRun.metadata?.managerNoBlindLoopPolicy?.requiresNewEvidence, true);
|
|
632
|
+
|
|
633
|
+
const supportInfraRetryRun = buildSupportAIRunFromEvidence({
|
|
634
|
+
ticket: { _id: 'ticket-infra-retry', ticketNumber: '004501', title: 'Support infra retry' },
|
|
635
|
+
job: {
|
|
636
|
+
_id: 'support-job-infra-retry',
|
|
637
|
+
status: 'Running',
|
|
638
|
+
phase: 'QA',
|
|
639
|
+
supportV5StepHistory: [{
|
|
640
|
+
lane: 'qa',
|
|
641
|
+
stepType: 'workflow_qa',
|
|
642
|
+
outcome: 'needs_repair',
|
|
643
|
+
failureClass: 'infra',
|
|
644
|
+
blocker: 'Chrome executable missing.',
|
|
645
|
+
evidenceHash: 'chrome-missing',
|
|
646
|
+
artifactPaths: ['qa/chrome-preflight.log']
|
|
647
|
+
}]
|
|
648
|
+
},
|
|
649
|
+
qaEvidence: {
|
|
650
|
+
infraChecks: [{ name: 'chrome_executable', status: 'blocked', message: 'Chrome executable missing.', path: 'qa/chrome-preflight.log' }]
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
const infraRetryGate = supportInfraRetryRun.gates.find((gate) => gate.key === 'manager_no_blind_loop_policy');
|
|
654
|
+
assert.equal(infraRetryGate?.status, 'warn');
|
|
655
|
+
assert.equal(infraRetryGate?.metadata?.action, 'retry_infra');
|
|
656
|
+
assert.equal(infraRetryGate?.metadata?.productRepairFailure, false);
|
|
657
|
+
assert.equal(infraRetryGate?.metadata?.dispatchAction, 'run_infra_repair');
|
|
658
|
+
assert.equal(supportInfraRetryRun.outcome, 'qa_infra_failed');
|
|
659
|
+
|
|
660
|
+
const supportGenericBusinessProofRun = buildSupportAIRunFromEvidence({
|
|
661
|
+
ticket: { _id: 'ticket-004421', ticketNumber: '004421', title: 'Generic support proof' },
|
|
662
|
+
job: {
|
|
663
|
+
_id: 'support-job-generic-proof',
|
|
664
|
+
status: 'Closed',
|
|
665
|
+
phase: 'COMPLETE',
|
|
666
|
+
supportV5DiagnosisGate: supportRun.metadata?.diagnosis
|
|
667
|
+
},
|
|
668
|
+
qaEvidence: {
|
|
669
|
+
infraChecks: [{ name: 'puppeteer_require', status: 'pass' }],
|
|
670
|
+
compile: { status: 'pass' },
|
|
671
|
+
routeProbes: [{ route: '/support', status: 'pass' }],
|
|
672
|
+
scorecardPassed: true,
|
|
673
|
+
businessAssertions: [{
|
|
674
|
+
assertion: 'The route loads and the ticket page has visible controls.',
|
|
675
|
+
status: 'pass',
|
|
676
|
+
route: '/support',
|
|
677
|
+
action: 'Open the ticket page.',
|
|
678
|
+
expected: 'Visible controls render.',
|
|
679
|
+
observed: 'Visible controls rendered.',
|
|
680
|
+
dataProof: 'Screenshot showed page content.'
|
|
681
|
+
}]
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
assert.equal(supportGenericBusinessProofRun.outcome, 'false_pass');
|
|
685
|
+
assert.equal(supportGenericBusinessProofRun.gates.some((gate) => gate.key === 'support_diagnosis_business_proof' && gate.status === 'blocked'), true);
|
|
686
|
+
|
|
687
|
+
const supportBusinessProofRun = buildSupportAIRunFromEvidence({
|
|
688
|
+
ticket: { _id: 'ticket-004430', ticketNumber: '004430', title: 'Filtered support ticket list' },
|
|
689
|
+
job: {
|
|
690
|
+
_id: 'support-job-2',
|
|
691
|
+
status: 'Closed',
|
|
692
|
+
phase: 'COMPLETE',
|
|
693
|
+
supportV5DiagnosisGate: supportRun.metadata?.diagnosis
|
|
694
|
+
},
|
|
695
|
+
qaEvidence: {
|
|
696
|
+
infraChecks: [{ name: 'puppeteer_require', status: 'pass' }],
|
|
697
|
+
compile: { status: 'pass' },
|
|
698
|
+
routeProbes: [{ route: '/support', status: 'pass' }],
|
|
699
|
+
businessAssertions: [{
|
|
700
|
+
assertion: 'Wrong-customer ticket is absent after applying the customer filter.',
|
|
701
|
+
status: 'pass',
|
|
702
|
+
route: '/support',
|
|
703
|
+
action: 'Apply customer filter and reload.',
|
|
704
|
+
expected: 'Only Customer B tickets are visible.',
|
|
705
|
+
observed: 'Customer A ticket was not rendered.',
|
|
706
|
+
dataProof: 'DOM and query proof matched the diagnosis proof plan.'
|
|
707
|
+
}]
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
assert.equal(supportBusinessProofRun.outcome, 'accepted');
|
|
711
|
+
|
|
712
|
+
const supportJobStoredBusinessProofRun = buildSupportAIRunFromEvidence({
|
|
713
|
+
ticket: { _id: 'ticket-004431', ticketNumber: '004431', title: 'Stored support business proof' },
|
|
714
|
+
job: {
|
|
715
|
+
_id: 'support-job-stored-proof',
|
|
716
|
+
status: 'Closed',
|
|
717
|
+
phase: 'COMPLETE',
|
|
718
|
+
supportV5DiagnosisGate: supportRun.metadata?.diagnosis,
|
|
719
|
+
supportQaValidationCursor: {
|
|
720
|
+
route_probe: { route: '/support', status: 'pass', screenshot: 'qa-artifacts/stored-route.png' },
|
|
721
|
+
business_assertions: [{
|
|
722
|
+
assertion: 'Wrong-customer ticket is absent after applying the customer filter.',
|
|
723
|
+
status: 'pass',
|
|
724
|
+
route: '/support',
|
|
725
|
+
action: 'Apply customer filter and reload.',
|
|
726
|
+
expected: 'Only Customer B tickets are visible.',
|
|
727
|
+
observed: 'Customer A ticket was not rendered.',
|
|
728
|
+
dataProof: 'DOM and query proof matched the diagnosis proof plan.',
|
|
729
|
+
artifactPaths: ['qa-artifacts/stored-business-proof.json'],
|
|
730
|
+
metadata: { supportDiagnosisProof: true }
|
|
731
|
+
}]
|
|
732
|
+
},
|
|
733
|
+
supportV5AutonomousDecision: {
|
|
734
|
+
business_proof_readiness: {
|
|
735
|
+
ready: true,
|
|
736
|
+
status: 'passed',
|
|
737
|
+
reason: 'Stored support business proof matched the diagnosis.',
|
|
738
|
+
artifact_paths: ['qa-artifacts/stored-business-proof.json']
|
|
739
|
+
},
|
|
740
|
+
customer_reply_policy: {
|
|
741
|
+
action: 'draft_resolution_reply',
|
|
742
|
+
canDraftCustomerReply: true,
|
|
743
|
+
canSendCustomerReply: false,
|
|
744
|
+
confidenceLevel: 'high',
|
|
745
|
+
safety: 'safe_to_draft',
|
|
746
|
+
reason: 'support_reply_resolution_draft_allowed_after_business_proof',
|
|
747
|
+
humanReviewPacket: {
|
|
748
|
+
reviewType: 'customer_resolution_reply',
|
|
749
|
+
primaryAction: 'review_customer_reply',
|
|
750
|
+
customerFacingDraftAllowed: true,
|
|
751
|
+
customerSendAllowed: false,
|
|
752
|
+
requiresHumanApproval: true,
|
|
753
|
+
evidenceRefs: ['qa-artifacts/stored-business-proof.json']
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
assert.equal(supportJobStoredBusinessProofRun.outcome, 'accepted');
|
|
760
|
+
assert.equal(supportJobStoredBusinessProofRun.qa?.businessAssertions.length, 1);
|
|
761
|
+
assert.equal(supportJobStoredBusinessProofRun.gates.some((gate) => gate.key === 'support_business_proof_readiness' && gate.status === 'pass'), true);
|
|
762
|
+
assert.equal(supportJobStoredBusinessProofRun.metadata?.businessProofReadiness?.ready, true);
|
|
763
|
+
assert.equal(supportJobStoredBusinessProofRun.gates.some((gate) => gate.key === 'support_customer_reply_policy' && gate.status === 'warn'), true);
|
|
764
|
+
assert.equal(supportJobStoredBusinessProofRun.metadata?.customerReplyPolicy?.reviewType, 'customer_resolution_reply');
|
|
765
|
+
assert.equal(supportJobStoredBusinessProofRun.metadata?.customerReplyPolicy?.canSendCustomerReply, false);
|
|
766
|
+
|
|
767
|
+
const supportRouteOnlyReadinessRun = buildSupportAIRunFromEvidence({
|
|
768
|
+
ticket: { _id: 'ticket-004432', ticketNumber: '004432', title: 'Stored route-only support proof' },
|
|
769
|
+
job: {
|
|
770
|
+
_id: 'support-job-route-only-readiness',
|
|
771
|
+
status: 'Closed',
|
|
772
|
+
phase: 'COMPLETE',
|
|
773
|
+
supportV5DiagnosisGate: supportRun.metadata?.diagnosis,
|
|
774
|
+
supportQaValidationCursor: {
|
|
775
|
+
workflow_probe: {
|
|
776
|
+
route: '/support',
|
|
777
|
+
status: 'pass',
|
|
778
|
+
screenshot: 'qa-artifacts/route-only.png',
|
|
779
|
+
message: 'Route loaded but no business assertion ran.'
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
supportV5AutonomousDecision: {
|
|
783
|
+
business_proof_readiness: {
|
|
784
|
+
ready: false,
|
|
785
|
+
status: 'route_only',
|
|
786
|
+
reason: 'Route probe is not business proof.',
|
|
787
|
+
blockers: ['Run the issue-class business assertion.'],
|
|
788
|
+
artifact_paths: ['qa-artifacts/route-only.png']
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
assert.notEqual(supportRouteOnlyReadinessRun.outcome, 'accepted');
|
|
794
|
+
assert.equal(supportRouteOnlyReadinessRun.gates.some((gate) => gate.key === 'support_business_proof_readiness' && gate.status === 'blocked'), true);
|
|
795
|
+
assert.equal(supportRouteOnlyReadinessRun.metadata?.businessProofReadiness?.status, 'route_only');
|
|
796
|
+
|
|
797
|
+
const aicoderJourneyContract = {
|
|
798
|
+
app_archetype: 'optimizer',
|
|
799
|
+
primary_actor: 'Operations planner',
|
|
800
|
+
primary_goal: 'Create a saved hose pressure recommendation for a field route.',
|
|
801
|
+
primary_workflow_id: 'layflat-optimizer',
|
|
802
|
+
first_screen: {
|
|
803
|
+
route: '/dashboard/hub',
|
|
804
|
+
purpose: 'Command center showing active scenarios and next optimizer action.',
|
|
805
|
+
visible_cta: 'Start optimizer scenario',
|
|
806
|
+
next_step: 'Open assumptions for the seeded route.'
|
|
807
|
+
},
|
|
808
|
+
north_star_workflow: [{
|
|
809
|
+
position: 'first',
|
|
810
|
+
id: 'start-scenario',
|
|
811
|
+
route: '/dashboard/hub',
|
|
812
|
+
visible_cta: 'Start optimizer scenario',
|
|
813
|
+
data_input_or_selection: 'Select North Field route.',
|
|
814
|
+
method_or_calculation: 'local calculation path optimizerScenarioDraft',
|
|
815
|
+
expected_state_transition: 'Scenario assumptions panel opens.',
|
|
816
|
+
success_confirmation: 'Scenario ready badge appears.',
|
|
817
|
+
next_step_destination: '/dashboard/hub?scenario=active'
|
|
818
|
+
}, {
|
|
819
|
+
position: 'next',
|
|
820
|
+
id: 'run-optimizer',
|
|
821
|
+
route: '/dashboard/hub',
|
|
822
|
+
visible_cta: 'Run optimization',
|
|
823
|
+
data_input_or_selection: 'Confirm pressure limit, terrain, pump, and hose specs.',
|
|
824
|
+
method_or_calculation: 'local calculation path runLayflatPressureOptimizer and server method saveOptimizerResult',
|
|
825
|
+
expected_state_transition: 'Alternatives table and recommendation card update.',
|
|
826
|
+
success_confirmation: 'Recommendation calculated badge appears.',
|
|
827
|
+
next_step_destination: '/dashboard/hub?result=compare'
|
|
828
|
+
}, {
|
|
829
|
+
position: 'last',
|
|
830
|
+
id: 'save-report',
|
|
831
|
+
route: '/reports/optimizer',
|
|
832
|
+
visible_cta: 'Save recommendation report',
|
|
833
|
+
data_input_or_selection: 'Choose the recommended hose plan.',
|
|
834
|
+
method_or_calculation: 'server method publishOptimizerRecommendation',
|
|
835
|
+
expected_state_transition: 'Saved report row appears.',
|
|
836
|
+
success_confirmation: 'Recommendation saved message appears.',
|
|
837
|
+
final_result: 'Saved optimizer recommendation with exportable pressure report.'
|
|
838
|
+
}],
|
|
839
|
+
secondary_workflows: [
|
|
840
|
+
{ id: 'setup', route: '/manage/settings', purpose: 'Maintain pump defaults.' },
|
|
841
|
+
{ id: 'report-export', route: '/reports/optimizer', purpose: 'Review saved recommendations.' },
|
|
842
|
+
{ id: 'recovery', route: '/dashboard/hub', purpose: 'Handle invalid pressure states.' }
|
|
843
|
+
],
|
|
844
|
+
screen_sequence: [{
|
|
845
|
+
route: '/dashboard/hub',
|
|
846
|
+
screen_purpose: 'Command center with seeded scenario and embedded optimizer action.',
|
|
847
|
+
visible_cta: 'Start optimizer scenario',
|
|
848
|
+
action: 'Open scenario assumptions',
|
|
849
|
+
method_or_calculation: 'local calculation path optimizerScenarioDraft',
|
|
850
|
+
expected_next_state: 'Scenario assumptions are visible.',
|
|
851
|
+
data_shown: 'Seeded route, elevation, pump, hose, and pressure-limit records.'
|
|
852
|
+
}, {
|
|
853
|
+
route: '/dashboard/hub',
|
|
854
|
+
screen_purpose: 'Run optimizer and compare alternatives.',
|
|
855
|
+
visible_cta: 'Run optimization',
|
|
856
|
+
action: 'Calculate pressure recommendation',
|
|
857
|
+
method_or_calculation: 'local calculation path runLayflatPressureOptimizer',
|
|
858
|
+
expected_next_state: 'Recommendation and alternatives update.',
|
|
859
|
+
data_shown: 'Comparison table and recommendation card.'
|
|
860
|
+
}, {
|
|
861
|
+
route: '/reports/optimizer',
|
|
862
|
+
screen_purpose: 'Save and export recommendation report.',
|
|
863
|
+
visible_cta: 'Save recommendation report',
|
|
864
|
+
action: 'Persist recommendation report',
|
|
865
|
+
method_or_calculation: 'server method publishOptimizerRecommendation',
|
|
866
|
+
expected_next_state: 'Saved report row and export button visible.',
|
|
867
|
+
data_shown: 'Saved recommendation and calculated pressure.'
|
|
868
|
+
}],
|
|
869
|
+
data_story: {
|
|
870
|
+
seeded_scenario: 'North Field irrigation route with elevation changes, pumps, and hose alternatives.',
|
|
871
|
+
records: ['North Field route', 'Pump A', 'Pump B', '4-inch layflat hose', '6-inch layflat hose'],
|
|
872
|
+
relationships: ['Route uses pump options', 'Pump options feed hose alternatives', 'Optimization result belongs to scenario'],
|
|
873
|
+
non_empty_states: ['Dashboard KPIs show pressure and flow.', 'Reports table shows saved recommendation row.']
|
|
874
|
+
},
|
|
875
|
+
completion_states: [
|
|
876
|
+
'Recommendation card shows selected hose and pressure margin.',
|
|
877
|
+
'Report route lists saved recommendation with export action.'
|
|
878
|
+
],
|
|
879
|
+
qa_assertions: [{
|
|
880
|
+
id: 'login-hub',
|
|
881
|
+
route: '/dashboard/hub',
|
|
882
|
+
action: 'Login and land on dashboard hub.',
|
|
883
|
+
expected_dom_or_data_proof: 'Hub shows seeded North Field scenario and non-empty KPIs.'
|
|
884
|
+
}, {
|
|
885
|
+
id: 'primary-hub-action',
|
|
886
|
+
route: '/dashboard/hub',
|
|
887
|
+
action: 'Click Start optimizer scenario.',
|
|
888
|
+
expected_dom_or_data_proof: 'Scenario assumptions panel opens with seeded route and pump records.'
|
|
889
|
+
}, {
|
|
890
|
+
id: 'workflow-completion',
|
|
891
|
+
route: '/dashboard/hub',
|
|
892
|
+
action: 'Run optimization and save recommendation.',
|
|
893
|
+
expected_dom_or_data_proof: 'Saved recommendation report row appears with calculated pressure result.'
|
|
894
|
+
}, {
|
|
895
|
+
id: 'mobile-viewport',
|
|
896
|
+
route: '/dashboard/hub',
|
|
897
|
+
action: 'Repeat primary optimizer path at mobile viewport 390x844.',
|
|
898
|
+
expected_dom_or_data_proof: 'Mobile hub shows non-empty scenario and recommendation controls.',
|
|
899
|
+
viewport: '390x844 mobile'
|
|
900
|
+
}, {
|
|
901
|
+
id: 'empty-error-recovery',
|
|
902
|
+
route: '/dashboard/hub',
|
|
903
|
+
action: 'Clear scenario input and submit invalid pressure limit.',
|
|
904
|
+
expected_dom_or_data_proof: 'Empty/error recovery message appears and Start optimizer scenario remains available.'
|
|
905
|
+
}]
|
|
906
|
+
};
|
|
907
|
+
const aicoderWorkflowQaRows = aicoderJourneyContract.qa_assertions.map((row, index) => ({
|
|
908
|
+
index: index + 1,
|
|
909
|
+
workflowId: 'layflat-optimizer',
|
|
910
|
+
stepId: row.id,
|
|
911
|
+
route: row.route,
|
|
912
|
+
action: row.action,
|
|
913
|
+
assertion: row.expected_dom_or_data_proof,
|
|
914
|
+
expectedState: row.expected_dom_or_data_proof,
|
|
915
|
+
status: 'pass',
|
|
916
|
+
artifactPaths: [`qa-artifacts/${row.id}.json`]
|
|
917
|
+
}));
|
|
918
|
+
|
|
919
|
+
const aicoderRun = buildAICoderAIRunFromEvidence({
|
|
920
|
+
app: { _id: 'layflat-app', name: 'Layflat Pressure Optimizer', domain: 'layflat.resolveio.app' },
|
|
921
|
+
job: {
|
|
922
|
+
_id: 'aicoder-job-1',
|
|
923
|
+
phase: 'COMPLETE',
|
|
924
|
+
status: 'Passed',
|
|
925
|
+
managerHotfixEvidence: {
|
|
926
|
+
channel: 'backend_js',
|
|
927
|
+
target: {
|
|
928
|
+
host: 'backend.aicoder.resolveio.com',
|
|
929
|
+
path: '/var/app/current/http/runner-manager-selftest.js'
|
|
930
|
+
},
|
|
931
|
+
compiledArtifactPath: 'dist/http/runner-manager-selftest.js',
|
|
932
|
+
remoteChecksumAfter: '3333333333333333333333333333333333333333333333333333333333333333',
|
|
933
|
+
sourceCommitSha: '6fd400e1d8c961c1e88820292c323e688fdcc0a4',
|
|
934
|
+
githubCommitUrl: 'https://github.com/resolveio/resolveio-all/commit/6fd400e1d8c961c1e88820292c323e688fdcc0a4',
|
|
935
|
+
gitPushStatus: 'passed',
|
|
936
|
+
restartEvidence: 'nodejs restarted on AICoder hosts',
|
|
937
|
+
healthCheckStatus: 'passed',
|
|
938
|
+
selfTestStatus: 'passed'
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
qaEvidence: {
|
|
942
|
+
journeyContract: aicoderJourneyContract,
|
|
943
|
+
workflowQaRows: aicoderWorkflowQaRows,
|
|
944
|
+
scorecardPassed: true,
|
|
945
|
+
deployStatus: 'pass',
|
|
946
|
+
publishStatus: 'published',
|
|
947
|
+
sampleDataStatus: 'empty seed collections',
|
|
948
|
+
compile: { status: 'pass' },
|
|
949
|
+
routeProbes: [{ route: '/optimizer', status: 'pass' }],
|
|
950
|
+
businessAssertions: [{
|
|
951
|
+
stepId: 'workflow-completion',
|
|
952
|
+
workflowId: 'layflat-optimizer',
|
|
953
|
+
route: '/dashboard/hub',
|
|
954
|
+
assertion: 'Saved recommendation report row appears with calculated pressure result.',
|
|
955
|
+
status: 'pass',
|
|
956
|
+
dataProof: 'Seeded hose row produced a pressure result.'
|
|
957
|
+
}]
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
assert.equal(aicoderRun.source, 'aicoder_app');
|
|
961
|
+
assert.equal(aicoderRun.outcome, 'release_blocked');
|
|
962
|
+
assert.equal(aicoderRun.events.some((event) => event.type === 'hotfix' && event.metadata?.hotfixSatisfied === true), true);
|
|
963
|
+
assert.equal(aicoderRun.gates.some((gate) => gate.key === 'hotfix_commit_proof' && gate.status === 'pass'), true);
|
|
964
|
+
assert.equal(aicoderRun.gates.some((gate) => gate.key === 'aicoder_workflow_proof_readiness' && gate.status === 'fail'), true);
|
|
965
|
+
assert.equal(aicoderRun.metadata?.workflowProofReadiness?.status, 'release_blocked');
|
|
966
|
+
|
|
967
|
+
const aicoderRouteOnlyRun = buildAICoderAIRunFromEvidence({
|
|
968
|
+
app: { _id: 'route-only-app', name: 'Route Only App' },
|
|
969
|
+
job: {
|
|
970
|
+
_id: 'aicoder-route-only',
|
|
971
|
+
phase: 'COMPLETE',
|
|
972
|
+
status: 'Passed',
|
|
973
|
+
workflowProofCheckpoint: {
|
|
974
|
+
required: true,
|
|
975
|
+
status: 'waiting_for_workflow_proof',
|
|
976
|
+
readinessStatus: 'workflow_qa_required',
|
|
977
|
+
nextGate: 'workflow_qa',
|
|
978
|
+
workflowProofFingerprint: 'aicoder-workflow-proof-route-only',
|
|
979
|
+
artifactFingerprint: 'aicoder-workflow-artifacts-route-only',
|
|
980
|
+
requiredEvidence: ['AIQaBusinessAssertion tied to journey_contract.qa_assertions'],
|
|
981
|
+
requiredResetEvidence: ['new workflow proof fingerprint', 'fresh workflow QA artifact'],
|
|
982
|
+
successRequiresWorkflowBusinessProof: true,
|
|
983
|
+
blocksProductRepairUntilJourneyContract: false,
|
|
984
|
+
blocksPublishUntilWorkflowProof: true,
|
|
985
|
+
blocksPublishUntilReleaseGate: false,
|
|
986
|
+
blocksWowUiUntilWorkflowProof: true,
|
|
987
|
+
nextAction: 'Run workflow QA from the journey contract before publish or wow UI polish.'
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
qaEvidence: {
|
|
991
|
+
journeyContract: aicoderJourneyContract,
|
|
992
|
+
scorecardPassed: true,
|
|
993
|
+
compile: { status: 'pass' },
|
|
994
|
+
routeProbes: [{ route: '/dashboard/hub', status: 'pass' }],
|
|
995
|
+
deployStatus: 'pass',
|
|
996
|
+
publishStatus: 'published',
|
|
997
|
+
sampleDataStatus: 'pass'
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
assert.equal(aicoderRouteOnlyRun.outcome, 'false_pass');
|
|
1001
|
+
assert.equal(aicoderRouteOnlyRun.gates.some((gate) => gate.key === 'aicoder_workflow_proof_readiness' && gate.status === 'blocked'), true);
|
|
1002
|
+
assert.equal(aicoderRouteOnlyRun.gates.some((gate) => gate.key === 'aicoder_workflow_proof_checkpoint' && gate.status === 'blocked'), true);
|
|
1003
|
+
assert.equal(aicoderRouteOnlyRun.metadata?.workflowProofReadiness?.status, 'route_only');
|
|
1004
|
+
assert.equal(aicoderRouteOnlyRun.metadata?.workflowProofCheckpoint?.blocksPublishUntilWorkflowProof, true);
|
|
1005
|
+
assert.equal(aicoderRouteOnlyRun.metadata?.workflowProofCheckpoint?.blocksWowUiUntilWorkflowProof, true);
|
|
1006
|
+
assert.equal(aicoderRouteOnlyRun.events.some((event) => event.category === 'aicoder_workflow_proof_checkpoint'), true);
|
|
1007
|
+
|
|
1008
|
+
const aicoderMissingJourneyContractRun = buildAICoderAIRunFromEvidence({
|
|
1009
|
+
app: { _id: 'missing-journey-app', name: 'Missing Journey App' },
|
|
1010
|
+
job: {
|
|
1011
|
+
_id: 'aicoder-missing-journey',
|
|
1012
|
+
phase: 'COMPLETE',
|
|
1013
|
+
status: 'Passed'
|
|
1014
|
+
},
|
|
1015
|
+
qaEvidence: {
|
|
1016
|
+
scorecardPassed: true,
|
|
1017
|
+
compile: { status: 'pass' },
|
|
1018
|
+
routeProbes: [{ route: '/dashboard/hub', status: 'pass' }],
|
|
1019
|
+
deployStatus: 'pass',
|
|
1020
|
+
publishStatus: 'published',
|
|
1021
|
+
sampleDataStatus: 'pass'
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
const aicoderMissingJourneyGate = aicoderMissingJourneyContractRun.gates.find((gate) => gate.key === 'aicoder_journey_contract');
|
|
1025
|
+
assert.equal(aicoderMissingJourneyContractRun.outcome, 'false_pass');
|
|
1026
|
+
assert.equal(aicoderMissingJourneyGate?.status, 'blocked');
|
|
1027
|
+
assert.equal(aicoderMissingJourneyGate?.metadata?.valid, false);
|
|
1028
|
+
assert.equal(aicoderMissingJourneyGate?.metadata?.blocksBuildUntilValid, true);
|
|
1029
|
+
assert.ok(Array.isArray(aicoderMissingJourneyGate?.metadata?.issueCodes));
|
|
1030
|
+
assert.ok((aicoderMissingJourneyGate?.metadata?.issueCodes || []).includes('missing_contract'));
|
|
1031
|
+
assert.equal(aicoderMissingJourneyContractRun.metadata?.journeyContract?.valid, false);
|
|
1032
|
+
assert.equal(aicoderMissingJourneyContractRun.metadata?.workflowProofReadiness?.status, 'missing_journey_contract');
|
|
1033
|
+
assert.equal(classifyAIRunFailureClass(aicoderMissingJourneyContractRun), 'journey_contract');
|
|
1034
|
+
const aicoderMissingJourneyRetry = decideAIRunRetry({ currentRun: aicoderMissingJourneyContractRun });
|
|
1035
|
+
assert.equal(aicoderMissingJourneyRetry.action, 'retry_journey_contract');
|
|
1036
|
+
assert.match(String(aicoderMissingJourneyRetry.nextAction || ''), /APP_JOURNEY_CONTRACT/i);
|
|
1037
|
+
assert.equal(aicoderMissingJourneyContractRun.events.some((event) => event.category === 'aicoder_journey_contract'), true);
|
|
1038
|
+
|
|
1039
|
+
const aicoderRepeatedJourneyRun = buildAICoderAIRunFromEvidence({
|
|
1040
|
+
app: { _id: 'repeated-journey-app', name: 'Repeated Journey App' },
|
|
1041
|
+
job: {
|
|
1042
|
+
_id: 'aicoder-repeated-journey',
|
|
1043
|
+
phase: 'Build',
|
|
1044
|
+
status: 'Running',
|
|
1045
|
+
aicoderV6Budget: { maxRepeatedNoProgress: 2 },
|
|
1046
|
+
aicoderV6StepHistory: [{
|
|
1047
|
+
lane: 'aicoder',
|
|
1048
|
+
stepType: 'journey_validation',
|
|
1049
|
+
outcome: 'needs_repair',
|
|
1050
|
+
failureClass: 'workflow',
|
|
1051
|
+
blocker: 'Journey contract still has no last saved/exported result.',
|
|
1052
|
+
evidenceHash: 'journey-missing-final-result',
|
|
1053
|
+
artifactPaths: ['qa/journey-contract-review.json']
|
|
1054
|
+
}, {
|
|
1055
|
+
lane: 'aicoder',
|
|
1056
|
+
stepType: 'journey_validation',
|
|
1057
|
+
outcome: 'needs_repair',
|
|
1058
|
+
failureClass: 'workflow',
|
|
1059
|
+
blocker: 'Journey contract still has no last saved/exported result.',
|
|
1060
|
+
evidenceHash: 'journey-missing-final-result',
|
|
1061
|
+
artifactPaths: ['qa/journey-contract-review.json']
|
|
1062
|
+
}]
|
|
1063
|
+
},
|
|
1064
|
+
qaEvidence: {
|
|
1065
|
+
journeyContract: aicoderJourneyContract,
|
|
1066
|
+
compile: { status: 'pass' },
|
|
1067
|
+
routeProbes: [{ route: '/dashboard/hub', status: 'pass' }]
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
1070
|
+
const aicoderRepeatedJourneyGate = aicoderRepeatedJourneyRun.gates.find((gate) => gate.key === 'manager_no_blind_loop_policy');
|
|
1071
|
+
assert.equal(aicoderRepeatedJourneyGate?.status, 'blocked');
|
|
1072
|
+
assert.equal(aicoderRepeatedJourneyGate?.metadata?.action, 'park_repeated_failure');
|
|
1073
|
+
assert.equal(aicoderRepeatedJourneyGate?.metadata?.requiresNewEvidence, true);
|
|
1074
|
+
assert.equal(aicoderRepeatedJourneyGate?.metadata?.productRepairAllowed, false);
|
|
1075
|
+
assert.equal(aicoderRepeatedJourneyRun.outcome, 'manual_handoff');
|
|
1076
|
+
assert.equal(aicoderRepeatedJourneyRun.events.some((event) => event.category === 'manager_no_blind_loop_policy'), true);
|
|
1077
|
+
assert.equal(aicoderRepeatedJourneyRun.metadata?.managerNoBlindLoopPolicy?.requiresNewEvidence, true);
|
|
1078
|
+
|
|
1079
|
+
const aicoderInfraRetryRun = buildAICoderAIRunFromEvidence({
|
|
1080
|
+
app: { _id: 'aicoder-infra-retry-app', name: 'AICoder Infra Retry App' },
|
|
1081
|
+
job: {
|
|
1082
|
+
_id: 'aicoder-infra-retry',
|
|
1083
|
+
phase: 'QA',
|
|
1084
|
+
status: 'Running',
|
|
1085
|
+
aicoderV6StepHistory: [{
|
|
1086
|
+
lane: 'qa',
|
|
1087
|
+
stepType: 'workflow_qa',
|
|
1088
|
+
outcome: 'needs_repair',
|
|
1089
|
+
failureClass: 'infra',
|
|
1090
|
+
blocker: 'Puppeteer module is missing before workflow QA can run.',
|
|
1091
|
+
evidenceHash: 'puppeteer-module-missing',
|
|
1092
|
+
artifactPaths: ['qa/puppeteer-preflight.log']
|
|
1093
|
+
}]
|
|
1094
|
+
},
|
|
1095
|
+
qaEvidence: {
|
|
1096
|
+
infraChecks: [{
|
|
1097
|
+
name: 'puppeteer_require',
|
|
1098
|
+
status: 'blocked',
|
|
1099
|
+
message: 'Cannot find module puppeteer.',
|
|
1100
|
+
path: 'qa/puppeteer-preflight.log'
|
|
1101
|
+
}]
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
const aicoderInfraRetryGate = aicoderInfraRetryRun.gates.find((gate) => gate.key === 'manager_no_blind_loop_policy');
|
|
1105
|
+
assert.equal(aicoderInfraRetryGate?.status, 'warn');
|
|
1106
|
+
assert.equal(aicoderInfraRetryGate?.metadata?.action, 'retry_infra');
|
|
1107
|
+
assert.equal(aicoderInfraRetryGate?.metadata?.productRepairFailure, false);
|
|
1108
|
+
assert.equal(aicoderInfraRetryGate?.metadata?.dispatchAction, 'run_infra_repair');
|
|
1109
|
+
assert.equal(aicoderInfraRetryRun.outcome, 'qa_infra_failed');
|
|
1110
|
+
|
|
1111
|
+
const aicoderFreshProofRun = buildAICoderAIRunFromEvidence({
|
|
1112
|
+
app: { _id: 'fresh-proof-app', name: 'Fresh Proof App' },
|
|
1113
|
+
job: { _id: 'aicoder-fresh-proof', phase: 'COMPLETE', status: 'Passed' },
|
|
1114
|
+
qaEvidence: {
|
|
1115
|
+
journeyContract: aicoderJourneyContract,
|
|
1116
|
+
workflowQaRows: aicoderWorkflowQaRows,
|
|
1117
|
+
scorecardPassed: true,
|
|
1118
|
+
compile: { status: 'pass' },
|
|
1119
|
+
routeProbes: [{ route: '/dashboard/hub', status: 'pass' }],
|
|
1120
|
+
deployStatus: 'pass',
|
|
1121
|
+
publishStatus: 'published',
|
|
1122
|
+
sampleDataStatus: 'pass',
|
|
1123
|
+
businessAssertions: [{
|
|
1124
|
+
stepId: 'workflow-completion',
|
|
1125
|
+
route: '/dashboard/hub',
|
|
1126
|
+
assertion: 'Saved recommendation report row appears with calculated pressure result.',
|
|
1127
|
+
status: 'pass',
|
|
1128
|
+
dataProof: 'Seeded hose row produced a pressure result.',
|
|
1129
|
+
artifactPaths: ['qa-artifacts/workflow-completion.json']
|
|
1130
|
+
}]
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
const freshProofFingerprint = String(aicoderFreshProofRun.metadata?.workflowProofReadiness?.workflowProofFingerprint || '');
|
|
1134
|
+
assert.match(freshProofFingerprint, /^aicoder-workflow-proof-/);
|
|
1135
|
+
|
|
1136
|
+
const aicoderStaleProofRun = buildAICoderAIRunFromEvidence({
|
|
1137
|
+
app: { _id: 'stale-proof-app', name: 'Stale Proof App' },
|
|
1138
|
+
job: { _id: 'aicoder-stale-proof', phase: 'COMPLETE', status: 'Passed' },
|
|
1139
|
+
qaEvidence: {
|
|
1140
|
+
journeyContract: aicoderJourneyContract,
|
|
1141
|
+
workflowQaRows: aicoderWorkflowQaRows,
|
|
1142
|
+
scorecardPassed: true,
|
|
1143
|
+
compile: { status: 'pass' },
|
|
1144
|
+
routeProbes: [{ route: '/dashboard/hub', status: 'pass' }],
|
|
1145
|
+
deployStatus: 'pass',
|
|
1146
|
+
publishStatus: 'published',
|
|
1147
|
+
sampleDataStatus: 'pass',
|
|
1148
|
+
previousWorkflowProofFingerprint: freshProofFingerprint,
|
|
1149
|
+
businessAssertions: [{
|
|
1150
|
+
stepId: 'workflow-completion',
|
|
1151
|
+
route: '/dashboard/hub',
|
|
1152
|
+
assertion: 'Saved recommendation report row appears with calculated pressure result.',
|
|
1153
|
+
status: 'pass',
|
|
1154
|
+
dataProof: 'Seeded hose row produced a pressure result.',
|
|
1155
|
+
artifactPaths: ['qa-artifacts/workflow-completion.json']
|
|
1156
|
+
}]
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
assert.equal(aicoderStaleProofRun.metadata?.workflowProofReadiness?.status, 'stale_workflow_proof');
|
|
1160
|
+
assert.equal(aicoderStaleProofRun.metadata?.workflowProofReadiness?.proofFreshness, 'same_as_previous');
|
|
1161
|
+
assert.equal(aicoderStaleProofRun.gates.some((gate) => gate.key === 'aicoder_workflow_proof_readiness' && gate.status === 'blocked'), true);
|
|
1162
|
+
|
|
1163
|
+
const assistantRun = buildAssistantAIRunFromEvidence({
|
|
1164
|
+
conversation: { _id: 'conversation-1', title: 'Invoice query', status: 'Closed', accepted: true },
|
|
1165
|
+
messages: [{ role: 'assistant', content: 'Used the current date window.' }],
|
|
1166
|
+
answerQuality: {
|
|
1167
|
+
queryStatus: 'ok',
|
|
1168
|
+
requiresCurrentDate: true,
|
|
1169
|
+
currentDateUsed: '2026-06-16',
|
|
1170
|
+
expectedCurrentDate: '2026-06-16',
|
|
1171
|
+
legalQueryShape: true,
|
|
1172
|
+
queryExecutions: [{
|
|
1173
|
+
id: 'tool-result-invoices-june-2026',
|
|
1174
|
+
tool: 'aiAssistantMongoRead',
|
|
1175
|
+
status: 'ok',
|
|
1176
|
+
collection: 'invoices',
|
|
1177
|
+
resultCount: 3
|
|
1178
|
+
}],
|
|
1179
|
+
citations: [{ id: 'tool-result-invoices-june-2026' }],
|
|
1180
|
+
confidence: { level: 'high' },
|
|
1181
|
+
nextActions: ['Review the returned June 2026 invoice rows.']
|
|
1182
|
+
},
|
|
1183
|
+
correctnessChecks: [{
|
|
1184
|
+
assertion: 'Date window uses the actual current month.',
|
|
1185
|
+
status: 'pass',
|
|
1186
|
+
expected: 'June 2026',
|
|
1187
|
+
observed: 'June 2026'
|
|
1188
|
+
}]
|
|
1189
|
+
});
|
|
1190
|
+
assert.equal(assistantRun.source, 'ai_assistant');
|
|
1191
|
+
assert.equal(assistantRun.outcome, 'accepted');
|
|
1192
|
+
assert.equal(assistantRun.gates.some((gate) => gate.key === 'assistant_answer_quality' && gate.status === 'pass'), true);
|
|
1193
|
+
assert.equal(assistantRun.metadata?.answerQuality?.queryStatus, 'ok');
|
|
1194
|
+
assert.equal(assistantRun.metadata?.answerQuality?.queryEvidencePresent, true);
|
|
1195
|
+
assert.equal(assistantRun.events.some((event) => event.type === 'assistant_query' && event.metadata?.collection === 'invoices'), true);
|
|
1196
|
+
|
|
1197
|
+
const assistantNoDataRun = buildAssistantAIRunFromEvidence({
|
|
1198
|
+
conversation: { _id: 'conversation-no-data', title: 'No invoice query', status: 'Closed', accepted: true },
|
|
1199
|
+
messages: [{ role: 'assistant', content: 'No invoices were found for June 2026.' }],
|
|
1200
|
+
answerQuality: {
|
|
1201
|
+
queryStatus: 'no_data',
|
|
1202
|
+
noDataConfirmed: true,
|
|
1203
|
+
requiresCurrentDate: true,
|
|
1204
|
+
currentDateUsed: '2026-06-16',
|
|
1205
|
+
expectedCurrentDate: '2026-06-16',
|
|
1206
|
+
legalQueryShape: true,
|
|
1207
|
+
queryExecutions: [{
|
|
1208
|
+
id: 'tool-result-empty-invoices-june-2026',
|
|
1209
|
+
tool: 'aiAssistantMongoRead',
|
|
1210
|
+
status: 'no_data',
|
|
1211
|
+
collection: 'invoices',
|
|
1212
|
+
resultCount: 0
|
|
1213
|
+
}],
|
|
1214
|
+
citationRefs: ['tool-result-empty-invoices-june-2026'],
|
|
1215
|
+
confidenceLevel: 'high',
|
|
1216
|
+
nextActions: ['Verify the date range or customer filter if invoices were expected.']
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
assert.equal(assistantNoDataRun.outcome, 'accepted');
|
|
1220
|
+
assert.equal(assistantNoDataRun.metadata?.answerQuality?.queryStatus, 'no_data');
|
|
1221
|
+
assert.equal(assistantNoDataRun.metadata?.answerQuality?.noDataConfirmed, true);
|
|
1222
|
+
assert.equal(assistantNoDataRun.metadata?.answerQuality?.queryEvidencePresent, true);
|
|
1223
|
+
|
|
1224
|
+
const assistantCitationOnlyRun = buildAssistantAIRunFromEvidence({
|
|
1225
|
+
conversation: { _id: 'conversation-citation-only', title: 'Citation-only answer', status: 'Closed', accepted: true },
|
|
1226
|
+
messages: [{ role: 'assistant', content: 'Found invoices for June 2026.' }],
|
|
1227
|
+
answerQuality: {
|
|
1228
|
+
queryStatus: 'ok',
|
|
1229
|
+
requiresCurrentDate: true,
|
|
1230
|
+
currentDateUsed: '2026-06-16',
|
|
1231
|
+
expectedCurrentDate: '2026-06-16',
|
|
1232
|
+
legalQueryShape: true,
|
|
1233
|
+
citationRefs: ['tool-result-invoices-june-2026'],
|
|
1234
|
+
confidenceLevel: 'high',
|
|
1235
|
+
nextActions: ['Open the invoice list.']
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
assert.notEqual(assistantCitationOnlyRun.outcome, 'accepted');
|
|
1239
|
+
assert.equal(assistantCitationOnlyRun.metadata?.answerQuality?.status, 'missing_query_proof');
|
|
1240
|
+
assert.equal(assistantCitationOnlyRun.metadata?.answerQuality?.queryEvidenceRequired, true);
|
|
1241
|
+
assert.equal(assistantCitationOnlyRun.metadata?.answerQuality?.queryEvidencePresent, false);
|
|
1242
|
+
assert.equal(classifyAIRunFailureClass(assistantCitationOnlyRun), 'assistant_missing_evidence');
|
|
1243
|
+
assert.equal(decideAIRunRetry({ currentRun: assistantCitationOnlyRun }).action, 'retry_assistant_answer_quality');
|
|
1244
|
+
|
|
1245
|
+
const assistantWrongDateRun = buildAssistantAIRunFromEvidence({
|
|
1246
|
+
conversation: { _id: 'conversation-wrong-date', title: 'Wrong month query', status: 'Closed', accepted: true },
|
|
1247
|
+
messages: [{ role: 'assistant', content: 'Used May 2026.' }],
|
|
1248
|
+
answerQuality: {
|
|
1249
|
+
queryStatus: 'ok',
|
|
1250
|
+
requiresCurrentDate: true,
|
|
1251
|
+
currentDateUsed: '2026-05-01',
|
|
1252
|
+
expectedCurrentDate: '2026-06-16',
|
|
1253
|
+
legalQueryShape: true,
|
|
1254
|
+
citationRefs: ['tool-result-wrong-month'],
|
|
1255
|
+
confidenceLevel: 'high',
|
|
1256
|
+
nextActions: ['Rerun using the actual current date.']
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
assert.notEqual(assistantWrongDateRun.outcome, 'accepted');
|
|
1260
|
+
assert.equal(assistantWrongDateRun.gates.some((gate) => gate.key === 'assistant_answer_quality' && gate.status === 'fail'), true);
|
|
1261
|
+
assert.equal(assistantWrongDateRun.metadata?.answerQuality?.status, 'date_incorrect');
|
|
1262
|
+
assert.equal(classifyAIRunFailureClass(assistantWrongDateRun), 'assistant_date_window');
|
|
1263
|
+
assert.equal(decideAIRunRetry({ currentRun: assistantWrongDateRun }).action, 'retry_assistant_date_window');
|
|
1264
|
+
|
|
1265
|
+
const assistantMissingDateWindowRun = buildAssistantAIRunFromEvidence({
|
|
1266
|
+
conversation: { _id: 'conversation-missing-window', title: 'Missing date window', status: 'Closed', accepted: true },
|
|
1267
|
+
messages: [{ role: 'assistant', content: 'Used the current date but did not record the query window.' }],
|
|
1268
|
+
answerQuality: {
|
|
1269
|
+
queryStatus: 'ok',
|
|
1270
|
+
requiresCurrentDate: true,
|
|
1271
|
+
currentDateUsed: '2026-06-16',
|
|
1272
|
+
expectedCurrentDate: '2026-06-16',
|
|
1273
|
+
requiresDateWindow: true,
|
|
1274
|
+
citationRefs: ['tool-result-no-window'],
|
|
1275
|
+
confidenceLevel: 'high',
|
|
1276
|
+
nextActions: ['Rerun with concrete date-window evidence.']
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
assert.notEqual(assistantMissingDateWindowRun.outcome, 'accepted');
|
|
1280
|
+
assert.equal(assistantMissingDateWindowRun.gates.some((gate) => gate.key === 'assistant_answer_quality' && gate.status === 'fail'), true);
|
|
1281
|
+
assert.equal(assistantMissingDateWindowRun.metadata?.answerQuality?.status, 'missing_date_window');
|
|
1282
|
+
assert.equal(assistantMissingDateWindowRun.metadata?.answerQuality?.dateWindowRequired, true);
|
|
1283
|
+
assert.equal(assistantMissingDateWindowRun.metadata?.answerQuality?.dateWindowPresent, false);
|
|
1284
|
+
assert.equal(classifyAIRunFailureClass(assistantMissingDateWindowRun), 'assistant_date_window');
|
|
1285
|
+
assert.equal(decideAIRunRetry({ currentRun: assistantMissingDateWindowRun }).action, 'retry_assistant_date_window');
|
|
1286
|
+
|
|
1287
|
+
const assistantIllegalProjectionRun = buildAssistantAIRunFromEvidence({
|
|
1288
|
+
conversation: { _id: 'conversation-illegal-query', title: 'Illegal Mongo projection', status: 'Closed', accepted: true },
|
|
1289
|
+
messages: [{ role: 'assistant', content: 'Mongo query failed.' }],
|
|
1290
|
+
answerQuality: {
|
|
1291
|
+
queryStatus: 'ok',
|
|
1292
|
+
requiresCurrentDate: false,
|
|
1293
|
+
mongoQuery: {
|
|
1294
|
+
collection: 'invoices',
|
|
1295
|
+
filter: { customerId: 'customer-1' },
|
|
1296
|
+
projection: { 'lineItems.$.amount': 1 }
|
|
1297
|
+
},
|
|
1298
|
+
citationRefs: ['tool-result-illegal-projection'],
|
|
1299
|
+
confidenceLevel: 'high',
|
|
1300
|
+
nextActions: ['Rewrite the projection using a legal aggregation or full field projection.']
|
|
1301
|
+
}
|
|
1302
|
+
});
|
|
1303
|
+
assert.notEqual(assistantIllegalProjectionRun.outcome, 'accepted');
|
|
1304
|
+
assert.equal(assistantIllegalProjectionRun.metadata?.answerQuality?.status, 'illegal_query_shape');
|
|
1305
|
+
assert.equal(classifyAIRunFailureClass(assistantIllegalProjectionRun), 'assistant_query_shape');
|
|
1306
|
+
assert.equal(decideAIRunRetry({ currentRun: assistantIllegalProjectionRun }).action, 'retry_assistant_query_shape');
|
|
1307
|
+
|
|
1308
|
+
const assistantQueryErrorRun = buildAssistantAIRunFromEvidence({
|
|
1309
|
+
conversation: { _id: 'conversation-query-error', title: 'Query error answer', status: 'Closed', accepted: true },
|
|
1310
|
+
messages: [{ role: 'assistant', content: 'No invoices were found.' }],
|
|
1311
|
+
answerQuality: {
|
|
1312
|
+
queryStatus: 'query_error',
|
|
1313
|
+
requiresCurrentDate: false,
|
|
1314
|
+
legalQueryShape: true,
|
|
1315
|
+
citationRefs: ['tool-result-query-error'],
|
|
1316
|
+
confidenceLevel: 'high',
|
|
1317
|
+
nextActions: ['Fix the query error and retry before answering.']
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
assert.notEqual(assistantQueryErrorRun.outcome, 'accepted');
|
|
1321
|
+
assert.equal(assistantQueryErrorRun.gates.some((gate) => gate.key === 'assistant_answer_quality' && gate.status === 'blocked'), true);
|
|
1322
|
+
assert.equal(assistantQueryErrorRun.metadata?.answerQuality?.queryStatus, 'query_error');
|
|
1323
|
+
assert.equal(classifyAIRunFailureClass(assistantQueryErrorRun), 'assistant_query_error');
|
|
1324
|
+
assert.equal(decideAIRunRetry({ currentRun: assistantQueryErrorRun }).action, 'retry_assistant_query');
|
|
1325
|
+
|
|
1326
|
+
const assistantPermissionErrorRun = buildAssistantAIRunFromEvidence({
|
|
1327
|
+
conversation: { _id: 'conversation-permission-error', title: 'Permission error answer', status: 'Closed', accepted: true },
|
|
1328
|
+
messages: [{ role: 'assistant', content: 'No invoices were found.' }],
|
|
1329
|
+
answerQuality: {
|
|
1330
|
+
queryStatus: 'permission_error',
|
|
1331
|
+
requiresCurrentDate: false,
|
|
1332
|
+
citationRefs: ['tool-result-permission-error'],
|
|
1333
|
+
confidenceLevel: 'high',
|
|
1334
|
+
nextActions: ['Ask an authorized user to grant invoice access before answering.']
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
1337
|
+
assert.notEqual(assistantPermissionErrorRun.outcome, 'accepted');
|
|
1338
|
+
assert.equal(assistantPermissionErrorRun.gates.some((gate) => gate.key === 'assistant_answer_quality' && gate.status === 'blocked'), true);
|
|
1339
|
+
assert.equal(assistantPermissionErrorRun.metadata?.answerQuality?.queryStatus, 'permission_error');
|
|
1340
|
+
assert.equal(classifyAIRunFailureClass(assistantPermissionErrorRun), 'assistant_permission');
|
|
1341
|
+
assert.equal(decideAIRunRetry({ currentRun: assistantPermissionErrorRun }).action, 'request_assistant_permission');
|
|
1342
|
+
|
|
1343
|
+
const assistantMissingQualityRun = buildAssistantAIRunFromEvidence({
|
|
1344
|
+
conversation: { _id: 'conversation-missing-quality', title: 'Missing assistant answerQuality', status: 'Closed', accepted: true },
|
|
1345
|
+
messages: [{ role: 'assistant', content: 'Invoices look fine.' }]
|
|
1346
|
+
});
|
|
1347
|
+
assert.notEqual(assistantMissingQualityRun.outcome, 'accepted');
|
|
1348
|
+
assert.equal(assistantMissingQualityRun.gates.some((gate) => gate.key === 'assistant_answer_quality' && gate.status === 'blocked'), true);
|
|
1349
|
+
assert.equal(assistantMissingQualityRun.metadata?.answerQuality?.status, 'missing_data_source');
|
|
1350
|
+
assert.equal(classifyAIRunFailureClass(assistantMissingQualityRun), 'assistant_missing_evidence');
|
|
1351
|
+
assert.equal(decideAIRunRetry({ currentRun: assistantMissingQualityRun }).action, 'retry_assistant_answer_quality');
|
|
1352
|
+
|
|
1353
|
+
const assistantAnswerRun = buildAssistantAIRunFromEvidence({
|
|
1354
|
+
runId: 'ai-run:ai_assistant:chat:conversation-1:message-2',
|
|
1355
|
+
requestId: 'request-1',
|
|
1356
|
+
messageId: 'message-2',
|
|
1357
|
+
conversation: { _id: 'conversation-1', title: 'Invoice query', status: 'Closed' },
|
|
1358
|
+
messages: [
|
|
1359
|
+
{ _id: 'message-1', role: 'user', content: 'Show invoices for this month.' },
|
|
1360
|
+
{
|
|
1361
|
+
_id: 'message-2',
|
|
1362
|
+
role: 'assistant',
|
|
1363
|
+
content: 'Found 3 invoices for June 2026.',
|
|
1364
|
+
usage: { model: 'gpt-5.4-mini' }
|
|
1365
|
+
}
|
|
1366
|
+
],
|
|
1367
|
+
answerQuality: {
|
|
1368
|
+
queryStatus: 'ok',
|
|
1369
|
+
requiresCurrentDate: true,
|
|
1370
|
+
currentDateUsed: '2026-06-16',
|
|
1371
|
+
expectedCurrentDate: '2026-06-16',
|
|
1372
|
+
legalQueryShape: true,
|
|
1373
|
+
queryExecutions: [{
|
|
1374
|
+
id: 'tool-result-invoices-june-2026',
|
|
1375
|
+
tool: 'aiAssistantMongoRead',
|
|
1376
|
+
status: 'ok',
|
|
1377
|
+
collection: 'invoices',
|
|
1378
|
+
resultCount: 3
|
|
1379
|
+
}],
|
|
1380
|
+
citationRefs: ['tool-result-invoices-june-2026'],
|
|
1381
|
+
confidenceLevel: 'high',
|
|
1382
|
+
nextActions: ['Open the invoice list filtered to June 2026.']
|
|
1383
|
+
},
|
|
1384
|
+
usageLedger: [{
|
|
1385
|
+
model: 'gpt-5.4-mini',
|
|
1386
|
+
category: 'ai-terminal',
|
|
1387
|
+
usage_source: 'ai_assistant',
|
|
1388
|
+
usage_surface: 'assistant',
|
|
1389
|
+
usage_phase: 'chat',
|
|
1390
|
+
input_tokens: 100,
|
|
1391
|
+
output_tokens: 50,
|
|
1392
|
+
total_tokens: 150,
|
|
1393
|
+
cost_estimate: 0.02
|
|
1394
|
+
}]
|
|
1395
|
+
});
|
|
1396
|
+
assert.equal(assistantAnswerRun.id, 'ai-run:ai_assistant:chat:conversation-1:message-2');
|
|
1397
|
+
assert.equal(assistantAnswerRun.sourceIds.requestId, 'request-1');
|
|
1398
|
+
assert.equal(assistantAnswerRun.sourceIds.messageId, 'message-2');
|
|
1399
|
+
assert.equal(assistantAnswerRun.events.some((event) => event.type === 'assistant_message' && event.metadata?.model === 'gpt-5.4-mini'), true);
|
|
1400
|
+
assert.equal(assistantAnswerRun.events.some((event) => event.type === 'assistant_query' && event.metadata?.id === 'tool-result-invoices-june-2026'), true);
|
|
1401
|
+
assert.equal(assistantAnswerRun.cost?.surfaces?.assistant.estimatedUsd, 0.02);
|
|
1402
|
+
|
|
1403
|
+
console.log('ai run evidence tests passed');
|