blun-king-cli 9.1.587 → 9.1.588
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -185
- package/LIESMICH.txt +51 -13
- package/README.md +44 -47
- package/agent-spine-plugin/.codex-plugin/plugin.json +16 -4
- package/agent-spine-plugin/CHANGELOG.md +37 -5
- package/agent-spine-plugin/README.md +3 -3
- package/agent-spine-plugin/blun.plugin.json +45 -10
- package/agent-spine-plugin/docs/artifact-evaluation.md +93 -0
- package/agent-spine-plugin/docs/host-integration.md +42 -27
- package/agent-spine-plugin/docs/preflight-recall.md +4 -2
- package/agent-spine-plugin/docs/session-timeline.md +97 -236
- package/agent-spine-plugin/docs/world-model.md +25 -0
- package/agent-spine-plugin/hooks/codex.json +1 -1
- package/agent-spine-plugin/hooks/hooks.json +1 -1
- package/agent-spine-plugin/package.json +1 -3
- package/agent-spine-plugin/scripts/check-hosts.js +3 -3
- package/agent-spine-plugin/scripts/release-check.js +10 -5
- package/agent-spine-plugin/scripts/run-checks.js +4 -1
- package/agent-spine-plugin/scripts/run-tests-hermetic.js +32 -6
- package/agent-spine-plugin/src/cli-learning.js +15 -0
- package/agent-spine-plugin/src/cli.js +2 -0
- package/agent-spine-plugin/src/hook.js +32 -32
- package/agent-spine-plugin/src/lib/action-lesson-recall.js +73 -8
- package/agent-spine-plugin/src/lib/briefing.js +146 -36
- package/agent-spine-plugin/src/lib/channel-continuity.js +19 -0
- package/agent-spine-plugin/src/lib/delivery-agent-usage.js +14 -7
- package/agent-spine-plugin/src/lib/gateway-group-response.js +128 -0
- package/agent-spine-plugin/src/lib/gateway-runs.js +24 -15
- package/agent-spine-plugin/src/lib/hook-briefing-use.js +13 -3
- package/agent-spine-plugin/src/lib/hook-context.js +16 -3
- package/agent-spine-plugin/src/lib/hook-output.js +129 -5
- package/agent-spine-plugin/src/lib/hook-timeline.js +5 -3
- package/agent-spine-plugin/src/lib/indexed-memory.js +2 -2
- package/agent-spine-plugin/src/lib/learning-artifact-evaluator.js +114 -0
- package/agent-spine-plugin/src/lib/learning-context.js +11 -4
- package/agent-spine-plugin/src/lib/learning-measurements.js +2 -2
- package/agent-spine-plugin/src/lib/mcp-runtime.js +89 -3
- package/agent-spine-plugin/src/lib/mcp-source-context.js +12 -2
- package/agent-spine-plugin/src/lib/mcp-timeline-tools.js +91 -8
- package/agent-spine-plugin/src/lib/mcp-world-tools.js +2 -2
- package/agent-spine-plugin/src/lib/owned-file-lock.js +20 -1
- package/agent-spine-plugin/src/lib/persona-runtime.js +2 -2
- package/agent-spine-plugin/src/lib/preflight-delivery-id.js +27 -0
- package/agent-spine-plugin/src/lib/preflight.js +4 -4
- package/agent-spine-plugin/src/lib/session-timeline-codex.js +15 -0
- package/agent-spine-plugin/src/lib/session-timeline-contract.js +12 -4
- package/agent-spine-plugin/src/lib/session-timeline-event-extract.js +36 -7
- package/agent-spine-plugin/src/lib/session-timeline-host-origin.js +13 -10
- package/agent-spine-plugin/src/lib/session-timeline-invocation.js +1 -1
- package/agent-spine-plugin/src/lib/session-timeline-king.js +14 -0
- package/agent-spine-plugin/src/lib/session-timeline-prior.js +18 -12
- package/agent-spine-plugin/src/lib/session-timeline-provider.js +5 -0
- package/agent-spine-plugin/src/lib/session-timeline-query.js +2 -0
- package/agent-spine-plugin/src/lib/session-timeline-results.js +35 -10
- package/agent-spine-plugin/src/lib/session-timeline-source-open.js +30 -0
- package/agent-spine-plugin/src/lib/session-timeline.js +122 -75
- package/agent-spine-plugin/src/lib/source-roots.js +3 -2
- package/agent-spine-plugin/src/lib/task-knowledge-context.js +22 -1
- package/agent-spine-plugin/src/lib/timeline-continuation-update.js +100 -0
- package/agent-spine-plugin/src/lib/timeline-tool-guard.js +30 -7
- package/agent-spine-plugin/src/lib/timeline-user-feedback.js +217 -0
- package/agent-spine-plugin/src/lib/timeline-world-capture.js +233 -0
- package/agent-spine-plugin/src/lib/world-knowledge.js +59 -2
- package/agent-spine-plugin/src/lib/world-model.js +64 -9
- package/agent-spine-plugin/src/worker.js +13 -1
- package/bin/blun.js +43 -28
- package/bin/core-bootstrap.js +5 -4
- package/bin/king.js +43 -28
- package/bin/launcher-mode.js +1 -10
- package/bin/launcher-runtime.js +128 -295
- package/bin/managed-node.js +0 -0
- package/bin/managed-plugin-selection.cjs +0 -1
- package/bin/native-module-repair.js +0 -0
- package/bin/node-runtime.js +0 -0
- package/bin/node-version.js +0 -0
- package/bin/plugin-bootstrap.js +56 -120
- package/bin/private-paths.js +11 -34
- package/bin/standard-tools-bootstrap.js +34 -114
- package/bin/turn-thinking-policy.cjs +3 -11
- package/bin/update-copy.js +200 -0
- package/bin/update-lease.js +0 -0
- package/bin/update-notice.js +136 -289
- package/bin/verify-agent-behavior.cjs +122 -0
- package/bin/verify-agent-components.cjs +104 -0
- package/bin/verify-bundled-agent-sources.cjs +57 -0
- package/blun.mjs +143076 -135288
- package/bundled-agent-sources.json +701 -0
- package/package.json +12 -15
- package/standard-skills/translate-native/README.md +1293 -0
- package/standard-skills/translate-native/SKILL.md +172 -22
- package/standard-skills/translate-native/VERSION +1 -1
- package/standard-skills/translate-native/agents/openai.yaml +18 -0
- package/standard-skills/translate-native/assets/icon.svg +8 -0
- package/standard-skills/translate-native/docs/BLUN_CODE_INTEGRATION.md +76 -0
- package/standard-skills/translate-native/docs/PREMORTEM.md +489 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION.md +2035 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_API.md +1302 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_EVIDENCE_HTTP.md +136 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_HEALTH_HTTP.md +130 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_HTTP_PROVIDER.md +175 -0
- package/standard-skills/translate-native/docs/WEBSITE_LOCALIZATION_RECEIPT_VERIFIER_HTTP.md +86 -0
- package/standard-skills/translate-native/integrations/AGENT_RULES.md +32 -0
- package/standard-skills/translate-native/integrations/adapters/blun-code-language-guard.js +514 -0
- package/standard-skills/translate-native/integrations/adapters/node-language-guard.js +230 -0
- package/standard-skills/translate-native/integrations/audit_log.py +327 -0
- package/standard-skills/translate-native/integrations/claude_language_hook.js +1536 -0
- package/standard-skills/translate-native/integrations/commercial_localization_profile.py +42 -0
- package/standard-skills/translate-native/integrations/delivery-policy.example.json +28 -0
- package/standard-skills/translate-native/integrations/enforced_delivery.py +543 -0
- package/standard-skills/translate-native/integrations/guard_service.py +435 -0
- package/standard-skills/translate-native/integrations/language_gateway.py +67 -0
- package/standard-skills/translate-native/integrations/mcp_auth_headers.py +198 -0
- package/standard-skills/translate-native/integrations/mcp_http_gateway.py +429 -0
- package/standard-skills/translate-native/integrations/non_language_html_entities.js +1485 -0
- package/standard-skills/translate-native/integrations/pre_output_guard.py +65 -0
- package/standard-skills/translate-native/integrations/task_router.py +101 -0
- package/standard-skills/translate-native/integrations/website_localization.py +401 -0
- package/standard-skills/translate-native/integrations/website_localization_api.py +581 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark.py +1885 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_campaign.py +1772 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_candidate.py +506 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_http.py +400 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_review_store.py +781 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_reviewer_http.py +500 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_runtime.py +1107 -0
- package/standard-skills/translate-native/integrations/website_localization_benchmark_suite.py +463 -0
- package/standard-skills/translate-native/integrations/website_localization_cms.py +2835 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_client.py +875 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_dispatch.py +805 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_http.py +588 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_lifecycle_monitor.py +991 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_receiver.py +1441 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_receiver_runtime.py +414 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_receiver_store.py +1073 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_removal_dispatch.py +865 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_client.py +583 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_delivery.py +964 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_delivery_runtime.py +665 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_http.py +1153 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_runtime.py +675 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_source_service.py +1125 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_notification.py +674 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_notification_http.py +444 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_notification_receiver.py +1469 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_notification_receiver_runtime.py +1142 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_processing_monitor.py +634 -0
- package/standard-skills/translate-native/integrations/website_localization_cms_terminal_receiver_client.py +804 -0
- package/standard-skills/translate-native/integrations/website_localization_deepl_baseline.py +922 -0
- package/standard-skills/translate-native/integrations/website_localization_evidence_http.py +482 -0
- package/standard-skills/translate-native/integrations/website_localization_health.py +1541 -0
- package/standard-skills/translate-native/integrations/website_localization_health_http.py +372 -0
- package/standard-skills/translate-native/integrations/website_localization_http_provider.py +297 -0
- package/standard-skills/translate-native/integrations/website_localization_native_reference_http.py +479 -0
- package/standard-skills/translate-native/integrations/website_localization_native_reference_intake.py +363 -0
- package/standard-skills/translate-native/integrations/website_localization_native_reference_queue.py +1449 -0
- package/standard-skills/translate-native/integrations/website_localization_native_reference_store.py +420 -0
- package/standard-skills/translate-native/integrations/website_localization_quality_profiles.py +235 -0
- package/standard-skills/translate-native/integrations/website_localization_queue.py +671 -0
- package/standard-skills/translate-native/integrations/website_localization_receipt_verifier_http.py +516 -0
- package/standard-skills/translate-native/integrations/website_localization_release.py +928 -0
- package/standard-skills/translate-native/integrations/website_localization_release_coordinator.py +1008 -0
- package/standard-skills/translate-native/integrations/website_localization_runner.py +276 -0
- package/standard-skills/translate-native/integrations/website_localization_runtime.py +862 -0
- package/standard-skills/translate-native/integrations/website_localization_service.py +350 -0
- package/standard-skills/translate-native/integrations/website_localization_supervisor.py +511 -0
- package/standard-skills/translate-native/integrations/website_localization_worker.py +663 -0
- package/standard-skills/translate-native/provenance.json +3 -4
- package/standard-skills/translate-native/references/commercial-localization.md +177 -0
- package/standard-skills/translate-native/scripts/blun_language_guard.py +7 -1
- package/standard-skills/translate-native/scripts/check_commercial_review.py +80 -0
- package/standard-skills/translate-native/scripts/commercial_localization_profile.py +333 -0
- package/standard-tools/language-guard/LICENSE +21 -0
- package/standard-tools/language-guard/VERSION +1 -0
- package/standard-tools/language-guard/blun_language_guard.py +7 -1
- package/standard-tools/language-guard/check_commercial_review.py +80 -0
- package/standard-tools/language-guard/commercial_localization_profile.py +333 -0
- package/standard-tools/language-guard/language_gateway.py +62 -0
- package/standard-tools/language-guard/pre_output_guard.py +64 -0
- package/standard-tools/language-guard/provenance.json +4 -11
- package/standard-tools/manifest.json +34 -11
- package/telegram-plugin/commands/access.md +2 -10
- package/telegram-plugin/dist/bridge.mjs +64041 -687
- package/telegram-plugin/dist/mcp-server.mjs +72810 -9027
- package/telegram-plugin/dist/noise.mjs +28 -63511
- package/agent-spine-plugin/CONTRIBUTING.md +0 -52
- package/agent-spine-plugin/SECURITY.md +0 -47
- package/agent-spine-plugin/docs/assignment-continuation.md +0 -48
- package/agent-spine-plugin/docs/releasing.md +0 -85
- package/agent-spine-plugin/docs/structured-completion.md +0 -67
- package/bin/abort-listener-policy.cjs +0 -43
- package/bin/active-steer-priority-policy.cjs +0 -24
- package/bin/agent-api-http-adapter.mjs +0 -446
- package/bin/agent-api-private-http-server.mjs +0 -288
- package/bin/agent-api-runtime.mjs +0 -252
- package/bin/agent-api-service-environment.mjs +0 -236
- package/bin/agent-api-service-host.mjs +0 -209
- package/bin/agent-api-service-process.mjs +0 -171
- package/bin/agent-api-session-registry.mjs +0 -428
- package/bin/agent-api-tool-broker.cjs +0 -248
- package/bin/agent-api-turn-controller.mjs +0 -461
- package/bin/agent-api-usage-journal.cjs +0 -259
- package/bin/agent-resume-snapshot.cjs +0 -241
- package/bin/agentspine-king-goal-inbox.mjs +0 -111
- package/bin/agentspine-king-goal-intake.mjs +0 -106
- package/bin/approval-rejection-stop.cjs +0 -15
- package/bin/assistant-message-offload-policy.cjs +0 -284
- package/bin/baseline-skill-performance-policy.cjs +0 -39
- package/bin/bash-search-scope-policy.cjs +0 -49
- package/bin/codebase-search-runtime.cjs +0 -23
- package/bin/cognitive-action-checkpoint.cjs +0 -1104
- package/bin/cognitive-attention-delivery.cjs +0 -76
- package/bin/cognitive-attention-policy.cjs +0 -143
- package/bin/cognitive-attention-runtime.cjs +0 -91
- package/bin/cognitive-context-projection.cjs +0 -73
- package/bin/cognitive-cross-portal-acceptance.cjs +0 -443
- package/bin/cognitive-effective-view.cjs +0 -77
- package/bin/cognitive-focus-projection.cjs +0 -206
- package/bin/cognitive-focus-scope.cjs +0 -37
- package/bin/cognitive-goal-autostart-policy.cjs +0 -72
- package/bin/cognitive-goal-time-trigger-controller.cjs +0 -146
- package/bin/cognitive-memory-adapter.cjs +0 -282
- package/bin/cognitive-memory-command.cjs +0 -293
- package/bin/cognitive-memory-provider.cjs +0 -92
- package/bin/cognitive-salience-policy.cjs +0 -159
- package/bin/cognitive-state-store.cjs +0 -508
- package/bin/cognitive-turn-lifecycle.cjs +0 -624
- package/bin/cognitive-work-focus.cjs +0 -180
- package/bin/compaction-history-archive.cjs +0 -166
- package/bin/compaction-history-startup.cjs +0 -50
- package/bin/compaction-model-policy.cjs +0 -31
- package/bin/compaction-stage-policy.cjs +0 -21
- package/bin/compaction-transaction-policy.cjs +0 -122
- package/bin/config-write-dedup-policy.cjs +0 -27
- package/bin/context-budget-ledger.cjs +0 -31
- package/bin/context-doctor-policy.cjs +0 -70
- package/bin/context-insight-policy.cjs +0 -36
- package/bin/context-performance-policy.cjs +0 -19
- package/bin/context-pressure-policy.cjs +0 -20
- package/bin/cron-run-output.cjs +0 -45
- package/bin/cron-run-store.cjs +0 -145
- package/bin/curiosity-scout-policy.cjs +0 -49
- package/bin/default-model-output-budget-policy.cjs +0 -28
- package/bin/durable-task-resume-policy.cjs +0 -130
- package/bin/durable-task-resume-runtime.cjs +0 -117
- package/bin/durable-task-resume-store.cjs +0 -88
- package/bin/editable-tool-approval-policy.cjs +0 -540
- package/bin/editable-tool-approval-runtime.cjs +0 -99
- package/bin/effective-system-prompt-cache-policy.cjs +0 -33
- package/bin/error-memory-performance-policy.cjs +0 -113
- package/bin/file-observation-policy.cjs +0 -133
- package/bin/foreground-output-capture-policy.cjs +0 -41
- package/bin/generated-source-health.cjs +0 -142
- package/bin/glob-pattern-policy.cjs +0 -13
- package/bin/goal-completion-evidence-policy.cjs +0 -120
- package/bin/grep-output-limit-policy.cjs +0 -39
- package/bin/historical-media-projection-policy.cjs +0 -48
- package/bin/history-offload-pressure-policy.cjs +0 -33
- package/bin/html-to-research-markdown.cjs +0 -147
- package/bin/identity-context-policy.cjs +0 -764
- package/bin/identity-journal-policy.cjs +0 -107
- package/bin/input-draft-persistence.cjs +0 -77
- package/bin/king-tui-function-contract.json +0 -33
- package/bin/launcher-restart-policy.cjs +0 -150
- package/bin/live-response-repetition-guard.cjs +0 -196
- package/bin/llm-config-log-dedup-policy.cjs +0 -76
- package/bin/loop-event-record-policy.cjs +0 -174
- package/bin/managed-context-startup-policy.cjs +0 -27
- package/bin/media-activity-layout-policy.cjs +0 -34
- package/bin/media-auto-retrieval-policy.cjs +0 -90
- package/bin/media-result-policy.cjs +0 -59
- package/bin/micro-compaction-policy.cjs +0 -145
- package/bin/mistake-relevance-policy.cjs +0 -319
- package/bin/model-retry-progress-policy.cjs +0 -46
- package/bin/native-large-file-io.cjs +0 -42
- package/bin/native-runtime-cache.cjs +0 -76
- package/bin/natural-presence-policy.cjs +0 -28
- package/bin/noninteractive-shell-env-policy.cjs +0 -19
- package/bin/observer-hooks.cjs +0 -14
- package/bin/outbound-claim-provenance.cjs +0 -150
- package/bin/oversized-context-offload-policy.cjs +0 -86
- package/bin/pending-media-policy.cjs +0 -182
- package/bin/pending-token-estimate-policy.cjs +0 -41
- package/bin/personal-memory-consent-policy.cjs +0 -72
- package/bin/personal-memory-performance-policy.cjs +0 -12
- package/bin/personality-choice-policy.cjs +0 -101
- package/bin/personality-memory-adapter.cjs +0 -379
- package/bin/personality-mode.cjs +0 -46
- package/bin/personality-setup-policy.cjs +0 -197
- package/bin/proactive-compaction-policy.cjs +0 -25
- package/bin/profile-identity-resolution.cjs +0 -136
- package/bin/profile-runtime.cjs +0 -318
- package/bin/profile-tool-exclusion-policy.cjs +0 -37
- package/bin/programmatic-context-isolation.cjs +0 -25
- package/bin/programmatic-tool-runtime.mjs +0 -627
- package/bin/provider-idle-timeout-policy.cjs +0 -14
- package/bin/provider-model-refresh-deadline.cjs +0 -53
- package/bin/provider-model-refresh-policy.cjs +0 -107
- package/bin/rate-limit-recovery-policy.cjs +0 -47
- package/bin/read-batch-policy.cjs +0 -32
- package/bin/read-continuation-policy.cjs +0 -59
- package/bin/recurring-cron-history-policy.cjs +0 -124
- package/bin/relationship-continuity-policy.cjs +0 -143
- package/bin/relationship-curiosity-policy.cjs +0 -107
- package/bin/relationship-learning-policy.cjs +0 -168
- package/bin/release-artifact-freeze-policy.cjs +0 -30
- package/bin/reload-plugin-bootstrap.cjs +0 -18
- package/bin/reload-queue-policy.cjs +0 -38
- package/bin/repeated-assistant-response-policy.cjs +0 -232
- package/bin/repeated-injection-projection.cjs +0 -107
- package/bin/repeated-user-message-projection.cjs +0 -8
- package/bin/research-page-result.cjs +0 -74
- package/bin/retry-checkpoint-policy.cjs +0 -13
- package/bin/runtime-exit-ledger.cjs +0 -144
- package/bin/scoped-cron-run-policy.cjs +0 -358
- package/bin/session-checkpoint-policy.cjs +0 -25
- package/bin/session-compaction-policy.cjs +0 -84
- package/bin/session-replay-policy.cjs +0 -20
- package/bin/session-replay-window-policy.cjs +0 -40
- package/bin/session-resume-checkpoint.cjs +0 -254
- package/bin/session-scrollback-archive.cjs +0 -229
- package/bin/skill-activation-performance-policy.cjs +0 -69
- package/bin/skill-listing-performance-policy.cjs +0 -92
- package/bin/soul-organization-policy.cjs +0 -78
- package/bin/soul-preservation-policy.cjs +0 -20
- package/bin/startup-preferences.cjs +0 -131
- package/bin/streaming-flush-performance-policy.cjs +0 -28
- package/bin/structured-agent-swarm-output.cjs +0 -325
- package/bin/structured-subagent-output.cjs +0 -252
- package/bin/subagent-context-fork-policy.cjs +0 -155
- package/bin/subagent-max-tokens-handoff-policy.cjs +0 -69
- package/bin/subagent-parent-responsiveness.cjs +0 -19
- package/bin/subagent-skill-policy.cjs +0 -206
- package/bin/subagent-timeout-policy.cjs +0 -182
- package/bin/subagent-tool-policy.cjs +0 -60
- package/bin/subagent-usage-rollup-policy.cjs +0 -29
- package/bin/system-prompt-context-policy.cjs +0 -124
- package/bin/system-prompt-token-cache-policy.cjs +0 -60
- package/bin/telegram-addressed-focus.cjs +0 -55
- package/bin/telegram-addressed-priority.cjs +0 -12
- package/bin/telegram-approval-relay.cjs +0 -290
- package/bin/telegram-bot-priority.cjs +0 -17
- package/bin/telegram-console-status-policy.cjs +0 -174
- package/bin/telegram-context-projection-policy.cjs +0 -141
- package/bin/telegram-delivery-lifecycle.cjs +0 -125
- package/bin/telegram-direct-focus-policy.cjs +0 -273
- package/bin/telegram-mcp-compatibility.cjs +0 -49
- package/bin/telegram-media-delivery-policy.cjs +0 -42
- package/bin/telegram-private-conversation-policy.cjs +0 -185
- package/bin/telegram-queue-handoff-policy.cjs +0 -73
- package/bin/telegram-remote-status-policy.cjs +0 -120
- package/bin/telegram-session-queue-runtime.mjs +0 -306
- package/bin/telegram-text-chunk-policy.cjs +0 -63
- package/bin/telegram-truncated-reply-policy.cjs +0 -37
- package/bin/telegram-urgent-policy.cjs +0 -45
- package/bin/telemetry-spool-policy.cjs +0 -57
- package/bin/thinking-activity-status-policy.cjs +0 -132
- package/bin/thinking-only-guard.cjs +0 -80
- package/bin/todo-list-turn-policy.cjs +0 -131
- package/bin/tool-call-loop-policy.cjs +0 -51
- package/bin/tool-file-persistence.cjs +0 -141
- package/bin/tool-result-offload-policy.cjs +0 -359
- package/bin/tool-result-offload-telemetry.cjs +0 -12
- package/bin/tool-schema-token-cache-policy.cjs +0 -41
- package/bin/tool-stream-preview-policy.cjs +0 -9
- package/bin/tui-functional-contract.cjs +0 -55
- package/bin/turn-tool-performance-policy.cjs +0 -486
- package/bin/usage-cache-efficiency-policy.cjs +0 -26
- package/bin/user-home-path-policy.cjs +0 -13
- package/bin/user-message-offload-policy.cjs +0 -103
- package/bin/user-prompt-hook-origin-policy.cjs +0 -34
- package/bin/user-tool-record-policy.cjs +0 -7
- package/bin/validated-learning-insight-policy.cjs +0 -58
- package/bin/validated-learning-outcome-trace.cjs +0 -107
- package/bin/validated-learning-performance-policy.cjs +0 -53
- package/bin/validated-learning-signal.cjs +0 -463
- package/bin/windows-bash-dialect-policy.cjs +0 -25
- package/bin/windows-node-crash-dump.cjs +0 -110
- package/bin/write-continuation-policy.cjs +0 -69
- package/codebase-index/README.md +0 -82
- package/codebase-index/codebase_index.py +0 -470
- package/standard-skills/agent-browser/SKILL.md +0 -19
- package/standard-skills/agent-browser/references/runtime.md +0 -8
- package/standard-skills/blun-session-inspector/SKILL.md +0 -41
- package/standard-skills/blun-session-inspector/scripts/inspect-session.cjs +0 -437
- package/standard-skills/design-taste-frontend/SKILL.md +0 -1206
- package/standard-skills/full-output-enforcement/SKILL.md +0 -49
- package/standard-skills/high-end-visual-design/SKILL.md +0 -98
- package/standard-skills/image-to-code/SKILL.md +0 -1228
- package/standard-skills/industrial-brutalist-ui/SKILL.md +0 -92
- package/standard-skills/minimalist-ui/SKILL.md +0 -85
- package/standard-skills/motion-design-taste/SKILL.md +0 -74
- package/standard-skills/playwright-testing/SKILL.md +0 -19
- package/standard-skills/playwright-testing/references/runtime.md +0 -7
- package/standard-skills/premortem/SKILL.md +0 -148
- package/standard-skills/redesign-existing-projects/SKILL.md +0 -178
- package/standard-skills/research-evidence/SKILL.md +0 -39
- package/standard-skills/research-evidence/references/evidence-format.md +0 -104
- package/standard-skills/research-evidence/scripts/evidence-collection.cjs +0 -260
- package/standard-skills/research-evidence/scripts/score-report.cjs +0 -130
- package/standard-skills/screenshot-lesen/SKILL.md +0 -52
- package/standard-skills/stitch-design-taste/DESIGN.md +0 -121
- package/standard-skills/stitch-design-taste/SKILL.md +0 -184
- package/standard-skills/telegram-channel/SKILL.md +0 -18
- package/standard-skills/telegram-channel/references/runtime.md +0 -7
- package/standard-skills/venture-flywheel/SKILL.md +0 -32
- package/standard-skills/venture-flywheel/identity/project-identity.cjs +0 -146
- package/standard-skills/venture-flywheel/policy/capability-engine.cjs +0 -114
- package/standard-skills/venture-flywheel/policy/repository-trust.cjs +0 -229
- package/standard-skills/venture-flywheel/references/BEISPIELE-phase0.md +0 -146
- package/standard-skills/venture-flywheel/references/CAPABILITY-MAP.md +0 -34
- package/standard-skills/venture-flywheel/references/SPEC-phase0-identity-trust.md +0 -77
- package/standard-skills/venture-flywheel/references/SPEC-phase0-state-events.md +0 -93
- package/standard-skills/venture-flywheel/schemas/capability-decision.schema.json +0 -13
- package/standard-skills/venture-flywheel/schemas/execution-event.schema.json +0 -44
- package/standard-skills/venture-flywheel/schemas/project-identity.schema.json +0 -32
- package/standard-skills/venture-flywheel/schemas/repository-trust.schema.json +0 -57
- package/standard-skills/venture-flywheel/schemas/run-transition.schema.json +0 -59
- package/standard-skills/venture-flywheel/state/execution-event.cjs +0 -191
- package/standard-skills/venture-flywheel/state/task-state-machine.cjs +0 -190
- package/standard-skills/web-lesen/SKILL.md +0 -73
- package/standard-skills/web-lesen/scripts/crawl_public.py +0 -379
- package/standard-skills/windows-mcp/SKILL.md +0 -19
- package/standard-skills/windows-mcp/references/runtime.md +0 -9
- package/telegram-plugin/DELIVERY.md +0 -36
- package/telegram-plugin/bin/telegram-approval-relay.cjs +0 -290
- package/telegram-plugin/bin/telegram-console-status-policy.cjs +0 -175
- package/telegram-plugin/bin/telegram-delivery-lifecycle.cjs +0 -125
- package/telegram-plugin/bin/telegram-direct-reply-policy.cjs +0 -48
- package/telegram-plugin/bin/telegram-launcher-status-queue.cjs +0 -122
- package/telegram-plugin/bin/telegram-private-conversation-policy.cjs +0 -186
- package/telegram-plugin/bin/telegram-remote-status-policy.cjs +0 -121
- package/telegram-plugin/bin/telegram-reply-parts.cjs +0 -149
- package/telegram-plugin/bin/telegram-text-chunk-policy.cjs +0 -63
- package/telegram-plugin/bin/telegram-typing-keepalive.cjs +0 -89
- package/telegram-plugin/compat/mcp-server-fa511cd1.mjs +0 -73825
- /package/{bin → scripts}/fix-node-pty-perms.js +0 -0
package/standard-skills/translate-native/integrations/website_localization_benchmark_runtime.py
ADDED
|
@@ -0,0 +1,1107 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""One fail-closed execution root for a durable benchmark campaign.
|
|
3
|
+
|
|
4
|
+
The host supplies four distinct SQLite connections and provider-neutral
|
|
5
|
+
adapters. This module owns the exact composition of durable candidate,
|
|
6
|
+
baseline, and qualified-native-reference artifacts before blind review.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import importlib.util
|
|
12
|
+
import re
|
|
13
|
+
import sqlite3
|
|
14
|
+
import sys
|
|
15
|
+
import time
|
|
16
|
+
from dataclasses import dataclass
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Any, Callable
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
ERROR_CODE = re.compile(r"^[a-z][a-z0-9_.-]{0,127}$")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _load_module(name: str, path: Path):
|
|
25
|
+
spec = importlib.util.spec_from_file_location(name, path)
|
|
26
|
+
if spec is None or spec.loader is None:
|
|
27
|
+
raise RuntimeError(f"cannot load benchmark runtime dependency: {path.name}")
|
|
28
|
+
module = importlib.util.module_from_spec(spec)
|
|
29
|
+
sys.modules[spec.name] = module
|
|
30
|
+
spec.loader.exec_module(module)
|
|
31
|
+
return module
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
_ROOT = Path(__file__).resolve().parents[1]
|
|
35
|
+
_CAMPAIGN = _load_module(
|
|
36
|
+
"blun_website_localization_runtime_campaign",
|
|
37
|
+
_ROOT / "integrations" / "website_localization_benchmark_campaign.py",
|
|
38
|
+
)
|
|
39
|
+
_CANDIDATE = _load_module(
|
|
40
|
+
"blun_website_localization_runtime_candidate",
|
|
41
|
+
_ROOT / "integrations" / "website_localization_benchmark_candidate.py",
|
|
42
|
+
)
|
|
43
|
+
_BASELINE = _load_module(
|
|
44
|
+
"blun_website_localization_runtime_baseline",
|
|
45
|
+
_ROOT / "integrations" / "website_localization_deepl_baseline.py",
|
|
46
|
+
)
|
|
47
|
+
_REFERENCE = _load_module(
|
|
48
|
+
"blun_website_localization_runtime_reference",
|
|
49
|
+
_ROOT / "integrations" / "website_localization_native_reference_store.py",
|
|
50
|
+
)
|
|
51
|
+
_REFERENCE_INTAKE = _load_module(
|
|
52
|
+
"blun_website_localization_runtime_reference_intake",
|
|
53
|
+
_ROOT / "integrations" / "website_localization_native_reference_intake.py",
|
|
54
|
+
)
|
|
55
|
+
_REFERENCE_QUEUE = _load_module(
|
|
56
|
+
"blun_website_localization_runtime_reference_queue",
|
|
57
|
+
_ROOT / "integrations" / "website_localization_native_reference_queue.py",
|
|
58
|
+
)
|
|
59
|
+
_REVIEW = _load_module(
|
|
60
|
+
"blun_website_localization_runtime_review_store",
|
|
61
|
+
_ROOT / "integrations" / "website_localization_benchmark_review_store.py",
|
|
62
|
+
)
|
|
63
|
+
_BENCHMARK = _CAMPAIGN._BENCHMARK
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class BenchmarkRuntimeFailed(RuntimeError):
|
|
67
|
+
"""Content-free configuration or dependency failure."""
|
|
68
|
+
|
|
69
|
+
benchmark_campaign_dependency_failure = True
|
|
70
|
+
|
|
71
|
+
def __init__(self, code: str, *, retryable: bool = False):
|
|
72
|
+
if not isinstance(code, str) or ERROR_CODE.fullmatch(code) is None:
|
|
73
|
+
raise ValueError("benchmark runtime error code is invalid")
|
|
74
|
+
if not isinstance(retryable, bool):
|
|
75
|
+
raise ValueError("benchmark runtime retryability must be boolean")
|
|
76
|
+
super().__init__(code)
|
|
77
|
+
self.code = code
|
|
78
|
+
self.retryable = retryable
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass(frozen=True)
|
|
82
|
+
class LeasedNativeReferenceWorkOrder:
|
|
83
|
+
"""One private lease plus its target-free editorial work order."""
|
|
84
|
+
|
|
85
|
+
claim: Any
|
|
86
|
+
work_order: dict[str, Any]
|
|
87
|
+
|
|
88
|
+
def as_payload(self) -> dict[str, Any]:
|
|
89
|
+
return {
|
|
90
|
+
"schema": "blun.website-localization-native-reference-lease.v1",
|
|
91
|
+
"work_id": self.claim.work_id,
|
|
92
|
+
"attempt": self.claim.attempt,
|
|
93
|
+
"max_attempts": self.claim.max_attempts,
|
|
94
|
+
"lease_token": self.claim.lease_token,
|
|
95
|
+
"lease_expires_at": self.claim.lease_expires_at,
|
|
96
|
+
"work_order": self.work_order,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _callable(value: Any, code: str) -> Any:
|
|
101
|
+
if not callable(value):
|
|
102
|
+
raise BenchmarkRuntimeFailed(code)
|
|
103
|
+
return value
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _adapter(value: Any, method: str, code: str) -> Any:
|
|
107
|
+
if not callable(getattr(value, method, None)):
|
|
108
|
+
raise BenchmarkRuntimeFailed(code)
|
|
109
|
+
return value
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _route(value: Any, code: str) -> str:
|
|
113
|
+
if not isinstance(value, str) or _BENCHMARK.IDENTIFIER.fullmatch(value) is None:
|
|
114
|
+
raise BenchmarkRuntimeFailed(code)
|
|
115
|
+
return value
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _connection(value: Any) -> sqlite3.Connection:
|
|
119
|
+
if not isinstance(value, sqlite3.Connection) or value.in_transaction:
|
|
120
|
+
raise BenchmarkRuntimeFailed("benchmark.runtime.connection_invalid")
|
|
121
|
+
return value
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class _GuardedAuthority:
|
|
125
|
+
def __init__(self, authority: Any, guard: Callable[[], None]):
|
|
126
|
+
self._authority = authority
|
|
127
|
+
self._guard = guard
|
|
128
|
+
|
|
129
|
+
def sign(self, payload: bytes):
|
|
130
|
+
self._guard()
|
|
131
|
+
return self._authority.sign(payload)
|
|
132
|
+
|
|
133
|
+
def verify(self, payload: bytes, signature: Any):
|
|
134
|
+
self._guard()
|
|
135
|
+
return self._authority.verify(payload, signature)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class _LazyCandidateProvider:
|
|
139
|
+
def __init__(
|
|
140
|
+
self,
|
|
141
|
+
resolver: Callable[[dict[str, Any]], Any],
|
|
142
|
+
job_payload: dict[str, Any],
|
|
143
|
+
guard: Callable[[], None],
|
|
144
|
+
):
|
|
145
|
+
self._resolver = resolver
|
|
146
|
+
self._job_payload = job_payload
|
|
147
|
+
self._guard = guard
|
|
148
|
+
self._provider = None
|
|
149
|
+
|
|
150
|
+
def invoke(self, request: Any):
|
|
151
|
+
if self._provider is None:
|
|
152
|
+
try:
|
|
153
|
+
self._provider = DurableBenchmarkInputResolver._resolve(
|
|
154
|
+
self._resolver,
|
|
155
|
+
self._job_payload,
|
|
156
|
+
self._guard,
|
|
157
|
+
"benchmark.runtime.candidate_provider_unavailable",
|
|
158
|
+
)
|
|
159
|
+
except Exception as error:
|
|
160
|
+
code = getattr(
|
|
161
|
+
error, "code", "benchmark.runtime.candidate_provider_unavailable",
|
|
162
|
+
)
|
|
163
|
+
retryable = getattr(error, "retryable", True)
|
|
164
|
+
raise _CANDIDATE._WORKER.ProviderCallFailed(
|
|
165
|
+
code if isinstance(code, str) else "provider_unavailable",
|
|
166
|
+
retryable=retryable if isinstance(retryable, bool) else True,
|
|
167
|
+
) from None
|
|
168
|
+
invoke = getattr(self._provider, "invoke", None)
|
|
169
|
+
if not callable(invoke):
|
|
170
|
+
raise _CANDIDATE._WORKER.ProviderCallFailed(
|
|
171
|
+
"candidate_provider_invalid", retryable=False,
|
|
172
|
+
)
|
|
173
|
+
return invoke(request)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class DurableBenchmarkInputResolver:
|
|
177
|
+
"""Build one canonical input envelope from three exact durable stores."""
|
|
178
|
+
|
|
179
|
+
def __init__(
|
|
180
|
+
self,
|
|
181
|
+
*,
|
|
182
|
+
candidate_store: Any,
|
|
183
|
+
baseline_store: Any,
|
|
184
|
+
reference_store: Any,
|
|
185
|
+
policy: Any,
|
|
186
|
+
candidate_route_id: str,
|
|
187
|
+
baseline_route_id: str,
|
|
188
|
+
native_reference_route_id: str,
|
|
189
|
+
assets_resolver: Callable[[dict[str, Any]], Any],
|
|
190
|
+
candidate_provider_resolver: Callable[[dict[str, Any]], Any],
|
|
191
|
+
baseline_acquirer: Callable[..., Any],
|
|
192
|
+
native_reference_loader: Callable[[dict[str, Any]], Any],
|
|
193
|
+
native_reference_verifier: Any,
|
|
194
|
+
evidence_authority: Any,
|
|
195
|
+
clock: Callable[[], float],
|
|
196
|
+
):
|
|
197
|
+
self.candidate_store = candidate_store
|
|
198
|
+
self.baseline_store = baseline_store
|
|
199
|
+
self.reference_store = reference_store
|
|
200
|
+
self.policy = policy
|
|
201
|
+
self.candidate_route_id = candidate_route_id
|
|
202
|
+
self.baseline_route_id = baseline_route_id
|
|
203
|
+
self.native_reference_route_id = native_reference_route_id
|
|
204
|
+
self.assets_resolver = assets_resolver
|
|
205
|
+
self.candidate_provider_resolver = candidate_provider_resolver
|
|
206
|
+
self.baseline_acquirer = baseline_acquirer
|
|
207
|
+
self.native_reference_loader = native_reference_loader
|
|
208
|
+
self.native_reference_verifier = native_reference_verifier
|
|
209
|
+
self.evidence_authority = evidence_authority
|
|
210
|
+
self.clock = clock
|
|
211
|
+
|
|
212
|
+
def __call__(self, _: dict[str, Any]):
|
|
213
|
+
raise BenchmarkRuntimeFailed("benchmark.runtime.operation_guard_missing")
|
|
214
|
+
|
|
215
|
+
@staticmethod
|
|
216
|
+
def _resolve(
|
|
217
|
+
resolver: Callable[[dict[str, Any]], Any],
|
|
218
|
+
job_payload: dict[str, Any],
|
|
219
|
+
guard: Callable[[], None],
|
|
220
|
+
code: str,
|
|
221
|
+
) -> Any:
|
|
222
|
+
guard()
|
|
223
|
+
try:
|
|
224
|
+
value = resolver(job_payload)
|
|
225
|
+
except Exception as error:
|
|
226
|
+
if getattr(error, "benchmark_campaign_dependency_failure", None) is True:
|
|
227
|
+
raise
|
|
228
|
+
raise BenchmarkRuntimeFailed(code, retryable=True) from None
|
|
229
|
+
guard()
|
|
230
|
+
return value
|
|
231
|
+
|
|
232
|
+
def resolve_with_operation_guard(
|
|
233
|
+
self,
|
|
234
|
+
job_payload: dict[str, Any],
|
|
235
|
+
operation_guard: Callable[[], None],
|
|
236
|
+
) -> Any:
|
|
237
|
+
_callable(operation_guard, "benchmark.runtime.operation_guard_invalid")
|
|
238
|
+
assets = self._resolve(
|
|
239
|
+
self.assets_resolver,
|
|
240
|
+
job_payload,
|
|
241
|
+
operation_guard,
|
|
242
|
+
"benchmark.runtime.assets_unavailable",
|
|
243
|
+
)
|
|
244
|
+
try:
|
|
245
|
+
candidate_assets = _CANDIDATE._WORKER.LocalizationAssets(
|
|
246
|
+
glossary_version=assets.glossary_version,
|
|
247
|
+
policy_version=assets.policy_version,
|
|
248
|
+
audience=assets.audience,
|
|
249
|
+
tone_profile=assets.tone_profile,
|
|
250
|
+
glossary=tuple(
|
|
251
|
+
_CANDIDATE._WORKER.GlossaryTerm(
|
|
252
|
+
source=term.source,
|
|
253
|
+
target=term.target,
|
|
254
|
+
note=term.note,
|
|
255
|
+
)
|
|
256
|
+
for term in assets.glossary
|
|
257
|
+
),
|
|
258
|
+
protected_terms=tuple(assets.protected_terms),
|
|
259
|
+
)
|
|
260
|
+
except (AttributeError, TypeError):
|
|
261
|
+
raise BenchmarkRuntimeFailed(
|
|
262
|
+
"benchmark.runtime.assets_invalid",
|
|
263
|
+
) from None
|
|
264
|
+
candidate = _CANDIDATE.resolve_candidate_acquisition(
|
|
265
|
+
self.candidate_store,
|
|
266
|
+
job_payload,
|
|
267
|
+
self.policy,
|
|
268
|
+
self.candidate_route_id,
|
|
269
|
+
candidate_assets,
|
|
270
|
+
_LazyCandidateProvider(
|
|
271
|
+
self.candidate_provider_resolver,
|
|
272
|
+
job_payload,
|
|
273
|
+
operation_guard,
|
|
274
|
+
),
|
|
275
|
+
evidence_authority=self.evidence_authority,
|
|
276
|
+
operation_guard=operation_guard,
|
|
277
|
+
now=self.clock(),
|
|
278
|
+
)
|
|
279
|
+
guarded_authority = _GuardedAuthority(
|
|
280
|
+
self.evidence_authority, operation_guard,
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
def acquire_baseline():
|
|
284
|
+
operation_guard()
|
|
285
|
+
try:
|
|
286
|
+
return self.baseline_acquirer(
|
|
287
|
+
job_payload,
|
|
288
|
+
self.policy,
|
|
289
|
+
self.evidence_authority,
|
|
290
|
+
operation_guard,
|
|
291
|
+
)
|
|
292
|
+
except Exception as error:
|
|
293
|
+
if getattr(error, "benchmark_campaign_dependency_failure", None) is True:
|
|
294
|
+
raise
|
|
295
|
+
raise BenchmarkRuntimeFailed(
|
|
296
|
+
"benchmark.runtime.baseline_unavailable", retryable=True,
|
|
297
|
+
) from None
|
|
298
|
+
|
|
299
|
+
baseline = _BASELINE.resolve_baseline_acquisition(
|
|
300
|
+
self.baseline_store,
|
|
301
|
+
job_payload,
|
|
302
|
+
self.policy,
|
|
303
|
+
self.baseline_route_id,
|
|
304
|
+
acquire_baseline,
|
|
305
|
+
evidence_authority=guarded_authority,
|
|
306
|
+
now=self.clock(),
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
def load_reference():
|
|
310
|
+
try:
|
|
311
|
+
return self.native_reference_loader(job_payload)
|
|
312
|
+
except Exception as error:
|
|
313
|
+
if getattr(error, "benchmark_campaign_dependency_failure", None) is True:
|
|
314
|
+
raise
|
|
315
|
+
raise BenchmarkRuntimeFailed(
|
|
316
|
+
"benchmark.runtime.reference_unavailable", retryable=True,
|
|
317
|
+
) from None
|
|
318
|
+
|
|
319
|
+
reference = _REFERENCE.resolve_native_reference_artifact(
|
|
320
|
+
self.reference_store,
|
|
321
|
+
job_payload,
|
|
322
|
+
self.policy,
|
|
323
|
+
self.native_reference_route_id,
|
|
324
|
+
load_reference,
|
|
325
|
+
native_reference_verifier=self.native_reference_verifier,
|
|
326
|
+
evidence_authority=guarded_authority,
|
|
327
|
+
operation_guard=operation_guard,
|
|
328
|
+
now=self.clock(),
|
|
329
|
+
)
|
|
330
|
+
return _CAMPAIGN.BenchmarkCaseInputs(
|
|
331
|
+
candidate_result=candidate,
|
|
332
|
+
baseline_artifact=baseline.artifact,
|
|
333
|
+
assets=assets,
|
|
334
|
+
native_reference_artifact=reference,
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
class WebsiteLocalizationBenchmarkRuntime:
|
|
339
|
+
"""Preflight, persist, and execute one exact benchmark campaign."""
|
|
340
|
+
|
|
341
|
+
def __init__(
|
|
342
|
+
self,
|
|
343
|
+
*,
|
|
344
|
+
campaign_connection: sqlite3.Connection,
|
|
345
|
+
candidate_connection: sqlite3.Connection,
|
|
346
|
+
baseline_connection: sqlite3.Connection,
|
|
347
|
+
native_reference_connection: sqlite3.Connection,
|
|
348
|
+
review_connection: sqlite3.Connection,
|
|
349
|
+
policy: Any,
|
|
350
|
+
candidate_route_id: str,
|
|
351
|
+
baseline_route_id: str,
|
|
352
|
+
native_reference_route_id: str,
|
|
353
|
+
reviewer_route_id: str,
|
|
354
|
+
assets_resolver: Callable[[dict[str, Any]], Any],
|
|
355
|
+
candidate_provider_resolver: Callable[[dict[str, Any]], Any],
|
|
356
|
+
baseline_acquirer: Callable[..., Any],
|
|
357
|
+
native_reference_loader: Callable[[dict[str, Any]], Any],
|
|
358
|
+
reviewer: Any,
|
|
359
|
+
native_reference_verifier: Any,
|
|
360
|
+
evidence_authority: Any,
|
|
361
|
+
blinding_key: bytes,
|
|
362
|
+
worker_id: str,
|
|
363
|
+
max_attempts: int = 3,
|
|
364
|
+
clock: Callable[[], float] = time.time,
|
|
365
|
+
):
|
|
366
|
+
connections = tuple(_connection(item) for item in (
|
|
367
|
+
campaign_connection,
|
|
368
|
+
candidate_connection,
|
|
369
|
+
baseline_connection,
|
|
370
|
+
native_reference_connection,
|
|
371
|
+
review_connection,
|
|
372
|
+
))
|
|
373
|
+
if len({id(item) for item in connections}) != len(connections):
|
|
374
|
+
raise BenchmarkRuntimeFailed("benchmark.runtime.connection_reused")
|
|
375
|
+
try:
|
|
376
|
+
policy = _BENCHMARK._validate_policy(policy)
|
|
377
|
+
except Exception:
|
|
378
|
+
raise BenchmarkRuntimeFailed("benchmark.runtime.policy_invalid") from None
|
|
379
|
+
candidate_route_id = _route(
|
|
380
|
+
candidate_route_id, "benchmark.runtime.candidate_route_invalid",
|
|
381
|
+
)
|
|
382
|
+
baseline_route_id = _route(
|
|
383
|
+
baseline_route_id, "benchmark.runtime.baseline_route_invalid",
|
|
384
|
+
)
|
|
385
|
+
native_reference_route_id = _route(
|
|
386
|
+
native_reference_route_id, "benchmark.runtime.reference_route_invalid",
|
|
387
|
+
)
|
|
388
|
+
reviewer_route_id = _route(
|
|
389
|
+
reviewer_route_id, "benchmark.runtime.reviewer_route_invalid",
|
|
390
|
+
)
|
|
391
|
+
_callable(assets_resolver, "benchmark.runtime.assets_resolver_invalid")
|
|
392
|
+
_callable(
|
|
393
|
+
candidate_provider_resolver,
|
|
394
|
+
"benchmark.runtime.candidate_provider_resolver_invalid",
|
|
395
|
+
)
|
|
396
|
+
_callable(baseline_acquirer, "benchmark.runtime.baseline_acquirer_invalid")
|
|
397
|
+
_callable(
|
|
398
|
+
native_reference_loader, "benchmark.runtime.reference_loader_invalid",
|
|
399
|
+
)
|
|
400
|
+
_adapter(reviewer, "review", "benchmark.runtime.reviewer_invalid")
|
|
401
|
+
_adapter(
|
|
402
|
+
native_reference_verifier,
|
|
403
|
+
"verify",
|
|
404
|
+
"benchmark.runtime.reference_verifier_invalid",
|
|
405
|
+
)
|
|
406
|
+
_adapter(evidence_authority, "sign", "benchmark.runtime.authority_invalid")
|
|
407
|
+
_adapter(evidence_authority, "verify", "benchmark.runtime.authority_invalid")
|
|
408
|
+
if not isinstance(blinding_key, bytes) or len(blinding_key) < 32:
|
|
409
|
+
raise BenchmarkRuntimeFailed("benchmark.runtime.blinding_key_invalid")
|
|
410
|
+
try:
|
|
411
|
+
worker_id = _CAMPAIGN._identifier(worker_id)
|
|
412
|
+
except Exception:
|
|
413
|
+
raise BenchmarkRuntimeFailed("benchmark.runtime.worker_invalid") from None
|
|
414
|
+
_callable(clock, "benchmark.runtime.clock_invalid")
|
|
415
|
+
if (
|
|
416
|
+
isinstance(max_attempts, bool)
|
|
417
|
+
or not isinstance(max_attempts, int)
|
|
418
|
+
or not 1 <= max_attempts <= _CAMPAIGN.MAX_ATTEMPTS
|
|
419
|
+
):
|
|
420
|
+
raise BenchmarkRuntimeFailed("benchmark.runtime.attempts_invalid")
|
|
421
|
+
try:
|
|
422
|
+
initial_now = _CAMPAIGN._timestamp(clock())
|
|
423
|
+
except Exception:
|
|
424
|
+
raise BenchmarkRuntimeFailed("benchmark.runtime.clock_invalid") from None
|
|
425
|
+
try:
|
|
426
|
+
_CAMPAIGN._assert_policy_current(policy, initial_now)
|
|
427
|
+
except Exception:
|
|
428
|
+
raise BenchmarkRuntimeFailed(
|
|
429
|
+
"benchmark.runtime.validity_expired",
|
|
430
|
+
) from None
|
|
431
|
+
|
|
432
|
+
self.policy = policy
|
|
433
|
+
self.reviewer = reviewer
|
|
434
|
+
self.reviewer_route_id = reviewer_route_id
|
|
435
|
+
self.native_reference_verifier = native_reference_verifier
|
|
436
|
+
self.evidence_authority = evidence_authority
|
|
437
|
+
self.blinding_key = blinding_key
|
|
438
|
+
self.worker_id = worker_id
|
|
439
|
+
self.clock = clock
|
|
440
|
+
self.campaign_store = _CAMPAIGN.BenchmarkCampaignStore(connections[0])
|
|
441
|
+
candidate_store = _CANDIDATE.CandidateAcquisitionStore(connections[1])
|
|
442
|
+
baseline_store = _BASELINE.BaselineAcquisitionStore(connections[2])
|
|
443
|
+
reference_store = _REFERENCE.NativeReferenceArtifactStore(connections[3])
|
|
444
|
+
self.review_store = _REVIEW.BenchmarkReviewEvidenceStore(connections[4])
|
|
445
|
+
self.campaign_id = self.campaign_store.create(
|
|
446
|
+
policy, max_attempts=max_attempts, now=initial_now,
|
|
447
|
+
)
|
|
448
|
+
self.native_reference_queue = _REFERENCE_QUEUE.NativeReferenceWorkQueue(
|
|
449
|
+
self.campaign_store,
|
|
450
|
+
)
|
|
451
|
+
self.native_reference_queue.ensure(
|
|
452
|
+
policy,
|
|
453
|
+
self.campaign_id,
|
|
454
|
+
max_attempts=max_attempts,
|
|
455
|
+
now=initial_now,
|
|
456
|
+
)
|
|
457
|
+
self.input_resolver = DurableBenchmarkInputResolver(
|
|
458
|
+
candidate_store=candidate_store,
|
|
459
|
+
baseline_store=baseline_store,
|
|
460
|
+
reference_store=reference_store,
|
|
461
|
+
policy=policy,
|
|
462
|
+
candidate_route_id=candidate_route_id,
|
|
463
|
+
baseline_route_id=baseline_route_id,
|
|
464
|
+
native_reference_route_id=native_reference_route_id,
|
|
465
|
+
assets_resolver=assets_resolver,
|
|
466
|
+
candidate_provider_resolver=candidate_provider_resolver,
|
|
467
|
+
baseline_acquirer=baseline_acquirer,
|
|
468
|
+
native_reference_loader=native_reference_loader,
|
|
469
|
+
native_reference_verifier=native_reference_verifier,
|
|
470
|
+
evidence_authority=evidence_authority,
|
|
471
|
+
clock=clock,
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
def run_once(
|
|
475
|
+
self,
|
|
476
|
+
*,
|
|
477
|
+
operation_guard: Callable[[float], Any] | None = None,
|
|
478
|
+
lease_seconds: Any = 300,
|
|
479
|
+
retry_base_seconds: Any = 5,
|
|
480
|
+
retry_max_seconds: Any = 3600,
|
|
481
|
+
):
|
|
482
|
+
review_guard = (
|
|
483
|
+
None
|
|
484
|
+
if operation_guard is None
|
|
485
|
+
else lambda: operation_guard(lease_seconds)
|
|
486
|
+
)
|
|
487
|
+
durable_reviewer = _REVIEW.DurableBenchmarkReviewer(
|
|
488
|
+
store=self.review_store,
|
|
489
|
+
policy=self.policy,
|
|
490
|
+
route_id=self.reviewer_route_id,
|
|
491
|
+
reviewer=self.reviewer,
|
|
492
|
+
evidence_authority=self.evidence_authority,
|
|
493
|
+
operation_guard=review_guard,
|
|
494
|
+
clock=self.clock,
|
|
495
|
+
)
|
|
496
|
+
outcome = _CAMPAIGN.run_next_benchmark_case(
|
|
497
|
+
self.campaign_store,
|
|
498
|
+
self.policy,
|
|
499
|
+
self.campaign_id,
|
|
500
|
+
self.worker_id,
|
|
501
|
+
self.input_resolver,
|
|
502
|
+
durable_reviewer,
|
|
503
|
+
blinding_key=self.blinding_key,
|
|
504
|
+
native_reference_verifier=self.native_reference_verifier,
|
|
505
|
+
evidence_authority=self.evidence_authority,
|
|
506
|
+
clock=self.clock,
|
|
507
|
+
operation_guard=operation_guard,
|
|
508
|
+
lease_seconds=lease_seconds,
|
|
509
|
+
retry_base_seconds=retry_base_seconds,
|
|
510
|
+
retry_max_seconds=retry_max_seconds,
|
|
511
|
+
)
|
|
512
|
+
report_outcome = None
|
|
513
|
+
if (
|
|
514
|
+
outcome is None or outcome.status == "succeeded"
|
|
515
|
+
) and self.campaign_store.report_finalization_required(
|
|
516
|
+
self.policy, self.campaign_id,
|
|
517
|
+
):
|
|
518
|
+
report_outcome = _CAMPAIGN.run_benchmark_report_finalization(
|
|
519
|
+
self.campaign_store,
|
|
520
|
+
self.policy,
|
|
521
|
+
self.campaign_id,
|
|
522
|
+
self.worker_id,
|
|
523
|
+
self.evidence_authority,
|
|
524
|
+
clock=self.clock,
|
|
525
|
+
operation_guard=operation_guard,
|
|
526
|
+
lease_seconds=lease_seconds,
|
|
527
|
+
retry_base_seconds=retry_base_seconds,
|
|
528
|
+
retry_max_seconds=retry_max_seconds,
|
|
529
|
+
)
|
|
530
|
+
return outcome if outcome is not None else report_outcome
|
|
531
|
+
|
|
532
|
+
def status(self):
|
|
533
|
+
return self.campaign_store.status(self.policy, self.campaign_id)
|
|
534
|
+
|
|
535
|
+
@staticmethod
|
|
536
|
+
def _retry_delay(attempt: int, base: Any, maximum: Any) -> float:
|
|
537
|
+
base = _REFERENCE_QUEUE._duration(base)
|
|
538
|
+
maximum = _REFERENCE_QUEUE._duration(maximum)
|
|
539
|
+
return min(maximum, base * (2 ** max(0, attempt - 1)))
|
|
540
|
+
|
|
541
|
+
def claim_native_reference_work_order(
|
|
542
|
+
self,
|
|
543
|
+
editor_id: Any,
|
|
544
|
+
*,
|
|
545
|
+
target_locale: Any = None,
|
|
546
|
+
request_id: Any = None,
|
|
547
|
+
operation_guard: Callable[[float], Any] | None = None,
|
|
548
|
+
lease_seconds: Any = 3600,
|
|
549
|
+
retry_base_seconds: Any = 30,
|
|
550
|
+
retry_max_seconds: Any = 3600,
|
|
551
|
+
) -> LeasedNativeReferenceWorkOrder | None:
|
|
552
|
+
"""Lease the next unresolved exact job without persisting its prose."""
|
|
553
|
+
if operation_guard is not None and not callable(operation_guard):
|
|
554
|
+
raise BenchmarkRuntimeFailed(
|
|
555
|
+
"benchmark.runtime.reference_queue.guard_invalid",
|
|
556
|
+
)
|
|
557
|
+
lease_seconds = _REFERENCE_QUEUE._duration(lease_seconds)
|
|
558
|
+
self._retry_delay(1, retry_base_seconds, retry_max_seconds)
|
|
559
|
+
expected_count = len(_CAMPAIGN._expected_work(self.policy))
|
|
560
|
+
for _ in range(expected_count):
|
|
561
|
+
try:
|
|
562
|
+
claim = self.native_reference_queue.claim(
|
|
563
|
+
self.policy,
|
|
564
|
+
self.campaign_id,
|
|
565
|
+
editor_id,
|
|
566
|
+
now=self.clock(),
|
|
567
|
+
lease_seconds=lease_seconds,
|
|
568
|
+
target_locale=target_locale,
|
|
569
|
+
request_id=request_id,
|
|
570
|
+
)
|
|
571
|
+
except Exception as error:
|
|
572
|
+
code = getattr(
|
|
573
|
+
error,
|
|
574
|
+
"code",
|
|
575
|
+
"benchmark.runtime.reference_queue.state_invalid",
|
|
576
|
+
)
|
|
577
|
+
if not isinstance(code, str) or ERROR_CODE.fullmatch(code) is None:
|
|
578
|
+
code = "benchmark.runtime.reference_queue.state_invalid"
|
|
579
|
+
raise BenchmarkRuntimeFailed(code) from None
|
|
580
|
+
if claim is None:
|
|
581
|
+
return None
|
|
582
|
+
|
|
583
|
+
def guard() -> None:
|
|
584
|
+
try:
|
|
585
|
+
if operation_guard is not None:
|
|
586
|
+
operation_guard(lease_seconds)
|
|
587
|
+
_CAMPAIGN._assert_policy_current(
|
|
588
|
+
self.policy, self.clock(),
|
|
589
|
+
)
|
|
590
|
+
self.native_reference_queue.assert_live(
|
|
591
|
+
claim, now=self.clock(),
|
|
592
|
+
)
|
|
593
|
+
except _CAMPAIGN.BenchmarkCampaignBlocked as error:
|
|
594
|
+
if error.code == "benchmark.campaign.validity_expired":
|
|
595
|
+
raise _REFERENCE_INTAKE.NativeReferenceIntakeFailed(
|
|
596
|
+
"native_reference.queue.policy_expired",
|
|
597
|
+
) from None
|
|
598
|
+
raise _REFERENCE_INTAKE.NativeReferenceIntakeFailed(
|
|
599
|
+
"native_reference.intake.operation_guard_failed",
|
|
600
|
+
retryable=True,
|
|
601
|
+
) from None
|
|
602
|
+
except _REFERENCE_INTAKE.NativeReferenceIntakeFailed:
|
|
603
|
+
raise
|
|
604
|
+
except Exception:
|
|
605
|
+
raise _REFERENCE_INTAKE.NativeReferenceIntakeFailed(
|
|
606
|
+
"native_reference.intake.operation_guard_failed",
|
|
607
|
+
retryable=True,
|
|
608
|
+
) from None
|
|
609
|
+
|
|
610
|
+
guarded_verifier = _REFERENCE_INTAKE._GuardedAdapter(
|
|
611
|
+
self.native_reference_verifier, guard,
|
|
612
|
+
)
|
|
613
|
+
guarded_authority = _REFERENCE_INTAKE._GuardedAdapter(
|
|
614
|
+
self.evidence_authority, guard,
|
|
615
|
+
)
|
|
616
|
+
try:
|
|
617
|
+
guard()
|
|
618
|
+
artifact = self.input_resolver.reference_store.load(
|
|
619
|
+
claim.job_payload,
|
|
620
|
+
self.policy,
|
|
621
|
+
self.input_resolver.native_reference_route_id,
|
|
622
|
+
native_reference_verifier=guarded_verifier,
|
|
623
|
+
evidence_authority=guarded_authority,
|
|
624
|
+
)
|
|
625
|
+
guard()
|
|
626
|
+
if artifact is None:
|
|
627
|
+
return LeasedNativeReferenceWorkOrder(
|
|
628
|
+
claim=claim,
|
|
629
|
+
work_order=self.create_native_reference_work_order(
|
|
630
|
+
claim.job_payload,
|
|
631
|
+
),
|
|
632
|
+
)
|
|
633
|
+
self.native_reference_queue.complete(
|
|
634
|
+
self.policy,
|
|
635
|
+
claim,
|
|
636
|
+
_REFERENCE_INTAKE._hash_json(artifact),
|
|
637
|
+
now=self.clock(),
|
|
638
|
+
)
|
|
639
|
+
except Exception as error:
|
|
640
|
+
code = getattr(
|
|
641
|
+
error,
|
|
642
|
+
"code",
|
|
643
|
+
"native_reference.queue.reconciliation_failed",
|
|
644
|
+
)
|
|
645
|
+
retryable = getattr(error, "retryable", False)
|
|
646
|
+
if not isinstance(code, str) or ERROR_CODE.fullmatch(code) is None:
|
|
647
|
+
code = "native_reference.queue.reconciliation_failed"
|
|
648
|
+
if not isinstance(retryable, bool):
|
|
649
|
+
retryable = False
|
|
650
|
+
try:
|
|
651
|
+
outcome = self.native_reference_queue.transition_failure(
|
|
652
|
+
self.policy,
|
|
653
|
+
claim,
|
|
654
|
+
code,
|
|
655
|
+
retryable=retryable,
|
|
656
|
+
delay_seconds=self._retry_delay(
|
|
657
|
+
claim.attempt,
|
|
658
|
+
retry_base_seconds,
|
|
659
|
+
retry_max_seconds,
|
|
660
|
+
),
|
|
661
|
+
now=self.clock(),
|
|
662
|
+
)
|
|
663
|
+
except Exception as transition_error:
|
|
664
|
+
transition_code = getattr(
|
|
665
|
+
transition_error,
|
|
666
|
+
"code",
|
|
667
|
+
"benchmark.runtime.reference_queue.state_invalid",
|
|
668
|
+
)
|
|
669
|
+
if (
|
|
670
|
+
not isinstance(transition_code, str)
|
|
671
|
+
or ERROR_CODE.fullmatch(transition_code) is None
|
|
672
|
+
):
|
|
673
|
+
transition_code = (
|
|
674
|
+
"benchmark.runtime.reference_queue.state_invalid"
|
|
675
|
+
)
|
|
676
|
+
raise BenchmarkRuntimeFailed(
|
|
677
|
+
code
|
|
678
|
+
if code == "native_reference.queue.policy_expired"
|
|
679
|
+
else transition_code,
|
|
680
|
+
) from None
|
|
681
|
+
raise BenchmarkRuntimeFailed(
|
|
682
|
+
outcome.error_code or code,
|
|
683
|
+
retryable=outcome.status == "retry_wait",
|
|
684
|
+
) from None
|
|
685
|
+
raise BenchmarkRuntimeFailed(
|
|
686
|
+
"benchmark.runtime.reference_queue.state_invalid",
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
def native_reference_lease_from_payload(
|
|
690
|
+
self, payload: Any, *, editor_id: Any, target_locale: Any,
|
|
691
|
+
) -> LeasedNativeReferenceWorkOrder:
|
|
692
|
+
"""Reconstruct and verify one private lease at a stateless boundary."""
|
|
693
|
+
keys = {
|
|
694
|
+
"schema", "work_id", "attempt", "max_attempts",
|
|
695
|
+
"lease_token", "lease_expires_at", "work_order",
|
|
696
|
+
}
|
|
697
|
+
try:
|
|
698
|
+
if (
|
|
699
|
+
not isinstance(payload, dict)
|
|
700
|
+
or set(payload) != keys
|
|
701
|
+
or payload.get("schema")
|
|
702
|
+
!= "blun.website-localization-native-reference-lease.v1"
|
|
703
|
+
or not isinstance(payload.get("work_order"), dict)
|
|
704
|
+
):
|
|
705
|
+
raise ValueError
|
|
706
|
+
editor_id = _REFERENCE_QUEUE._identifier(editor_id)
|
|
707
|
+
target_locale = _REFERENCE_QUEUE._identifier(target_locale)
|
|
708
|
+
work_order = payload["work_order"]
|
|
709
|
+
suite = work_order.get("suite")
|
|
710
|
+
if (
|
|
711
|
+
work_order.get("target_locale") != target_locale
|
|
712
|
+
or not isinstance(suite, dict)
|
|
713
|
+
or not isinstance(suite.get("case_key"), str)
|
|
714
|
+
):
|
|
715
|
+
raise ValueError
|
|
716
|
+
case_key = suite["case_key"]
|
|
717
|
+
expected = {
|
|
718
|
+
(locale, key): work_id
|
|
719
|
+
for work_id, locale, key in _CAMPAIGN._expected_work(self.policy)
|
|
720
|
+
}
|
|
721
|
+
work_id = expected.get((target_locale, case_key))
|
|
722
|
+
if work_id is None or payload.get("work_id") != work_id:
|
|
723
|
+
raise ValueError
|
|
724
|
+
attempt = payload.get("attempt")
|
|
725
|
+
maximum = payload.get("max_attempts")
|
|
726
|
+
if (
|
|
727
|
+
isinstance(attempt, bool) or not isinstance(attempt, int)
|
|
728
|
+
or isinstance(maximum, bool) or not isinstance(maximum, int)
|
|
729
|
+
or not 1 <= attempt <= maximum <= _REFERENCE_QUEUE.MAX_ATTEMPTS
|
|
730
|
+
):
|
|
731
|
+
raise ValueError
|
|
732
|
+
token = _REFERENCE_QUEUE._identifier(payload.get("lease_token"))
|
|
733
|
+
expires = _REFERENCE_QUEUE._timestamp(payload.get("lease_expires_at"))
|
|
734
|
+
job_payload = _CAMPAIGN._job_payload(
|
|
735
|
+
self.policy, target_locale, case_key,
|
|
736
|
+
)
|
|
737
|
+
expected_order = self.create_native_reference_work_order(job_payload)
|
|
738
|
+
if _REFERENCE_INTAKE._canonical_json(
|
|
739
|
+
work_order,
|
|
740
|
+
) != _REFERENCE_INTAKE._canonical_json(expected_order):
|
|
741
|
+
raise ValueError
|
|
742
|
+
claim = _REFERENCE_QUEUE.ClaimedNativeReference(
|
|
743
|
+
work_id=work_id,
|
|
744
|
+
campaign_id=self.campaign_id,
|
|
745
|
+
target_locale=target_locale,
|
|
746
|
+
suite_case_key=case_key,
|
|
747
|
+
job_payload=job_payload,
|
|
748
|
+
attempt=attempt,
|
|
749
|
+
max_attempts=maximum,
|
|
750
|
+
lease_owner=editor_id,
|
|
751
|
+
lease_token=token,
|
|
752
|
+
lease_expires_at=expires,
|
|
753
|
+
)
|
|
754
|
+
self.native_reference_queue.assert_live(claim, now=self.clock())
|
|
755
|
+
return LeasedNativeReferenceWorkOrder(
|
|
756
|
+
claim=claim, work_order=expected_order,
|
|
757
|
+
)
|
|
758
|
+
except BenchmarkRuntimeFailed:
|
|
759
|
+
raise
|
|
760
|
+
except Exception as error:
|
|
761
|
+
code = getattr(
|
|
762
|
+
error, "code", "benchmark.runtime.reference_queue.claim_invalid",
|
|
763
|
+
)
|
|
764
|
+
if not isinstance(code, str) or ERROR_CODE.fullmatch(code) is None:
|
|
765
|
+
code = "benchmark.runtime.reference_queue.claim_invalid"
|
|
766
|
+
raise BenchmarkRuntimeFailed(code) from None
|
|
767
|
+
|
|
768
|
+
def renew_native_reference_work_order(
|
|
769
|
+
self,
|
|
770
|
+
lease: Any,
|
|
771
|
+
*,
|
|
772
|
+
lease_seconds: Any = 3600,
|
|
773
|
+
request_id: Any = None,
|
|
774
|
+
request_sha256: Any = None,
|
|
775
|
+
) -> LeasedNativeReferenceWorkOrder:
|
|
776
|
+
"""Renew only the exact live editorial lease token."""
|
|
777
|
+
if not isinstance(lease, LeasedNativeReferenceWorkOrder):
|
|
778
|
+
raise BenchmarkRuntimeFailed(
|
|
779
|
+
"benchmark.runtime.reference_queue.claim_invalid",
|
|
780
|
+
)
|
|
781
|
+
try:
|
|
782
|
+
claim = self.native_reference_queue.renew(
|
|
783
|
+
lease.claim,
|
|
784
|
+
now=self.clock(),
|
|
785
|
+
lease_seconds=lease_seconds,
|
|
786
|
+
policy=self.policy if (
|
|
787
|
+
request_id is not None or request_sha256 is not None
|
|
788
|
+
) else None,
|
|
789
|
+
request_id=request_id,
|
|
790
|
+
request_sha256=request_sha256,
|
|
791
|
+
)
|
|
792
|
+
except Exception as error:
|
|
793
|
+
code = getattr(
|
|
794
|
+
error, "code", "benchmark.runtime.reference_queue.state_invalid",
|
|
795
|
+
)
|
|
796
|
+
raise BenchmarkRuntimeFailed(code) from None
|
|
797
|
+
return LeasedNativeReferenceWorkOrder(
|
|
798
|
+
claim=claim, work_order=lease.work_order,
|
|
799
|
+
)
|
|
800
|
+
|
|
801
|
+
def native_reference_http_request_replay(
|
|
802
|
+
self,
|
|
803
|
+
*,
|
|
804
|
+
editor_id: Any,
|
|
805
|
+
target_locale: Any,
|
|
806
|
+
operation: Any,
|
|
807
|
+
request_id: Any,
|
|
808
|
+
request_sha256: Any,
|
|
809
|
+
) -> dict[str, Any] | None:
|
|
810
|
+
"""Load one exact completed HTTP mutation without touching prose."""
|
|
811
|
+
try:
|
|
812
|
+
return self.native_reference_queue.replay_http_request(
|
|
813
|
+
self.policy,
|
|
814
|
+
self.campaign_id,
|
|
815
|
+
editor_id,
|
|
816
|
+
target_locale,
|
|
817
|
+
operation,
|
|
818
|
+
request_id,
|
|
819
|
+
request_sha256,
|
|
820
|
+
now=self.clock(),
|
|
821
|
+
)
|
|
822
|
+
except Exception as error:
|
|
823
|
+
code = getattr(
|
|
824
|
+
error,
|
|
825
|
+
"code",
|
|
826
|
+
"benchmark.runtime.reference_queue.state_invalid",
|
|
827
|
+
)
|
|
828
|
+
if not isinstance(code, str) or ERROR_CODE.fullmatch(code) is None:
|
|
829
|
+
code = "benchmark.runtime.reference_queue.state_invalid"
|
|
830
|
+
raise BenchmarkRuntimeFailed(code) from None
|
|
831
|
+
|
|
832
|
+
def accept_leased_native_reference_submission(
|
|
833
|
+
self,
|
|
834
|
+
lease: Any,
|
|
835
|
+
submission: Any,
|
|
836
|
+
*,
|
|
837
|
+
operation_guard: Callable[[float], Any] | None = None,
|
|
838
|
+
lease_seconds: Any = 3600,
|
|
839
|
+
retry_base_seconds: Any = 30,
|
|
840
|
+
retry_max_seconds: Any = 3600,
|
|
841
|
+
request_id: Any = None,
|
|
842
|
+
request_sha256: Any = None,
|
|
843
|
+
):
|
|
844
|
+
"""Verify, store, and complete one exact leased editorial result."""
|
|
845
|
+
if not isinstance(lease, LeasedNativeReferenceWorkOrder):
|
|
846
|
+
raise BenchmarkRuntimeFailed(
|
|
847
|
+
"benchmark.runtime.reference_queue.claim_invalid",
|
|
848
|
+
)
|
|
849
|
+
if operation_guard is not None and not callable(operation_guard):
|
|
850
|
+
raise BenchmarkRuntimeFailed(
|
|
851
|
+
"benchmark.runtime.reference_queue.guard_invalid",
|
|
852
|
+
)
|
|
853
|
+
lease_seconds = _REFERENCE_QUEUE._duration(lease_seconds)
|
|
854
|
+
http_request = request_id is not None or request_sha256 is not None
|
|
855
|
+
if http_request:
|
|
856
|
+
try:
|
|
857
|
+
replay = self.native_reference_queue.begin_http_submission_request(
|
|
858
|
+
self.policy,
|
|
859
|
+
lease.claim,
|
|
860
|
+
request_id,
|
|
861
|
+
request_sha256,
|
|
862
|
+
now=self.clock(),
|
|
863
|
+
)
|
|
864
|
+
if replay is not None:
|
|
865
|
+
return self.native_reference_queue.outcome_from_payload(replay)
|
|
866
|
+
except Exception as error:
|
|
867
|
+
code = getattr(
|
|
868
|
+
error,
|
|
869
|
+
"code",
|
|
870
|
+
"benchmark.runtime.reference_queue.state_invalid",
|
|
871
|
+
)
|
|
872
|
+
if not isinstance(code, str) or ERROR_CODE.fullmatch(code) is None:
|
|
873
|
+
code = "benchmark.runtime.reference_queue.state_invalid"
|
|
874
|
+
raise BenchmarkRuntimeFailed(code) from None
|
|
875
|
+
|
|
876
|
+
def guard() -> None:
|
|
877
|
+
try:
|
|
878
|
+
if operation_guard is not None:
|
|
879
|
+
operation_guard(lease_seconds)
|
|
880
|
+
_CAMPAIGN._assert_policy_current(
|
|
881
|
+
self.policy, self.clock(),
|
|
882
|
+
)
|
|
883
|
+
self.native_reference_queue.assert_live(
|
|
884
|
+
lease.claim, now=self.clock(),
|
|
885
|
+
)
|
|
886
|
+
except _CAMPAIGN.BenchmarkCampaignBlocked as error:
|
|
887
|
+
if error.code == "benchmark.campaign.validity_expired":
|
|
888
|
+
raise _REFERENCE_INTAKE.NativeReferenceIntakeFailed(
|
|
889
|
+
"native_reference.queue.policy_expired",
|
|
890
|
+
) from None
|
|
891
|
+
raise _REFERENCE_INTAKE.NativeReferenceIntakeFailed(
|
|
892
|
+
"native_reference.intake.operation_guard_failed",
|
|
893
|
+
retryable=True,
|
|
894
|
+
) from None
|
|
895
|
+
except _REFERENCE_INTAKE.NativeReferenceIntakeFailed:
|
|
896
|
+
raise
|
|
897
|
+
except Exception:
|
|
898
|
+
raise _REFERENCE_INTAKE.NativeReferenceIntakeFailed(
|
|
899
|
+
"native_reference.intake.operation_guard_failed",
|
|
900
|
+
retryable=True,
|
|
901
|
+
) from None
|
|
902
|
+
|
|
903
|
+
try:
|
|
904
|
+
artifact = _REFERENCE_INTAKE.accept_native_reference_submission(
|
|
905
|
+
self.input_resolver.reference_store,
|
|
906
|
+
lease.work_order,
|
|
907
|
+
submission,
|
|
908
|
+
lease.claim.job_payload,
|
|
909
|
+
self.policy,
|
|
910
|
+
self.input_resolver.native_reference_route_id,
|
|
911
|
+
native_reference_verifier=self.native_reference_verifier,
|
|
912
|
+
evidence_authority=self.evidence_authority,
|
|
913
|
+
operation_guard=guard,
|
|
914
|
+
now=self.clock(),
|
|
915
|
+
)
|
|
916
|
+
guard()
|
|
917
|
+
return self.native_reference_queue.complete(
|
|
918
|
+
self.policy,
|
|
919
|
+
lease.claim,
|
|
920
|
+
_REFERENCE_INTAKE._hash_json(artifact),
|
|
921
|
+
now=self.clock(),
|
|
922
|
+
request_id=request_id,
|
|
923
|
+
request_sha256=request_sha256,
|
|
924
|
+
)
|
|
925
|
+
except Exception as error:
|
|
926
|
+
code = getattr(
|
|
927
|
+
error, "code", "native_reference.intake.adapter_invalid",
|
|
928
|
+
)
|
|
929
|
+
retryable = getattr(error, "retryable", False)
|
|
930
|
+
if not isinstance(code, str) or ERROR_CODE.fullmatch(code) is None:
|
|
931
|
+
code = "native_reference.intake.adapter_invalid"
|
|
932
|
+
if not isinstance(retryable, bool):
|
|
933
|
+
retryable = False
|
|
934
|
+
try:
|
|
935
|
+
return self.native_reference_queue.transition_failure(
|
|
936
|
+
self.policy,
|
|
937
|
+
lease.claim,
|
|
938
|
+
code,
|
|
939
|
+
retryable=retryable,
|
|
940
|
+
delay_seconds=self._retry_delay(
|
|
941
|
+
lease.claim.attempt,
|
|
942
|
+
retry_base_seconds,
|
|
943
|
+
retry_max_seconds,
|
|
944
|
+
),
|
|
945
|
+
now=self.clock(),
|
|
946
|
+
request_id=request_id,
|
|
947
|
+
request_sha256=request_sha256,
|
|
948
|
+
)
|
|
949
|
+
except Exception as transition_error:
|
|
950
|
+
transition_code = getattr(
|
|
951
|
+
transition_error,
|
|
952
|
+
"code",
|
|
953
|
+
"benchmark.runtime.reference_queue.state_invalid",
|
|
954
|
+
)
|
|
955
|
+
if (
|
|
956
|
+
not isinstance(transition_code, str)
|
|
957
|
+
or ERROR_CODE.fullmatch(transition_code) is None
|
|
958
|
+
):
|
|
959
|
+
transition_code = (
|
|
960
|
+
"benchmark.runtime.reference_queue.state_invalid"
|
|
961
|
+
)
|
|
962
|
+
raise BenchmarkRuntimeFailed(
|
|
963
|
+
code
|
|
964
|
+
if code == "native_reference.queue.policy_expired"
|
|
965
|
+
else transition_code,
|
|
966
|
+
) from None
|
|
967
|
+
|
|
968
|
+
def native_reference_queue_status(self):
|
|
969
|
+
"""Return content-free intake counts and stable failure codes."""
|
|
970
|
+
return self.native_reference_queue.status(
|
|
971
|
+
self.policy, self.campaign_id,
|
|
972
|
+
)
|
|
973
|
+
|
|
974
|
+
def native_reference_queue_health(
|
|
975
|
+
self, *, now: Any, stale_after_seconds: Any = 3600,
|
|
976
|
+
):
|
|
977
|
+
"""Reverify every completed digest in a content-free health snapshot."""
|
|
978
|
+
health = self.native_reference_queue.health(
|
|
979
|
+
self.policy,
|
|
980
|
+
self.campaign_id,
|
|
981
|
+
now=now,
|
|
982
|
+
stale_after_seconds=stale_after_seconds,
|
|
983
|
+
)
|
|
984
|
+
if health.status == "blocked":
|
|
985
|
+
return health
|
|
986
|
+
try:
|
|
987
|
+
rows = self.native_reference_queue.connection.execute("""
|
|
988
|
+
SELECT target_locale, suite_case_key, artifact_sha256
|
|
989
|
+
FROM benchmark_native_reference_queue
|
|
990
|
+
WHERE campaign_id = ? AND status = 'succeeded'
|
|
991
|
+
ORDER BY target_locale, suite_case_key
|
|
992
|
+
""", (self.campaign_id,)).fetchall()
|
|
993
|
+
for row in rows:
|
|
994
|
+
payload = _CAMPAIGN._job_payload(
|
|
995
|
+
self.policy, row["target_locale"], row["suite_case_key"],
|
|
996
|
+
)
|
|
997
|
+
artifact = self.input_resolver.reference_store.load(
|
|
998
|
+
payload,
|
|
999
|
+
self.policy,
|
|
1000
|
+
self.input_resolver.native_reference_route_id,
|
|
1001
|
+
native_reference_verifier=self.native_reference_verifier,
|
|
1002
|
+
evidence_authority=self.evidence_authority,
|
|
1003
|
+
)
|
|
1004
|
+
if (
|
|
1005
|
+
artifact is None
|
|
1006
|
+
or _REFERENCE_INTAKE._hash_json(artifact)
|
|
1007
|
+
!= row["artifact_sha256"]
|
|
1008
|
+
):
|
|
1009
|
+
raise ValueError
|
|
1010
|
+
except Exception:
|
|
1011
|
+
return _REFERENCE_QUEUE.NativeReferenceQueueHealth(
|
|
1012
|
+
campaign_id=self.campaign_id,
|
|
1013
|
+
status="blocked",
|
|
1014
|
+
reasons=("native_reference.queue.state_invalid",),
|
|
1015
|
+
counts=health.counts,
|
|
1016
|
+
work_count=health.work_count,
|
|
1017
|
+
last_progress_at=health.last_progress_at,
|
|
1018
|
+
)
|
|
1019
|
+
return health
|
|
1020
|
+
|
|
1021
|
+
def create_native_reference_work_order(self, job_payload: Any):
|
|
1022
|
+
"""Export one current target-free order for qualified native review."""
|
|
1023
|
+
return _REFERENCE_INTAKE.create_native_reference_work_order(
|
|
1024
|
+
job_payload,
|
|
1025
|
+
self.policy,
|
|
1026
|
+
self.input_resolver.native_reference_route_id,
|
|
1027
|
+
)
|
|
1028
|
+
|
|
1029
|
+
def native_reference_verification_request(
|
|
1030
|
+
self,
|
|
1031
|
+
work_order: Any,
|
|
1032
|
+
job_payload: Any,
|
|
1033
|
+
target_text: Any,
|
|
1034
|
+
*,
|
|
1035
|
+
reviewer_id: Any,
|
|
1036
|
+
reviewer_version: Any,
|
|
1037
|
+
):
|
|
1038
|
+
"""Return the exact request that the qualification receipt must bind."""
|
|
1039
|
+
return _REFERENCE_INTAKE.native_reference_verification_request_for_work_order(
|
|
1040
|
+
work_order,
|
|
1041
|
+
job_payload,
|
|
1042
|
+
self.policy,
|
|
1043
|
+
self.input_resolver.native_reference_route_id,
|
|
1044
|
+
target_text,
|
|
1045
|
+
reviewer_id=reviewer_id,
|
|
1046
|
+
reviewer_version=reviewer_version,
|
|
1047
|
+
)
|
|
1048
|
+
|
|
1049
|
+
def accept_native_reference_submission(
|
|
1050
|
+
self,
|
|
1051
|
+
work_order: Any,
|
|
1052
|
+
submission: Any,
|
|
1053
|
+
job_payload: Any,
|
|
1054
|
+
*,
|
|
1055
|
+
operation_guard: Callable[[], Any] | None = None,
|
|
1056
|
+
):
|
|
1057
|
+
"""Verify and persist one current qualified-native submission."""
|
|
1058
|
+
return _REFERENCE_INTAKE.accept_native_reference_submission(
|
|
1059
|
+
self.input_resolver.reference_store,
|
|
1060
|
+
work_order,
|
|
1061
|
+
submission,
|
|
1062
|
+
job_payload,
|
|
1063
|
+
self.policy,
|
|
1064
|
+
self.input_resolver.native_reference_route_id,
|
|
1065
|
+
native_reference_verifier=self.native_reference_verifier,
|
|
1066
|
+
evidence_authority=self.evidence_authority,
|
|
1067
|
+
operation_guard=operation_guard,
|
|
1068
|
+
now=self.clock(),
|
|
1069
|
+
)
|
|
1070
|
+
|
|
1071
|
+
def health(self, *, now: Any, stale_after_seconds: Any = 3600):
|
|
1072
|
+
return self.campaign_store.health(
|
|
1073
|
+
self.policy,
|
|
1074
|
+
self.campaign_id,
|
|
1075
|
+
self.evidence_authority,
|
|
1076
|
+
now=now,
|
|
1077
|
+
stale_after_seconds=stale_after_seconds,
|
|
1078
|
+
)
|
|
1079
|
+
|
|
1080
|
+
def load_report(self):
|
|
1081
|
+
"""Return the stored, reverified report without signing or writes."""
|
|
1082
|
+
return self.campaign_store.load_report(
|
|
1083
|
+
self.policy,
|
|
1084
|
+
self.campaign_id,
|
|
1085
|
+
self.evidence_authority,
|
|
1086
|
+
now=self.clock(),
|
|
1087
|
+
)
|
|
1088
|
+
|
|
1089
|
+
def summarize(
|
|
1090
|
+
self, *, operation_guard: Callable[[float], Any] | None = None,
|
|
1091
|
+
lease_seconds: Any = 300,
|
|
1092
|
+
):
|
|
1093
|
+
if operation_guard is not None and not callable(operation_guard):
|
|
1094
|
+
raise TypeError("operation_guard must be callable")
|
|
1095
|
+
lease_seconds = _CAMPAIGN._duration(lease_seconds)
|
|
1096
|
+
report_guard = (
|
|
1097
|
+
None
|
|
1098
|
+
if operation_guard is None
|
|
1099
|
+
else lambda: operation_guard(lease_seconds)
|
|
1100
|
+
)
|
|
1101
|
+
return self.campaign_store.summarize(
|
|
1102
|
+
self.policy,
|
|
1103
|
+
self.campaign_id,
|
|
1104
|
+
self.evidence_authority,
|
|
1105
|
+
now=self.clock(),
|
|
1106
|
+
operation_guard=report_guard,
|
|
1107
|
+
)
|