@okfit/engine 0.18.0 → 0.18.2

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.
@@ -30,8 +30,6 @@ const shift = (edit, by) => by === 0 ? edit : MarkdownEdit.make({
30
30
  length: edit.length,
31
31
  content: edit.content
32
32
  });
33
- /** The value of a located scalar's raw source text, quotes removed. */
34
- const unquote = (raw, quote) => quote === "plain" ? raw.trim() : raw.slice(1, -1);
35
33
  /**
36
34
  * A public facade over the `verify/locate.ts` and `verify/splice.ts`
37
35
  * machinery: byte-range `MarkdownEdit`s for a concept's top-level `status`
@@ -112,7 +110,7 @@ var FrontmatterEdits = class {
112
110
  key: "status",
113
111
  shape: target.shape
114
112
  });
115
- if (target._tag !== "replaceScalar" || unquote(text.slice(target.start, target.end), target.quote) !== status) statusEdit = spliceTopLevelScalar(target, "status", status, newline);
113
+ if (target._tag !== "replaceScalar" || target.value !== status) statusEdit = spliceTopLevelScalar(target, "status", status, newline);
116
114
  const integrity = yield* locateIntegrity(text);
117
115
  if (integrity._tag === "unsupported") return yield* new UnsupportedFrontmatterError({
118
116
  key: "integrity",
package/errors.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Runtime, Schema } from "effect";
2
+ import { ErrorText } from "@effected/engine";
2
3
 
3
4
  // src/errors.ts
4
5
  /**
@@ -100,14 +101,6 @@ var VerifyNothingToRevokeError = class extends Schema.TaggedError()("VerifyNothi
100
101
  return `"${this.id}" has no verified entry by ${this.actor} to revoke`;
101
102
  }
102
103
  };
103
- /** The error's `message` when it has one as a string, else `String(error)`. */
104
- const messageOf = (error) => {
105
- if (typeof error === "object" && error !== null && "message" in error) {
106
- const message = error.message;
107
- if (typeof message === "string") return message;
108
- }
109
- return String(error);
110
- };
111
104
  /**
112
105
  * A config file at a KNOWN path failed to parse or validate (K-46's own
113
106
  * intent — "each class' message already names the offending path" does not
@@ -124,7 +117,7 @@ var ConfigMalformedError = class extends Schema.TaggedError()("ConfigMalformedEr
124
117
  }) {
125
118
  [Runtime.errorExitCode] = 3;
126
119
  get message() {
127
- return `malformed config ${this.path}: ${messageOf(this.cause)}`;
120
+ return `malformed config ${this.path}: ${ErrorText.describe(this.cause)}`;
128
121
  }
129
122
  };
130
123
  /**
package/index.d.ts CHANGED
@@ -864,7 +864,7 @@ export declare class OverlayDocuments extends OverlayDocuments_base {
864
864
  static readonly layer: Layer.Layer<OverlayDocuments>;
865
865
  }
866
866
  /**
867
- * Wrap `underlying` so `readFile`, `readFileString`, `exists` and `stat` answer
867
+ * Wrap `underlying` so `readFile`, `readFileString`, `exists`, `stat` and `lstat` answer
868
868
  * from `documents` for open paths, and a non-recursive `readDirectory` also lists
869
869
  * open documents whose parent is the directory read (so a brand-new unsaved file
870
870
  * is walked). Every other member, and every path not open, is `underlying`'s.
@@ -1966,10 +1966,14 @@ interface AttestableSelection {
1966
1966
  * batch. A draft is unsettled and a deprecated concept is retired (#143), so
1967
1967
  * both are skipped before the already-verified check. A concept whose
1968
1968
  * verification has drifted, or is bound to another actor, is a candidate.
1969
+ * With `options.drifted`, a drifted concept of any type is considered too,
1970
+ * as the picker does: the `verified-drift` lint's remedy is `okfit verify`.
1969
1971
  *
1970
1972
  * @public
1971
1973
  */
