@okfit/core 0.9.2 → 0.11.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 CHANGED
@@ -10,6 +10,13 @@ const form = (actor) => {
10
10
  const prefix = colon === -1 ? "" : actor.slice(0, colon);
11
11
  return prefix === "human" ? "human" : prefix === "process" ? "process" : "other";
12
12
  };
13
+ const GLOB_RE = /[*?]/u;
14
+ const ESCAPE_RE = /[.+^${}()|[\]\\/]/gu;
15
+ /** `*` is any run of non-whitespace, `?` one non-whitespace character; everything else is literal. */
16
+ const patternRegExp = (pattern) => new RegExp(`^${[...pattern].map((char) => char === "*" ? "\\S*" : char === "?" ? "\\S" : char.replace(ESCAPE_RE, "\\$&")).join("")}$`, "iu");
17
+ const isPattern = (value) => GLOB_RE.test(value);
18
+ const matches = (actor, pattern) => patternRegExp(pattern).test(actor);
19
+ const allowed = (actor, humans) => humans.length === 0 || humans.some((pattern) => matches(actor, pattern));
13
20
  /**
14
21
  * Branded, pattern-checked actor codec with prefix classification statics.
15
22
  * @public
@@ -24,8 +31,20 @@ const Actor = Object.assign(Schema.String.pipe(Schema.check(Schema.isPattern(ACT
24
31
  ]
25
32
  }), {
26
33
  isHuman,
27
- form
34
+ form,
35
+ matches,
36
+ allowed,
37
+ isPattern
38
+ });
39
+ /**
40
+ * Branded, pattern-checked `[actors].humans` entry codec.
41
+ * @public
42
+ */
43
+ const ActorPattern = Schema.String.pipe(Schema.check(Schema.isPattern(ACTOR_RE, { message: "Expected <prefix>:<id> (globs * and ? allowed in the id) with no whitespace" })), Schema.brand("ActorPattern")).annotate({
44
+ title: "Actor or actor glob",
45
+ description: "An actor id (\"human:spencer\") or an id glob (\"human:spencer*\"; * matches any run of characters, ? one), matched case-insensitively.",
46
+ examples: ["human:spencer", "human:spencer*"]
28
47
  });
29
48
 
30
49
  //#endregion
31
- export { Actor };
50
+ export { Actor, ActorPattern };
package/Concept.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AttestedComputation } from "./AttestedComputation.js";
2
2
  import { Timestamp } from "./Timestamp.js";
3
3
  import { Generated } from "./Generated.js";
4
+ import { Integrity } from "./Integrity.js";
4
5
  import { Source, UsageWindow } from "./Source.js";
5
6
  import { Status } from "./Status.js";
6
7
  import { Verification } from "./Verification.js";
@@ -35,6 +36,7 @@ var Concept = class extends Schema.Class("Concept")({
35
36
  verified: Schema.optionalKey(Verification.List),
36
37
  status: Schema.optionalKey(Status),
37
38
  stale_after: Schema.optionalKey(Timestamp),
39
+ integrity: Schema.optionalKey(Integrity),
38
40
  attested: Schema.optionalKey(AttestedComputation),
39
41
  extensions: Schema.Record(Schema.String, Schema.Unknown),
40
42
  raw: Schema.Record(Schema.String, Schema.Unknown)
package/Derive.js CHANGED
@@ -102,6 +102,19 @@ var Derive = class Derive {
102
102
  if (groups.length === 0) return `# ${title}\n`;
103
103
  return `# ${title}\n\n${groups.map(Derive.renderLogEntry).join("\n")}`;
104
104
  };
105
+ /**
106
+ * Every directory that owes an `index.md`: each directory holding a concept, plus its ancestors up to
107
+ * (not including) the bundle root, which a parent index links to even when it holds no concept itself.
108
+ * The root (`""`) is included only when it holds a concept. Sorted.
109
+ */
110
+ static indexDirectories = (bundle) => {
111
+ const dirs = /* @__PURE__ */ new Set();
112
+ for (const dir of bundle.directories) {
113
+ dirs.add(dir);
114
+ for (let ancestor = dirnameOf(dir); ancestor !== ""; ancestor = dirnameOf(ancestor)) dirs.add(ancestor);
115
+ }
116
+ return [...dirs].sort();
117
+ };
105
118
  /** Index text for `dir` from the concepts directly in it plus its immediate child directories; no frontmatter. */
106
119
  static synthesizeIndex = (bundle, dir) => {
107
120
  const prefix = dir === "" ? "" : `${dir}/`;
package/Diagnostic.js CHANGED
@@ -44,7 +44,10 @@ const LintCode = Schema.Literals([
44
44
  "generated-missing",
45
45
  "publication-drift",
46
46
  "publication-orphan",
47
- "surface-unmatched"
47
+ "surface-unmatched",
48
+ "verified-drift",
49
+ "actor-email",
50
+ "verified-actor-unknown"
48
51
  ]);
49
52
  /** @public */
50
53
  const DiagnosticCode = Schema.Union([ConformanceCode, LintCode]);
package/Generated.js CHANGED
@@ -3,14 +3,6 @@ import { Timestamp } from "./Timestamp.js";
3
3
  import { Schema } from "effect";
4
4
 
5
5
  //#region src/Generated.ts
6
- const SHA256_HEX_RE = /^[0-9a-f]{64}$/u;
7
- /**
8
- * A lowercase 64-character hex sha256 digest of a concept's body, as `@okfit/profiles`'
9
- * `Derivation.bodyDigest` computes it (issue #19). Optional: every concept stamped before
10
- * this field existed lacks it, and core itself never computes one -- it only holds the field.
11
- * @public
12
- */
13
- const BodySha256 = Schema.String.pipe(Schema.check(Schema.isPattern(SHA256_HEX_RE, { message: "Expected a lowercase 64-character hex sha256 digest" })));
14
6
  /**
15
7
  * Who last generated a concept's content, and when.
16
8
  * @public
@@ -18,11 +10,16 @@ const BodySha256 = Schema.String.pipe(Schema.check(Schema.isPattern(SHA256_HEX_R
18
10
  var Generated = class extends Schema.Class("Generated")({
19
11
  by: Actor,
20
12
  at: Schema.optionalKey(Timestamp),
21
- body_sha256: Schema.optionalKey(BodySha256)
13
+ /**
14
+ * Legacy (pre-integrity) body digest, read only as a migration fallback and never
15
+ * written. Lenient on purpose: a malformed legacy value must never fail the
16
+ * `generated` family and drop `by`/`at`. `okfit sync` moves it to `integrity.generated.body`.
17
+ */
18
+ body_sha256: Schema.optionalKey(Schema.String)
22
19
  }) {
23
20
  /** The `by` used when a legacy v0.1 `timestamp` is folded into `generated.at` (D-15); v0.1 has no actor. */
24
21
  static LEGACY_BY = "process:legacy-timestamp";
25
22
  };
26
23
 
27
24
  //#endregion
28
- export { BodySha256, Generated };
25
+ export { Generated };
package/Graph.js CHANGED
@@ -116,6 +116,18 @@ var LinkGraph = class LinkGraph {
116
116
  return [...new Set(pick(this.graph, at))].flatMap((next) => Option.toArray(Graph.getNode(this.graph, next)));
117
117
  }
118
118
  };
