carrick 0.3.100 → 0.3.102
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/dist/scan.d.ts +11 -0
- package/dist/scan.js +15 -0
- package/dist/scan.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/index.js +64 -10
- package/sidecar/dist/src/library-claims.d.ts +105 -0
- package/sidecar/dist/src/library-claims.js +2840 -0
- package/sidecar/dist/src/types.d.ts +224 -2
- package/sidecar/dist/src/validators.d.ts +1608 -18
- package/sidecar/dist/src/validators.js +116 -0
- package/sidecar/dist/src/client-semantics.d.ts +0 -36
- package/sidecar/dist/src/client-semantics.js +0 -1008
|
@@ -349,6 +349,120 @@ export const VerifyClientSemanticsRequestSchema = BaseRequestSchema.extend({
|
|
|
349
349
|
checks: z.array(SemanticsCheckSchema),
|
|
350
350
|
budget_ms: z.number().int().nonnegative().optional(),
|
|
351
351
|
});
|
|
352
|
+
/** Where one part of a library call sits (carrick#1616). */
|
|
353
|
+
const ClaimSlotSchema = z
|
|
354
|
+
.object({
|
|
355
|
+
arg: z.number().int().nonnegative(),
|
|
356
|
+
key: z.string().min(1).optional(),
|
|
357
|
+
})
|
|
358
|
+
.strict();
|
|
359
|
+
const BoundNameSchema = z.object({ bound: z.enum(['maker', 'scope']) }).strict();
|
|
360
|
+
const ClaimOnSchema = z.enum(['export', 'instance', 'both']);
|
|
361
|
+
const MemberPathSchema = z.array(z.string().min(1));
|
|
362
|
+
const KeyLabelsSchema = z.record(z.string().min(1), z.enum(['name', 'not_name']));
|
|
363
|
+
/** Carried for the scanner, never read. */
|
|
364
|
+
const NameScopeSchema = z
|
|
365
|
+
.object({ scope: z.enum(['global', 'service']), namespace: z.string().min(1).nullable() })
|
|
366
|
+
.strict();
|
|
367
|
+
/**
|
|
368
|
+
* One claim element in the shape the store answers, tagged by `kind`
|
|
369
|
+
* (contract on carrick#1564, sections 2 and 3, as amendment 2 changes them).
|
|
370
|
+
* A maker's parts are slots; `on` and `of` are checked against each other by
|
|
371
|
+
* the verifier (`claim_invalid`), not here.
|
|
372
|
+
*/
|
|
373
|
+
const LibraryClaimSchema = z.discriminatedUnion('kind', [
|
|
374
|
+
z
|
|
375
|
+
.object({
|
|
376
|
+
kind: z.literal('make'),
|
|
377
|
+
form: z.enum(['call', 'new']),
|
|
378
|
+
member: z.string().min(1).nullable(),
|
|
379
|
+
base: ClaimSlotSchema.optional(),
|
|
380
|
+
prefix: ClaimSlotSchema.optional(),
|
|
381
|
+
name: ClaimSlotSchema.optional(),
|
|
382
|
+
handler: ClaimSlotSchema.optional(),
|
|
383
|
+
key_labels: KeyLabelsSchema.optional(),
|
|
384
|
+
name_scope: NameScopeSchema.optional(),
|
|
385
|
+
picker: z.string().optional(),
|
|
386
|
+
})
|
|
387
|
+
.strict(),
|
|
388
|
+
z
|
|
389
|
+
.object({
|
|
390
|
+
kind: z.literal('scope'),
|
|
391
|
+
member: z.string().min(1),
|
|
392
|
+
name: ClaimSlotSchema,
|
|
393
|
+
path: MemberPathSchema.optional(),
|
|
394
|
+
on: ClaimOnSchema.optional(),
|
|
395
|
+
of: z.string().min(1).optional(),
|
|
396
|
+
key_labels: KeyLabelsSchema.optional(),
|
|
397
|
+
name_scope: NameScopeSchema.optional(),
|
|
398
|
+
picker: z.string().optional(),
|
|
399
|
+
})
|
|
400
|
+
.strict(),
|
|
401
|
+
z
|
|
402
|
+
.object({
|
|
403
|
+
kind: z.literal('op'),
|
|
404
|
+
op: z.enum(['request', 'send', 'receive', 'execute']),
|
|
405
|
+
member: z.string().min(1).nullable(),
|
|
406
|
+
path: MemberPathSchema.optional(),
|
|
407
|
+
on: ClaimOnSchema.optional(),
|
|
408
|
+
of: z.string().min(1).optional(),
|
|
409
|
+
name: z.union([BoundNameSchema, ClaimSlotSchema]).optional(),
|
|
410
|
+
payload: ClaimSlotSchema.optional(),
|
|
411
|
+
handler: ClaimSlotSchema.optional(),
|
|
412
|
+
ack: ClaimSlotSchema.optional(),
|
|
413
|
+
key_labels: KeyLabelsSchema.optional(),
|
|
414
|
+
name_scope: NameScopeSchema.optional(),
|
|
415
|
+
picker: z.string().optional(),
|
|
416
|
+
options: ClaimSlotSchema.optional(),
|
|
417
|
+
method: z.string().min(1).optional(),
|
|
418
|
+
method_key: ClaimSlotSchema.optional(),
|
|
419
|
+
})
|
|
420
|
+
.strict(),
|
|
421
|
+
z
|
|
422
|
+
.object({
|
|
423
|
+
kind: z.literal('reserved'),
|
|
424
|
+
member: z.string().min(1),
|
|
425
|
+
name: z.string().min(1),
|
|
426
|
+
path: MemberPathSchema.optional(),
|
|
427
|
+
on: ClaimOnSchema.optional(),
|
|
428
|
+
of: z.string().min(1).optional(),
|
|
429
|
+
picker: z.string().optional(),
|
|
430
|
+
})
|
|
431
|
+
.strict(),
|
|
432
|
+
]);
|
|
433
|
+
const LibraryCheckSchema = z
|
|
434
|
+
.object({
|
|
435
|
+
claim_id: z.string().min(1),
|
|
436
|
+
package: z.string().min(1),
|
|
437
|
+
export: z.string().min(1),
|
|
438
|
+
role: z.enum([
|
|
439
|
+
'http_client',
|
|
440
|
+
'graphql_client',
|
|
441
|
+
'broker',
|
|
442
|
+
'in_process_bus',
|
|
443
|
+
'socket',
|
|
444
|
+
'server_framework',
|
|
445
|
+
'none',
|
|
446
|
+
]),
|
|
447
|
+
// Any other receiver answers `unchecked` (`receiver_invalid`) on its own.
|
|
448
|
+
receiver: z.string().min(1),
|
|
449
|
+
claim: LibraryClaimSchema,
|
|
450
|
+
})
|
|
451
|
+
.strict();
|
|
452
|
+
export const VerifyLibraryClaimsRequestSchema = BaseRequestSchema.extend({
|
|
453
|
+
action: z.literal('verify_library_claims'),
|
|
454
|
+
from_dir: z.string().min(1),
|
|
455
|
+
checks: z.array(LibraryCheckSchema),
|
|
456
|
+
// The contract's sample sends `null` for "no budget of the request's own".
|
|
457
|
+
budget_ms: z.number().int().nonnegative().nullable().optional(),
|
|
458
|
+
});
|
|
459
|
+
export const ListLibrarySurfaceRequestSchema = BaseRequestSchema.extend({
|
|
460
|
+
action: z.literal('list_library_surface'),
|
|
461
|
+
from_dir: z.string().min(1),
|
|
462
|
+
packages: z.array(z.string().min(1)),
|
|
463
|
+
max_entries: z.number().int().positive().optional(),
|
|
464
|
+
exports: z.record(z.string(), z.array(z.string().min(1))).optional(),
|
|
465
|
+
});
|
|
352
466
|
// ============================================================================
|
|
353
467
|
// Discriminated Union Schema
|
|
354
468
|
// ============================================================================
|
|
@@ -367,6 +481,8 @@ export const SidecarRequestSchema = z.discriminatedUnion('action', [
|
|
|
367
481
|
ResolveDefinitionsRequestSchema,
|
|
368
482
|
RetypeCheckRequestSchema,
|
|
369
483
|
VerifyClientSemanticsRequestSchema,
|
|
484
|
+
VerifyLibraryClaimsRequestSchema,
|
|
485
|
+
ListLibrarySurfaceRequestSchema,
|
|
370
486
|
HealthRequestSchema,
|
|
371
487
|
ShutdownRequestSchema,
|
|
372
488
|
]);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `verify_client_semantics` (carrick#1564): check what a model said about an
|
|
3
|
-
* HTTP client library against the package's own type declarations.
|
|
4
|
-
*
|
|
5
|
-
* A claim names a member of a package export (or of an instance one of its
|
|
6
|
-
* factories returns) and says how that member is called: which option key
|
|
7
|
-
* carries the base URL, which HTTP method a verb sends, where the path, method
|
|
8
|
-
* and body sit. The scanner reads call sites through a claim only when this
|
|
9
|
-
* check verified it, and a verified claim becomes a fact that can fail a pull
|
|
10
|
-
* request check. So a claim is `verified` only when the declarations say so
|
|
11
|
-
* positively. `failed` means the declarations resolved and contradict the
|
|
12
|
-
* claim; `unchecked` means they could not be read, or say nothing at the place
|
|
13
|
-
* the claim needs (`any`, `unknown`, `{}`, an unconstrained type parameter).
|
|
14
|
-
* The scanner drops both.
|
|
15
|
-
*
|
|
16
|
-
* The export's type is read the way the service's own code would read it: a
|
|
17
|
-
* probe file in `from_dir` imports it, inside the service's program, under the
|
|
18
|
-
* service's compiler options. The declarations must be the installed
|
|
19
|
-
* package's: a `paths` alias or a `declare module` block the service writes
|
|
20
|
-
* for itself is not evidence about the library.
|
|
21
|
-
*/
|
|
22
|
-
import { type Project } from 'ts-morph';
|
|
23
|
-
import type { SemanticsCheck, SemanticsModule, SemanticsResult } from './types.js';
|
|
24
|
-
export interface VerifyResult {
|
|
25
|
-
semantics: SemanticsResult[];
|
|
26
|
-
modules: SemanticsModule[];
|
|
27
|
-
}
|
|
28
|
-
export declare class ClientSemanticsVerifier {
|
|
29
|
-
private readonly project;
|
|
30
|
-
constructor(project: Project);
|
|
31
|
-
/**
|
|
32
|
-
* Judge every check, in request order, spending at most `budgetMs`. Checks
|
|
33
|
-
* the budget does not reach come back `unchecked` with reason `budget`.
|
|
34
|
-
*/
|
|
35
|
-
run(fromDir: string, checks: SemanticsCheck[], budgetMs: number): VerifyResult;
|
|
36
|
-
}
|