@okfit/core 0.14.0 → 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 +87 -11
- package/Concept.js +30 -2
- package/Derive.js +80 -14
- package/Diagnostic.js +16 -3
- package/Generated.js +1 -1
- package/GeneratedAtFuture.js +33 -0
- package/Graph.js +47 -12
- package/IndexDocument.js +8 -1
- package/Integrity.js +13 -2
- package/OkfVersion.js +40 -0
- package/OkfitConfig.js +162 -15
- package/README.md +4 -2
- package/Source.js +2 -2
- package/Status.js +12 -1
- package/Timestamp.js +12 -5
- package/Validate.js +1 -0
- package/index.d.ts +314 -35
- package/index.js +7 -5
- package/internal/conceptDecode.js +230 -32
- package/internal/frontmatter.js +18 -5
- package/internal/links.js +10 -8
- package/internal/lintRules.js +153 -24
- package/internal/reserved.js +31 -7
- package/internal/templates.js +27 -5
- package/internal/tier.js +7 -0
- package/package.json +3 -3
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
1
|
import { ConfigFile, ConfigMerge } from "@effected/config-file";
|
|
2
2
|
import { TomlCodec } from "@effected/config-file/toml";
|
|
3
|
+
import { GlobPattern } from "@effected/glob";
|
|
3
4
|
import { HostedSchema } from "@effected/schemastore";
|
|
4
|
-
import { Duration, Effect, Option, Schema, SchemaGetter, SchemaIssue, SchemaTransformation } from "effect";
|
|
5
|
+
import { Duration, Effect, Option, Result, Schema, SchemaGetter, SchemaIssue, SchemaTransformation } from "effect";
|
|
5
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({
|
|
@@ -247,31 +274,112 @@ const LintTable = Schema.Struct({
|
|
|
247
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\".",
|
|
248
275
|
default: "warn"
|
|
249
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
|
+
})),
|
|
250
292
|
generated_missing: Schema.optionalKey(LintLevel.annotate({
|
|
251
293
|
title: "generated-missing",
|
|
252
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.",
|
|
253
295
|
default: "warn"
|
|
254
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
|
+
})),
|
|
255
307
|
publication_drift: Schema.optionalKey(LintLevel.annotate({
|
|
256
308
|
title: "publication-drift",
|
|
257
|
-
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".`,
|
|
258
310
|
default: "warn"
|
|
259
311
|
})),
|
|
260
312
|
publication_orphan: Schema.optionalKey(LintLevel.annotate({
|
|
261
313
|
title: "publication-orphan",
|
|
262
|
-
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".`,
|
|
263
315
|
default: "error"
|
|
264
316
|
})),
|
|
265
317
|
surface_unmatched: Schema.optionalKey(LintLevel.annotate({
|
|
266
318
|
title: "surface-unmatched",
|
|
267
319
|
description: "A Surface's resource glob matches no file or directory; legitimate in a brand-new monorepo, so it only warns. Default \"warn\".",
|
|
268
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"
|
|
269
346
|
}))
|
|
270
347
|
}).annotate({
|
|
271
348
|
title: "Lint severities",
|
|
272
349
|
description: "Per-code severity overrides. Any key omitted keeps its default."
|
|
273
350
|
});
|
|
274
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
|
+
/**
|
|
275
383
|
* The `OkfitConfig` struct schema. Exported only so the `OkfitConfigFields`
|
|
276
384
|
* type below is reachable from the rollup; the barrel never re-exports this
|
|
277
385
|
* value, so it stays out of the named public surface.
|
|
@@ -280,9 +388,8 @@ const LintTable = Schema.Struct({
|
|
|
280
388
|
const okfitConfigFields = Schema.Struct({
|
|
281
389
|
okf_version: Schema.optionalKey(Schema.String.annotate({
|
|
282
390
|
title: "OKF spec version",
|
|
283
|
-
description: "The
|
|
284
|
-
|
|
285
|
-
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"]
|
|
286
393
|
})),
|
|
287
394
|
bundle: Schema.optionalKey(Schema.Struct({
|
|
288
395
|
path: Schema.optionalKey(Schema.String.annotate({
|
|
@@ -296,6 +403,16 @@ const okfitConfigFields = Schema.Struct({
|
|
|
296
403
|
description: "The named profile merged under `DEFAULTS < profile < file`, or \"none\" to disable profile merging.",
|
|
297
404
|
default: "software-project",
|
|
298
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"]]
|
|
299
416
|
}))
|
|
300
417
|
}).annotate({
|
|
301
418
|
title: "Bundle location and profile",
|
|
@@ -438,6 +555,7 @@ const LINT_KEY = {
|
|
|
438
555
|
"required-key-missing": "required_key_missing",
|
|
439
556
|
"field-value-unknown": "field_value_unknown",
|
|
440
557
|
"require-verified-unmet": "require_verified_unmet",
|
|
558
|
+
"verified-before-change": "verified_before_change",
|
|
441
559
|
"family-invalid": "family_invalid",
|
|
442
560
|
"computation-runtime-missing": "computation_runtime_missing",
|
|
443
561
|
"footnote-source-unknown": "footnote_source_unknown",
|
|
@@ -448,6 +566,7 @@ const LINT_KEY = {
|
|
|
448
566
|
"verified-actor-unknown": "verified_actor_unknown",
|
|
449
567
|
"legacy-timestamp": "legacy_timestamp",
|
|
450
568
|
"config-unknown-key": "config_unknown_key",
|
|
569
|
+
"config-okf-version-stale": "config_okf_version_stale",
|
|
451
570
|
stale: "stale",
|
|
452
571
|
"walk-unreadable": "walk_unreadable",
|
|
453
572
|
"generated-at-drift": "generated_at_drift",
|
|
@@ -456,10 +575,23 @@ const LINT_KEY = {
|
|
|
456
575
|
"source-resource-missing": "source_resource_missing",
|
|
457
576
|
"resource-ignored": "resource_ignored",
|
|
458
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",
|
|
459
581
|
"generated-missing": "generated_missing",
|
|
582
|
+
"computation-missing": "computation_missing",
|
|
583
|
+
"generated-at-future": "generated_at_future",
|
|
460
584
|
"publication-drift": "publication_drift",
|
|
461
585
|
"publication-orphan": "publication_orphan",
|
|
462
|
-
"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"
|
|
463
595
|
};
|
|
464
596
|
const DEFAULT_LINT = {
|
|
465
597
|
broken_links: "warn",
|
|
@@ -468,6 +600,7 @@ const DEFAULT_LINT = {
|
|
|
468
600
|
required_key_missing: "error",
|
|
469
601
|
field_value_unknown: "error",
|
|
470
602
|
require_verified_unmet: "error",
|
|
603
|
+
verified_before_change: "warn",
|
|
471
604
|
family_invalid: "error",
|
|
472
605
|
computation_runtime_missing: "error",
|
|
473
606
|
footnote_source_unknown: "warn",
|
|
@@ -478,6 +611,7 @@ const DEFAULT_LINT = {
|
|
|
478
611
|
verified_actor_unknown: "warn",
|
|
479
612
|
legacy_timestamp: "info",
|
|
480
613
|
config_unknown_key: "warn",
|
|
614
|
+
config_okf_version_stale: "warn",
|
|
481
615
|
stale: "info",
|
|
482
616
|
walk_unreadable: "warn",
|
|
483
617
|
generated_at_drift: "warn",
|
|
@@ -486,10 +620,23 @@ const DEFAULT_LINT = {
|
|
|
486
620
|
source_resource_missing: "warn",
|
|
487
621
|
resource_ignored: "error",
|
|
488
622
|
resource_untracked: "warn",
|
|
623
|
+
resource_outside_project: "info",
|
|
624
|
+
superseded_by_orphan: "warn",
|
|
625
|
+
superseded_by_unresolved: "warn",
|
|
489
626
|
generated_missing: "warn",
|
|
627
|
+
computation_missing: "warn",
|
|
628
|
+
generated_at_future: "warn",
|
|
490
629
|
publication_drift: "warn",
|
|
491
630
|
publication_orphan: "error",
|
|
492
|
-
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"
|
|
493
640
|
};
|
|
494
641
|
const toSeverity = (level) => level === "warn" ? "warning" : level;
|
|
495
642
|
const severityFor = (config, code) => {
|
|
@@ -510,7 +657,6 @@ const deepFreeze = (value) => {
|
|
|
510
657
|
return value;
|
|
511
658
|
};
|
|
512
659
|
const DEFAULTS = deepFreeze({
|
|
513
|
-
okf_version: "0.2",
|
|
514
660
|
bundle: {
|
|
515
661
|
path: "okf",
|
|
516
662
|
profile: "software-project"
|
|
@@ -528,7 +674,8 @@ const DEFAULTS = deepFreeze({
|
|
|
528
674
|
});
|
|
529
675
|
const read = (path) => ConfigFile.read(path, {
|
|
530
676
|
schema: OkfitConfigWire,
|
|
531
|
-
codec: TomlCodec
|
|
677
|
+
codec: TomlCodec,
|
|
678
|
+
parseOptions: { errors: "all" }
|
|
532
679
|
}).pipe(Effect.withSpan("OkfitConfig.read", { attributes: { path } }));
|
|
533
680
|
/**
|
|
534
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
|
@@ -8,8 +8,8 @@ import { Timestamp } from "./Timestamp.js";
|
|
|
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
|
|