@okfit/engine 0.18.1 → 0.19.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/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
  /**
@@ -85,6 +86,25 @@ var VerifyUnsupportedFrontmatterError = class extends Schema.TaggedError()("Veri
85
86
  }
86
87
  };
87
88
  /**
89
+ * `okfit verify` cannot bind a verification to a concept whose content cannot be
90
+ * hashed: a frontmatter value holds an unpaired surrogate (a YAML `"\\uD800"`
91
+ * escape), which the content digest's canonical JSON refuses (okfit#327). Nothing
92
+ * was written. Exit 3, like the other verify refusals.
93
+ *
94
+ * @public
95
+ */
96
+ var VerifyContentUnhashableError = class extends Schema.TaggedError()("VerifyContentUnhashableError", {
97
+ id: Schema.String,
98
+ path: Schema.Array(Schema.Union([Schema.String, Schema.Number])),
99
+ detail: Schema.String
100
+ }) {
101
+ [Runtime.errorExitCode] = 3;
102
+ get message() {
103
+ const where = this.path.length === 0 ? "its frontmatter" : this.path.join(".");
104
+ return `"${this.id}" cannot be verified: ${where} cannot be hashed (${this.detail}); fix the value, then re-run okfit verify`;
105
+ }
106
+ };
107
+ /**
88
108
  * `okfit verify --revoke` found no `verified` entry by the resolved actor on
89
109
  * the concept, so there is nothing to remove. Exit 3, like any other verify
90
110
  * outcome that cannot proceed on the concept.
@@ -100,14 +120,6 @@ var VerifyNothingToRevokeError = class extends Schema.TaggedError()("VerifyNothi
100
120
  return `"${this.id}" has no verified entry by ${this.actor} to revoke`;
101
121
  }
102
122
  };
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
123
  /**
112
124
  * A config file at a KNOWN path failed to parse or validate (K-46's own
113
125
  * intent — "each class' message already names the offending path" does not
@@ -124,7 +136,7 @@ var ConfigMalformedError = class extends Schema.TaggedError()("ConfigMalformedEr
124
136
  }) {
125
137
  [Runtime.errorExitCode] = 3;
126
138
  get message() {
127
- return `malformed config ${this.path}: ${messageOf(this.cause)}`;
139
+ return `malformed config ${this.path}: ${ErrorText.describe(this.cause)}`;
128
140
  }
129
141
  };
130
142
  /**
@@ -334,4 +346,4 @@ var MoveError = class extends Schema.TaggedError()("MoveError", {
334
346
  }
335
347
  };
336
348
 
337
- export { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError };
349
+ export { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError };
package/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { AppDirs, AppDirs as AppDirs$1, Xdg, Xdg as Xdg$1, XdgEnvError } from "@effected/xdg";
2
2
  import { Actor, BundleLoadError, ConceptId, Diagnostic, DiagnosticRange, DiagnosticSeverity, GraphLink, GraphNode, GraphNodeKind, LinkGraph, LoadedBundle, LoadedConcept, OkfitConfig, OkfitConfigFile, PathField, StaleConcept, Status, ValidationReport } from "@okfit/core";
3
- import { Context, Crypto, DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Result, Runtime, Schema } from "effect";
3
+ import { Context, DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Result, Runtime, Schema } from "effect";
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";
7
7
  import { YamlParseError } from "@effected/yaml";
8
+ import { Digest } from "effect/crypto";
8
9
  import * as NodeServices from "@effect/platform-node/NodeServices";
9
10
  import { Distribution as Distribution$1 } from "@effected/engine";
10
11
  import { Git, GitCommandError, UnknownRefError } from "@effected/git";
11
- import { ChildProcessSpawner } from "effect/process";
12
12
  /**
13
13
  * What {@link resolveProjectRoot} needs about the winning discovery source
14
14
  * (K-12, K-58). Narrower than `@effected/config-file`'s own
@@ -140,6 +140,23 @@ export declare class VerifyUnsupportedFrontmatterError extends VerifyUnsupported
140
140
  readonly [Runtime.errorExitCode] = 3;
141
141
  get message(): string;
142
142
  }
143
+ declare const VerifyContentUnhashableError_base: Schema.Class<VerifyContentUnhashableError, Schema.TaggedStruct<"VerifyContentUnhashableError", {
144
+ readonly id: Schema.String;
145
+ readonly path: Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>;
146
+ readonly detail: Schema.String;
147
+ }>, import("effect/Cause").YieldableError>;
148
+ /**
149
+ * `okfit verify` cannot bind a verification to a concept whose content cannot be
150
+ * hashed: a frontmatter value holds an unpaired surrogate (a YAML `"\\uD800"`
151
+ * escape), which the content digest's canonical JSON refuses (okfit#327). Nothing
152
+ * was written. Exit 3, like the other verify refusals.
153
+ *
154
+ * @public
155
+ */
156
+ export declare class VerifyContentUnhashableError extends VerifyContentUnhashableError_base {
157
+ readonly [Runtime.errorExitCode] = 3;
158
+ get message(): string;
159
+ }
143
160
  declare const VerifyNothingToRevokeError_base: Schema.Class<VerifyNothingToRevokeError, Schema.TaggedStruct<"VerifyNothingToRevokeError", {
144
161
  readonly id: Schema.String;
145
162
  readonly actor: Schema.String;
@@ -780,7 +797,7 @@ type PlanError = MoveError | TargetResolutionError | BundleLoadError | PlatformE
780
797
  *
781
798
  * @public
782
799
  */
783
- export declare const planMove: (options: PlanMoveOptions) => Effect.Effect<MovePlan, PlanError, Crypto.Crypto | FileSystem.FileSystem | Path.Path>;
800
+ export declare const planMove: (options: PlanMoveOptions) => Effect.Effect<MovePlan, PlanError, Digest.Digest | FileSystem.FileSystem | Path.Path>;
784
801
  /**
785
802
  * Plan the move, then (unless `dryRun`) write it: every referrer atomically, the moved file's new
786
803
  * text over its old path, then a rename to the destination (its directory created first). Nothing is
@@ -792,7 +809,7 @@ export declare const runMove: (options: RunMoveOptions) => Effect.Effect<{
792
809
  readonly plan: MovePlan;
793
810
  readonly bundleRoot: string;
794
811
  readonly dryRun: boolean;
795
- }, PlanError, Crypto.Crypto | FileSystem.FileSystem | Path.Path>;
812
+ }, PlanError, Digest.Digest | FileSystem.FileSystem | Path.Path>;
796
813
  /**
797
814
  * One unsaved document: `path` is bundle-relative posix (`metrics/churn.md`),
798
815
  * `text` the full file contents.
@@ -865,7 +882,8 @@ export declare class OverlayDocuments extends OverlayDocuments_base {
865
882
  }
866
883
  /**
867
884
  * Wrap `underlying` so `readFile`, `readFileString`, `exists`, `stat` and `lstat` answer
868
- * from `documents` for open paths, and a non-recursive `readDirectory` also lists
885
+ * from `documents` for open paths, and a non-recursive `readDirectory` (and
886
+ * `readDirectoryEntries`, Effect 4.1's typed listing, as a `"File"`) also lists
869
887
  * open documents whose parent is the directory read (so a brand-new unsaved file
870
888
  * is walked). Every other member, and every path not open, is `underlying`'s.
871
889
  *
@@ -883,8 +901,9 @@ export declare const layerOverlayFileSystem: Layer.Layer<FileSystem.FileSystem,
883
901
  * `Layer.provide(Xdg.layer)` alone does not close it.
884
902
  * `Layer.provideMerge(NodeServices.layer)` supplies `FileSystem`/`Path` to
885
903
  * both members and keeps every service in the output.
886
- * `NodeServices.layer` provides `ChildProcessSpawner | Crypto | FileSystem | Path | Stdio | Terminal`,
887
- * a superset of `Command.Environment`.
904
+ * `NodeServices.layer` provides `ChildProcessSpawner | FileSystem | Path | Stdio | Terminal`,
905
+ * a superset of `Command.Environment`. Since Effect 4.1 it carries no crypto, so
906
+ * `NodeCrypto.layerDigest` supplies the `Digest` every body and content digest needs.
888
907
  *
889
908
  * K-13: `Xdg.layer` fails with `XdgEnvError` when `HOME` is unset. Callers
890
909
  * are responsible for providing this layer INSIDE whatever region renders
@@ -893,7 +912,7 @@ export declare const layerOverlayFileSystem: Layer.Layer<FileSystem.FileSystem,
893
912
  *
894
913
  * @public
895
914
  */
896
- export declare const OkfitPlatform: Layer.Layer<AppDirs$1 | Xdg$1 | NodeServices.NodeServices, import("@effected/xdg").XdgEnvError, never>;
915
+ export declare const OkfitPlatform: Layer.Layer<AppDirs$1 | import("effect/crypto/Digest").Digest | Xdg$1 | NodeServices.NodeServices, import("@effected/xdg").XdgEnvError, never>;
897
916
  /**
898
917
  * Filter for {@link ConceptQuery.list}. Every field is optional; an absent
899
918
  * field does not constrain.
@@ -1457,7 +1476,7 @@ export declare const moveEnvelope: (input: {
1457
1476
  * @public
1458
1477
  */
1459
1478
  export declare const TrustDrift: Schema.Struct<{
1460
- readonly reason: Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed"]>;
1479
+ readonly reason: Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed", "content-unhashable"]>;
1461
1480
  readonly edited_by: Schema.NullOr<Schema.String>;
1462
1481
  readonly edited_at: Schema.NullOr<Schema.String>;
1463
1482
  }>;
@@ -1545,7 +1564,7 @@ export declare const QueryGetEnvelope: Schema.Struct<{
1545
1564
  readonly integrity: Schema.Literals<readonly ["current", "drifted", "none"]>;
1546
1565
  readonly stale: Schema.Boolean;
1547
1566
  readonly drift: Schema.NullOr<Schema.Struct<{
1548
- readonly reason: Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed"]>;
1567
+ readonly reason: Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed", "content-unhashable"]>;
1549
1568
  readonly edited_by: Schema.NullOr<Schema.String>;
1550
1569
  readonly edited_at: Schema.NullOr<Schema.String>;
1551
1570
  }>>;
@@ -1808,7 +1827,7 @@ interface SyncPlan {
1808
1827
  *
1809
1828
  * @public
1810
1829
  */
1811
- export declare const planSync: (options: SyncOptions) => Effect.Effect<SyncPlan, BundleLoadError | GeneratedAtError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Crypto.Crypto>;
1830
+ export declare const planSync: (options: SyncOptions) => Effect.Effect<SyncPlan, BundleLoadError | GeneratedAtError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Digest.Digest>;
1812
1831
  /**
1813
1832
  * Performs exactly the writes a {@link SyncPlan} recorded (atomically, in plan
1814
1833
  * order), then the `--staged` re-add, and returns the non-dry-run
@@ -1831,7 +1850,7 @@ export declare const applySyncPlan: (plan: SyncPlan) => Effect.Effect<{
1831
1850
  *
1832
1851
  * @public
1833
1852
  */
1834
- export declare const runSync: (options: SyncOptions) => Effect.Effect<SyncResult, BundleLoadError | GeneratedAtError | SyncPlanStaleError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Crypto.Crypto>;
1853
+ export declare const runSync: (options: SyncOptions) => Effect.Effect<SyncResult, BundleLoadError | GeneratedAtError | SyncPlanStaleError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Digest.Digest>;
1835
1854
  /** @public */
1836
1855
  export declare const SyncModeEnvelope: Schema.Struct<{
1837
1856
  readonly selected: Schema.Boolean;
@@ -2061,7 +2080,7 @@ export declare const VerifyEnvelope: Schema.Struct<{
2061
2080
  readonly to: Schema.Literals<readonly ["stable", "draft"]>;
2062
2081
  }>>;
2063
2082
  /** Why the prior human verification no longer bound the concept; absent when it did not drift. */
2064
- readonly prior_integrity: Schema.optionalKey<Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed"]>>;
2083
+ readonly prior_integrity: Schema.optionalKey<Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed", "content-unhashable"]>>;
2065
2084
  readonly dry_run: Schema.Boolean;
2066
2085
  readonly exit_code: Schema.Literal<0>;
2067
2086
  }>;
@@ -2231,7 +2250,7 @@ interface WatchedFilesOutcome {
2231
2250
  *
2232
2251
  * @public
2233
2252
  */
2234
- type BundleSessionServices = FileSystem.FileSystem | Path.Path | Git | GitHistory | Crypto.Crypto;
2253
+ type BundleSessionServices = FileSystem.FileSystem | Path.Path | Git | GitHistory | Digest.Digest;
2235
2254
  /** @public */
2236
2255
  interface BundleSessionShape {
2237
2256
  /** Absolute, resolved bundle root. */
@@ -2349,7 +2368,7 @@ export declare const stampPublication: (options: {
2349
2368
  readonly bundleRoot: string;
2350
2369
  readonly id: string;
2351
2370
  readonly dryRun: boolean;
2352
- }) => Effect.Effect<PublicationEnvelope, PublicationNotFoundError | NotAPublicationError | BundleLoadError | YamlParseError | UnsupportedFrontmatterError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Crypto.Crypto>;
2371
+ }) => Effect.Effect<PublicationEnvelope, PublicationNotFoundError | NotAPublicationError | BundleLoadError | YamlParseError | UnsupportedFrontmatterError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Digest.Digest>;
2353
2372
  /**
2354
2373
  * One resolved concept target: the argument as typed, the bundle-relative
2355
2374
  * posix file path, and the concept id (absent only for a non-concept file
@@ -2398,7 +2417,7 @@ interface ContextTrustOptions {
2398
2417
  *
2399
2418
  * @public
2400
2419
  */
2401
- export declare const runContextTrust: (options: ContextTrustOptions) => Effect.Effect<ContextTrust, BundleLoadError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Crypto.Crypto>;
2420
+ export declare const runContextTrust: (options: ContextTrustOptions) => Effect.Effect<ContextTrust, BundleLoadError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Digest.Digest>;
2402
2421
  declare const Now_base: Context.ServiceClass<Now, "@okfit/engine/Now", DateTime.Utc>;
2403
2422
  /**
2404
2423
  * K-47's ambient clock. `bin.ts` resolves `OKFIT_NOW` (or the wall clock)
@@ -2481,7 +2500,7 @@ interface RunResult {
2481
2500
  *
2482
2501
  * @public
2483
2502
  */
2484
- export declare const run: (options: RunOptions) => Effect.Effect<RunResult, BundleLoadError | GitHistoryError | GitCommandError | UnknownRefError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Git | GitHistory | Crypto.Crypto>;
2503
+ export declare const run: (options: RunOptions) => Effect.Effect<RunResult, BundleLoadError | GitHistoryError | GitCommandError | UnknownRefError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Git | GitHistory | Digest.Digest>;
2485
2504
  /**
2486
2505
  * What changed in a concept file since a human last verified it.
2487
2506
  *
@@ -2509,11 +2528,10 @@ type ChangeSince = {
2509
2528
  * at or before `at`; the patch is `git diff <baseline> -- <file>`.
2510
2529
  *
2511
2530
  * Git access: `@effected/git`'s `Git.log` (scoped to the file, newest first,
2512
- * filtered here on `committedAt`) finds the baseline. `Git.log` has no `until`,
2513
- * and no `Git` member returns a patch (`show` returns a blob, `nameStatus` only
2514
- * paths), so the diff itself runs `git diff` through `effect/process`'s
2515
- * `ChildProcessSpawner`, the same spawner `Git.layer` is built on. Spawn
2516
- * failure maps onto `Git`'s own `GitCommandError`.
2531
+ * filtered here on `committedAt`) finds the baseline (`Git.log` has no
2532
+ * `until`), and `Git.diffFile` produces the patch with the output-shaping
2533
+ * flags pinned, so user git config cannot change its bytes. Every diff
2534
+ * failure is reported as `GitCommandError`, the one error callers handle.
2517
2535
  *
2518
2536
  * @param options - `file` is the absolute path of the concept file; `at` is the
2519
2537
  * time the binding recorded.
@@ -2537,7 +2555,7 @@ export declare const changeSince: (options: {
2537
2555
  _tag: "diff";
2538
2556
  baseline: string;
2539
2557
  patch: string;
2540
- }, GitCommandError, ChildProcessSpawner.ChildProcessSpawner | Git | Path.Path>;
2558
+ }, GitCommandError, Git | Path.Path>;
2541
2559
  /** @internal */
2542
2560
  interface VerifyOptions {
2543
2561
  readonly id: string;
@@ -2644,8 +2662,8 @@ export declare const runVerify: (options: VerifyOptions) => Effect.Effect<{
2644
2662
  } | null;
2645
2663
  statusFragment: string | null;
2646
2664
  content: string;
2647
- priorDrift: "actor-not-allowed" | "content-changed" | "entry-superseded" | "unbound" | null;
2648
- }, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/Crypto").Crypto | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2665
+ priorDrift: "actor-not-allowed" | "content-changed" | "content-unhashable" | "entry-superseded" | "unbound" | null;
2666
+ }, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyContentUnhashableError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2649
2667
  /**
2650
2668
  * What {@link inspectDrift} found out about one concept before a re-verify.
2651
2669
  *
@@ -2675,9 +2693,9 @@ export declare const inspectDrift: (options: {
2675
2693
  }) => Effect.Effect<{
2676
2694
  id: ConceptId;
2677
2695
  absolutePath: string;
2678
- drift: "actor-not-allowed" | "content-changed" | "entry-superseded" | "unbound" | null;
2696
+ drift: "actor-not-allowed" | "content-changed" | "content-unhashable" | "entry-superseded" | "unbound" | null;
2679
2697
  boundAt?: DateTime.Utc;
2680
- }, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | import("@okfit/core").BundleLoadError, import("effect/Crypto").Crypto | FileSystem.FileSystem | Path.Path>;
2698
+ }, VerifyConceptNotFoundError | import("@okfit/core").BundleLoadError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | Path.Path>;
2681
2699
  /**
2682
2700
  * Options for {@link runRevoke}.
2683
2701
  *
@@ -2782,7 +2800,7 @@ export declare const runVerifyBatch: (options: VerifyBatchOptions) => Effect.Eff
2782
2800
  readonly id: string;
2783
2801
  readonly reason: VerifyBatchSkipReason;
2784
2802
  }[];
2785
- }, import("effect/PlatformError").PlatformError | VerifySelectionError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/Crypto").Crypto | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2803
+ }, import("effect/PlatformError").PlatformError | VerifyContentUnhashableError | VerifySelectionError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2786
2804
  /**
2787
2805
  * Issue #214: options for {@link runVerifyIds}.
2788
2806
  *
@@ -2830,7 +2848,7 @@ export declare const runVerifyIds: (options: VerifyIdsOptions) => Effect.Effect<
2830
2848
  fragment: string;
2831
2849
  }[];
2832
2850
  skipped: never[];
2833
- }, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/Crypto").Crypto | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2851
+ }, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyContentUnhashableError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2834
2852
  /**
2835
2853
  * Options for {@link loadPickerCandidates}.
2836
2854
  *
@@ -2851,7 +2869,7 @@ interface PickerCandidatesOptions {
2851
2869
  export declare const loadPickerCandidates: (options: PickerCandidatesOptions) => Effect.Effect<{
2852
2870
  by: Actor;
2853
2871
  candidates: readonly PickerCandidate[];
2854
- }, import("effect/PlatformError").PlatformError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/Crypto").Crypto | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2872
+ }, import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2855
2873
  /**
2856
2874
  * Issue #228: as {@link loadPickerCandidates}, but the rows are the concepts
2857
2875
  * stale at `now` (any type, the actor's own attestations included), for
@@ -2864,7 +2882,7 @@ export declare const loadStaleCandidates: (options: PickerCandidatesOptions & {
2864
2882
  }) => Effect.Effect<{
2865
2883
  by: Actor;
2866
2884
  candidates: readonly PickerCandidate[];
2867
- }, import("effect/PlatformError").PlatformError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/Crypto").Crypto | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2885
+ }, import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
2868
2886
  /**
2869
2887
  * The verify picker's diff previews: for each drifted candidate, in candidate
2870
2888
  * order and one at a time, what changed in its file since its verification was
@@ -2875,7 +2893,7 @@ export declare const loadStaleCandidates: (options: PickerCandidatesOptions & {
2875
2893
  *
2876
2894
  * @public
2877
2895
  */
2878
- export declare const loadPreviews: (candidates: readonly PickerCandidate[]) => Effect.Effect<ReadonlyMap<string, ChangeSince>, never, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("@effected/git").Git | Path.Path>;
2896
+ export declare const loadPreviews: (candidates: readonly PickerCandidate[]) => Effect.Effect<ReadonlyMap<string, ChangeSince>, never, import("@effected/git").Git | Path.Path>;
2879
2897
  /**
2880
2898
  * The version this engine reports as `engine_version` in every JSON
2881
2899
  * envelope. `@savvy-web/bundler` replaces `process.env.__PACKAGE_VERSION__`
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolveBundleRoot, resolveProjectRoot } from "./config/anchor.js";
2
- import { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError } from "./errors.js";
2
+ import { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError } from "./errors.js";
3
3
  import { buildConfigLayer, provideConfig } from "./config/layer.js";
4
4
  import { DEFAULT_PROFILE_NAME, resolveProjectConfig } from "./config/resolve.js";
5
5
  import { runContext } from "./context/run.js";
@@ -38,4 +38,4 @@ import { changeSince } from "./verify/diff.js";
38
38
  import { resolveBatchTypes, selectAttestable, selectPickerCandidates, selectStaleCandidates } from "./verify/select.js";
39
39
  import { inspectDrift, loadPickerCandidates, loadPreviews, loadStaleCandidates, runRevoke, runRevokeIds, runVerify, runVerifyBatch, runVerifyIds } from "./verify/run.js";
40
40
 
41
- export { BundleSession, CONFIG_RELATIVE_PATH, ConceptQuery, ConceptSummary, ConfigMalformedError, ConfigPathNotFoundError, ContextEnvelope, ContextField, ContextFieldValue, ContextTag, ContextTrust, ContextType, DEFAULT_PROFILE_NAME, DistributionField, DocumentPathError, ENGINE_VERSION, ExternalReferences, FrontmatterEdits, GraphEdgeEnvelope, GraphEnvelope, GraphNodeEnvelope, GraphSummary, InitOverwriteError, JsonDiagnostic, JsonEnvelope, JsonErrorEnvelope, JsonSummary, MoveEnvelope, MoveError, NotAPublicationError, Now, OkfitPlatform, OverlayDocuments, PublicationEnvelope, PublicationNotFoundError, QueryConceptNotFoundError, QueryGetEnvelope, QueryLink, QueryListEnvelope, QueryNeighbor, QueryNeighborsEnvelope, QuerySelectionError, QueryUnknownVocabularyError, ReferenceCheck, ReferenceState, RevokeEnvelope, SkipReason, StaleEnvelope, StaleItem, StaleSummary, SyncEnvelope, SyncModeEnvelope, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, Targets, TrustDrift, UnsupportedFrontmatterError, VerifyBatchEnvelope, VerifyConceptNotFoundError, VerifyEnvelope, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError, applySyncPlan, buildConfigLayer, changeSince, collect, conceptFor, configValue, contextEnvelope, files, forDiagnostics, graphEnvelope, inspectDrift, json, jsonError, layerOverlayFileSystem, loadPickerCandidates, loadPreviews, loadStaleCandidates, makeOverlayFileSystem, moveEnvelope, planMove, planSync, provideConfig, provideDocuments, queryGetEnvelope, queryListEnvelope, queryNeighborsEnvelope, referencesOf, resolveBatchTypes, resolveBundleRoot, resolveDocumentPath, resolveProjectConfig, resolveProjectRoot, revokeEnvelope, rewriteReference, run, runContext, runContextTrust, runGraph, runMove, runRevoke, runRevokeIds, runStale, runSync, runVerify, runVerifyBatch, runVerifyIds, selectAttestable, selectPickerCandidates, selectStaleCandidates, signalFor, sort, staleEnvelope, stampPublication, syncEnvelope, tally, targetPaths, toConceptSummary, toTrustDrift, verifyBatchEnvelope, verifyEnvelope, withFallbackRange };
41
+ export { BundleSession, CONFIG_RELATIVE_PATH, ConceptQuery, ConceptSummary, ConfigMalformedError, ConfigPathNotFoundError, ContextEnvelope, ContextField, ContextFieldValue, ContextTag, ContextTrust, ContextType, DEFAULT_PROFILE_NAME, DistributionField, DocumentPathError, ENGINE_VERSION, ExternalReferences, FrontmatterEdits, GraphEdgeEnvelope, GraphEnvelope, GraphNodeEnvelope, GraphSummary, InitOverwriteError, JsonDiagnostic, JsonEnvelope, JsonErrorEnvelope, JsonSummary, MoveEnvelope, MoveError, NotAPublicationError, Now, OkfitPlatform, OverlayDocuments, PublicationEnvelope, PublicationNotFoundError, QueryConceptNotFoundError, QueryGetEnvelope, QueryLink, QueryListEnvelope, QueryNeighbor, QueryNeighborsEnvelope, QuerySelectionError, QueryUnknownVocabularyError, ReferenceCheck, ReferenceState, RevokeEnvelope, SkipReason, StaleEnvelope, StaleItem, StaleSummary, SyncEnvelope, SyncModeEnvelope, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, Targets, TrustDrift, UnsupportedFrontmatterError, VerifyBatchEnvelope, VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyEnvelope, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError, applySyncPlan, buildConfigLayer, changeSince, collect, conceptFor, configValue, contextEnvelope, files, forDiagnostics, graphEnvelope, inspectDrift, json, jsonError, layerOverlayFileSystem, loadPickerCandidates, loadPreviews, loadStaleCandidates, makeOverlayFileSystem, moveEnvelope, planMove, planSync, provideConfig, provideDocuments, queryGetEnvelope, queryListEnvelope, queryNeighborsEnvelope, referencesOf, resolveBatchTypes, resolveBundleRoot, resolveDocumentPath, resolveProjectConfig, resolveProjectRoot, revokeEnvelope, rewriteReference, run, runContext, runContextTrust, runGraph, runMove, runRevoke, runRevokeIds, runStale, runSync, runVerify, runVerifyBatch, runVerifyIds, selectAttestable, selectPickerCandidates, selectStaleCandidates, signalFor, sort, staleEnvelope, stampPublication, syncEnvelope, tally, targetPaths, toConceptSummary, toTrustDrift, verifyBatchEnvelope, verifyEnvelope, withFallbackRange };
package/move/run.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { MoveError } from "../errors.js";
2
2
  import { referencesOf, rewriteReference } from "./references.js";
3
3
  import { writeAtomic } from "../sync/write.js";
4
- import { relativeInside } from "../targets/inside.js";
5
4
  import { Targets } from "../targets/resolve.js";
6
5
  import { Bundle, ConceptId } from "@okfit/core";
7
6
  import { Effect, FileSystem, Option, Path } from "effect";
8
7
  import { Trust } from "@okfit/profiles";
9
8
  import { MarkdownEdit } from "@effected/markdown";
10
9
  import { posix } from "node:path";
10
+ import { relativeWithin } from "@effected/walker";
11
11
 
12
12
  // src/move/run.ts
13
13
  const withMd = (value) => value.endsWith(".md") ? value : `${value}.md`;
@@ -21,24 +21,20 @@ const resolveDestination = Effect.fn("okfit/move/destination")(function* (to, cw
21
21
  const fs = yield* FileSystem.FileSystem;
22
22
  const path = yield* Path.Path;
23
23
  const realOr = (absolute) => fs.realPath(absolute).pipe(Effect.orElseSucceed(() => absolute));
24
- /** Real path of the deepest existing ancestor, re-joined with the rest (the file does not exist yet). */
25
- const realish = (absolute) => Effect.gen(function* () {
26
- const resolved = yield* fs.realPath(absolute).pipe(Effect.option);
27
- if (Option.isSome(resolved)) return resolved.value;
28
- const parent = path.dirname(absolute);
29
- if (parent === absolute) return absolute;
30
- return path.join(yield* realish(parent), path.basename(absolute));
31
- });
32
24
  const root = yield* realOr(bundle.root);
33
- /** Bundle-relative posix path of `absolute` (`""` for the root itself); `undefined` outside the bundle. */
34
- const inside = (absolute) => relativeInside(path, root, absolute);
25
+ /**
26
+ * Bundle-relative posix path of `absolute` (`""` for the root itself), resolved physically through
27
+ * its deepest existing ancestor, since the destination does not exist yet (`@effected/walker`'s
28
+ * `relativeWithin`); `undefined` outside the bundle or when containment cannot be proved.
29
+ */
30
+ const within = (absolute) => Effect.map(relativeWithin(root, absolute), Option.getOrUndefined);
35
31
  const exists = (absolute) => fs.exists(absolute).pipe(Effect.orElseSucceed(() => false));
36
32
  const isDirectory = (absolute) => fs.stat(absolute).pipe(Effect.map((info) => info.type === "Directory"), Effect.orElseSucceed(() => false));
37
33
  const trailingSlash = /\/$/.test(to);
38
34
  const spelled = trailingSlash ? to.replace(/\/+$/, "") : to;
39
35
  const base = posix.basename(sourcePath);
40
36
  const underCwd = path.isAbsolute(spelled) ? spelled : path.resolve(cwd, spelled);
41
- const cwdPath = inside(yield* realish(underCwd));
37
+ const cwdPath = yield* within(underCwd);
42
38
  const lexicalInside = (base) => {
43
39
  const relative = path.relative(base, underCwd);
44
40
  return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
@@ -49,7 +45,7 @@ const resolveDestination = Effect.fn("okfit/move/destination")(function* (to, cw
49
45
  if (!idReadable) return void 0;
50
46
  const id = Option.getOrUndefined(ConceptId.normalize(spelled));
51
47
  if (id === void 0) return void 0;
52
- return inside(yield* realish(path.join(root, posix.normalize(id))));
48
+ return yield* within(path.join(root, posix.normalize(id)));
53
49
  });
54
50
  const dirs = [cwdPath, idPath].filter((candidate) => candidate !== void 0);
55
51
  const existingDir = yield* Effect.findFirst(dirs, (candidate) => isDirectory(path.join(root, candidate)));
package/overlay/layer.js CHANGED
@@ -71,7 +71,8 @@ const shadowInfo = (documents, path, read) => Effect.flatMap(documents.get(path)
71
71
  }));
72
72
  /**
73
73
  * Wrap `underlying` so `readFile`, `readFileString`, `exists`, `stat` and `lstat` answer
74
- * from `documents` for open paths, and a non-recursive `readDirectory` also lists
74
+ * from `documents` for open paths, and a non-recursive `readDirectory` (and
75
+ * `readDirectoryEntries`, Effect 4.1's typed listing, as a `"File"`) also lists
75
76
  * open documents whose parent is the directory read (so a brand-new unsaved file
76
77
  * is walked). Every other member, and every path not open, is `underlying`'s.
77
78
  *
@@ -95,11 +96,23 @@ const makeOverlayFileSystem = (underlying, documents) => FileSystem.FileSystem.o
95
96
  lstat: (path) => shadowInfo(documents, path, underlying.lstat),
96
97
  readDirectory: (path, options) => options?.recursive === true ? underlying.readDirectory(path, options) : Effect.gen(function* () {
97
98
  const names = yield* underlying.readDirectory(path, options);
98
- const directory = trimTrailingSeparators(path);
99
- const extra = (yield* documents.entries()).map(([key]) => parentAndName(key)).filter(([parent, name]) => parent === directory && !names.includes(name)).map(([, name]) => name);
99
+ const extra = yield* overlayOnlyNames(documents, path, names);
100
100
  return extra.length === 0 ? names : [...names, ...extra];
101
+ }),
102
+ readDirectoryEntries: (path) => Effect.gen(function* () {
103
+ const entries = yield* underlying.readDirectoryEntries(path);
104
+ const extra = yield* overlayOnlyNames(documents, path, entries.map((entry) => entry.name));
105
+ return extra.length === 0 ? entries : [...entries, ...extra.map((name) => ({
106
+ name,
107
+ type: "File"
108
+ }))];
101
109
  })
102
110
  });
111
+ /** Names of open documents directly under `path` that `listed` does not already hold. */
112
+ const overlayOnlyNames = (documents, path, listed) => Effect.map(documents.entries(), (entries) => {
113
+ const directory = trimTrailingSeparators(path);
114
+ return entries.map(([key]) => parentAndName(key)).filter(([parent, name]) => parent === directory && !listed.includes(name)).map(([, name]) => name);
115
+ });
103
116
  /**
104
117
  * The ambient `FileSystem`, shadowed by the ambient `OverlayDocuments`.
105
118
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okfit/engine",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
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.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
- "@effected/markdown": "^0.23.0",
45
- "@effected/schemastore": "^0.26.3",
46
- "@effected/store": "^0.20.0",
47
- "@effected/toml": "^0.16.0",
48
- "@effected/walker": "^0.21.0",
49
- "@effected/xdg": "^0.16.0",
50
- "@effected/yaml": "^0.25.1",
51
- "@okfit/core": "0.11.7",
52
- "@okfit/profiles": "0.12.0",
53
- "effect": "^4.0.6"
37
+ "@effect/platform-node": "~4.1.1",
38
+ "@effected/app": "^0.30.0",
39
+ "@effected/config-file": "^0.23.0",
40
+ "@effected/engine": "^0.11.0",
41
+ "@effected/git": "^0.29.0",
42
+ "@effected/glob": "^0.17.0",
43
+ "@effected/jsonc": "^0.22.0",
44
+ "@effected/markdown": "^0.25.0",
45
+ "@effected/schemastore": "^0.28.0",
46
+ "@effected/source": "^0.2.0",
47
+ "@effected/store": "^0.22.0",
48
+ "@effected/toml": "^0.18.0",
49
+ "@effected/walker": "^0.24.0",
50
+ "@effected/xdg": "^0.18.0",
51
+ "@effected/yaml": "^0.27.0",
52
+ "@okfit/core": "0.12.0",
53
+ "@okfit/profiles": "0.14.0",
54
+ "effect": "~4.1.1"
54
55
  },
55
56
  "engines": {
56
57
  "node": ">=24.11.0"
package/platform.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Layer } from "effect";
2
+ import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
2
3
  import * as NodeServices from "@effect/platform-node/NodeServices";
3
4
  import { AppDirs, Xdg } from "@effected/xdg";
4
5
 
@@ -16,8 +17,9 @@ const OKFIT_APP_NAMESPACE = "okfit";
16
17
  * `Layer.provide(Xdg.layer)` alone does not close it.
17
18
  * `Layer.provideMerge(NodeServices.layer)` supplies `FileSystem`/`Path` to
18
19
  * both members and keeps every service in the output.
19
- * `NodeServices.layer` provides `ChildProcessSpawner | Crypto | FileSystem | Path | Stdio | Terminal`,
20
- * a superset of `Command.Environment`.
20
+ * `NodeServices.layer` provides `ChildProcessSpawner | FileSystem | Path | Stdio | Terminal`,
21
+ * a superset of `Command.Environment`. Since Effect 4.1 it carries no crypto, so
22
+ * `NodeCrypto.layerDigest` supplies the `Digest` every body and content digest needs.
21
23
  *
22
24
  * K-13: `Xdg.layer` fails with `XdgEnvError` when `HOME` is unset. Callers
23
25
  * are responsible for providing this layer INSIDE whatever region renders
@@ -26,6 +28,6 @@ const OKFIT_APP_NAMESPACE = "okfit";
26
28
  *
27
29
  * @public
28
30
  */
29
- const OkfitPlatform = Layer.mergeAll(Xdg.layer, AppDirs.layer({ namespace: OKFIT_APP_NAMESPACE }).pipe(Layer.provide(Xdg.layer))).pipe(Layer.provideMerge(NodeServices.layer));
31
+ const OkfitPlatform = Layer.mergeAll(Xdg.layer, AppDirs.layer({ namespace: OKFIT_APP_NAMESPACE }).pipe(Layer.provide(Xdg.layer))).pipe(Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layerDigest)));
30
32
 
