@mutagent/helix 0.1.0-alpha.14
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/.claude/skills/mutagent-helix/SKILL.md +113 -0
- package/.claude/skills/mutagent-helix/scripts/cli/codex-transcode.ts +143 -0
- package/.claude/skills/mutagent-helix/scripts/cli/doctor.ts +111 -0
- package/.claude/skills/mutagent-helix/scripts/cli/init.ts +382 -0
- package/.claude/skills/mutagent-helix/scripts/cli/run.sh +61 -0
- package/CLAUDE.md +193 -0
- package/LICENSE +201 -0
- package/NOTICE +22 -0
- package/README.md +209 -0
- package/assets/adl-loop.svg +162 -0
- package/assets/system-status.svg +422 -0
- package/bin/mutagent-cli.mjs +9950 -0
- package/bin/mutagent-helix.mjs +78 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/CLAUDE.md +28 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/SKILL.md +138 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/assets/templates/agentspec.yaml.tpl +247 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/frameworks/doc-pins.md +53 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/principles.md +91 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/requirements.yaml +295 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/workflows/orchestrator-protocol.md +302 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/doctor.ts +116 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/init.ts +230 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/run.sh +60 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/config/resolve-spec-dir.ts +199 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/contract/agentspec.schema.ts +455 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/setup/detect.ts +67 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/validate/validate-spec.ts +93 -0
- package/mutagent-agentspec/LICENSE +201 -0
- package/mutagent-agentspec/NOTICE +19 -0
- package/mutagent-agentspec/README.md +44 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/SKILL.md +100 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/assets/agents/ai-architect.md +312 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/assets/agents/ai-engineer.md +357 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/assets/templates/build-report.md.tpl +39 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/references/principles.md +31 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/references/workflows/build-protocol.md +61 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/references/workflows/improve-handoff.md +23 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/scripts/cli/run.sh +60 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/scripts/handoff/validate-build-input.ts +72 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/scripts/sync-spec/check-sync-spec.ts +499 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/scripts/verify/spec-impl-coverage.ts +182 -0
- package/mutagent-builder/CLAUDE.md +25 -0
- package/mutagent-builder/README.md +26 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/README.md +192 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/SKILL.md +352 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/ai-architect.md +256 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/ai-engineer.md +344 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/diagnostics-analyzer.md +576 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/discovery.md +425 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/audit.json.tpl +24 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/audit.md.tpl +49 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/config.yaml.tpl +100 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/pr-body.md.tpl +56 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/report.html.tpl +327 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/README.md +27 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/iter-N-handover.md.tpl +125 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/self-diagnosis-contract.v0.1.0.yaml.tpl +234 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/spec.yaml.tpl +152 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/team.yaml.tpl +127 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/wave-N-dashboard.html.tpl +1712 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.1-nl-query.md +59 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.2-tier0-progress.md +58 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.3-analysis-progress.md +44 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.4-html-report.md +61 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.5-rca-detail.md +69 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.6-stale-warning.md +53 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.1-welcome.md +60 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.2-source-platform-picker.md +41 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.3-source-auth.md +75 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.4-target-picker.md +48 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.5-ask-tool.md +43 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.6-config-review.md +57 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.7-filter-defaults.md +52 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.8-first-run.md +59 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/examples/sample-findings.json +92 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/examples/sample-meta.json +47 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/adapter-strategy.md +75 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/config-migration.md +84 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/config.md +159 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/filter-search-matrix.md +66 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/harness-knowledge.md +22 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/memory-format.md +78 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/onboarding-decisions.yaml +187 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/operation-inventory.md +59 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/overview.md +167 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/reference.md +119 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/script-index.md +101 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-adapter-contract.md +93 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/claude-code-transcripts.md +66 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/codex-transcripts.md +78 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/codex.md +145 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/install-paths.md +57 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/langfuse.md +178 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/local-jsonl.md +55 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/openobserve.md +102 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/otel.md +63 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/cloud-rest.md +84 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-claude.md +65 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-cloud-agent-sdk.md +92 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-codex.md +72 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-cursor.md +108 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-mastra.md +77 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-opencode.md +70 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/apply-pr-comment-format.md +82 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/diagnostics.md +35 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/handover-contract.md +247 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/onboarding.md +300 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/orchestrator-protocol.md +1861 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/rca.md +331 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/rendering-anatomy.md +314 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/schedule-prep.md +100 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/scope-model.md +128 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/verification-methodology.md +174 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/aggregate/sort-findings.ts +0 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/awareness/blind-spots.ts +167 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/awareness/llm-sample.ts +681 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/doctor.ts +215 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/init.ts +1013 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/install-agents.ts +350 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/run.sh +61 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/shared-templates.ts +79 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/load.ts +392 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/resolve-credential.ts +120 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/schema.ts +641 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/validate.ts +134 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/context/build-diagnosis-context.ts +417 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/context/load-context.ts +105 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/contract/types.ts +166 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/build-render-input.ts +1964 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/corpus-severity.ts +172 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/dismissal-match.ts +270 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/rank-remedies.ts +75 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/hooks/install-hooks.sh +46 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/hooks/pre-push.sh +78 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/invocation/parse-brief.ts +188 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/match.ts +114 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/paths.ts +95 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/store.ts +535 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/types.ts +181 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/lint/template-inline-js.ts +267 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/memory/append.ts +188 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/memory/read.ts +218 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/platforms/entity-context.ts +686 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/read-unitf.ts +267 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/trace.ts +1078 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/unitf-adapter.ts +0 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/unitf-types.ts +213 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/report/persist-selections.ts +174 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/report/render.ts +3254 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/run/diagnose.ts +64 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/run/session.ts +167 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/caps.ts +345 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/deep-read-gate.ts +424 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/representative.ts +584 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/scan/objection.ts +224 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/scan/trajectory.ts +489 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/self-diagnostics/dispatch.ts +135 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/self-diagnostics/probe.ts +170 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/detect.ts +307 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/ensure-cli.ts +315 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/reconfigure.ts +77 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/verify-agents.ts +207 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/slicer.ts +166 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/claude-code.ts +17 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/codex.ts +11 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/langfuse.ts +17 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/local-jsonl.ts +12 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/otel.ts +12 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/index.ts +54 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/registry.ts +45 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/types.ts +86 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/stale-detector.ts +74 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/test/render-playwright.cli.ts +477 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0/claude-code.ts +133 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0/langfuse.ts +143 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0-scan.ts +423 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/completeness-check.ts +436 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/doc-refs.ts +190 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/finalize-gate.ts +417 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/findings-contract.ts +628 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/render-js-syntax.ts +188 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/report-checklist.yaml +217 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/trace-shape.ts +262 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/wave6-checklist.ts +326 -0
- package/mutagent-diagnostics/CLAUDE.md +41 -0
- package/mutagent-diagnostics/LICENSE +201 -0
- package/mutagent-diagnostics/NOTICE +18 -0
- package/mutagent-diagnostics/README.md +343 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/SKILL.md +548 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/audit-executor.md +169 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/dataset-builder.md +160 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/discovery.md +425 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/evaluator.md +1108 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/brand/theme.css +213 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/brand/wordmark.html +9 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/context-flow-lens.md +85 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/data-lens.md +47 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/decision-lens.md +48 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/methodology-critic-lens.md +53 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/trajectory-lens.md +44 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/build-review-interface.md +83 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/edd-loop.md +134 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/error-analysis.md +113 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/eval-audit.md +154 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/eval-stage.md +168 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/generate-synthetic-data.md +81 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/grounded-adjudication.md +221 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/memory-format.md +65 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/methodology.md +201 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/operation-inventory.md +197 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/validate-evaluator.md +125 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/workflows/orchestrator-protocol.md +300 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/write-judge-prompt.md +123 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/behavior-tree.schema.yaml +73 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/dataset.schema.yaml +66 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/edd-change-request.schema.yaml +114 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/eval-matrix.schema.yaml +74 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/flow-graph.schema.yaml +69 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/flow-profile.schema.yaml +49 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/methodology-review.schema.yaml +40 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/scorecard.schema.yaml +85 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/agent-dispatch.ts +0 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/aggregate-discover.ts +543 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/artifact-paths.ts +115 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/assemble-scorecard.ts +172 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-dataset.ts +186 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-evals.ts +93 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-review-ui.ts +393 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/check-method-router.ts +170 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/aggregate.ts +112 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/audit-run.ts +182 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/doctor.ts +211 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/dogfood.ts +133 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/init.ts +601 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/methodology-review.ts +122 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/prep.ts +295 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/profile-subject.ts +165 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/run.sh +56 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/variance-check.ts +105 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/code-eval.ts +248 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/code-quality-verdict.ts +285 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/codegen-evals.ts +173 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cold-start-project.ts +151 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cold-start-sampler.ts +267 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/config/load.ts +343 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/config/schema.ts +380 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/agentspec-evals.ts +85 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/dataset.ts +149 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-engine.ts +118 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-matrix.ts +577 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-types.ts +1074 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/flow-graph.ts +194 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/types.ts +303 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/validation.ts +193 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/derive-dataset.ts +152 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/determine-outcome.ts +219 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/diff-discriminate.ts +160 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/discover-criteria.ts +348 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/change-request.ts +232 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/edd-types.ts +210 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/variance-gate.ts +186 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/emit-completeness.ts +111 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/eval-engine.ts +160 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/evaluate.ts +333 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/flow-graph.ts +230 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/judge-prompt-template.ts +253 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/judge-provider.ts +135 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/lint-grounding.ts +229 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/lint-uniformity.ts +168 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/living-suite.ts +109 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-bundle.ts +203 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-profile-vocab.ts +64 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-profile.ts +106 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/mask.ts +138 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/materialize-dataset.ts +113 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/matrix-judge.ts +750 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/memory/append.ts +215 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/memory/read.ts +168 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/persist-eval-criteria.ts +232 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/prep-tasks.ts +125 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/profile-subject.ts +310 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/publish-report.ts +131 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/read-unitf-traces.ts +81 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-build-cards.ts +195 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-discover-report.ts +1640 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-eval-report.ts +3838 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-report.ts +212 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/resolve-credential.ts +110 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/resolve-ref.ts +98 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/result-verify.ts +129 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/route-failures.ts +330 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-deterministic.ts +367 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-evaluate.ts +719 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-judge.ts +155 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-pipeline.ts +175 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/sample-traces.ts +210 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/self-audit.ts +387 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/source-map.ts +106 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/subject-profile.ts +134 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/substrate.ts +162 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/sync-eval-criteria.ts +244 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/ui-slots.ts +119 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/unitf-to-evaltrace.ts +284 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/validate-judge.ts +358 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/variance-compare.ts +177 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/behavior-tree.yaml +140 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/eval-matrix.yaml +1270 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/methodology-review.yaml +105 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/audit.workflow.js +82 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/data-leak.workflow.js +236 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/variance.workflow.js +163 -0
- package/mutagent-evaluator/CLAUDE.md +45 -0
- package/mutagent-evaluator/LICENSE +201 -0
- package/mutagent-evaluator/NOTICE +23 -0
- package/mutagent-evaluator/README.md +88 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/SKILL.md +287 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/contracts/amend-request.ts +503 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/improve-loop-run.ts +304 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/loop-state-cli.ts +300 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/loop-state.ts +440 -0
- package/mutagent-optimize/CLAUDE.md +49 -0
- package/mutagent-optimize/README.md +26 -0
- package/mutagent-orchestrator/CLAUDE.md +102 -0
- package/mutagent-orchestrator/README.md +20 -0
- package/mutagent-orchestrator/assets/agents/discovery.md +425 -0
- package/mutagent-orchestrator/assets/agents/dogfood-monitor.md +266 -0
- package/mutagent-orchestrator/assets/agents/monitor.md +258 -0
- package/mutagent-orchestrator/orchestrator.md +782 -0
- package/mutagent-orchestrator/references/MONITORING.md +209 -0
- package/mutagent-orchestrator/references/config-fields.md +132 -0
- package/mutagent-orchestrator/references/config-migration.md +132 -0
- package/mutagent-orchestrator/references/index-registry.md +92 -0
- package/mutagent-orchestrator/routing.yaml +391 -0
- package/mutagent-orchestrator/scripts/config-schema.ts +1010 -0
- package/mutagent-orchestrator/scripts/dispatch.ts +439 -0
- package/mutagent-orchestrator/scripts/dogfood/extract-feedback.ts +203 -0
- package/mutagent-orchestrator/scripts/dogfood/reconstruct-trajectory.ts +327 -0
- package/mutagent-orchestrator/scripts/dogfood/render-dogfood-report.ts +347 -0
- package/mutagent-orchestrator/scripts/dogfood/resolve-subagents.ts +160 -0
- package/mutagent-orchestrator/scripts/dogfood/run-report.ts +264 -0
- package/mutagent-orchestrator/scripts/dogfood/slack-thread.ts +106 -0
- package/mutagent-orchestrator/scripts/dogfood/types.ts +257 -0
- package/mutagent-orchestrator/scripts/eval-routing.ts +753 -0
- package/mutagent-orchestrator/scripts/gate.ts +219 -0
- package/mutagent-orchestrator/scripts/handover-contract.ts +362 -0
- package/mutagent-orchestrator/scripts/index/build-index.ts +351 -0
- package/mutagent-orchestrator/scripts/index/render-index.ts +110 -0
- package/mutagent-orchestrator/scripts/monitor/slack-notify.ts +111 -0
- package/mutagent-orchestrator/scripts/monitor/triggers.ts +162 -0
- package/mutagent-orchestrator/scripts/onboarding-check.ts +369 -0
- package/mutagent-orchestrator/scripts/render-roster.ts +308 -0
- package/mutagent-orchestrator/scripts/resolve-credential.ts +185 -0
- package/mutagent-orchestrator/scripts/resolve-paths.ts +114 -0
- package/mutagent-orchestrator/scripts/slack/format.ts +63 -0
- package/mutagent-orchestrator/scripts/slack/post.ts +115 -0
- package/mutagent-orchestrator/scripts/sync-index.ts +311 -0
- package/package.json +64 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scripts/contracts/flow-graph.ts — W3-OWN contracts (EV-032 / EV-037).
|
|
3
|
+
* ---------------------------------------------------------------------------
|
|
4
|
+
* The information-flow graph (EV-032) + the expected-flow profile (EV-037) the
|
|
5
|
+
* W3 context-flow audit reasons over. DELIBERATELY a SEPARATE contract file from
|
|
6
|
+
* `contracts/eval-types.ts` (the shared W1 surface) and `contracts/types.ts`
|
|
7
|
+
* (the v1 auditor surface): the flow-graph is a NEW W3 capability, kept disjoint
|
|
8
|
+
* so the shared types stay frozen while this grows (mirrors the eval-types.ts
|
|
9
|
+
* rationale).
|
|
10
|
+
*
|
|
11
|
+
* Design invariants (mirror the package's pure-core style):
|
|
12
|
+
* - Pure data shapes + categorical constants (no magic strings).
|
|
13
|
+
* - SUBJECT-AGNOSTIC: a flow-graph names producers/consumers by the trace's
|
|
14
|
+
* OWN observation names; the expected-flow's dispatch/UI vocabulary is
|
|
15
|
+
* SUPPLIED (auto-gen EV-049 or authored) — never a module constant.
|
|
16
|
+
* - No clock / random / network: a flow-graph is a pure function of a trace.
|
|
17
|
+
*/
|
|
18
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
19
|
+
import { Value } from "@sinclair/typebox/value";
|
|
20
|
+
|
|
21
|
+
// ── Edge kind (no magic strings) ─────────────────────────────────────────────
|
|
22
|
+
export const FlowEdgeKind = {
|
|
23
|
+
/** A producer's output value reaches a later consumer's input (EV-028). */
|
|
24
|
+
Threaded: "threaded",
|
|
25
|
+
/** The producer is a sub-agent DISPATCH; the edge is a context handoff (EV-029). */
|
|
26
|
+
Handoff: "handoff",
|
|
27
|
+
} as const;
|
|
28
|
+
export type FlowEdgeKindValue = (typeof FlowEdgeKind)[keyof typeof FlowEdgeKind];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One node in the flow-graph: a single trace observation viewed as a
|
|
32
|
+
* producer/consumer of named data slots.
|
|
33
|
+
* - `produces` / `consumes` are the top-level slot KEYS of the observation's
|
|
34
|
+
* output / input (deterministic structural extraction). A primitive payload
|
|
35
|
+
* surfaces as the sentinel slot `VALUE_SLOT` / `TEXT_SLOT`.
|
|
36
|
+
* - `isHandoff` marks a sub-agent dispatch (name ∈ injected dispatchToolNames).
|
|
37
|
+
*/
|
|
38
|
+
export interface FlowNode {
|
|
39
|
+
id: string;
|
|
40
|
+
index: number;
|
|
41
|
+
type: string;
|
|
42
|
+
name: string;
|
|
43
|
+
produces: string[];
|
|
44
|
+
consumes: string[];
|
|
45
|
+
isHandoff: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A data-handoff edge: producer slot `slot` at `from` reached consumer `to`. */
|
|
49
|
+
export interface FlowEdge {
|
|
50
|
+
from: string;
|
|
51
|
+
to: string;
|
|
52
|
+
slot: string;
|
|
53
|
+
kind: FlowEdgeKindValue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A producer slot whose value NEVER reached a downstream consumer (EV-028 candidate). */
|
|
57
|
+
export interface UnthreadedOutput {
|
|
58
|
+
node: string;
|
|
59
|
+
name: string;
|
|
60
|
+
slot: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The full information-flow graph for ONE trace. PURE function of the trace. */
|
|
64
|
+
export interface FlowGraph {
|
|
65
|
+
traceId: string;
|
|
66
|
+
nodes: FlowNode[];
|
|
67
|
+
edges: FlowEdge[];
|
|
68
|
+
unthreadedOutputs: UnthreadedOutput[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Sentinel slot names for primitive (non-object) payloads. NOT subject vocab. */
|
|
72
|
+
export const VALUE_SLOT = "_value";
|
|
73
|
+
export const TEXT_SLOT = "_text";
|
|
74
|
+
|
|
75
|
+
// ── Expected-flow profile (EV-037) ───────────────────────────────────────────
|
|
76
|
+
/**
|
|
77
|
+
* One expected producer→consumer threading the subject SHOULD exhibit. Names are
|
|
78
|
+
* the subject's OWN tool/step names (supplied, never hardcoded). `slot` is
|
|
79
|
+
* optional — when present the diff also requires that slot to thread.
|
|
80
|
+
*/
|
|
81
|
+
export interface ExpectedFlowEdge {
|
|
82
|
+
fromTool: string;
|
|
83
|
+
toTool: string;
|
|
84
|
+
slot?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The agent-shaped expected-flow spec (EV-037). SUBJECT-AGNOSTIC: every field is
|
|
89
|
+
* supplied by the subject profile (auto-gen EV-049 or authored), so the audit
|
|
90
|
+
* diffs ACTUAL flow-graph vs EXPECTED without any subject constant in the engine.
|
|
91
|
+
* - `dispatchToolNames` — which tool names are sub-agent dispatches (EV-029).
|
|
92
|
+
* - `edges` — producer→consumer threadings the subject should have.
|
|
93
|
+
* - `expectedUiSlots` — slots that SHOULD be rendered in the subject's HTML
|
|
94
|
+
* artifact (EV-039/040, the operator's missing-data case).
|
|
95
|
+
*/
|
|
96
|
+
export interface ExpectedFlow {
|
|
97
|
+
dispatchToolNames: string[];
|
|
98
|
+
edges: ExpectedFlowEdge[];
|
|
99
|
+
expectedUiSlots: string[];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Diff of an actual flow-graph against an expected-flow (deterministic). */
|
|
103
|
+
export interface ExpectedFlowDiff {
|
|
104
|
+
satisfied: ExpectedFlowEdge[];
|
|
105
|
+
missing: ExpectedFlowEdge[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ── TypeBox guards (closed objects — auditable boundary) ─────────────────────
|
|
109
|
+
export const FlowNodeSchema = Type.Object(
|
|
110
|
+
{
|
|
111
|
+
id: Type.String({ minLength: 1 }),
|
|
112
|
+
index: Type.Integer({ minimum: 0 }),
|
|
113
|
+
type: Type.String({ minLength: 1 }),
|
|
114
|
+
name: Type.String(),
|
|
115
|
+
produces: Type.Array(Type.String()),
|
|
116
|
+
consumes: Type.Array(Type.String()),
|
|
117
|
+
isHandoff: Type.Boolean(),
|
|
118
|
+
},
|
|
119
|
+
{ additionalProperties: false },
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
export const FlowEdgeSchema = Type.Object(
|
|
123
|
+
{
|
|
124
|
+
from: Type.String({ minLength: 1 }),
|
|
125
|
+
to: Type.String({ minLength: 1 }),
|
|
126
|
+
slot: Type.String({ minLength: 1 }),
|
|
127
|
+
kind: Type.Union([
|
|
128
|
+
Type.Literal(FlowEdgeKind.Threaded),
|
|
129
|
+
Type.Literal(FlowEdgeKind.Handoff),
|
|
130
|
+
]),
|
|
131
|
+
},
|
|
132
|
+
{ additionalProperties: false },
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
export const UnthreadedOutputSchema = Type.Object(
|
|
136
|
+
{
|
|
137
|
+
node: Type.String({ minLength: 1 }),
|
|
138
|
+
name: Type.String(),
|
|
139
|
+
slot: Type.String({ minLength: 1 }),
|
|
140
|
+
},
|
|
141
|
+
{ additionalProperties: false },
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
export const FlowGraphSchema = Type.Object(
|
|
145
|
+
{
|
|
146
|
+
traceId: Type.String(),
|
|
147
|
+
nodes: Type.Array(FlowNodeSchema),
|
|
148
|
+
edges: Type.Array(FlowEdgeSchema),
|
|
149
|
+
unthreadedOutputs: Type.Array(UnthreadedOutputSchema),
|
|
150
|
+
},
|
|
151
|
+
{ additionalProperties: false },
|
|
152
|
+
);
|
|
153
|
+
export type FlowGraphStatic = Static<typeof FlowGraphSchema>;
|
|
154
|
+
|
|
155
|
+
export const ExpectedFlowEdgeSchema = Type.Object(
|
|
156
|
+
{
|
|
157
|
+
fromTool: Type.String({ minLength: 1 }),
|
|
158
|
+
toTool: Type.String({ minLength: 1 }),
|
|
159
|
+
slot: Type.Optional(Type.String({ minLength: 1 })),
|
|
160
|
+
},
|
|
161
|
+
{ additionalProperties: false },
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
export const ExpectedFlowSchema = Type.Object(
|
|
165
|
+
{
|
|
166
|
+
dispatchToolNames: Type.Array(Type.String({ minLength: 1 })),
|
|
167
|
+
edges: Type.Array(ExpectedFlowEdgeSchema),
|
|
168
|
+
expectedUiSlots: Type.Array(Type.String({ minLength: 1 })),
|
|
169
|
+
},
|
|
170
|
+
{ additionalProperties: false },
|
|
171
|
+
);
|
|
172
|
+
export type ExpectedFlowStatic = Static<typeof ExpectedFlowSchema>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Validate + narrow an unknown value to `ExpectedFlow` (guarded-parse style).
|
|
176
|
+
* THROWS with the first schema error — a malformed authored/loaded expected-flow
|
|
177
|
+
* must never silently reach the audit.
|
|
178
|
+
*/
|
|
179
|
+
export function parseExpectedFlow(value: unknown): ExpectedFlow {
|
|
180
|
+
if (!Value.Check(ExpectedFlowSchema, value)) {
|
|
181
|
+
const first = [...Value.Errors(ExpectedFlowSchema, value)][0];
|
|
182
|
+
const where = first?.path ?? "(root)";
|
|
183
|
+
const msg = first?.message ?? "does not match ExpectedFlow";
|
|
184
|
+
throw new Error(`parseExpectedFlow: invalid expected-flow at ${where}: ${msg}`);
|
|
185
|
+
}
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** An empty expected-flow (no constraints) — the EV-049 pre-authoring default. */
|
|
190
|
+
export const EMPTY_EXPECTED_FLOW: ExpectedFlow = {
|
|
191
|
+
dispatchToolNames: [],
|
|
192
|
+
edges: [],
|
|
193
|
+
expectedUiSlots: [],
|
|
194
|
+
};
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scripts/contracts/types.ts
|
|
3
|
+
* ---------------------------------------------------------------------------
|
|
4
|
+
* Canonical TypeBox contracts + exported TS types for the generic evaluator
|
|
5
|
+
* engine. These are the single source of truth that load-bundle / run-
|
|
6
|
+
* deterministic / assemble-scorecard / variance-compare / render-report all
|
|
7
|
+
* consume — no downstream guessing.
|
|
8
|
+
*
|
|
9
|
+
* Kept in lockstep with the human-readable shape contracts under schemas/*.yaml.
|
|
10
|
+
*/
|
|
11
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
12
|
+
|
|
13
|
+
// ── Categorical constants (no magic strings — coding-rules) ─────────────────
|
|
14
|
+
export const Dimension = {
|
|
15
|
+
OperationCorrectness: "operation-correctness",
|
|
16
|
+
DataCorrectness: "data-correctness",
|
|
17
|
+
OperationalDeviation: "operational-deviation",
|
|
18
|
+
} as const;
|
|
19
|
+
export type DimensionValue = (typeof Dimension)[keyof typeof Dimension];
|
|
20
|
+
|
|
21
|
+
export const CheckMethod = {
|
|
22
|
+
DeterministicScript: "deterministic-script",
|
|
23
|
+
TypeboxSchema: "typebox-schema",
|
|
24
|
+
Gate: "gate",
|
|
25
|
+
TraceCrossRef: "trace-cross-ref",
|
|
26
|
+
TrajectoryDiff: "trajectory-diff",
|
|
27
|
+
// SF-2 (DEC-16) — additive generic content-judge checkMethod. Judge-track (it is
|
|
28
|
+
// NOT in DETERMINISTIC_CHECK_METHODS, so trackForCheckMethod routes it to Judge).
|
|
29
|
+
// Lets a v1 eval-matrix row be a generic LLM content judge, not only the
|
|
30
|
+
// diagnostics-specific trace-cross-ref / trajectory-diff. v2 MinedCriterion carries
|
|
31
|
+
// its own 3-value router (eval-types.ts check_method); the two coexist.
|
|
32
|
+
LlmJudge: "llm-judge",
|
|
33
|
+
} as const;
|
|
34
|
+
export type CheckMethodValue = (typeof CheckMethod)[keyof typeof CheckMethod];
|
|
35
|
+
|
|
36
|
+
export const Severity = {
|
|
37
|
+
Crit: "CRIT",
|
|
38
|
+
High: "HIGH",
|
|
39
|
+
Med: "MED",
|
|
40
|
+
Low: "LOW",
|
|
41
|
+
} as const;
|
|
42
|
+
export type SeverityValue = (typeof Severity)[keyof typeof Severity];
|
|
43
|
+
|
|
44
|
+
export const ExistingCoverage = {
|
|
45
|
+
Covered: "covered",
|
|
46
|
+
Partial: "partial",
|
|
47
|
+
None: "none",
|
|
48
|
+
} as const;
|
|
49
|
+
export type ExistingCoverageValue =
|
|
50
|
+
(typeof ExistingCoverage)[keyof typeof ExistingCoverage];
|
|
51
|
+
|
|
52
|
+
export const Track = {
|
|
53
|
+
Deterministic: "deterministic",
|
|
54
|
+
Judge: "judge",
|
|
55
|
+
} as const;
|
|
56
|
+
export type TrackValue = (typeof Track)[keyof typeof Track];
|
|
57
|
+
|
|
58
|
+
export const RowResult = {
|
|
59
|
+
Pass: "pass",
|
|
60
|
+
Fail: "fail",
|
|
61
|
+
Skip: "skip",
|
|
62
|
+
/** GA — a CRIT/HIGH criterion that adjudicated indeterminate (uncertain). It
|
|
63
|
+
* does NOT fail the component but blocks certification ⇒ component/run
|
|
64
|
+
* `incomplete`. Additive; the v1 audit path never emits it (back-compat). */
|
|
65
|
+
Incomplete: "incomplete",
|
|
66
|
+
} as const;
|
|
67
|
+
export type RowResultValue = (typeof RowResult)[keyof typeof RowResult];
|
|
68
|
+
|
|
69
|
+
/** GA — the run/component ternary lattice `fail ▸ incomplete ▸ pass`. */
|
|
70
|
+
export const RunVerdict = {
|
|
71
|
+
Pass: "pass",
|
|
72
|
+
Fail: "fail",
|
|
73
|
+
Incomplete: "incomplete",
|
|
74
|
+
} as const;
|
|
75
|
+
export type RunVerdictValue = (typeof RunVerdict)[keyof typeof RunVerdict];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The deterministic-vs-judge split is a pure function of checkMethod
|
|
79
|
+
* (decision #4): deterministic-script | typebox-schema | gate run with NO
|
|
80
|
+
* model; trace-cross-ref | trajectory-diff run under the pinned judge.
|
|
81
|
+
*/
|
|
82
|
+
export const DETERMINISTIC_CHECK_METHODS: ReadonlySet<string> = new Set([
|
|
83
|
+
CheckMethod.DeterministicScript,
|
|
84
|
+
CheckMethod.TypeboxSchema,
|
|
85
|
+
CheckMethod.Gate,
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
export function trackForCheckMethod(checkMethod: string): TrackValue {
|
|
89
|
+
return DETERMINISTIC_CHECK_METHODS.has(checkMethod)
|
|
90
|
+
? Track.Deterministic
|
|
91
|
+
: Track.Judge;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── Eval-matrix (subject profile) ───────────────────────────────────────────
|
|
95
|
+
export const CriterionSchema = Type.Object(
|
|
96
|
+
{
|
|
97
|
+
dimension: Type.Union([
|
|
98
|
+
Type.Literal(Dimension.OperationCorrectness),
|
|
99
|
+
Type.Literal(Dimension.DataCorrectness),
|
|
100
|
+
Type.Literal(Dimension.OperationalDeviation),
|
|
101
|
+
]),
|
|
102
|
+
statement: Type.String({ minLength: 1 }),
|
|
103
|
+
checkMethod: Type.Union([
|
|
104
|
+
Type.Literal(CheckMethod.DeterministicScript),
|
|
105
|
+
Type.Literal(CheckMethod.TypeboxSchema),
|
|
106
|
+
Type.Literal(CheckMethod.Gate),
|
|
107
|
+
Type.Literal(CheckMethod.TraceCrossRef),
|
|
108
|
+
Type.Literal(CheckMethod.TrajectoryDiff),
|
|
109
|
+
Type.Literal(CheckMethod.LlmJudge), // SF-2 additive (DEC-16)
|
|
110
|
+
]),
|
|
111
|
+
passCondition: Type.String({ minLength: 1 }),
|
|
112
|
+
severity: Type.Union([
|
|
113
|
+
Type.Literal(Severity.Crit),
|
|
114
|
+
Type.Literal(Severity.High),
|
|
115
|
+
Type.Literal(Severity.Med),
|
|
116
|
+
Type.Literal(Severity.Low),
|
|
117
|
+
]),
|
|
118
|
+
existingCoverage: Type.Union([
|
|
119
|
+
Type.Literal(ExistingCoverage.Covered),
|
|
120
|
+
Type.Literal(ExistingCoverage.Partial),
|
|
121
|
+
Type.Literal(ExistingCoverage.None),
|
|
122
|
+
]),
|
|
123
|
+
evidenceSource: Type.Optional(Type.String()),
|
|
124
|
+
},
|
|
125
|
+
{ additionalProperties: false },
|
|
126
|
+
);
|
|
127
|
+
export type Criterion = Static<typeof CriterionSchema>;
|
|
128
|
+
|
|
129
|
+
export const ComponentSchema = Type.Object(
|
|
130
|
+
{
|
|
131
|
+
componentId: Type.String({ minLength: 1 }),
|
|
132
|
+
componentName: Type.String({ minLength: 1 }),
|
|
133
|
+
componentType: Type.Union([
|
|
134
|
+
Type.Literal("agent"),
|
|
135
|
+
Type.Literal("skill-orchestrator-step"),
|
|
136
|
+
Type.Literal("star-command"),
|
|
137
|
+
Type.Literal("script"),
|
|
138
|
+
Type.Literal("gate"),
|
|
139
|
+
// SF-1 additive — product-feature / pipeline-stage component kinds (a
|
|
140
|
+
// multi-stage generation subject is a CHAIN of stages; §6a).
|
|
141
|
+
Type.Literal("feature"),
|
|
142
|
+
Type.Literal("pipeline-stage"),
|
|
143
|
+
]),
|
|
144
|
+
criteria: Type.Array(CriterionSchema),
|
|
145
|
+
},
|
|
146
|
+
{ additionalProperties: false },
|
|
147
|
+
);
|
|
148
|
+
export type Component = Static<typeof ComponentSchema>;
|
|
149
|
+
|
|
150
|
+
export const EvalMatrixSchema = Type.Object(
|
|
151
|
+
{
|
|
152
|
+
subject: Type.String({ minLength: 1 }),
|
|
153
|
+
version: Type.String({ minLength: 1 }),
|
|
154
|
+
generatedAt: Type.String(),
|
|
155
|
+
designPrinciples: Type.Array(Type.String()),
|
|
156
|
+
components: Type.Array(ComponentSchema),
|
|
157
|
+
},
|
|
158
|
+
{ additionalProperties: false },
|
|
159
|
+
);
|
|
160
|
+
export type EvalMatrix = Static<typeof EvalMatrixSchema>;
|
|
161
|
+
|
|
162
|
+
// ── Scorecard (two-track) ───────────────────────────────────────────────────
|
|
163
|
+
export const ScorecardCriterionSchema = Type.Object(
|
|
164
|
+
{
|
|
165
|
+
dimension: Type.String(),
|
|
166
|
+
severity: Type.String(),
|
|
167
|
+
checkMethod: Type.String(),
|
|
168
|
+
track: Type.Union([
|
|
169
|
+
Type.Literal(Track.Deterministic),
|
|
170
|
+
Type.Literal(Track.Judge),
|
|
171
|
+
]),
|
|
172
|
+
result: Type.Union([
|
|
173
|
+
Type.Literal(RowResult.Pass),
|
|
174
|
+
Type.Literal(RowResult.Fail),
|
|
175
|
+
Type.Literal(RowResult.Skip),
|
|
176
|
+
Type.Literal(RowResult.Incomplete), // GA — additive (back-compat)
|
|
177
|
+
]),
|
|
178
|
+
detail: Type.Optional(Type.String()),
|
|
179
|
+
},
|
|
180
|
+
{ additionalProperties: false },
|
|
181
|
+
);
|
|
182
|
+
export type ScorecardCriterion = Static<typeof ScorecardCriterionSchema>;
|
|
183
|
+
|
|
184
|
+
export const GateComponentSchema = Type.Object(
|
|
185
|
+
{
|
|
186
|
+
componentId: Type.String(),
|
|
187
|
+
pass: Type.Boolean(),
|
|
188
|
+
/** GA — the component ternary verdict (optional/back-compat; `pass` mirrors
|
|
189
|
+
* `verdict === "pass"`). `incomplete` when a CRIT/HIGH row is indeterminate. */
|
|
190
|
+
verdict: Type.Optional(
|
|
191
|
+
Type.Union([
|
|
192
|
+
Type.Literal(RunVerdict.Pass),
|
|
193
|
+
Type.Literal(RunVerdict.Fail),
|
|
194
|
+
Type.Literal(RunVerdict.Incomplete),
|
|
195
|
+
]),
|
|
196
|
+
),
|
|
197
|
+
criteria: Type.Array(ScorecardCriterionSchema),
|
|
198
|
+
},
|
|
199
|
+
{ additionalProperties: false },
|
|
200
|
+
);
|
|
201
|
+
export type GateComponent = Static<typeof GateComponentSchema>;
|
|
202
|
+
|
|
203
|
+
export const TrendDimensionSchema = Type.Object(
|
|
204
|
+
{
|
|
205
|
+
name: Type.String(),
|
|
206
|
+
measure: Type.String(),
|
|
207
|
+
target: Type.String(),
|
|
208
|
+
divergence: Type.Union([
|
|
209
|
+
Type.Literal("identical"),
|
|
210
|
+
Type.Literal("within-target"),
|
|
211
|
+
Type.Literal("diverged"),
|
|
212
|
+
Type.Literal("not-evaluated"),
|
|
213
|
+
]),
|
|
214
|
+
},
|
|
215
|
+
{ additionalProperties: false },
|
|
216
|
+
);
|
|
217
|
+
export type TrendDimension = Static<typeof TrendDimensionSchema>;
|
|
218
|
+
|
|
219
|
+
// Coverage honesty (EV-OUT-002): graded-vs-total + skip-rate warning. Optional
|
|
220
|
+
// so older scorecards (without it) still validate; warning-only — never gates.
|
|
221
|
+
export const CoverageSchema = Type.Object(
|
|
222
|
+
{
|
|
223
|
+
graded: Type.Integer(),
|
|
224
|
+
total: Type.Integer(),
|
|
225
|
+
skipped: Type.Integer(),
|
|
226
|
+
skipRate: Type.Number(),
|
|
227
|
+
skipRateWarnThreshold: Type.Number(),
|
|
228
|
+
coverageWarning: Type.Boolean(),
|
|
229
|
+
},
|
|
230
|
+
{ additionalProperties: false },
|
|
231
|
+
);
|
|
232
|
+
export type Coverage = Static<typeof CoverageSchema>;
|
|
233
|
+
|
|
234
|
+
export const ScorecardSchema = Type.Object(
|
|
235
|
+
{
|
|
236
|
+
subject: Type.String(),
|
|
237
|
+
runId: Type.String(),
|
|
238
|
+
generatedAt: Type.String(),
|
|
239
|
+
coverage: Type.Optional(CoverageSchema),
|
|
240
|
+
gate: Type.Object(
|
|
241
|
+
{
|
|
242
|
+
runPass: Type.Boolean(),
|
|
243
|
+
/** GA — the ternary run verdict `fail ▸ incomplete ▸ pass` (optional/
|
|
244
|
+
* back-compat; `runPass` is `runVerdict === "pass"`). */
|
|
245
|
+
runVerdict: Type.Optional(
|
|
246
|
+
Type.Union([
|
|
247
|
+
Type.Literal(RunVerdict.Pass),
|
|
248
|
+
Type.Literal(RunVerdict.Fail),
|
|
249
|
+
Type.Literal(RunVerdict.Incomplete),
|
|
250
|
+
]),
|
|
251
|
+
),
|
|
252
|
+
components: Type.Array(GateComponentSchema),
|
|
253
|
+
totals: Type.Object(
|
|
254
|
+
{
|
|
255
|
+
pass: Type.Integer(),
|
|
256
|
+
fail: Type.Integer(),
|
|
257
|
+
skip: Type.Integer(),
|
|
258
|
+
critFail: Type.Integer(),
|
|
259
|
+
highFail: Type.Integer(),
|
|
260
|
+
/** GA — CRIT/HIGH indeterminate count (optional/back-compat). */
|
|
261
|
+
incomplete: Type.Optional(Type.Integer()),
|
|
262
|
+
},
|
|
263
|
+
{ additionalProperties: false },
|
|
264
|
+
),
|
|
265
|
+
},
|
|
266
|
+
{ additionalProperties: false },
|
|
267
|
+
),
|
|
268
|
+
trend: Type.Object(
|
|
269
|
+
{
|
|
270
|
+
runPair: Type.Optional(
|
|
271
|
+
Type.Object(
|
|
272
|
+
{ a: Type.String(), b: Type.String() },
|
|
273
|
+
{ additionalProperties: false },
|
|
274
|
+
),
|
|
275
|
+
),
|
|
276
|
+
dimensions: Type.Array(TrendDimensionSchema),
|
|
277
|
+
varianceScore: Type.Number(),
|
|
278
|
+
},
|
|
279
|
+
{ additionalProperties: false },
|
|
280
|
+
),
|
|
281
|
+
},
|
|
282
|
+
{ additionalProperties: false },
|
|
283
|
+
);
|
|
284
|
+
export type Scorecard = Static<typeof ScorecardSchema>;
|
|
285
|
+
|
|
286
|
+
// ── Run-bundle (the audited run's artifacts) ────────────────────────────────
|
|
287
|
+
/**
|
|
288
|
+
* The validated audit input produced by load-bundle.ts. A run-bundle is a
|
|
289
|
+
* .mutagent/diagnostics/{runId}/ directory. The evaluator is subject-agnostic:
|
|
290
|
+
* it loads whatever artifacts the subject's run produced and exposes them as a
|
|
291
|
+
* flat, validated map. Only `runId` is structurally required; everything else
|
|
292
|
+
* is best-effort per the subject.
|
|
293
|
+
*/
|
|
294
|
+
export interface RunBundle {
|
|
295
|
+
runId: string;
|
|
296
|
+
bundleDir: string;
|
|
297
|
+
/** absolute paths to artifact files discovered in the bundle */
|
|
298
|
+
artifacts: Record<string, string>;
|
|
299
|
+
/** parsed JSON artifacts keyed by logical name (runMeta, tracesMetadata, ...) */
|
|
300
|
+
data: Record<string, unknown>;
|
|
301
|
+
/** non-fatal load warnings (missing-but-optional artifacts) */
|
|
302
|
+
warnings: string[];
|
|
303
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scripts/contracts/validation.ts — the W2 TRUST-layer data contracts.
|
|
3
|
+
* ---------------------------------------------------------------------------
|
|
4
|
+
* The executable (TypeBox) companion for the W2 trust track:
|
|
5
|
+
* - `HumanLabel` — one ground-truth annotation produced by `*review`
|
|
6
|
+
* (`scripts/build-review-ui.ts`) and consumed by `*validate`
|
|
7
|
+
* (`scripts/validate-judge.ts`). This is the human-judgment a judge is
|
|
8
|
+
* calibrated AGAINST (validate-evaluator.md TPR/TNR).
|
|
9
|
+
*
|
|
10
|
+
* Strict austerity (operator directive): this file is **Type A — data contract
|
|
11
|
+
* only**. It holds NO judge prompt, NO LLM-reasoning, makes NO pass/fail
|
|
12
|
+
* decision. It only declares + validates the label shapes the deterministic
|
|
13
|
+
* scripts read/write. PURE — no clock / random / network.
|
|
14
|
+
*
|
|
15
|
+
* Disjointness (W2-OWN): this is a NEW W2 contract file. It does NOT touch the
|
|
16
|
+
* shared `contracts/eval-types.ts` (W3 may touch shared types — kept out of it).
|
|
17
|
+
* The confusion-matrix / validation-result shapes (`*validate` numbers) are
|
|
18
|
+
* appended to this same file by the W2 *validate task.
|
|
19
|
+
*/
|
|
20
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
21
|
+
import { Value } from "@sinclair/typebox/value";
|
|
22
|
+
|
|
23
|
+
// ── HumanLabel verdict (the annotation the reviewer picks) ───────────────────
|
|
24
|
+
//
|
|
25
|
+
// Mirrors the determiner's OutcomeVerdict closed set (pass/fail) PLUS `defer`
|
|
26
|
+
// — the review UI's third button for genuinely uncertain traces. A deferred
|
|
27
|
+
// label is NOT a judgment: it is excluded from TPR/TNR (it provides no ground
|
|
28
|
+
// truth), and it drives uncertainty resampling. We keep the set local to the
|
|
29
|
+
// trust layer rather than importing OutcomeVerdict, because `defer` is a
|
|
30
|
+
// review-UI concept (a human punting), not a determiner outcome.
|
|
31
|
+
export const HumanVerdict = {
|
|
32
|
+
Pass: "pass",
|
|
33
|
+
Fail: "fail",
|
|
34
|
+
/** reviewer is uncertain — excluded from confusion-matrix math, never coerced. */
|
|
35
|
+
Defer: "defer",
|
|
36
|
+
} as const;
|
|
37
|
+
export type HumanVerdictValue = (typeof HumanVerdict)[keyof typeof HumanVerdict];
|
|
38
|
+
|
|
39
|
+
// ── HumanLabel — one reviewer annotation for one trace ───────────────────────
|
|
40
|
+
export const HumanLabelSchema = Type.Object(
|
|
41
|
+
{
|
|
42
|
+
/** the trace this label judges. */
|
|
43
|
+
traceId: Type.String({ minLength: 1 }),
|
|
44
|
+
/** the reviewer's binary verdict (or `defer`). */
|
|
45
|
+
label: Type.Union([
|
|
46
|
+
Type.Literal(HumanVerdict.Pass),
|
|
47
|
+
Type.Literal(HumanVerdict.Fail),
|
|
48
|
+
Type.Literal(HumanVerdict.Defer),
|
|
49
|
+
]),
|
|
50
|
+
/** free-text note describing what went wrong/right (build-review-interface.md). */
|
|
51
|
+
notes: Type.Optional(Type.String()),
|
|
52
|
+
/**
|
|
53
|
+
* which data SPLIT this labeled trace belongs to (train/dev/test). Carried so
|
|
54
|
+
* `*validate` can enforce split-disjointness + the test-once guard. Optional —
|
|
55
|
+
* the review UI may collect labels before the split is assigned.
|
|
56
|
+
*/
|
|
57
|
+
split: Type.Optional(
|
|
58
|
+
Type.Union([Type.Literal("train"), Type.Literal("dev"), Type.Literal("test")]),
|
|
59
|
+
),
|
|
60
|
+
/** the annotator id (for two-annotator agreement). Optional. */
|
|
61
|
+
annotator: Type.Optional(Type.String()),
|
|
62
|
+
/**
|
|
63
|
+
* ISO timestamp stamped by the BROWSER on save (non-deterministic). The
|
|
64
|
+
* deterministic script core NEVER stamps this (mask discipline / C-PIN); it
|
|
65
|
+
* only round-trips + dedups by traceId. Optional so masked fixtures validate.
|
|
66
|
+
*/
|
|
67
|
+
labeledAt: Type.Optional(Type.String()),
|
|
68
|
+
},
|
|
69
|
+
{ additionalProperties: false },
|
|
70
|
+
);
|
|
71
|
+
export type HumanLabel = Static<typeof HumanLabelSchema>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Validate + parse a labels file (raw JSON text = `HumanLabel[]`). ENFORCES the
|
|
75
|
+
* schema (closed label set, traceId non-empty); THROWS on any violation — a
|
|
76
|
+
* malformed labels file is never silently accepted. PURE.
|
|
77
|
+
*/
|
|
78
|
+
export function parseHumanLabels(raw: string): HumanLabel[] {
|
|
79
|
+
let parsed: unknown;
|
|
80
|
+
try {
|
|
81
|
+
parsed = JSON.parse(raw);
|
|
82
|
+
} catch {
|
|
83
|
+
throw new Error(`parseHumanLabels: not valid JSON: ${raw.slice(0, 120)}`);
|
|
84
|
+
}
|
|
85
|
+
const schema = Type.Array(HumanLabelSchema);
|
|
86
|
+
if (!Value.Check(schema, parsed)) {
|
|
87
|
+
const first = [...Value.Errors(schema, parsed)][0];
|
|
88
|
+
throw new Error(
|
|
89
|
+
`parseHumanLabels: schema violation at '${first?.path ?? "?"}': ` +
|
|
90
|
+
`${first?.message ?? "invalid HumanLabel[]"}`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return parsed;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Assert one HumanLabel conforms (used before persisting). THROWS on violation. */
|
|
97
|
+
export function assertHumanLabel(label: unknown): asserts label is HumanLabel {
|
|
98
|
+
if (!Value.Check(HumanLabelSchema, label)) {
|
|
99
|
+
const first = [...Value.Errors(HumanLabelSchema, label)][0];
|
|
100
|
+
throw new Error(
|
|
101
|
+
`assertHumanLabel: schema violation at '${first?.path ?? "?"}': ` +
|
|
102
|
+
`${first?.message ?? "invalid HumanLabel"}`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ── *validate (EV-044) result shapes — the trust layer numbers ───────────────
|
|
108
|
+
//
|
|
109
|
+
// The output of calibrating a judge against human labels (validate-evaluator.md):
|
|
110
|
+
// a 2×2 confusion matrix → TPR/TNR → Rogan-Gladen bias-corrected true rate →
|
|
111
|
+
// bootstrap CI, with a `validated`/`unvalidated` status that degrades gracefully
|
|
112
|
+
// when there are too few human labels (the loop NEVER blocks on a human).
|
|
113
|
+
|
|
114
|
+
/** A judge's calibration status. */
|
|
115
|
+
export const ValidationStatus = {
|
|
116
|
+
/** ≥ MIN_LABELS labels AND TPR/TNR clear the target — verdicts are trusted. */
|
|
117
|
+
Validated: "validated",
|
|
118
|
+
/**
|
|
119
|
+
* too few labels OR TPR/TNR below target — the judge's aggregate rate is
|
|
120
|
+
* reported BIAS-CORRECTED (not raw) and flagged; never blocks the loop.
|
|
121
|
+
*/
|
|
122
|
+
Unvalidated: "unvalidated",
|
|
123
|
+
} as const;
|
|
124
|
+
export type ValidationStatusValue = (typeof ValidationStatus)[keyof typeof ValidationStatus];
|
|
125
|
+
|
|
126
|
+
/** 2×2 confusion matrix (Pass = positive class). `defer`/`uncertain` excluded. */
|
|
127
|
+
export const ConfusionMatrixSchema = Type.Object(
|
|
128
|
+
{
|
|
129
|
+
/** judge Pass AND human Pass. */
|
|
130
|
+
tp: Type.Integer({ minimum: 0 }),
|
|
131
|
+
/** judge Pass AND human Fail (false pass — judge too lenient). */
|
|
132
|
+
fp: Type.Integer({ minimum: 0 }),
|
|
133
|
+
/** judge Fail AND human Fail. */
|
|
134
|
+
tn: Type.Integer({ minimum: 0 }),
|
|
135
|
+
/** judge Fail AND human Pass (false fail — judge too strict). */
|
|
136
|
+
fn: Type.Integer({ minimum: 0 }),
|
|
137
|
+
},
|
|
138
|
+
{ additionalProperties: false },
|
|
139
|
+
);
|
|
140
|
+
export type ConfusionMatrix = Static<typeof ConfusionMatrixSchema>;
|
|
141
|
+
|
|
142
|
+
/** A bootstrap confidence interval for the corrected rate. */
|
|
143
|
+
export const ConfidenceIntervalSchema = Type.Object(
|
|
144
|
+
{
|
|
145
|
+
lo: Type.Number({ minimum: 0, maximum: 1 }),
|
|
146
|
+
hi: Type.Number({ minimum: 0, maximum: 1 }),
|
|
147
|
+
/** the 2-sided level (e.g. 0.95). */
|
|
148
|
+
level: Type.Number({ minimum: 0, maximum: 1 }),
|
|
149
|
+
},
|
|
150
|
+
{ additionalProperties: false },
|
|
151
|
+
);
|
|
152
|
+
export type ConfidenceInterval = Static<typeof ConfidenceIntervalSchema>;
|
|
153
|
+
|
|
154
|
+
/** The full `*validate` result for ONE judge (one criterion). */
|
|
155
|
+
export const ValidationResultSchema = Type.Object(
|
|
156
|
+
{
|
|
157
|
+
criterionId: Type.String({ minLength: 1 }),
|
|
158
|
+
/** the PINNED judge model the numbers belong to (C-PIN — re-validate on change). */
|
|
159
|
+
judgeModel: Type.String({ minLength: 1 }),
|
|
160
|
+
status: Type.Union([
|
|
161
|
+
Type.Literal(ValidationStatus.Validated),
|
|
162
|
+
Type.Literal(ValidationStatus.Unvalidated),
|
|
163
|
+
]),
|
|
164
|
+
/** total non-deferred human labels used (the calibration sample size). */
|
|
165
|
+
labelCount: Type.Integer({ minimum: 0 }),
|
|
166
|
+
/** true-positive rate (judge agrees on Pass); null when no human Pass exists. */
|
|
167
|
+
tpr: Type.Union([Type.Number({ minimum: 0, maximum: 1 }), Type.Null()]),
|
|
168
|
+
/** true-negative rate (judge agrees on Fail); null when no human Fail exists. */
|
|
169
|
+
tnr: Type.Union([Type.Number({ minimum: 0, maximum: 1 }), Type.Null()]),
|
|
170
|
+
/** observed judge Pass-rate on the unlabeled production set (p_obs). */
|
|
171
|
+
observedPassRate: Type.Union([Type.Number({ minimum: 0, maximum: 1 }), Type.Null()]),
|
|
172
|
+
/** Rogan-Gladen bias-corrected true rate; null when invalid (judge ≈ random). */
|
|
173
|
+
correctedRate: Type.Union([Type.Number({ minimum: 0, maximum: 1 }), Type.Null()]),
|
|
174
|
+
/** whether the Rogan-Gladen correction was valid (TPR+TNR−1 not ≈ 0). */
|
|
175
|
+
correctionValid: Type.Boolean(),
|
|
176
|
+
ci: Type.Optional(ConfidenceIntervalSchema),
|
|
177
|
+
/** human-readable note on the status (why unvalidated, etc.). */
|
|
178
|
+
note: Type.Optional(Type.String()),
|
|
179
|
+
},
|
|
180
|
+
{ additionalProperties: false },
|
|
181
|
+
);
|
|
182
|
+
export type ValidationResult = Static<typeof ValidationResultSchema>;
|
|
183
|
+
|
|
184
|
+
/** Assert a ValidationResult conforms (used before stamping the scorecard). THROWS. */
|
|
185
|
+
export function assertValidationResult(r: unknown): asserts r is ValidationResult {
|
|
186
|
+
if (!Value.Check(ValidationResultSchema, r)) {
|
|
187
|
+
const first = [...Value.Errors(ValidationResultSchema, r)][0];
|
|
188
|
+
throw new Error(
|
|
189
|
+
`assertValidationResult: schema violation at '${first?.path ?? "?"}': ` +
|
|
190
|
+
`${first?.message ?? "invalid ValidationResult"}`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|