119
+ const indexes = /* @__PURE__ */ new WeakMap();
120
+ /** The lookup sets for one loaded bundle, built once: a bundle is immutable after load. */
121
+ const indexOf = (bundle) => {
122
+ const cached = indexes.get(bundle);
123
+ if (cached !== void 0) return cached;
124
+ const built = {
125
+ files: new Set(bundle.files),
126
+ concepts: new Set(bundle.concepts.keys())
127
+ };
128
+ indexes.set(bundle, built);
129
+ return built;
130
+ };
119
131
  /**
120
132
  * Static facade building a {@link LinkGraph} from a loaded bundle (D-6).
121
133
  *
@@ -124,6 +136,14 @@ var LinkGraph = class LinkGraph {
124
136
  var Graph$1 = class {
125
137
  constructor() {}
126
138
  /**
139
+ * Pure. Resolve `raw`, written in the file at bundle-relative `from`, the way the graph does; `field`
140
+ * applies the path-field rules (a `sources.resource` descriptor).
141
+ */
142
+ static resolve = (bundle, from, raw, field) => {
143
+ const lookup = indexOf(bundle);
144
+ return field === void 0 ? resolveTarget(from, raw, lookup) : resolvePathField(from, field, raw, lookup);
145
+ };
146
+ /**
127
147
  * Pure. Body links come from `document.links`, path fields from the frontmatter (D-23, D-24).
128
148
  * Placeholder `missing` nodes are added before their edge because `Graph.addEdge` throws on an absent endpoint.
129
149
  */
package/Integrity.js ADDED
@@ -0,0 +1,40 @@
1
+ import { Actor } from "./Actor.js";
2
+ import { Timestamp } from "./Timestamp.js";
3
+ import { Schema } from "effect";
4
+
5
+ //#region src/Integrity.ts
6
+ const DIGEST_RE = /^[0-9a-f]{16}$/u;
7
+ /**
8
+ * An okfit digest: the first 16 lowercase hex characters (64 bits) of SHA-256 over the
9
+ * input bytes `@okfit/profiles` defines. A signal, not a tamper seal. Core holds the
10
+ * shape and never computes one.
11
+ * @public
12
+ */
13
+ const Digest = Schema.String.pipe(Schema.check(Schema.isPattern(DIGEST_RE, { message: "Expected a lowercase 16-character hex digest" })));
14
+ /**
15
+ * The body digest as of `generated.at`.
16
+ * @public
17
+ */
18
+ var IntegrityGenerated = class extends Schema.Class("IntegrityGenerated")({ body: Digest }) {};
19
+ /**
20
+ * Binds one `human:` `verified` entry (joined on `by` and `at`) to the content it covered.
21
+ * @public
22
+ */
23
+ var IntegrityVerified = class extends Schema.Class("IntegrityVerified")({
24
+ by: Actor,
25
+ at: Timestamp,
26
+ content: Digest
27
+ }) {};
28
+ /**
29
+ * okfit's own top-level frontmatter family, the only place okfit stores digests
30
+ * (OKF v0.2 section 4.1 extension key). Spec families such as `generated` and
31
+ * `verified` stay exactly as the spec defines them.
32
+ * @public
33
+ */
34
+ var Integrity = class extends Schema.Class("Integrity")({
35
+ generated: Schema.optionalKey(IntegrityGenerated),
36
+ verified: Schema.optionalKey(IntegrityVerified)
37
+ }) {};
38
+
39
+ //#endregion
40
+ export { Digest, Integrity, IntegrityGenerated, IntegrityVerified };
package/OkfitConfig.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Actor } from "./Actor.js";
1
+ import { Actor, ActorPattern } from "./Actor.js";
2
2
  import { Duration, Effect, Option, Schema, SchemaGetter, SchemaIssue, SchemaTransformation } from "effect";
3
3
  import { ConfigFile, TomlCodec } from "@effected/config-file";
4
4
  import { HostedSchema } from "@effected/schemastore";
@@ -186,6 +186,16 @@ const LintTable = Schema.Struct({
186
186
  description: "An actor's prefix is not human, process, or a producer shape. Default \"info\".",
187
187
  default: "info"
188
188
  })),
