@okfit/engine 0.18.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.
- package/edits/FrontmatterEdits.js +1 -3
- package/index.d.ts +13 -5
- package/overlay/layer.js +14 -8
- package/package.json +13 -13
- package/sync/run.js +2 -1
- package/verify/locate.js +2 -1
- package/verify/run.js +3 -2
- package/verify/select.js +12 -5
- package/version.js +1 -1
|
@@ -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" ||
|
|
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
|
@@ -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 `
|
|
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
|
|
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
|
|
2003
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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) =>
|
|
84
|
-
|
|
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.
|
|
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.
|
|
39
|
-
"@effected/config-file": "^0.
|
|
40
|
-
"@effected/engine": "^0.
|
|
41
|
-
"@effected/git": "^0.
|
|
42
|
-
"@effected/glob": "^0.
|
|
43
|
-
"@effected/jsonc": "^0.20.
|
|
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.
|
|
46
|
-
"@effected/store": "^0.
|
|
45
|
+
"@effected/schemastore": "^0.26.3",
|
|
46
|
+
"@effected/store": "^0.20.0",
|
|
47
47
|
"@effected/toml": "^0.16.0",
|
|
48
|
-
"@effected/walker": "^0.
|
|
49
|
-
"@effected/xdg": "^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.
|
|
52
|
-
"@okfit/profiles": "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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
54
|
-
*
|
|
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
|
-
|
|
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({
|