@dailephd/my-dev-kit-lab 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +468 -0
- package/README.md +8 -1
- package/dist/scripts/report-context-integrity-smoke.js +70 -0
- package/dist/src/evaluation/ecosystemFixtures/index.js +3 -0
- package/dist/src/evaluation/ecosystemFixtures/loadContextIntegrityFixture.js +102 -0
- package/dist/src/evaluation/ecosystemFixtures/manifestTypes.js +1 -0
- package/dist/src/evaluation/ecosystemFixtures/validateManifest.js +82 -0
- package/dist/src/evaluation/ecosystemFixtures/verifyFixtureHashes.js +45 -0
- package/dist/src/evaluation/stageContextExpectations/producerReadinessExpectationTypes.js +8 -0
- package/dist/src/evaluation/stageContextExpectations/validation.js +200 -0
- package/dist/src/evaluation/stageContextMetrics/calculateAllocationMetrics.js +265 -0
- package/dist/src/evaluation/stageContextMetrics/calculateConditionCoverageMetrics.js +74 -0
- package/dist/src/evaluation/stageContextMetrics/calculateCriticalityMetrics.js +112 -0
- package/dist/src/evaluation/stageContextMetrics/calculateOwnerMetrics.js +84 -0
- package/dist/src/evaluation/stageContextMetrics/calculateProducerConditionAgreement.js +113 -0
- package/dist/src/evaluation/stageContextMetrics/calculateReadinessAgreement.js +212 -0
- package/dist/src/evaluation/stageContextMetrics/calculateRunIntegrityAgreement.js +309 -0
- package/dist/src/evaluation/stageContextMetrics/calculateSupplementalRawAgreement.js +60 -0
- package/dist/src/evaluation/stageContextMetrics/calculateTruncationClassification.js +144 -0
- package/dist/src/evaluation/stageContextMetrics/evaluateProducerReadinessBridge.js +198 -0
- package/dist/src/evaluation/stageContextMetrics/index.js +11 -0
- package/dist/src/evaluation/stageContextMetrics/producerReadinessMetricTypes.js +1 -0
- package/dist/src/evaluation/stageContextMetrics/runIntegrityAgreementTypes.js +1 -0
- package/dist/src/evaluation/stageContextSelectors/contextArtifactConsistency.js +17 -0
- package/dist/src/evaluation/stageContextSelectors/index.js +1 -0
- package/dist/src/evaluation/stageContextSelectors/orchestratorRunIntegritySelectors.js +64 -0
- package/dist/src/evaluation/upstreamArtifacts/index.js +8 -0
- package/dist/src/evaluation/upstreamArtifacts/orchestratorContextReadinessResultV1.js +247 -0
- package/dist/src/evaluation/upstreamArtifacts/orchestratorRunIntegrityV1.js +33 -0
- package/dist/src/evaluation/upstreamArtifacts/readImplementationContextPacketV1.js +9 -0
- package/dist/src/evaluation/upstreamArtifacts/readImplementationContextRetrievalReportV1.js +9 -0
- package/dist/src/evaluation/upstreamArtifacts/readOrchestratorRunIntegrityV1.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/supplementalContextTextParser.js +75 -0
- package/dist/src/evaluation/upstreamArtifacts/supplementalContextTypes.js +152 -0
- package/dist/src/evaluation/upstreamArtifacts/validateMyDevKitContextCapsuleV1.js +59 -2
- package/dist/src/evaluation/upstreamArtifacts/validateMyDevKitRetrievalAuditRecordV1.js +15 -3
- package/dist/src/evaluation/upstreamArtifacts/validateOrchestratorRunIntegrityV1.js +177 -0
- package/dist/src/evaluation/upstreamArtifacts/validateSupplementalContextDocumentV1.js +148 -0
- package/dist/src/experiments/plugins/contextStrategyComparison/loadV043StrategyArtifacts.js +117 -6
- package/dist/src/experiments/plugins/contextStrategyComparison/runV043StageContextStrategyWithAssurance.js +18 -3
- package/dist/src/experiments/plugins/contextStrategyComparison/validateV043StrategyInput.js +17 -3
- package/dist/src/report/experiments/buildContextIntegrityReport.js +204 -0
- package/dist/src/report/experiments/buildContextStrategyComparisonV043Report.js +122 -0
- package/dist/src/report/experiments/contextIntegrityReportModel.js +1 -0
- package/dist/src/report/experiments/index.js +5 -0
- package/dist/src/report/experiments/renderContextIntegrityHtml.js +98 -0
- package/dist/src/report/experiments/renderContextIntegrityJsonReport.js +3 -0
- package/dist/src/report/experiments/renderContextIntegrityText.js +111 -0
- package/dist/src/report/experiments/renderContextStrategyComparisonV043Html.js +62 -0
- package/dist/src/report/experiments/renderPluginExperimentReportText.js +67 -0
- package/dist/src/securityValidation/packageChecks/requiredPackageContents.js +33 -0
- package/dist/src/securityValidation/packageChecks/runPackageChecks.js +11 -5
- package/docs/METRICS.md +111 -0
- package/package.json +5 -3
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/derived/run-integrity-evidence.json +99 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/producer/implementation-audit.json +1585 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/producer/implementation-capsule.json +11455 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/00-request.txt +1 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/architecture-context-packet.txt +82 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/behavior-model.txt +104 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/final-report.txt +41 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/implementation-context-packet.txt +114 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/implementation-report.txt +92 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/judge-report.txt +34 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/pseudocode-packet.txt +244 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/request-brief.txt +40 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-context-packet.txt +93 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-implementation-report.txt +69 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-strategy-packet.txt +354 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/verification-report.txt +85 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/derived/run-integrity-evidence.json +98 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/architecture-audit.json +1169 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/architecture-request.json +29 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-audit.json +1494 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-capsule.json +11364 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-request.json +33 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/test-request.json +74 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/architecture-context-retrieval-report.txt +58 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/implementation-context-retrieval-report.txt +75 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/test-context-retrieval-report.txt +84 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/run.json +62 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/tool-versions/my-dev-kit-version.txt +1 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/tool-versions/orchestrator-version.txt +1 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/manifests/corrected-replay-manifest.json +19 -0
- package/tests/fixtures/ecosystem/context-integrity/v0.4.5/manifests/failed-run-manifest.json +56 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/PROVENANCE.txt +18 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/context-capsule/complete-v1.0.0.json +556 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/retrieval-audit-record/complete-v1.0.0.json +238 -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.3/run-integrity/PROVENANCE.txt +31 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.3/run-integrity/ready-pass-final-pass.json +132 -0
- package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.3/run-integrity/refresh-required-need-context.json +146 -0
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
}
|
|
45
|
+
// v0.4.5 Batch 2: condition-aware truncation classification. Distinguishes the seven states
|
|
46
|
+
// required by the Batch 2 plan using only explicit upstream evidence (truncation.truncated,
|
|
47
|
+
// truncation.requiredEvidenceLost, ContextCapsule.groupTruncation's required/optional omitted
|
|
48
|
+
// counts, and roleConditionCoverage's lostRequiredCondition/lossReason). Never independently
|
|
49
|
+
// decides that a condition lost its last witness from a raw file count.
|
|
50
|
+
export function classifyConditionAwareTruncation(artifact, sourceArtifact, sourceInstance) {
|
|
51
|
+
const requiredEvidenceLost = artifact.truncation.requiredEvidenceLost;
|
|
52
|
+
const roleConditionCoverage = artifact.roleConditionCoverage;
|
|
53
|
+
const groupTruncation = "groupTruncation" in artifact ? artifact.groupTruncation : undefined;
|
|
54
|
+
const lostConditions = roleConditionCoverage?.filter((c) => c.lostRequiredCondition) ?? undefined;
|
|
55
|
+
const lostRequiredConditionIds = lostConditions?.map((c) => c.conditionId) ?? [];
|
|
56
|
+
const groupsWithBothOmissionFields = groupTruncation?.filter((g) => g.requiredOmittedCount !== undefined && g.optionalOmittedCount !== undefined);
|
|
57
|
+
const requiredOmittedTotal = groupsWithBothOmissionFields !== undefined && groupsWithBothOmissionFields.length === (groupTruncation?.length ?? -1) && groupTruncation.length > 0
|
|
58
|
+
? groupsWithBothOmissionFields.reduce((sum, g) => sum + (g.requiredOmittedCount ?? 0), 0)
|
|
59
|
+
: null;
|
|
60
|
+
const optionalOmittedTotal = groupsWithBothOmissionFields !== undefined && groupsWithBothOmissionFields.length === (groupTruncation?.length ?? -1) && groupTruncation.length > 0
|
|
61
|
+
? groupsWithBothOmissionFields.reduce((sum, g) => sum + (g.optionalOmittedCount ?? 0), 0)
|
|
62
|
+
: null;
|
|
63
|
+
const base = {
|
|
64
|
+
sourceArtifact,
|
|
65
|
+
sourceInstance,
|
|
66
|
+
requiredEvidenceLost: requiredEvidenceLost ?? null,
|
|
67
|
+
requiredOmittedTotal,
|
|
68
|
+
optionalOmittedTotal,
|
|
69
|
+
lostRequiredConditionIds
|
|
70
|
+
};
|
|
71
|
+
const hasAnyCurrentDiagnostics = requiredEvidenceLost !== undefined || roleConditionCoverage !== undefined || requiredOmittedTotal !== null;
|
|
72
|
+
if (!hasAnyCurrentDiagnostics) {
|
|
73
|
+
return {
|
|
74
|
+
...base,
|
|
75
|
+
availability: "unavailable",
|
|
76
|
+
state: "unsupported-legacy-diagnostics",
|
|
77
|
+
contradictionCodes: [],
|
|
78
|
+
reason: "No v1.10.3/v1.10.4 truncation or condition-coverage diagnostics were supplied (legacy schema-major-1 evidence)."
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const contradictionCodes = [];
|
|
82
|
+
if (requiredEvidenceLost === false && lostRequiredConditionIds.length > 0) {
|
|
83
|
+
contradictionCodes.push("REQUIRED_EVIDENCE_LOST_FALSE_BUT_CONDITION_LOSS_REPORTED");
|
|
84
|
+
}
|
|
85
|
+
if (requiredEvidenceLost === true &&
|
|
86
|
+
roleConditionCoverage !== undefined &&
|
|
87
|
+
lostRequiredConditionIds.length === 0 &&
|
|
88
|
+
roleConditionCoverage.filter((c) => c.required).every((c) => c.conditionSatisfied) &&
|
|
89
|
+
(requiredOmittedTotal === null || requiredOmittedTotal === 0)) {
|
|
90
|
+
contradictionCodes.push("REQUIRED_EVIDENCE_LOST_TRUE_BUT_ALL_REQUIRED_CONDITIONS_RETAINED");
|
|
91
|
+
}
|
|
92
|
+
if (contradictionCodes.length > 0) {
|
|
93
|
+
return {
|
|
94
|
+
...base,
|
|
95
|
+
availability: "available",
|
|
96
|
+
state: "contradictory-producer-evidence",
|
|
97
|
+
contradictionCodes,
|
|
98
|
+
reason: "Producer evidence is internally contradictory; both sides are retained rather than resolved by the lab."
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (lostRequiredConditionIds.length > 0) {
|
|
102
|
+
return {
|
|
103
|
+
...base,
|
|
104
|
+
availability: "available",
|
|
105
|
+
state: "required-condition-or-last-witness-loss",
|
|
106
|
+
contradictionCodes: [],
|
|
107
|
+
reason: `Explicit lostRequiredCondition evidence exists for: ${lostRequiredConditionIds.join(", ")}.`
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (requiredEvidenceLost === true || (requiredOmittedTotal !== null && requiredOmittedTotal > 0)) {
|
|
111
|
+
return {
|
|
112
|
+
...base,
|
|
113
|
+
availability: "available",
|
|
114
|
+
state: "required-evidence-loss",
|
|
115
|
+
contradictionCodes: [],
|
|
116
|
+
reason: "Required evidence loss is explicitly reported without condition-level detail."
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (requiredEvidenceLost === undefined && artifact.truncation.truncated) {
|
|
120
|
+
return {
|
|
121
|
+
...base,
|
|
122
|
+
availability: "available",
|
|
123
|
+
state: "unknown-criticality",
|
|
124
|
+
contradictionCodes: [],
|
|
125
|
+
reason: "General truncation occurred but the rollup requiredEvidenceLost field is absent, so required-versus-optional criticality cannot be determined."
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (artifact.truncation.truncated) {
|
|
129
|
+
return {
|
|
130
|
+
...base,
|
|
131
|
+
availability: "available",
|
|
132
|
+
state: "optional-only-truncation",
|
|
133
|
+
contradictionCodes: [],
|
|
134
|
+
reason: "Truncation occurred but no required evidence loss or condition loss was reported."
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...base,
|
|
139
|
+
availability: "available",
|
|
140
|
+
state: "no-truncation",
|
|
141
|
+
contradictionCodes: [],
|
|
142
|
+
reason: null
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { collectSelectedOwnerEvidence, calculateOwnerMetrics } from "./calculateOwnerMetrics.js";
|
|
2
|
+
import { calculateAllocationFactsForGroups, calculateGroupAllocationMetrics } from "./calculateAllocationMetrics.js";
|
|
3
|
+
import { classifyTruncationRecords, classifyConditionAwareTruncation } from "./calculateTruncationClassification.js";
|
|
4
|
+
import { calculateConditionCoverageMetrics } from "./calculateConditionCoverageMetrics.js";
|
|
5
|
+
import { calculateCapsuleAuditConditionAgreement, calculateProducerConditionAgreement, calculateRequiredEvidenceLossAgreement } from "./calculateProducerConditionAgreement.js";
|
|
6
|
+
import { calculateSupplementalRawAgreement } from "./calculateSupplementalRawAgreement.js";
|
|
7
|
+
import { calculateReadinessAgreementMetrics, calculateProducerReadinessRelationship } from "./calculateReadinessAgreement.js";
|
|
8
|
+
import { calculateCriticalityMetrics } from "./calculateCriticalityMetrics.js";
|
|
9
|
+
import { evaluateRunIntegrity } from "./calculateRunIntegrityAgreement.js";
|
|
10
|
+
function ownerExpectationsFor(expectations, sourceArtifact) {
|
|
11
|
+
return expectations?.ownerExpectations?.filter((e) => e.sourceArtifact === sourceArtifact);
|
|
12
|
+
}
|
|
13
|
+
function evaluateSide(input, expectations) {
|
|
14
|
+
const producerExpectations = expectations?.producerReadinessExpectations;
|
|
15
|
+
// Owner-selection and allocation-group evidence only exist on ContextCapsule (Batch 1
|
|
16
|
+
// contract-lock evidence: RetrievalAuditRecord has no selectedOwners/evidenceGroups
|
|
17
|
+
// fields). Truncation and responsibility-mapping evidence exist on both.
|
|
18
|
+
const capsule = input.contextCapsule;
|
|
19
|
+
const truncationArtifact = input.contextCapsule ?? input.retrievalAuditRecord;
|
|
20
|
+
const rawForAgreement = input.contextCapsule ?? input.retrievalAuditRecord;
|
|
21
|
+
const selectedOwnerEvidence = capsule ? collectSelectedOwnerEvidence(capsule.selectedOwners, "context-capsule", input.role) : undefined;
|
|
22
|
+
const ownerEvaluation = calculateOwnerMetrics(selectedOwnerEvidence, ownerExpectationsFor(producerExpectations, "context-capsule"));
|
|
23
|
+
const allocationFacts = capsule
|
|
24
|
+
? calculateAllocationFactsForGroups(capsule.evidenceGroups, "context-capsule", input.role)
|
|
25
|
+
: { requiredGroupCapacity: [], usedReservation: [], borrowedCapacity: [], unusedCapacity: [] };
|
|
26
|
+
const allocationEvaluation = {
|
|
27
|
+
...allocationFacts,
|
|
28
|
+
requiredEvidenceOmitted: {
|
|
29
|
+
availability: "not-applicable",
|
|
30
|
+
count: null,
|
|
31
|
+
evidenceKeys: [],
|
|
32
|
+
reason: "Batch 3 bridge evaluation derives omission from truncation records, not expectation matches; see truncationEvaluation."
|
|
33
|
+
},
|
|
34
|
+
requiredEvidenceOmittedEntries: []
|
|
35
|
+
};
|
|
36
|
+
const truncationSourceArtifact = input.contextCapsule ? "context-capsule" : "retrieval-audit-record";
|
|
37
|
+
const truncationEvaluation = truncationArtifact
|
|
38
|
+
? classifyTruncationRecords(truncationArtifact.truncation.records, truncationSourceArtifact, input.role)
|
|
39
|
+
: [];
|
|
40
|
+
const packetAgreement = input.packet !== undefined || rawForAgreement !== undefined ? calculateSupplementalRawAgreement(input.packet, rawForAgreement) : null;
|
|
41
|
+
const reportAgreement = input.report !== undefined || rawForAgreement !== undefined ? calculateSupplementalRawAgreement(input.report, rawForAgreement) : null;
|
|
42
|
+
// v0.4.5 Batch 2: allocation/condition-coverage evidence, computed once per side and
|
|
43
|
+
// carried through the result unchanged (never recomputed by a renderer or later batch).
|
|
44
|
+
const groupAllocationEvaluation = calculateGroupAllocationMetrics(capsule?.groupTruncation, input.role);
|
|
45
|
+
const conditionAwareTruncationEvaluation = truncationArtifact
|
|
46
|
+
? classifyConditionAwareTruncation(truncationArtifact, truncationSourceArtifact, input.role)
|
|
47
|
+
: null;
|
|
48
|
+
const roleConditionCoverage = capsule?.roleConditionCoverage ?? input.retrievalAuditRecord?.roleConditionCoverage;
|
|
49
|
+
const availableEvidenceGroupIds = capsule?.evidenceGroups.map((g) => g.id);
|
|
50
|
+
const conditionCoverageEvaluation = calculateConditionCoverageMetrics(roleConditionCoverage, availableEvidenceGroupIds);
|
|
51
|
+
const roleAdequacyStatus = (capsule ?? input.retrievalAuditRecord)?.roleAdequacy.status;
|
|
52
|
+
const producerConditionAgreement = calculateProducerConditionAgreement(roleAdequacyStatus, conditionCoverageEvaluation);
|
|
53
|
+
const requiredEvidenceLossAgreement = calculateRequiredEvidenceLossAgreement(truncationArtifact?.truncation.requiredEvidenceLost, conditionCoverageEvaluation, groupAllocationEvaluation.aggregate.totalRequiredOmitted);
|
|
54
|
+
const capsuleAuditConditionAgreement = calculateCapsuleAuditConditionAgreement(capsule, input.retrievalAuditRecord);
|
|
55
|
+
return {
|
|
56
|
+
ownerEvaluation,
|
|
57
|
+
allocationEvaluation,
|
|
58
|
+
truncationEvaluation,
|
|
59
|
+
packetAgreement,
|
|
60
|
+
reportAgreement,
|
|
61
|
+
groupAllocationEvaluation,
|
|
62
|
+
conditionAwareTruncationEvaluation,
|
|
63
|
+
conditionCoverageEvaluation,
|
|
64
|
+
producerConditionAgreement,
|
|
65
|
+
requiredEvidenceLossAgreement,
|
|
66
|
+
capsuleAuditConditionAgreement
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// Builds bridge-evaluator input from an already-loaded combined-bounded-stage-context
|
|
70
|
+
// execution payload (Batch 3 section 12.1: "accept already-read raw, supplemental,
|
|
71
|
+
// readiness, and expectation inputs"). Never reads a file itself.
|
|
72
|
+
export function buildProducerReadinessBridgeInputFromCombinedPayload(payload, expectations) {
|
|
73
|
+
const implementationPair = payload.contextArtifacts.find((p) => p.role === "implementation");
|
|
74
|
+
const testPair = payload.contextArtifacts.find((p) => p.role === "test-implementation");
|
|
75
|
+
const hasImplementationSide = implementationPair !== undefined || payload.implementationContextPacket !== undefined || payload.implementationContextRetrievalReport !== undefined;
|
|
76
|
+
const hasTestSide = testPair !== undefined || payload.testContextPacket !== undefined || payload.testContextRetrievalReport !== undefined;
|
|
77
|
+
return {
|
|
78
|
+
implementation: hasImplementationSide
|
|
79
|
+
? {
|
|
80
|
+
role: "implementation",
|
|
81
|
+
contextCapsule: implementationPair?.contextCapsule,
|
|
82
|
+
retrievalAuditRecord: implementationPair?.retrievalAuditRecord,
|
|
83
|
+
packet: payload.implementationContextPacket,
|
|
84
|
+
packetSourcePath: payload.implementationContextPacketSourcePath,
|
|
85
|
+
report: payload.implementationContextRetrievalReport
|
|
86
|
+
}
|
|
87
|
+
: undefined,
|
|
88
|
+
testImplementation: hasTestSide
|
|
89
|
+
? {
|
|
90
|
+
role: "test-implementation",
|
|
91
|
+
contextCapsule: testPair?.contextCapsule,
|
|
92
|
+
retrievalAuditRecord: testPair?.retrievalAuditRecord,
|
|
93
|
+
packet: payload.testContextPacket,
|
|
94
|
+
packetSourcePath: payload.testContextPacketSourcePath,
|
|
95
|
+
report: payload.testContextRetrievalReport
|
|
96
|
+
}
|
|
97
|
+
: undefined,
|
|
98
|
+
readiness: payload.readiness,
|
|
99
|
+
expectations
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function evaluateProducerReadinessBridge(input) {
|
|
103
|
+
const hasAnyInput = input.implementation !== undefined ||
|
|
104
|
+
input.testImplementation !== undefined ||
|
|
105
|
+
input.readiness !== undefined ||
|
|
106
|
+
input.runIntegrityEvidence !== undefined;
|
|
107
|
+
if (!hasAnyInput) {
|
|
108
|
+
return {
|
|
109
|
+
status: "not-applicable",
|
|
110
|
+
reason: "No producer-readiness bridge inputs (supplemental artifacts or readiness result) were supplied.",
|
|
111
|
+
implementation: null,
|
|
112
|
+
testImplementation: null,
|
|
113
|
+
readinessAgreement: null,
|
|
114
|
+
criticalityEvaluation: null,
|
|
115
|
+
producerReadinessRelationship: null,
|
|
116
|
+
runIntegrityEvaluation: null,
|
|
117
|
+
warnings: [],
|
|
118
|
+
evidenceReferences: []
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const evidenceReferences = [];
|
|
122
|
+
const warnings = [];
|
|
123
|
+
let implementation = null;
|
|
124
|
+
if (input.implementation !== undefined) {
|
|
125
|
+
const evaluated = evaluateSide(input.implementation, input.expectations);
|
|
126
|
+
implementation = { role: "implementation", ...evaluated };
|
|
127
|
+
if (input.implementation.packetSourcePath)
|
|
128
|
+
evidenceReferences.push(input.implementation.packetSourcePath);
|
|
129
|
+
}
|
|
130
|
+
let testImplementation = null;
|
|
131
|
+
if (input.testImplementation !== undefined) {
|
|
132
|
+
const evaluated = evaluateSide(input.testImplementation, input.expectations);
|
|
133
|
+
testImplementation = { role: "test-implementation", ...evaluated };
|
|
134
|
+
if (input.testImplementation.packetSourcePath)
|
|
135
|
+
evidenceReferences.push(input.testImplementation.packetSourcePath);
|
|
136
|
+
}
|
|
137
|
+
let readinessAgreement = null;
|
|
138
|
+
if (input.readiness !== undefined) {
|
|
139
|
+
const readinessExpectations = input.expectations.producerReadinessExpectations?.readinessExpectations;
|
|
140
|
+
const matchingExpectation = readinessExpectations?.find((e) => e.kind === input.readiness.kind);
|
|
141
|
+
const relevantPacket = input.readiness.kind === "implementation" ? input.implementation?.packet : input.testImplementation?.packet;
|
|
142
|
+
const relevantPacketPath = input.readiness.kind === "implementation" ? input.implementation?.packetSourcePath : input.testImplementation?.packetSourcePath;
|
|
143
|
+
readinessAgreement = calculateReadinessAgreementMetrics(input.readiness, matchingExpectation, relevantPacket, relevantPacketPath);
|
|
144
|
+
}
|
|
145
|
+
const criticalityMappings = input.testImplementation?.retrievalAuditRecord?.responsibilityMappings.mappings ??
|
|
146
|
+
input.testImplementation?.contextCapsule?.responsibilityMappings.mappings ??
|
|
147
|
+
input.implementation?.retrievalAuditRecord?.responsibilityMappings.mappings ??
|
|
148
|
+
input.implementation?.contextCapsule?.responsibilityMappings.mappings;
|
|
149
|
+
const criticalityEvaluation = calculateCriticalityMetrics(criticalityMappings, input.expectations.producerReadinessExpectations?.criticalityExpectations);
|
|
150
|
+
// v0.4.5 Batch 2: producer role adequacy vs supplied orchestrator readiness. Selects the
|
|
151
|
+
// side input.readiness.kind actually applies to when available, otherwise falls back to
|
|
152
|
+
// the same test-implementation-preferred precedence as criticalityEvaluation above.
|
|
153
|
+
const readinessSideRole = input.readiness?.kind === "implementation" || input.readiness?.kind === "test" ? input.readiness.kind : undefined;
|
|
154
|
+
const readinessSideEvaluation = readinessSideRole === "implementation" ? implementation : readinessSideRole === "test" ? testImplementation : (testImplementation ?? implementation);
|
|
155
|
+
const readinessSideRawArtifact = readinessSideEvaluation?.role === "implementation"
|
|
156
|
+
? (input.implementation?.contextCapsule ?? input.implementation?.retrievalAuditRecord)
|
|
157
|
+
: readinessSideEvaluation?.role === "test-implementation"
|
|
158
|
+
? (input.testImplementation?.contextCapsule ?? input.testImplementation?.retrievalAuditRecord)
|
|
159
|
+
: undefined;
|
|
160
|
+
// calculateProducerReadinessRelationship short-circuits before touching this argument
|
|
161
|
+
// whenever roleAdequacyStatus is undefined, so a placeholder is safe when no side applies.
|
|
162
|
+
const placeholderProducerConditionAgreement = {
|
|
163
|
+
availability: "unavailable",
|
|
164
|
+
outcome: "insufficient-evidence",
|
|
165
|
+
observedRoleAdequacyStatus: null,
|
|
166
|
+
contradictionCodes: [],
|
|
167
|
+
reason: "No producer side applies to the supplied readiness result."
|
|
168
|
+
};
|
|
169
|
+
const producerReadinessRelationship = calculateProducerReadinessRelationship(readinessSideRawArtifact?.roleAdequacy.status, readinessSideEvaluation?.producerConditionAgreement ?? placeholderProducerConditionAgreement, input.readiness);
|
|
170
|
+
// v0.4.5 Batch 3: bounded orchestrator run-integrity evidence and agreement, computed
|
|
171
|
+
// once here and carried through unchanged. Stage selection follows the same
|
|
172
|
+
// applicableContextKinds the gate itself declares (implementation preferred, since the
|
|
173
|
+
// gate blocks implementation before test-implementation in workflow order); the
|
|
174
|
+
// producerReadinessRelationship outcome already computed above feeds the end-to-end
|
|
175
|
+
// summary's "producerReadiness" component rather than being recalculated.
|
|
176
|
+
let runIntegrityEvaluation = null;
|
|
177
|
+
if (input.runIntegrityEvidence !== undefined) {
|
|
178
|
+
const gate = input.runIntegrityEvidence.gate;
|
|
179
|
+
const stageName = gate.applicableContextKinds.includes("implementation")
|
|
180
|
+
? "implementation"
|
|
181
|
+
: gate.applicableContextKinds.includes("test")
|
|
182
|
+
? "test-implementation"
|
|
183
|
+
: gate.mode;
|
|
184
|
+
runIntegrityEvaluation = evaluateRunIntegrity(input.runIntegrityEvidence, stageName, producerReadinessRelationship.outcome);
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
status: "evaluated",
|
|
188
|
+
reason: null,
|
|
189
|
+
implementation,
|
|
190
|
+
testImplementation,
|
|
191
|
+
readinessAgreement,
|
|
192
|
+
criticalityEvaluation,
|
|
193
|
+
producerReadinessRelationship,
|
|
194
|
+
runIntegrityEvaluation,
|
|
195
|
+
warnings,
|
|
196
|
+
evidenceReferences
|
|
197
|
+
};
|
|
198
|
+
}
|
|
@@ -8,3 +8,14 @@ export { compareExpectedContextCapsuleState, compareExpectedRetrievalAuditState,
|
|
|
8
8
|
export { calculateContextCapsuleResponsibilityMappingMetric, calculateRetrievalAuditResponsibilityMappingMetric } from "./calculateResponsibilityMappingMetrics.js";
|
|
9
9
|
export { calculateV043ExecutionContextSize } from "./calculateContextSizeMetrics.js";
|
|
10
10
|
export { evaluateV043StageContextExecution } from "./evaluateV043StageContextExecution.js";
|
|
11
|
+
export { collectSelectedOwnerEvidence, calculateOwnerMetrics } from "./calculateOwnerMetrics.js";
|
|
12
|
+
export { calculateAllocationFactsForGroups, calculateRequiredEvidenceOmitted, findAllocationExpectationForGroup } from "./calculateAllocationMetrics.js";
|
|
13
|
+
export { classifyTruncationRecord, classifyTruncationRecords } from "./calculateTruncationClassification.js";
|
|
14
|
+
export { calculateSupplementalRawAgreement } from "./calculateSupplementalRawAgreement.js";
|
|
15
|
+
export { calculateReadinessStructuralAgreement, calculateReadinessDecisionAgreement, calculateInvalidReady, calculateValidBlocked, calculateReadinessAgreementMetrics } from "./calculateReadinessAgreement.js";
|
|
16
|
+
export { calculateCriticalityMetrics } from "./calculateCriticalityMetrics.js";
|
|
17
|
+
export { evaluateProducerReadinessBridge, buildProducerReadinessBridgeInputFromCombinedPayload } from "./evaluateProducerReadinessBridge.js";
|
|
18
|
+
export { calculateGroupAllocationMetrics } from "./calculateAllocationMetrics.js";
|
|
19
|
+
export { calculateConditionCoverageMetrics } from "./calculateConditionCoverageMetrics.js";
|
|
20
|
+
export { calculateProducerConditionAgreement, calculateRequiredEvidenceLossAgreement, calculateCapsuleAuditConditionAgreement } from "./calculateProducerConditionAgreement.js";
|
|
21
|
+
export { calculateReadinessPromptAgreement, calculateReadinessExpectedJudgeAgreement, calculateExpectedActualJudgeAgreement, calculateJudgeCorrectionAgreement, calculateJudgeFinalEligibilityAgreement, calculateEligibilityFinalArtifactAgreement, calculateLifecycleIntegrityAgreement, evaluateRunIntegrity } from "./calculateRunIntegrityAgreement.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,6 +18,16 @@ export function checkMyDevKitContextArtifactConsistency(capsule, audit) {
|
|
|
18
18
|
capsuleValue: capsule.index.manifestPath,
|
|
19
19
|
auditValue: audit.index.manifestPath
|
|
20
20
|
},
|
|
21
|
+
{
|
|
22
|
+
fieldPath: "index.manifestSchemaVersion",
|
|
23
|
+
capsuleValue: capsule.index.manifestSchemaVersion ?? null,
|
|
24
|
+
auditValue: audit.index.manifestSchemaVersion ?? null
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
fieldPath: "index.projectRoot",
|
|
28
|
+
capsuleValue: capsule.index.projectRoot ?? null,
|
|
29
|
+
auditValue: audit.index.projectRoot ?? null
|
|
30
|
+
},
|
|
21
31
|
{
|
|
22
32
|
fieldPath: "contextAdequacy",
|
|
23
33
|
capsuleValue: capsule.contextAdequacy,
|
|
@@ -28,6 +38,13 @@ export function checkMyDevKitContextArtifactConsistency(capsule, audit) {
|
|
|
28
38
|
capsuleValue: capsule.roleContext,
|
|
29
39
|
auditValue: audit.roleContext
|
|
30
40
|
},
|
|
41
|
+
// Both absent is a compatible legacy pair. One absent and one present is a
|
|
42
|
+
// contradiction; absence is never normalized to an empty current result.
|
|
43
|
+
{
|
|
44
|
+
fieldPath: "roleConditionCoverage",
|
|
45
|
+
capsuleValue: (capsule.roleConditionCoverage ?? null),
|
|
46
|
+
auditValue: (audit.roleConditionCoverage ?? null)
|
|
47
|
+
},
|
|
31
48
|
{
|
|
32
49
|
fieldPath: "responsibilityMappings",
|
|
33
50
|
capsuleValue: capsule.responsibilityMappings,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export function selectReadinessClassification(evidence) {
|
|
2
|
+
return evidence.gate.readinessClassification;
|
|
3
|
+
}
|
|
4
|
+
export function selectContextReady(evidence) {
|
|
5
|
+
return evidence.gate.contextReady;
|
|
6
|
+
}
|
|
7
|
+
export function selectBlockingCodes(evidence) {
|
|
8
|
+
return evidence.gate.blockingCodes;
|
|
9
|
+
}
|
|
10
|
+
export function selectRecommendedCorrectionStage(evidence) {
|
|
11
|
+
return evidence.gate.recommendedCorrectionStage;
|
|
12
|
+
}
|
|
13
|
+
export function selectExpectedJudgeVerdict(evidence) {
|
|
14
|
+
return evidence.gate.expectedJudgeVerdict;
|
|
15
|
+
}
|
|
16
|
+
// Prompt mode is not a field the exact v1.2.3 gate contract exposes as a literal string --
|
|
17
|
+
// it is a derived per-stage decision (evaluateStageRunIntegrity()). The lab represents it
|
|
18
|
+
// via the same contextReady/blockedStageNames facts the gate already exposes rather than
|
|
19
|
+
// inventing a separate "promptMode" string the upstream contract does not itself declare.
|
|
20
|
+
export function selectStageMayRenderNormalPrompt(evidence, stageName) {
|
|
21
|
+
const contextSensitive = evidence.gate.blockedStageNames.length > 0 || stageName === "implementation" || stageName === "test-implementation";
|
|
22
|
+
if (!contextSensitive)
|
|
23
|
+
return undefined;
|
|
24
|
+
return !evidence.gate.blockedStageNames.includes(stageName);
|
|
25
|
+
}
|
|
26
|
+
export function selectJudgeArtifactPresent(evidence) {
|
|
27
|
+
return evidence.judgeIntegrity?.judgeArtifactPresent;
|
|
28
|
+
}
|
|
29
|
+
export function selectJudgeVerdictParseStatus(evidence) {
|
|
30
|
+
return evidence.judgeIntegrity?.judgeVerdictParseStatus;
|
|
31
|
+
}
|
|
32
|
+
export function selectAuthoredJudgeVerdict(evidence) {
|
|
33
|
+
return evidence.judgeIntegrity?.authoredJudgeVerdict;
|
|
34
|
+
}
|
|
35
|
+
export function selectJudgeVerdictMatchesExpected(evidence) {
|
|
36
|
+
return evidence.judgeIntegrity?.judgeVerdictMatchesExpected;
|
|
37
|
+
}
|
|
38
|
+
export function selectJudgeVerdictAccepted(evidence) {
|
|
39
|
+
return evidence.judgeIntegrity?.judgeVerdictAccepted;
|
|
40
|
+
}
|
|
41
|
+
export function selectAcceptedCorrectionStage(evidence) {
|
|
42
|
+
return evidence.judgeIntegrity?.acceptedCorrectionStage;
|
|
43
|
+
}
|
|
44
|
+
export function selectAcceptedCorrectionRoute(evidence) {
|
|
45
|
+
return evidence.judgeIntegrity?.acceptedCorrectionRoute;
|
|
46
|
+
}
|
|
47
|
+
export function selectJudgeFinalReportEligible(evidence) {
|
|
48
|
+
return evidence.judgeIntegrity?.finalReportEligible;
|
|
49
|
+
}
|
|
50
|
+
export function selectFinalReportEligible(evidence) {
|
|
51
|
+
return evidence.finalReportEligibility?.eligible;
|
|
52
|
+
}
|
|
53
|
+
export function selectFinalArtifactPresent(evidence) {
|
|
54
|
+
return evidence.finalArtifactPresent;
|
|
55
|
+
}
|
|
56
|
+
export function selectFinalArtifactVerdict(evidence) {
|
|
57
|
+
return evidence.finalArtifactVerdict;
|
|
58
|
+
}
|
|
59
|
+
export function selectLifecycleEntries(evidence) {
|
|
60
|
+
return evidence.lifecycle;
|
|
61
|
+
}
|
|
62
|
+
export function selectLifecycleEntryForStage(evidence, stageName) {
|
|
63
|
+
return evidence.lifecycle.find((entry) => entry.stageName === stageName);
|
|
64
|
+
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export { readMyDevKitContextCapsuleV1 } from "./readMyDevKitContextCapsuleV1.js";
|
|
2
2
|
export { readMyDevKitRetrievalAuditRecordV1 } from "./readMyDevKitRetrievalAuditRecordV1.js";
|
|
3
3
|
export { readOrchestratorWorkflowInstructionPacketV1 } from "./readOrchestratorWorkflowInstructionPacketV1.js";
|
|
4
|
+
export { ROLE_BY_DOCUMENT_KIND, REQUIRED_METADATA_BY_DOCUMENT_KIND, REQUIRED_SECTIONS_BY_DOCUMENT_KIND, VALID_REPOSITORY_SCOPES, VALID_DECLARED_STATUSES, VALID_FRESHNESS_VALUES, VALID_ADEQUACY_VALUES, VALID_TRUNCATION_VALUES } from "./supplementalContextTypes.js";
|
|
5
|
+
export { readImplementationContextPacketV1 } from "./readImplementationContextPacketV1.js";
|
|
6
|
+
export { readImplementationContextRetrievalReportV1 } from "./readImplementationContextRetrievalReportV1.js";
|
|
7
|
+
export { readTestContextPacketV1 } from "./readTestContextPacketV1.js";
|
|
8
|
+
export { readTestContextRetrievalReportV1 } from "./readTestContextRetrievalReportV1.js";
|
|
9
|
+
export { READINESS_DECISIONS, READINESS_CLASSIFICATIONS, validateOrchestratorContextReadinessResultV1, checkSupplementalReadinessIdentityConsistency } from "./orchestratorContextReadinessResultV1.js";
|
|
10
|
+
export { readOrchestratorRunIntegrityEvidenceV1 } from "./readOrchestratorRunIntegrityV1.js";
|
|
11
|
+
export { validateOrchestratorRunIntegrityEvidenceV1 } from "./validateOrchestratorRunIntegrityV1.js";
|