1972
- export declare const selectAttestable: (bundle: LoadedBundle, types: ReadonlySet<string>, actor: string, signals: ReadonlyMap<string, ConceptSignal>) => AttestableSelection;
1974
+ export declare const selectAttestable: (bundle: LoadedBundle, types: ReadonlySet<string>, actor: string, signals: ReadonlyMap<string, ConceptSignal>, options?: {
1975
+ readonly drifted?: boolean;
1976
+ }) => AttestableSelection;
1973
1977
  /**
1974
1978
  * One row of the interactive verify picker: a `require_verified` concept the
1975
1979
  * actor has not attested yet.
@@ -1999,8 +2003,11 @@ interface PickerCandidate {
1999
2003
  }
2000
2004
  /**
2001
2005
  * Every concept whose type sets `require_verified` that `actor` has not
2002
- * attested: drafts included, deprecated concepts and the actor's own still-bound
2003
- * attestations excluded (a drifted one is offered again). Sorted by type, then id; grouping is the caller's.
2006
+ * attested, plus every drifted concept of any type (a human verified it once
2007
+ * and its content has changed since, so the `verified-drift` lint sends the
2008
+ * reader here): drafts included, deprecated concepts and the actor's own
2009
+ * still-bound attestations excluded (a drifted one is offered again). Sorted
2010
+ * by type, then id; grouping is the caller's.
2004
2011
  *
2005
2012
  * @public
2006
2013
  */
@@ -2752,7 +2759,8 @@ export declare const runRevokeIds: (options: RevokeIdsOptions) => Effect.Effect<
2752
2759
  }[], import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyNothingToRevokeError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2753
