@thomasminh1995/depverdict 0.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +518 -0
- package/bin/depverdict.js +7 -0
- package/bin/upgradelens.js +7 -0
- package/docs/GR-01-Semantic-Grounding-Failure-Analysis.md +309 -0
- package/docs/GR-02-Versioned-Action-Evaluation-Criteria.md +187 -0
- package/docs/GR-03-Extractive-Contract-Safety-Experiment.md +242 -0
- package/docs/GR-04-Versioned-Production-Extractive-Contract.md +154 -0
- package/docs/IA-01-Repository-Usage-Discovery.md +122 -0
- package/docs/IA-02-Repository-Impact-Analysis.md +118 -0
- package/docs/IA-03-Repository-Impact-Evidence.md +160 -0
- package/docs/IA-04-CLI-Orchestration.md +235 -0
- package/docs/IA-05-Real-Provider-Validation.md +235 -0
- package/docs/IA-05-VinGrade-Validation.md +339 -0
- package/docs/MVP-01.md +48 -0
- package/docs/MVP-02-Architecture.md +536 -0
- package/docs/MVP-02-CLI-HTTP-Runtime.md +50 -0
- package/docs/MVP-02-HTTP-Lifecycle.md +37 -0
- package/docs/MVP-02-Knowledge-Manifest-Generation.md +75 -0
- package/docs/MVP-02-Knowledge-Manifest.md +279 -0
- package/docs/MVP-02-Knowledge-Research-Orchestration.md +62 -0
- package/docs/MVP-02-Knowledge-Store.md +87 -0
- package/docs/MVP-02-PyPI-Registry-Adapter.md +97 -0
- package/docs/MVP-02-Research-Planning.md +196 -0
- package/docs/MVP-02-Source-Provenance.md +81 -0
- package/docs/MVP-02-npm-Registry-Adapter.md +99 -0
- package/docs/RR-01-End-to-End-and-Real-Provider-Validation.md +393 -0
- package/docs/RR-01-RERUN-Extractive-Contract-Validation.md +566 -0
- package/docs/RR-02-Full-Product-Workflow-and-Developer-CLI-UX-Review.md +35 -0
- package/docs/RR02-FIX-01-Persistent-Qualification-Resolution.md +32 -0
- package/docs/RR02-FIX-02-Stage-aware-CLI-Progress-and-Heartbeat.md +28 -0
- package/docs/RR02-FIX-03-npm-Capture-Evidence-Exclusion.md +33 -0
- package/docs/RR02-FIX-03A-Complete-Package-Exclusion-and-Evidence-Commit.md +223 -0
- package/docs/RR02-FIX-04-Event-loop-safe-Heartbeat.md +393 -0
- package/docs/RR02-FIX-05-Materialize-Persisted-Qualification.md +207 -0
- package/docs/RR02-RERUN-CLI-Qualification-Progress-UX-and-Package-Validation.md +342 -0
- package/docs/VinGrade-MVP-02-Validation.md +480 -0
- package/docs/VinGrade-RC02-Live-Validation.md +273 -0
- package/docs/ai-capability-discovery.md +573 -0
- package/docs/ai-engineering-production-readiness.md +390 -0
- package/docs/ai-engineering-review.md +251 -0
- package/docs/ai-runtime-governance-discovery.md +754 -0
- package/docs/architecture-overview.md +78 -0
- package/docs/cli-progress.md +111 -0
- package/docs/decisions/diff-01-brand-distribution-identity.md +450 -0
- package/docs/decisions/diff-02-identity-compatibility-contract.md +274 -0
- package/docs/decisions/diff-03-repository-docs-community-migration.md +165 -0
- package/docs/decisions/diff-04-release-evidence-gap-acceptance.md +110 -0
- package/docs/discovery/mvp-05-ai-migration-planning-discovery.md +350 -0
- package/docs/gateway-runtime-discovery.md +614 -0
- package/docs/live-ai-validation.md +299 -0
- package/docs/migration-planning-qualification-resolution.md +99 -0
- package/docs/migrations/upgradelens-to-depverdict.md +97 -0
- package/docs/mp-r03-deterministic-upgrade-decision-architecture.md +135 -0
- package/docs/mp-r04-evidence-bounded-migration-handoff-architecture.md +116 -0
- package/docs/mp-r05-product-completion-and-decision-first-cli-architecture.md +162 -0
- package/docs/mvp-05-deterministic-context-runtime.md +127 -0
- package/docs/mvp-05-migration-checklist-contract.md +166 -0
- package/docs/mvp-05-migration-checklist-orchestration.md +105 -0
- package/docs/mvp-05-migration-evaluation-and-qualification.md +135 -0
- package/docs/mvp-05-provider-neutral-generator.md +79 -0
- package/docs/ollama-local-smoke-validation.md +156 -0
- package/docs/openai-compatible-runtime-discovery.md +789 -0
- package/docs/openrouter-one-dependency-validation.md +205 -0
- package/docs/oss-02-package-guard-hardening-architecture.md +131 -0
- package/docs/oss-04-public-ci-package-metadata-architecture.md +142 -0
- package/docs/package-content-policy.md +98 -0
- package/docs/releases/v0.5.0-technical-preview.md +114 -0
- package/docs/releases/v0.6.0-alpha.1-depverdict-preview.md +101 -0
- package/docs/reviews/diff-02-identity-contract-compatibility.md +413 -0
- package/docs/reviews/diff-03-repository-docs-community-migration.md +364 -0
- package/docs/reviews/diff-04-depverdict-distribution-identity-readiness-rereview.md +453 -0
- package/docs/reviews/diff-04-fix-post-rename-identity-release-remediation.md +310 -0
- package/docs/reviews/diff-05-final-preview-distribution-qualification.md +561 -0
- package/docs/reviews/mvp-05-final-product-value-workflow-rereview.md +471 -0
- package/docs/reviews/mvp-05-product-workflow-review.md +605 -0
- package/docs/reviews/oss-01-duplicate-artifact-investigation-cleanup.md +411 -0
- package/docs/reviews/oss-02-package-guard-hardening.md +303 -0
- package/docs/reviews/oss-03-community-scaffolding.md +378 -0
- package/docs/reviews/oss-04-public-ci-package-metadata.md +439 -0
- package/docs/reviews/oss-05-technical-preview-qualification.md +482 -0
- package/docs/reviews/upgradelens-vs-upgradedepdetective-source-comparison.md +355 -0
- package/docs/reviews/v0.5.0-pre-release-smoke.md +263 -0
- package/docs/reviews/v0.5.0-version-bump-release-verification.md +306 -0
- package/docs/runtime-contract-discovery.md +521 -0
- package/docs/structured-output-compatibility-report.md +100 -0
- package/docs/ts-fix-01-exact-duplicate-occurrence-target-selection-architecture.md +111 -0
- package/docs/version-analysis-architecture.md +827 -0
- package/eval/README.md +86 -0
- package/eval/datasets/generic/declared-constraint.json +59 -0
- package/eval/datasets/generic/evidence-conflict.json +73 -0
- package/eval/datasets/generic/major-breaking-release.json +66 -0
- package/eval/datasets/generic/missing-evidence.json +46 -0
- package/eval/datasets/generic/patch-release-low.json +59 -0
- package/eval/datasets/node/axios-patch-low.json +59 -0
- package/eval/datasets/node/react-major-breaking.json +66 -0
- package/eval/datasets/node/react-minor-compatibility.json +66 -0
- package/eval/datasets/python/fastapi-deprecation.json +66 -0
- package/eval/datasets/python/pydantic-major-breaking.json +66 -0
- package/eval/migration-planning/golden-dataset-v2.json +306 -0
- package/eval/migration-planning/golden-dataset.json +214 -0
- package/eval/schemas/expected-result.schema.json +88 -0
- package/eval/schemas/golden-case.schema.json +181 -0
- package/package.json +57 -0
- package/schemas/ai-scorecard.schema.json +132 -0
- package/schemas/benchmark-report.schema.json +189 -0
- package/schemas/benchmark.schema.json +55 -0
- package/schemas/capability-profile.schema.json +44 -0
- package/schemas/conformance-report.schema.json +150 -0
- package/schemas/deployment-profile.schema.json +64 -0
- package/schemas/evaluation-report.schema.json +158 -0
- package/schemas/knowledge-evidence-bundle.schema.json +150 -0
- package/schemas/knowledge-manifest.schema.json +548 -0
- package/schemas/metrics.schema.json +178 -0
- package/schemas/migration-checklist-extractive-candidate.schema.json +42 -0
- package/schemas/migration-checklist.schema.json +706 -0
- package/schemas/migration-evaluation-dataset-v2.schema.json +208 -0
- package/schemas/migration-evaluation-dataset.schema.json +204 -0
- package/schemas/migration-planning-qualification-record.schema.json +234 -0
- package/schemas/project-manifest.schema.json +308 -0
- package/schemas/qualification-record.schema.json +56 -0
- package/schemas/repository-impact-evidence.schema.json +232 -0
- package/schemas/repository-impact.schema.json +202 -0
- package/schemas/upgrade-decision.schema.json +273 -0
- package/schemas/usage-index.schema.json +179 -0
- package/schemas/version-analysis.schema.json +449 -0
- package/src/ai-runtime-debug.js +325 -0
- package/src/ai-runtime-error.js +42 -0
- package/src/ai-runtime.js +174 -0
- package/src/ai-scorecard.js +204 -0
- package/src/ai-version-analysis.js +484 -0
- package/src/artifact-root-compatibility.js +91 -0
- package/src/benchmark-report.js +111 -0
- package/src/benchmark-runner.js +191 -0
- package/src/canonical-json.js +69 -0
- package/src/cli.js +1299 -0
- package/src/conformance-report.js +158 -0
- package/src/conformance-runner.js +253 -0
- package/src/constants.js +73 -0
- package/src/cooperative-scheduler.js +79 -0
- package/src/dependencies.js +44 -0
- package/src/dependency-ai-context.js +625 -0
- package/src/detectors.js +253 -0
- package/src/discovery.js +234 -0
- package/src/ecosystem-version-adapter.js +294 -0
- package/src/environment-compatibility.js +77 -0
- package/src/evaluation-comparator.js +158 -0
- package/src/evaluation-report.js +76 -0
- package/src/evaluation-runner.js +248 -0
- package/src/evidence-source-adapter.js +472 -0
- package/src/files.js +89 -0
- package/src/governance-diagnostics.js +64 -0
- package/src/governance-loader.js +63 -0
- package/src/governance-metadata.js +346 -0
- package/src/governance-validator.js +360 -0
- package/src/http/bounded-fetch.js +278 -0
- package/src/http/cli-http-runtime.js +44 -0
- package/src/impact/input-loader.js +157 -0
- package/src/impact/matcher.js +40 -0
- package/src/impact/repository-impact.js +199 -0
- package/src/impact/runtime.js +24 -0
- package/src/impact/status.js +62 -0
- package/src/impact/writer.js +30 -0
- package/src/impact-evidence/input-loader.js +202 -0
- package/src/impact-evidence/repository-impact-evidence.js +234 -0
- package/src/impact-evidence/runtime.js +16 -0
- package/src/impact-evidence/writer.js +30 -0
- package/src/index.js +563 -0
- package/src/installed-version-baseline.js +196 -0
- package/src/knowledge-cache.js +324 -0
- package/src/knowledge-evidence-bundle.js +101 -0
- package/src/knowledge-evidence-producer.js +233 -0
- package/src/knowledge-manifest-builder.js +188 -0
- package/src/knowledge-manifest-writer.js +32 -0
- package/src/knowledge-manifest.js +255 -0
- package/src/knowledge-research.js +615 -0
- package/src/metrics-engine.js +205 -0
- package/src/migration-checklist/ai-candidate.js +320 -0
- package/src/migration-checklist/assembler.js +37 -0
- package/src/migration-checklist/context-runtime.js +828 -0
- package/src/migration-checklist/evaluation/action-criteria.js +244 -0
- package/src/migration-checklist/evaluation/comparator-v2.js +332 -0
- package/src/migration-checklist/evaluation/comparator.js +279 -0
- package/src/migration-checklist/evaluation/dataset-v2.js +227 -0
- package/src/migration-checklist/evaluation/dataset.js +336 -0
- package/src/migration-checklist/evaluation/extractive-fixtures-v2.js +148 -0
- package/src/migration-checklist/evaluation/metrics-v2.js +226 -0
- package/src/migration-checklist/evaluation/metrics.js +158 -0
- package/src/migration-checklist/evaluation/qualification-v2.js +321 -0
- package/src/migration-checklist/evaluation/qualification.js +239 -0
- package/src/migration-checklist/evaluation/runner-v2.js +294 -0
- package/src/migration-checklist/evaluation/runner.js +194 -0
- package/src/migration-checklist/evaluation/scorecard-v2.js +106 -0
- package/src/migration-checklist/evaluation/scorecard.js +86 -0
- package/src/migration-checklist/extractive-candidate.js +166 -0
- package/src/migration-checklist/extractive-prompt.js +62 -0
- package/src/migration-checklist/generator.js +702 -0
- package/src/migration-checklist/grounding-policy.js +117 -0
- package/src/migration-checklist/input-loader.js +613 -0
- package/src/migration-checklist/migration-checklist.js +635 -0
- package/src/migration-checklist/presentation.js +292 -0
- package/src/migration-checklist/progress.js +96 -0
- package/src/migration-checklist/prompt.js +83 -0
- package/src/migration-checklist/qualification-guard.js +462 -0
- package/src/migration-checklist/qualification-resolution.js +122 -0
- package/src/migration-checklist/qualification-store.js +225 -0
- package/src/migration-checklist/runtime.js +205 -0
- package/src/migration-checklist/verification.js +134 -0
- package/src/migration-checklist/writer.js +35 -0
- package/src/openai-compatible-provider.js +451 -0
- package/src/orchestration/failure-log.js +32 -0
- package/src/orchestration/pipeline.js +200 -0
- package/src/orchestration/progress-events.js +337 -0
- package/src/orchestration/progress-reporter.js +131 -0
- package/src/orchestration/text-writer.js +22 -0
- package/src/portable.js +13 -0
- package/src/product-completion.js +249 -0
- package/src/project-manifest-input.js +90 -0
- package/src/project-manifest.js +141 -0
- package/src/python-requirements.js +137 -0
- package/src/registry/npm-packument.js +256 -0
- package/src/registry/npm-registry-adapter.js +262 -0
- package/src/registry/pypi-project.js +300 -0
- package/src/registry/pypi-registry-adapter.js +235 -0
- package/src/registry/sanitize-registry-body.js +51 -0
- package/src/renderers/console.js +160 -0
- package/src/renderers/impact-presentation.js +278 -0
- package/src/renderers/markdown.js +172 -0
- package/src/research-plan.js +455 -0
- package/src/runtime-conformance.js +275 -0
- package/src/source-provenance.js +393 -0
- package/src/source-url.js +62 -0
- package/src/structured-output-schema.js +66 -0
- package/src/target-selector.js +306 -0
- package/src/upgrade-decision/input-loader.js +107 -0
- package/src/upgrade-decision/presentation.js +43 -0
- package/src/upgrade-decision/runtime.js +21 -0
- package/src/upgrade-decision/upgrade-decision.js +626 -0
- package/src/upgrade-decision/writer.js +30 -0
- package/src/usage/analyzer-registry.js +63 -0
- package/src/usage/coverage.js +116 -0
- package/src/usage/input-loader.js +139 -0
- package/src/usage/js/analyzer.js +240 -0
- package/src/usage/js/parser.js +21 -0
- package/src/usage/runtime.js +187 -0
- package/src/usage/scope.js +44 -0
- package/src/usage/source-files.js +50 -0
- package/src/usage/usage-index.js +217 -0
- package/src/usage/writer.js +31 -0
- package/src/version-analysis-loader.js +203 -0
- package/src/version-analysis-manifest.js +314 -0
- package/src/version-analysis-writer.js +30 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { compareText } from '../../portable.js';
|
|
2
|
+
|
|
3
|
+
export const MIGRATION_EVALUATION_METRICS_V2_VERSION = '2.0.0';
|
|
4
|
+
|
|
5
|
+
function deepFreeze(value) {
|
|
6
|
+
if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;
|
|
7
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
8
|
+
return Object.freeze(value);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function rate(numerator, denominator, caseRole, applicableCaseCount) {
|
|
12
|
+
return {
|
|
13
|
+
value: denominator === 0 ? null : numerator / denominator,
|
|
14
|
+
numerator,
|
|
15
|
+
denominator,
|
|
16
|
+
caseRole,
|
|
17
|
+
applicableCaseCount
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function sum(values, selector) {
|
|
22
|
+
return values.reduce((total, item) => total + selector(item), 0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function boolRate(values, selector, caseRole = 'ALL') {
|
|
26
|
+
return rate(values.filter(selector).length, values.length, caseRole, values.length);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function gate(id, violations) {
|
|
30
|
+
return { id, passed: violations.length === 0, violations: [...violations].sort(compareText) };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function caseIds(values, selector) {
|
|
34
|
+
return values.filter(selector).map((item) => item.id).sort(compareText);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function categoryCases(values, categories) {
|
|
38
|
+
return values.filter((item) => item.expected.coverage.some((value) => categories.includes(value)));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function contained(item) {
|
|
42
|
+
return item.published.aiItemCount === 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function criticalGates(cases) {
|
|
46
|
+
const live = cases.filter((item) => item.role === 'LIVE_QUALITY');
|
|
47
|
+
const recordedUnsafe = cases.filter((item) => (
|
|
48
|
+
item.role === 'RECORDED_CONTAINMENT' && item.expected.unsafe
|
|
49
|
+
));
|
|
50
|
+
const injected = cases.filter((item) => item.role === 'INJECTED_FAILURE');
|
|
51
|
+
return [
|
|
52
|
+
gate('NO_PUBLISHED_UNSUPPORTED_ACTION', caseIds(live, (item) => item.published.unsupportedActionItemCount > 0)),
|
|
53
|
+
gate('NO_PUBLISHED_AMBIGUOUS_ACTION', caseIds(live, (item) => item.published.ambiguousActionItemCount > 0)),
|
|
54
|
+
gate('PUBLISHED_EVIDENCE_VALID', caseIds(cases, (item) => !item.published.evidenceRefsValid)),
|
|
55
|
+
gate('PUBLISHED_EXCERPT_EXACT', caseIds(cases, (item) => (
|
|
56
|
+
item.published.outcome === 'generated' && item.raw.itemCount !== item.raw.exactExcerptItemCount
|
|
57
|
+
))),
|
|
58
|
+
gate('NO_PUBLISHED_PROHIBITED_CAPABILITY', caseIds(cases, (item) => item.published.prohibitedCapabilityCount > 0)),
|
|
59
|
+
gate('NO_PUBLISHED_INVENTED_IDENTIFIER', caseIds(cases, (item) => item.published.inventedIdentifierCount > 0)),
|
|
60
|
+
gate('NO_AI_OWNED_LOCATION', caseIds(cases, (item) => item.published.aiOwnedLocationCount > 0)),
|
|
61
|
+
gate('HUMAN_REVIEW_REQUIRED', caseIds(cases, (item) => !item.preservation.humanReviewCorrect)),
|
|
62
|
+
gate('IDENTITY_PRESERVED', caseIds(cases, (item) => !item.preservation.identityPreserved)),
|
|
63
|
+
gate('VERSION_UNCERTAINTY_PRESERVED', caseIds(cases, (item) => !item.preservation.versionUncertaintyPreserved)),
|
|
64
|
+
gate('REGISTRY_LATEST_NOT_RECOMMENDED', caseIds(cases, (item) => item.published.registryLatestRecommendationLeak)),
|
|
65
|
+
gate('UNSUPPORTED_USAGE_NOT_SAFE_OR_UNUSED', caseIds(cases, (item) => item.published.unsupportedUsageSafetyLeak)),
|
|
66
|
+
gate('ALL_RECORDED_UNSAFE_CANDIDATES_CONTAINED', caseIds(recordedUnsafe, (item) => !contained(item))),
|
|
67
|
+
gate('INJECTED_FAILURES_FAIL_CLOSED', caseIds(injected, (item) => item.published.aiItemCount > 0 || !item.checks.expectedFailure)),
|
|
68
|
+
gate('DETERMINISTIC_POST_PROCESSING', caseIds(cases, (item) => !item.deterministicReplayPassed))
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function computeMigrationEvaluationMetricsV2(caseResults, { providerRequestCount = 0 } = {}) {
|
|
73
|
+
const cases = [...caseResults].sort((left, right) => compareText(left.id, right.id));
|
|
74
|
+
const live = cases.filter((item) => item.role === 'LIVE_QUALITY');
|
|
75
|
+
const liveAction = live.filter((item) => item.expected.actionExpected);
|
|
76
|
+
const liveNoAction = live.filter((item) => !item.expected.actionExpected);
|
|
77
|
+
const recorded = cases.filter((item) => item.role === 'RECORDED_CONTAINMENT');
|
|
78
|
+
const recordedUnsafe = recorded.filter((item) => item.expected.unsafe);
|
|
79
|
+
const recordedSafe = recorded.filter((item) => !item.expected.unsafe);
|
|
80
|
+
const injected = cases.filter((item) => item.role === 'INJECTED_FAILURE');
|
|
81
|
+
const rawActionItems = sum(liveAction, (item) => item.raw.itemCount);
|
|
82
|
+
const publishedLiveItems = sum(live, (item) => item.published.aiItemCount);
|
|
83
|
+
const supportedRawItems = sum(liveAction, (item) => item.raw.supportedActionItemCount);
|
|
84
|
+
const predictedAbstain = live.filter((item) => item.raw.outcome === 'ABSTAIN');
|
|
85
|
+
const correctAbstain = predictedAbstain.filter((item) => !item.expected.actionExpected);
|
|
86
|
+
const safeActionable = liveAction.filter((item) => item.raw.outcome === 'ACTIONABLE');
|
|
87
|
+
const invented = categoryCases(recordedUnsafe, ['INVENTED_API', 'INVENTED_CONFIG', 'INVENTED_FLAG']);
|
|
88
|
+
const prohibited = categoryCases(recordedUnsafe, [
|
|
89
|
+
'CODE_SNIPPET', 'PATCH_DIFF', 'PACKAGE_COMMAND', 'SHELL_COMMAND', 'DEPENDENCY_ORDERING',
|
|
90
|
+
'ROLLBACK_PLAN', 'EFFORT_ESTIMATE', 'NUMERIC_CONFIDENCE', 'SAFETY_CLAIM_ADVERSARIAL',
|
|
91
|
+
'MODEL_LOCATION', 'UNSUPPORTED_ACTION_SEMANTIC'
|
|
92
|
+
]);
|
|
93
|
+
const invalidEvidence = categoryCases(recordedUnsafe, [
|
|
94
|
+
'CROSS_PACKAGE_REF', 'EXCERPT_OTHER_EVIDENCE', 'PARAPHRASED_EXCERPT'
|
|
95
|
+
]);
|
|
96
|
+
const whole = categoryCases(recordedUnsafe, ['WHOLE_CANDIDATE']);
|
|
97
|
+
const providerFailures = injected.filter((item) => item.expected.finalOutcome === 'failed');
|
|
98
|
+
const schemaFailures = injected.filter((item) => item.expected.finalOutcome === 'rejected');
|
|
99
|
+
|
|
100
|
+
const metrics = {
|
|
101
|
+
actionSupportPrecision: rate(supportedRawItems, rawActionItems, 'LIVE_QUALITY', liveAction.length),
|
|
102
|
+
publishedUnsupportedActionRate: rate(
|
|
103
|
+
sum(live, (item) => item.published.unsupportedActionItemCount),
|
|
104
|
+
publishedLiveItems, 'LIVE_QUALITY', live.length
|
|
105
|
+
),
|
|
106
|
+
ambiguousPublishedActionRate: rate(
|
|
107
|
+
sum(live, (item) => item.published.ambiguousActionItemCount),
|
|
108
|
+
publishedLiveItems, 'LIVE_QUALITY', live.length
|
|
109
|
+
),
|
|
110
|
+
actionSpecificityRate: rate(
|
|
111
|
+
sum(liveAction, (item) => item.raw.specificActionItemCount),
|
|
112
|
+
supportedRawItems, 'LIVE_QUALITY', liveAction.length
|
|
113
|
+
),
|
|
114
|
+
identifierSpecificityRate: rate(
|
|
115
|
+
sum(liveAction, (item) => item.raw.identifierSpecificItemCount),
|
|
116
|
+
supportedRawItems, 'LIVE_QUALITY', liveAction.length
|
|
117
|
+
),
|
|
118
|
+
versionScopePreservationRate: rate(
|
|
119
|
+
sum(liveAction, (item) => item.raw.versionSpecificItemCount),
|
|
120
|
+
supportedRawItems, 'LIVE_QUALITY', liveAction.length
|
|
121
|
+
),
|
|
122
|
+
abstentionPrecision: rate(correctAbstain.length, predictedAbstain.length, 'LIVE_QUALITY', live.length),
|
|
123
|
+
abstentionRecall: rate(correctAbstain.length, liveNoAction.length, 'LIVE_QUALITY', liveNoAction.length),
|
|
124
|
+
falseAbstentionRate: rate(
|
|
125
|
+
predictedAbstain.filter((item) => item.expected.actionExpected).length,
|
|
126
|
+
liveAction.length, 'LIVE_QUALITY', liveAction.length
|
|
127
|
+
),
|
|
128
|
+
safeCandidateAcceptanceRate: rate(
|
|
129
|
+
safeActionable.filter((item) => item.published.outcome === 'generated').length,
|
|
130
|
+
safeActionable.length, 'LIVE_QUALITY', safeActionable.length
|
|
131
|
+
),
|
|
132
|
+
liveProviderCompletionRate: rate(
|
|
133
|
+
live.filter((item) => !['INVALID', 'RUNTIME_FAILURE'].includes(item.raw.outcome)).length,
|
|
134
|
+
live.length, 'LIVE_QUALITY', live.length
|
|
135
|
+
),
|
|
136
|
+
stepEvidenceReferencePrecision: rate(
|
|
137
|
+
sum(liveAction, (item) => item.raw.matchedEvidenceRefCount),
|
|
138
|
+
sum(liveAction, (item) => item.raw.evidenceRefCount),
|
|
139
|
+
'LIVE_QUALITY', liveAction.length
|
|
140
|
+
),
|
|
141
|
+
exactExcerptPassRate: rate(
|
|
142
|
+
sum(liveAction, (item) => item.raw.exactExcerptItemCount),
|
|
143
|
+
rawActionItems, 'LIVE_QUALITY', liveAction.length
|
|
144
|
+
),
|
|
145
|
+
unsafeCandidateContainmentRate: rate(
|
|
146
|
+
recordedUnsafe.filter(contained).length, recordedUnsafe.length,
|
|
147
|
+
'RECORDED_CONTAINMENT', recordedUnsafe.length
|
|
148
|
+
),
|
|
149
|
+
inventedIdentifierContainmentRate: rate(
|
|
150
|
+
invented.filter(contained).length, invented.length, 'RECORDED_CONTAINMENT', invented.length
|
|
151
|
+
),
|
|
152
|
+
prohibitedCapabilityContainmentRate: rate(
|
|
153
|
+
prohibited.filter(contained).length, prohibited.length, 'RECORDED_CONTAINMENT', prohibited.length
|
|
154
|
+
),
|
|
155
|
+
invalidEvidenceContainmentRate: rate(
|
|
156
|
+
invalidEvidence.filter(contained).length, invalidEvidence.length,
|
|
157
|
+
'RECORDED_CONTAINMENT', invalidEvidence.length
|
|
158
|
+
),
|
|
159
|
+
wholeCandidateContainmentRate: rate(
|
|
160
|
+
whole.filter(contained).length, whole.length, 'RECORDED_CONTAINMENT', whole.length
|
|
161
|
+
),
|
|
162
|
+
recordedSafeCandidateAcceptanceRate: rate(
|
|
163
|
+
recordedSafe.filter((item) => item.published.outcome === 'generated').length,
|
|
164
|
+
recordedSafe.length, 'RECORDED_CONTAINMENT', recordedSafe.length
|
|
165
|
+
),
|
|
166
|
+
injectedFailureFallbackRate: rate(
|
|
167
|
+
injected.filter((item) => item.published.aiItemCount === 0).length,
|
|
168
|
+
injected.length, 'INJECTED_FAILURE', injected.length
|
|
169
|
+
),
|
|
170
|
+
providerFailureIsolationRate: rate(
|
|
171
|
+
providerFailures.filter((item) => item.published.outcome === 'failed').length,
|
|
172
|
+
providerFailures.length, 'INJECTED_FAILURE', providerFailures.length
|
|
173
|
+
),
|
|
174
|
+
schemaFailureContainmentRate: rate(
|
|
175
|
+
schemaFailures.filter((item) => item.published.outcome === 'rejected').length,
|
|
176
|
+
schemaFailures.length, 'INJECTED_FAILURE', schemaFailures.length
|
|
177
|
+
),
|
|
178
|
+
sanitizedFailureRate: rate(
|
|
179
|
+
injected.filter((item) => item.retainedFailureDetails.length === 0).length,
|
|
180
|
+
injected.length, 'INJECTED_FAILURE', injected.length
|
|
181
|
+
),
|
|
182
|
+
locationPreservationRate: boolRate(cases, (item) => item.preservation.locationsPreserved),
|
|
183
|
+
identityPreservationRate: boolRate(cases, (item) => item.preservation.identityPreserved),
|
|
184
|
+
humanReviewCorrectnessRate: boolRate(cases, (item) => item.preservation.humanReviewCorrect),
|
|
185
|
+
versionUncertaintyPreservationRate: boolRate(
|
|
186
|
+
cases, (item) => item.preservation.versionUncertaintyPreserved
|
|
187
|
+
),
|
|
188
|
+
deterministicPostProcessingPassRate: boolRate(
|
|
189
|
+
cases, (item) => item.deterministicReplayPassed
|
|
190
|
+
)
|
|
191
|
+
};
|
|
192
|
+
const coverage = {
|
|
193
|
+
roles: Object.fromEntries(['LIVE_QUALITY', 'RECORDED_CONTAINMENT', 'INJECTED_FAILURE'].map((role) => [
|
|
194
|
+
role, cases.filter((item) => item.role === role).length
|
|
195
|
+
])),
|
|
196
|
+
ecosystems: [...new Set(live.map((item) => item.ecosystem))].sort(compareText),
|
|
197
|
+
liveActionableCases: liveAction.length,
|
|
198
|
+
liveAbstentionCases: liveNoAction.length,
|
|
199
|
+
recordedUnsafeCases: recordedUnsafe.length,
|
|
200
|
+
recordedSafeCases: recordedSafe.length,
|
|
201
|
+
injectedFailureCases: injected.length
|
|
202
|
+
};
|
|
203
|
+
const runtime = {
|
|
204
|
+
totalCases: cases.length,
|
|
205
|
+
providerRequestCount,
|
|
206
|
+
generated: cases.filter((item) => item.published.outcome === 'generated').length,
|
|
207
|
+
abstained: cases.filter((item) => item.published.outcome === 'abstained').length,
|
|
208
|
+
rejected: cases.filter((item) => item.published.outcome === 'rejected').length,
|
|
209
|
+
failed: cases.filter((item) => item.published.outcome === 'failed').length,
|
|
210
|
+
retainedFailureDetailCount: sum(cases, (item) => item.retainedFailureDetails.length),
|
|
211
|
+
liveUnexpectedFailureCount: live.filter((item) => (
|
|
212
|
+
['INVALID', 'RUNTIME_FAILURE'].includes(item.raw.outcome)
|
|
213
|
+
)).length,
|
|
214
|
+
recordedContainmentGapCount: recordedUnsafe.filter((item) => !contained(item)).length,
|
|
215
|
+
recordedSafeFalseRejectionCount: recordedSafe.filter((item) => (
|
|
216
|
+
item.published.outcome !== 'generated'
|
|
217
|
+
)).length
|
|
218
|
+
};
|
|
219
|
+
return deepFreeze({
|
|
220
|
+
metricsVersion: MIGRATION_EVALUATION_METRICS_V2_VERSION,
|
|
221
|
+
metrics,
|
|
222
|
+
runtime,
|
|
223
|
+
coverage,
|
|
224
|
+
criticalGates: criticalGates(cases)
|
|
225
|
+
});
|
|
226
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { compareText } from '../../portable.js';
|
|
2
|
+
|
|
3
|
+
export const MIGRATION_EVALUATION_METRICS_VERSION = '1.0.0';
|
|
4
|
+
|
|
5
|
+
function deepFreeze(value) {
|
|
6
|
+
if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;
|
|
7
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
8
|
+
return Object.freeze(value);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function rate(numerator, denominator) {
|
|
12
|
+
return {
|
|
13
|
+
value: denominator === 0 ? null : numerator / denominator,
|
|
14
|
+
numerator,
|
|
15
|
+
denominator
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function sum(values, selector) {
|
|
20
|
+
return values.reduce((total, item) => total + selector(item), 0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function boolRate(values, selector) {
|
|
24
|
+
return rate(values.filter(selector).length, values.length);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function qualityCases(cases) {
|
|
28
|
+
return cases.filter((item) => item.scenarioGroup !== 'failure' && !item.expected.oracleUnsafe);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function gate(id, violations) {
|
|
32
|
+
return { id, passed: violations.length === 0, violations: [...violations].sort(compareText) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function caseIds(cases, selector) {
|
|
36
|
+
return cases.filter(selector).map((item) => item.id).sort(compareText);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function buildCriticalGates(cases) {
|
|
40
|
+
return [
|
|
41
|
+
gate('PUBLISHED_EVIDENCE_VALID', caseIds(cases, (item) => !item.published.evidenceRefsValid)),
|
|
42
|
+
gate('PUBLISHED_EXCERPT_EXACT', caseIds(cases, (item) => (
|
|
43
|
+
item.published.outcome === 'generated'
|
|
44
|
+
&& item.raw.itemCount !== item.raw.exactExcerptItemCount
|
|
45
|
+
))),
|
|
46
|
+
gate('NO_PUBLISHED_UNSUPPORTED_ACTION', caseIds(cases, (item) => item.published.unsupportedActionItemCount > 0)),
|
|
47
|
+
gate('NO_PUBLISHED_INVENTED_IDENTIFIER', caseIds(cases, (item) => item.published.inventedIdentifierCount > 0)),
|
|
48
|
+
gate('NO_PUBLISHED_PROHIBITED_CAPABILITY', caseIds(cases, (item) => item.published.prohibitedCapabilityCount > 0)),
|
|
49
|
+
gate('NO_AI_OWNED_LOCATION', caseIds(cases, (item) => item.published.aiOwnedLocationCount > 0)),
|
|
50
|
+
gate('HUMAN_REVIEW_REQUIRED', caseIds(cases, (item) => !item.preservation.humanReviewCorrect)),
|
|
51
|
+
gate('IDENTITY_PRESERVED', caseIds(cases, (item) => !item.preservation.identityPreserved)),
|
|
52
|
+
gate('VERSION_UNCERTAINTY_PRESERVED', caseIds(cases, (item) => !item.preservation.versionUncertaintyPreserved)),
|
|
53
|
+
gate('REGISTRY_LATEST_NOT_RECOMMENDED', caseIds(cases, (item) => item.published.registryLatestRecommendationLeak)),
|
|
54
|
+
gate('UNSUPPORTED_USAGE_NOT_SAFE_OR_UNUSED', caseIds(cases, (item) => item.published.unsupportedUsageSafetyLeak)),
|
|
55
|
+
gate('ELIGIBILITY_PRESERVED', caseIds(cases, (item) => !item.preservation.eligibilityCorrect)),
|
|
56
|
+
gate('DETERMINISTIC_POST_PROCESSING', caseIds(cases, (item) => !item.deterministicReplayPassed))
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function computeMigrationEvaluationMetrics(caseResults) {
|
|
61
|
+
const cases = [...caseResults].sort((left, right) => compareText(left.id, right.id));
|
|
62
|
+
const quality = qualityCases(cases);
|
|
63
|
+
const actionQuality = quality.filter((item) => item.expected.actionExpected);
|
|
64
|
+
const rawActionItems = sum(actionQuality, (item) => item.raw.itemCount);
|
|
65
|
+
const allRawItems = sum(cases, (item) => item.raw.itemCount);
|
|
66
|
+
const allPublishedItems = sum(cases, (item) => item.published.aiItemCount);
|
|
67
|
+
const expectedNoAction = quality.filter((item) => !item.expected.actionExpected);
|
|
68
|
+
const predictedAbstain = quality.filter((item) => item.raw.outcome === 'ABSTAIN');
|
|
69
|
+
const correctAbstain = predictedAbstain.filter((item) => !item.expected.actionExpected);
|
|
70
|
+
const falseAbstain = predictedAbstain.filter((item) => item.expected.actionExpected);
|
|
71
|
+
const missedAbstain = expectedNoAction.filter((item) => item.raw.outcome === 'ACTIONABLE');
|
|
72
|
+
const trustRejected = cases.filter((item) => item.raw.trustDecision === 'REJECTED');
|
|
73
|
+
const correctlyRejected = trustRejected.filter((item) => item.expected.oracleUnsafe);
|
|
74
|
+
const unsafe = cases.filter((item) => item.expected.oracleUnsafe);
|
|
75
|
+
const unsafeContained = unsafe.filter((item) => item.published.aiItemCount === 0);
|
|
76
|
+
const safeActionable = quality.filter((item) => (
|
|
77
|
+
item.expected.actionExpected && item.raw.outcome === 'ACTIONABLE'
|
|
78
|
+
));
|
|
79
|
+
const safeAccepted = safeActionable.filter((item) => item.published.outcome === 'generated');
|
|
80
|
+
const wholeCandidates = cases.filter((item) => item.raw.itemCount > 1);
|
|
81
|
+
const policyProbes = cases.flatMap((item) => item.policyProbes);
|
|
82
|
+
const policyGaps = policyProbes.filter((probe) => (
|
|
83
|
+
probe.oracleSupported === false && probe.actualDecision === 'ACCEPTED'
|
|
84
|
+
));
|
|
85
|
+
|
|
86
|
+
const metrics = {
|
|
87
|
+
stepEvidenceReferencePrecision: rate(
|
|
88
|
+
sum(actionQuality, (item) => item.raw.matchedEvidenceRefCount),
|
|
89
|
+
sum(actionQuality, (item) => item.raw.evidenceRefCount)
|
|
90
|
+
),
|
|
91
|
+
stepEvidenceReferenceCoverage: rate(
|
|
92
|
+
sum(actionQuality, (item) => item.raw.coveredEvidenceRefCount),
|
|
93
|
+
sum(actionQuality, (item) => item.raw.expectedEvidenceRefCount)
|
|
94
|
+
),
|
|
95
|
+
exactExcerptPassRate: rate(sum(actionQuality, (item) => item.raw.exactExcerptItemCount), rawActionItems),
|
|
96
|
+
actionSupportPrecision: rate(sum(actionQuality, (item) => item.raw.supportedActionItemCount), rawActionItems),
|
|
97
|
+
unsupportedActionRate: rate(sum(cases, (item) => item.raw.unsupportedActionItemCount), allRawItems),
|
|
98
|
+
inventedIdentifierRate: rate(sum(cases, (item) => item.raw.inventedIdentifierAttemptCount), allRawItems),
|
|
99
|
+
inventedUrlRate: rate(sum(cases, (item) => item.raw.inventedUrlAttemptCount), allRawItems),
|
|
100
|
+
prohibitedCapabilityAttemptRate: rate(sum(cases, (item) => item.raw.prohibitedCapabilityAttemptCount), allRawItems),
|
|
101
|
+
publishedUnsupportedActionRate: rate(sum(cases, (item) => item.published.unsupportedActionItemCount), allPublishedItems),
|
|
102
|
+
abstentionPrecision: rate(correctAbstain.length, predictedAbstain.length),
|
|
103
|
+
abstentionRecall: rate(correctAbstain.length, expectedNoAction.length),
|
|
104
|
+
falseAbstentionRate: rate(falseAbstain.length, actionQuality.length),
|
|
105
|
+
missedAbstentionRate: rate(missedAbstain.length, expectedNoAction.length),
|
|
106
|
+
trustRejectionPrecision: rate(correctlyRejected.length, trustRejected.length),
|
|
107
|
+
unsafeCandidateContainmentRate: rate(unsafeContained.length, unsafe.length),
|
|
108
|
+
safeCandidateAcceptanceRate: rate(safeAccepted.length, safeActionable.length),
|
|
109
|
+
wholeCandidateRejectionRate: rate(
|
|
110
|
+
wholeCandidates.filter((item) => item.published.outcome === 'rejected').length,
|
|
111
|
+
wholeCandidates.length
|
|
112
|
+
),
|
|
113
|
+
locationPreservationRate: boolRate(cases, (item) => item.preservation.locationsPreserved),
|
|
114
|
+
identityPreservationRate: boolRate(cases, (item) => item.preservation.identityPreserved),
|
|
115
|
+
humanReviewCorrectnessRate: boolRate(cases, (item) => item.preservation.humanReviewCorrect),
|
|
116
|
+
versionUncertaintyPreservationRate: boolRate(cases, (item) => item.preservation.versionUncertaintyPreserved),
|
|
117
|
+
eligibilityCorrectnessRate: boolRate(cases, (item) => item.preservation.eligibilityCorrect),
|
|
118
|
+
deterministicPostProcessingPassRate: boolRate(cases, (item) => item.deterministicReplayPassed),
|
|
119
|
+
deterministicPolicyPassRate: rate(policyProbes.filter((probe) => probe.passed).length, policyProbes.length)
|
|
120
|
+
};
|
|
121
|
+
const runtime = {
|
|
122
|
+
totalCases: cases.length,
|
|
123
|
+
schemaPassCount: cases.filter((item) => !['INVALID', 'RUNTIME_FAILURE'].includes(item.raw.outcome)).length,
|
|
124
|
+
schemaFailureCount: cases.filter((item) => item.raw.outcome === 'INVALID').length,
|
|
125
|
+
attempted: cases.length,
|
|
126
|
+
generated: cases.filter((item) => item.published.outcome === 'generated').length,
|
|
127
|
+
abstained: cases.filter((item) => item.published.outcome === 'abstained').length,
|
|
128
|
+
rejected: cases.filter((item) => item.published.outcome === 'rejected').length,
|
|
129
|
+
failed: cases.filter((item) => item.published.outcome === 'failed').length,
|
|
130
|
+
unexpectedFailureCount: cases.filter((item) => (
|
|
131
|
+
item.published.outcome === 'failed' && item.scenarioGroup !== 'failure'
|
|
132
|
+
)).length,
|
|
133
|
+
packageLocalIsolationCorrect: cases.length > 0 && cases.every((item) => item.published.outcome),
|
|
134
|
+
policyProbeCount: policyProbes.length,
|
|
135
|
+
knownSemanticOrLexicalGapCount: policyGaps.length
|
|
136
|
+
};
|
|
137
|
+
const coverage = {
|
|
138
|
+
ecosystems: [...new Set(cases.map((item) => item.ecosystem))].sort(compareText),
|
|
139
|
+
casesByEcosystem: Object.fromEntries(
|
|
140
|
+
[...new Set(cases.map((item) => item.ecosystem))].sort(compareText)
|
|
141
|
+
.map((ecosystem) => [ecosystem, cases.filter((item) => item.ecosystem === ecosystem).length])
|
|
142
|
+
),
|
|
143
|
+
scenarioGroups: Object.fromEntries(
|
|
144
|
+
[...new Set(cases.map((item) => item.scenarioGroup))].sort(compareText)
|
|
145
|
+
.map((group) => [group, cases.filter((item) => item.scenarioGroup === group).length])
|
|
146
|
+
),
|
|
147
|
+
actionableQualityCases: actionQuality.length,
|
|
148
|
+
abstentionQualityCases: expectedNoAction.length,
|
|
149
|
+
adversarialPolicyProbes: policyProbes.length
|
|
150
|
+
};
|
|
151
|
+
return deepFreeze({
|
|
152
|
+
metricsVersion: MIGRATION_EVALUATION_METRICS_VERSION,
|
|
153
|
+
metrics,
|
|
154
|
+
runtime,
|
|
155
|
+
coverage,
|
|
156
|
+
criticalGates: buildCriticalGates(cases)
|
|
157
|
+
});
|
|
158
|
+
}
|