31
33
  export { OKFIT_APP_NAMESPACE, OkfitPlatform };
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,8 +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
- const worktree = yield* Derivation.worktreeRoot(bundle.root);
65
- repoRoot = worktree !== void 0 ? yield* fs.realPath(worktree) : yield* git.repoRoot(bundle.root);
64
+ repoRoot = yield* git.repoRoot(bundle.root, { ignoreRepositoryEnv: true }).pipe(Effect.catchTag("NotARepositoryError", () => git.repoRoot(bundle.root)));
66
65
  const stagedPaths = new Set(yield* git.stagedChanges(repoRoot));
67
66
  const selected = /* @__PURE__ */ new Set();
68
67
  const provenanceStaged = /* @__PURE__ */ new Map();
package/sync/write.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Effect, FileSystem, Option, Path } from "effect";
2
- import { randomUUID } from "node:crypto";
2
+ import { SecureRandom } from "effect/crypto";
3
3
 
4
4
  // src/sync/write.ts
5
5
  /**
@@ -22,8 +22,8 @@ import { randomUUID } from "node:crypto";
22
22
  * DISCREPANCY from S-33's literal "the temp name carries the pid": `src/`
23
23
  * outside `bin.ts`/`commands/*`/`internal/exit.ts`/`internal/tty.ts` never
24
24
  * reads the global `process` (K-39, enforced by `__test__/boundaries.test.ts`),
25
- * and `sync/write.ts` is not on that allowlist. A `randomUUID()` token
26
- * (`node:crypto`, not `process`) satisfies S-33's actual requirement --
25
+ * and `sync/write.ts` is not on that allowlist. A random UUIDv4 token
26
+ * (`SecureRandom.uuidV4Unsafe` from `effect/crypto`, not `process`) satisfies S-33's actual requirement --
27
27
  * two concurrent `sync` runs never collide on a fixed temp name -- without
28
28
  * widening the process-access boundary for one helper. Recorded here per
29
29
  * the Global Constraints' "record the discrepancy" instruction.
@@ -36,7 +36,7 @@ const writeAtomic = Effect.fn("okfit/sync/writeAtomic")(function* (target, conte
36
36
  const resolved = yield* fs.realPath(target).pipe(Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(target)));
37
37
  const dir = path.dirname(resolved);
38
38
  const base = path.basename(resolved);
39
- const tempPath = path.join(dir, `${base}.okfit-sync.${randomUUID()}.tmp`);
39
+ const tempPath = path.join(dir, `${base}.okfit-sync.${SecureRandom.uuidV4Unsafe()}.tmp`);
40
40
  const originalMode = yield* fs.stat(resolved).pipe(Effect.map((info) => Option.some(info.mode)), Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(Option.none())));
41
41
  yield* fs.writeFileString(tempPath, contents).pipe(Effect.tap(() => Option.match(originalMode, {
42
42
  onNone: () => Effect.void,
@@ -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/diff.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { DateTime, Effect, Path } from "effect";
2
2
  import { Git, GitCommandError } from "@effected/git";
3
- import { ChildProcess, ChildProcessSpawner } from "effect/process";
4
3
 
5
4
  // src/verify/diff.ts
6
5
  /**
@@ -11,11 +10,10 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
11
10
  * at or before `at`; the patch is `git diff <baseline> -- <file>`.
12
11
  *
13
12
  * Git access: `@effected/git`'s `Git.log` (scoped to the file, newest first,
14
- * filtered here on `committedAt`) finds the baseline. `Git.log` has no `until`,
15
- * and no `Git` member returns a patch (`show` returns a blob, `nameStatus` only
16
- * paths), so the diff itself runs `git diff` through `effect/process`'s
17
- * `ChildProcessSpawner`, the same spawner `Git.layer` is built on. Spawn
18
- * failure maps onto `Git`'s own `GitCommandError`.
13
+ * filtered here on `committedAt`) finds the baseline (`Git.log` has no
14
+ * `until`), and `Git.diffFile` produces the patch with the output-shaping
15
+ * flags pinned, so user git config cannot change its bytes. Every diff
16
+ * failure is reported as `GitCommandError`, the one error callers handle.
19
17
  *
20
18
  * @param options - `file` is the absolute path of the concept file; `at` is the
21
19
  * time the binding recorded.
@@ -23,7 +21,6 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
23
21
  */