2760
  /**
2754
2761
  * Issue #138. Attests every concept selected by `options.types` (or, when
2755
- * empty, every type whose declaration sets `require_verified = true`) that
2762
+ * empty, every type whose declaration sets `require_verified = true`, plus
2763
+ * every drifted concept of any type) that
2756
2764
  * is not a draft, is not deprecated (#143) and whose `verified` entry by the
2757
2765
  * resolved actor does not already bind its current content (`Trust.signals`). Every candidate is located FIRST -- an unsupported
2758
2766
  * `verified` shape on any one of them fails the whole batch with nothing
package/overlay/layer.js CHANGED
@@ -59,7 +59,18 @@ const overlayInfo = (text) => ({
59
59
  blocks: Option.none()
60
60
  });
61
61
  /**
62
- * Wrap `underlying` so `readFile`, `readFileString`, `exists` and `stat` answer
62
+ * `read`'s `File.Info` for `path`, with an open document's size, or a plain
63
+ * file's info for a document that exists only in the overlay.
64
+ */
65
+ const shadowInfo = (documents, path, read) => Effect.flatMap(documents.get(path), Option.match({
66
+ onNone: () => read(path),
67
+ onSome: (document) => read(path).pipe(Effect.map((info) => ({
68
+ ...info,
69
+ size: ByteSize.bytes(encoder.encode(document.text).byteLength)
70
+ })), Effect.catchTag("PlatformError", (error) => error.reason._tag === "NotFound" ? Effect.succeed(overlayInfo(document.text)) : Effect.fail(error)))
71
+ }));
72
+ /**
73
+ * Wrap `underlying` so `readFile`, `readFileString`, `exists`, `stat` and `lstat` answer
63
74
  * from `documents` for open paths, and a non-recursive `readDirectory` also lists
64
75
  * open documents whose parent is the directory read (so a brand-new unsaved file
65
76
  * is walked). Every other member, and every path not open, is `underlying`'s.
@@ -80,13 +91,8 @@ const makeOverlayFileSystem = (underlying, documents) => FileSystem.FileSystem.o
80
91
  onNone: () => underlying.exists(path),
81
92
  onSome: () => Effect.succeed(true)
82
93
  })),
83
- stat: (path) => Effect.flatMap(documents.get(path), Option.match({
84
- onNone: () => underlying.stat(path),
85
- onSome: (document) => underlying.stat(path).pipe(Effect.map((info) => ({
86
- ...info,
87
- size: ByteSize.bytes(encoder.encode(document.text).byteLength)
88
- })), Effect.catchTag("PlatformError", (error) => error.reason._tag === "NotFound" ? Effect.succeed(overlayInfo(document.text)) : Effect.fail(error)))
89
- })),
94
+ stat: (path) => shadowInfo(documents, path, underlying.stat),
95
+ lstat: (path) => shadowInfo(documents, path, underlying.lstat),
90
96
  readDirectory: (path, options) => options?.recursive === true ? underlying.readDirectory(path, options) : Effect.gen(function* () {
91
97
  const names = yield* underlying.readDirectory(path, options);
92
98
  const directory = trimTrailingSeparators(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okfit/engine",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "private": false,
5
5
  "description": "The okfit engine: platform layer, config discovery, and the validate, verify, sync, init and context programs shared by the okfit CLI and MCP server.",
6
6
  "keywords": [
@@ -34,23 +34,24 @@
34
34
  "./package.json": "./package.json"
35
35
  },
36
36
  "dependencies": {
37
- "@effect/platform-node": "^4.0.6",
38
- "@effected/app": "^0.27.1",
39
- "@effected/config-file": "^0.20.1",
40
- "@effected/engine": "^0.8.0",
41
- "@effected/git": "^0.25.1",
42
- "@effected/glob": "^0.14.0",
43
- "@effected/jsonc": "^0.20.0",
44
- "@effected/markdown": "^0.23.0",
45
- "@effected/schemastore": "^0.26.2",
46
- "@effected/store": "^0.19.0",
47
- "@effected/toml": "^0.16.0",
48
- "@effected/walker": "^0.20.1",
49
- "@effected/xdg": "^0.15.1",
50
- "@effected/yaml": "^0.25.1",
51
- "@okfit/core": "0.11.6",
52
- "@okfit/profiles": "0.11.0",
53
- "effect": "^4.0.6"
37
+ "@effect/platform-node": "^4.0.7",
38
+ "@effected/app": "^0.29.0",
39
+ "@effected/config-file": "^0.22.0",
40
+ "@effected/engine": "^0.10.0",
41
+ "@effected/git": "^0.27.0",
42
+ "@effected/glob": "^0.16.0",
43
+ "@effected/jsonc": "^0.21.0",
44
+ "@effected/markdown": "^0.24.0",
45
+ "@effected/schemastore": "^0.27.0",
46
+ "@effected/source": "^0.1.0",
47
+ "@effected/store": "^0.21.0",
48
+ "@effected/toml": "^0.17.0",
49
+ "@effected/walker": "^0.22.0",
50
+ "@effected/xdg": "^0.17.0",
51
+ "@effected/yaml": "^0.26.0",
52
+ "@okfit/core": "0.11.8",
53
+ "@okfit/profiles": "0.13.0",
54
+ "effect": "^4.0.7"
54
55
  },
55
56
  "engines": {
56
57
  "node": ">=24.11.0"
package/render/json.js CHANGED
@@ -1,9 +1,10 @@
1
- import { DistributionField } from "./distribution.js";
1
+ import { DistributionField as DistributionField$1 } from "./distribution.js";
2
2
  import { tally } from "./exit.js";
3
3
  import { ENGINE_VERSION } from "../version.js";
4
4
  import { sort } from "./sort.js";
5
5
  import { DiagnosticRange, DiagnosticSeverity } from "@okfit/core";
6
6
  import { Runtime, Schema } from "effect";
7
+ import { ErrorText } from "@effected/engine";
7
8
 
8
9
  // src/render/json.ts
9
10
  /** One entry of the `diagnostics` array (K-21). @public */
