@milkenjoyer/toolchain 0.13.0 → 0.14.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/README.md +21 -1
- package/dist/formal.mjs +7 -120
- package/dist/guard.d.mts +2 -2
- package/dist/guard.mjs +1 -46
- package/dist/manifest-xQwgnYI1.mjs +53 -0
- package/dist/specs-file-NsQF4V7X.mjs +135 -0
- package/dist/standard.d.mts +2 -0
- package/dist/standard.mjs +398 -0
- package/package.json +4 -1
- package/src/formal/critical.ts +48 -0
- package/src/formal/proofs.ts +2 -45
- package/src/formal/specs-file.ts +119 -0
- package/src/formal/specs.ts +2 -112
- package/src/formal/z3.ts +18 -1
- package/src/standard/agents.ts +44 -0
- package/src/standard/checks.ts +19 -0
- package/src/standard/config.ts +110 -0
- package/src/standard/formal.ts +93 -0
- package/src/standard/manifest.ts +102 -0
- package/src/standard/plugin-skills.ts +88 -0
- package/src/standard/repo.ts +69 -0
- package/src/standard/toolchain.ts +90 -0
- package/src/standard.ts +71 -0
package/README.md
CHANGED
|
@@ -241,7 +241,7 @@ export default z3({
|
|
|
241
241
|
|
|
242
242
|
A `z3` proof passes only when all of these hold:
|
|
243
243
|
|
|
244
|
-
- `code` returns a whole number equal to the model's output on `samples` seeded inputs
|
|
244
|
+
- `code` returns a whole number equal to the model's output on `samples` seeded inputs. Edge values come first, then one draw uniform over each range for every three small-magnitude draws, which put each input within a random power of two of its range's value nearest 0.
|
|
245
245
|
- The claim uses only Int and BitVec arithmetic. Real and Float arithmetic fail.
|
|
246
246
|
- `holds` is false for some output, so the claim constrains the model.
|
|
247
247
|
- z3 answers `unsat` for the negated claim. `unknown`, a timeout or a crash fails.
|
|
@@ -249,3 +249,23 @@ A `z3` proof passes only when all of these hold:
|
|
|
249
249
|
The toolchain pins `z3-solver` 5.3.3, and the command starts and stops its worker threads. Division or remainder by a symbolic value is slow over BitVec, so state it over Int.
|
|
250
250
|
|
|
251
251
|
Rule 16 applies once `specs.json` has an `arithmetic` key. Each `arithmetic` glob must match a tracked file, and a proof or Kani entry must cover every tracked file one matches. Without the key, the `arithmetic` check logs that rule 16 is off. A repo adds the key in the same PR as its proofs.
|
|
252
|
+
|
|
253
|
+
## Standard check
|
|
254
|
+
|
|
255
|
+
Run `vp exec standard` from a Git repository. The command accepts no arguments. It checks tracked files that still exist.
|
|
256
|
+
|
|
257
|
+
Findings go to stderr as `<file>: <rule>: <message>`, sorted by file and rule order. Failure ends with `standard: N findings` and exit code 1. Success prints `standard: N rules, no findings` and exits 0. Extra arguments print `usage: standard` and exit 2.
|
|
258
|
+
|
|
259
|
+
- `toolchain-pin` requires an exact toolchain dependency or an exact catalog entry.
|
|
260
|
+
- `lint-package` rejects repo-owned lint packages.
|
|
261
|
+
- `lint-fmt` requires the shared lint and fmt imports through the root Vite config.
|
|
262
|
+
- `tsconfig-base` requires the shared base in the root extends chain.
|
|
263
|
+
- `node-version` requires the toolchain's Node version.
|
|
264
|
+
- `renovate-preset` requires the shared Renovate preset URL.
|
|
265
|
+
- `exact-versions` rejects dependency ranges in tracked manifests.
|
|
266
|
+
- `specs` requires valid specs metadata, a spec entry and coverage of critical files.
|
|
267
|
+
- `ready-formal` requires a ready workflow step running `vp exec formal`. A step or job with `if: false` or `continue-on-error` does not count.
|
|
268
|
+
- `task-agents` requires a Task agents section with one line pointing to `agent-kit:task-agents`.
|
|
269
|
+
- `skill-names` rejects repo skills that share plugin skill names.
|
|
270
|
+
|
|
271
|
+
New rules register in `src/standard/checks.ts`.
|
package/dist/formal.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
+
import { n as criticalFindings, t as decode } from "./specs-file-NsQF4V7X.mjs";
|
|
2
3
|
import { i as sorted, r as receiptPath, t as FORMAL_TRACES } from "./trace-file-KuPRWgwt.mjs";
|
|
3
4
|
import * as Data from "effect/Data";
|
|
4
5
|
import * as Option from "effect/Option";
|
|
@@ -22,7 +23,6 @@ import * as Context from "effect/Context";
|
|
|
22
23
|
import { FetchHttpClient, HttpClient } from "effect/http";
|
|
23
24
|
import { Path } from "effect/Path";
|
|
24
25
|
import * as Cache from "effect/Cache";
|
|
25
|
-
import * as SchemaIssue from "effect/SchemaIssue";
|
|
26
26
|
// src/formal/proof-run.ts
|
|
27
27
|
const Edit = Schema.Struct({
|
|
28
28
|
file: Schema.String,
|
|
@@ -428,7 +428,7 @@ var Tla = class Tla extends Context.Service()("formal/Tla") {
|
|
|
428
428
|
static layer = Layer.effect(Tla, make$1);
|
|
429
429
|
};
|
|
430
430
|
// src/formal/arithmetic.ts
|
|
431
|
-
const matches
|
|
431
|
+
const matches = (glob, file) => new Bun.Glob(glob).match(file);
|
|
432
432
|
const moduleFile = /\.(?:[cm]?[jt]s|[jt]sx)$/u;
|
|
433
433
|
const arithmetic = (repo) => Effect.gen(function* () {
|
|
434
434
|
if (repo.file.arithmetic === void 0) {
|
|
@@ -436,14 +436,14 @@ const arithmetic = (repo) => Effect.gen(function* () {
|
|
|
436
436
|
return [];
|
|
437
437
|
}
|
|
438
438
|
return repo.file.arithmetic.flatMap((glob) => {
|
|
439
|
-
const files = repo.tracked.filter((f) => matches
|
|
439
|
+
const files = repo.tracked.filter((f) => matches(glob, f));
|
|
440
440
|
return files.length === 0 ? [{
|
|
441
441
|
file: "specs.json",
|
|
442
442
|
message: `arithmetic glob ${glob} matches no tracked file`
|
|
443
443
|
}] : files.filter((f) => !Object.values({
|
|
444
444
|
...repo.file.proofs,
|
|
445
445
|
...repo.file.kani
|
|
446
|
-
}).some((e) => e.covers.some((g) => matches
|
|
446
|
+
}).some((e) => e.covers.some((g) => matches(g, f)))).map((file) => ({
|
|
447
447
|
file,
|
|
448
448
|
message: `matches arithmetic glob ${glob} but no proof covers it`
|
|
449
449
|
}));
|
|
@@ -481,7 +481,7 @@ const proofs = (repo) => Effect.scoped(Effect.gen(function* () {
|
|
|
481
481
|
file,
|
|
482
482
|
message
|
|
483
483
|
});
|
|
484
|
-
const covered = repo.tracked.filter((f) => entry.covers.some((g) => matches
|
|
484
|
+
const covered = repo.tracked.filter((f) => entry.covers.some((g) => matches(g, f)));
|
|
485
485
|
const before = problems.length;
|
|
486
486
|
for (const [i, edit] of entry.breaks.entries()) {
|
|
487
487
|
if (!covered.includes(edit.file)) {
|
|
@@ -862,32 +862,7 @@ const violate = Effect.fn("formal.violate")(function* (repo, m, target, edit) {
|
|
|
862
862
|
}));
|
|
863
863
|
});
|
|
864
864
|
// src/formal/proofs.ts
|
|
865
|
-
const
|
|
866
|
-
const critical = (repo) => Effect.succeed([
|
|
867
|
-
...repo.file.critical.flatMap((glob) => repo.tracked.some((f) => matches(glob, f)) ? [] : [{
|
|
868
|
-
file: "specs.json",
|
|
869
|
-
message: `critical glob ${glob} matches no tracked file`
|
|
870
|
-
}]),
|
|
871
|
-
...Object.entries({
|
|
872
|
-
...repo.file.specs,
|
|
873
|
-
...repo.file.kani,
|
|
874
|
-
...repo.file.proofs
|
|
875
|
-
}).flatMap(([file, e]) => e.covers.flatMap((glob) => repo.tracked.some((f) => matches(glob, f)) ? [] : [{
|
|
876
|
-
file,
|
|
877
|
-
message: `covers glob ${glob} matches no tracked file`
|
|
878
|
-
}])),
|
|
879
|
-
...repo.tracked.flatMap((file) => {
|
|
880
|
-
const glob = repo.file.critical.find((g) => matches(g, file));
|
|
881
|
-
return glob !== void 0 && !Object.values({
|
|
882
|
-
...repo.file.specs,
|
|
883
|
-
...repo.file.kani,
|
|
884
|
-
...repo.file.proofs
|
|
885
|
-
}).some((e) => (!("mode" in e) || e.mode !== "library") && e.covers.some((g) => matches(g, file))) ? [{
|
|
886
|
-
file,
|
|
887
|
-
message: `matches critical glob ${glob} but no spec covers it`
|
|
888
|
-
}] : [];
|
|
889
|
-
})
|
|
890
|
-
]);
|
|
865
|
+
const critical = (repo) => Effect.succeed(criticalFindings(repo));
|
|
891
866
|
const fairness = (repo) => Effect.succeed(repo.specs.flatMap((s) => s.analysis._tag === "Parsed" ? s.analysis.semantics.fairness.filter((f) => !f.valid).map((f) => ({
|
|
892
867
|
file: s.path,
|
|
893
868
|
message: `${f.kind} at line ${f.line}; fairness must be WF_vars or SF_vars`
|
|
@@ -1293,89 +1268,6 @@ const checks = {
|
|
|
1293
1268
|
proofs
|
|
1294
1269
|
};
|
|
1295
1270
|
// src/formal/specs.ts
|
|
1296
|
-
const RepoPath = Schema.String.check(Schema.isPattern(/^(?!\/)(?!(?:.*\/)?\.\.(?:\/|$))[^\0\\]+$/u));
|
|
1297
|
-
const OperatorName = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_]*$/u));
|
|
1298
|
-
const Common = {
|
|
1299
|
-
synced: Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/u)),
|
|
1300
|
-
covers: Schema.NonEmptyArray(Schema.NonEmptyString)
|
|
1301
|
-
};
|
|
1302
|
-
const Runtime = {
|
|
1303
|
-
...Common,
|
|
1304
|
-
timeoutSeconds: Schema.Int.check(Schema.isBetween({
|
|
1305
|
-
minimum: 1,
|
|
1306
|
-
maximum: 1800
|
|
1307
|
-
})).pipe(Schema.withDecodingDefaultKey(Effect.succeed(60)))
|
|
1308
|
-
};
|
|
1309
|
-
const Proof = {
|
|
1310
|
-
...Runtime,
|
|
1311
|
-
witnesses: Schema.NonEmptyArray(OperatorName).check(Schema.makeFilter((names) => new Set(names).size === names.length || "witnesses must be unique")),
|
|
1312
|
-
breaks: Schema.Array(Schema.Struct({
|
|
1313
|
-
violates: OperatorName,
|
|
1314
|
-
find: Schema.NonEmptyString,
|
|
1315
|
-
replace: Schema.String,
|
|
1316
|
-
file: Schema.optionalKey(RepoPath)
|
|
1317
|
-
})).pipe(Schema.withDecodingDefaultKey(Effect.succeed([])))
|
|
1318
|
-
};
|
|
1319
|
-
const Entry = Schema.Union([
|
|
1320
|
-
Schema.Struct({
|
|
1321
|
-
...Proof,
|
|
1322
|
-
mode: Schema.Literal("gate"),
|
|
1323
|
-
traces: Schema.optionalKey(Schema.Struct({
|
|
1324
|
-
seed: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
1325
|
-
depth: Schema.Int.check(Schema.isBetween({
|
|
1326
|
-
minimum: 1,
|
|
1327
|
-
maximum: 1e4
|
|
1328
|
-
})),
|
|
1329
|
-
count: Schema.Int.check(Schema.isBetween({
|
|
1330
|
-
minimum: 1,
|
|
1331
|
-
maximum: 1e5
|
|
1332
|
-
})),
|
|
1333
|
-
steer: Schema.optionalKey(Schema.Record(OperatorName, Schema.Int.check(Schema.isBetween({
|
|
1334
|
-
minimum: 2,
|
|
1335
|
-
maximum: 1e3
|
|
1336
|
-
})))),
|
|
1337
|
-
conformance: RepoPath
|
|
1338
|
-
}))
|
|
1339
|
-
}),
|
|
1340
|
-
Schema.Struct({
|
|
1341
|
-
...Proof,
|
|
1342
|
-
mode: Schema.Literal("manual")
|
|
1343
|
-
}),
|
|
1344
|
-
Schema.Struct({
|
|
1345
|
-
...Common,
|
|
1346
|
-
mode: Schema.Literal("library")
|
|
1347
|
-
})
|
|
1348
|
-
]);
|
|
1349
|
-
const ArithmeticCommon = {
|
|
1350
|
-
covers: Common.covers,
|
|
1351
|
-
timeoutSeconds: Runtime.timeoutSeconds,
|
|
1352
|
-
breaks: Schema.NonEmptyArray(Schema.Struct({
|
|
1353
|
-
file: RepoPath,
|
|
1354
|
-
find: Schema.NonEmptyString,
|
|
1355
|
-
replace: Schema.String
|
|
1356
|
-
}))
|
|
1357
|
-
};
|
|
1358
|
-
const ArithmeticProof = Schema.Union([Schema.Struct({
|
|
1359
|
-
...ArithmeticCommon,
|
|
1360
|
-
kind: Schema.Literal("every")
|
|
1361
|
-
}), Schema.Struct({
|
|
1362
|
-
...ArithmeticCommon,
|
|
1363
|
-
kind: Schema.Literal("z3"),
|
|
1364
|
-
samples: Schema.Int.check(Schema.isBetween({
|
|
1365
|
-
minimum: 1e4,
|
|
1366
|
-
maximum: 1e6
|
|
1367
|
-
})).pipe(Schema.withDecodingDefaultKey(Effect.succeed(1e4)))
|
|
1368
|
-
})]);
|
|
1369
|
-
const SpecsFile = Schema.Struct({
|
|
1370
|
-
critical: Schema.NonEmptyArray(Schema.NonEmptyString),
|
|
1371
|
-
arithmetic: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),
|
|
1372
|
-
proofs: Schema.Record(RepoPath.check(Schema.isPattern(/\.proof\.ts$/u)), ArithmeticProof).pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
|
|
1373
|
-
specs: Schema.Record(RepoPath.check(Schema.isPattern(/\.tla$/u)), Entry),
|
|
1374
|
-
kani: Schema.Record(RepoPath.check(Schema.isPattern(/\.rs$/u)), Schema.Struct({
|
|
1375
|
-
...Runtime,
|
|
1376
|
-
mode: Schema.Literals(["gate", "manual"])
|
|
1377
|
-
})).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})))
|
|
1378
|
-
});
|
|
1379
1271
|
const load = Effect.fn("formal.load")(function* (root) {
|
|
1380
1272
|
const fs = yield* FileSystem;
|
|
1381
1273
|
const path = yield* Path;
|
|
@@ -1396,12 +1288,7 @@ const load = Effect.fn("formal.load")(function* (root) {
|
|
|
1396
1288
|
let decodeErrors = [];
|
|
1397
1289
|
if (yield* fs.exists(path.join(root, "specs.json"))) {
|
|
1398
1290
|
const raw = yield* fs.readFileString(path.join(root, "specs.json"));
|
|
1399
|
-
|
|
1400
|
-
errors: "all",
|
|
1401
|
-
onExcessProperty: "error"
|
|
1402
|
-
});
|
|
1403
|
-
if (Result.isSuccess(decoded)) file = decoded.success;
|
|
1404
|
-
else decodeErrors = SchemaIssue.makeFormatterStandardSchemaV1()(decoded.failure.issue).issues.map(({ message, path: at = [] }) => at.length === 0 ? message : `${at.map((key) => `[${JSON.stringify(typeof key === "object" ? key.key : key)}]`).join("")}: ${message}`);
|
|
1291
|
+
({file, decodeErrors} = decode(raw));
|
|
1405
1292
|
}
|
|
1406
1293
|
const modules = tracked.filter((f) => f.endsWith(".tla"));
|
|
1407
1294
|
const configs = tracked.filter((f) => f.endsWith(".cfg") && modules.some((m) => path.dirname(m) === path.dirname(f)));
|
package/dist/guard.d.mts
CHANGED
|
@@ -4,12 +4,12 @@ import { t as Catalog } from "./versions-D02TrtKw.mjs";
|
|
|
4
4
|
import { OxlintConfig } from "vite-plus/lint";
|
|
5
5
|
type Ranges = Readonly<Record<string, string>>;
|
|
6
6
|
export declare const manifestRanges: (text: string) => ReadonlyArray<readonly [string, Ranges]>;
|
|
7
|
-
export declare const isFoldkitViteInput: (file: string) => boolean;
|
|
8
|
-
export declare const foldkitViteFindings: (files: ReadonlyArray<readonly [string, string]>) => ReadonlyArray<string>;
|
|
9
7
|
export declare const exactFindings: {
|
|
10
8
|
(text: string): (file: string) => ReadonlyArray<string>;
|
|
11
9
|
(file: string, text: string): ReadonlyArray<string>;
|
|
12
10
|
};
|
|
11
|
+
export declare const isFoldkitViteInput: (file: string) => boolean;
|
|
12
|
+
export declare const foldkitViteFindings: (files: ReadonlyArray<readonly [string, string]>) => ReadonlyArray<string>;
|
|
13
13
|
export declare const pinFindings: {
|
|
14
14
|
(text: string, rootCatalog?: Ranges): (file: string) => ReadonlyArray<string>;
|
|
15
15
|
(file: string, text: string, rootCatalog?: Ranges): ReadonlyArray<string>;
|
package/dist/guard.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { d as otherTags, l as latestOf, u as onLatestLine } from "./compatible-D
|
|
|
2
2
|
import { i as enforcedTsgoRules } from "./effect-tsgo-D0QfeKGD.mjs";
|
|
3
3
|
import { t as exceptions } from "./exceptions-Dybl9xpc.mjs";
|
|
4
4
|
import { a as toolchainScopes, n as effectRules, r as foldkitPreset, t as birbprophetRules } from "./lint-IhmtnBbx.mjs";
|
|
5
|
+
import { n as exactFindings, r as manifestRanges } from "./manifest-xQwgnYI1.mjs";
|
|
5
6
|
import { c as lead, f as versionOf } from "./versions-C7LKZGr3.mjs";
|
|
6
7
|
import * as Arr from "effect/Array";
|
|
7
8
|
import { dual } from "effect/Function";
|
|
@@ -10,52 +11,7 @@ import * as Option from "effect/Option";
|
|
|
10
11
|
import * as R from "effect/Record";
|
|
11
12
|
import * as Schema from "effect/Schema";
|
|
12
13
|
import * as Str from "effect/String";
|
|
13
|
-
import * as Effect from "effect/Effect";
|
|
14
|
-
import * as Result from "effect/Result";
|
|
15
14
|
// src/guard.ts
|
|
16
|
-
const Versions = Schema.Record(Schema.String, Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
|
|
17
|
-
const Catalogs = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String)).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
|
|
18
|
-
const WorkspaceList = Schema.Array(Schema.String);
|
|
19
|
-
const WorkspaceCatalogs = Schema.Struct({
|
|
20
|
-
catalog: Versions,
|
|
21
|
-
catalogs: Catalogs
|
|
22
|
-
});
|
|
23
|
-
const Manifest = Schema.fromJsonString(Schema.Struct({
|
|
24
|
-
dependencies: Versions,
|
|
25
|
-
devDependencies: Versions,
|
|
26
|
-
peerDependencies: Versions,
|
|
27
|
-
optionalDependencies: Versions,
|
|
28
|
-
overrides: Versions,
|
|
29
|
-
resolutions: Versions,
|
|
30
|
-
catalog: Versions,
|
|
31
|
-
catalogs: Catalogs,
|
|
32
|
-
workspaces: Schema.optionalKey(Schema.Union([WorkspaceList, WorkspaceCatalogs]))
|
|
33
|
-
}));
|
|
34
|
-
const named = (prefix, catalogs) => Arr.map(R.toEntries(catalogs), ([name, ranges]) => [`${prefix}.${name}`, ranges]);
|
|
35
|
-
const manifestRanges = (text) => {
|
|
36
|
-
const decoded = Schema.decodeResult(Manifest)(text);
|
|
37
|
-
if (Result.isFailure(decoded)) throw decoded.failure;
|
|
38
|
-
const manifest = decoded.success;
|
|
39
|
-
const workspaces = Schema.is(WorkspaceCatalogs)(manifest.workspaces) ? manifest.workspaces : {
|
|
40
|
-
catalog: {},
|
|
41
|
-
catalogs: {}
|
|
42
|
-
};
|
|
43
|
-
return [
|
|
44
|
-
["dependencies", manifest.dependencies],
|
|
45
|
-
["devDependencies", manifest.devDependencies],
|
|
46
|
-
["peerDependencies", manifest.peerDependencies],
|
|
47
|
-
["optionalDependencies", manifest.optionalDependencies],
|
|
48
|
-
["overrides", manifest.overrides],
|
|
49
|
-
["resolutions", manifest.resolutions],
|
|
50
|
-
["catalog", manifest.catalog],
|
|
51
|
-
["workspaces.catalog", workspaces.catalog],
|
|
52
|
-
...named("catalogs", manifest.catalogs),
|
|
53
|
-
...named("workspaces.catalogs", workspaces.catalogs)
|
|
54
|
-
];
|
|
55
|
-
};
|
|
56
|
-
const SEMVER = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
|
|
57
|
-
const EXACT = new RegExp(String.raw`^(?:npm:(?:@[\w.-]+\/)?[\w.-]+@)?${SEMVER}$`, "u");
|
|
58
|
-
const REFERENCE = /^(?:catalog:[\w.-]*|workspace:\*)$/u;
|
|
59
15
|
const DEPENDENCY_FIELDS = HashSet.fromIterable([
|
|
60
16
|
"dependencies",
|
|
61
17
|
"devDependencies",
|
|
@@ -71,7 +27,6 @@ const foldkitViteFindings = (files) => {
|
|
|
71
27
|
const foldkitFolders = HashSet.fromIterable(Arr.flatMap(files, ([file, text]) => MANIFEST.test(file) && Arr.some(manifestRanges(text), ([field, ranges]) => HashSet.has(DEPENDENCY_FIELDS, field) && R.has(ranges, "foldkit")) ? [folderOf(file)] : []));
|
|
72
28
|
return Arr.flatMap(files, ([config, source]) => VITE_CONFIG.test(config) && HashSet.has(foldkitFolders, folderOf(config)) && !VITE_PLUGIN.test(source) ? [`${config} builds a foldkit package without @foldkit/vite-plugin, so view identity isn't stamped and keyed patching breaks`] : []);
|
|
73
29
|
};
|
|
74
|
-
const exactFindings = dual(2, (file, text) => Arr.flatMap(manifestRanges(text), ([field, ranges]) => Arr.flatMap(R.toEntries(ranges), ([name, version]) => EXACT.test(version) || REFERENCE.test(version) ? [] : [`${file} ${field} ${name}: ${version} is not an exact version`])));
|
|
75
30
|
const pinFindings = dual((args) => Schema.is(Schema.String)(args[1]), (file, text, rootCatalog = {}) => Arr.flatMap(manifestRanges(text), ([field, ranges]) => Arr.flatMap(R.toEntries(ranges), ([name, written]) => Option.match(versionOf(name), {
|
|
76
31
|
onNone: () => [],
|
|
77
32
|
onSome: (pinnedVersion) => {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as Arr from "effect/Array";
|
|
2
|
+
import { dual } from "effect/Function";
|
|
3
|
+
import * as R from "effect/Record";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Result from "effect/Result";
|
|
7
|
+
// src/standard/manifest.ts
|
|
8
|
+
const Versions = Schema.Record(Schema.String, Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
|
|
9
|
+
const Catalogs = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String)).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
|
|
10
|
+
const WorkspaceList = Schema.Array(Schema.String);
|
|
11
|
+
const WorkspaceCatalogs = Schema.Struct({
|
|
12
|
+
catalog: Versions,
|
|
13
|
+
catalogs: Catalogs
|
|
14
|
+
});
|
|
15
|
+
const Manifest = Schema.fromJsonString(Schema.Struct({
|
|
16
|
+
dependencies: Versions,
|
|
17
|
+
devDependencies: Versions,
|
|
18
|
+
peerDependencies: Versions,
|
|
19
|
+
optionalDependencies: Versions,
|
|
20
|
+
overrides: Versions,
|
|
21
|
+
resolutions: Versions,
|
|
22
|
+
catalog: Versions,
|
|
23
|
+
catalogs: Catalogs,
|
|
24
|
+
workspaces: Schema.optionalKey(Schema.Union([WorkspaceList, WorkspaceCatalogs]))
|
|
25
|
+
}));
|
|
26
|
+
const named = (prefix, catalogs) => Arr.map(R.toEntries(catalogs), ([name, ranges]) => [`${prefix}.${name}`, ranges]);
|
|
27
|
+
const manifestRanges = (text) => {
|
|
28
|
+
const decoded = Schema.decodeResult(Manifest)(text);
|
|
29
|
+
if (Result.isFailure(decoded)) throw decoded.failure;
|
|
30
|
+
const manifest = decoded.success;
|
|
31
|
+
const workspaces = Schema.is(WorkspaceCatalogs)(manifest.workspaces) ? manifest.workspaces : {
|
|
32
|
+
catalog: {},
|
|
33
|
+
catalogs: {}
|
|
34
|
+
};
|
|
35
|
+
return [
|
|
36
|
+
["dependencies", manifest.dependencies],
|
|
37
|
+
["devDependencies", manifest.devDependencies],
|
|
38
|
+
["peerDependencies", manifest.peerDependencies],
|
|
39
|
+
["optionalDependencies", manifest.optionalDependencies],
|
|
40
|
+
["overrides", manifest.overrides],
|
|
41
|
+
["resolutions", manifest.resolutions],
|
|
42
|
+
["catalog", manifest.catalog],
|
|
43
|
+
["workspaces.catalog", workspaces.catalog],
|
|
44
|
+
...named("catalogs", manifest.catalogs),
|
|
45
|
+
...named("workspaces.catalogs", workspaces.catalogs)
|
|
46
|
+
];
|
|
47
|
+
};
|
|
48
|
+
const SEMVER = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
|
|
49
|
+
const PLAIN = new RegExp(`^${SEMVER}$`, "u");
|
|
50
|
+
const EXACT = new RegExp(String.raw`^(?:npm:(?:@[\w.-]+\/)?[\w.-]+@)?${SEMVER}$`, "u");
|
|
51
|
+
const REFERENCE = /^(?:catalog:[\w.-]*|workspace:\*)$/u;
|
|
52
|
+
const exactFindings = dual(2, (file, text) => Arr.flatMap(manifestRanges(text), ([field, ranges]) => Arr.flatMap(R.toEntries(ranges), ([name, version]) => EXACT.test(version) || REFERENCE.test(version) ? [] : [`${file} ${field} ${name}: ${version} is not an exact version`])));
|
|
53
|
+
export { exactFindings as n, manifestRanges as r, PLAIN as t };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Result from "effect/Result";
|
|
4
|
+
import * as SchemaIssue from "effect/SchemaIssue";
|
|
5
|
+
// src/formal/critical.ts
|
|
6
|
+
const matches = (glob, file) => new Bun.Glob(glob).match(file);
|
|
7
|
+
const criticalFindings = (repo) => [
|
|
8
|
+
...repo.file.critical.flatMap((glob) => repo.tracked.some((f) => matches(glob, f)) ? [] : [{
|
|
9
|
+
file: "specs.json",
|
|
10
|
+
message: `critical glob ${glob} matches no tracked file`
|
|
11
|
+
}]),
|
|
12
|
+
...Object.entries({
|
|
13
|
+
...repo.file.specs,
|
|
14
|
+
...repo.file.kani,
|
|
15
|
+
...repo.file.proofs
|
|
16
|
+
}).flatMap(([file, e]) => e.covers.flatMap((glob) => repo.tracked.some((f) => matches(glob, f)) ? [] : [{
|
|
17
|
+
file,
|
|
18
|
+
message: `covers glob ${glob} matches no tracked file`
|
|
19
|
+
}])),
|
|
20
|
+
...repo.tracked.flatMap((file) => {
|
|
21
|
+
const glob = repo.file.critical.find((g) => matches(g, file));
|
|
22
|
+
return glob !== void 0 && !Object.values({
|
|
23
|
+
...repo.file.specs,
|
|
24
|
+
...repo.file.kani,
|
|
25
|
+
...repo.file.proofs
|
|
26
|
+
}).some((e) => (!("mode" in e) || e.mode !== "library") && e.covers.some((g) => matches(g, file))) ? [{
|
|
27
|
+
file,
|
|
28
|
+
message: `matches critical glob ${glob} but no spec covers it`
|
|
29
|
+
}] : [];
|
|
30
|
+
})
|
|
31
|
+
];
|
|
32
|
+
// src/formal/specs-file.ts
|
|
33
|
+
const RepoPath = Schema.String.check(Schema.isPattern(/^(?!\/)(?!(?:.*\/)?\.\.(?:\/|$))[^\0\\]+$/u));
|
|
34
|
+
const OperatorName = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_]*$/u));
|
|
35
|
+
const Common = {
|
|
36
|
+
synced: Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/u)),
|
|
37
|
+
covers: Schema.NonEmptyArray(Schema.NonEmptyString)
|
|
38
|
+
};
|
|
39
|
+
const Runtime = {
|
|
40
|
+
...Common,
|
|
41
|
+
timeoutSeconds: Schema.Int.check(Schema.isBetween({
|
|
42
|
+
minimum: 1,
|
|
43
|
+
maximum: 1800
|
|
44
|
+
})).pipe(Schema.withDecodingDefaultKey(Effect.succeed(60)))
|
|
45
|
+
};
|
|
46
|
+
const Proof = {
|
|
47
|
+
...Runtime,
|
|
48
|
+
witnesses: Schema.NonEmptyArray(OperatorName).check(Schema.makeFilter((names) => new Set(names).size === names.length || "witnesses must be unique")),
|
|
49
|
+
breaks: Schema.Array(Schema.Struct({
|
|
50
|
+
violates: OperatorName,
|
|
51
|
+
find: Schema.NonEmptyString,
|
|
52
|
+
replace: Schema.String,
|
|
53
|
+
file: Schema.optionalKey(RepoPath)
|
|
54
|
+
})).pipe(Schema.withDecodingDefaultKey(Effect.succeed([])))
|
|
55
|
+
};
|
|
56
|
+
const Entry = Schema.Union([
|
|
57
|
+
Schema.Struct({
|
|
58
|
+
...Proof,
|
|
59
|
+
mode: Schema.Literal("gate"),
|
|
60
|
+
traces: Schema.optionalKey(Schema.Struct({
|
|
61
|
+
seed: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
62
|
+
depth: Schema.Int.check(Schema.isBetween({
|
|
63
|
+
minimum: 1,
|
|
64
|
+
maximum: 1e4
|
|
65
|
+
})),
|
|
66
|
+
count: Schema.Int.check(Schema.isBetween({
|
|
67
|
+
minimum: 1,
|
|
68
|
+
maximum: 1e5
|
|
69
|
+
})),
|
|
70
|
+
steer: Schema.optionalKey(Schema.Record(OperatorName, Schema.Int.check(Schema.isBetween({
|
|
71
|
+
minimum: 2,
|
|
72
|
+
maximum: 1e3
|
|
73
|
+
})))),
|
|
74
|
+
conformance: RepoPath
|
|
75
|
+
}))
|
|
76
|
+
}),
|
|
77
|
+
Schema.Struct({
|
|
78
|
+
...Proof,
|
|
79
|
+
mode: Schema.Literal("manual")
|
|
80
|
+
}),
|
|
81
|
+
Schema.Struct({
|
|
82
|
+
...Common,
|
|
83
|
+
mode: Schema.Literal("library")
|
|
84
|
+
})
|
|
85
|
+
]);
|
|
86
|
+
const ArithmeticCommon = {
|
|
87
|
+
covers: Common.covers,
|
|
88
|
+
timeoutSeconds: Runtime.timeoutSeconds,
|
|
89
|
+
breaks: Schema.NonEmptyArray(Schema.Struct({
|
|
90
|
+
file: RepoPath,
|
|
91
|
+
find: Schema.NonEmptyString,
|
|
92
|
+
replace: Schema.String
|
|
93
|
+
}))
|
|
94
|
+
};
|
|
95
|
+
const ArithmeticProof = Schema.Union([Schema.Struct({
|
|
96
|
+
...ArithmeticCommon,
|
|
97
|
+
kind: Schema.Literal("every")
|
|
98
|
+
}), Schema.Struct({
|
|
99
|
+
...ArithmeticCommon,
|
|
100
|
+
kind: Schema.Literal("z3"),
|
|
101
|
+
samples: Schema.Int.check(Schema.isBetween({
|
|
102
|
+
minimum: 1e4,
|
|
103
|
+
maximum: 1e6
|
|
104
|
+
})).pipe(Schema.withDecodingDefaultKey(Effect.succeed(1e4)))
|
|
105
|
+
})]);
|
|
106
|
+
const SpecsFile = Schema.Struct({
|
|
107
|
+
critical: Schema.NonEmptyArray(Schema.NonEmptyString),
|
|
108
|
+
arithmetic: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),
|
|
109
|
+
proofs: Schema.Record(RepoPath.check(Schema.isPattern(/\.proof\.ts$/u)), ArithmeticProof).pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
|
|
110
|
+
specs: Schema.Record(RepoPath.check(Schema.isPattern(/\.tla$/u)), Entry),
|
|
111
|
+
kani: Schema.Record(RepoPath.check(Schema.isPattern(/\.rs$/u)), Schema.Struct({
|
|
112
|
+
...Runtime,
|
|
113
|
+
mode: Schema.Literals(["gate", "manual"])
|
|
114
|
+
})).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})))
|
|
115
|
+
});
|
|
116
|
+
const decode = (raw) => {
|
|
117
|
+
let file = {
|
|
118
|
+
critical: [],
|
|
119
|
+
specs: {},
|
|
120
|
+
kani: {},
|
|
121
|
+
proofs: {}
|
|
122
|
+
};
|
|
123
|
+
let decodeErrors = [];
|
|
124
|
+
const decoded = Schema.decodeResult(Schema.fromJsonString(SpecsFile))(raw, {
|
|
125
|
+
errors: "all",
|
|
126
|
+
onExcessProperty: "error"
|
|
127
|
+
});
|
|
128
|
+
if (Result.isSuccess(decoded)) file = decoded.success;
|
|
129
|
+
else decodeErrors = SchemaIssue.makeFormatterStandardSchemaV1()(decoded.failure.issue).issues.map(({ message, path: at = [] }) => at.length === 0 ? message : `${at.map((key) => `[${JSON.stringify(typeof key === "object" ? key.key : key)}]`).join("")}: ${message}`);
|
|
130
|
+
return {
|
|
131
|
+
file,
|
|
132
|
+
decodeErrors
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export { criticalFindings as n, decode as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
export declare const standard: (root: string) => Effect.Effect<0 | 1, unknown, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("effect/Scope").Scope>;
|