@dailephd/my-dev-kit-lab 0.4.2 → 0.4.3
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/README.md +23 -113
- package/benchmarks/contracts/todo-behavior.md +1 -1
- package/benchmarks/projects/task-analytics-large-mixed/README.md +2 -0
- package/benchmarks/projects/task-workflow-medium-ts/README.md +3 -1
- package/dist/src/evaluation/stageContextDeterminism/calculateStageContextDeterminism.js +52 -0
- package/dist/src/evaluation/stageContextDeterminism/canonicalizeStageContextRun.js +53 -0
- package/dist/src/evaluation/stageContextDeterminism/index.js +2 -0
- package/dist/src/evaluation/stageContextDeterminism/types.js +1 -0
- package/dist/src/evaluation/stageContextExpectations/index.js +2 -0
- package/dist/src/evaluation/stageContextExpectations/readStageContextExpectationFixtureV1.js +50 -0
- package/dist/src/evaluation/stageContextExpectations/readTypes.js +1 -0
- package/dist/src/evaluation/stageContextExpectations/types.js +1 -0
- package/dist/src/evaluation/stageContextExpectations/validation.js +568 -0
- package/dist/src/evaluation/stageContextMetrics/calculateArtifactStateMetrics.js +130 -0
- package/dist/src/evaluation/stageContextMetrics/calculateContextSizeMetrics.js +85 -0
- package/dist/src/evaluation/stageContextMetrics/calculateExpectationMetrics.js +103 -0
- package/dist/src/evaluation/stageContextMetrics/calculateResponsibilityMappingMetrics.js +36 -0
- package/dist/src/evaluation/stageContextMetrics/collectContextCapsuleEvidence.js +312 -0
- package/dist/src/evaluation/stageContextMetrics/collectRetrievalAuditEvidence.js +35 -0
- package/dist/src/evaluation/stageContextMetrics/collectWorkflowInstructionEvidence.js +137 -0
- package/dist/src/evaluation/stageContextMetrics/evaluateV043StageContextExecution.js +247 -0
- package/dist/src/evaluation/stageContextMetrics/index.js +10 -0
- package/dist/src/evaluation/stageContextMetrics/matchStageContextExpectations.js +38 -0
- package/dist/src/evaluation/stageContextMetrics/targetKeys.js +35 -0
- package/dist/src/evaluation/stageContextMetrics/types.js +1 -0
- package/dist/src/evaluation/stageContextSelectors/contextArtifactConsistency.js +79 -0
- package/dist/src/evaluation/stageContextSelectors/contextCapsuleSelectors.js +126 -0
- package/dist/src/evaluation/stageContextSelectors/index.js +4 -0
- package/dist/src/evaluation/stageContextSelectors/retrievalAuditRecordSelectors.js +54 -0
- package/dist/src/evaluation/stageContextSelectors/workflowInstructionPacketSelectors.js +51 -0
- package/dist/src/evaluation/targetImmutability/captureTargetSnapshot.js +208 -0
- package/dist/src/evaluation/targetImmutability/compareTargetSnapshots.js +56 -0
- package/dist/src/evaluation/targetImmutability/index.js +3 -0
- package/dist/src/evaluation/targetImmutability/types.js +1 -0
- package/dist/src/evaluation/targetImmutability/validateTargetImmutabilityConfig.js +130 -0
- package/dist/src/evaluation/upstreamArtifacts/artifactReadTypes.js +1 -0
- package/dist/src/evaluation/upstreamArtifacts/index.js +3 -0
- package/dist/src/evaluation/upstreamArtifacts/jsonTypes.js +1 -0
- package/dist/src/evaluation/upstreamArtifacts/myDevKitClassificationTypesV1.js +1 -0
- package/dist/src/evaluation/upstreamArtifacts/myDevKitContextArtifactsV1.js +1 -0
- package/dist/src/evaluation/upstreamArtifacts/myDevKitSemanticTypesV1.js +1 -0
- package/dist/src/evaluation/upstreamArtifacts/orchestratorWorkflowInstructionPacketV1.js +1 -0
- package/dist/src/evaluation/upstreamArtifacts/readJsonArtifact.js +53 -0
- package/dist/src/evaluation/upstreamArtifacts/readMyDevKitContextCapsuleV1.js +9 -0
- package/dist/src/evaluation/upstreamArtifacts/readMyDevKitRetrievalAuditRecordV1.js +9 -0
- package/dist/src/evaluation/upstreamArtifacts/readOrchestratorWorkflowInstructionPacketV1.js +9 -0
- package/dist/src/evaluation/upstreamArtifacts/runtimeValidation.js +131 -0
- package/dist/src/evaluation/upstreamArtifacts/schemaVersion.js +32 -0
- package/dist/src/evaluation/upstreamArtifacts/validateMyDevKitContextCapsuleV1.js +1208 -0
- package/dist/src/evaluation/upstreamArtifacts/validateMyDevKitRetrievalAuditRecordV1.js +105 -0
- package/dist/src/evaluation/upstreamArtifacts/validateOrchestratorWorkflowInstructionPacketV1.js +235 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/executeV043StageContextStrategy.js +46 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/index.js +9 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/loadV043StrategyArtifacts.js +286 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/plugin.js +39 -1
- package/dist/src/experiments/plugins/contextStrategyComparison/readV043FullWorkflowLibraryFixture.js +162 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/resolveV043StrategyInputs.js +43 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/resultMapping.js +3 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/runV043StageContextStrategyWithAssurance.js +190 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/v043FullWorkflowLibraryFixture.js +1 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/v043RunAssuranceTypes.js +1 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/v043StrategyExecutionTypes.js +1 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/v043StrategyIds.js +13 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/v043StrategyInputContracts.js +1 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/validateV043RunAssuranceConfig.js +59 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/validateV043StrategyInput.js +252 -0
- package/dist/src/report/experiments/buildContextStrategyComparisonV043Report.js +398 -0
- package/dist/src/report/experiments/buildPluginExperimentReport.js +21 -6
- package/dist/src/report/experiments/contextStrategyComparisonV043ReportModel.js +1 -0
- package/dist/src/report/experiments/index.js +4 -0
- package/dist/src/report/experiments/renderContextStrategyComparisonV043Html.js +234 -0
- package/dist/src/report/experiments/renderPluginExperimentReportHtml.js +3 -0
- package/dist/src/report/experiments/renderPluginExperimentReportText.js +225 -0
- package/dist/src/report/experiments/writePluginExperimentReports.js +3 -0
- package/dist/src/securityValidation/attackScenarios/scenarios/secretLeakageScenario.js +215 -9
- package/docs/METRICS.md +56 -10
- package/package.json +1 -1
- package/tests/fixtures/full-workflow-library/complete-v1.0.0.json +24 -0
- package/tests/fixtures/full-workflow-library/future-minor-v1.1.0-additive.json +25 -0
- package/tests/fixtures/stage-context-expectations/complete-v1.0.0.json +230 -0
- package/tests/fixtures/stage-context-expectations/future-minor-v1.1.0-additive.json +232 -0
- package/tests/fixtures/stage-context-expectations/invalid/malformed-json.txt +1 -0
- package/tests/fixtures/stage-context-expectations/invalid/non-object-root.json +1 -0
- package/tests/fixtures/stage-context-expectations/minimal-v1.0.0.json +18 -0
- package/tests/fixtures/upstream-artifacts/invalid/malformed-json.txt +1 -0
- package/tests/fixtures/upstream-artifacts/invalid/non-object-root.json +1 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/context-capsule/complete-v1.0.0.json +504 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/context-capsule/future-minor-v1.1.0-additive.json +955 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/retrieval-audit-record/complete-v1.0.0.json +190 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/retrieval-audit-record/future-minor-v1.1.0-additive.json +327 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.1/workflow-instruction-packet/complete-v1.0.0.json +160 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.1/workflow-instruction-packet/future-minor-v1.1.0-additive.json +186 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const SOURCE_ARTIFACT = "retrieval-audit-record";
|
|
2
|
+
function dedupeEvidence(records) {
|
|
3
|
+
const seen = new Set();
|
|
4
|
+
const result = [];
|
|
5
|
+
for (const record of records) {
|
|
6
|
+
const key = `${record.sourceInstance} ${record.category} ${record.targetKey}`;
|
|
7
|
+
if (seen.has(key))
|
|
8
|
+
continue;
|
|
9
|
+
seen.add(key);
|
|
10
|
+
result.push(record);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
export function collectRetrievalAuditEvidence(artifact, sourceInstance) {
|
|
15
|
+
const records = [];
|
|
16
|
+
artifact.responsibilityMappings.mappings.forEach((mapping, index) => {
|
|
17
|
+
records.push({
|
|
18
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
19
|
+
sourceInstance,
|
|
20
|
+
category: "production-responsibility",
|
|
21
|
+
targetKey: `${SOURCE_ARTIFACT}|production-responsibility|responsibilityId:${mapping.responsibilityId}`,
|
|
22
|
+
sourceFieldPath: `responsibilityMappings.mappings[${index}].responsibilityId`
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
artifact.provenance.forEach((provenanceRecord, index) => {
|
|
26
|
+
records.push({
|
|
27
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
28
|
+
sourceInstance,
|
|
29
|
+
category: "provenance",
|
|
30
|
+
targetKey: `${SOURCE_ARTIFACT}|provenance|evidenceId:${provenanceRecord.evidenceId}`,
|
|
31
|
+
sourceFieldPath: `provenance[${index}].evidenceId`
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return dedupeEvidence(records);
|
|
35
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
function dedupeEvidence(records) {
|
|
2
|
+
const seen = new Set();
|
|
3
|
+
const result = [];
|
|
4
|
+
for (const record of records) {
|
|
5
|
+
const key = `${record.sourceInstance} ${record.category} ${record.targetKey}`;
|
|
6
|
+
if (seen.has(key))
|
|
7
|
+
continue;
|
|
8
|
+
seen.add(key);
|
|
9
|
+
result.push(record);
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
function workflowStableIdKey(sourceArtifact, category, id) {
|
|
14
|
+
return `${sourceArtifact}|${category}|id:${id}`;
|
|
15
|
+
}
|
|
16
|
+
function provenanceKey(sourceArtifact, evidenceId) {
|
|
17
|
+
return `${sourceArtifact}|provenance|evidenceId:${evidenceId}`;
|
|
18
|
+
}
|
|
19
|
+
export function collectWorkflowInstructionPacketEvidence(artifact, sourceInstance) {
|
|
20
|
+
const SOURCE_ARTIFACT = "workflow-instruction-packet";
|
|
21
|
+
const records = [];
|
|
22
|
+
records.push({
|
|
23
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
24
|
+
sourceInstance,
|
|
25
|
+
category: "workflow",
|
|
26
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "workflow", artifact.workflowId),
|
|
27
|
+
sourceFieldPath: "workflowId"
|
|
28
|
+
});
|
|
29
|
+
records.push({
|
|
30
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
31
|
+
sourceInstance,
|
|
32
|
+
category: "stage",
|
|
33
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "stage", artifact.stageId),
|
|
34
|
+
sourceFieldPath: "stageId"
|
|
35
|
+
});
|
|
36
|
+
artifact.resolvedCommands.forEach((command, index) => {
|
|
37
|
+
records.push({
|
|
38
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
39
|
+
sourceInstance,
|
|
40
|
+
category: "command",
|
|
41
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "command", command.id),
|
|
42
|
+
sourceFieldPath: `resolvedCommands[${index}].id`
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
artifact.resolvedRules.forEach((rule, index) => {
|
|
46
|
+
records.push({
|
|
47
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
48
|
+
sourceInstance,
|
|
49
|
+
category: "rule",
|
|
50
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "rule", rule.id),
|
|
51
|
+
sourceFieldPath: `resolvedRules[${index}].id`
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
records.push({
|
|
55
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
56
|
+
sourceInstance,
|
|
57
|
+
category: "report-contract",
|
|
58
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "report-contract", artifact.reportContract.id),
|
|
59
|
+
sourceFieldPath: "reportContract.id"
|
|
60
|
+
});
|
|
61
|
+
artifact.resolutionProvenance.forEach((entry, index) => {
|
|
62
|
+
records.push({
|
|
63
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
64
|
+
sourceInstance,
|
|
65
|
+
category: "provenance",
|
|
66
|
+
targetKey: provenanceKey(SOURCE_ARTIFACT, entry.sourceEntryId),
|
|
67
|
+
sourceFieldPath: `resolutionProvenance[${index}].sourceEntryId`
|
|
68
|
+
});
|
|
69
|
+
records.push({
|
|
70
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
71
|
+
sourceInstance,
|
|
72
|
+
category: "provenance",
|
|
73
|
+
targetKey: provenanceKey(SOURCE_ARTIFACT, entry.referencedEntryId),
|
|
74
|
+
sourceFieldPath: `resolutionProvenance[${index}].referencedEntryId`
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
return dedupeEvidence(records);
|
|
78
|
+
}
|
|
79
|
+
export function collectFullWorkflowLibraryEvidence(fixture, sourceInstance) {
|
|
80
|
+
const SOURCE_ARTIFACT = "full-workflow-library";
|
|
81
|
+
const records = [];
|
|
82
|
+
fixture.workflowIds.forEach((id, index) => {
|
|
83
|
+
records.push({
|
|
84
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
85
|
+
sourceInstance,
|
|
86
|
+
category: "workflow",
|
|
87
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "workflow", id),
|
|
88
|
+
sourceFieldPath: `workflowIds[${index}]`
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
fixture.stageIds.forEach((id, index) => {
|
|
92
|
+
records.push({
|
|
93
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
94
|
+
sourceInstance,
|
|
95
|
+
category: "stage",
|
|
96
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "stage", id),
|
|
97
|
+
sourceFieldPath: `stageIds[${index}]`
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
fixture.commandIds.forEach((id, index) => {
|
|
101
|
+
records.push({
|
|
102
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
103
|
+
sourceInstance,
|
|
104
|
+
category: "command",
|
|
105
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "command", id),
|
|
106
|
+
sourceFieldPath: `commandIds[${index}]`
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
fixture.ruleIds.forEach((id, index) => {
|
|
110
|
+
records.push({
|
|
111
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
112
|
+
sourceInstance,
|
|
113
|
+
category: "rule",
|
|
114
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "rule", id),
|
|
115
|
+
sourceFieldPath: `ruleIds[${index}]`
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
fixture.reportContractIds.forEach((id, index) => {
|
|
119
|
+
records.push({
|
|
120
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
121
|
+
sourceInstance,
|
|
122
|
+
category: "report-contract",
|
|
123
|
+
targetKey: workflowStableIdKey(SOURCE_ARTIFACT, "report-contract", id),
|
|
124
|
+
sourceFieldPath: `reportContractIds[${index}]`
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
fixture.provenanceEvidenceIds.forEach((id, index) => {
|
|
128
|
+
records.push({
|
|
129
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
130
|
+
sourceInstance,
|
|
131
|
+
category: "provenance",
|
|
132
|
+
targetKey: provenanceKey(SOURCE_ARTIFACT, id),
|
|
133
|
+
sourceFieldPath: `provenanceEvidenceIds[${index}]`
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
return dedupeEvidence(records);
|
|
137
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { collectContextCapsuleEvidence } from "./collectContextCapsuleEvidence.js";
|
|
2
|
+
import { collectRetrievalAuditEvidence } from "./collectRetrievalAuditEvidence.js";
|
|
3
|
+
import { collectFullWorkflowLibraryEvidence, collectWorkflowInstructionPacketEvidence } from "./collectWorkflowInstructionEvidence.js";
|
|
4
|
+
import { matchStageContextExpectations } from "./matchStageContextExpectations.js";
|
|
5
|
+
import { calculateAllowedEvidenceCoverage, calculateForbiddenEvidenceInclusion, calculateIrrelevantFileInclusion, calculateIrrelevantInstructionInclusion, calculateRequiredEvidenceRecall, calculateRequiredProvenanceRecall } from "./calculateExpectationMetrics.js";
|
|
6
|
+
import { calculateContextCapsuleResponsibilityMappingMetric, calculateRetrievalAuditResponsibilityMappingMetric } from "./calculateResponsibilityMappingMetrics.js";
|
|
7
|
+
import { compareExpectedContextCapsuleState, compareExpectedRetrievalAuditState, compareExpectedTargetImmutabilityState, compareExpectedWorkflowInstructionPacketState } from "./calculateArtifactStateMetrics.js";
|
|
8
|
+
import { calculateV043ExecutionContextSize } from "./calculateContextSizeMetrics.js";
|
|
9
|
+
function collectExecutionEvidence(execution) {
|
|
10
|
+
const evidence = [];
|
|
11
|
+
function pushPairEvidence(pair, labelPrefix) {
|
|
12
|
+
evidence.push(...collectContextCapsuleEvidence(pair.contextCapsule, `${labelPrefix}.contextCapsule`));
|
|
13
|
+
if (pair.retrievalAuditRecord) {
|
|
14
|
+
evidence.push(...collectRetrievalAuditEvidence(pair.retrievalAuditRecord, `${labelPrefix}.retrievalAuditRecord`));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
switch (execution.strategyId) {
|
|
18
|
+
case "architecture-context-only": {
|
|
19
|
+
const payload = execution.payload;
|
|
20
|
+
pushPairEvidence(payload.architecture, "architecture");
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case "architecture-plus-implementation-refresh": {
|
|
24
|
+
const payload = execution.payload;
|
|
25
|
+
pushPairEvidence(payload.architecture, "architecture");
|
|
26
|
+
pushPairEvidence(payload.implementation, "implementation");
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case "architecture-plus-implementation-and-test-refresh": {
|
|
30
|
+
const payload = execution.payload;
|
|
31
|
+
pushPairEvidence(payload.architecture, "architecture");
|
|
32
|
+
pushPairEvidence(payload.implementation, "implementation");
|
|
33
|
+
pushPairEvidence(payload.testImplementation, "testImplementation");
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case "full-workflow-library": {
|
|
37
|
+
const payload = execution.payload;
|
|
38
|
+
evidence.push(...collectFullWorkflowLibraryEvidence(payload.fullWorkflowLibrary, "fullWorkflowLibrary"));
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "bounded-workflow-instruction-packet": {
|
|
42
|
+
const payload = execution.payload;
|
|
43
|
+
evidence.push(...collectWorkflowInstructionPacketEvidence(payload.workflowInstructionPacket, "workflowInstructionPacket"));
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case "combined-bounded-stage-context": {
|
|
47
|
+
const payload = execution.payload;
|
|
48
|
+
payload.contextArtifacts.forEach((pair, index) => {
|
|
49
|
+
pushPairEvidence(pair, `contextArtifacts[${index}]`);
|
|
50
|
+
});
|
|
51
|
+
evidence.push(...collectWorkflowInstructionPacketEvidence(payload.workflowInstructionPacket, "workflowInstructionPacket"));
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return evidence;
|
|
56
|
+
}
|
|
57
|
+
function collectResponsibilityMetrics(execution) {
|
|
58
|
+
const metrics = [];
|
|
59
|
+
function pushPairMetrics(pair, labelPrefix) {
|
|
60
|
+
metrics.push(calculateContextCapsuleResponsibilityMappingMetric(pair.contextCapsule, `${labelPrefix}.contextCapsule`));
|
|
61
|
+
if (pair.retrievalAuditRecord) {
|
|
62
|
+
metrics.push(calculateRetrievalAuditResponsibilityMappingMetric(pair.retrievalAuditRecord, `${labelPrefix}.retrievalAuditRecord`));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
switch (execution.strategyId) {
|
|
66
|
+
case "architecture-context-only": {
|
|
67
|
+
const payload = execution.payload;
|
|
68
|
+
pushPairMetrics(payload.architecture, "architecture");
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case "architecture-plus-implementation-refresh": {
|
|
72
|
+
const payload = execution.payload;
|
|
73
|
+
pushPairMetrics(payload.architecture, "architecture");
|
|
74
|
+
pushPairMetrics(payload.implementation, "implementation");
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case "architecture-plus-implementation-and-test-refresh": {
|
|
78
|
+
const payload = execution.payload;
|
|
79
|
+
pushPairMetrics(payload.architecture, "architecture");
|
|
80
|
+
pushPairMetrics(payload.implementation, "implementation");
|
|
81
|
+
pushPairMetrics(payload.testImplementation, "testImplementation");
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "combined-bounded-stage-context": {
|
|
85
|
+
const payload = execution.payload;
|
|
86
|
+
payload.contextArtifacts.forEach((pair, index) => {
|
|
87
|
+
pushPairMetrics(pair, `contextArtifacts[${index}]`);
|
|
88
|
+
});
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case "full-workflow-library":
|
|
92
|
+
case "bounded-workflow-instruction-packet":
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
return metrics;
|
|
96
|
+
}
|
|
97
|
+
function buildTargetImmutabilityMetric(targetImmutability) {
|
|
98
|
+
if (targetImmutability === undefined) {
|
|
99
|
+
return {
|
|
100
|
+
availability: "unavailable",
|
|
101
|
+
count: null,
|
|
102
|
+
evidenceKeys: [],
|
|
103
|
+
reason: "Target immutability configuration was not supplied for this strategy run."
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (targetImmutability.availability === "unavailable") {
|
|
107
|
+
return {
|
|
108
|
+
availability: "unavailable",
|
|
109
|
+
count: null,
|
|
110
|
+
evidenceKeys: [],
|
|
111
|
+
reason: targetImmutability.reason
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
availability: "available",
|
|
116
|
+
count: targetImmutability.comparison.newMutationCount,
|
|
117
|
+
evidenceKeys: targetImmutability.comparison.mutations.map((mutation) => mutation.id),
|
|
118
|
+
reason: null
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function collectStateComparisons(execution, targetImmutability) {
|
|
122
|
+
const expectedStates = execution.expectations.expectedStates;
|
|
123
|
+
const comparisons = [];
|
|
124
|
+
function pushPairComparisons(pair, labelPrefix) {
|
|
125
|
+
comparisons.push(...compareExpectedContextCapsuleState(expectedStates.contextCapsule, pair.contextCapsule, `${labelPrefix}.contextCapsule`));
|
|
126
|
+
if (pair.retrievalAuditRecord) {
|
|
127
|
+
comparisons.push(...compareExpectedRetrievalAuditState(expectedStates.retrievalAuditRecord, pair.retrievalAuditRecord, `${labelPrefix}.retrievalAuditRecord`));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
switch (execution.strategyId) {
|
|
131
|
+
case "architecture-context-only": {
|
|
132
|
+
const payload = execution.payload;
|
|
133
|
+
pushPairComparisons(payload.architecture, "architecture");
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "architecture-plus-implementation-refresh": {
|
|
137
|
+
const payload = execution.payload;
|
|
138
|
+
pushPairComparisons(payload.architecture, "architecture");
|
|
139
|
+
pushPairComparisons(payload.implementation, "implementation");
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case "architecture-plus-implementation-and-test-refresh": {
|
|
143
|
+
const payload = execution.payload;
|
|
144
|
+
pushPairComparisons(payload.architecture, "architecture");
|
|
145
|
+
pushPairComparisons(payload.implementation, "implementation");
|
|
146
|
+
pushPairComparisons(payload.testImplementation, "testImplementation");
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case "full-workflow-library":
|
|
150
|
+
break;
|
|
151
|
+
case "bounded-workflow-instruction-packet": {
|
|
152
|
+
const payload = execution.payload;
|
|
153
|
+
comparisons.push(...compareExpectedWorkflowInstructionPacketState(expectedStates.workflowInstructionPacket, payload.workflowInstructionPacket, "workflowInstructionPacket"));
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case "combined-bounded-stage-context": {
|
|
157
|
+
const payload = execution.payload;
|
|
158
|
+
payload.contextArtifacts.forEach((pair, index) => {
|
|
159
|
+
pushPairComparisons(pair, `contextArtifacts[${index}]`);
|
|
160
|
+
});
|
|
161
|
+
comparisons.push(...compareExpectedWorkflowInstructionPacketState(expectedStates.workflowInstructionPacket, payload.workflowInstructionPacket, "workflowInstructionPacket"));
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
comparisons.push(...compareExpectedTargetImmutabilityState(expectedStates.targetImmutability, targetImmutability));
|
|
166
|
+
return comparisons;
|
|
167
|
+
}
|
|
168
|
+
export function evaluateV043StageContextExecution(execution, context) {
|
|
169
|
+
try {
|
|
170
|
+
if (execution.status === "invalid-input") {
|
|
171
|
+
return {
|
|
172
|
+
status: "not-applicable",
|
|
173
|
+
strategyId: execution.strategyId,
|
|
174
|
+
executionStatus: "invalid-input",
|
|
175
|
+
reason: "Metrics are not applicable because strategy input validation failed."
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (execution.status === "failed") {
|
|
179
|
+
return {
|
|
180
|
+
status: "not-applicable",
|
|
181
|
+
strategyId: execution.strategyId,
|
|
182
|
+
executionStatus: "failed",
|
|
183
|
+
reason: "Metrics are not applicable because strategy execution failed."
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const status = execution.status;
|
|
187
|
+
if (status === "unavailable") {
|
|
188
|
+
return {
|
|
189
|
+
status: "not-applicable",
|
|
190
|
+
strategyId: execution.strategyId,
|
|
191
|
+
executionStatus: "unavailable",
|
|
192
|
+
reason: "Metrics are not applicable because strategy execution is unavailable."
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (status === "not-applicable") {
|
|
196
|
+
return {
|
|
197
|
+
status: "not-applicable",
|
|
198
|
+
strategyId: execution.strategyId,
|
|
199
|
+
executionStatus: "not-applicable",
|
|
200
|
+
reason: "Metrics are not applicable to this strategy execution."
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const observedEvidence = collectExecutionEvidence(execution);
|
|
204
|
+
const expectationMatches = matchStageContextExpectations(execution.expectations, observedEvidence);
|
|
205
|
+
const metrics = {
|
|
206
|
+
requiredEvidenceRecall: calculateRequiredEvidenceRecall(expectationMatches),
|
|
207
|
+
allowedEvidenceCoverage: calculateAllowedEvidenceCoverage(expectationMatches),
|
|
208
|
+
forbiddenEvidenceInclusion: calculateForbiddenEvidenceInclusion(expectationMatches),
|
|
209
|
+
irrelevantFileInclusion: calculateIrrelevantFileInclusion(execution.expectations, observedEvidence),
|
|
210
|
+
irrelevantInstructionInclusion: calculateIrrelevantInstructionInclusion(execution.expectations, observedEvidence),
|
|
211
|
+
requiredProvenanceRecall: calculateRequiredProvenanceRecall(expectationMatches),
|
|
212
|
+
responsibilityMappingCompleteness: collectResponsibilityMetrics(execution),
|
|
213
|
+
stateComparisons: collectStateComparisons(execution, context?.targetImmutability),
|
|
214
|
+
contextSize: calculateV043ExecutionContextSize(execution),
|
|
215
|
+
consideredButUnselectedReads: {
|
|
216
|
+
availability: "unavailable",
|
|
217
|
+
count: null,
|
|
218
|
+
evidenceKeys: [],
|
|
219
|
+
reason: "The published upstream artifacts do not expose considered-but-unselected reads."
|
|
220
|
+
},
|
|
221
|
+
unnecessaryReads: {
|
|
222
|
+
availability: "unavailable",
|
|
223
|
+
count: null,
|
|
224
|
+
evidenceKeys: [],
|
|
225
|
+
reason: "The published upstream artifacts do not expose unnecessary-read evidence."
|
|
226
|
+
},
|
|
227
|
+
targetImmutability: buildTargetImmutabilityMetric(context?.targetImmutability)
|
|
228
|
+
};
|
|
229
|
+
return {
|
|
230
|
+
status: "completed",
|
|
231
|
+
strategyId: execution.strategyId,
|
|
232
|
+
executionStatus: "completed",
|
|
233
|
+
expectationMatches,
|
|
234
|
+
observedEvidence,
|
|
235
|
+
metrics,
|
|
236
|
+
warnings: []
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
return {
|
|
241
|
+
status: "failed",
|
|
242
|
+
strategyId: execution.strategyId,
|
|
243
|
+
executionStatus: execution.status,
|
|
244
|
+
reason: "Unexpected v0.4.3 stage-context metric evaluation failure."
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { buildStageContextExpectationTargetKey } from "./targetKeys.js";
|
|
2
|
+
export { collectContextCapsuleEvidence } from "./collectContextCapsuleEvidence.js";
|
|
3
|
+
export { collectRetrievalAuditEvidence } from "./collectRetrievalAuditEvidence.js";
|
|
4
|
+
export { collectFullWorkflowLibraryEvidence, collectWorkflowInstructionPacketEvidence } from "./collectWorkflowInstructionEvidence.js";
|
|
5
|
+
export { matchStageContextExpectations } from "./matchStageContextExpectations.js";
|
|
6
|
+
export { calculateAllowedEvidenceCoverage, calculateForbiddenEvidenceInclusion, calculateIrrelevantFileInclusion, calculateIrrelevantInstructionInclusion, calculateRequiredEvidenceRecall, calculateRequiredProvenanceRecall } from "./calculateExpectationMetrics.js";
|
|
7
|
+
export { compareExpectedContextCapsuleState, compareExpectedRetrievalAuditState, compareExpectedTargetImmutabilityState, compareExpectedWorkflowInstructionPacketState } from "./calculateArtifactStateMetrics.js";
|
|
8
|
+
export { calculateContextCapsuleResponsibilityMappingMetric, calculateRetrievalAuditResponsibilityMappingMetric } from "./calculateResponsibilityMappingMetrics.js";
|
|
9
|
+
export { calculateV043ExecutionContextSize } from "./calculateContextSizeMetrics.js";
|
|
10
|
+
export { evaluateV043StageContextExecution } from "./evaluateV043StageContextExecution.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { buildStageContextExpectationTargetKey } from "./targetKeys.js";
|
|
2
|
+
function dedupeStrings(values) {
|
|
3
|
+
const seen = new Set();
|
|
4
|
+
const result = [];
|
|
5
|
+
for (const value of values) {
|
|
6
|
+
if (seen.has(value))
|
|
7
|
+
continue;
|
|
8
|
+
seen.add(value);
|
|
9
|
+
result.push(value);
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
export function matchStageContextExpectations(expectations, observedEvidence) {
|
|
14
|
+
return expectations.expectedEvidence.map((item) => {
|
|
15
|
+
const targetKey = buildStageContextExpectationTargetKey(item);
|
|
16
|
+
const observedMatches = observedEvidence.filter((evidence) => evidence.sourceArtifact === item.sourceArtifact && evidence.category === item.category && evidence.targetKey === targetKey);
|
|
17
|
+
const matchedSourceInstances = dedupeStrings(observedMatches.map((evidence) => evidence.sourceInstance));
|
|
18
|
+
const matchedSourceFieldPaths = dedupeStrings(observedMatches.map((evidence) => evidence.sourceFieldPath));
|
|
19
|
+
const hasMatch = observedMatches.length > 0;
|
|
20
|
+
let outcome;
|
|
21
|
+
if (item.inclusion === "forbidden") {
|
|
22
|
+
outcome = hasMatch ? "violated" : "matched";
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
outcome = hasMatch ? "matched" : "missing";
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
expectationId: item.expectationId,
|
|
29
|
+
inclusion: item.inclusion,
|
|
30
|
+
sourceArtifact: item.sourceArtifact,
|
|
31
|
+
category: item.category,
|
|
32
|
+
targetKey,
|
|
33
|
+
outcome,
|
|
34
|
+
matchedSourceInstances,
|
|
35
|
+
matchedSourceFieldPaths
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function buildStageContextExpectationTargetKey(item) {
|
|
2
|
+
switch (item.category) {
|
|
3
|
+
case "file":
|
|
4
|
+
case "test-file":
|
|
5
|
+
case "fixture":
|
|
6
|
+
case "factory":
|
|
7
|
+
case "mock":
|
|
8
|
+
case "setup-file":
|
|
9
|
+
case "test-configuration":
|
|
10
|
+
return `${item.sourceArtifact}|${item.category}|path:${item.match.path}`;
|
|
11
|
+
case "symbol":
|
|
12
|
+
case "contract":
|
|
13
|
+
case "validator":
|
|
14
|
+
case "constant":
|
|
15
|
+
case "error":
|
|
16
|
+
case "schema-or-serializer":
|
|
17
|
+
return `${item.sourceArtifact}|${item.category}|symbolId:${item.match.symbolId}`;
|
|
18
|
+
case "source-range":
|
|
19
|
+
return `context-capsule|source-range|filePath:${item.match.filePath}|startLine:${item.match.startLine}|endLine:${item.match.endLine}`;
|
|
20
|
+
case "production-responsibility":
|
|
21
|
+
return `${item.sourceArtifact}|production-responsibility|responsibilityId:${item.match.responsibilityId}`;
|
|
22
|
+
case "package-script":
|
|
23
|
+
return `context-capsule|package-script|name:${item.match.name}`;
|
|
24
|
+
case "test-command":
|
|
25
|
+
return `context-capsule|test-command|commandText:${item.match.commandText}`;
|
|
26
|
+
case "workflow":
|
|
27
|
+
case "stage":
|
|
28
|
+
case "command":
|
|
29
|
+
case "rule":
|
|
30
|
+
case "report-contract":
|
|
31
|
+
return `${item.sourceArtifact}|${item.category}|id:${item.match.id}`;
|
|
32
|
+
case "provenance":
|
|
33
|
+
return `${item.sourceArtifact}|provenance|evidenceId:${item.match.evidenceId}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
export function checkMyDevKitContextArtifactConsistency(capsule, audit) {
|
|
3
|
+
const comparisons = [
|
|
4
|
+
{ fieldPath: "schemaVersion", capsuleValue: capsule.schemaVersion, auditValue: audit.schemaVersion },
|
|
5
|
+
{
|
|
6
|
+
fieldPath: "tool",
|
|
7
|
+
capsuleValue: capsule.tool,
|
|
8
|
+
auditValue: audit.tool
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
fieldPath: "request",
|
|
12
|
+
capsuleValue: capsule.request,
|
|
13
|
+
auditValue: audit.request
|
|
14
|
+
},
|
|
15
|
+
{ fieldPath: "index.indexPath", capsuleValue: capsule.index.indexPath, auditValue: audit.index.indexPath },
|
|
16
|
+
{
|
|
17
|
+
fieldPath: "index.manifestPath",
|
|
18
|
+
capsuleValue: capsule.index.manifestPath,
|
|
19
|
+
auditValue: audit.index.manifestPath
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
fieldPath: "contextAdequacy",
|
|
23
|
+
capsuleValue: capsule.contextAdequacy,
|
|
24
|
+
auditValue: audit.contextAdequacy
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
fieldPath: "roleContext",
|
|
28
|
+
capsuleValue: capsule.roleContext,
|
|
29
|
+
auditValue: audit.roleContext
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
fieldPath: "responsibilityMappings",
|
|
33
|
+
capsuleValue: capsule.responsibilityMappings,
|
|
34
|
+
auditValue: audit.responsibilityMappings
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
fieldPath: "roleAdequacy",
|
|
38
|
+
capsuleValue: capsule.roleAdequacy,
|
|
39
|
+
auditValue: audit.roleAdequacy
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
fieldPath: "freshness",
|
|
43
|
+
capsuleValue: capsule.freshness,
|
|
44
|
+
auditValue: audit.freshness
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
fieldPath: "budget",
|
|
48
|
+
capsuleValue: capsule.budget,
|
|
49
|
+
auditValue: audit.budget
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
fieldPath: "truncation",
|
|
53
|
+
capsuleValue: capsule.truncation,
|
|
54
|
+
auditValue: audit.truncation
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
fieldPath: "fullFileFallback",
|
|
58
|
+
capsuleValue: capsule.fullFileFallback,
|
|
59
|
+
auditValue: audit.fullFileFallback
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
fieldPath: "provenance",
|
|
63
|
+
capsuleValue: capsule.provenance,
|
|
64
|
+
auditValue: audit.provenance
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
const issues = [];
|
|
68
|
+
for (const comparison of comparisons) {
|
|
69
|
+
if (!isDeepStrictEqual(comparison.capsuleValue, comparison.auditValue)) {
|
|
70
|
+
issues.push({
|
|
71
|
+
fieldPath: comparison.fieldPath,
|
|
72
|
+
capsuleValue: comparison.capsuleValue,
|
|
73
|
+
auditValue: comparison.auditValue,
|
|
74
|
+
message: `ContextCapsule and RetrievalAuditRecord differ at "${comparison.fieldPath}".`
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { consistent: issues.length === 0, issues };
|
|
79
|
+
}
|