@cat-factory/contracts 0.163.0 → 0.165.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/dist/execution.d.ts +48 -0
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +11 -0
- package/dist/execution.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/routes/agent-runs.d.ts +30 -0
- package/dist/routes/agent-runs.d.ts.map +1 -1
- package/dist/routes/execution.d.ts +120 -0
- package/dist/routes/execution.d.ts.map +1 -1
- package/dist/routes/human-review.d.ts +15 -0
- package/dist/routes/human-review.d.ts.map +1 -1
- package/dist/routes/human-test.d.ts +75 -0
- package/dist/routes/human-test.d.ts.map +1 -1
- package/dist/routes/index.d.ts +2 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +2 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/runners.d.ts +10 -0
- package/dist/routes/runners.d.ts.map +1 -1
- package/dist/routes/validation-checks.d.ts +175 -0
- package/dist/routes/validation-checks.d.ts.map +1 -0
- package/dist/routes/validation-checks.js +40 -0
- package/dist/routes/validation-checks.js.map +1 -0
- package/dist/routes/vcs.d.ts +47 -0
- package/dist/routes/vcs.d.ts.map +1 -0
- package/dist/routes/vcs.js +34 -0
- package/dist/routes/vcs.js.map +1 -0
- package/dist/routes/visual-confirm.d.ts +45 -0
- package/dist/routes/visual-confirm.d.ts.map +1 -1
- package/dist/routes/workspaces.d.ts +30 -0
- package/dist/routes/workspaces.d.ts.map +1 -1
- package/dist/runners.d.ts +90 -0
- package/dist/runners.d.ts.map +1 -1
- package/dist/runners.js +9 -0
- package/dist/runners.js.map +1 -1
- package/dist/snapshot.d.ts +15 -0
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/validation-checks.d.ts +123 -0
- package/dist/validation-checks.d.ts.map +1 -0
- package/dist/validation-checks.js +118 -0
- package/dist/validation-checks.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
/** One configured validation check: what to run and what to call it. */
|
|
3
|
+
export declare const validationCheckSchema: v.ObjectSchema<{
|
|
4
|
+
readonly label: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 80, undefined>]>;
|
|
5
|
+
readonly command: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export type ValidationCheck = v.InferOutput<typeof validationCheckSchema>;
|
|
8
|
+
/**
|
|
9
|
+
* How many times the harness may re-run the agent against failing checks before giving up.
|
|
10
|
+
* Bounded so a wedged service can't burn a container indefinitely. `1` = run the checks once
|
|
11
|
+
* and fail on the first red (no repair round).
|
|
12
|
+
*
|
|
13
|
+
* MIRRORED in the executor-harness (`executor-harness/src/job.ts`), which clamps the same field
|
|
14
|
+
* off the job body but takes no dependency on this package. Change both together: the harness
|
|
15
|
+
* silently capping a budget this schema accepts would be invisible from either side.
|
|
16
|
+
*/
|
|
17
|
+
export declare const VALIDATION_DEFAULT_MAX_ATTEMPTS = 3;
|
|
18
|
+
export declare const VALIDATION_MAX_ATTEMPTS_CEILING = 10;
|
|
19
|
+
/** At most this many checks per service — the loop runs them in order, so the list stays short. */
|
|
20
|
+
export declare const VALIDATION_MAX_CHECKS = 10;
|
|
21
|
+
/** Set/replace a service's validation checks. An empty list clears the config. */
|
|
22
|
+
export declare const upsertServiceValidationConfigSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
23
|
+
readonly checks: v.ArraySchema<v.ObjectSchema<{
|
|
24
|
+
readonly label: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 80, undefined>]>;
|
|
25
|
+
readonly command: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
26
|
+
}, undefined>, undefined>;
|
|
27
|
+
/** Repair-round budget; omitted ⇒ {@link VALIDATION_DEFAULT_MAX_ATTEMPTS}. */
|
|
28
|
+
readonly maxAttempts: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 10, undefined>]>, undefined>;
|
|
29
|
+
}, undefined>, v.CheckAction<{
|
|
30
|
+
checks: {
|
|
31
|
+
label: string;
|
|
32
|
+
command: string;
|
|
33
|
+
}[];
|
|
34
|
+
maxAttempts?: number | undefined;
|
|
35
|
+
}, "validation check labels must be unique within a service">, v.CheckAction<{
|
|
36
|
+
checks: {
|
|
37
|
+
label: string;
|
|
38
|
+
command: string;
|
|
39
|
+
}[];
|
|
40
|
+
maxAttempts?: number | undefined;
|
|
41
|
+
}, "at most 10 validation checks per service">]>;
|
|
42
|
+
export type UpsertServiceValidationConfigInput = v.InferOutput<typeof upsertServiceValidationConfigSchema>;
|
|
43
|
+
/** What `GET .../validation-checks` returns for one service frame. */
|
|
44
|
+
export declare const serviceValidationConfigSchema: v.ObjectSchema<{
|
|
45
|
+
/** The service-frame block these checks belong to. */
|
|
46
|
+
readonly blockId: v.StringSchema<undefined>;
|
|
47
|
+
readonly checks: v.ArraySchema<v.ObjectSchema<{
|
|
48
|
+
readonly label: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 80, undefined>]>;
|
|
49
|
+
readonly command: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
50
|
+
}, undefined>, undefined>;
|
|
51
|
+
readonly maxAttempts: v.NumberSchema<undefined>;
|
|
52
|
+
}, undefined>;
|
|
53
|
+
export type ServiceValidationConfig = v.InferOutput<typeof serviceValidationConfigSchema>;
|
|
54
|
+
/**
|
|
55
|
+
* The RESOLVED checks a dispatch carries: the frame-chain walk's result, folded onto the
|
|
56
|
+
* agent run context and forwarded on the coding job body. `null`/absent ⇒ the service
|
|
57
|
+
* configured none, so the harness runs its existing (unvalidated) path unchanged.
|
|
58
|
+
*/
|
|
59
|
+
export declare const resolvedValidationChecksSchema: v.ObjectSchema<{
|
|
60
|
+
readonly checks: v.ArraySchema<v.ObjectSchema<{
|
|
61
|
+
readonly label: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 80, undefined>]>;
|
|
62
|
+
readonly command: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
63
|
+
}, undefined>, undefined>;
|
|
64
|
+
readonly maxAttempts: v.NumberSchema<undefined>;
|
|
65
|
+
}, undefined>;
|
|
66
|
+
export type ResolvedValidationChecks = v.InferOutput<typeof resolvedValidationChecksSchema>;
|
|
67
|
+
/** One command's outcome in a validation attempt. */
|
|
68
|
+
export declare const validationCheckOutcomeSchema: v.ObjectSchema<{
|
|
69
|
+
readonly label: v.SchemaWithFallback<v.StringSchema<undefined>, "check">;
|
|
70
|
+
readonly command: v.SchemaWithFallback<v.StringSchema<undefined>, "">;
|
|
71
|
+
/** Exit code (0 = pass); 124 on watchdog timeout, 127 on spawn failure, 130 on abort. */
|
|
72
|
+
readonly exitCode: v.SchemaWithFallback<v.NumberSchema<undefined>, 1>;
|
|
73
|
+
readonly passed: v.SchemaWithFallback<v.BooleanSchema<undefined>, false>;
|
|
74
|
+
/** Bounded, secret-scrubbed tail of the command's combined stdout+stderr. */
|
|
75
|
+
readonly outputTail: v.SchemaWithFallback<v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
76
|
+
/** Wall-clock of the command, ms. */
|
|
77
|
+
readonly durationMs: v.SchemaWithFallback<v.OptionalSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
78
|
+
/** Set when the command was killed by the per-command watchdog. */
|
|
79
|
+
readonly timedOut: v.SchemaWithFallback<v.OptionalSchema<v.BooleanSchema<undefined>, undefined>, undefined>;
|
|
80
|
+
}, undefined>;
|
|
81
|
+
export type ValidationCheckOutcome = v.InferOutput<typeof validationCheckOutcomeSchema>;
|
|
82
|
+
/**
|
|
83
|
+
* The harness-computed report of a run's pre-PR validation: whether the LAST attempt's
|
|
84
|
+
* commands all passed, how many attempts were spent, and each command's outcome in that
|
|
85
|
+
* attempt. Produced by the executor-harness (it runs the commands and reads the exit codes)
|
|
86
|
+
* and carried back on the runner view/result → {@link AgentRunResult.validationReport}; the
|
|
87
|
+
* engine records it on the step. Lenient (`v.fallback`) so a malformed field degrades rather
|
|
88
|
+
* than discarding the whole report.
|
|
89
|
+
*/
|
|
90
|
+
export declare const validationReportSchema: v.ObjectSchema<{
|
|
91
|
+
/** Whether every command in the latest attempt exited 0 (⇒ the PR was allowed to open). */
|
|
92
|
+
readonly passed: v.SchemaWithFallback<v.BooleanSchema<undefined>, false>;
|
|
93
|
+
/** How many agent+check rounds ran (1 = the checks passed/failed on the first pass). */
|
|
94
|
+
readonly attempts: v.SchemaWithFallback<v.NumberSchema<undefined>, 1>;
|
|
95
|
+
/** The budget the loop ran under, so the UI can show "3 / 3 attempts". */
|
|
96
|
+
readonly maxAttempts: v.SchemaWithFallback<v.NumberSchema<undefined>, 3>;
|
|
97
|
+
/** Per-command outcomes of the LATEST attempt, in configured order. */
|
|
98
|
+
readonly outcomes: v.SchemaWithFallback<v.ArraySchema<v.ObjectSchema<{
|
|
99
|
+
readonly label: v.SchemaWithFallback<v.StringSchema<undefined>, "check">;
|
|
100
|
+
readonly command: v.SchemaWithFallback<v.StringSchema<undefined>, "">;
|
|
101
|
+
/** Exit code (0 = pass); 124 on watchdog timeout, 127 on spawn failure, 130 on abort. */
|
|
102
|
+
readonly exitCode: v.SchemaWithFallback<v.NumberSchema<undefined>, 1>;
|
|
103
|
+
readonly passed: v.SchemaWithFallback<v.BooleanSchema<undefined>, false>;
|
|
104
|
+
/** Bounded, secret-scrubbed tail of the command's combined stdout+stderr. */
|
|
105
|
+
readonly outputTail: v.SchemaWithFallback<v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
106
|
+
/** Wall-clock of the command, ms. */
|
|
107
|
+
readonly durationMs: v.SchemaWithFallback<v.OptionalSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
108
|
+
/** Set when the command was killed by the per-command watchdog. */
|
|
109
|
+
readonly timedOut: v.SchemaWithFallback<v.OptionalSchema<v.BooleanSchema<undefined>, undefined>, undefined>;
|
|
110
|
+
}, undefined>, undefined>, readonly []>;
|
|
111
|
+
/** Epoch ms the latest attempt finished. */
|
|
112
|
+
readonly at: v.SchemaWithFallback<v.OptionalSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
113
|
+
}, undefined>;
|
|
114
|
+
export type ValidationReport = v.InferOutput<typeof validationReportSchema>;
|
|
115
|
+
/** Parse-or-throw a harness validation report (lenient — malformed fields degrade to defaults). */
|
|
116
|
+
export declare function parseValidationReport(value: unknown): ValidationReport;
|
|
117
|
+
/**
|
|
118
|
+
* The one-line human summary of a failed validation report, used as the step's failure detail
|
|
119
|
+
* when the attempt budget is spent. Names the failing checks + their exit codes so the run
|
|
120
|
+
* detail is actionable without opening the report.
|
|
121
|
+
*/
|
|
122
|
+
export declare function summarizeValidationFailure(report: ValidationReport): string;
|
|
123
|
+
//# sourceMappingURL=validation-checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-checks.d.ts","sourceRoot":"","sources":["../src/validation-checks.ts"],"names":[],"mappings":"AAAA,OAAO,K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BAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE3E,mGAAmG;AACnG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAQ3E"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Pre-PR validation checks.
|
|
4
|
+
//
|
|
5
|
+
// A service declares shell commands (install / lint / test / build) that the
|
|
6
|
+
// executor-harness runs against the CHECKOUT after the coding agent settles and
|
|
7
|
+
// BEFORE the PR is opened. A failing command's captured output is handed back to
|
|
8
|
+
// the agent as its next instruction, and the loop repeats until the commands pass
|
|
9
|
+
// or the attempt budget is spent — a programmatic exit condition, computed by the
|
|
10
|
+
// harness, never self-reported by the model. Only a passing checkout opens a PR;
|
|
11
|
+
// an exhausted budget FAILS the step with the last captured output.
|
|
12
|
+
//
|
|
13
|
+
// Config is per SERVICE FRAME (resolved up the frame chain), mirroring the
|
|
14
|
+
// `test_secrets` / `release_health_configs` shape, and travels to the container IN
|
|
15
|
+
// THE JOB BODY (containers have no DB access). See
|
|
16
|
+
// docs/initiatives/pre-pr-validation.md.
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/** A short operator-facing label for a check (`lint`, `unit tests`, `build`). */
|
|
19
|
+
const validationCheckLabelSchema = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(80));
|
|
20
|
+
/**
|
|
21
|
+
* The shell command a check runs, executed as `sh -c <command>` in the checkout (the
|
|
22
|
+
* service directory for a monorepo service). Runs INSIDE the sandboxed run container —
|
|
23
|
+
* the same trust boundary as the coding agent — so there is no host/backend execution.
|
|
24
|
+
*/
|
|
25
|
+
const validationCommandSchema = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(2000));
|
|
26
|
+
/** One configured validation check: what to run and what to call it. */
|
|
27
|
+
export const validationCheckSchema = v.object({
|
|
28
|
+
label: validationCheckLabelSchema,
|
|
29
|
+
command: validationCommandSchema,
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* How many times the harness may re-run the agent against failing checks before giving up.
|
|
33
|
+
* Bounded so a wedged service can't burn a container indefinitely. `1` = run the checks once
|
|
34
|
+
* and fail on the first red (no repair round).
|
|
35
|
+
*
|
|
36
|
+
* MIRRORED in the executor-harness (`executor-harness/src/job.ts`), which clamps the same field
|
|
37
|
+
* off the job body but takes no dependency on this package. Change both together: the harness
|
|
38
|
+
* silently capping a budget this schema accepts would be invisible from either side.
|
|
39
|
+
*/
|
|
40
|
+
export const VALIDATION_DEFAULT_MAX_ATTEMPTS = 3;
|
|
41
|
+
export const VALIDATION_MAX_ATTEMPTS_CEILING = 10;
|
|
42
|
+
const validationMaxAttemptsSchema = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(VALIDATION_MAX_ATTEMPTS_CEILING));
|
|
43
|
+
/** At most this many checks per service — the loop runs them in order, so the list stays short. */
|
|
44
|
+
export const VALIDATION_MAX_CHECKS = 10;
|
|
45
|
+
/** Set/replace a service's validation checks. An empty list clears the config. */
|
|
46
|
+
export const upsertServiceValidationConfigSchema = v.pipe(v.object({
|
|
47
|
+
checks: v.array(validationCheckSchema),
|
|
48
|
+
/** Repair-round budget; omitted ⇒ {@link VALIDATION_DEFAULT_MAX_ATTEMPTS}. */
|
|
49
|
+
maxAttempts: v.optional(validationMaxAttemptsSchema),
|
|
50
|
+
}), v.check((o) => new Set(o.checks.map((c) => c.label)).size === o.checks.length, 'validation check labels must be unique within a service'), v.check((o) => o.checks.length <= VALIDATION_MAX_CHECKS, `at most ${VALIDATION_MAX_CHECKS} validation checks per service`));
|
|
51
|
+
/** What `GET .../validation-checks` returns for one service frame. */
|
|
52
|
+
export const serviceValidationConfigSchema = v.object({
|
|
53
|
+
/** The service-frame block these checks belong to. */
|
|
54
|
+
blockId: v.string(),
|
|
55
|
+
checks: v.array(validationCheckSchema),
|
|
56
|
+
maxAttempts: v.number(),
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* The RESOLVED checks a dispatch carries: the frame-chain walk's result, folded onto the
|
|
60
|
+
* agent run context and forwarded on the coding job body. `null`/absent ⇒ the service
|
|
61
|
+
* configured none, so the harness runs its existing (unvalidated) path unchanged.
|
|
62
|
+
*/
|
|
63
|
+
export const resolvedValidationChecksSchema = v.object({
|
|
64
|
+
checks: v.array(validationCheckSchema),
|
|
65
|
+
maxAttempts: v.number(),
|
|
66
|
+
});
|
|
67
|
+
// ---- The harness-produced report ------------------------------------------
|
|
68
|
+
/** One command's outcome in a validation attempt. */
|
|
69
|
+
export const validationCheckOutcomeSchema = v.object({
|
|
70
|
+
label: v.fallback(v.string(), 'check'),
|
|
71
|
+
command: v.fallback(v.string(), ''),
|
|
72
|
+
/** Exit code (0 = pass); 124 on watchdog timeout, 127 on spawn failure, 130 on abort. */
|
|
73
|
+
exitCode: v.fallback(v.number(), 1),
|
|
74
|
+
passed: v.fallback(v.boolean(), false),
|
|
75
|
+
/** Bounded, secret-scrubbed tail of the command's combined stdout+stderr. */
|
|
76
|
+
outputTail: v.fallback(v.optional(v.string()), undefined),
|
|
77
|
+
/** Wall-clock of the command, ms. */
|
|
78
|
+
durationMs: v.fallback(v.optional(v.number()), undefined),
|
|
79
|
+
/** Set when the command was killed by the per-command watchdog. */
|
|
80
|
+
timedOut: v.fallback(v.optional(v.boolean()), undefined),
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* The harness-computed report of a run's pre-PR validation: whether the LAST attempt's
|
|
84
|
+
* commands all passed, how many attempts were spent, and each command's outcome in that
|
|
85
|
+
* attempt. Produced by the executor-harness (it runs the commands and reads the exit codes)
|
|
86
|
+
* and carried back on the runner view/result → {@link AgentRunResult.validationReport}; the
|
|
87
|
+
* engine records it on the step. Lenient (`v.fallback`) so a malformed field degrades rather
|
|
88
|
+
* than discarding the whole report.
|
|
89
|
+
*/
|
|
90
|
+
export const validationReportSchema = v.object({
|
|
91
|
+
/** Whether every command in the latest attempt exited 0 (⇒ the PR was allowed to open). */
|
|
92
|
+
passed: v.fallback(v.boolean(), false),
|
|
93
|
+
/** How many agent+check rounds ran (1 = the checks passed/failed on the first pass). */
|
|
94
|
+
attempts: v.fallback(v.number(), 1),
|
|
95
|
+
/** The budget the loop ran under, so the UI can show "3 / 3 attempts". */
|
|
96
|
+
maxAttempts: v.fallback(v.number(), VALIDATION_DEFAULT_MAX_ATTEMPTS),
|
|
97
|
+
/** Per-command outcomes of the LATEST attempt, in configured order. */
|
|
98
|
+
outcomes: v.fallback(v.array(validationCheckOutcomeSchema), []),
|
|
99
|
+
/** Epoch ms the latest attempt finished. */
|
|
100
|
+
at: v.fallback(v.optional(v.number()), undefined),
|
|
101
|
+
});
|
|
102
|
+
/** Parse-or-throw a harness validation report (lenient — malformed fields degrade to defaults). */
|
|
103
|
+
export function parseValidationReport(value) {
|
|
104
|
+
return v.parse(validationReportSchema, value);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The one-line human summary of a failed validation report, used as the step's failure detail
|
|
108
|
+
* when the attempt budget is spent. Names the failing checks + their exit codes so the run
|
|
109
|
+
* detail is actionable without opening the report.
|
|
110
|
+
*/
|
|
111
|
+
export function summarizeValidationFailure(report) {
|
|
112
|
+
const failed = report.outcomes.filter((o) => !o.passed);
|
|
113
|
+
const names = failed.map((o) => `${o.label} (exit ${o.exitCode})`).join(', ');
|
|
114
|
+
return (`Pre-PR validation failed after ${report.attempts} of ${report.maxAttempts} attempt(s)` +
|
|
115
|
+
(names ? `: ${names}` : '') +
|
|
116
|
+
'. No pull request was opened.');
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=validation-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-checks.js","sourceRoot":"","sources":["../src/validation-checks.ts"],"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