archctx-contracts 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fixtures/valid/archctx-capabilities.json +1 -1
- package/fixtures/valid/product-version-manifest.json +4 -4
- package/package.json +1 -1
- package/schemas/repo/refactor-decision.schema.json +27 -3
- package/schemas/runtime/cli-check.schema.json +13 -1
- package/schemas/runtime/docs-anchors.schema.json +13 -1
- package/schemas/runtime/path-context.schema.json +13 -1
- package/schemas/runtime/refactor-scan-v2.schema.json +962 -4
- package/schemas/runtime/refactor-simulate.schema.json +52 -4
- package/schemas/runtime/sync-check.schema.json +13 -1
- package/src/failure.ts +1 -0
- package/src/product-version.ts +1 -1
- package/src/refactor-constants.ts +3 -3
- package/src/refactor-decision-validators.ts +2 -1
- package/src/refactor-v2.ts +167 -2
- package/src/refactor-validation-helpers.ts +5 -1
- package/src/schema-kit.ts +5 -1
- package/src/schema.ts +15 -0
|
@@ -60,11 +60,23 @@
|
|
|
60
60
|
{
|
|
61
61
|
"pattern": "^/"
|
|
62
62
|
},
|
|
63
|
+
{
|
|
64
|
+
"pattern": "/$"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"pattern": "//"
|
|
68
|
+
},
|
|
63
69
|
{
|
|
64
70
|
"pattern": "\\\\"
|
|
65
71
|
},
|
|
66
72
|
{
|
|
67
|
-
"pattern": "
|
|
73
|
+
"pattern": "^[A-Za-z]:"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"pattern": "[\\u0000-\\u001f\\u007f]"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"pattern": "(^|/)\\.\\.?(/|$)"
|
|
68
80
|
}
|
|
69
81
|
]
|
|
70
82
|
}
|
|
@@ -271,11 +283,23 @@
|
|
|
271
283
|
{
|
|
272
284
|
"pattern": "^/"
|
|
273
285
|
},
|
|
286
|
+
{
|
|
287
|
+
"pattern": "/$"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"pattern": "//"
|
|
291
|
+
},
|
|
274
292
|
{
|
|
275
293
|
"pattern": "\\\\"
|
|
276
294
|
},
|
|
277
295
|
{
|
|
278
|
-
"pattern": "
|
|
296
|
+
"pattern": "^[A-Za-z]:"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"pattern": "[\\u0000-\\u001f\\u007f]"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"pattern": "(^|/)\\.\\.?(/|$)"
|
|
279
303
|
}
|
|
280
304
|
]
|
|
281
305
|
}
|
|
@@ -288,11 +312,23 @@
|
|
|
288
312
|
{
|
|
289
313
|
"pattern": "^/"
|
|
290
314
|
},
|
|
315
|
+
{
|
|
316
|
+
"pattern": "/$"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"pattern": "//"
|
|
320
|
+
},
|
|
291
321
|
{
|
|
292
322
|
"pattern": "\\\\"
|
|
293
323
|
},
|
|
294
324
|
{
|
|
295
|
-
"pattern": "
|
|
325
|
+
"pattern": "^[A-Za-z]:"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"pattern": "[\\u0000-\\u001f\\u007f]"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"pattern": "(^|/)\\.\\.?(/|$)"
|
|
296
332
|
}
|
|
297
333
|
]
|
|
298
334
|
}
|
|
@@ -385,11 +421,23 @@
|
|
|
385
421
|
{
|
|
386
422
|
"pattern": "^/"
|
|
387
423
|
},
|
|
424
|
+
{
|
|
425
|
+
"pattern": "/$"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"pattern": "//"
|
|
429
|
+
},
|
|
388
430
|
{
|
|
389
431
|
"pattern": "\\\\"
|
|
390
432
|
},
|
|
391
433
|
{
|
|
392
|
-
"pattern": "
|
|
434
|
+
"pattern": "^[A-Za-z]:"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"pattern": "[\\u0000-\\u001f\\u007f]"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"pattern": "(^|/)\\.\\.?(/|$)"
|
|
393
441
|
}
|
|
394
442
|
]
|
|
395
443
|
}
|
|
@@ -48,11 +48,23 @@
|
|
|
48
48
|
{
|
|
49
49
|
"pattern": "^/"
|
|
50
50
|
},
|
|
51
|
+
{
|
|
52
|
+
"pattern": "/$"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"pattern": "//"
|
|
56
|
+
},
|
|
51
57
|
{
|
|
52
58
|
"pattern": "\\\\"
|
|
53
59
|
},
|
|
54
60
|
{
|
|
55
|
-
"pattern": "
|
|
61
|
+
"pattern": "^[A-Za-z]:"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"pattern": "[\\u0000-\\u001f\\u007f]"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"pattern": "(^|/)\\.\\.?(/|$)"
|
|
56
68
|
}
|
|
57
69
|
]
|
|
58
70
|
}
|
package/src/failure.ts
CHANGED
|
@@ -178,6 +178,7 @@ Object.assign(policies, {
|
|
|
178
178
|
"runtime-writer-locked": {"code": "AC_PRECONDITION_FAILED", "message": "Runtime writer is locked.", "facts": {}},
|
|
179
179
|
"runtime-ledger-mode-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Runtime architecture ledger mode invalid.", "facts": {"field": "ledgerModeField"}},
|
|
180
180
|
"runtime-writer-owned": {"code": "AC_PRECONDITION_FAILED", "message": "local-store-writer-owned: another live process owns this store.", "facts": {}},
|
|
181
|
+
"local-store-unproven-file": {"code": "AC_PRECONDITION_FAILED", "message": "Local store target is not an ArchContext SQLite cache; refusing to modify or delete it.", "facts": {}},
|
|
181
182
|
"rpc-input-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Runtime RPC input invalid.", "facts": {}},
|
|
182
183
|
"rpc-method-invalid": {"code": "AC_SCHEMA_INVALID", "message": "Unknown runtime RPC method. Upgrade the client.", "facts": {}, "action":"upgrade-client"},
|
|
183
184
|
"changeset-rollback-conflict": {code: "AC_PRECONDITION_FAILED", message: "ChangeSet rollback is incomplete because the projection manifest changed externally. Preserve the pending journal and backup for manual recovery.", facts: {journalId: "optional:id", changeSetId: "id", manualRecoveryRequired: "boolean"}},
|
package/src/product-version.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./schema-kit";
|
|
11
11
|
|
|
12
12
|
export const ARCHCONTEXT_PRODUCT_NAME = "archctx" as const;
|
|
13
|
-
export const ARCHCONTEXT_PRODUCT_VERSION = "0.18.
|
|
13
|
+
export const ARCHCONTEXT_PRODUCT_VERSION = "0.18.1" as const;
|
|
14
14
|
export const ARCHCONTEXT_PACKAGE_MANAGER = "bun@1.4.4" as const;
|
|
15
15
|
export const ARCHCONTEXT_NODE_RANGE = ">=22.22 <26" as const;
|
|
16
16
|
export const LOCAL_RUNTIME_RPC_SCHEMA_VERSION = "archcontext.runtime-rpc/v2" as const;
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
ArchitectureSubjectSelectorKind,
|
|
4
4
|
RecommendationStatus
|
|
5
5
|
} from "./ledger-records";
|
|
6
|
-
import {
|
|
6
|
+
import { isCanonicalRepoRelativePosixPath } from "./schema";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The bounded grammar an execution evidence `locator` must fit: 1..256 characters drawn from the
|
|
@@ -181,7 +181,7 @@ export const REFACTOR_RECOMMENDATION_ID_PATTERN = /^recommendation\.[a-f0-9]{16}
|
|
|
181
181
|
* #636 / #643: Symbolic kill-list targets use `path#symbol`, where `path` is a safe repo-relative
|
|
182
182
|
* POSIX path and `symbol` is a non-empty identifier without whitespace or control characters.
|
|
183
183
|
*/
|
|
184
|
-
export const REFACTOR_KILL_LIST_SYMBOL_TARGET_REGEX = "^(
|
|
184
|
+
export const REFACTOR_KILL_LIST_SYMBOL_TARGET_REGEX = "^(?![A-Za-z]:)(?!\\.\\.?(?:/|#))[^/#\\s\\\\\\u0000-\\u001f\\u007f]+(?:/(?!\\.\\.?(?:/|#))[^/#\\s\\\\\\u0000-\\u001f\\u007f]+)*#[^#\\s\\u0000-\\u001f\\u007f]+$";
|
|
185
185
|
|
|
186
186
|
export function formatRefactorKillListSymbolTarget(path: string, symbol: string): string {
|
|
187
187
|
return `${path}#${symbol}`;
|
|
@@ -193,7 +193,7 @@ export function parseRefactorKillListSymbolTarget(target: string): { path: strin
|
|
|
193
193
|
if (target.indexOf("#", hashIndex + 1) !== -1) return undefined;
|
|
194
194
|
const path = target.slice(0, hashIndex);
|
|
195
195
|
const symbol = target.slice(hashIndex + 1);
|
|
196
|
-
if (!
|
|
196
|
+
if (!isCanonicalRepoRelativePosixPath(path) || /[\s\u0000-\u001f\u007f]/.test(path)) return undefined;
|
|
197
197
|
if (/[\s\u0000-\u001f\u007f]/.test(symbol) || symbol.length === 0) return undefined;
|
|
198
198
|
return { path, symbol };
|
|
199
199
|
}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from "./refactor-constants";
|
|
20
20
|
import type { RefactorDecisionV1 } from "./refactor-evidence-types";
|
|
21
21
|
import {
|
|
22
|
+
canonicalRepoPathIssues,
|
|
22
23
|
digestIssues,
|
|
23
24
|
GIT_HEAD_SHA_PATTERN,
|
|
24
25
|
outcomeIssues,
|
|
@@ -253,7 +254,7 @@ export function refactorDecisionInvariantIssues(value: unknown, prefix = "refact
|
|
|
253
254
|
continue;
|
|
254
255
|
}
|
|
255
256
|
if (entry.kind === "path") {
|
|
256
|
-
issues.push(...
|
|
257
|
+
issues.push(...canonicalRepoPathIssues(`${prefix}.killList.target`, entry.target));
|
|
257
258
|
} else if (entry.kind === "symbol" && !isValidRefactorKillListSymbolTarget(entry.target)) {
|
|
258
259
|
issues.push(`${prefix}.killList.target must be <repo-relative-path>#<symbol>`);
|
|
259
260
|
}
|
package/src/refactor-v2.ts
CHANGED
|
@@ -7,6 +7,18 @@ import {
|
|
|
7
7
|
parseRefactorKillListSymbolTarget,
|
|
8
8
|
isValidRefactorKillListSymbolTarget
|
|
9
9
|
} from "./refactor";
|
|
10
|
+
import type {
|
|
11
|
+
RefactorEvidenceCoChangePairV1,
|
|
12
|
+
RefactorEvidenceDirectionViolationV1,
|
|
13
|
+
RefactorEvidenceImportEdgeV1,
|
|
14
|
+
RefactorEvidenceLowCohesionClusterV1,
|
|
15
|
+
RefactorEvidenceLowCohesionFileV1,
|
|
16
|
+
RefactorEvidencePairDirectionV1,
|
|
17
|
+
RefactorEvidencePathV1,
|
|
18
|
+
RefactorEvidenceUnresolvedImportV1,
|
|
19
|
+
RefactorEvidenceUnstableTargetV1,
|
|
20
|
+
RefactorObservationEvidenceV1
|
|
21
|
+
} from "./refactor-evidence-types";
|
|
10
22
|
import {
|
|
11
23
|
AnyOf,
|
|
12
24
|
BoundedStringSchema,
|
|
@@ -18,6 +30,7 @@ import {
|
|
|
18
30
|
OneOf,
|
|
19
31
|
RawEnum,
|
|
20
32
|
RecordOf,
|
|
33
|
+
Ref,
|
|
21
34
|
RepoPathSchema,
|
|
22
35
|
SchemaDocument,
|
|
23
36
|
Sha256DigestSchema,
|
|
@@ -188,6 +201,145 @@ export const RefactorDecisionFileSchema = SchemaDocument({
|
|
|
188
201
|
});
|
|
189
202
|
export type RefactorDecisionFileV1 = Static<typeof RefactorDecisionFileSchema>;
|
|
190
203
|
|
|
204
|
+
const EvidenceImportEdgeSchema = StrictObject({
|
|
205
|
+
fromPath: RepoPathSchema,
|
|
206
|
+
fromLine: NullableType("integer", { minimum: 1 }),
|
|
207
|
+
toPath: RepoPathSchema,
|
|
208
|
+
specifier: NonEmptyStringSchema,
|
|
209
|
+
fromNodeId: NonEmptyStringSchema,
|
|
210
|
+
toNodeId: NonEmptyStringSchema
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const EvidencePairDirectionSchema = StrictObject({
|
|
214
|
+
fromNodeId: NonEmptyStringSchema,
|
|
215
|
+
toNodeId: NonEmptyStringSchema,
|
|
216
|
+
totalCount: CountSchema,
|
|
217
|
+
sampledCount: CountSchema
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const EvidenceDirectionViolationSchema = StrictObject({
|
|
221
|
+
constraintId: NonEmptyStringSchema,
|
|
222
|
+
fromPath: RepoPathSchema,
|
|
223
|
+
fromLine: NullableType("integer", { minimum: 1 }),
|
|
224
|
+
toPath: RepoPathSchema,
|
|
225
|
+
specifier: NonEmptyStringSchema,
|
|
226
|
+
fromNodeId: NonEmptyStringSchema,
|
|
227
|
+
toNodeId: NonEmptyStringSchema
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const EvidencePathEntrySchema = StrictObject({
|
|
231
|
+
path: RepoPathSchema,
|
|
232
|
+
candidateOwnerNodeIds: UniqueStringArray(NonEmptyStringSchema),
|
|
233
|
+
candidateOwnerCount: CountSchema
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const EvidenceUnresolvedImportSchema = StrictObject({
|
|
237
|
+
fromPath: RepoPathSchema,
|
|
238
|
+
fromLine: NullableType("integer", { minimum: 1 }),
|
|
239
|
+
specifier: NonEmptyStringSchema
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
const EvidenceLowCohesionClusterSchema = StrictObject({
|
|
243
|
+
symbols: UniqueStringArray(NonEmptyStringSchema),
|
|
244
|
+
startLine: Type.Integer({ minimum: 1 }),
|
|
245
|
+
endLine: Type.Integer({ minimum: 1 }),
|
|
246
|
+
intraClusterEdges: CountSchema,
|
|
247
|
+
crossClusterEdges: CountSchema
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const EvidenceLowCohesionFileSchema = StrictObject({
|
|
251
|
+
path: RepoPathSchema,
|
|
252
|
+
lineCount: CountSchema,
|
|
253
|
+
topLevelSymbolCount: CountSchema,
|
|
254
|
+
clusterCount: CountSchema,
|
|
255
|
+
clusters: Type.Array(Ref<RefactorEvidenceLowCohesionClusterV1>("#/$defs/evidenceLowCohesionCluster"))
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const EvidenceUnstableTargetSchema = StrictObject({
|
|
259
|
+
targetNodeId: NonEmptyStringSchema,
|
|
260
|
+
targetInstability: Type.Number({ minimum: 0, maximum: 1 }),
|
|
261
|
+
delta: Type.Number({ minimum: -1, maximum: 1 }),
|
|
262
|
+
edgeCount: Type.Integer({ minimum: 1 })
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const EvidenceCoChangePairSchema = StrictObject({
|
|
266
|
+
pathA: RepoPathSchema,
|
|
267
|
+
pathB: RepoPathSchema,
|
|
268
|
+
coChangeCount: Type.Integer({ minimum: 1 }),
|
|
269
|
+
jaccard: Type.Number({ minimum: 0, maximum: 1 })
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const ObservationEvidenceSchema = OneOf([
|
|
273
|
+
StrictObject({
|
|
274
|
+
kind: Const("cycle"),
|
|
275
|
+
memberNodeIds: UniqueStringArray(NonEmptyStringSchema),
|
|
276
|
+
directions: Type.Array(Ref<RefactorEvidencePairDirectionV1>("#/$defs/evidencePairDirection")),
|
|
277
|
+
edges: Type.Array(Ref<RefactorEvidenceImportEdgeV1>("#/$defs/evidenceImportEdge")),
|
|
278
|
+
totalCount: CountSchema,
|
|
279
|
+
truncated: Type.Boolean()
|
|
280
|
+
}),
|
|
281
|
+
StrictObject({
|
|
282
|
+
kind: Const("residual-cycle"),
|
|
283
|
+
memberNodeIds: UniqueStringArray(NonEmptyStringSchema),
|
|
284
|
+
edges: Type.Array(Ref<RefactorEvidenceImportEdgeV1>("#/$defs/evidenceImportEdge")),
|
|
285
|
+
totalCount: CountSchema,
|
|
286
|
+
truncated: Type.Boolean()
|
|
287
|
+
}),
|
|
288
|
+
StrictObject({
|
|
289
|
+
kind: Const("direction-violation"),
|
|
290
|
+
constraintIds: UniqueStringArray(NonEmptyStringSchema),
|
|
291
|
+
constraintCount: CountSchema,
|
|
292
|
+
violations: Type.Array(Ref<RefactorEvidenceDirectionViolationV1>("#/$defs/evidenceDirectionViolation")),
|
|
293
|
+
totalCount: CountSchema,
|
|
294
|
+
truncated: Type.Boolean()
|
|
295
|
+
}),
|
|
296
|
+
StrictObject({
|
|
297
|
+
kind: StringEnum(["ownership-ambiguous", "undeclared-footprint", "unowned-paths"] as const),
|
|
298
|
+
paths: Type.Array(Ref<RefactorEvidencePathV1>("#/$defs/evidencePathEntry")),
|
|
299
|
+
totalCount: CountSchema,
|
|
300
|
+
truncated: Type.Boolean()
|
|
301
|
+
}),
|
|
302
|
+
StrictObject({
|
|
303
|
+
kind: Const("evidence-gap"),
|
|
304
|
+
coverage: StringEnum(["complete", "partial", "unknown"] as const),
|
|
305
|
+
reasonCodes: UniqueStringArray(BoundedStringSchema),
|
|
306
|
+
unresolvedImports: Type.Array(Ref<RefactorEvidenceUnresolvedImportV1>("#/$defs/evidenceUnresolvedImport")),
|
|
307
|
+
totalCount: CountSchema,
|
|
308
|
+
truncated: Type.Boolean()
|
|
309
|
+
}),
|
|
310
|
+
StrictObject({
|
|
311
|
+
kind: Const("low-cohesion-god-file"),
|
|
312
|
+
files: Type.Array(Ref<RefactorEvidenceLowCohesionFileV1>("#/$defs/evidenceLowCohesionFile")),
|
|
313
|
+
totalCount: CountSchema,
|
|
314
|
+
truncated: Type.Boolean()
|
|
315
|
+
}),
|
|
316
|
+
StrictObject({
|
|
317
|
+
kind: Const("entrypoint-bypass"),
|
|
318
|
+
declaredEntrypointPaths: UniqueStringArray(RepoPathSchema),
|
|
319
|
+
edges: Type.Array(Ref<RefactorEvidenceImportEdgeV1>("#/$defs/evidenceImportEdge")),
|
|
320
|
+
totalCount: CountSchema,
|
|
321
|
+
truncated: Type.Boolean()
|
|
322
|
+
}),
|
|
323
|
+
StrictObject({
|
|
324
|
+
kind: Const("unstable-dependency"),
|
|
325
|
+
sourceFanIn: CountSchema,
|
|
326
|
+
sourceInstability: Type.Number({ minimum: 0, maximum: 1 }),
|
|
327
|
+
targets: Type.Array(Ref<RefactorEvidenceUnstableTargetV1>("#/$defs/evidenceUnstableTarget")),
|
|
328
|
+
totalCount: CountSchema,
|
|
329
|
+
truncated: Type.Boolean()
|
|
330
|
+
}),
|
|
331
|
+
StrictObject({
|
|
332
|
+
kind: Const("co-change-coupling"),
|
|
333
|
+
memberNodeIds: UniqueStringArray(NonEmptyStringSchema),
|
|
334
|
+
coverageStatus: StringEnum(["complete", "shallow", "insufficient-history", "unavailable"] as const),
|
|
335
|
+
windowLimit: Type.Integer({ minimum: 1 }),
|
|
336
|
+
observedCommitCount: CountSchema,
|
|
337
|
+
pairs: Type.Array(Ref<RefactorEvidenceCoChangePairV1>("#/$defs/evidenceCoChangePair")),
|
|
338
|
+
totalCount: CountSchema,
|
|
339
|
+
truncated: Type.Boolean()
|
|
340
|
+
})
|
|
341
|
+
]);
|
|
342
|
+
|
|
191
343
|
export const RefactorScanFindingV2Schema = StrictObject({
|
|
192
344
|
recommendationId: Type.String({ pattern: "^recommendation\\.[a-f0-9]{16}$" }),
|
|
193
345
|
fingerprint: Sha256DigestSchema,
|
|
@@ -209,7 +361,8 @@ export const RefactorScanFindingV2Schema = StrictObject({
|
|
|
209
361
|
instabilityTarget: Type.Optional(Type.Number({ minimum: 0, maximum: 1 })),
|
|
210
362
|
testCallerCoverage: Type.Optional(NullableType("number", { minimum: 0, maximum: 1 })),
|
|
211
363
|
lcomScore: Type.Optional(Type.Number({ minimum: 0 })),
|
|
212
|
-
splitClusterCount: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
364
|
+
splitClusterCount: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
365
|
+
observation: Type.Optional(Ref<RefactorObservationEvidenceV1>("#/$defs/observationEvidence"))
|
|
213
366
|
})
|
|
214
367
|
});
|
|
215
368
|
export type RefactorScanFindingV2 = Static<typeof RefactorScanFindingV2Schema>;
|
|
@@ -244,7 +397,19 @@ export const RefactorScanV2Schema = SchemaDocument({
|
|
|
244
397
|
$id: "https://archcontext.dev/schemas/runtime/refactor-scan-v2.schema.json",
|
|
245
398
|
title: "RefactorScanV2",
|
|
246
399
|
description: "v2 Stage 5 deterministic refactor radar output for `archctx scan --json` (#643).",
|
|
247
|
-
schema: RefactorScanV2BodySchema
|
|
400
|
+
schema: RefactorScanV2BodySchema,
|
|
401
|
+
$defs: {
|
|
402
|
+
evidenceImportEdge: EvidenceImportEdgeSchema,
|
|
403
|
+
evidencePairDirection: EvidencePairDirectionSchema,
|
|
404
|
+
evidenceDirectionViolation: EvidenceDirectionViolationSchema,
|
|
405
|
+
evidencePathEntry: EvidencePathEntrySchema,
|
|
406
|
+
evidenceUnresolvedImport: EvidenceUnresolvedImportSchema,
|
|
407
|
+
evidenceLowCohesionCluster: EvidenceLowCohesionClusterSchema,
|
|
408
|
+
evidenceLowCohesionFile: EvidenceLowCohesionFileSchema,
|
|
409
|
+
evidenceUnstableTarget: EvidenceUnstableTargetSchema,
|
|
410
|
+
evidenceCoChangePair: EvidenceCoChangePairSchema,
|
|
411
|
+
observationEvidence: ObservationEvidenceSchema
|
|
412
|
+
}
|
|
248
413
|
});
|
|
249
414
|
export type RefactorScanV2 = Static<typeof RefactorScanV2Schema>;
|
|
250
415
|
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
type RefactorProposalAuthorSource
|
|
15
15
|
} from "./refactor-constants";
|
|
16
16
|
import type { ArchitectureTargetDeltaV1, RefactorTargetOutcomeV1 } from "./refactor-types";
|
|
17
|
-
import { isRepoRelativePosixPath, type Json } from "./schema";
|
|
17
|
+
import { isCanonicalRepoRelativePosixPath, isRepoRelativePosixPath, type Json } from "./schema";
|
|
18
18
|
|
|
19
19
|
export const DIGEST_PREFIX_LENGTH = "sha256:".length;
|
|
20
20
|
export const SHA256_DIGEST_PATTERN = /^sha256:[a-f0-9]{64}$/;
|
|
@@ -166,6 +166,10 @@ export function repoPathIssues(label: string, path: string): string[] {
|
|
|
166
166
|
return typeof path === "string" && isRepoRelativePosixPath(path) ? [] : [`${label} must be a repo-relative POSIX path`];
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
export function canonicalRepoPathIssues(label: string, path: string): string[] {
|
|
170
|
+
return typeof path === "string" && isCanonicalRepoRelativePosixPath(path) ? [] : [`${label} must be a canonical repo-relative POSIX path`];
|
|
171
|
+
}
|
|
172
|
+
|
|
169
173
|
export function lineIssues(label: string, line: number | null): string[] {
|
|
170
174
|
return line === null || (Number.isInteger(line) && line >= 1) ? [] : [`${label} must be null or a positive integer`];
|
|
171
175
|
}
|
package/src/schema-kit.ts
CHANGED
|
@@ -152,8 +152,12 @@ export const RepoPathSchema: TUnsafe<string> = TypedUnsafe<string>({
|
|
|
152
152
|
not: {
|
|
153
153
|
anyOf: [
|
|
154
154
|
{ pattern: "^/" },
|
|
155
|
+
{ pattern: "/$" },
|
|
156
|
+
{ pattern: "//" },
|
|
155
157
|
{ pattern: "\\\\" },
|
|
156
|
-
{ pattern: "
|
|
158
|
+
{ pattern: "^[A-Za-z]:" },
|
|
159
|
+
{ pattern: "[\\u0000-\\u001f\\u007f]" },
|
|
160
|
+
{ pattern: "(^|/)\\.\\.?(/|$)" }
|
|
157
161
|
]
|
|
158
162
|
}
|
|
159
163
|
});
|
package/src/schema.ts
CHANGED
|
@@ -128,10 +128,25 @@ export function stableId(...parts: string[]): string {
|
|
|
128
128
|
.join(".");
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
const WINDOWS_DRIVE_PREFIX = /^[A-Za-z]:/;
|
|
132
|
+
const PATH_CONTROL_CHARS = /[\u0000-\u001f\u007f]/;
|
|
133
|
+
|
|
131
134
|
export function isRepoRelativePosixPath(path: string): boolean {
|
|
132
135
|
return path.length > 0 && !path.startsWith("/") && !path.includes("\\") && !path.split("/").includes("..");
|
|
133
136
|
}
|
|
134
137
|
|
|
138
|
+
export function isCanonicalRepoRelativePosixPath(path: string): boolean {
|
|
139
|
+
if (
|
|
140
|
+
!isRepoRelativePosixPath(path)
|
|
141
|
+
|| path.endsWith("/")
|
|
142
|
+
|| WINDOWS_DRIVE_PREFIX.test(path)
|
|
143
|
+
|| PATH_CONTROL_CHARS.test(path)
|
|
144
|
+
) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return path.split("/").every((segment) => segment.length > 0 && segment !== ".");
|
|
148
|
+
}
|
|
149
|
+
|
|
135
150
|
export function stableYaml(value: Json, indent = 0): string {
|
|
136
151
|
const pad = " ".repeat(indent);
|
|
137
152
|
if (value === null) return "null\n";
|