@okfit/core 0.13.5 → 0.15.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/Actor.js +1 -1
- package/AttestedComputation.js +3 -3
- package/Bundle.js +89 -13
- package/Concept.js +31 -3
- package/ConceptId.js +1 -1
- package/Derive.js +82 -16
- package/Diagnostic.js +20 -5
- package/Generated.js +2 -2
- package/GeneratedAtFuture.js +33 -0
- package/Graph.js +48 -13
- package/IndexDocument.js +9 -2
- package/Integrity.js +14 -3
- package/LogDocument.js +1 -1
- package/OkfVersion.js +40 -0
- package/OkfitConfig.js +177 -16
- package/README.md +4 -2
- package/Source.js +3 -3
- package/Status.js +12 -1
- package/Timestamp.js +12 -5
- package/Validate.js +2 -1
- package/Verification.js +1 -1
- package/index.d.ts +322 -35
- package/index.js +7 -5
- package/internal/conceptDecode.js +231 -33
- package/internal/frontmatter.js +19 -6
- package/internal/links.js +12 -10
- package/internal/lintRules.js +154 -25
- package/internal/reserved.js +33 -9
- package/internal/templates.js +28 -6
- package/internal/tier.js +7 -0
- package/internal/walk.js +1 -1
- package/internal/yamlPathSpan.js +2 -2
- package/package.json +3 -3
package/Integrity.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { Actor } from "./Actor.js";
|
|
2
3
|
import { Timestamp } from "./Timestamp.js";
|
|
3
|
-
import { Schema } from "effect";
|
|
4
4
|
|
|
5
5
|
// src/Integrity.ts
|
|
6
6
|
const DIGEST_RE = /^[0-9a-f]{16}$/u;
|
|
@@ -12,6 +12,17 @@ const DIGEST_RE = /^[0-9a-f]{16}$/u;
|
|
|
12
12
|
*/
|
|
13
13
|
const Digest = Schema.String.pipe(Schema.check(Schema.isPattern(DIGEST_RE, { message: "Expected a lowercase 16-character hex digest" })));
|
|
14
14
|
/**
|
|
15
|
+
* The prefix of every frontmatter key okfit owns (OKF v0.3 section 4.1 extension keys).
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
const OKFIT_KEY_PREFIX = "x-okfit-";
|
|
19
|
+
/**
|
|
20
|
+
* The top-level frontmatter key that holds okfit's {@link Integrity} family.
|
|
21
|
+
* Every reader and writer of that key goes through this constant.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
const INTEGRITY_KEY = `${OKFIT_KEY_PREFIX}integrity`;
|
|
25
|
+
/**
|
|
15
26
|
* The body digest as of `generated.at`.
|
|
16
27
|
* @public
|
|
17
28
|
*/
|
|
@@ -27,7 +38,7 @@ var IntegrityVerified = class extends Schema.Class("IntegrityVerified")({
|
|
|
27
38
|
}) {};
|
|
28
39
|
/**
|
|
29
40
|
* okfit's own top-level frontmatter family, the only place okfit stores digests
|
|
30
|
-
* (OKF v0.
|
|
41
|
+
* (OKF v0.3 section 4.1 extension key). Spec families such as `generated` and
|
|
31
42
|
* `verified` stay exactly as the spec defines them.
|
|
32
43
|
* @public
|
|
33
44
|
*/
|
|
@@ -36,4 +47,4 @@ var Integrity = class extends Schema.Class("Integrity")({
|
|
|
36
47
|
verified: Schema.optionalKey(IntegrityVerified)
|
|
37
48
|
}) {};
|
|
38
49
|
|
|
39
|
-
export { Digest, Integrity, IntegrityGenerated, IntegrityVerified };
|
|
50
|
+
export { Digest, INTEGRITY_KEY, Integrity, IntegrityGenerated, IntegrityVerified, OKFIT_KEY_PREFIX };
|
package/LogDocument.js
CHANGED
package/OkfVersion.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Option } from "effect";
|
|
2
|
+
|
|
3
|
+
// src/OkfVersion.ts
|
|
4
|
+
const VERSION = /^(\d+)\.(\d+)$/;
|
|
5
|
+
const LEGACY = {
|
|
6
|
+
major: 0,
|
|
7
|
+
minor: 2
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Reads and compares the OKF version a bundle declares. The declared version is the bundle-root
|
|
11
|
+
* `index.md`'s `okf_version`; one gate, {@link OkfVersion.legacyFallbacks}, decides whether the v0.2
|
|
12
|
+
* fallbacks apply. @public
|
|
13
|
+
*/
|
|
14
|
+
var OkfVersion = class OkfVersion {
|
|
15
|
+
constructor() {}
|
|
16
|
+
/** Parses exactly `<major>.<minor>` (no `v`, no patch, no whitespace); anything else is `None`. */
|
|
17
|
+
static parse = (raw) => {
|
|
18
|
+
const match = VERSION.exec(raw);
|
|
19
|
+
return match === null ? Option.none() : Option.some({
|
|
20
|
+
major: Number(match[1]),
|
|
21
|
+
minor: Number(match[2])
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
/** Compares numerically, major first, so `0.10` sorts after `0.9`. */
|
|
25
|
+
static compare = (a, b) => a.major !== b.major ? a.major < b.major ? -1 : 1 : a.minor === b.minor ? 0 : a.minor < b.minor ? -1 : 1;
|
|
26
|
+
/** The version the bundle-root `index.md` declares, as written; `None` when there is no root index or no `okf_version`. */
|
|
27
|
+
static declared = (bundle) => Option.fromNullishOr(bundle.indexes.get("")?.okfVersion);
|
|
28
|
+
/** True when nothing is declared or the declared version parses and is 0.2 or earlier; an unparsable version reads as current. */
|
|
29
|
+
static allowsLegacyFallbacks = (declared) => Option.match(declared, {
|
|
30
|
+
onNone: () => true,
|
|
31
|
+
onSome: (raw) => Option.match(OkfVersion.parse(raw), {
|
|
32
|
+
onNone: () => false,
|
|
33
|
+
onSome: (version) => OkfVersion.compare(version, LEGACY) <= 0
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
/** Whether the v0.2 fallbacks apply to this bundle: `allowsLegacyFallbacks(declared(bundle))`. */
|
|
37
|
+
static legacyFallbacks = (bundle) => OkfVersion.allowsLegacyFallbacks(OkfVersion.declared(bundle));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { OkfVersion };
|
package/OkfitConfig.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Actor, ActorPattern } from "./Actor.js";
|
|
2
|
-
import { Duration, Effect, Option, Schema, SchemaGetter, SchemaIssue, SchemaTransformation } from "effect";
|
|
3
1
|
import { ConfigFile, ConfigMerge } from "@effected/config-file";
|
|
4
2
|
import { TomlCodec } from "@effected/config-file/toml";
|
|
3
|
+
import { GlobPattern } from "@effected/glob";
|
|
5
4
|
import { HostedSchema } from "@effected/schemastore";
|
|
5
|
+
import { Duration, Effect, Option, Result, Schema, SchemaGetter, SchemaIssue, SchemaTransformation } from "effect";
|
|
6
|
+
import { Actor, ActorPattern } from "./Actor.js";
|
|
7
|
+
import { INTEGRITY_KEY, OKFIT_KEY_PREFIX } from "./Integrity.js";
|
|
6
8
|
|
|
7
9
|
// src/OkfitConfig.ts
|
|
8
10
|
/**
|
|
@@ -157,9 +159,14 @@ const LintTable = Schema.Struct({
|
|
|
157
159
|
description: "A concept whose type sets require_verified = true carries no verified entry and is not a draft. Default \"error\".",
|
|
158
160
|
default: "error"
|
|
159
161
|
})),
|
|
162
|
+
verified_before_change: Schema.optionalKey(LintLevel.annotate({
|
|
163
|
+
title: "verified-before-change",
|
|
164
|
+
description: "A concept has verification events, but the ones at or after generated.at give a lower trust tier than all of them would: the content changed after it was verified (OKF 0.3 §5.3, \"verified before the last change\"). Draft, deprecated and unknown-status concepts are exempt. Default \"warn\".",
|
|
165
|
+
default: "warn"
|
|
166
|
+
})),
|
|
160
167
|
family_invalid: Schema.optionalKey(LintLevel.annotate({
|
|
161
168
|
title: "family-invalid",
|
|
162
|
-
description:
|
|
169
|
+
description: `okfit's own ${INTEGRITY_KEY} family does not match its shape. Default "error".`,
|
|
163
170
|
default: "error"
|
|
164
171
|
})),
|
|
165
172
|
computation_runtime_missing: Schema.optionalKey(LintLevel.annotate({
|
|
@@ -184,17 +191,17 @@ const LintTable = Schema.Struct({
|
|
|
184
191
|
})),
|
|
185
192
|
actor_prefix_unknown: Schema.optionalKey(LintLevel.annotate({
|
|
186
193
|
title: "actor-prefix-unknown",
|
|
187
|
-
description: "An actor
|
|
194
|
+
description: "An actor in generated.by, verified[].by or sources[].author uses a scheme other than human, team, process or a producer shape; it is accepted and read as non-human. Default \"info\".",
|
|
188
195
|
default: "info"
|
|
189
196
|
})),
|
|
190
197
|
actor_email: Schema.optionalKey(LintLevel.annotate({
|
|
191
198
|
title: "actor-email",
|
|
192
|
-
description:
|
|
199
|
+
description: `An actor in generated.by, verified[].by, ${INTEGRITY_KEY}.verified.by or [actors].humans contains "@", so an email address or domain is stored in the bundle or its config. Use a human:<id> without the domain. Default "warn".`,
|
|
193
200
|
default: "warn"
|
|
194
201
|
})),
|
|
195
202
|
verified_actor_unknown: Schema.optionalKey(LintLevel.annotate({
|
|
196
203
|
title: "verified-actor-unknown",
|
|
197
|
-
description:
|
|
204
|
+
description: `A human verified[].by or ${INTEGRITY_KEY}.verified.by matches no entry of a non-empty [actors].humans. Silent when the list is empty. Default "warn".`,
|
|
198
205
|
default: "warn"
|
|
199
206
|
})),
|
|
200
207
|
legacy_timestamp: Schema.optionalKey(LintLevel.annotate({
|
|
@@ -207,6 +214,11 @@ const LintTable = Schema.Struct({
|
|
|
207
214
|
description: "The config file declares a top-level key the schema does not recognize. Default \"warn\".",
|
|
208
215
|
default: "warn"
|
|
209
216
|
})),
|
|
217
|
+
config_okf_version_stale: Schema.optionalKey(LintLevel.annotate({
|
|
218
|
+
title: "config-okf-version-stale",
|
|
219
|
+
description: "The config sets okf_version and the bundle-root index.md declares a different one; the index decides how the bundle reads, so the config value is stale. Default \"warn\".",
|
|
220
|
+
default: "warn"
|
|
221
|
+
})),
|
|
210
222
|
stale: Schema.optionalKey(LintLevel.annotate({
|
|
211
223
|
title: "stale",
|
|
212
224
|
description: "A concept is past its stale_after instant. Default \"info\".",
|
|
@@ -217,6 +229,21 @@ const LintTable = Schema.Struct({
|
|
|
217
229
|
description: "A directory in the bundle could not be read while walking. Default \"warn\".",
|
|
218
230
|
default: "warn"
|
|
219
231
|
})),
|
|
232
|
+
frontmatter_missing: Schema.optionalKey(LintLevel.annotate({
|
|
233
|
+
title: "frontmatter-missing",
|
|
234
|
+
description: "A .md file other than index.md or log.md has no frontmatter, so it is not a concept and is skipped (OKF 0.3 §3.2). Default \"warn\".",
|
|
235
|
+
default: "warn"
|
|
236
|
+
})),
|
|
237
|
+
type_missing: Schema.optionalKey(LintLevel.annotate({
|
|
238
|
+
title: "type-missing",
|
|
239
|
+
description: "A .md file's frontmatter has no non-empty string type, so it is not a concept and is skipped (OKF 0.3 §3.2). Default \"warn\".",
|
|
240
|
+
default: "warn"
|
|
241
|
+
})),
|
|
242
|
+
symlink_escape: Schema.optionalKey(LintLevel.annotate({
|
|
243
|
+
title: "symlink-escape",
|
|
244
|
+
description: "A file in the bundle is a symbolic link whose target lies outside the bundle root; it is not read and not part of the bundle (OKF 0.3 §3.2). Default \"warn\".",
|
|
245
|
+
default: "warn"
|
|
246
|
+
})),
|
|
220
247
|
generated_at_drift: Schema.optionalKey(LintLevel.annotate({
|
|
221
248
|
title: "generated-at-drift",
|
|
222
249
|
description: "A committed concept's generated.at is missing or does not match its last body-changing commit, and is not otherwise authoritative (issue #19: a stamp recorded during the unchanged-body run survives a squash/rebase merge). Default \"warn\".",
|
|
@@ -224,7 +251,7 @@ const LintTable = Schema.Struct({
|
|
|
224
251
|
})),
|
|
225
252
|
verified_drift: Schema.optionalKey(LintLevel.annotate({
|
|
226
253
|
title: "verified-drift",
|
|
227
|
-
description:
|
|
254
|
+
description: `A concept's latest human verification no longer covers its current content: the body or authored frontmatter changed since, the binding (${INTEGRITY_KEY}.verified) is missing, a later human entry is unbound, or the bound verifier is not in a non-empty [actors].humans. Draft and deprecated concepts are exempt, since okfit verify refuses them. A signal to re-verify, not a gate. Default "warn".`,
|
|
228
255
|
default: "warn"
|
|
229
256
|
})),
|
|
230
257
|
status_missing: Schema.optionalKey(LintLevel.annotate({
|
|
@@ -237,31 +264,122 @@ const LintTable = Schema.Struct({
|
|
|
237
264
|
description: "A resource or sources[].resource path resolves neither in the bundle nor on disk relative to the concept (issue #106). Default \"warn\".",
|
|
238
265
|
default: "warn"
|
|
239
266
|
})),
|
|
267
|
+
resource_ignored: Schema.optionalKey(LintLevel.annotate({
|
|
268
|
+
title: "resource-ignored",
|
|
269
|
+
description: "A resource or sources[].resource path names a file that exists locally but is gitignored, so every other checkout sees it missing (issue #279). Skipped outside a git repository and under --skip-provenance. Default \"error\".",
|
|
270
|
+
default: "error"
|
|
271
|
+
})),
|
|
272
|
+
resource_untracked: Schema.optionalKey(LintLevel.annotate({
|
|
273
|
+
title: "resource-untracked",
|
|
274
|
+
description: "A resource or sources[].resource path names a file that exists locally but git does not track yet; not raised once the file is staged (issue #279). Skipped outside a git repository and under --skip-provenance. Default \"warn\".",
|
|
275
|
+
default: "warn"
|
|
276
|
+
})),
|
|
277
|
+
resource_outside_project: Schema.optionalKey(LintLevel.annotate({
|
|
278
|
+
title: "resource-outside-project",
|
|
279
|
+
description: "A resource value resolves outside the project root, directly or through a symlink, so okfit never reads, stats or asks git about the target (okfit's repository check, not OKF). Default \"info\".",
|
|
280
|
+
default: "info"
|
|
281
|
+
})),
|
|
282
|
+
superseded_by_orphan: Schema.optionalKey(LintLevel.annotate({
|
|
283
|
+
title: "superseded-by-orphan",
|
|
284
|
+
description: "A concept carries superseded_by but its status is not deprecated; superseded_by has a meaning only with status: deprecated (OKF 0.3 §5.4). Default \"warn\".",
|
|
285
|
+
default: "warn"
|
|
286
|
+
})),
|
|
287
|
+
superseded_by_unresolved: Schema.optionalKey(LintLevel.annotate({
|
|
288
|
+
title: "superseded-by-unresolved",
|
|
289
|
+
description: "A deprecated concept's superseded_by resolves to an asset, an external value or the concept itself rather than a replacement concept (OKF 0.3 §5.4). A missing target is reported by broken-links. Default \"warn\".",
|
|
290
|
+
default: "warn"
|
|
291
|
+
})),
|
|
240
292
|
generated_missing: Schema.optionalKey(LintLevel.annotate({
|
|
241
293
|
title: "generated-missing",
|
|
242
294
|
description: "A concept has no generated block while actors.agent is configured, so okfit sync cannot stamp generated.at until the block exists (issue #73). Default \"warn\"; silent when actors.agent is unset.",
|
|
243
295
|
default: "warn"
|
|
244
296
|
})),
|
|
297
|
+
computation_missing: Schema.optionalKey(LintLevel.annotate({
|
|
298
|
+
title: "computation-missing",
|
|
299
|
+
description: "An Attested Computation has no computation: no computation key, and nothing in its Computation section that the bundle's OKF version reads as one (under 0.3 the first fenced block, §10.3; under 0.2 the text of a top-level section), so it is not attestable. Default \"warn\".",
|
|
300
|
+
default: "warn"
|
|
301
|
+
})),
|
|
302
|
+
generated_at_future: Schema.optionalKey(LintLevel.annotate({
|
|
303
|
+
title: "generated-at-future",
|
|
304
|
+
description: "A concept's generated.at is more than 5 minutes later than now, so no verification can count yet (OKF 0.3 §5.3) and okfit verify refuses it; okfit sync re-stamps it. Default \"warn\".",
|
|
305
|
+
default: "warn"
|
|
306
|
+
})),
|
|
245
307
|
publication_drift: Schema.optionalKey(LintLevel.annotate({
|
|
246
308
|
title: "publication-drift",
|
|
247
|
-
description:
|
|
309
|
+
description: `A Publication's ${OKFIT_KEY_PREFIX}renders[].body is missing or no longer matches the current body of the concept it names, so the published page may restate stale facts. Default "warn".`,
|
|
248
310
|
default: "warn"
|
|
249
311
|
})),
|
|
250
312
|
publication_orphan: Schema.optionalKey(LintLevel.annotate({
|
|
251
313
|
title: "publication-orphan",
|
|
252
|
-
description:
|
|
314
|
+
description: `A Publication's ${OKFIT_KEY_PREFIX}surface or ${OKFIT_KEY_PREFIX}renders[].path does not resolve to a concept, or ${OKFIT_KEY_PREFIX}renders is not a list of { path, body } entries. Default "error".`,
|
|
253
315
|
default: "error"
|
|
254
316
|
})),
|
|
255
317
|
surface_unmatched: Schema.optionalKey(LintLevel.annotate({
|
|
256
318
|
title: "surface-unmatched",
|
|
257
319
|
description: "A Surface's resource glob matches no file or directory; legitimate in a brand-new monorepo, so it only warns. Default \"warn\".",
|
|
258
320
|
default: "warn"
|
|
321
|
+
})),
|
|
322
|
+
index_metadata_invalid: Schema.optionalKey(LintLevel.annotate({
|
|
323
|
+
title: "index-metadata-invalid",
|
|
324
|
+
description: "The bundle-root index.md frontmatter carries an okf_version that is not a quoted <major>.<minor> string, or a title, description or license that is not a string; the value is read best-effort. Default \"warn\".",
|
|
325
|
+
default: "warn"
|
|
326
|
+
})),
|
|
327
|
+
entry_ignored: Schema.optionalKey(LintLevel.annotate({
|
|
328
|
+
title: "entry-ignored",
|
|
329
|
+
description: "An entry or mapping the spec defines (a sources, verified or parameters entry, generated) lacks a REQUIRED key or has one okfit cannot read, so it is ignored (OKF 0.3 §11.2 rule 3). Default \"warn\".",
|
|
330
|
+
default: "warn"
|
|
331
|
+
})),
|
|
332
|
+
value_malformed: Schema.optionalKey(LintLevel.annotate({
|
|
333
|
+
title: "value-malformed",
|
|
334
|
+
description: "A defined value okfit cannot read in its defined shape (wrong type, unparsable timestamp, malformed optional key) is read as absent; a malformed stale_after reads as malformed, never fresh (OKF 0.3 §5.5, §11.2). Default \"warn\".",
|
|
335
|
+
default: "warn"
|
|
336
|
+
})),
|
|
337
|
+
value_unknown: Schema.optionalKey(LintLevel.annotate({
|
|
338
|
+
title: "value-unknown",
|
|
339
|
+
description: "A defined key carries a value outside its vocabulary (today: status); the value is kept and the concept is not read as current knowledge (OKF 0.3 §5.4, §11.2 rule 4). Default \"warn\".",
|
|
340
|
+
default: "warn"
|
|
341
|
+
})),
|
|
342
|
+
non_concept_unlisted: Schema.optionalKey(LintLevel.annotate({
|
|
343
|
+
title: "non-concept-unlisted",
|
|
344
|
+
description: "A .md file is not a concept (no frontmatter, or no type) and matches no glob in [bundle] non_concepts. An okfit opinion, not OKF conformance (§3.2 allows such files). Silent when non_concepts is absent. Default \"warn\".",
|
|
345
|
+
default: "warn"
|
|
259
346
|
}))
|
|
260
347
|
}).annotate({
|
|
261
348
|
title: "Lint severities",
|
|
262
349
|
description: "Per-code severity overrides. Any key omitted keeps its default."
|
|
263
350
|
});
|
|
264
351
|
/**
|
|
352
|
+
* Scan a glob once, left to right, for a `[` or `{` that never closes; the
|
|
353
|
+
* result is the rejection message tail naming the opener, or `undefined` when
|
|
354
|
+
* none is left open. A backslash escapes the next character; a class closes at
|
|
355
|
+
* the first `]` after at least one member, where a leading `!` or `^` is not a
|
|
356
|
+
* member (so `[]a]` and `[!]a]` are classes but `[]` and `[!]` are not) and a
|
|
357
|
+
* POSIX `[:name:]` inside it is one unit; a `{` inside a class is literal;
|
|
358
|
+
* braces are counted by depth. A stray `]` or `}` is literal text.
|
|
359
|
+
*/
|
|
360
|
+
const unclosedGlobMessage = (glob) => {
|
|
361
|
+
let depth = 0;
|
|
362
|
+
let classStart = -1;
|
|
363
|
+
let firstMember = -1;
|
|
364
|
+
for (let i = 0; i < glob.length; i++) {
|
|
365
|
+
const ch = glob[i];
|
|
366
|
+
if (ch === "\\") i++;
|
|
367
|
+
else if (classStart >= 0) {
|
|
368
|
+
if (ch === "[" && glob[i + 1] === ":") {
|
|
369
|
+
let j = i + 2;
|
|
370
|
+
while (j < glob.length && /[a-z]/.test(glob[j] ?? "")) j++;
|
|
371
|
+
if (j > i + 2 && glob[j] === ":" && glob[j + 1] === "]") i = j + 1;
|
|
372
|
+
} else if (ch === "]" && i > firstMember) classStart = -1;
|
|
373
|
+
} else if (ch === "[") {
|
|
374
|
+
classStart = i;
|
|
375
|
+
firstMember = glob[i + 1] === "!" || glob[i + 1] === "^" ? i + 2 : i + 1;
|
|
376
|
+
} else if (ch === "{") depth++;
|
|
377
|
+
else if (ch === "}" && depth > 0) depth--;
|
|
378
|
+
}
|
|
379
|
+
if (classStart >= 0) return `"[" opens a character class that never closes; to match a literal bracket write '\\[' in single quotes or "\\\\[" in double quotes`;
|
|
380
|
+
return depth > 0 ? `"{" opens a brace group that never closes; to match a literal brace write '\\{' in single quotes or "\\\\{" in double quotes` : void 0;
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
265
383
|
* The `OkfitConfig` struct schema. Exported only so the `OkfitConfigFields`
|
|
266
384
|
* type below is reachable from the rollup; the barrel never re-exports this
|
|
267
385
|
* value, so it stays out of the named public surface.
|
|
@@ -270,9 +388,8 @@ const LintTable = Schema.Struct({
|
|
|
270
388
|
const okfitConfigFields = Schema.Struct({
|
|
271
389
|
okf_version: Schema.optionalKey(Schema.String.annotate({
|
|
272
390
|
title: "OKF spec version",
|
|
273
|
-
description: "The
|
|
274
|
-
|
|
275
|
-
examples: ["0.2"]
|
|
391
|
+
description: "The okf_version okfit writes into a bundle-root index.md that declares none (okfit init, okfit sync). The bundle's own declaration decides how it is read. When the root index.md declares a different version, the lint config-okf-version-stale reports this value as stale.",
|
|
392
|
+
examples: ["0.3"]
|
|
276
393
|
})),
|
|
277
394
|
bundle: Schema.optionalKey(Schema.Struct({
|
|
278
395
|
path: Schema.optionalKey(Schema.String.annotate({
|
|
@@ -286,6 +403,16 @@ const okfitConfigFields = Schema.Struct({
|
|
|
286
403
|
description: "The named profile merged under `DEFAULTS < profile < file`, or \"none\" to disable profile merging.",
|
|
287
404
|
default: "software-project",
|
|
288
405
|
examples: ["software-project", "none"]
|
|
406
|
+
})),
|
|
407
|
+
non_concepts: Schema.optionalKey(Schema.Array(Schema.String.check(Schema.makeFilter((value) => {
|
|
408
|
+
const unclosed = unclosedGlobMessage(value);
|
|
409
|
+
if (unclosed !== void 0) return `Expected a valid glob pattern, got ${JSON.stringify(value)}: ${unclosed}`;
|
|
410
|
+
const compiled = GlobPattern.compileResult(value);
|
|
411
|
+
return Result.isSuccess(compiled) || `Expected a valid glob pattern, got ${JSON.stringify(value)}`;
|
|
412
|
+
}))).annotate({
|
|
413
|
+
title: "Non-concept Markdown",
|
|
414
|
+
description: "Globs, relative to the bundle root, of .md files that may have no frontmatter or no type (OKF 0.3 §3.2 lets a bundle hold README.md, AGENTS.md, CONTRIBUTING.md and SKILL.md). A `[` or `{` that never closes is rejected; to match the character itself write '\\[' in single quotes or \"\\\\[\" in double quotes. When set, any other typeless .md is the lint non-concept-unlisted, and the okfit plugin's hook stops an agent writing one. Absent: no restriction.",
|
|
415
|
+
examples: [["**/README.md", "**/AGENTS.md"]]
|
|
289
416
|
}))
|
|
290
417
|
}).annotate({
|
|
291
418
|
title: "Bundle location and profile",
|
|
@@ -428,6 +555,7 @@ const LINT_KEY = {
|
|
|
428
555
|
"required-key-missing": "required_key_missing",
|
|
429
556
|
"field-value-unknown": "field_value_unknown",
|
|
430
557
|
"require-verified-unmet": "require_verified_unmet",
|
|
558
|
+
"verified-before-change": "verified_before_change",
|
|
431
559
|
"family-invalid": "family_invalid",
|
|
432
560
|
"computation-runtime-missing": "computation_runtime_missing",
|
|
433
561
|
"footnote-source-unknown": "footnote_source_unknown",
|
|
@@ -438,16 +566,32 @@ const LINT_KEY = {
|
|
|
438
566
|
"verified-actor-unknown": "verified_actor_unknown",
|
|
439
567
|
"legacy-timestamp": "legacy_timestamp",
|
|
440
568
|
"config-unknown-key": "config_unknown_key",
|
|
569
|
+
"config-okf-version-stale": "config_okf_version_stale",
|
|
441
570
|
stale: "stale",
|
|
442
571
|
"walk-unreadable": "walk_unreadable",
|
|
443
572
|
"generated-at-drift": "generated_at_drift",
|
|
444
573
|
"verified-drift": "verified_drift",
|
|
445
574
|
"status-missing": "status_missing",
|
|
446
575
|
"source-resource-missing": "source_resource_missing",
|
|
576
|
+
"resource-ignored": "resource_ignored",
|
|
577
|
+
"resource-untracked": "resource_untracked",
|
|
578
|
+
"resource-outside-project": "resource_outside_project",
|
|
579
|
+
"superseded-by-orphan": "superseded_by_orphan",
|
|
580
|
+
"superseded-by-unresolved": "superseded_by_unresolved",
|
|
447
581
|
"generated-missing": "generated_missing",
|
|
582
|
+
"computation-missing": "computation_missing",
|
|
583
|
+
"generated-at-future": "generated_at_future",
|
|
448
584
|
"publication-drift": "publication_drift",
|
|
449
585
|
"publication-orphan": "publication_orphan",
|
|
450
|
-
"surface-unmatched": "surface_unmatched"
|
|
586
|
+
"surface-unmatched": "surface_unmatched",
|
|
587
|
+
"index-metadata-invalid": "index_metadata_invalid",
|
|
588
|
+
"entry-ignored": "entry_ignored",
|
|
589
|
+
"value-malformed": "value_malformed",
|
|
590
|
+
"value-unknown": "value_unknown",
|
|
591
|
+
"frontmatter-missing": "frontmatter_missing",
|
|
592
|
+
"type-missing": "type_missing",
|
|
593
|
+
"symlink-escape": "symlink_escape",
|
|
594
|
+
"non-concept-unlisted": "non_concept_unlisted"
|
|
451
595
|
};
|
|
452
596
|
const DEFAULT_LINT = {
|
|
453
597
|
broken_links: "warn",
|
|
@@ -456,6 +600,7 @@ const DEFAULT_LINT = {
|
|
|
456
600
|
required_key_missing: "error",
|
|
457
601
|
field_value_unknown: "error",
|
|
458
602
|
require_verified_unmet: "error",
|
|
603
|
+
verified_before_change: "warn",
|
|
459
604
|
family_invalid: "error",
|
|
460
605
|
computation_runtime_missing: "error",
|
|
461
606
|
footnote_source_unknown: "warn",
|
|
@@ -466,16 +611,32 @@ const DEFAULT_LINT = {
|
|
|
466
611
|
verified_actor_unknown: "warn",
|
|
467
612
|
legacy_timestamp: "info",
|
|
468
613
|
config_unknown_key: "warn",
|
|
614
|
+
config_okf_version_stale: "warn",
|
|
469
615
|
stale: "info",
|
|
470
616
|
walk_unreadable: "warn",
|
|
471
617
|
generated_at_drift: "warn",
|
|
472
618
|
verified_drift: "warn",
|
|
473
619
|
status_missing: "off",
|
|
474
620
|
source_resource_missing: "warn",
|
|
621
|
+
resource_ignored: "error",
|
|
622
|
+
resource_untracked: "warn",
|
|
623
|
+
resource_outside_project: "info",
|
|
624
|
+
superseded_by_orphan: "warn",
|
|
625
|
+
superseded_by_unresolved: "warn",
|
|
475
626
|
generated_missing: "warn",
|
|
627
|
+
computation_missing: "warn",
|
|
628
|
+
generated_at_future: "warn",
|
|
476
629
|
publication_drift: "warn",
|
|
477
630
|
publication_orphan: "error",
|
|
478
|
-
surface_unmatched: "warn"
|
|
631
|
+
surface_unmatched: "warn",
|
|
632
|
+
index_metadata_invalid: "warn",
|
|
633
|
+
entry_ignored: "warn",
|
|
634
|
+
value_malformed: "warn",
|
|
635
|
+
value_unknown: "warn",
|
|
636
|
+
frontmatter_missing: "warn",
|
|
637
|
+
type_missing: "warn",
|
|
638
|
+
symlink_escape: "warn",
|
|
639
|
+
non_concept_unlisted: "warn"
|
|
479
640
|
};
|
|
480
641
|
const toSeverity = (level) => level === "warn" ? "warning" : level;
|
|
481
642
|
const severityFor = (config, code) => {
|
|
@@ -496,7 +657,6 @@ const deepFreeze = (value) => {
|
|
|
496
657
|
return value;
|
|
497
658
|
};
|
|
498
659
|
const DEFAULTS = deepFreeze({
|
|
499
|
-
okf_version: "0.2",
|
|
500
660
|
bundle: {
|
|
501
661
|
path: "okf",
|
|
502
662
|
profile: "software-project"
|
|
@@ -514,7 +674,8 @@ const DEFAULTS = deepFreeze({
|
|
|
514
674
|
});
|
|
515
675
|
const read = (path) => ConfigFile.read(path, {
|
|
516
676
|
schema: OkfitConfigWire,
|
|
517
|
-
codec: TomlCodec
|
|
677
|
+
codec: TomlCodec,
|
|
678
|
+
parseOptions: { errors: "all" }
|
|
518
679
|
}).pipe(Effect.withSpan("OkfitConfig.read", { attributes: { path } }));
|
|
519
680
|
/**
|
|
520
681
|
* The okfit config codec and its statics (spec 4.2, D-28 to D-31).
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @okfit/core
|
|
2
2
|
|
|
3
|
-
Spec-level [Open Knowledge Format (OKF)](https://github.com/
|
|
3
|
+
Spec-level [Open Knowledge Format (OKF)](https://github.com/open-knowledge-format/open-knowledge-format/blob/main/SPEC.md) v0.3 support for [Effect](https://effect.website): frontmatter schemas, bundle loading, the concept link graph, trust and staleness derivation, and conformance validation.
|
|
4
4
|
|
|
5
5
|
> **Pre-release.** Part of the `@okfit/*` kit, in early development against a single pinned Effect v4 prerelease.
|
|
6
6
|
|
|
@@ -23,7 +23,9 @@ const program = Effect.gen(function* () {
|
|
|
23
23
|
});
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
`
|
|
26
|
+
`Derive.trustTier` follows OKF 0.3 §5.3 and §7: only current verification events count (`at` equal to or later than `generated.at`, or any event when `generated` or `generated.at` is absent), and only a `human:` verifier gives `human-reviewed`; `team:` and other schemes give `machine-confirmed`. This holds for every bundle whatever `okf_version` it declares. `Derive.isCurrent` and `Derive.currentVerifications` expose the rule, and the `verified-before-change` lint (default `warn`) reports a concept that has a `generated.at` and whose tier dropped because its verification predates it (draft, deprecated and unknown-status concepts are exempt).
|
|
27
|
+
|
|
28
|
+
`Bundle.load` needs `FileSystem` and `Path`; `OkfitConfig.read` needs `FileSystem`. Loading never fails on content: bad files become `Diagnostic`s. `Graph.fromBundle` treats a path-valued field or link whose target, resolved from its concept's directory, lands outside the bundle root as an external reference: no graph node and no `broken-links` diagnostic, exactly like a URL. `OkfitConfig` decodes the spec 4.2 TOML shape; unknown top-level keys are kept in `extensions` and reported by `Validate.lint` as `config-unknown-key`. `[bundle] non_concepts` globs must compile, and a `[` or `{` that never closes is rejected at decode (to match the character write '\[' in single quotes or "\\[" in double quotes). `lifecycle.default_stale_after` accepts `90d`, `12h`, `2w`, or `"90 days"`. `OkfitConfig.merge` deep-merges tables; arrays and scalars in `override` replace wholesale. Apply `DEFAULTS < profile < file` yourself. `OkfitConfigFile` is the service tag; the CLI provides its layer. `okfitConfigDocumentFields` is `okfitConfigFields` minus `extensions` (wire bookkeeping no human writes), with an open rest so unknown top-level keys stay permitted while every declared table stays closed; it is the single source `@okfit/engine`'s `lib/configs/schemastore.config.ts` builds the published JSON Schema (`schemas/1.0/config.json`) from via `effected schema`, and carries no annotations of its own beyond what each field already declares in `OkfitConfig.ts`. The document's `HostedSchema` identity (`okfitConfigSchemaHost`, the same `$id` `okfit init` stamps into a fresh config's `#:schema` directive) lives in `@okfit/engine`, not here — core stays free of a runtime `@effected/schemastore` dependency. The `[lint]` table's forty-three keys include `generated_at_drift` (default `"warn"`), which fires when a committed concept's `generated.at` no longer matches the instant its body was last changed AND is not otherwise authoritative (issue #19: a stamp recorded during the unchanged-body run survives a squash/rebase merge) — computed by `okfit sync`/`okfit validate`, never by core itself.
|
|
27
29
|
|
|
28
30
|
## License
|
|
29
31
|
|
package/Source.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { Actor } from "./Actor.js";
|
|
2
3
|
import { Timestamp } from "./Timestamp.js";
|
|
3
|
-
import { Schema } from "effect";
|
|
4
4
|
|
|
5
5
|
// src/Source.ts
|
|
6
6
|
/**
|
|
@@ -8,8 +8,8 @@ import { Schema } from "effect";
|
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
var UsageWindow = class extends Schema.Class("UsageWindow")({
|
|
11
|
-
from: Timestamp,
|
|
12
|
-
to: Timestamp
|
|
11
|
+
from: Schema.optionalKey(Timestamp),
|
|
12
|
+
to: Schema.optionalKey(Timestamp)
|
|
13
13
|
}) {};
|
|
14
14
|
/**
|
|
15
15
|
* One provenance entry. `resource` is a URL, a bundle path or a scope descriptor (D-24); never resolved here.
|
package/Status.js
CHANGED
|
@@ -10,5 +10,16 @@ const Status = Schema.Literals([
|
|
|
10
10
|
"stable",
|
|
11
11
|
"deprecated"
|
|
12
12
|
]);
|
|
13
|
+
/**
|
|
14
|
+
* What `Derive.status` reads: the three known values, or `unknown` for a `status` outside the
|
|
15
|
+
* vocabulary (OKF 0.3 §5.4). `unknown` is never written; `Status` is the write vocabulary.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
const DerivedStatus = Schema.Literals([
|
|
19
|
+
"draft",
|
|
20
|
+
"stable",
|
|
21
|
+
"deprecated",
|
|
22
|
+
"unknown"
|
|
23
|
+
]);
|
|
13
24
|
|
|
14
|
-
export { Status };
|
|
25
|
+
export { DerivedStatus, Status };
|
package/Timestamp.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema, SchemaTransformation } from "effect";
|
|
2
2
|
|
|
3
3
|
// src/Timestamp.ts
|
|
4
4
|
const OFFSET_RE = /(?:Z|[+-]\d{2}:\d{2})$/u;
|
|
5
|
+
const DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/u;
|
|
6
|
+
const isCalendarDay = (value) => {
|
|
7
|
+
const [year, month, day] = value.split("-").map(Number);
|
|
8
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
9
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
10
|
+
};
|
|
5
11
|
const ZERO_MILLIS = /\.000(?=Z$)/;
|
|
6
12
|
/**
|
|
7
13
|
* ISO 8601 string with an explicit offset (`Z`, `+hh:mm` or `-hh:mm`) to `DateTime.Utc`.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
14
|
+
* A date-only `YYYY-MM-DD` value (OKF 0.3 section 5) reads as the start of that day in UTC; an impossible
|
|
15
|
+
* calendar day fails. Offset-less date-times fail before parsing and are reported as `value-malformed`.
|
|
16
|
+
* Encoding always writes a date-time: `2026-03-01T08:00:00Z` for a whole second, non-zero milliseconds kept.
|
|
10
17
|
* @public
|
|
11
18
|
*/
|
|
12
|
-
const Timestamp = Schema.String.pipe(Schema.check(Schema.
|
|
13
|
-
decode:
|
|
19
|
+
const Timestamp = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => OFFSET_RE.test(value) || DATE_ONLY_RE.test(value) && isCalendarDay(value) || "Expected an ISO 8601 timestamp with an explicit offset (Z, +hh:mm or -hh:mm) or a calendar date (YYYY-MM-DD)")), Schema.decodeTo(Schema.String, SchemaTransformation.transform({
|
|
20
|
+
decode: (value) => DATE_ONLY_RE.test(value) ? `${value}T00:00:00Z` : value,
|
|
14
21
|
encode: (iso) => iso.replace(ZERO_MILLIS, "")
|
|
15
22
|
})), Schema.decodeTo(Schema.DateTimeUtcFromString));
|
|
16
23
|
|
package/Validate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { Diagnostic, LintCode } from "./Diagnostic.js";
|
|
2
3
|
import { Graph as Graph$1 } from "./Graph.js";
|
|
3
4
|
import { LINT_RULES } from "./internal/lintRules.js";
|
|
4
5
|
import { OkfitConfig } from "./OkfitConfig.js";
|
|
5
|
-
import { Schema } from "effect";
|
|
6
6
|
|
|
7
7
|
// src/Validate.ts
|
|
8
8
|
const isLintCode = Schema.is(LintCode);
|
|
@@ -29,6 +29,7 @@ var Validate = class Validate {
|
|
|
29
29
|
config,
|
|
30
30
|
graph: Graph$1.fromBundle(bundle),
|
|
31
31
|
now: options.now,
|
|
32
|
+
configPath: options.configPath,
|
|
32
33
|
severity
|
|
33
34
|
};
|
|
34
35
|
return [...loadTime, ...LINT_RULES.flatMap((rule) => rule(context))];
|
package/Verification.js
CHANGED