archctx-contracts 0.17.1 → 0.18.0
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/fixtures/valid/archctx-capabilities.json +2 -2
- package/fixtures/valid/product-version-manifest.json +4 -10
- package/package.json +4 -1
- package/schemas/repo/refactor-decision.schema.json +283 -37
- package/schemas/runtime/archctx-capabilities.schema.json +144 -20
- package/schemas/runtime/architecture-debt-delta.schema.json +58 -19
- package/schemas/runtime/architecture-debt.schema.json +42 -42
- package/schemas/runtime/architecture-event.schema.json +1 -1
- package/schemas/runtime/architecture-history.schema.json +354 -0
- package/schemas/runtime/capability-dependencies.schema.json +266 -59
- package/schemas/runtime/cli-check.schema.json +197 -0
- package/schemas/runtime/cli-help.schema.json +28 -0
- package/schemas/runtime/dependency-constraint-evaluation.schema.json +67 -68
- package/schemas/runtime/docs-anchors.schema.json +250 -67
- package/schemas/runtime/doctor-code-facts.schema.json +49 -0
- package/schemas/runtime/evidence-binding.schema.json +1 -1
- package/schemas/runtime/flow-selector-check.schema.json +179 -46
- package/schemas/runtime/hook-debt-checkpoint.schema.json +12 -12
- package/schemas/runtime/index-seed.schema.json +56 -0
- package/schemas/runtime/path-context.schema.json +108 -0
- package/schemas/runtime/product-version-manifest.schema.json +142 -54
- package/schemas/runtime/projection-slice.schema.json +34 -34
- package/schemas/runtime/recommendation-v3.schema.json +372 -1
- package/schemas/runtime/ref-impact-batch-request.schema.json +20 -7
- package/schemas/runtime/ref-impact-batch.schema.json +83 -13
- package/schemas/runtime/ref-impact.schema.json +68 -61
- package/schemas/runtime/refactor-scan-v2.schema.json +434 -0
- package/schemas/runtime/refactor-simulate.schema.json +505 -0
- package/schemas/runtime/refactor-verify-v2.schema.json +172 -0
- package/schemas/runtime/resolve-path.schema.json +69 -0
- package/schemas/runtime/runtime-recommendation-show.schema.json +531 -2
- package/schemas/runtime/runtime-refactor-scan.schema.json +498 -2
- package/schemas/runtime/runtime-verify.schema.json +274 -56
- package/schemas/runtime/state-machine-check.schema.json +357 -89
- package/schemas/runtime/structural-observation-payload.schema.json +372 -1
- package/schemas/runtime/sync-check.schema.json +65 -0
- package/src/architecture-debt.ts +125 -38
- package/src/architecture-history.ts +168 -42
- package/src/architecture.ts +100 -0
- package/src/cli-read.ts +228 -0
- package/src/docs-anchors.ts +105 -50
- package/src/explorer-occurrence-ports.ts +175 -0
- package/src/explorer-query-ports.ts +270 -0
- package/src/failure.ts +3 -0
- package/src/index-seed.ts +42 -0
- package/src/index.ts +5 -0
- package/src/ledger-records.ts +262 -0
- package/src/ledger.ts +27 -566
- package/src/ownership-dependencies.ts +115 -5
- package/src/ports.ts +6 -541
- package/src/product-version.ts +74 -55
- package/src/projection-apply-types.ts +216 -0
- package/src/projection-apply-validators.ts +355 -0
- package/src/projection-capabilities.ts +181 -0
- package/src/projection-constants.ts +317 -0
- package/src/projection-manifest-types.ts +298 -0
- package/src/projection-manifest.ts +12 -299
- package/src/projection-recovery-validators.ts +229 -0
- package/src/projection-request-validators.ts +326 -0
- package/src/projection-types.ts +365 -0
- package/src/projection-validation-helpers.ts +15 -0
- package/src/projection.ts +7 -1689
- package/src/ref-impact.ts +225 -33
- package/src/refactor-constants.ts +213 -0
- package/src/refactor-decision-validators.ts +350 -0
- package/src/refactor-evidence-types.ts +286 -0
- package/src/refactor-observation-validators.ts +359 -0
- package/src/refactor-resolution-validators.ts +229 -0
- package/src/refactor-snapshot-validators.ts +368 -0
- package/src/refactor-types.ts +270 -0
- package/src/refactor-v2.ts +389 -0
- package/src/refactor-validation-helpers.ts +195 -0
- package/src/refactor.ts +7 -1849
- package/src/review-guards.ts +3 -23
- package/src/runtime-verify.ts +87 -0
- package/src/schema-kit.ts +183 -0
- package/src/schema-registry.ts +73 -0
- package/src/schema.ts +0 -4
- package/src/state-machine-schemas.ts +192 -0
- package/src/state-machine-types.ts +188 -0
- package/src/state-machine.ts +9 -189
- package/fixtures/boundary/agent-job-expired.json +0 -33
- package/fixtures/invalid/adapter-fidelity-reverse-sync.json +0 -9
- package/fixtures/invalid/agent-job-direct-mutation.json +0 -32
- package/fixtures/invalid/cloud-egress-envelope-private-field.json +0 -12
- package/fixtures/invalid/investigation-report-direct-mutation.json +0 -38
- package/fixtures/invalid/investigation-report-missing-proposed-delta.json +0 -19
- package/fixtures/invalid/notification-event-code-field.json +0 -11
- package/fixtures/valid/adapter-fidelity.json +0 -9
- package/fixtures/valid/agent-job.json +0 -33
- package/fixtures/valid/architecture-candidate-delta-policy.json +0 -45
- package/fixtures/valid/architecture-candidate-delta.json +0 -188
- package/fixtures/valid/chatgpt-ga-tool.json +0 -9
- package/fixtures/valid/cloud-egress-envelope.json +0 -11
- package/fixtures/valid/entitlement.json +0 -12
- package/fixtures/valid/investigation-report.json +0 -38
- package/fixtures/valid/likec4-mapping.json +0 -14
- package/fixtures/valid/notification-event.json +0 -10
- package/fixtures/valid/notification-provider.json +0 -12
- package/fixtures/valid/structurizr-mapping.json +0 -15
- package/schemas/cloud/cloud-egress-envelope.schema.json +0 -19
- package/schemas/cloud/entitlement.schema.json +0 -24
- package/schemas/integrations/adapter-fidelity.schema.json +0 -21
- package/schemas/integrations/chatgpt-ga-tool.schema.json +0 -25
- package/schemas/integrations/likec4-mapping.schema.json +0 -32
- package/schemas/integrations/structurizr-mapping.schema.json +0 -33
- package/schemas/runtime/agent-job.schema.json +0 -63
- package/schemas/runtime/architecture-candidate-delta-policy.schema.json +0 -129
- package/schemas/runtime/architecture-candidate-delta.schema.json +0 -386
- package/schemas/runtime/investigation-report.schema.json +0 -119
- package/schemas/runtime/notification-event.schema.json +0 -18
- package/schemas/runtime/notification-provider.schema.json +0 -26
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import type { RecommendationV3 } from "./ledger";
|
|
2
|
+
import {
|
|
3
|
+
MODULE_STATISTICS_SCHEMA_VERSION,
|
|
4
|
+
REFACTOR_EXECUTION_EVIDENCE_KINDS,
|
|
5
|
+
REFACTOR_EXECUTION_EVIDENCE_LOCATOR_PATTERN,
|
|
6
|
+
REFACTOR_EXECUTION_EVIDENCE_LOCATOR_RULE,
|
|
7
|
+
REFACTOR_PROPOSAL_SCHEMA_VERSION,
|
|
8
|
+
REFACTOR_REQUEST_SCHEMA_VERSION,
|
|
9
|
+
REFACTOR_VERIFICATION_REQUEST_KEYS,
|
|
10
|
+
REFACTOR_VERIFICATION_REQUEST_SCHEMA_VERSION
|
|
11
|
+
} from "./refactor-constants";
|
|
12
|
+
import type {
|
|
13
|
+
RecommendationV3FingerprintInputV1,
|
|
14
|
+
RefactorAssessmentV1,
|
|
15
|
+
RefactorResolutionEvidenceV1
|
|
16
|
+
} from "./refactor-evidence-types";
|
|
17
|
+
import type {
|
|
18
|
+
ArchitectureTargetDeltaV1,
|
|
19
|
+
ModuleDependencyV1,
|
|
20
|
+
ModuleStatisticsSnapshotV1,
|
|
21
|
+
ModuleStatisticsV1,
|
|
22
|
+
RefactorProposalV1,
|
|
23
|
+
RefactorRequestV1,
|
|
24
|
+
RefactorVerificationRequestV1
|
|
25
|
+
} from "./refactor-types";
|
|
26
|
+
import {
|
|
27
|
+
authoredTargetDelta,
|
|
28
|
+
BARE_SHA256_PATTERN,
|
|
29
|
+
compareText,
|
|
30
|
+
DIGEST_PREFIX_LENGTH,
|
|
31
|
+
digestIssues,
|
|
32
|
+
fingerprintPayloadSubset,
|
|
33
|
+
GIT_HEAD_SHA_PATTERN,
|
|
34
|
+
nonNegativeIntegerIssues,
|
|
35
|
+
outcomeIssues,
|
|
36
|
+
ratioIssues,
|
|
37
|
+
refactorProposalAuthorIssues,
|
|
38
|
+
sortedUniqueIssues
|
|
39
|
+
} from "./refactor-validation-helpers";
|
|
40
|
+
import { digestJson, isRepoRelativePosixPath, type Json } from "./schema";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Digest exclusion rule for every helper below: drop the record's own digest
|
|
44
|
+
* field, its top-level `extensions`, and its timestamps. Nested `extensions`
|
|
45
|
+
* (for example `modules[i].extensions`) stay inside the hashed content, so a
|
|
46
|
+
* nested annotation changes the digest. The single exception is the derived
|
|
47
|
+
* `targetDelta` identity below: ArchContext fills `unresolvedTargets` after the
|
|
48
|
+
* agent authored the proposal, so `refactorProposalDigest` hashes the delta
|
|
49
|
+
* under the same exclusions as `architectureTargetDeltaInterventionId`
|
|
50
|
+
* (`interventionId`, `unresolvedTargets`, `extensions`) and the agent-authored
|
|
51
|
+
* identity survives assessment. `authoredBy` stays hashed at the top level:
|
|
52
|
+
* the no-self-authored gate must be digest-bound.
|
|
53
|
+
*/
|
|
54
|
+
export function refactorProposalDigest(proposal: RefactorProposalV1): string {
|
|
55
|
+
const { proposalDigest: _proposalDigest, extensions: _extensions, ...hashable } = proposal;
|
|
56
|
+
return digestJson({
|
|
57
|
+
...hashable,
|
|
58
|
+
...(hashable.targetDelta ? { targetDelta: authoredTargetDelta(hashable.targetDelta) } : {})
|
|
59
|
+
} as unknown as Json);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function architectureTargetDeltaInterventionId(delta: ArchitectureTargetDeltaV1): string {
|
|
63
|
+
const digest = digestJson(authoredTargetDelta(delta) as unknown as Json);
|
|
64
|
+
return `intervention.${digest.slice(DIGEST_PREFIX_LENGTH, DIGEST_PREFIX_LENGTH + 16)}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function moduleStatisticsDigest(module: ModuleStatisticsV1): string {
|
|
68
|
+
const { moduleDigest: _moduleDigest, extensions: _extensions, ...hashable } = module;
|
|
69
|
+
return digestJson(hashable as unknown as Json);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function moduleStatisticsSnapshotDigest(snapshot: ModuleStatisticsSnapshotV1): string {
|
|
73
|
+
const { snapshotDigest: _snapshotDigest, createdAt: _createdAt, extensions: _extensions, ...hashable } = snapshot;
|
|
74
|
+
return digestJson(hashable as unknown as Json);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Repository measurements have no scope digest. Scoped measurements can compare only to the same scope. */
|
|
78
|
+
export function refactorSnapshotScopeDigest(scope: ModuleStatisticsSnapshotV1["scope"]): string | undefined {
|
|
79
|
+
return scope === undefined ? undefined : digestJson(scope);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function refactorAssessmentDigest(assessment: RefactorAssessmentV1): string {
|
|
83
|
+
const {
|
|
84
|
+
assessmentDigest: _assessmentDigest,
|
|
85
|
+
requestId: _requestId,
|
|
86
|
+
createdAt: _createdAt,
|
|
87
|
+
extensions: _extensions,
|
|
88
|
+
...hashable
|
|
89
|
+
} = assessment;
|
|
90
|
+
return digestJson(hashable as unknown as Json);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function refactorResolutionEvidenceDigest(evidence: RefactorResolutionEvidenceV1): string {
|
|
94
|
+
const {
|
|
95
|
+
resolutionDigest: _resolutionDigest,
|
|
96
|
+
verifiedAt: _verifiedAt,
|
|
97
|
+
extensions: _extensions,
|
|
98
|
+
...hashable
|
|
99
|
+
} = evidence;
|
|
100
|
+
return digestJson(hashable as unknown as Json);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Canonical fingerprint input for a v3 recommendation. It deliberately drops
|
|
105
|
+
* `assessmentDigest` and `baselineSnapshotDigest` so that re-detecting the same
|
|
106
|
+
* structural fact at a new HEAD dedups against the previous recommendation and
|
|
107
|
+
* drives `relations.regressesFrom` instead of creating an unrelated record.
|
|
108
|
+
*/
|
|
109
|
+
export function recommendationV3FingerprintInput(
|
|
110
|
+
recommendation: Pick<RecommendationV3, "category" | "subjectSelectorId" | "practiceId" | "payload">
|
|
111
|
+
): RecommendationV3FingerprintInputV1 {
|
|
112
|
+
return {
|
|
113
|
+
category: recommendation.category,
|
|
114
|
+
subjectSelectorId: recommendation.subjectSelectorId,
|
|
115
|
+
practiceId: recommendation.practiceId ?? null,
|
|
116
|
+
payload: fingerprintPayloadSubset(recommendation.category, recommendation.payload)
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function refactorProposalInvariantIssues(proposal: RefactorProposalV1, prefix = "proposal"): string[] {
|
|
121
|
+
const issues = [
|
|
122
|
+
...sortedUniqueIssues(`${prefix}.scopePaths`, proposal.scopePaths),
|
|
123
|
+
...digestIssues(`${prefix}.proposalDigest`, proposal.proposalDigest),
|
|
124
|
+
...outcomeIssues(`${prefix}.targetOutcomes`, proposal.targetOutcomes)
|
|
125
|
+
];
|
|
126
|
+
if (proposal.schemaVersion !== REFACTOR_PROPOSAL_SCHEMA_VERSION) issues.push(`${prefix}.schemaVersion is invalid`);
|
|
127
|
+
if (proposal.intent.trim() === "") issues.push(`${prefix}.intent must not be empty`);
|
|
128
|
+
if (proposal.scopePaths.length === 0) issues.push(`${prefix}.scopePaths must contain at least one path`);
|
|
129
|
+
for (const path of proposal.scopePaths) {
|
|
130
|
+
if (!isRepoRelativePosixPath(path)) issues.push(`${prefix}.scopePaths must be repo-relative POSIX paths: ${path}`);
|
|
131
|
+
}
|
|
132
|
+
issues.push(...refactorProposalAuthorIssues(proposal.authoredBy, prefix));
|
|
133
|
+
issues.push(...sortedUniqueIssues(`${prefix}.killList.selectorId`, proposal.killList.map((entry) => entry.selectorId)));
|
|
134
|
+
if (refactorProposalDigest(proposal) !== proposal.proposalDigest) {
|
|
135
|
+
issues.push(`${prefix}.proposalDigest must bind the authored proposal payload`);
|
|
136
|
+
}
|
|
137
|
+
if (proposal.targetDelta) issues.push(...architectureTargetDeltaInvariantIssues(proposal.targetDelta, `${prefix}.targetDelta`));
|
|
138
|
+
return issues;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function architectureTargetDeltaInvariantIssues(delta: ArchitectureTargetDeltaV1, prefix = "targetDelta"): string[] {
|
|
142
|
+
const issues = [
|
|
143
|
+
...sortedUniqueIssues(`${prefix}.unresolvedTargets`, delta.unresolvedTargets),
|
|
144
|
+
...outcomeIssues(`${prefix}.completionCriteria`, delta.completionCriteria)
|
|
145
|
+
];
|
|
146
|
+
if (delta.thesis.trim() === "") issues.push(`${prefix}.thesis must not be empty`);
|
|
147
|
+
if (delta.trigger.length === 0) issues.push(`${prefix}.trigger must state at least one trigger`);
|
|
148
|
+
if (delta.falsifiers.length === 0) issues.push(`${prefix}.falsifiers must state at least one falsifier`);
|
|
149
|
+
if (delta.completionCriteria.length === 0) issues.push(`${prefix}.completionCriteria must contain at least one outcome`);
|
|
150
|
+
if (delta.benefitLedger.rollbackPoint.trim() === "") issues.push(`${prefix}.benefitLedger.rollbackPoint must not be empty`);
|
|
151
|
+
const temporaryRelations = new Set(delta.migrationState.temporaryRelations);
|
|
152
|
+
for (const relation of delta.targetState.requiredRelations) {
|
|
153
|
+
if (temporaryRelations.has(relation)) {
|
|
154
|
+
issues.push(`${prefix}.targetState.requiredRelations must not contain migration-only relation: ${relation}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (architectureTargetDeltaInterventionId(delta) !== delta.interventionId) {
|
|
158
|
+
issues.push(`${prefix}.interventionId must be derived from the authored delta`);
|
|
159
|
+
}
|
|
160
|
+
return issues;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function refactorRequestInvariantIssues(request: RefactorRequestV1, prefix = "request"): string[] {
|
|
164
|
+
const issues: string[] = [];
|
|
165
|
+
if (request.schemaVersion !== REFACTOR_REQUEST_SCHEMA_VERSION) issues.push(`${prefix}.schemaVersion is invalid`);
|
|
166
|
+
if (request.scope.kind === "node" && request.scope.nodeId.trim() === "") issues.push(`${prefix}.scope.nodeId must not be empty`);
|
|
167
|
+
if (request.scope.kind === "paths") {
|
|
168
|
+
issues.push(...sortedUniqueIssues(`${prefix}.scope.paths`, request.scope.paths));
|
|
169
|
+
if (request.scope.paths.length === 0) issues.push(`${prefix}.scope.paths must contain at least one path`);
|
|
170
|
+
for (const path of request.scope.paths) {
|
|
171
|
+
if (!isRepoRelativePosixPath(path)) issues.push(`${prefix}.scope.paths must be repo-relative POSIX paths: ${path}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (request.proposal) issues.push(...refactorProposalInvariantIssues(request.proposal, `${prefix}.proposal`));
|
|
175
|
+
if (request.importNodeLimit !== undefined && !(Number.isInteger(request.importNodeLimit) && request.importNodeLimit >= 1)) {
|
|
176
|
+
issues.push(`${prefix}.importNodeLimit must be a positive integer`);
|
|
177
|
+
}
|
|
178
|
+
return issues;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Validates a `refactor verify` request before anything measures on its behalf.
|
|
183
|
+
*
|
|
184
|
+
* Top-level keys are closed to `REFACTOR_VERIFICATION_REQUEST_KEYS`. Every ingress rebuilds the
|
|
185
|
+
* request from the declared fields, so a typo (`expectedWorktreeDigset`) would otherwise be
|
|
186
|
+
* dropped in silence and the caller's freshness claim would simply cease to exist — the request
|
|
187
|
+
* would be answered under a weaker precondition than the one it stated.
|
|
188
|
+
*
|
|
189
|
+
* `executionEvidenceRefs` are checked under exactly the rules that bind them into the ledger:
|
|
190
|
+
* three declared keys and nothing else, a kind from the frozen vocabulary, and a bare SHA-256.
|
|
191
|
+
* An extra key would ride a cast into a record whose envelope promises no raw bodies, and the
|
|
192
|
+
* resolution-evidence validator only ever inspects `locator` and `sha256`, so it would never see
|
|
193
|
+
* it. Refusing here is the only place that key is still visible.
|
|
194
|
+
*/
|
|
195
|
+
export function refactorVerificationRequestInvariantIssues(
|
|
196
|
+
request: RefactorVerificationRequestV1,
|
|
197
|
+
prefix = "request"
|
|
198
|
+
): string[] {
|
|
199
|
+
const issues: string[] = [];
|
|
200
|
+
const unknownKeys = Object.keys(request as unknown as Record<string, unknown>)
|
|
201
|
+
.filter((key) => !(REFACTOR_VERIFICATION_REQUEST_KEYS as readonly string[]).includes(key))
|
|
202
|
+
.sort();
|
|
203
|
+
if (unknownKeys.length > 0) issues.push(`${prefix} has unsupported key(s): ${unknownKeys.join(", ")}`);
|
|
204
|
+
if (request.schemaVersion !== REFACTOR_VERIFICATION_REQUEST_SCHEMA_VERSION) issues.push(`${prefix}.schemaVersion is invalid`);
|
|
205
|
+
if (typeof request.recommendationId !== "string" || request.recommendationId.trim() === "") {
|
|
206
|
+
issues.push(`${prefix}.recommendationId must be a non-empty string`);
|
|
207
|
+
}
|
|
208
|
+
if (request.expectedHeadSha !== undefined && !GIT_HEAD_SHA_PATTERN.test(request.expectedHeadSha)) {
|
|
209
|
+
issues.push(`${prefix}.expectedHeadSha must be a 40-hex Git commit sha`);
|
|
210
|
+
}
|
|
211
|
+
if (request.expectedWorktreeDigest !== undefined) {
|
|
212
|
+
issues.push(...digestIssues(`${prefix}.expectedWorktreeDigest`, request.expectedWorktreeDigest));
|
|
213
|
+
}
|
|
214
|
+
if (request.importNodeLimit !== undefined && !(Number.isInteger(request.importNodeLimit) && request.importNodeLimit >= 1)) {
|
|
215
|
+
issues.push(`${prefix}.importNodeLimit must be a positive integer`);
|
|
216
|
+
}
|
|
217
|
+
if (request.executionEvidenceRefs !== undefined) {
|
|
218
|
+
if (!Array.isArray(request.executionEvidenceRefs)) {
|
|
219
|
+
issues.push(`${prefix}.executionEvidenceRefs must be an array`);
|
|
220
|
+
return issues;
|
|
221
|
+
}
|
|
222
|
+
request.executionEvidenceRefs.forEach((ref, index) => {
|
|
223
|
+
const label = `${prefix}.executionEvidenceRefs[${index}]`;
|
|
224
|
+
if (!ref || typeof ref !== "object" || Array.isArray(ref)) {
|
|
225
|
+
issues.push(`${label} must be an object`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const extras = Object.keys(ref).filter((key) => key !== "kind" && key !== "locator" && key !== "sha256");
|
|
229
|
+
if (extras.length > 0) issues.push(`${label} has unsupported key(s): ${[...extras].sort().join(", ")}`);
|
|
230
|
+
if (!(REFACTOR_EXECUTION_EVIDENCE_KINDS as readonly string[]).includes(ref.kind)) {
|
|
231
|
+
issues.push(`${label}.kind must be one of ${REFACTOR_EXECUTION_EVIDENCE_KINDS.join(", ")}`);
|
|
232
|
+
}
|
|
233
|
+
if (typeof ref.locator !== "string" || ref.locator.trim() === "") {
|
|
234
|
+
issues.push(`${label}.locator must be a non-empty string`);
|
|
235
|
+
} else if (!REFACTOR_EXECUTION_EVIDENCE_LOCATOR_PATTERN.test(ref.locator)) {
|
|
236
|
+
issues.push(`${label}.locator ${REFACTOR_EXECUTION_EVIDENCE_LOCATOR_RULE}`);
|
|
237
|
+
}
|
|
238
|
+
if (typeof ref.sha256 !== "string" || !BARE_SHA256_PATTERN.test(ref.sha256)) {
|
|
239
|
+
issues.push(`${label}.sha256 must be a bare SHA-256 hex digest`);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return issues;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function moduleStatisticsInvariantIssues(module: ModuleStatisticsV1, prefix = "module"): string[] {
|
|
247
|
+
const issues = [...digestIssues(`${prefix}.moduleDigest`, module.moduleDigest), ...digestIssues(`${prefix}.nodeDigest`, module.nodeDigest)];
|
|
248
|
+
if (module.nodeId.trim() === "") issues.push(`${prefix}.nodeId must not be empty`);
|
|
249
|
+
if (module.footprintDeclared === (module.footprint === null)) {
|
|
250
|
+
issues.push(`${prefix}.footprint must be present exactly when footprintDeclared is true`);
|
|
251
|
+
}
|
|
252
|
+
if (module.footprint) {
|
|
253
|
+
issues.push(
|
|
254
|
+
...digestIssues(`${prefix}.footprint.sourceFilesDigest`, module.footprint.sourceFilesDigest),
|
|
255
|
+
...nonNegativeIntegerIssues(`${prefix}.footprint.fileCount`, module.footprint.fileCount),
|
|
256
|
+
...nonNegativeIntegerIssues(`${prefix}.footprint.lineCount`, module.footprint.lineCount)
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
if (module.dependencyGraph) {
|
|
260
|
+
const graph = module.dependencyGraph;
|
|
261
|
+
issues.push(
|
|
262
|
+
...nonNegativeIntegerIssues(`${prefix}.dependencyGraph.internalEdgeCount`, graph.internalEdgeCount),
|
|
263
|
+
...nonNegativeIntegerIssues(`${prefix}.dependencyGraph.inboundModuleEdges`, graph.inboundModuleEdges),
|
|
264
|
+
...nonNegativeIntegerIssues(`${prefix}.dependencyGraph.outboundModuleEdges`, graph.outboundModuleEdges),
|
|
265
|
+
...nonNegativeIntegerIssues(`${prefix}.dependencyGraph.fanIn`, graph.fanIn),
|
|
266
|
+
...nonNegativeIntegerIssues(`${prefix}.dependencyGraph.fanOut`, graph.fanOut),
|
|
267
|
+
...nonNegativeIntegerIssues(`${prefix}.dependencyGraph.cycleCount`, graph.cycleCount),
|
|
268
|
+
...nonNegativeIntegerIssues(`${prefix}.dependencyGraph.directionViolationCount`, graph.directionViolationCount),
|
|
269
|
+
...ratioIssues(`${prefix}.dependencyGraph.instability`, graph.instability)
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
issues.push(
|
|
273
|
+
...nonNegativeIntegerIssues(`${prefix}.tests.testFileCount`, module.tests.testFileCount),
|
|
274
|
+
...nonNegativeIntegerIssues(`${prefix}.tests.observedTestEdges`, module.tests.observedTestEdges),
|
|
275
|
+
...ratioIssues(`${prefix}.tests.callerCoverage`, module.tests.callerCoverage),
|
|
276
|
+
...nonNegativeIntegerIssues(`${prefix}.uncertainty.unresolvedImports`, module.uncertainty.unresolvedImports)
|
|
277
|
+
);
|
|
278
|
+
if (moduleStatisticsDigest(module) !== module.moduleDigest) {
|
|
279
|
+
issues.push(`${prefix}.moduleDigest must bind the measured module payload`);
|
|
280
|
+
}
|
|
281
|
+
return issues;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function moduleStatisticsSnapshotInvariantIssues(snapshot: ModuleStatisticsSnapshotV1, prefix = "snapshot"): string[] {
|
|
285
|
+
const issues = [
|
|
286
|
+
...digestIssues(`${prefix}.snapshotDigest`, snapshot.snapshotDigest),
|
|
287
|
+
...digestIssues(`${prefix}.modelDigest`, snapshot.modelDigest),
|
|
288
|
+
...sortedUniqueIssues(`${prefix}.codeFacts.reasonCodes`, snapshot.codeFacts.reasonCodes),
|
|
289
|
+
...sortedUniqueIssues(`${prefix}.modules.nodeId`, snapshot.modules.map((module) => module.nodeId)),
|
|
290
|
+
...snapshot.modules.flatMap((module, index) => moduleStatisticsInvariantIssues(module, `${prefix}.modules[${index}]`))
|
|
291
|
+
];
|
|
292
|
+
if (snapshot.schemaVersion !== MODULE_STATISTICS_SCHEMA_VERSION) issues.push(`${prefix}.schemaVersion is invalid`);
|
|
293
|
+
if (snapshot.codeFacts.coverage === "unknown") {
|
|
294
|
+
if (!snapshot.codeFacts.truncated) issues.push(`${prefix}.codeFacts.truncated must be true when coverage is unknown`);
|
|
295
|
+
for (const [index, module] of snapshot.modules.entries()) {
|
|
296
|
+
if (module.dependencyGraph !== null) {
|
|
297
|
+
issues.push(`${prefix}.modules[${index}].dependencyGraph must be null when codeFacts.coverage is unknown`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (snapshot.codeFacts.coverage !== "unknown") {
|
|
302
|
+
if (snapshot.codeFacts.indexedWorktreeDigest === null) {
|
|
303
|
+
issues.push(`${prefix}.codeFacts.indexedWorktreeDigest must be present when coverage is ${snapshot.codeFacts.coverage}`);
|
|
304
|
+
} else if (snapshot.codeFacts.indexedWorktreeDigest !== snapshot.worktree.worktreeDigest) {
|
|
305
|
+
issues.push(`${prefix}.codeFacts.indexedWorktreeDigest must match the measured worktreeDigest`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
issues.push(...nonNegativeIntegerIssues(`${prefix}.codeFacts.edgeLimit`, snapshot.codeFacts.edgeLimit));
|
|
309
|
+
const importNodeCount = snapshot.codeFacts.importNodeCount ?? null;
|
|
310
|
+
issues.push(...nonNegativeIntegerIssues(`${prefix}.codeFacts.importNodeCount`, importNodeCount));
|
|
311
|
+
if (snapshot.codeFacts.reasonCodes.includes("code-facts-import-limit")) {
|
|
312
|
+
const { edgeLimit } = snapshot.codeFacts;
|
|
313
|
+
if (snapshot.codeFacts.coverage !== "partial") issues.push(`${prefix}.codeFacts.coverage must be partial when the import limit was reached`);
|
|
314
|
+
if (edgeLimit === null || (importNodeCount !== null && importNodeCount <= edgeLimit)) {
|
|
315
|
+
issues.push(`${prefix}.codeFacts.importNodeCount must exceed edgeLimit when the import limit was reached`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
for (const [field, value] of Object.entries(snapshot.repositorySummary)) {
|
|
319
|
+
issues.push(...nonNegativeIntegerIssues(`${prefix}.repositorySummary.${field}`, value));
|
|
320
|
+
}
|
|
321
|
+
issues.push(...moduleDependencyIssues(snapshot, prefix));
|
|
322
|
+
if (snapshot.repositorySummary.moduleCount !== snapshot.modules.length) {
|
|
323
|
+
issues.push(`${prefix}.repositorySummary.moduleCount must equal the module count`);
|
|
324
|
+
}
|
|
325
|
+
const undeclared = snapshot.modules.filter((module) => !module.footprintDeclared).length;
|
|
326
|
+
if (snapshot.repositorySummary.undeclaredFootprintNodeCount !== undeclared) {
|
|
327
|
+
issues.push(`${prefix}.repositorySummary.undeclaredFootprintNodeCount must equal the undeclared footprint module count`);
|
|
328
|
+
}
|
|
329
|
+
if (moduleStatisticsSnapshotDigest(snapshot) !== snapshot.snapshotDigest) {
|
|
330
|
+
issues.push(`${prefix}.snapshotDigest must bind the measured snapshot payload`);
|
|
331
|
+
}
|
|
332
|
+
return issues;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* The dependency table binds the graph counts it was measured with: sorted and unique by
|
|
337
|
+
* `(fromNodeId, toNodeId)`, positive counts, no self edge, both ends measured modules, one entry per
|
|
338
|
+
* counted cross-module edge, and nothing at all when the graph was not measured.
|
|
339
|
+
*/
|
|
340
|
+
function moduleDependencyIssues(snapshot: ModuleStatisticsSnapshotV1, prefix: string): string[] {
|
|
341
|
+
const label = `${prefix}.moduleDependencies`;
|
|
342
|
+
const dependencies = (snapshot as { moduleDependencies?: unknown }).moduleDependencies;
|
|
343
|
+
if (!Array.isArray(dependencies)) return [`${label} must be an array`];
|
|
344
|
+
const issues: string[] = [];
|
|
345
|
+
const modules = new Set(snapshot.modules.map((module) => module.nodeId));
|
|
346
|
+
for (const [index, entry] of (dependencies as ModuleDependencyV1[]).entries()) {
|
|
347
|
+
if (!entry || typeof entry !== "object") {
|
|
348
|
+
issues.push(`${label}[${index}] must be an object`);
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
if (!modules.has(entry.fromNodeId) || !modules.has(entry.toNodeId)) issues.push(`${label}[${index}] must name measured modules`);
|
|
352
|
+
if (entry.fromNodeId === entry.toNodeId) issues.push(`${label}[${index}] must not be a self dependency`);
|
|
353
|
+
if (!Number.isInteger(entry.distinctFileEdgeCount) || entry.distinctFileEdgeCount < 1) {
|
|
354
|
+
issues.push(`${label}[${index}].distinctFileEdgeCount must be a positive integer`);
|
|
355
|
+
}
|
|
356
|
+
const previous = (dependencies as ModuleDependencyV1[])[index - 1];
|
|
357
|
+
if (previous && (compareText(previous.fromNodeId, entry.fromNodeId) || compareText(previous.toNodeId, entry.toNodeId)) >= 0) {
|
|
358
|
+
issues.push(`${label} must be sorted and unique by (fromNodeId, toNodeId)`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (dependencies.length !== snapshot.repositorySummary.crossModuleEdgeCount) {
|
|
362
|
+
issues.push(`${label} must hold one entry per repositorySummary.crossModuleEdgeCount`);
|
|
363
|
+
}
|
|
364
|
+
if (snapshot.codeFacts.coverage === "unknown" && dependencies.length > 0) {
|
|
365
|
+
issues.push(`${label} must be empty when codeFacts.coverage is unknown`);
|
|
366
|
+
}
|
|
367
|
+
return [...new Set(issues)];
|
|
368
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ArchitectureRepositoryIdentityV1,
|
|
3
|
+
ArchitectureWorktreeIdentityV1,
|
|
4
|
+
EvidenceCoverageLevelV2,
|
|
5
|
+
RecommendationAuthorV1
|
|
6
|
+
} from "./ledger-records";
|
|
7
|
+
import type {
|
|
8
|
+
MODULE_STATISTICS_SCHEMA_VERSION,
|
|
9
|
+
ModuleDynamicInvocationLevel,
|
|
10
|
+
ModuleTestsCoverageStatus,
|
|
11
|
+
REFACTOR_PROPOSAL_SCHEMA_VERSION,
|
|
12
|
+
REFACTOR_REQUEST_SCHEMA_VERSION,
|
|
13
|
+
REFACTOR_VERIFICATION_REQUEST_SCHEMA_VERSION,
|
|
14
|
+
RefactorKillListKind,
|
|
15
|
+
RefactorOutcomeDirection,
|
|
16
|
+
RefactorOutcomeOperator,
|
|
17
|
+
RefactorScaleReasonCode
|
|
18
|
+
} from "./refactor-constants";
|
|
19
|
+
import type { RefactorExecutionEvidenceRefV1 } from "./refactor-evidence-types";
|
|
20
|
+
import type { Json } from "./schema";
|
|
21
|
+
|
|
22
|
+
export type RefactorScopeV1 =
|
|
23
|
+
| { kind: "repository" }
|
|
24
|
+
| { kind: "node"; nodeId: string }
|
|
25
|
+
| { kind: "paths"; paths: string[] };
|
|
26
|
+
|
|
27
|
+
export interface RefactorTargetOutcomeV1 {
|
|
28
|
+
outcomeId: string;
|
|
29
|
+
metric: string;
|
|
30
|
+
subjectSelectorId: string;
|
|
31
|
+
nodeId: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* The module set a `moduleDependencies.*` metric is measured over: the two ends of a pair, or the
|
|
34
|
+
* members of a residual cycle. Present exactly for that metric family, sorted and unique.
|
|
35
|
+
*/
|
|
36
|
+
memberNodeIds?: string[];
|
|
37
|
+
operator: RefactorOutcomeOperator;
|
|
38
|
+
value: number | null;
|
|
39
|
+
required: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface RefactorObservedOutcomeV1 {
|
|
43
|
+
outcomeId: string;
|
|
44
|
+
observedValue: number | null;
|
|
45
|
+
satisfied: boolean;
|
|
46
|
+
direction: RefactorOutcomeDirection;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface RefactorKillListEntryV1 {
|
|
50
|
+
kind: RefactorKillListKind;
|
|
51
|
+
selectorId: string;
|
|
52
|
+
required: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ArchitectureTargetDeltaV1 {
|
|
56
|
+
interventionId: string;
|
|
57
|
+
trigger: string[];
|
|
58
|
+
thesis: string;
|
|
59
|
+
targetState: {
|
|
60
|
+
owners: Record<string, string>;
|
|
61
|
+
requiredRelations: string[];
|
|
62
|
+
removedConcepts: string[];
|
|
63
|
+
};
|
|
64
|
+
migrationState: {
|
|
65
|
+
active: boolean;
|
|
66
|
+
compatibilityContracts: string[];
|
|
67
|
+
cleanupBy?: string;
|
|
68
|
+
temporaryRelations: string[];
|
|
69
|
+
};
|
|
70
|
+
completionCriteria: RefactorTargetOutcomeV1[];
|
|
71
|
+
falsifiers: string[];
|
|
72
|
+
benefitLedger: {
|
|
73
|
+
benefits: string[];
|
|
74
|
+
costs: string[];
|
|
75
|
+
rollbackPoint: string;
|
|
76
|
+
};
|
|
77
|
+
unresolvedTargets: string[];
|
|
78
|
+
extensions?: Record<string, Json>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface RefactorProposalV1 {
|
|
82
|
+
schemaVersion: typeof REFACTOR_PROPOSAL_SCHEMA_VERSION;
|
|
83
|
+
authoredBy: RecommendationAuthorV1;
|
|
84
|
+
intent: string;
|
|
85
|
+
scopePaths: string[];
|
|
86
|
+
targetDelta?: ArchitectureTargetDeltaV1;
|
|
87
|
+
targetOutcomes: RefactorTargetOutcomeV1[];
|
|
88
|
+
killList: RefactorKillListEntryV1[];
|
|
89
|
+
proposalDigest: string;
|
|
90
|
+
extensions?: Record<string, Json>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface RefactorRequestV1 {
|
|
94
|
+
schemaVersion: typeof REFACTOR_REQUEST_SCHEMA_VERSION;
|
|
95
|
+
scope: RefactorScopeV1;
|
|
96
|
+
proposal?: RefactorProposalV1;
|
|
97
|
+
expectedHeadSha?: string;
|
|
98
|
+
expectedWorktreeDigest?: string;
|
|
99
|
+
task?: string;
|
|
100
|
+
/**
|
|
101
|
+
* The most CodeGraph import nodes the scan reads. Omitted means the runtime default. A larger
|
|
102
|
+
* index gives partial coverage with `code-facts-import-limit`, never `code-facts-truncated`.
|
|
103
|
+
*/
|
|
104
|
+
importNodeLimit?: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The JSON ingress for `refactor verify`. `recommendationId` is the whole subject: a verification
|
|
109
|
+
* always re-measures whatever is at HEAD now, so there is no caller-supplied AFTER state and no
|
|
110
|
+
* outcome override — the recorded recommendation already carries the acceptance test, and letting
|
|
111
|
+
* a caller restate it would let the requester steer its own verdict.
|
|
112
|
+
*
|
|
113
|
+
* `expectedHeadSha` and `expectedWorktreeDigest` are claims about the state the caller believes it
|
|
114
|
+
* is verifying. A claim that no longer holds is refused rather than answered with fresh numbers
|
|
115
|
+
* under the old identity.
|
|
116
|
+
*/
|
|
117
|
+
export interface RefactorVerificationRequestV1 {
|
|
118
|
+
schemaVersion: typeof REFACTOR_VERIFICATION_REQUEST_SCHEMA_VERSION;
|
|
119
|
+
recommendationId: string;
|
|
120
|
+
expectedHeadSha?: string;
|
|
121
|
+
expectedWorktreeDigest?: string;
|
|
122
|
+
executionEvidenceRefs?: RefactorExecutionEvidenceRefV1[];
|
|
123
|
+
/**
|
|
124
|
+
* The most CodeGraph import nodes the re-measure reads. Omitted means the limit the recorded
|
|
125
|
+
* baseline snapshot was measured with, so BEFORE and AFTER read the same import population.
|
|
126
|
+
*/
|
|
127
|
+
importNodeLimit?: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface ModuleStatisticsV1 {
|
|
131
|
+
nodeId: string;
|
|
132
|
+
nodeDigest: string;
|
|
133
|
+
parentNodeId: string | null;
|
|
134
|
+
footprintDeclared: boolean;
|
|
135
|
+
footprint: {
|
|
136
|
+
fileCount: number;
|
|
137
|
+
lineCount: number;
|
|
138
|
+
sourceFilesDigest: string;
|
|
139
|
+
includePatterns: string[];
|
|
140
|
+
excludePatterns: string[];
|
|
141
|
+
} | null;
|
|
142
|
+
surfaces: {
|
|
143
|
+
declaredEntrypoints: string[];
|
|
144
|
+
observedEntrypoints: string[];
|
|
145
|
+
lifecycleOwners: string[];
|
|
146
|
+
datastoreSubjects: string[];
|
|
147
|
+
entrypointBypassCount?: number;
|
|
148
|
+
};
|
|
149
|
+
dependencyGraph: {
|
|
150
|
+
internalEdgeCount: number;
|
|
151
|
+
inboundModuleEdges: number;
|
|
152
|
+
outboundModuleEdges: number;
|
|
153
|
+
fanIn: number;
|
|
154
|
+
fanOut: number;
|
|
155
|
+
stronglyConnectedComponentId: string | null;
|
|
156
|
+
cycleCount: number;
|
|
157
|
+
instability: number | null;
|
|
158
|
+
directionViolationCount: number | null;
|
|
159
|
+
unstableDependencyCount?: number;
|
|
160
|
+
} | null;
|
|
161
|
+
cohesion?: {
|
|
162
|
+
lowCohesionFileCount: number;
|
|
163
|
+
measuredFileCount: number;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* `callerCoverage` is a graph-boundary resolution ratio (the share of the
|
|
167
|
+
* module's inbound call boundary the index could resolve), not a test
|
|
168
|
+
* measurement, so it is independent of `coverageStatus`: a producer may know
|
|
169
|
+
* the boundary ratio while observing no test evidence at all, and it may know
|
|
170
|
+
* test files while the boundary stays unresolved. Only the 0-1 ratio bound is
|
|
171
|
+
* enforced; the two fields are never coupled (PRD 0.3-16).
|
|
172
|
+
*/
|
|
173
|
+
tests: {
|
|
174
|
+
testFileCount: number | null;
|
|
175
|
+
observedTestEdges: number | null;
|
|
176
|
+
callerCoverage: number | null;
|
|
177
|
+
coverageStatus: ModuleTestsCoverageStatus;
|
|
178
|
+
};
|
|
179
|
+
uncertainty: {
|
|
180
|
+
unresolvedImports: number;
|
|
181
|
+
dynamicInvocation: ModuleDynamicInvocationLevel;
|
|
182
|
+
ambiguousOwnership: boolean;
|
|
183
|
+
};
|
|
184
|
+
moduleDigest: string;
|
|
185
|
+
extensions?: Record<string, Json>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* One ordered cross-module dependency of the measured graph: `distinctFileEdgeCount` distinct
|
|
190
|
+
* file-to-file import edges whose source file `fromNodeId` owns and whose target `toNodeId` owns.
|
|
191
|
+
* A contested file is attributed to each claimant, exactly as the module counts are.
|
|
192
|
+
*/
|
|
193
|
+
export interface ModuleDependencyV1 {
|
|
194
|
+
fromNodeId: string;
|
|
195
|
+
toNodeId: string;
|
|
196
|
+
distinctFileEdgeCount: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface GitCoChangeWindowV1 {
|
|
200
|
+
anchorHeadSha: string;
|
|
201
|
+
windowLimit: number;
|
|
202
|
+
observedCommitCount: number;
|
|
203
|
+
eligibleCommitCount: number;
|
|
204
|
+
maxFilesPerCommit: number;
|
|
205
|
+
isShallow: boolean;
|
|
206
|
+
reachedHistoryRoot: boolean;
|
|
207
|
+
coverageStatus: "complete" | "shallow" | "insufficient-history" | "unavailable";
|
|
208
|
+
reasonCodes: string[];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface CoChangeDependencySummaryV1 {
|
|
212
|
+
fromNodeId: string;
|
|
213
|
+
toNodeId: string;
|
|
214
|
+
pairCount: number;
|
|
215
|
+
maxCoChangeCount: number;
|
|
216
|
+
maxJaccard: number;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface ModuleStatisticsSnapshotV1 {
|
|
220
|
+
schemaVersion: typeof MODULE_STATISTICS_SCHEMA_VERSION;
|
|
221
|
+
/** When present, counts describe the requested files and their direct import neighbors. */
|
|
222
|
+
scope?: Exclude<RefactorScopeV1, { kind: "repository" }>;
|
|
223
|
+
repository: ArchitectureRepositoryIdentityV1;
|
|
224
|
+
worktree: ArchitectureWorktreeIdentityV1;
|
|
225
|
+
modelDigest: string;
|
|
226
|
+
codeFacts: {
|
|
227
|
+
provider: "codegraph";
|
|
228
|
+
version: string;
|
|
229
|
+
binaryDigest: string;
|
|
230
|
+
indexedWorktreeDigest: string | null;
|
|
231
|
+
coverage: EvidenceCoverageLevelV2;
|
|
232
|
+
/**
|
|
233
|
+
* True only when the read is shorter than the population the index reported. A read cut by
|
|
234
|
+
* `edgeLimit` is not truncated: it reports `code-facts-import-limit` instead.
|
|
235
|
+
*/
|
|
236
|
+
truncated: boolean;
|
|
237
|
+
/** The import-node read limit the scan applied. */
|
|
238
|
+
edgeLimit: number | null;
|
|
239
|
+
/**
|
|
240
|
+
* Import nodes the index reported, or `null` when no index gave a count. Absent on snapshots
|
|
241
|
+
* recorded before the field existed.
|
|
242
|
+
*/
|
|
243
|
+
importNodeCount?: number | null;
|
|
244
|
+
reasonCodes: RefactorScaleReasonCode[];
|
|
245
|
+
};
|
|
246
|
+
modules: ModuleStatisticsV1[];
|
|
247
|
+
/**
|
|
248
|
+
* The module dependency table the graph counts were measured from, sorted by
|
|
249
|
+
* `(fromNodeId, toNodeId)`; one entry per `repositorySummary.crossModuleEdgeCount`. Empty when the
|
|
250
|
+
* graph was not measured (`codeFacts.coverage: unknown`).
|
|
251
|
+
*/
|
|
252
|
+
moduleDependencies: ModuleDependencyV1[];
|
|
253
|
+
repositorySummary: {
|
|
254
|
+
moduleCount: number;
|
|
255
|
+
undeclaredFootprintNodeCount: number;
|
|
256
|
+
ownedFileCount: number;
|
|
257
|
+
unownedFileCount: number;
|
|
258
|
+
multiplyOwnedFileCount: number;
|
|
259
|
+
crossModuleEdgeCount: number;
|
|
260
|
+
crossModuleCycleCount: number;
|
|
261
|
+
stronglyConnectedComponentCount: number;
|
|
262
|
+
unresolvedImportCount: number;
|
|
263
|
+
dynamicInvocationRiskCount: number;
|
|
264
|
+
};
|
|
265
|
+
coChangeDependencies?: CoChangeDependencySummaryV1[];
|
|
266
|
+
gitHistory?: GitCoChangeWindowV1;
|
|
267
|
+
createdAt: string;
|
|
268
|
+
snapshotDigest: string;
|
|
269
|
+
extensions?: Record<string, Json>;
|
|
270
|
+
}
|