@okfit/engine 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import { AppDirs, AppDirs as AppDirs$1, Xdg, Xdg as Xdg$1, XdgEnvError } from "@effected/xdg";
1
2
  import { Actor, BundleLoadError, ConceptId, Diagnostic, DiagnosticRange, DiagnosticSeverity, GraphLink, GraphNode, GraphNodeKind, LinkGraph, LoadedBundle, LoadedConcept, OkfitConfig, OkfitConfigFile, PathField, StaleConcept, Status, ValidationReport } from "@okfit/core";
2
3
  import { Context, Crypto, DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Result, Runtime, Schema } from "effect";
3
- import { AppDirs, Xdg } from "@effected/xdg";
4
4
  import { ConfigReadError } from "@effected/config-file";
5
5
  import { ConceptSignal, DriftReason, GeneratedAtError, GitHistory, GitHistoryError, IntegrityState, Layout, Profile, ProfileDiagnostic } from "@okfit/profiles";
6
6
  import { FrontmatterWriteError, MarkdownEdit, MarkdownParseError } from "@effected/markdown";
@@ -367,7 +367,7 @@ export declare const buildConfigLayer: (options: {
367
367
  * in test environments. No production call site sets it.
368
368
  */
369
369
  readonly systemConfigDir?: string;
370
- }) => Layer.Layer<OkfitConfigFile, never, FileSystem.FileSystem | Path.Path | AppDirs | Xdg>;
370
+ }) => Layer.Layer<OkfitConfigFile, never, FileSystem.FileSystem | Path.Path | AppDirs$1 | Xdg$1>;
371
371
  /**
372
372
  * The K-1 pre-flight and the provide, in that order and in one place: stat
373
373
  * `explicitConfigPath` with `FileSystem.exists` and fail with
@@ -406,7 +406,7 @@ export declare const provideConfig: (options: {
406
406
  readonly explicitConfigPath: Option.Option<string>;
407
407
  readonly discoveryCwd: string;
408
408
  readonly systemConfigDir?: string;
409
- }) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | ConfigPathNotFoundError | ConfigMalformedError | PlatformError.PlatformError, Exclude<R, OkfitConfigFile> | FileSystem.FileSystem | Path.Path | AppDirs | Xdg>;
409
+ }) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | ConfigPathNotFoundError | ConfigMalformedError | PlatformError.PlatformError, Exclude<R, OkfitConfigFile> | FileSystem.FileSystem | Path.Path | AppDirs$1 | Xdg$1>;
410
410
  /**
411
411
  * `OkfitConfig.DEFAULTS.bundle.profile` is `"software-project"` at runtime
412
412
  * (the frozen literal always sets it), but `bundle` and `profile` are both
@@ -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.
@@ -893,7 +893,7 @@ export declare const layerOverlayFileSystem: Layer.Layer<FileSystem.FileSystem,
893
893
  *
894
894
  * @public
895
895
  */
896
- export declare const OkfitPlatform: Layer.Layer<AppDirs | Xdg | NodeServices.NodeServices, import("@effected/xdg").XdgEnvError, never>;
896
+ export declare const OkfitPlatform: Layer.Layer<AppDirs$1 | Xdg$1 | NodeServices.NodeServices, import("@effected/xdg").XdgEnvError, never>;
897
897
  /**
898
898
  * Filter for {@link ConceptQuery.list}. Every field is optional; an absent
899
899
  * field does not constrain.
@@ -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
@@ -2881,5 +2889,5 @@ export declare const loadPreviews: (candidates: readonly PickerCandidate[]) => E
2881
2889
  * @public
2882
2890
  */
2883
2891
  export declare const ENGINE_VERSION: string;