189
+ actor_email: Schema.optionalKey(LintLevel.annotate({
190
+ title: "actor-email",
191
+ description: "An actor in generated.by, verified[].by, integrity.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\".",
192
+ default: "warn"
193
+ })),
194
+ verified_actor_unknown: Schema.optionalKey(LintLevel.annotate({
195
+ title: "verified-actor-unknown",
196
+ description: "A human verified[].by or integrity.verified.by matches no entry of a non-empty [actors].humans. Silent when the list is empty. Default \"warn\".",
197
+ default: "warn"
198
+ })),
189
199
  legacy_timestamp: Schema.optionalKey(LintLevel.annotate({
190
200
  title: "legacy-timestamp",
191
201
  description: "A concept uses the legacy timestamp field instead of generated.at. Default \"info\".",
@@ -198,7 +208,7 @@ const LintTable = Schema.Struct({
198
208
  })),
199
209
  stale: Schema.optionalKey(LintLevel.annotate({
200
210
  title: "stale",
201
- description: "A concept has gone unedited past lifecycle.default_stale_after. Default \"info\".",
211
+ description: "A concept is past its stale_after instant. Default \"info\".",
202
212
  default: "info"
203
213
  })),
204
214
  walk_unreadable: Schema.optionalKey(LintLevel.annotate({
@@ -211,6 +221,11 @@ const LintTable = Schema.Struct({
211
221
  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\".",
212
222
  default: "warn"
213
223
  })),
224
+ verified_drift: Schema.optionalKey(LintLevel.annotate({
225
+ title: "verified-drift",
226
+ description: "A concept's latest human verification no longer covers its current content: the body or authored frontmatter changed since, the binding (integrity.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\".",
227
+ default: "warn"
228
+ })),
214
229
  status_missing: Schema.optionalKey(LintLevel.annotate({
215
230
  title: "status-missing",
216
231
  description: "A concept carries neither status nor verified, so it silently reads as stable (issue #110). Off by default because the spec reads an absent status as stable; the software-project profile raises it to \"warn\".",
@@ -228,12 +243,12 @@ const LintTable = Schema.Struct({
228
243
  })),
229
244
  publication_drift: Schema.optionalKey(LintLevel.annotate({
230
245
  title: "publication-drift",
231
- description: "A Publication's renders[].body_sha256 is missing or no longer matches the current body of the concept it names, so the published page may restate stale facts. Default \"warn\".",
246
+ description: "A Publication's 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\".",
232
247
  default: "warn"
233
248
  })),
234
249
  publication_orphan: Schema.optionalKey(LintLevel.annotate({
235
250
  title: "publication-orphan",
236
- description: "A Publication's surface or renders[].path does not resolve to a concept, or renders is not a list of { path, body_sha256 } entries. Default \"error\".",
251
+ description: "A Publication's surface or renders[].path does not resolve to a concept, or renders is not a list of { path, body } entries. Default \"error\".",
237
252
  default: "error"
238
253
  })),
239
254
  surface_unmatched: Schema.optionalKey(LintLevel.annotate({
@@ -299,11 +314,11 @@ const okfitConfigFields = Schema.Struct({
299
314
  title: "Agent actor",
300
315
  description: "The actor id an agent writes as `generated.by`."
301
316
  })),
302
- humans: Schema.optionalKey(Schema.Array(Actor).annotate({
317
+ humans: Schema.optionalKey(Schema.Array(ActorPattern).annotate({
303
318
  title: "Human actors",
304
- description: "Actor ids for the humans working in this bundle, \"human:<id>\" form.",
319
+ description: "The humans allowed to verify concepts in this bundle: \"human:<id>\" ids or id globs (\"human:spencer*\"). Empty or absent lets any resolved identity verify; non-empty makes it an allow-list for okfit verify and the trust signal. Never an email address.",
305
320
  default: [],
306
- examples: [["human:spencer"]]
321
+ examples: [["human:spencer"], ["human:spencer", "human:team-*"]]
307
322
  }))
308
323
  }).annotate({
309
324
  title: "Actor identities",
@@ -448,11 +463,14 @@ const LINT_KEY = {
448
463
  "footnote-undefined": "footnote_undefined",
449
464
  "log-frontmatter": "log_frontmatter",
450
465
  "actor-prefix-unknown": "actor_prefix_unknown",
466
+ "actor-email": "actor_email",
467
+ "verified-actor-unknown": "verified_actor_unknown",
451
468
  "legacy-timestamp": "legacy_timestamp",
452
469
  "config-unknown-key": "config_unknown_key",
453
470
  stale: "stale",
454
471
  "walk-unreadable": "walk_unreadable",
455
472
  "generated-at-drift": "generated_at_drift",
473
+ "verified-drift": "verified_drift",
456
474
  "status-missing": "status_missing",
457
475
  "source-resource-missing": "source_resource_missing",
458
476
  "generated-missing": "generated_missing",
@@ -473,11 +491,14 @@ const DEFAULT_LINT = {
473
491
  footnote_undefined: "warn",
474
492
  log_frontmatter: "warn",
475
493
  actor_prefix_unknown: "info",
494
+ actor_email: "warn",
495
+ verified_actor_unknown: "warn",
476
496
  legacy_timestamp: "info",
477
497
  config_unknown_key: "warn",
478
498
  stale: "info",
479
499
  walk_unreadable: "warn",
480
500
  generated_at_drift: "warn",
501
+ verified_drift: "warn",
481
502
  status_missing: "off",
482
503
  source_resource_missing: "warn",
483
504
  generated_missing: "warn",
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @okfit/core
2
2
 
3
- Spec-level [Open Knowledge Format (OKF)](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md) v0.2 support for [Effect](https://effect.website): frontmatter schemas, bundle loading, the concept link graph, trust and staleness derivation, and conformance validation.
3
+ Spec-level [Open Knowledge Format (OKF)](https://github.com/GoogleCloudPlatform/open-knowledge-format/blob/main/SPEC.md) v0.2 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
 
package/index.d.ts CHANGED
@@ -21,7 +21,25 @@ type ActorForm = "producer" | "human" | "process" | "other";
21
21
  export declare const Actor: Schema.Codec<Actor, string> & {
22
22
  readonly isHuman: (actor: string) => boolean;
23
23
  readonly form: (actor: string) => ActorForm;
24
+ /** True when the actor equals the pattern, case-insensitively; `*` and `?` are the only wildcards. */
25
+ readonly matches: (actor: string, pattern: string) => boolean;
26
+ /** True when `humans` is empty, else when the actor matches at least one entry. */
27
+ readonly allowed: (actor: string, humans: ReadonlyArray<string>) => boolean;
28
+ /** True when the value contains a glob character (`*` or `?`). */
29
+ readonly isPattern: (value: string) => boolean;
24
30
  };
31
+ /**
32
+ * An `[actors].humans` entry: an exact actor id, or an id glob (`*`, `?`)
33
+ * such as `human:spencer*`. Same grammar as {@link (Actor:variable)}; the
34
+ * glob characters are already legal id characters.
35
+ * @public
36
+ */
37
+ export type ActorPattern = string & Brand.Brand<"ActorPattern">;
38
+ /**
39
+ * Branded, pattern-checked `[actors].humans` entry codec.
40
+ * @public
41
+ */
42
+ export declare const ActorPattern: Schema.Codec<ActorPattern, string>;
25
43
  //#endregion
26
44
  //#region src/AttestedComputation.d.ts
27
45
  declare const ComputationParameter_base: Schema.Class<ComputationParameter, Schema.Struct<{
@@ -66,24 +84,20 @@ declare const AttestedComputation_base: Schema.Class<AttestedComputation, Schema
66
84
  export declare class AttestedComputation extends AttestedComputation_base {}
67
85
  //#endregion
68
86
  //#region src/Generated.d.ts
69
- /**
70
- * A lowercase 64-character hex sha256 digest of a concept's body, as `@okfit/profiles`'
71
- * `Derivation.bodyDigest` computes it (issue #19). Optional: every concept stamped before
72
- * this field existed lacks it, and core itself never computes one -- it only holds the field.
73
- * @public
74
- */
75
- export declare const BodySha256: Schema.String;
76
- /**
77
- * The type of {@link (BodySha256:variable)}.
78
- * @public
79
- */
80
- export type BodySha256 = typeof BodySha256.Type;
81
87
  declare const Generated_base: Schema.Class<Generated, Schema.Struct<{
82
88
  readonly by: Schema.Codec<Actor, string, never, never> & {
83
89
  readonly isHuman: (actor: string) => boolean;
84
90
  readonly form: (actor: string) => ActorForm;
91
+ readonly matches: (actor: string, pattern: string) => boolean;
92
+ readonly allowed: (actor: string, humans: ReadonlyArray<string>) => boolean;
93
+ readonly isPattern: (value: string) => boolean;
85
94
  };
86
95
  readonly at: Schema.optionalKey<Schema.Codec<import("effect/DateTime").Utc, string, never, never>>;
96
+ /**
97
+ * Legacy (pre-integrity) body digest, read only as a migration fallback and never
98
+ * written. Lenient on purpose: a malformed legacy value must never fail the
99
+ * `generated` family and drop `by`/`at`. `okfit sync` moves it to `integrity.generated.body`.
100
+ */
87
101
  readonly body_sha256: Schema.optionalKey<Schema.String>;
88
102
  }>, {}>;
89
103
  /**
@@ -95,6 +109,55 @@ export declare class Generated extends Generated_base {
95
109
  static readonly LEGACY_BY: Actor;
96
110
  }
97
111
  //#endregion
112
+ //#region src/Integrity.d.ts
113
+ /**
114
+ * An okfit digest: the first 16 lowercase hex characters (64 bits) of SHA-256 over the
115
+ * input bytes `@okfit/profiles` defines. A signal, not a tamper seal. Core holds the
116
+ * shape and never computes one.
117
+ * @public
118
+ */
119
+ export declare const Digest: Schema.String;
120
+ /**
121
+ * The type of {@link (Digest:variable)}.
122
+ * @public
123
+ */
124
+ export type Digest = typeof Digest.Type;
125
+ declare const IntegrityGenerated_base: Schema.Class<IntegrityGenerated, Schema.Struct<{
126
+ readonly body: Schema.String;
127
+ }>, {}>;
128
+ /**
129
+ * The body digest as of `generated.at`.
130
+ * @public
131
+ */
132
+ export declare class IntegrityGenerated extends IntegrityGenerated_base {}
133
+ declare const IntegrityVerified_base: Schema.Class<IntegrityVerified, Schema.Struct<{
134
+ readonly by: Schema.Codec<Actor, string, never, never> & {
135
+ readonly isHuman: (actor: string) => boolean;
136
+ readonly form: (actor: string) => ActorForm;
137
+ readonly matches: (actor: string, pattern: string) => boolean;
138
+ readonly allowed: (actor: string, humans: ReadonlyArray<string>) => boolean;
139
+ readonly isPattern: (value: string) => boolean;
140
+ };
141
+ readonly at: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
142
+ readonly content: Schema.String;
143
+ }>, {}>;
144
+ /**
145
+ * Binds one `human:` `verified` entry (joined on `by` and `at`) to the content it covered.
146
+ * @public
147
+ */
148
+ export declare class IntegrityVerified extends IntegrityVerified_base {}
149
+ declare const Integrity_base: Schema.Class<Integrity, Schema.Struct<{
150
+ readonly generated: Schema.optionalKey<typeof IntegrityGenerated>;
151
+ readonly verified: Schema.optionalKey<typeof IntegrityVerified>;
152
+ }>, {}>;
153
+ /**
154
+ * okfit's own top-level frontmatter family, the only place okfit stores digests
155
+ * (OKF v0.2 section 4.1 extension key). Spec families such as `generated` and
156
+ * `verified` stay exactly as the spec defines them.
157
+ * @public
158
+ */
159
+ export declare class Integrity extends Integrity_base {}
160
+ //#endregion
98
161
  //#region src/Source.d.ts
99
162
  declare const UsageWindow_base: Schema.Class<UsageWindow, Schema.Struct<{
100
163
  readonly from: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
@@ -112,6 +175,9 @@ declare const Source_base: Schema.Class<Source, Schema.Struct<{
112
175
  readonly author: Schema.optionalKey<Schema.Codec<Actor, string, never, never> & {
113
176
  readonly isHuman: (actor: string) => boolean;
114
177
  readonly form: (actor: string) => ActorForm;
178
+ readonly matches: (actor: string, pattern: string) => boolean;
179
+ readonly allowed: (actor: string, humans: ReadonlyArray<string>) => boolean;
180
+ readonly isPattern: (value: string) => boolean;
115
181
  }>;
116
182
  readonly usage_count: Schema.optionalKey<Schema.Union<readonly [Schema.Number, Schema.FiniteFromString]>>;
117
183
  readonly last_modified: Schema.optionalKey<Schema.Codec<import("effect/DateTime").Utc, string, never, never>>;
@@ -128,6 +194,9 @@ declare const Verification_base: Schema.Class<Verification, Schema.Struct<{
128
194
  readonly by: Schema.Codec<Actor, string, never, never> & {
129
195
  readonly isHuman: (actor: string) => boolean;
130
196
  readonly form: (actor: string) => ActorForm;
197
+ readonly matches: (actor: string, pattern: string) => boolean;
198
+ readonly allowed: (actor: string, humans: ReadonlyArray<string>) => boolean;
199
+ readonly isPattern: (value: string) => boolean;
131
200
  };
132
201
  readonly at: Schema.Codec<import("effect/DateTime").Utc, string, never, never>;
133
202
  }>, {}>;
@@ -165,6 +234,7 @@ declare const Concept_base: Schema.Class<Concept, Schema.Struct<{
165
234
  readonly verified: Schema.optionalKey<Schema.decodeTo<Schema.$Array<Schema.toType<typeof Verification>>, Schema.Union<readonly [typeof Verification, Schema.$Array<typeof Verification>]>, never, never>>;
166
235
  readonly status: Schema.optionalKey<Schema.Literals<readonly ["draft", "stable", "deprecated"]>>;
167
236
  readonly stale_after: Schema.optionalKey<Schema.Codec<import("effect/DateTime").Utc, string, never, never>>;
237
+ readonly integrity: Schema.optionalKey<typeof Integrity>;
168
238
  readonly attested: Schema.optionalKey<typeof AttestedComputation>;
169
239
  readonly extensions: Schema.$Record<Schema.String, Schema.Unknown>;
170
240
  readonly raw: Schema.$Record<Schema.String, Schema.Unknown>;
@@ -207,11 +277,11 @@ export declare const ConformanceCode: Schema.Literals<readonly ["frontmatter-mis
207
277
  /** @public */
208
278
  export type ConformanceCode = typeof ConformanceCode.Type;
209
279
  /** Severity from `OkfitConfig` (D-34). @public */
210
- export declare const LintCode: Schema.Literals<readonly ["broken-links", "missing-index", "unknown-type", "required-key-missing", "field-value-unknown", "require-verified-unmet", "family-invalid", "computation-runtime-missing", "footnote-source-unknown", "footnote-undefined", "log-frontmatter", "actor-prefix-unknown", "legacy-timestamp", "config-unknown-key", "stale", "walk-unreadable", "generated-at-drift", "status-missing", "source-resource-missing", "generated-missing", "publication-drift", "publication-orphan", "surface-unmatched"]>;
280
+ export declare const LintCode: Schema.Literals<readonly ["broken-links", "missing-index", "unknown-type", "required-key-missing", "field-value-unknown", "require-verified-unmet", "family-invalid", "computation-runtime-missing", "footnote-source-unknown", "footnote-undefined", "log-frontmatter", "actor-prefix-unknown", "legacy-timestamp", "config-unknown-key", "stale", "walk-unreadable", "generated-at-drift", "status-missing", "source-resource-missing", "generated-missing", "publication-drift", "publication-orphan", "surface-unmatched", "verified-drift", "actor-email", "verified-actor-unknown"]>;
211
281
  /** @public */
212
282
  export type LintCode = typeof LintCode.Type;
213
283
  /** @public */
214
- export declare const DiagnosticCode: Schema.Union<readonly [Schema.Literals<readonly ["frontmatter-missing", "frontmatter-unclosed", "frontmatter-unparseable", "type-missing", "index-frontmatter", "index-malformed", "log-heading-invalid", "log-malformed"]>, Schema.Literals<readonly ["broken-links", "missing-index", "unknown-type", "required-key-missing", "field-value-unknown", "require-verified-unmet", "family-invalid", "computation-runtime-missing", "footnote-source-unknown", "footnote-undefined", "log-frontmatter", "actor-prefix-unknown", "legacy-timestamp", "config-unknown-key", "stale", "walk-unreadable", "generated-at-drift", "status-missing", "source-resource-missing", "generated-missing", "publication-drift", "publication-orphan", "surface-unmatched"]>]>;
284
+ export declare const DiagnosticCode: Schema.Union<readonly [Schema.Literals<readonly ["frontmatter-missing", "frontmatter-unclosed", "frontmatter-unparseable", "type-missing", "index-frontmatter", "index-malformed", "log-heading-invalid", "log-malformed"]>, Schema.Literals<readonly ["broken-links", "missing-index", "unknown-type", "required-key-missing", "field-value-unknown", "require-verified-unmet", "family-invalid", "computation-runtime-missing", "footnote-source-unknown", "footnote-undefined", "log-frontmatter", "actor-prefix-unknown", "legacy-timestamp", "config-unknown-key", "stale", "walk-unreadable", "generated-at-drift", "status-missing", "source-resource-missing", "generated-missing", "publication-drift", "publication-orphan", "surface-unmatched", "verified-drift", "actor-email", "verified-actor-unknown"]>]>;
215
285
  /** @public */
216
286
  export type DiagnosticCode = typeof DiagnosticCode.Type;
217
287
  declare const DiagnosticRange_base: Schema.Class<DiagnosticRange, Schema.Struct<{
@@ -245,7 +315,7 @@ export declare class DiagnosticRange extends DiagnosticRange_base {
245
315
  declare const Diagnostic_base: Schema.Class<Diagnostic, Schema.Struct<{
246
316
  readonly file: Schema.String;
247
317
  readonly range: Schema.optionalKey<typeof DiagnosticRange>;
248
- readonly code: Schema.Union<readonly [Schema.Literals<readonly ["frontmatter-missing", "frontmatter-unclosed", "frontmatter-unparseable", "type-missing", "index-frontmatter", "index-malformed", "log-heading-invalid", "log-malformed"]>, Schema.Literals<readonly ["broken-links", "missing-index", "unknown-type", "required-key-missing", "field-value-unknown", "require-verified-unmet", "family-invalid", "computation-runtime-missing", "footnote-source-unknown", "footnote-undefined", "log-frontmatter", "actor-prefix-unknown", "legacy-timestamp", "config-unknown-key", "stale", "walk-unreadable", "generated-at-drift", "status-missing", "source-resource-missing", "generated-missing", "publication-drift", "publication-orphan", "surface-unmatched"]>]>;
318
+ readonly code: Schema.Union<readonly [Schema.Literals<readonly ["frontmatter-missing", "frontmatter-unclosed", "frontmatter-unparseable", "type-missing", "index-frontmatter", "index-malformed", "log-heading-invalid", "log-malformed"]>, Schema.Literals<readonly ["broken-links", "missing-index", "unknown-type", "required-key-missing", "field-value-unknown", "require-verified-unmet", "family-invalid", "computation-runtime-missing", "footnote-source-unknown", "footnote-undefined", "log-frontmatter", "actor-prefix-unknown", "legacy-timestamp", "config-unknown-key", "stale", "walk-unreadable", "generated-at-drift", "status-missing", "source-resource-missing", "generated-missing", "publication-drift", "publication-orphan", "surface-unmatched", "verified-drift", "actor-email", "verified-actor-unknown"]>]>;
249
319
  readonly severity: Schema.Literals<readonly ["error", "warning", "info"]>;
250
320
  readonly message: Schema.String;
251
321
  }>, {}>;
@@ -507,6 +577,12 @@ export declare class Derive {
507
577
  static readonly renderLog: (groups: ReadonlyArray<LogEntry>, options?: {
508
578
  readonly title?: string;
509
579
  }) => string;
580
+ /**
581
+ * Every directory that owes an `index.md`: each directory holding a concept, plus its ancestors up to
582
+ * (not including) the bundle root, which a parent index links to even when it holds no concept itself.
583
+ * The root (`""`) is included only when it holds a concept. Sorted.
584
+ */
585
+ static readonly indexDirectories: (bundle: LoadedBundle) => ReadonlyArray<string>;
510
586
  /** Index text for `dir` from the concepts directly in it plus its immediate child directories; no frontmatter. */
511
587
  static readonly synthesizeIndex: (bundle: LoadedBundle, dir: string) => string;
512
588
  }
@@ -523,6 +599,26 @@ export declare const GraphNodeKind: Schema.Literals<readonly ["concept", "file",
523
599
  export type GraphNodeKind = typeof GraphNodeKind.Type;
524
600
  /** Frontmatter fields whose value is a bundle path (D-23). @public */
525
601
  type PathField = "resource" | "sources.resource" | "computation" | "executor.resource" | "attester.resource";
602
+ /**
603
+ * How one reference resolved (D-23, D-24); `via` says which D-23 branch produced a node: `rooted` (a leading
604
+ * `/`), `file` (against the linking file's directory) or `root` (a bare path against the bundle root).
605
+ *
606
+ * @public
607
+ */
608
+ type LinkResolution = {
609
+ readonly _tag: "url";
610
+ } | {
611
+ readonly _tag: "self";
612
+ } | {
613
+ readonly _tag: "external";
614
+ } | {
615
+ readonly _tag: "descriptor";
616
+ } | {
617
+ readonly _tag: "node";
618
+ readonly id: string;
619
+ readonly kind: GraphNodeKind;
620
+ readonly via: "rooted" | "file" | "root";
621
+ };
526
622
  /** A node: a concept id, or a bundle-relative path with extension for `file` and `missing` nodes. @public */
527
623
  interface GraphNode {
528
624
  readonly id: string;
@@ -576,6 +672,11 @@ export declare class LinkGraph {
576
672
  */
577
673
  export declare class Graph {
578
674
  private constructor();
675
+ /**
676
+ * Pure. Resolve `raw`, written in the file at bundle-relative `from`, the way the graph does; `field`
677
+ * applies the path-field rules (a `sources.resource` descriptor).
678
+ */
679
+ static readonly resolve: (bundle: LoadedBundle, from: string, raw: string, field?: PathField) => LinkResolution;
579
680
  /**
580
681
  * Pure. Body links come from `document.links`, path fields from the frontmatter (D-23, D-24).
581
682
  * Placeholder `missing` nodes are added before their edge because `Graph.addEdge` throws on an absent endpoint.
@@ -657,11 +758,14 @@ export declare const LintTable: Schema.Struct<{
657
758
  readonly footnote_undefined: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
658
759
  readonly log_frontmatter: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
659
760
  readonly actor_prefix_unknown: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
761
+ readonly actor_email: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
762
+ readonly verified_actor_unknown: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
660
763
  readonly legacy_timestamp: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
661
764
  readonly config_unknown_key: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
662
765
  readonly stale: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
663
766
  readonly walk_unreadable: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
664
767
  readonly generated_at_drift: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
768
+ readonly verified_drift: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
665
769
  readonly status_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
666
770
  readonly source_resource_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
667
771
  readonly generated_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
@@ -692,10 +796,7 @@ declare const okfitConfigFields: Schema.Struct<{
692
796
  }>>;
693
797
  readonly actors: Schema.optionalKey<Schema.Struct<{
694
798
  readonly agent: Schema.optionalKey<Schema.Codec<Actor, string, never, never>>;
695
- readonly humans: Schema.optionalKey<Schema.$Array<Schema.Codec<Actor, string, never, never> & {
696
- readonly isHuman: (actor: string) => boolean;
697
- readonly form: (actor: string) => ActorForm;
698
- }>>;
799
+ readonly humans: Schema.optionalKey<Schema.$Array<Schema.Codec<ActorPattern, string, never, never>>>;
699
800
  }>>;
700
801
  readonly lint: Schema.optionalKey<Schema.Struct<{
701
802
  readonly broken_links: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
@@ -710,11 +811,14 @@ declare const okfitConfigFields: Schema.Struct<{
710
811
  readonly footnote_undefined: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
711
812
  readonly log_frontmatter: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
712
813
  readonly actor_prefix_unknown: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
814
+ readonly actor_email: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
815
+ readonly verified_actor_unknown: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
713
816
  readonly legacy_timestamp: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
714
817
  readonly config_unknown_key: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
715
818
  readonly stale: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
716
819
  readonly walk_unreadable: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
717
820
  readonly generated_at_drift: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
821
+ readonly verified_drift: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
718
822
  readonly status_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
719
823
  readonly source_resource_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
720
824
  readonly generated_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
@@ -798,10 +902,7 @@ export declare const okfitConfigDocumentFields: Schema.StructWithRest<Schema.Str
798
902
  }>>;
799
903
  readonly actors: Schema.optionalKey<Schema.Struct<{
800
904
  readonly agent: Schema.optionalKey<Schema.Codec<Actor, string, never, never>>;
801
- readonly humans: Schema.optionalKey<Schema.$Array<Schema.Codec<Actor, string, never, never> & {
802
- readonly isHuman: (actor: string) => boolean;
803
- readonly form: (actor: string) => ActorForm;
804
- }>>;
905
+ readonly humans: Schema.optionalKey<Schema.$Array<Schema.Codec<ActorPattern, string, never, never>>>;
805
906
  }>>;
806
907
  readonly lint: Schema.optionalKey<Schema.Struct<{
807
908
  readonly broken_links: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
@@ -816,11 +917,14 @@ export declare const okfitConfigDocumentFields: Schema.StructWithRest<Schema.Str
816
917
  readonly footnote_undefined: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
817
918
  readonly log_frontmatter: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
818
919
  readonly actor_prefix_unknown: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
920
+ readonly actor_email: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
921
+ readonly verified_actor_unknown: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
819
922
  readonly legacy_timestamp: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
820
923
  readonly config_unknown_key: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
821
924
  readonly stale: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
822
925
  readonly walk_unreadable: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
823
926
  readonly generated_at_drift: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
927
+ readonly verified_drift: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
824
928
  readonly status_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
825
929
  readonly source_resource_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
826
930
  readonly generated_missing: Schema.optionalKey<Schema.Literals<readonly ["off", "info", "warn", "error"]>>;
@@ -892,7 +996,7 @@ declare const OkfitConfigFile_base: import("effect/Context").ServiceClass<OkfitC
892
996
  };
893
997
  readonly actors?: {
894
998
  readonly agent?: Actor;
895
- readonly humans?: readonly Actor[];
999
+ readonly humans?: readonly ActorPattern[];
896
1000
  };
897
1001
  readonly lint?: {
898
1002
  readonly broken_links?: "error" | "info" | "off" | "warn";
@@ -907,11 +1011,14 @@ declare const OkfitConfigFile_base: import("effect/Context").ServiceClass<OkfitC
907
1011
  readonly footnote_undefined?: "error" | "info" | "off" | "warn";
908
1012
  readonly log_frontmatter?: "error" | "info" | "off" | "warn";
909
1013
  readonly actor_prefix_unknown?: "error" | "info" | "off" | "warn";
1014
+ readonly actor_email?: "error" | "info" | "off" | "warn";
1015
+ readonly verified_actor_unknown?: "error" | "info" | "off" | "warn";
910
1016
  readonly legacy_timestamp?: "error" | "info" | "off" | "warn";
911
1017
  readonly config_unknown_key?: "error" | "info" | "off" | "warn";
912
1018
  readonly stale?: "error" | "info" | "off" | "warn";
913
1019
  readonly walk_unreadable?: "error" | "info" | "off" | "warn";
914
1020
  readonly generated_at_drift?: "error" | "info" | "off" | "warn";
1021
+ readonly verified_drift?: "error" | "info" | "off" | "warn";
915
1022
  readonly status_missing?: "error" | "info" | "off" | "warn";
916
1023
  readonly source_resource_missing?: "error" | "info" | "off" | "warn";
917
1024
  readonly generated_missing?: "error" | "info" | "off" | "warn";
@@ -1002,5 +1109,5 @@ export declare class Validate {
1002
1109
  */
1003
1110
  export declare const OKF_SPEC_VERSION: "0.2";
1004
1111
  //#endregion
1005
- export type { ActorForm, BundleLoadError, BundleLoadOptions, GraphEdge, GraphLink, GraphNode, LogEntry, OkfitConfigFields, PathField, RenderIndexOptions, StaleConcept, ValidateOptions, ValidationReport };
1112
+ export type { ActorForm, BundleLoadError, BundleLoadOptions, GraphEdge, GraphLink, GraphNode, LinkResolution, LogEntry, OkfitConfigFields, PathField, RenderIndexOptions, StaleConcept, ValidateOptions, ValidationReport };
1006
1113
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { Actor } from "./Actor.js";
1
+ import { Actor, ActorPattern } from "./Actor.js";
2
2
  import { AttestedComputation, ComputationAttester, ComputationExecutor, ComputationParameter } from "./AttestedComputation.js";
3
3
  import { Timestamp } from "./Timestamp.js";
4
- import { BodySha256, Generated } from "./Generated.js";
4
+ import { Generated } from "./Generated.js";
5
+ import { Digest, Integrity, IntegrityGenerated, IntegrityVerified } from "./Integrity.js";
5
6
  import { Source, UsageWindow } from "./Source.js";
6
7
  import { Status } from "./Status.js";
7
8
  import { Verification } from "./Verification.js";
@@ -25,4 +26,4 @@ import { Validate } from "./Validate.js";
25
26
  const OKF_SPEC_VERSION = "0.2";
26
27
 
27
28
  //#endregion
28
- export { ATTESTED_COMPUTATION_TYPE, Actor, AttestedComputation, BodySha256, Bundle, BundleDepthExceededError, BundleReadError, BundleRootNotFoundError, CONFIG_SCHEMA_VERSION, ComputationAttester, ComputationExecutor, ComputationParameter, Concept, ConceptId, ConformanceCode, Derive, Diagnostic, DiagnosticCode, DiagnosticRange, DiagnosticSeverity, FieldDeclaration, Generated, Graph, GraphNodeKind, IndexDocument, IndexEntry, IndexSection, LinkGraph, LintCode, LintLevel, LintTable, LoadedBundle, LoadedConcept, LogDocument, LogGroup, LogItem, OKF_SPEC_VERSION, OkfitConfig, OkfitConfigFile, SCHEMA_DIRECTIVE, Source, StaleAfterDuration, Staleness, Status, TagDeclaration, Timestamp, TrustTier, TypeDeclaration, UsageWindow, Validate, Verification, okfitConfigDocumentFields, okfitConfigSchemaHost };
29
+ export { ATTESTED_COMPUTATION_TYPE, Actor, ActorPattern, AttestedComputation, Bundle, BundleDepthExceededError, BundleReadError, BundleRootNotFoundError, CONFIG_SCHEMA_VERSION, ComputationAttester, ComputationExecutor, ComputationParameter, Concept, ConceptId, ConformanceCode, Derive, Diagnostic, DiagnosticCode, DiagnosticRange, DiagnosticSeverity, Digest, FieldDeclaration, Generated, Graph, GraphNodeKind, IndexDocument, IndexEntry, IndexSection, Integrity, IntegrityGenerated, IntegrityVerified, LinkGraph, LintCode, LintLevel, LintTable, LoadedBundle, LoadedConcept, LogDocument, LogGroup, LogItem, OKF_SPEC_VERSION, OkfitConfig, OkfitConfigFile, SCHEMA_DIRECTIVE, Source, StaleAfterDuration, Staleness, Status, TagDeclaration, Timestamp, TrustTier, TypeDeclaration, UsageWindow, Validate, Verification, okfitConfigDocumentFields, okfitConfigSchemaHost };
@@ -1,6 +1,7 @@
1
1
  import { AttestedComputation } from "../AttestedComputation.js";
2
2
  import { Timestamp } from "../Timestamp.js";
3
3
  import { Generated } from "../Generated.js";
4
+ import { Integrity } from "../Integrity.js";
4
5
  import { Source, UsageWindow } from "../Source.js";
5
6
  import { Status } from "../Status.js";
6
7
  import { Verification } from "../Verification.js";
@@ -28,7 +29,8 @@ const FAMILY_SCHEMAS = {
28
29
  generated: Generated,
29
30
  verified: Verification.List,
30
31
  status: Status,
31
- stale_after: Timestamp
32
+ stale_after: Timestamp,
33
+ integrity: Integrity
32
34
  };
33
35
  const FAMILY_KEYS = Object.keys(FAMILY_SCHEMAS);
34
36
  const PARSE_OPTIONS = { errors: "all" };
package/internal/links.js CHANGED
@@ -23,33 +23,36 @@ const isReserved = (path) => {
23
23
  };
24
24
  const escapes = (path) => path === ".." || path.startsWith("../");
25
25
  const withIndex = (candidate) => candidate.endsWith("/") ? `${candidate}index.md` : candidate;
26
- const existing = (path, index) => {
26
+ const existing = (path, index, via) => {
27
27
  if (!index.files.has(path)) return void 0;
28
28
  if (path.endsWith(".md") && !isReserved(path)) {
29
29
  const id = path.slice(0, -3);
30
30
  if (index.concepts.has(id)) return {
31
31
  _tag: "node",
32
32
  id,
33
- kind: "concept"
33
+ kind: "concept",
34
+ via
34
35
  };
35
36
  }
36
37
  return {
37
38
  _tag: "node",
38
39
  id: path,
39
- kind: "file"
40
+ kind: "file",
41
+ via
40
42
  };
41
43
  };
42
- const lookup = (candidate, index) => {
44
+ const lookup = (candidate, index, via) => {
43
45
  const path = withIndex(candidate);
44
46
  if (path === "." || path === "") return void 0;
45
- const direct = existing(path, index);
47
+ const direct = existing(path, index, via);
46
48
  if (direct !== void 0) return direct;
47
- return basename(path).includes(".") ? void 0 : existing(`${path}.md`, index);
49
+ return basename(path).includes(".") ? void 0 : existing(`${path}.md`, index, via);
48
50
  };
49
- const missing = (candidate) => ({
51
+ const missing = (candidate, via) => ({
50
52
  _tag: "node",
51
53
  id: withIndex(candidate),
52
- kind: "missing"
54
+ kind: "missing",
55
+ via
53
56
  });
54
57
  /** Resolve a body link or path field from `from` (the linking file's bundle-relative path), order A-D (D-23). @internal */
55
58
  const resolveTarget = (from, raw, index) => {
@@ -61,21 +64,21 @@ const resolveTarget = (from, raw, index) => {
61
64
  const rooted = target.slice(1);
62
65
  const candidate = rooted === "" ? "index.md" : normalize(rooted);
63
66
  if (escapes(candidate)) return { _tag: "external" };
64
- return lookup(candidate, index) ?? missing(candidate);
67
+ return lookup(candidate, index, "rooted") ?? missing(candidate, "rooted");
65
68
  }
66
69
  const relative = target.startsWith("./") || target.startsWith("../");
67
70
  const fileRelative = join(dirname(from), target);
68
71
  if (escapes(fileRelative)) return { _tag: "external" };
69
- const hitB = lookup(fileRelative, index);
72
+ const hitB = lookup(fileRelative, index, "file");
70
73
  if (hitB !== void 0) return hitB;
71
74
  if (!relative) {
72
75
  const rootRelative = normalize(target);
73
76
  if (escapes(rootRelative)) return { _tag: "external" };
74
- const hitC = lookup(rootRelative, index);
77
+ const hitC = lookup(rootRelative, index, "root");
75
78
  if (hitC !== void 0) return hitC;
76
- if (target.includes("/")) return missing(rootRelative);
79
+ if (target.includes("/")) return missing(rootRelative, "root");
77
80
  }
78
- return missing(fileRelative);
81
+ return missing(fileRelative, "file");
79
82
  };
80
83
  /** Field-aware resolution (D-24): a `sources.resource` with whitespace, or that resolves to nothing, is a descriptor. @internal */
81
84
  const resolvePathField = (from, field, raw, index) => {
@@ -85,6 +85,43 @@ const actorPrefixUnknown = perConcept("actor-prefix-unknown", (concept) => {
85
85
  }
86
86
  return out;
87
87
  });
88
+ /** Every actor-valued frontmatter field of a concept, with the path that names it. */
89
+ const actorsOf = (concept) => {
90
+ const verifiedPath = (index) => Array.isArray(concept.frontmatter.raw.verified) ? [
91
+ "verified",
92
+ index,
93
+ "by"
94
+ ] : ["verified", "by"];
95
+ const binding = concept.frontmatter.integrity?.verified;
96
+ return [
97
+ ...concept.frontmatter.generated === void 0 ? [] : [{
98
+ by: concept.frontmatter.generated.by,
99
+ path: ["generated", "by"]
100
+ }],
101
+ ...(concept.frontmatter.verified ?? []).map((entry, index) => ({
102
+ by: entry.by,
103
+ path: verifiedPath(index)
104
+ })),
105
+ ...binding === void 0 ? [] : [{
106
+ by: binding.by,
107
+ path: [
108
+ "integrity",
109
+ "verified",
110
+ "by"
111
+ ]
112
+ }]
113
+ ];
114
+ };
115
+ const EMAIL_HINT = "okfit never stores email addresses; use a human:<id> without the domain";
116
+ const actorEmail = rule("actor-email", (context, severity) => [...(context.config.actors?.humans ?? []).filter((entry) => entry.includes("@")).map((entry) => diagnostic("", "actor-email", severity, `actors.humans entry "${entry}" contains "@"; ${EMAIL_HINT}`, void 0)), ...[...context.bundle.concepts.values()].flatMap((concept) => actorsOf(concept).filter((candidate) => candidate.by.includes("@")).map((candidate) => diagnostic(concept.path, "actor-email", severity, `Actor "${candidate.by}" contains "@"; ${EMAIL_HINT}`, frontmatterPathRange(concept.document, candidate.path))))]);
117
+ const verifiedActorUnknown = perConcept("verified-actor-unknown", (concept, context) => {
118
+ const humans = context.config.actors?.humans ?? [];
119
+ if (humans.length === 0) return [];
120
+ return actorsOf(concept).filter((candidate) => candidate.path[0] !== "generated").filter((candidate) => Actor.isHuman(candidate.by) && !Actor.allowed(candidate.by, humans)).map((candidate) => ({
121
+ message: `Verifier "${candidate.by}" matches no entry of actors.humans; add it there, or have a listed human re-verify`,
122
+ path: candidate.path
123
+ }));
124
+ });
88
125
  const stale = perConcept("stale", (concept, context) => context.now !== void 0 && concept.frontmatter.stale_after !== void 0 && Derive.isStale(concept.frontmatter, context.now) ? [{
89
126
  message: `Concept is stale since ${DateTime.formatIso(concept.frontmatter.stale_after)}`,
90
127
  path: ["stale_after"]
@@ -220,7 +257,7 @@ const brokenLinks = rule("broken-links", (context, severity) => {
220
257
  }
221
258
  return [...dangling, ...anchors];
222
259
  });
223
- const missingIndex = rule("missing-index", (context, severity) => context.bundle.directories.filter((dir) => !context.bundle.indexes.has(dir)).map((dir) => {
260
+ const missingIndex = rule("missing-index", (context, severity) => Derive.indexDirectories(context.bundle).filter((dir) => !context.bundle.indexes.has(dir)).map((dir) => {
224
261
  const message = `Directory "${dir === "" ? "." : dir}" has no index.md`;
225
262
  return diagnostic(dir === "" ? "index.md" : `${dir}/index.md`, "missing-index", severity, message, void 0);
226
263
  }));
@@ -234,6 +271,8 @@ const LINT_RULES = [
234
271
  statusMissing,
235
272
  generatedMissing,
236
273
  actorPrefixUnknown,
274
+ actorEmail,
275
+ verifiedActorUnknown,
237
276
  footnoteSourceUnknown,
238
277
  footnoteUndefined,
239
278
  brokenLinks,
@@ -242,4 +281,4 @@ const LINT_RULES = [
242
281
  ];
243
282
 
244
283
  //#endregion
245
- export { LINT_RULES, actorPrefixUnknown, brokenLinks, configUnknownKey, fieldValueUnknown, footnoteSourceUnknown, footnoteUndefined, generatedMissing, missingIndex, requireVerifiedUnmet, requiredKeyMissing, stale, statusMissing, unknownType };
284
+ export { LINT_RULES, actorEmail, actorPrefixUnknown, brokenLinks, configUnknownKey, fieldValueUnknown, footnoteSourceUnknown, footnoteUndefined, generatedMissing, missingIndex, requireVerifiedUnmet, requiredKeyMissing, stale, statusMissing, unknownType, verifiedActorUnknown };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okfit/core",
3
- "version": "0.9.2",
3
+ "version": "0.11.0",
4
4
  "private": false,
5
5
  "description": "Spec-level Open Knowledge Format (OKF) v0.2 schemas, bundle loading, graph, derivation, and validation for Effect.",
6
6
  "keywords": [
@@ -37,14 +37,14 @@
37
37
  "./package.json": "./package.json"
38
38
  },
39
39
  "peerDependencies": {
40
- "@effected/config-file": "^0.14.0",
41
- "@effected/glob": "^0.10.0",
42
- "@effected/jsonc": "^0.15.0",
43
- "@effected/markdown": "^0.15.0",
44
- "@effected/schemastore": "^0.21.0",
45
- "@effected/toml": "^0.11.0",
46
- "@effected/walker": "^0.15.0",
47
- "@effected/yaml": "^0.19.0",
40
+ "@effected/config-file": "^0.15.0",
41
+ "@effected/glob": "^0.11.0",
42
+ "@effected/jsonc": "^0.16.0",
43
+ "@effected/markdown": "^0.16.0",
44
+ "@effected/schemastore": "^0.22.0",
45
+ "@effected/toml": "^0.12.0",
46
+ "@effected/walker": "^0.16.0",
47
+ "@effected/yaml": "^0.20.0",
48
48
  "effect": "^4.0.0"
49
49
  },
50
50
  "engines": {