@dailephd/my-dev-kit-lab 0.4.2 → 0.4.4
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 +28 -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/producerReadinessExpectationTypes.js +8 -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 +768 -0
- package/dist/src/evaluation/stageContextMetrics/calculateAllocationMetrics.js +96 -0
- package/dist/src/evaluation/stageContextMetrics/calculateArtifactStateMetrics.js +130 -0
- package/dist/src/evaluation/stageContextMetrics/calculateContextSizeMetrics.js +85 -0
- package/dist/src/evaluation/stageContextMetrics/calculateCriticalityMetrics.js +112 -0
- package/dist/src/evaluation/stageContextMetrics/calculateExpectationMetrics.js +103 -0
- package/dist/src/evaluation/stageContextMetrics/calculateOwnerMetrics.js +84 -0
- package/dist/src/evaluation/stageContextMetrics/calculateReadinessAgreement.js +152 -0
- package/dist/src/evaluation/stageContextMetrics/calculateResponsibilityMappingMetrics.js +36 -0
- package/dist/src/evaluation/stageContextMetrics/calculateSupplementalRawAgreement.js +50 -0
- package/dist/src/evaluation/stageContextMetrics/calculateTruncationClassification.js +44 -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/evaluateProducerReadinessBridge.js +127 -0
- package/dist/src/evaluation/stageContextMetrics/evaluateV043StageContextExecution.js +247 -0
- package/dist/src/evaluation/stageContextMetrics/index.js +17 -0
- package/dist/src/evaluation/stageContextMetrics/matchStageContextExpectations.js +38 -0
- package/dist/src/evaluation/stageContextMetrics/producerReadinessMetricTypes.js +1 -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 +89 -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 +9 -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/orchestratorContextReadinessResultV1.js +247 -0
- package/dist/src/evaluation/upstreamArtifacts/orchestratorWorkflowInstructionPacketV1.js +1 -0
- package/dist/src/evaluation/upstreamArtifacts/readImplementationContextPacketV1.js +9 -0
- package/dist/src/evaluation/upstreamArtifacts/readImplementationContextRetrievalReportV1.js +9 -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/readSupplementalContextTextFile.js +29 -0
- package/dist/src/evaluation/upstreamArtifacts/readTestContextPacketV1.js +9 -0
- package/dist/src/evaluation/upstreamArtifacts/readTestContextRetrievalReportV1.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/supplementalContextTextParser.js +75 -0
- package/dist/src/evaluation/upstreamArtifacts/supplementalContextTypes.js +152 -0
- package/dist/src/evaluation/upstreamArtifacts/validateMyDevKitContextCapsuleV1.js +1208 -0
- package/dist/src/evaluation/upstreamArtifacts/validateMyDevKitRetrievalAuditRecordV1.js +112 -0
- package/dist/src/evaluation/upstreamArtifacts/validateOrchestratorWorkflowInstructionPacketV1.js +235 -0
- package/dist/src/evaluation/upstreamArtifacts/validateSupplementalContextDocumentV1.js +148 -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 +397 -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 +205 -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 +266 -0
- package/dist/src/report/experiments/buildContextStrategyComparisonV043Report.js +520 -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 +296 -0
- package/dist/src/report/experiments/renderPluginExperimentReportHtml.js +3 -0
- package/dist/src/report/experiments/renderPluginExperimentReportText.js +292 -0
- package/dist/src/report/experiments/writePluginExperimentReports.js +3 -0
- package/dist/src/securityValidation/attackScenarios/scenarios/secretLeakageScenario.js +215 -9
- package/docs/METRICS.md +84 -10
- package/package.json +2 -2
- 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-1.10.2-identity/PROVENANCE.txt +13 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit-1.10.2-identity/context-capsule.json +7874 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit-1.10.2-identity/retrieval-audit-record.json +1076 -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,152 @@
|
|
|
1
|
+
// v0.4.4 Batch 2: readiness/raw-evidence agreement. Readiness stays observed consumer
|
|
2
|
+
// output (Batch 1) -- this module only compares it against an explicit fixture-declared
|
|
3
|
+
// expectation. It never calls, imports, or reimplements contextReadiness.ts.
|
|
4
|
+
import { checkSupplementalReadinessIdentityConsistency } from "../upstreamArtifacts/index.js";
|
|
5
|
+
function unavailableStructural(field, reason) {
|
|
6
|
+
return { field, expectedValue: null, observedValue: null, agreement: null, availability: "unavailable", reason };
|
|
7
|
+
}
|
|
8
|
+
export function calculateReadinessStructuralAgreement(readiness, supplementalPacket, packetSourcePath) {
|
|
9
|
+
const results = [];
|
|
10
|
+
if (readiness === undefined) {
|
|
11
|
+
results.push(unavailableStructural("canonicalRepositoryIdentity", "No readiness result was supplied."));
|
|
12
|
+
results.push(unavailableStructural("packetPath", "No readiness result was supplied."));
|
|
13
|
+
return results;
|
|
14
|
+
}
|
|
15
|
+
if (supplementalPacket === undefined) {
|
|
16
|
+
results.push(unavailableStructural("canonicalRepositoryIdentity", "No supplemental document was supplied to compare against readiness."));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const diagnostic = checkSupplementalReadinessIdentityConsistency(supplementalPacket, readiness);
|
|
20
|
+
results.push({
|
|
21
|
+
field: "canonicalRepositoryIdentity",
|
|
22
|
+
expectedValue: supplementalPacket.indexIdentity,
|
|
23
|
+
observedValue: readiness.indexIdentity ?? null,
|
|
24
|
+
agreement: diagnostic === null,
|
|
25
|
+
availability: readiness.indexIdentity === undefined ? "unavailable" : "available",
|
|
26
|
+
reason: readiness.indexIdentity === undefined ? "The readiness result does not declare indexIdentity." : diagnostic?.message ?? null
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (packetSourcePath === undefined) {
|
|
30
|
+
results.push(unavailableStructural("packetPath", "No packet source path was supplied to compare against readiness.packetPath."));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
results.push({
|
|
34
|
+
field: "packetPath",
|
|
35
|
+
expectedValue: packetSourcePath,
|
|
36
|
+
observedValue: readiness.packetPath,
|
|
37
|
+
agreement: packetSourcePath === readiness.packetPath,
|
|
38
|
+
availability: "available",
|
|
39
|
+
reason: null
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return results;
|
|
43
|
+
}
|
|
44
|
+
export function calculateReadinessDecisionAgreement(readiness, expectation) {
|
|
45
|
+
if (expectation === undefined) {
|
|
46
|
+
return {
|
|
47
|
+
availability: "not-applicable",
|
|
48
|
+
observedDecision: readiness?.decision ?? null,
|
|
49
|
+
allowedDecisions: null,
|
|
50
|
+
decisionAgreement: null,
|
|
51
|
+
observedClassification: readiness?.classification ?? null,
|
|
52
|
+
expectedClassification: null,
|
|
53
|
+
classificationAgreement: null,
|
|
54
|
+
observedIssueCodes: readiness?.blockingIssueCodes ?? [],
|
|
55
|
+
expectedIssueCodes: null,
|
|
56
|
+
issueCodesAgreement: null,
|
|
57
|
+
observedPrimaryIssueCode: readiness?.primaryIssue?.code ?? null,
|
|
58
|
+
expectedPrimaryIssueCode: null,
|
|
59
|
+
primaryIssueAgreement: null,
|
|
60
|
+
reason: "The expectation fixture declares no readiness expectation."
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (readiness === undefined) {
|
|
64
|
+
return {
|
|
65
|
+
availability: "unavailable",
|
|
66
|
+
observedDecision: null,
|
|
67
|
+
allowedDecisions: expectation.allowedDecisions ?? null,
|
|
68
|
+
decisionAgreement: null,
|
|
69
|
+
observedClassification: null,
|
|
70
|
+
expectedClassification: expectation.expectedClassification ?? null,
|
|
71
|
+
classificationAgreement: null,
|
|
72
|
+
observedIssueCodes: [],
|
|
73
|
+
expectedIssueCodes: expectation.expectedIssueCodes ?? null,
|
|
74
|
+
issueCodesAgreement: null,
|
|
75
|
+
observedPrimaryIssueCode: null,
|
|
76
|
+
expectedPrimaryIssueCode: expectation.expectedPrimaryIssueCode ?? null,
|
|
77
|
+
primaryIssueAgreement: null,
|
|
78
|
+
reason: "No readiness result was supplied."
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const decisionAgreement = expectation.allowedDecisions === undefined ? null : expectation.allowedDecisions.includes(readiness.decision);
|
|
82
|
+
const classificationAgreement = expectation.expectedClassification === undefined ? null : expectation.expectedClassification === readiness.classification;
|
|
83
|
+
const issueCodesAgreement = expectation.expectedIssueCodes === undefined
|
|
84
|
+
? null
|
|
85
|
+
: expectation.expectedIssueCodes.length === readiness.blockingIssueCodes.length &&
|
|
86
|
+
expectation.expectedIssueCodes.every((code) => readiness.blockingIssueCodes.includes(code));
|
|
87
|
+
const primaryIssueAgreement = expectation.expectedPrimaryIssueCode === undefined
|
|
88
|
+
? null
|
|
89
|
+
: expectation.expectedPrimaryIssueCode === (readiness.primaryIssue?.code ?? null);
|
|
90
|
+
return {
|
|
91
|
+
availability: "available",
|
|
92
|
+
observedDecision: readiness.decision,
|
|
93
|
+
allowedDecisions: expectation.allowedDecisions ?? null,
|
|
94
|
+
decisionAgreement,
|
|
95
|
+
observedClassification: readiness.classification,
|
|
96
|
+
expectedClassification: expectation.expectedClassification ?? null,
|
|
97
|
+
classificationAgreement,
|
|
98
|
+
observedIssueCodes: readiness.blockingIssueCodes,
|
|
99
|
+
expectedIssueCodes: expectation.expectedIssueCodes ?? null,
|
|
100
|
+
issueCodesAgreement,
|
|
101
|
+
observedPrimaryIssueCode: readiness.primaryIssue?.code ?? null,
|
|
102
|
+
expectedPrimaryIssueCode: expectation.expectedPrimaryIssueCode ?? null,
|
|
103
|
+
primaryIssueAgreement,
|
|
104
|
+
reason: null
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export function calculateInvalidReady(readiness, expectation) {
|
|
108
|
+
if (readiness === undefined) {
|
|
109
|
+
return { availability: "unavailable", invalidReady: null, observedDecision: null, expectedBlockingDecision: false, missingExpectedIssueCodes: [], reason: "No readiness result was supplied." };
|
|
110
|
+
}
|
|
111
|
+
if (expectation === undefined) {
|
|
112
|
+
return { availability: "not-applicable", invalidReady: null, observedDecision: readiness.decision, expectedBlockingDecision: false, missingExpectedIssueCodes: [], reason: "The expectation fixture declares no readiness expectation." };
|
|
113
|
+
}
|
|
114
|
+
const expectsBlocking = (expectation.allowedDecisions !== undefined &&
|
|
115
|
+
!expectation.allowedDecisions.includes("ready") &&
|
|
116
|
+
(expectation.allowedDecisions.includes("refresh-required") || expectation.allowedDecisions.length > 0)) ||
|
|
117
|
+
(expectation.expectedIssueCodes !== undefined && expectation.expectedIssueCodes.length > 0);
|
|
118
|
+
if (!expectsBlocking) {
|
|
119
|
+
return { availability: "not-applicable", invalidReady: null, observedDecision: readiness.decision, expectedBlockingDecision: false, missingExpectedIssueCodes: [], reason: "The expectation fixture does not require blocked or refresh-required behavior." };
|
|
120
|
+
}
|
|
121
|
+
if (readiness.decision !== "ready") {
|
|
122
|
+
return { availability: "available", invalidReady: false, observedDecision: readiness.decision, expectedBlockingDecision: true, missingExpectedIssueCodes: [], reason: null };
|
|
123
|
+
}
|
|
124
|
+
const expectedCodes = expectation.expectedIssueCodes ?? [];
|
|
125
|
+
const missing = expectedCodes.filter((code) => !readiness.blockingIssueCodes.includes(code));
|
|
126
|
+
return { availability: "available", invalidReady: true, observedDecision: readiness.decision, expectedBlockingDecision: true, missingExpectedIssueCodes: missing, reason: null };
|
|
127
|
+
}
|
|
128
|
+
export function calculateValidBlocked(readiness, expectation) {
|
|
129
|
+
if (readiness === undefined) {
|
|
130
|
+
return { availability: "unavailable", validBlocked: null, validRefreshRequired: null, observedDecision: null, reason: "No readiness result was supplied." };
|
|
131
|
+
}
|
|
132
|
+
if (expectation === undefined) {
|
|
133
|
+
return { availability: "not-applicable", validBlocked: null, validRefreshRequired: null, observedDecision: readiness.decision, reason: "The expectation fixture declares no readiness expectation." };
|
|
134
|
+
}
|
|
135
|
+
if (readiness.decision !== "refresh-required") {
|
|
136
|
+
return { availability: "available", validBlocked: false, validRefreshRequired: false, observedDecision: readiness.decision, reason: null };
|
|
137
|
+
}
|
|
138
|
+
const allowsRefreshRequired = expectation.allowedDecisions === undefined || expectation.allowedDecisions.includes("refresh-required");
|
|
139
|
+
const issueCodesMatch = expectation.expectedIssueCodes === undefined ||
|
|
140
|
+
expectation.expectedIssueCodes.every((code) => readiness.blockingIssueCodes.includes(code));
|
|
141
|
+
const primaryMatches = expectation.expectedPrimaryIssueCode === undefined || expectation.expectedPrimaryIssueCode === (readiness.primaryIssue?.code ?? null);
|
|
142
|
+
const valid = allowsRefreshRequired && issueCodesMatch && primaryMatches;
|
|
143
|
+
return { availability: "available", validBlocked: valid, validRefreshRequired: valid, observedDecision: readiness.decision, reason: null };
|
|
144
|
+
}
|
|
145
|
+
export function calculateReadinessAgreementMetrics(readiness, expectation, supplementalPacket, packetSourcePath) {
|
|
146
|
+
return {
|
|
147
|
+
structuralAgreement: calculateReadinessStructuralAgreement(readiness, supplementalPacket, packetSourcePath),
|
|
148
|
+
decisionAgreement: calculateReadinessDecisionAgreement(readiness, expectation),
|
|
149
|
+
invalidReady: calculateInvalidReady(readiness, expectation),
|
|
150
|
+
validBlocked: calculateValidBlocked(readiness, expectation)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function buildMetric(sourceArtifact, sourceInstance, requested, operational, mappings) {
|
|
2
|
+
let mappedCount = 0;
|
|
3
|
+
let partiallyMappedCount = 0;
|
|
4
|
+
let unmappedCount = 0;
|
|
5
|
+
let notApplicableCount = 0;
|
|
6
|
+
for (const mapping of mappings) {
|
|
7
|
+
if (mapping.mappingStatus === "mapped")
|
|
8
|
+
mappedCount += 1;
|
|
9
|
+
else if (mapping.mappingStatus === "partially-mapped")
|
|
10
|
+
partiallyMappedCount += 1;
|
|
11
|
+
else if (mapping.mappingStatus === "unmapped")
|
|
12
|
+
unmappedCount += 1;
|
|
13
|
+
else if (mapping.mappingStatus === "not-applicable")
|
|
14
|
+
notApplicableCount += 1;
|
|
15
|
+
}
|
|
16
|
+
const denominator = mappedCount + partiallyMappedCount + unmappedCount;
|
|
17
|
+
const mappedRate = denominator > 0 ? mappedCount / denominator : null;
|
|
18
|
+
return {
|
|
19
|
+
sourceArtifact,
|
|
20
|
+
sourceInstance,
|
|
21
|
+
requested,
|
|
22
|
+
operational,
|
|
23
|
+
mappedCount,
|
|
24
|
+
partiallyMappedCount,
|
|
25
|
+
unmappedCount,
|
|
26
|
+
notApplicableCount,
|
|
27
|
+
denominator,
|
|
28
|
+
mappedRate
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function calculateContextCapsuleResponsibilityMappingMetric(artifact, sourceInstance) {
|
|
32
|
+
return buildMetric("context-capsule", sourceInstance, artifact.responsibilityMappings.requested, artifact.responsibilityMappings.operational, artifact.responsibilityMappings.mappings);
|
|
33
|
+
}
|
|
34
|
+
export function calculateRetrievalAuditResponsibilityMappingMetric(artifact, sourceInstance) {
|
|
35
|
+
return buildMetric("retrieval-audit-record", sourceInstance, artifact.responsibilityMappings.requested, artifact.responsibilityMappings.operational, artifact.responsibilityMappings.mappings);
|
|
36
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function extractRawIdentity(artifact) {
|
|
2
|
+
return {
|
|
3
|
+
projectRoot: artifact.index.projectRoot,
|
|
4
|
+
role: artifact.request.role,
|
|
5
|
+
freshnessState: artifact.freshness.state,
|
|
6
|
+
truncated: artifact.truncation.truncated
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function truncationToYesNo(value) {
|
|
10
|
+
return value ? "yes" : "no";
|
|
11
|
+
}
|
|
12
|
+
function buildField(field, rawValue, supplementalValue, unavailableReason) {
|
|
13
|
+
if (unavailableReason !== null) {
|
|
14
|
+
return { field, rawValue, supplementalValue, agreement: null, availability: "unavailable", reason: unavailableReason };
|
|
15
|
+
}
|
|
16
|
+
return { field, rawValue, supplementalValue, agreement: rawValue === supplementalValue, availability: "available", reason: null };
|
|
17
|
+
}
|
|
18
|
+
export function calculateSupplementalRawAgreement(supplemental, raw) {
|
|
19
|
+
if (supplemental === undefined || raw === undefined) {
|
|
20
|
+
const reason = supplemental === undefined && raw === undefined
|
|
21
|
+
? "Neither a supplemental document nor a raw artifact was supplied."
|
|
22
|
+
: supplemental === undefined
|
|
23
|
+
? "No supplemental document was supplied."
|
|
24
|
+
: "No raw context-capsule or retrieval-audit artifact was supplied.";
|
|
25
|
+
const fields = [
|
|
26
|
+
buildField("canonicalRepositoryIdentity", null, supplemental?.indexIdentity ?? null, reason),
|
|
27
|
+
buildField("role", null, supplemental?.role ?? null, reason),
|
|
28
|
+
buildField("freshness", null, supplemental?.freshness ?? null, reason),
|
|
29
|
+
buildField("requiredEvidenceTruncated", null, supplemental?.requiredEvidenceTruncated ?? null, reason)
|
|
30
|
+
];
|
|
31
|
+
return { fields, contradictions: [], upstreamProducerParityPreserved: null };
|
|
32
|
+
}
|
|
33
|
+
const rawIdentity = extractRawIdentity(raw);
|
|
34
|
+
const fields = [];
|
|
35
|
+
fields.push(buildField("canonicalRepositoryIdentity", rawIdentity.projectRoot ?? null, supplemental.indexIdentity, rawIdentity.projectRoot === undefined ? "The raw artifact does not declare index.projectRoot." : null));
|
|
36
|
+
const roleComparable = rawIdentity.role === "implementation" || rawIdentity.role === "test-implementation";
|
|
37
|
+
fields.push(buildField("role", rawIdentity.role, supplemental.role, roleComparable ? null : `Raw role "${rawIdentity.role}" has no supplemental-document counterpart in this vocabulary.`));
|
|
38
|
+
fields.push(buildField("freshness", rawIdentity.freshnessState, supplemental.freshness, null));
|
|
39
|
+
fields.push(buildField("requiredEvidenceTruncated", truncationToYesNo(rawIdentity.truncated), supplemental.requiredEvidenceTruncated, supplemental.requiredEvidenceTruncated === "unknown"
|
|
40
|
+
? "The supplemental document declares truncation as \"unknown\", so agreement with the raw boolean cannot be determined."
|
|
41
|
+
: null));
|
|
42
|
+
const contradictions = fields.filter((f) => f.availability === "available" && f.agreement === false);
|
|
43
|
+
return {
|
|
44
|
+
fields,
|
|
45
|
+
contradictions,
|
|
46
|
+
// A successfully read raw pair is itself the observed outcome of the frozen
|
|
47
|
+
// assertRawEvidenceParity() write-time guard; see file header. Never recomputed here.
|
|
48
|
+
upstreamProducerParityPreserved: true
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function classifyTruncationRecord(record, sourceArtifact, sourceInstance) {
|
|
2
|
+
const base = {
|
|
3
|
+
groupId: record.affectedGroup,
|
|
4
|
+
sourceArtifact,
|
|
5
|
+
sourceInstance,
|
|
6
|
+
limit: record.limit,
|
|
7
|
+
used: record.used,
|
|
8
|
+
available: record.available,
|
|
9
|
+
omittedRequiredEvidenceIds: record.requiredEvidenceLost ? record.droppedEvidenceIds : []
|
|
10
|
+
};
|
|
11
|
+
if (!record.requiredEvidenceLost) {
|
|
12
|
+
return {
|
|
13
|
+
...base,
|
|
14
|
+
cause: "none",
|
|
15
|
+
availability: "available",
|
|
16
|
+
reason: "No fixture-required evidence was reported lost for this group."
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (record.limit === null) {
|
|
20
|
+
return {
|
|
21
|
+
...base,
|
|
22
|
+
cause: "unresolved",
|
|
23
|
+
availability: "available",
|
|
24
|
+
reason: "Required evidence was lost but no hard limit is declared for this group, so avoidability cannot be proven either way."
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (record.used < record.limit) {
|
|
28
|
+
return {
|
|
29
|
+
...base,
|
|
30
|
+
cause: "avoidable",
|
|
31
|
+
availability: "available",
|
|
32
|
+
reason: `Required evidence was lost while used (${record.used}) remained below the declared limit (${record.limit}); compatible headroom existed under the hard limit.`
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
...base,
|
|
37
|
+
cause: "genuine-hard-limit",
|
|
38
|
+
availability: "available",
|
|
39
|
+
reason: `Required evidence was lost and used (${record.used}) reached or exceeded the declared limit (${record.limit}); no compatible headroom remained.`
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function classifyTruncationRecords(records, sourceArtifact, sourceInstance) {
|
|
43
|
+
return records.map((record) => classifyTruncationRecord(record, sourceArtifact, sourceInstance));
|
|
44
|
+
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
const SOURCE_ARTIFACT = "context-capsule";
|
|
2
|
+
function pathKey(category, path) {
|
|
3
|
+
return `${SOURCE_ARTIFACT}|${category}|path:${path}`;
|
|
4
|
+
}
|
|
5
|
+
function symbolKey(category, symbolId) {
|
|
6
|
+
return `${SOURCE_ARTIFACT}|${category}|symbolId:${symbolId}`;
|
|
7
|
+
}
|
|
8
|
+
function sourceRangeKey(filePath, startLine, endLine) {
|
|
9
|
+
return `context-capsule|source-range|filePath:${filePath}|startLine:${startLine}|endLine:${endLine}`;
|
|
10
|
+
}
|
|
11
|
+
function responsibilityKey(responsibilityId) {
|
|
12
|
+
return `${SOURCE_ARTIFACT}|production-responsibility|responsibilityId:${responsibilityId}`;
|
|
13
|
+
}
|
|
14
|
+
function packageScriptKey(name) {
|
|
15
|
+
return `context-capsule|package-script|name:${name}`;
|
|
16
|
+
}
|
|
17
|
+
function testCommandKey(commandText) {
|
|
18
|
+
return `context-capsule|test-command|commandText:${commandText}`;
|
|
19
|
+
}
|
|
20
|
+
function provenanceKey(evidenceId) {
|
|
21
|
+
return `${SOURCE_ARTIFACT}|provenance|evidenceId:${evidenceId}`;
|
|
22
|
+
}
|
|
23
|
+
function pushFileEvidenceFromRefs(records, items, fieldPrefix, category, sourceInstance) {
|
|
24
|
+
items.forEach((item, index) => {
|
|
25
|
+
if (item.path !== undefined) {
|
|
26
|
+
records.push({
|
|
27
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
28
|
+
sourceInstance,
|
|
29
|
+
category,
|
|
30
|
+
targetKey: pathKey(category, item.path),
|
|
31
|
+
sourceFieldPath: `${fieldPrefix}[${index}].path`
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (item.sourceLocation?.filePath !== undefined) {
|
|
35
|
+
records.push({
|
|
36
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
37
|
+
sourceInstance,
|
|
38
|
+
category,
|
|
39
|
+
targetKey: pathKey(category, item.sourceLocation.filePath),
|
|
40
|
+
sourceFieldPath: `${fieldPrefix}[${index}].sourceLocation.filePath`
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function pushSymbolEvidenceFromRefs(records, items, fieldPrefix, category, sourceInstance) {
|
|
46
|
+
items.forEach((item, index) => {
|
|
47
|
+
if (item.symbolId !== undefined) {
|
|
48
|
+
records.push({
|
|
49
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
50
|
+
sourceInstance,
|
|
51
|
+
category,
|
|
52
|
+
targetKey: symbolKey(category, item.symbolId),
|
|
53
|
+
sourceFieldPath: `${fieldPrefix}[${index}].symbolId`
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (item.nodeId !== undefined) {
|
|
57
|
+
records.push({
|
|
58
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
59
|
+
sourceInstance,
|
|
60
|
+
category,
|
|
61
|
+
targetKey: symbolKey(category, item.nodeId),
|
|
62
|
+
sourceFieldPath: `${fieldPrefix}[${index}].nodeId`
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function dedupeEvidence(records) {
|
|
68
|
+
const seen = new Set();
|
|
69
|
+
const result = [];
|
|
70
|
+
for (const record of records) {
|
|
71
|
+
const key = `${record.sourceInstance} ${record.category} ${record.targetKey}`;
|
|
72
|
+
if (seen.has(key))
|
|
73
|
+
continue;
|
|
74
|
+
seen.add(key);
|
|
75
|
+
result.push(record);
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
export function collectContextCapsuleEvidence(artifact, sourceInstance) {
|
|
80
|
+
const records = [];
|
|
81
|
+
// Section 25: general file evidence
|
|
82
|
+
artifact.candidateFiles.forEach((candidate, index) => {
|
|
83
|
+
if (candidate.retained) {
|
|
84
|
+
records.push({
|
|
85
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
86
|
+
sourceInstance,
|
|
87
|
+
category: "file",
|
|
88
|
+
targetKey: pathKey("file", candidate.path),
|
|
89
|
+
sourceFieldPath: `candidateFiles[${index}].path`
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
artifact.selectedGraph.nodes.forEach((node, index) => {
|
|
94
|
+
if (node.filePath !== undefined) {
|
|
95
|
+
records.push({
|
|
96
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
97
|
+
sourceInstance,
|
|
98
|
+
category: "file",
|
|
99
|
+
targetKey: pathKey("file", node.filePath),
|
|
100
|
+
sourceFieldPath: `selectedGraph.nodes[${index}].filePath`
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
artifact.selectedSource.slices.forEach((slice, index) => {
|
|
105
|
+
records.push({
|
|
106
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
107
|
+
sourceInstance,
|
|
108
|
+
category: "file",
|
|
109
|
+
targetKey: pathKey("file", slice.filePath),
|
|
110
|
+
sourceFieldPath: `selectedSource.slices[${index}].filePath`
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
artifact.selectedSourceBundles.bundles.forEach((bundle, bundleIndex) => {
|
|
114
|
+
bundle.blocks.forEach((block, blockIndex) => {
|
|
115
|
+
records.push({
|
|
116
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
117
|
+
sourceInstance,
|
|
118
|
+
category: "file",
|
|
119
|
+
targetKey: pathKey("file", block.filePath),
|
|
120
|
+
sourceFieldPath: `selectedSourceBundles.bundles[${bundleIndex}].blocks[${blockIndex}].filePath`
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
artifact.roleContext.changedSurface.files.forEach((file, index) => {
|
|
125
|
+
records.push({
|
|
126
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
127
|
+
sourceInstance,
|
|
128
|
+
category: "file",
|
|
129
|
+
targetKey: pathKey("file", file.path),
|
|
130
|
+
sourceFieldPath: `roleContext.changedSurface.files[${index}].path`
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
artifact.evidenceGroups.forEach((group, groupIndex) => {
|
|
134
|
+
pushFileEvidenceFromRefs(records, group.items, `evidenceGroups[${groupIndex}].items`, "file", sourceInstance);
|
|
135
|
+
});
|
|
136
|
+
pushFileEvidenceFromRefs(records, artifact.selectedOwners, "selectedOwners", "file", sourceInstance);
|
|
137
|
+
pushFileEvidenceFromRefs(records, artifact.selectedContracts, "selectedContracts", "file", sourceInstance);
|
|
138
|
+
pushFileEvidenceFromRefs(records, artifact.selectedTests, "selectedTests", "file", sourceInstance);
|
|
139
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.relatedTests, "testInfrastructure.relatedTests", "file", sourceInstance);
|
|
140
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.fixtures, "testInfrastructure.fixtures", "file", sourceInstance);
|
|
141
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.factories, "testInfrastructure.factories", "file", sourceInstance);
|
|
142
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.mocks, "testInfrastructure.mocks", "file", sourceInstance);
|
|
143
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.setupFiles, "testInfrastructure.setupFiles", "file", sourceInstance);
|
|
144
|
+
artifact.testInfrastructure.testConfigurations.forEach((config, index) => {
|
|
145
|
+
records.push({
|
|
146
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
147
|
+
sourceInstance,
|
|
148
|
+
category: "file",
|
|
149
|
+
targetKey: pathKey("file", config.path),
|
|
150
|
+
sourceFieldPath: `testInfrastructure.testConfigurations[${index}].path`
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
artifact.testInfrastructure.packageScripts.forEach((script, index) => {
|
|
154
|
+
records.push({
|
|
155
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
156
|
+
sourceInstance,
|
|
157
|
+
category: "file",
|
|
158
|
+
targetKey: pathKey("file", script.packageJsonPath),
|
|
159
|
+
sourceFieldPath: `testInfrastructure.packageScripts[${index}].packageJsonPath`
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
artifact.testInfrastructure.testCommands.forEach((command, commandIndex) => {
|
|
163
|
+
command.testFiles.forEach((testFile, fileIndex) => {
|
|
164
|
+
records.push({
|
|
165
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
166
|
+
sourceInstance,
|
|
167
|
+
category: "file",
|
|
168
|
+
targetKey: pathKey("file", testFile),
|
|
169
|
+
sourceFieldPath: `testInfrastructure.testCommands[${commandIndex}].testFiles[${fileIndex}]`
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
// Section 26: specific path-category evidence
|
|
174
|
+
pushFileEvidenceFromRefs(records, artifact.selectedTests, "selectedTests", "test-file", sourceInstance);
|
|
175
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.relatedTests, "testInfrastructure.relatedTests", "test-file", sourceInstance);
|
|
176
|
+
artifact.testInfrastructure.testCommands.forEach((command, commandIndex) => {
|
|
177
|
+
command.testFiles.forEach((testFile, fileIndex) => {
|
|
178
|
+
records.push({
|
|
179
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
180
|
+
sourceInstance,
|
|
181
|
+
category: "test-file",
|
|
182
|
+
targetKey: pathKey("test-file", testFile),
|
|
183
|
+
sourceFieldPath: `testInfrastructure.testCommands[${commandIndex}].testFiles[${fileIndex}]`
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.fixtures, "testInfrastructure.fixtures", "fixture", sourceInstance);
|
|
188
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.factories, "testInfrastructure.factories", "factory", sourceInstance);
|
|
189
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.mocks, "testInfrastructure.mocks", "mock", sourceInstance);
|
|
190
|
+
pushFileEvidenceFromRefs(records, artifact.testInfrastructure.setupFiles, "testInfrastructure.setupFiles", "setup-file", sourceInstance);
|
|
191
|
+
artifact.testInfrastructure.testConfigurations.forEach((config, index) => {
|
|
192
|
+
records.push({
|
|
193
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
194
|
+
sourceInstance,
|
|
195
|
+
category: "test-configuration",
|
|
196
|
+
targetKey: pathKey("test-configuration", config.path),
|
|
197
|
+
sourceFieldPath: `testInfrastructure.testConfigurations[${index}].path`
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
// Section 27: symbol and symbol-subtype evidence
|
|
201
|
+
artifact.candidateNodes.forEach((node, index) => {
|
|
202
|
+
if (node.retained) {
|
|
203
|
+
records.push({
|
|
204
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
205
|
+
sourceInstance,
|
|
206
|
+
category: "symbol",
|
|
207
|
+
targetKey: symbolKey("symbol", node.nodeId),
|
|
208
|
+
sourceFieldPath: `candidateNodes[${index}].nodeId`
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
artifact.selectedGraph.nodes.forEach((node, index) => {
|
|
213
|
+
records.push({
|
|
214
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
215
|
+
sourceInstance,
|
|
216
|
+
category: "symbol",
|
|
217
|
+
targetKey: symbolKey("symbol", node.nodeId),
|
|
218
|
+
sourceFieldPath: `selectedGraph.nodes[${index}].nodeId`
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
artifact.evidenceGroups.forEach((group, groupIndex) => {
|
|
222
|
+
pushSymbolEvidenceFromRefs(records, group.items, `evidenceGroups[${groupIndex}].items`, "symbol", sourceInstance);
|
|
223
|
+
});
|
|
224
|
+
pushSymbolEvidenceFromRefs(records, artifact.selectedOwners, "selectedOwners", "symbol", sourceInstance);
|
|
225
|
+
pushSymbolEvidenceFromRefs(records, artifact.selectedContracts, "selectedContracts", "symbol", sourceInstance);
|
|
226
|
+
pushSymbolEvidenceFromRefs(records, artifact.selectedTests, "selectedTests", "symbol", sourceInstance);
|
|
227
|
+
pushSymbolEvidenceFromRefs(records, artifact.testInfrastructure.relatedTests, "testInfrastructure.relatedTests", "symbol", sourceInstance);
|
|
228
|
+
pushSymbolEvidenceFromRefs(records, artifact.testInfrastructure.fixtures, "testInfrastructure.fixtures", "symbol", sourceInstance);
|
|
229
|
+
pushSymbolEvidenceFromRefs(records, artifact.testInfrastructure.factories, "testInfrastructure.factories", "symbol", sourceInstance);
|
|
230
|
+
pushSymbolEvidenceFromRefs(records, artifact.testInfrastructure.mocks, "testInfrastructure.mocks", "symbol", sourceInstance);
|
|
231
|
+
pushSymbolEvidenceFromRefs(records, artifact.testInfrastructure.setupFiles, "testInfrastructure.setupFiles", "symbol", sourceInstance);
|
|
232
|
+
pushSymbolEvidenceFromRefs(records, artifact.selectedContracts, "selectedContracts", "contract", sourceInstance);
|
|
233
|
+
artifact.responsibilityMappings.mappings.forEach((mapping, mappingIndex) => {
|
|
234
|
+
pushSymbolEvidenceFromRefs(records, mapping.contracts, `responsibilityMappings.mappings[${mappingIndex}].contracts`, "contract", sourceInstance);
|
|
235
|
+
});
|
|
236
|
+
artifact.responsibilityMappings.mappings.forEach((mapping, mappingIndex) => {
|
|
237
|
+
pushSymbolEvidenceFromRefs(records, mapping.validators, `responsibilityMappings.mappings[${mappingIndex}].validators`, "validator", sourceInstance);
|
|
238
|
+
});
|
|
239
|
+
artifact.responsibilityMappings.mappings.forEach((mapping, mappingIndex) => {
|
|
240
|
+
pushSymbolEvidenceFromRefs(records, mapping.constants, `responsibilityMappings.mappings[${mappingIndex}].constants`, "constant", sourceInstance);
|
|
241
|
+
});
|
|
242
|
+
artifact.responsibilityMappings.mappings.forEach((mapping, mappingIndex) => {
|
|
243
|
+
pushSymbolEvidenceFromRefs(records, mapping.errors, `responsibilityMappings.mappings[${mappingIndex}].errors`, "error", sourceInstance);
|
|
244
|
+
});
|
|
245
|
+
pushSymbolEvidenceFromRefs(records, artifact.selectedContracts, "selectedContracts", "schema-or-serializer", sourceInstance);
|
|
246
|
+
artifact.responsibilityMappings.mappings.forEach((mapping, mappingIndex) => {
|
|
247
|
+
pushSymbolEvidenceFromRefs(records, mapping.contracts, `responsibilityMappings.mappings[${mappingIndex}].contracts`, "schema-or-serializer", sourceInstance);
|
|
248
|
+
});
|
|
249
|
+
// Section 28: source-range evidence
|
|
250
|
+
artifact.selectedSource.slices.forEach((slice, index) => {
|
|
251
|
+
records.push({
|
|
252
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
253
|
+
sourceInstance,
|
|
254
|
+
category: "source-range",
|
|
255
|
+
targetKey: sourceRangeKey(slice.filePath, slice.startLine, slice.endLine),
|
|
256
|
+
sourceFieldPath: `selectedSource.slices[${index}]`
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
artifact.selectedSourceBundles.bundles.forEach((bundle, bundleIndex) => {
|
|
260
|
+
bundle.blocks.forEach((block, blockIndex) => {
|
|
261
|
+
records.push({
|
|
262
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
263
|
+
sourceInstance,
|
|
264
|
+
category: "source-range",
|
|
265
|
+
targetKey: sourceRangeKey(block.filePath, block.startLine, block.endLine),
|
|
266
|
+
sourceFieldPath: `selectedSourceBundles.bundles[${bundleIndex}].blocks[${blockIndex}]`
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
// Section 29: production-responsibility evidence
|
|
271
|
+
artifact.responsibilityMappings.mappings.forEach((mapping, index) => {
|
|
272
|
+
records.push({
|
|
273
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
274
|
+
sourceInstance,
|
|
275
|
+
category: "production-responsibility",
|
|
276
|
+
targetKey: responsibilityKey(mapping.responsibilityId),
|
|
277
|
+
sourceFieldPath: `responsibilityMappings.mappings[${index}].responsibilityId`
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
// Section 30: package-script and test-command evidence
|
|
281
|
+
artifact.testInfrastructure.packageScripts.forEach((script, index) => {
|
|
282
|
+
records.push({
|
|
283
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
284
|
+
sourceInstance,
|
|
285
|
+
category: "package-script",
|
|
286
|
+
targetKey: packageScriptKey(script.name),
|
|
287
|
+
sourceFieldPath: `testInfrastructure.packageScripts[${index}].name`
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
artifact.testInfrastructure.testCommands.forEach((command, index) => {
|
|
291
|
+
if (command.commandText !== null) {
|
|
292
|
+
records.push({
|
|
293
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
294
|
+
sourceInstance,
|
|
295
|
+
category: "test-command",
|
|
296
|
+
targetKey: testCommandKey(command.commandText),
|
|
297
|
+
sourceFieldPath: `testInfrastructure.testCommands[${index}].commandText`
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
// Section 31: context-capsule provenance evidence
|
|
302
|
+
artifact.provenance.forEach((provenanceRecord, index) => {
|
|
303
|
+
records.push({
|
|
304
|
+
sourceArtifact: SOURCE_ARTIFACT,
|
|
305
|
+
sourceInstance,
|
|
306
|
+
category: "provenance",
|
|
307
|
+
targetKey: provenanceKey(provenanceRecord.evidenceId),
|
|
308
|
+
sourceFieldPath: `provenance[${index}].evidenceId`
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
return dedupeEvidence(records);
|
|
312
|
+
}
|
|
@@ -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
|
+
}
|