2884
- export type { AttestableSelection, BundleSessionOptions, BundleSessionServices, BundleSessionShape, ChangeSince, ConceptFilter, ConceptLink, ConceptNeighbor, ContextResult, ContextRunOptions, ContextTrustOptions, DiagnosticSource, DiscoveredConfig, Distribution, DocumentInput, DriftInspection, ExternalReferencesShape, GraphRunOptions, GraphRunResult, MovePlan, OverlayDocument, OverlayDocumentsShape, PendingWrite, PickerCandidate, PickerCandidatesOptions, PlanError, PlanMoveOptions, Reference, RenderedDiagnostic, ResolveProjectConfigInput, ResolvedProjectConfig, ResolvedTarget, RevalidateError, RevalidateOptions, RevalidateResult, RevalidateTier, RevokeIdsOptions, RevokeOptions, RevokeResult, RunMoveOptions, RunOptions, RunResult, ScaffoldFile, ScaffoldOptions, StaleRunOptions, StaleRunResult, SyncMode, SyncModeResult, SyncOptions, SyncPlan, SyncResult, Tally, UnlocatableReference, VerifyBatchOptions, VerifyBatchResult, VerifyBatchSkipReason, VerifyIdsOptions, VerifyOptions, VerifyResult, WatchedFilesOutcome };
2892
+ export type { AppDirs, AttestableSelection, BundleSessionOptions, BundleSessionServices, BundleSessionShape, ChangeSince, ConceptFilter, ConceptLink, ConceptNeighbor, ContextResult, ContextRunOptions, ContextTrustOptions, DiagnosticSource, DiscoveredConfig, Distribution, DocumentInput, DriftInspection, ExternalReferencesShape, GraphRunOptions, GraphRunResult, MovePlan, OverlayDocument, OverlayDocumentsShape, PendingWrite, PickerCandidate, PickerCandidatesOptions, PlanError, PlanMoveOptions, Reference, RenderedDiagnostic, ResolveProjectConfigInput, ResolvedProjectConfig, ResolvedTarget, RevalidateError, RevalidateOptions, RevalidateResult, RevalidateTier, RevokeIdsOptions, RevokeOptions, RevokeResult, RunMoveOptions, RunOptions, RunResult, ScaffoldFile, ScaffoldOptions, StaleRunOptions, StaleRunResult, SyncMode, SyncModeResult, SyncOptions, SyncPlan, SyncResult, Tally, UnlocatableReference, VerifyBatchOptions, VerifyBatchResult, VerifyBatchSkipReason, VerifyIdsOptions, VerifyOptions, VerifyResult, WatchedFilesOutcome, Xdg, XdgEnvError };
2885
2893
  //# sourceMappingURL=index.d.ts.map
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.17.0",
3
+ "version": "0.18.1",
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": [
@@ -35,21 +35,21 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@effect/platform-node": "^4.0.6",
38
- "@effected/app": "^0.27.0",
39
- "@effected/config-file": "^0.20.0",
40
- "@effected/engine": "^0.8.0",
41
- "@effected/git": "^0.25.0",
42
- "@effected/glob": "^0.14.0",
43
- "@effected/jsonc": "^0.20.0",
38
+ "@effected/app": "^0.28.0",
39
+ "@effected/config-file": "^0.21.0",
40
+ "@effected/engine": "^0.9.0",
41
+ "@effected/git": "^0.26.0",
42
+ "@effected/glob": "^0.15.0",
43
+ "@effected/jsonc": "^0.20.1",
44
44
  "@effected/markdown": "^0.23.0",
45
- "@effected/schemastore": "^0.26.2",
46
- "@effected/store": "^0.19.0",
45
+ "@effected/schemastore": "^0.26.3",
46
+ "@effected/store": "^0.20.0",
47
47
  "@effected/toml": "^0.16.0",
48
- "@effected/walker": "^0.20.0",
49
- "@effected/xdg": "^0.15.0",
48
+ "@effected/walker": "^0.21.0",
49
+ "@effected/xdg": "^0.16.0",
50
50
  "@effected/yaml": "^0.25.1",
51
- "@okfit/core": "0.11.6",
52
- "@okfit/profiles": "0.11.0",
51
+ "@okfit/core": "0.11.7",
52
+ "@okfit/profiles": "0.12.0",
53
53
  "effect": "^4.0.6"
54
54
  },
55
55
  "engines": {
package/sync/run.js CHANGED
@@ -61,7 +61,8 @@ 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
+ const worktree = yield* Derivation.worktreeRoot(bundle.root);
65
+ repoRoot = worktree !== void 0 ? yield* fs.realPath(worktree) : yield* git.repoRoot(bundle.root);
65
66
  const stagedPaths = new Set(yield* git.stagedChanges(repoRoot));
66
67
  const selected = /* @__PURE__ */ new Set();
67
68
  const provenanceStaged = /* @__PURE__ */ new Map();
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.17.0";
14
+ const ENGINE_VERSION = "0.18.1";
15
15
 
16
16
  export { ENGINE_VERSION };