@@ -47,7 +48,7 @@ const JsonEnvelope = Schema.Struct({
47
48
  okfit_version: Schema.String,
48
49
  engine_version: Schema.String,
49
50
  producer: Schema.String,
50
- distribution: DistributionField,
51
+ distribution: DistributionField$1,
51
52
  okf_version: Schema.String,
52
53
  root: Schema.String,
53
54
  profile: Schema.NullOr(Schema.String),
@@ -71,7 +72,7 @@ const JsonErrorEnvelope = Schema.Struct({
71
72
  schema: Schema.Literal(1),
72
73
  okfit_version: Schema.String,
73
74
  engine_version: Schema.String,
74
- distribution: DistributionField,
75
+ distribution: DistributionField$1,
75
76
  exit_code: Schema.Literals([3, 64]),
76
77
  error: Schema.Struct({
77
78
  tag: Schema.String,
@@ -127,14 +128,6 @@ const tagOf = (error) => {
127
128
  if (typeof tag === "string") return tag;
128
129
  return error.constructor?.name ?? "UnknownError";
129
130
  };
130
- /** The error's `message` when it has one as a string, else `String(error)`. */
131
- const messageOf = (error) => {
132
- if (typeof error === "object" && error !== null && "message" in error) {
133
- const message = error.message;
134
- if (typeof message === "string") return message;
135
- }
136
- return String(error);
137
- };
138
131
  /**
139
132
  * The `[Runtime.errorExitCode]` marker's value when it is present and is one
140
133
  * of the two exit codes the JSON error envelope can carry; `3` otherwise
@@ -156,7 +149,7 @@ const jsonError = (error, okfitVersion, distribution) => ({
156
149
  exit_code: exitCodeOf(error),
157
150
  error: {
158
151
  tag: tagOf(error),
159
- message: messageOf(error)
152
+ message: ErrorText.describe(error)
160
153
  }
161
154
  });
162
155
 
package/sync/run.js CHANGED
@@ -61,7 +61,7 @@ const planSync = Effect.fn("okfit/sync/planSync")(function* (options) {
61
61
  const git = yield* Git;
62
62
  const fs = yield* FileSystem.FileSystem;
63
63
  const path = yield* Path.Path;
64
- repoRoot = yield* fs.realPath((yield* Derivation.worktreeRoot(bundle.root)) ?? (yield* git.repoRoot(bundle.root)));
64
+ repoRoot = yield* git.repoRoot(bundle.root, { ignoreRepositoryEnv: true }).pipe(Effect.catchTag("NotARepositoryError", () => git.repoRoot(bundle.root)));
65
65
  const stagedPaths = new Set(yield* git.stagedChanges(repoRoot));
66
66
  const selected = /* @__PURE__ */ new Set();
67
67
  const provenanceStaged = /* @__PURE__ */ new Map();
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.4"
8
+ "packageVersion": "7.60.0"
9
9
  }
10
10
  ]
11
11
  }
package/verify/locate.js CHANGED
@@ -298,7 +298,8 @@ const locateTopLevelScalar = Effect.fn("okfit/verify/locateTopLevelScalar")(func
298
298
  _tag: "replaceScalar",
299
299
  start: valueStart + node.offset,
300
300
  end: valueStart + node.offset + node.length,
301
- quote: node.style
301
+ quote: node.style,
302
+ value: node.value
302
303
  };
303
304
  }
304
305
  const findKey = (name) => contents.items.find((item) => item.key instanceof YamlScalar && item.key.value === name);
package/verify/run.js CHANGED
@@ -303,7 +303,8 @@ const runRevokeIds = Effect.fn("okfit/verify/runRevokeIds")(function* (options)
303
303
  });
304
304
  /**
305
305
  * Issue #138. Attests every concept selected by `options.types` (or, when
306
- * empty, every type whose declaration sets `require_verified = true`) that
306
+ * empty, every type whose declaration sets `require_verified = true`, plus
307
+ * every drifted concept of any type) that
307
308
  * is not a draft, is not deprecated (#143) and whose `verified` entry by the
308
309
  * resolved actor does not already bind its current content (`Trust.signals`). Every candidate is located FIRST -- an unsupported
309
310
  * `verified` shape on any one of them fails the whole batch with nothing
@@ -320,7 +321,7 @@ const runVerifyBatch = Effect.fn("okfit/verify/runVerifyBatch")(function* (optio
320
321
  });
321
322
  const at = Schema.encodeSync(Timestamp)(options.at);
322
323
  const signals = yield* Trust.signals(bundle, options.config, options.at);
323
- const selection = selectAttestable(bundle, types, actor, signals);
324
+ const selection = selectAttestable(bundle, types, actor, signals, { drifted: options.types.length === 0 });
324
325
  const prepared = [];
325
326
  for (const concept of selection.candidates) prepared.push({
326
327
  id: concept.id,
package/verify/select.js CHANGED
@@ -13,14 +13,17 @@ const attestedBy = (concept, actor, signals) => signals.get(concept.id)?.integri
13
13
  * batch. A draft is unsettled and a deprecated concept is retired (#143), so
14
14
  * both are skipped before the already-verified check. A concept whose
15
15
  * verification has drifted, or is bound to another actor, is a candidate.
16
+ * With `options.drifted`, a drifted concept of any type is considered too,
17
+ * as the picker does: the `verified-drift` lint's remedy is `okfit verify`.
16
18
  *
17
19
  * @public
18
20
  */
19
- const selectAttestable = (bundle, types, actor, signals) => {
21
+ const selectAttestable = (bundle, types, actor, signals, options = {}) => {
20
22
  const candidates = [];
21
23
  const skipped = [];
22
24
  for (const [id, concept] of bundle.concepts) {
23
- if (!types.has(concept.frontmatter.type)) continue;
25
+ const drifted = options.drifted === true && signals.get(id)?.integrity === "drifted";
26
+ if (!types.has(concept.frontmatter.type) && !drifted) continue;
24
27
  const status = concept.frontmatter.status;
25
28
  if (status === "draft" || status === "deprecated") {
26
29
  skipped.push({
@@ -50,8 +53,11 @@ const boundAtOf = (concept) => {
50
53
  };
51
54
  /**
52
55
  * Every concept whose type sets `require_verified` that `actor` has not
53
- * attested: drafts included, deprecated concepts and the actor's own still-bound
54
- * attestations excluded (a drifted one is offered again). Sorted by type, then id; grouping is the caller's.
56
+ * attested, plus every drifted concept of any type (a human verified it once
57
+ * and its content has changed since, so the `verified-drift` lint sends the
58
+ * reader here): drafts included, deprecated concepts and the actor's own
59
+ * still-bound attestations excluded (a drifted one is offered again). Sorted
60
+ * by type, then id; grouping is the caller's.
55
61
  *
56
62
  * @public
57
63
  */
@@ -60,7 +66,8 @@ const selectPickerCandidates = (bundle, config, actor, signals) => {
60
66
  const rows = [];
61
67
  for (const [id, concept] of bundle.concepts) {
62
68
  const { type, status, title, description } = concept.frontmatter;
63
- if (!types.has(type) || status === "deprecated") continue;
69
+ const drifted = signals.get(id)?.integrity === "drifted";
70
+ if (!types.has(type) && !drifted || status === "deprecated") continue;
64
71
  const verified = concept.frontmatter.verified ?? [];
65
72
  if (attestedBy(concept, actor, signals)) continue;
66
73
  rows.push({
package/version.js CHANGED
@@ -11,6 +11,6 @@
11
11
  *
12
12
  * @public
13
13
  */
14
- const ENGINE_VERSION = "0.18.0";
14
+ const ENGINE_VERSION = "0.18.2";
15
15
 
16
16
  export { ENGINE_VERSION };