24
22
  const changeSince = Effect.fn("okfit/verify/changeSince")(function* (options) {
25
23
  const git = yield* Git;
26
- const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
27
24
  const path = yield* Path.Path;
28
25
  const cwd = path.dirname(options.file);
29
26
  const name = path.basename(options.file);
@@ -37,26 +34,28 @@ const changeSince = Effect.fn("okfit/verify/changeSince")(function* (options) {
37
34
  _tag: "no-baseline",
38
35
  reason: "no-commit-before"
39
36
  };
40
- const args = [
41
- "diff",
42
- "--no-color",
43
- "--no-ext-diff",
44
- baseline.sha,
45
- "--",
46
- name
47
- ];
48
- const patch = yield* spawner.string(ChildProcess.setCwd(ChildProcess.make("git", args), cwd)).pipe(Effect.mapError((error) => new GitCommandError({
49
- kind: "failed",
50
- args,
51
- cwd,
52
- stderr: "",
53
- detail: error.message
54
- })));
37
+ const patch = yield* git.diffFile(cwd, baseline.sha, name, { allowMissing: true }).pipe(Effect.catchTags({
38
+ NotARepositoryError: (error) => Effect.fail(asCommandError(error, baseline.sha, name, cwd)),
39
+ UnknownRefError: (error) => Effect.fail(asCommandError(error, baseline.sha, name, cwd)),
40
+ FileNotFoundError: (error) => Effect.fail(asCommandError(error, baseline.sha, name, cwd))
41
+ }));
55
42
  return {
56
43
  _tag: "diff",
57
44
  baseline: baseline.sha.slice(0, 7),
58
45
  patch
59
46
  };
60
47
  });
48
+ const asCommandError = (error, ref, name, cwd) => new GitCommandError({
49
+ kind: "failed",
50
+ args: [
51
+ "diff",
52
+ ref,
53
+ "--",
54
+ name
55
+ ],
56
+ cwd,
57
+ stderr: "",
58
+ detail: error.message
59
+ });
61
60
 
62
61
  export { changeSince };
package/verify/run.js CHANGED
@@ -1,4 +1,4 @@
1
- import { VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifyUnsupportedFrontmatterError } from "../errors.js";
1
+ import { VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyNothingToRevokeError, VerifyUnsupportedFrontmatterError } from "../errors.js";
2
2
  import { documentNewline, locate, locateTopLevelScalar, locateVerifiedAt, stripBom } from "./locate.js";
3
3
  import { locateIntegrity, removeIntegrityVerified, spliceIntegrityVerified } from "./integrity.js";
4
4
  import { orderVerifyEdits, quoteLike, splice, spliceTopLevelScalar } from "./splice.js";
@@ -29,7 +29,11 @@ const UNDECODABLE_CODES = /* @__PURE__ */ new Set([
29
29
  ]);
30
30
  /** Steps 9-14 of runVerify: read, locate (fail closed), splice; no write. */
31
31
  const prepareVerify = Effect.fn("okfit/verify/prepareVerify")(function* (bundle, concept, actor, at, status, staleAfter = void 0) {
32
- const content = yield* Derivation.contentDigest(concept.frontmatter.raw, concept.document.source);
32
+ const content = yield* Derivation.contentDigest(concept.frontmatter.raw, concept.document.source).pipe(Effect.catchTag("ContentUnhashableError", (error) => Effect.fail(new VerifyContentUnhashableError({
33
+ id: concept.id,
34
+ path: error.path,
35
+ detail: error.detail
36
+ }))));
33
37
  const fs = yield* FileSystem.FileSystem;
34
38
  const absolutePath = (yield* Path.Path).join(bundle.root, concept.path);
35
39
  const source = new TextDecoder("utf-8", { ignoreBOM: true }).decode(yield* fs.readFile(absolutePath));
package/version.js CHANGED
@@ -11,6 +11,6 @@
11
11
  *
12
12
  * @public
13
13
  */
14
- const ENGINE_VERSION = "0.18.1";
14
+ const ENGINE_VERSION = "0.19.0";
15
15
 
16
16
  export { ENGINE_VERSION };