kibi-cli 2.28.1 → 2.30.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.
Files changed (106) hide show
  1. package/bin/kibi +12 -1
  2. package/dist/cli-command.d.ts +3 -0
  3. package/dist/cli-command.d.ts.map +1 -1
  4. package/dist/cli-command.js +11 -0
  5. package/dist/cli-operation-metadata.d.ts +8 -8
  6. package/dist/cli-operation-metadata.js +8 -8
  7. package/dist/cli-register-reporting.d.ts.map +1 -1
  8. package/dist/cli-register-reporting.js +12 -0
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +5 -2
  11. package/dist/commands/check.d.ts.map +1 -1
  12. package/dist/commands/check.js +8 -1
  13. package/dist/commands/engine.d.ts.map +1 -1
  14. package/dist/commands/engine.js +26 -2
  15. package/dist/commands/signoff.d.ts +37 -0
  16. package/dist/commands/signoff.d.ts.map +1 -0
  17. package/dist/commands/signoff.js +152 -0
  18. package/dist/commands/sync.d.ts +10 -0
  19. package/dist/commands/sync.d.ts.map +1 -1
  20. package/dist/commands/sync.js +67 -3
  21. package/dist/engine.d.ts +11 -1
  22. package/dist/engine.d.ts.map +1 -1
  23. package/dist/engine.js +120 -34
  24. package/dist/operations/modeling/predicate-applicability.d.ts +5 -1
  25. package/dist/operations/modeling/predicate-applicability.d.ts.map +1 -1
  26. package/dist/operations/modeling/predicate-applicability.js +35 -2
  27. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  28. package/dist/operations/modeling/suggest-predicates.js +3 -1
  29. package/dist/operations/mutation/contradictions.d.ts +7 -5
  30. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  31. package/dist/operations/mutation/contradictions.js +8 -6
  32. package/dist/operations/mutation/source-authoring.d.ts +15 -0
  33. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  34. package/dist/operations/mutation/source-authoring.js +19 -7
  35. package/dist/operations/mutation/types.d.ts +5 -0
  36. package/dist/operations/mutation/types.d.ts.map +1 -1
  37. package/dist/operations/mutation/upsert.d.ts +14 -0
  38. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  39. package/dist/operations/mutation/upsert.js +42 -36
  40. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  41. package/dist/operations/mutation/validate-upsert.js +61 -37
  42. package/dist/prolog/error-terms.d.ts.map +1 -1
  43. package/dist/prolog/error-terms.js +15 -9
  44. package/dist/prolog/store-lock.d.ts +11 -0
  45. package/dist/prolog/store-lock.d.ts.map +1 -1
  46. package/dist/prolog/store-lock.js +48 -1
  47. package/dist/public/operations/catalog.d.ts +29 -8
  48. package/dist/public/operations/catalog.d.ts.map +1 -1
  49. package/dist/public/operations/contracts.d.ts.map +1 -1
  50. package/dist/public/operations/contracts.js +2 -0
  51. package/dist/public/operations/specs/bootstrap.d.ts +1 -1
  52. package/dist/public/operations/specs/bootstrap.js +1 -1
  53. package/dist/public/operations/specs/composite.d.ts +1 -1
  54. package/dist/public/operations/specs/composite.js +1 -1
  55. package/dist/public/operations/specs/discovery.d.ts +1 -1
  56. package/dist/public/operations/specs/discovery.js +1 -1
  57. package/dist/public/operations/specs/impact-review-preparation.d.ts +2 -1
  58. package/dist/public/operations/specs/impact-review-preparation.d.ts.map +1 -1
  59. package/dist/public/operations/specs/impact-review-preparation.js +2 -1
  60. package/dist/public/operations/specs/planning.d.ts +1 -1
  61. package/dist/public/operations/specs/planning.js +1 -1
  62. package/dist/public/operations/specs/reporting.d.ts +23 -3
  63. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  64. package/dist/public/operations/specs/reporting.js +97 -21
  65. package/dist/public/skills/kibi-commit-review/SKILL.md +125 -0
  66. package/dist/public/skills/kibi-commit-review/resources/staged-gate.md +98 -0
  67. package/dist/public/skills/kibi-decisions/SKILL.md +130 -0
  68. package/dist/public/skills/kibi-decisions/resources/decision-records.md +142 -0
  69. package/dist/public/skills/kibi-decisions/resources/signoff-views.md +66 -0
  70. package/dist/public/skills/kibi-freshness/SKILL.md +2 -0
  71. package/dist/public/skills/kibi-traceability/SKILL.md +4 -0
  72. package/dist/public/skills/kibi-usage/SKILL.md +20 -15
  73. package/dist/signoff/collect.d.ts +39 -0
  74. package/dist/signoff/collect.d.ts.map +1 -0
  75. package/dist/signoff/collect.js +398 -0
  76. package/dist/signoff/html.d.ts +4 -0
  77. package/dist/signoff/html.d.ts.map +1 -0
  78. package/dist/signoff/html.js +210 -0
  79. package/dist/signoff/markdown.d.ts +20 -0
  80. package/dist/signoff/markdown.d.ts.map +1 -0
  81. package/dist/signoff/markdown.js +203 -0
  82. package/dist/signoff/model.d.ts +134 -0
  83. package/dist/signoff/model.d.ts.map +1 -0
  84. package/dist/signoff/model.js +138 -0
  85. package/dist/traceability/commit-amend.d.ts +7 -0
  86. package/dist/traceability/commit-amend.d.ts.map +1 -0
  87. package/dist/traceability/commit-amend.js +85 -0
  88. package/dist/traceability/staged-inventory-drift.d.ts +12 -2
  89. package/dist/traceability/staged-inventory-drift.d.ts.map +1 -1
  90. package/dist/traceability/staged-inventory-drift.js +22 -5
  91. package/package.json +2 -2
  92. package/src/public/operations/contracts.ts +2 -0
  93. package/src/public/operations/specs/bootstrap.ts +1 -1
  94. package/src/public/operations/specs/composite.ts +1 -1
  95. package/src/public/operations/specs/discovery.ts +1 -1
  96. package/src/public/operations/specs/impact-review-preparation.ts +3 -1
  97. package/src/public/operations/specs/planning.ts +1 -1
  98. package/src/public/operations/specs/reporting.ts +109 -21
  99. package/src/public/skills/kibi-commit-review/SKILL.md +125 -0
  100. package/src/public/skills/kibi-commit-review/resources/staged-gate.md +98 -0
  101. package/src/public/skills/kibi-decisions/SKILL.md +130 -0
  102. package/src/public/skills/kibi-decisions/resources/decision-records.md +142 -0
  103. package/src/public/skills/kibi-decisions/resources/signoff-views.md +66 -0
  104. package/src/public/skills/kibi-freshness/SKILL.md +2 -0
  105. package/src/public/skills/kibi-traceability/SKILL.md +4 -0
  106. package/src/public/skills/kibi-usage/SKILL.md +20 -15
@@ -19,6 +19,7 @@ import { execSync } from "node:child_process";
19
19
  import { createHash } from "node:crypto";
20
20
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync, } from "node:fs";
21
21
  import * as path from "node:path";
22
+ import { markErrorReported } from "../cli-command.js";
22
23
  import { branchErrorToDiagnostic, createDocsNotIndexedDiagnostic, createInvalidAuthoringDiagnostic, createKbMissingDiagnostic, formatSyncSummary, } from "../diagnostics.js";
23
24
  import { EngineClient, acquireEnginePublicationLease, engineSocketPath, ensureJournaledBranchStoreAsync, formatEngineAttachmentMismatch, fsyncJournaledBranchStore, parseEngineAttachmentIdentity, readEngineAttachmentIdentity, } from "../engine.js";
24
25
  import { isCliDebugEnabled } from "../env.js";
@@ -28,7 +29,7 @@ import { analyzeSemanticAdvisorInput } from "../operations/semantic-advisor/anal
28
29
  import { validateSemanticInventoryBoundary } from "../operations/semantic-advisor/ingestion-boundary.js";
29
30
  import { PrologProcess } from "../prolog.js";
30
31
  import { detachedHeadWriteRefusal, resolveBranchAttachment, } from "../utils/branch-resolver.js";
31
- import { branchStoreManifestPath, branchStorePath, ensureBranchStoreManifest, expectedBranchStoreManifest, } from "../utils/branch-store-locator.js";
32
+ import { branchStoreManifestPath, branchStorePath, branchStoresRoot, ensureBranchStoreManifest, expectedBranchStoreManifest, } from "../utils/branch-store-locator.js";
32
33
  import { loadEntityPaths } from "../utils/config.js";
33
34
  import { SYNC_CACHE_TTL_MS, SYNC_CACHE_VERSION, SYNC_COMPILER_FINGERPRINT, failedSourceKeepsSemanticBaseline, hashFile, hashManifestWithCoordinates, hashNormalized, readSyncCache, toCacheKey, writeSyncCache, } from "./sync/cache.js";
34
35
  import { clearRecoveredPendingSourceReceipts, discoverSourceFiles, } from "./sync/discovery.js";
@@ -75,6 +76,62 @@ function assertNoUnresolvedGitConflicts(workspaceRoot) {
75
76
  throw new SyncError(`Unresolved Git conflicts block Kibi compilation; resolve these authored files first: ${conflicted.split("\n").join(", ")}`);
76
77
  }
77
78
  }
79
+ /**
80
+ * Sources staged as new files (renames included) that HEAD does not contain yet. An empty branch
81
+ * store compiles its first sync as a semantic baseline, which accepts
82
+ * requirements without an inventory. Once another branch of the workspace has
83
+ * synced, that grace covers committed history only: a new branch must not
84
+ * accept a staged requirement its parent branch would refuse. Without a HEAD
85
+ * commit (or outside Git) there is no history to tell apart, and the set is
86
+ * empty.
87
+ */
88
+ // implements REQ-kibi-proposition-complete-ingestion
89
+ export function stagedNewSourceKeys(workspaceRoot) {
90
+ try {
91
+ return new Set(execSync(
92
+ // --no-renames: a staged rename is a new source key too, judged on
93
+ // the parent branch like any other addition.
94
+ "git diff --cached --no-renames --name-only --relative --diff-filter=A -z HEAD", {
95
+ cwd: workspaceRoot,
96
+ encoding: "utf8",
97
+ timeout: 5000,
98
+ stdio: ["pipe", "pipe", "pipe"],
99
+ })
100
+ .split("\0")
101
+ .filter(Boolean)
102
+ .map((file) => file.replaceAll("\\", "/")));
103
+ }
104
+ catch {
105
+ return new Set();
106
+ }
107
+ }
108
+ /** Whether a branch store other than `livePath` has a non-empty sync cache. */
109
+ function anotherBranchStoreSynced(workspaceRoot, livePath) {
110
+ const root = branchStoresRoot(workspaceRoot);
111
+ let entries;
112
+ try {
113
+ entries = readdirSync(root);
114
+ }
115
+ catch {
116
+ return false;
117
+ }
118
+ for (const entry of entries) {
119
+ const storePath = path.join(root, entry);
120
+ if (path.resolve(storePath) === path.resolve(livePath))
121
+ continue;
122
+ try {
123
+ const cache = JSON.parse(readFileSync(path.join(storePath, "sync-cache.json"), "utf8"));
124
+ if (cache.hashes !== null &&
125
+ typeof cache.hashes === "object" &&
126
+ Object.keys(cache.hashes).length > 0)
127
+ return true;
128
+ }
129
+ catch {
130
+ // A store without a readable cache has not synced.
131
+ }
132
+ }
133
+ return false;
134
+ }
78
135
  export function trackedRelationshipFiles(workspaceRoot, relationshipsDir, recoverMissingPendingSources = false, recoveredPendingReceiptPaths = []) {
79
136
  let tracked;
80
137
  try {
@@ -531,6 +588,10 @@ export async function syncCommand(options = {}, runtime = {}) {
531
588
  const addedShardRelationships = [];
532
589
  const removedShardRelationships = [];
533
590
  const initialSemanticBaseline = Object.keys(syncCache.hashes).length === 0;
591
+ const baselineExcludedKeys = initialSemanticBaseline &&
592
+ anotherBranchStoreSynced(workspaceRoot, livePathForEngine)
593
+ ? stagedNewSourceKeys(workspaceRoot)
594
+ : new Set();
534
595
  const changedMarkdownFiles = [];
535
596
  const changedManifestFiles = [];
536
597
  const forceEntitySourceKeys = new Set();
@@ -664,7 +725,8 @@ export async function syncCommand(options = {}, runtime = {}) {
664
725
  nextExtractionFailures[key] = {
665
726
  hash,
666
727
  message: failure.message,
667
- ...(initialSemanticBaseline || previousFailure?.baseline === true
728
+ ...((initialSemanticBaseline && !baselineExcludedKeys.has(key)) ||
729
+ previousFailure?.baseline === true
668
730
  ? { baseline: true }
669
731
  : {}),
670
732
  ...(semanticHash !== undefined ? { semanticHash } : {}),
@@ -774,7 +836,8 @@ export async function syncCommand(options = {}, runtime = {}) {
774
836
  const enforceBoundary = advertisedContract ||
775
837
  (previousFailure !== undefined
776
838
  ? !failedSourceKeepsSemanticBaseline(previousFailure, boundary.sourceHash)
777
- : (!initialSemanticBaseline && syncCache.hashes[key] === undefined) ||
839
+ : (syncCache.hashes[key] === undefined &&
840
+ (!initialSemanticBaseline || baselineExcludedKeys.has(key))) ||
778
841
  syncCache.semanticContracts[key] === true ||
779
842
  (previousSemanticHash !== undefined &&
780
843
  previousSemanticHash !== boundary.sourceHash));
@@ -1251,6 +1314,7 @@ export async function syncCommand(options = {}, runtime = {}) {
1251
1314
  }
1252
1315
  const errorMessage = error instanceof Error ? error.message : String(error);
1253
1316
  console.error(`Error: ${errorMessage}`);
1317
+ markErrorReported(error);
1254
1318
  const commit = getCurrentCommit();
1255
1319
  const summary = withOptionalCommit({
1256
1320
  branch: currentBranch || "unknown",
package/dist/engine.d.ts CHANGED
@@ -55,6 +55,14 @@ export type EnginePublicationLease = Readonly<{
55
55
  readonly release: () => void;
56
56
  }>;
57
57
  export declare function acquireEnginePublicationLease(workspaceRoot: string, branch: string): EnginePublicationLease;
58
+ /**
59
+ * The Node binary that hosts the daemon. A Node client starts it with its own
60
+ * runtime, so a host that runs Kibi through Node 22+ by absolute path still
61
+ * gets a Node 22+ daemon when an older `node` comes first on PATH. Bun clients
62
+ * (source checkouts, tests) use `node` from PATH, since the daemon is a Node
63
+ * artifact. KIBI_NODE_PATH overrides both.
64
+ */
65
+ export declare function daemonNodePath(environment?: NodeJS.ProcessEnv): string;
58
66
  /** What a live daemon reports in its handshake. */
59
67
  export type EngineDaemonIdentity = Readonly<{
60
68
  prologIdentity: string | null;
@@ -137,7 +145,9 @@ export declare class EngineClient {
137
145
  private reconcileAttachment;
138
146
  private shutdownConnectedDaemon;
139
147
  getPid(): number;
140
- stop(startIfMissing?: boolean): Promise<void>;
148
+ /** Resolves false when no daemon answered and none was started. */
149
+ stop(startIfMissing?: boolean): Promise<boolean>;
150
+ private daemonProcessAlive;
141
151
  terminate(): Promise<void>;
142
152
  }
143
153
  export declare function ensureJournaledBranchStoreAsync(branchPath: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAgCA,OAAO,EAEL,KAAK,iBAAiB,EAMvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAa7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,sCAAsC,CAAC;AAQ9C,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACz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CAAC,EAAE,MAAM,CAAC;CAClC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsxBhB"}
package/dist/engine.js CHANGED
@@ -293,10 +293,22 @@ function parseFrames(buffer, onFrame) {
293
293
  }
294
294
  return buffer.subarray(cursor);
295
295
  }
296
+ /**
297
+ * The socket directory every Kibi process for one user must agree on. Linux
298
+ * hosts and agent harnesses often give their children a private TMPDIR, so
299
+ * following it there would hide an engine from the CLI, git hooks and other
300
+ * hosts that share its branch store (they then see only `store_locked`).
301
+ * Linux therefore uses /tmp unless KIBI_RUNTIME_DIR or XDG_RUNTIME_DIR names
302
+ * a directory. macOS keeps its per-user TMPDIR, which launchd sets for every
303
+ * process of the user.
304
+ */
305
+ function defaultRuntimeDirectory() {
306
+ return path.join(process.platform === "linux" ? "/tmp" : os.tmpdir(), "kibi-runtime");
307
+ }
296
308
  export function runtimeDirectory() {
297
309
  const configured = process.env.KIBI_RUNTIME_DIR ??
298
310
  process.env.XDG_RUNTIME_DIR ??
299
- path.join(os.tmpdir(), "kibi-runtime");
311
+ defaultRuntimeDirectory();
300
312
  // Windows named pipes have no Unix socket pathname budget. Preserve its
301
313
  // filesystem location policy for the associated pid files.
302
314
  if (process.platform === "win32") {
@@ -340,38 +352,62 @@ export function runtimeDirectory() {
340
352
  const maximumBytes = process.platform === "linux" ? 107 : 103;
341
353
  const socketName = `kibi-${"0".repeat(32)}.sock`;
342
354
  for (const candidate of candidates) {
355
+ const rejection = runtimeDirectoryRejection(candidate, euid, socketName, maximumBytes);
356
+ if (typeof rejection === "object")
357
+ return rejection.directory;
358
+ if (candidate === process.env.KIBI_RUNTIME_DIR)
359
+ warnRuntimeDirectoryIgnored(candidate, rejection);
360
+ }
361
+ throw new Error("Unable to create a writable Kibi engine runtime directory");
362
+ }
363
+ /**
364
+ * The canonical runtime directory when `candidate` can hold the engine socket,
365
+ * else why it cannot.
366
+ */
367
+ function runtimeDirectoryRejection(candidate, euid, socketName, maximumBytes) {
368
+ try {
343
369
  try {
344
- try {
345
- if (lstatSync(candidate).isSymbolicLink())
346
- continue;
347
- }
348
- catch (error) {
349
- if (error.code !== "ENOENT")
350
- throw error;
351
- }
352
- mkdirSync(candidate, { recursive: true, mode: 0o700 });
353
- const directory = lstatSync(candidate);
354
- if (!directory.isDirectory() ||
355
- directory.uid !== euid ||
356
- (directory.mode & 0o077) !== 0)
357
- continue;
358
- const canonical = canonicalFilesystemPath(candidate);
359
- if (Buffer.byteLength(path.join(canonical, socketName), "utf8") >
360
- maximumBytes)
361
- continue;
362
- // XDG_RUNTIME_DIR can exist but be mounted read-only (for example in a
363
- // constrained container). Probe the directory before using it for the
364
- // socket, start lock, and pid files so auto-start fails over cleanly.
365
- const probe = path.join(canonical, `.kibi-write-${randomUUID()}`);
366
- writeFileSync(probe, "", { mode: 0o600, flag: "wx" });
367
- unlinkSync(probe);
368
- return canonical;
369
- }
370
- catch {
371
- // Try the private system-temp fallback below.
370
+ if (lstatSync(candidate).isSymbolicLink())
371
+ return "it is a symbolic link";
372
372
  }
373
+ catch (error) {
374
+ if (error.code !== "ENOENT")
375
+ throw error;
376
+ }
377
+ mkdirSync(candidate, { recursive: true, mode: 0o700 });
378
+ const directory = lstatSync(candidate);
379
+ if (!directory.isDirectory())
380
+ return "it is not a directory";
381
+ if (directory.uid !== euid)
382
+ return `it is owned by uid ${directory.uid}, not by the current user (uid ${euid})`;
383
+ if ((directory.mode & 0o077) !== 0)
384
+ return `its mode is ${(directory.mode & 0o777).toString(8).padStart(4, "0")}; it must be private to its owner (chmod 700)`;
385
+ const canonical = canonicalFilesystemPath(candidate);
386
+ if (Buffer.byteLength(path.join(canonical, socketName), "utf8") > maximumBytes)
387
+ return `its path is too long for a Unix socket (at most ${maximumBytes - socketName.length - 1} bytes)`;
388
+ // XDG_RUNTIME_DIR can exist but be mounted read-only (for example in a
389
+ // constrained container). Probe the directory before using it for the
390
+ // socket, start lock, and pid files so auto-start fails over cleanly.
391
+ const probe = path.join(canonical, `.kibi-write-${randomUUID()}`);
392
+ writeFileSync(probe, "", { mode: 0o600, flag: "wx" });
393
+ unlinkSync(probe);
394
+ return { directory: canonical };
395
+ }
396
+ catch (error) {
397
+ return `it is not usable (${error.message})`;
373
398
  }
374
- throw new Error("Unable to create a writable Kibi engine runtime directory");
399
+ }
400
+ const warnedRuntimeDirectories = new Set();
401
+ /**
402
+ * Processes that disagree on the runtime directory cannot reach each other's
403
+ * engine, so an explicit KIBI_RUNTIME_DIR that Kibi cannot use is reported
404
+ * (once per process) instead of being replaced silently.
405
+ */
406
+ function warnRuntimeDirectoryIgnored(directory, reason) {
407
+ if (warnedRuntimeDirectories.has(directory))
408
+ return;
409
+ warnedRuntimeDirectories.add(directory);
410
+ process.stderr.write(`kibi: ignoring KIBI_RUNTIME_DIR=${directory} because ${reason}; using a private directory under /tmp instead.\n`);
375
411
  }
376
412
  function fsyncPath(filePath) {
377
413
  if (!existsSync(filePath))
@@ -669,6 +705,18 @@ function recoverStaleJournalLock(branchPath) {
669
705
  // race between the liveness probe and removal.
670
706
  }
671
707
  }
708
+ /**
709
+ * The Node binary that hosts the daemon. A Node client starts it with its own
710
+ * runtime, so a host that runs Kibi through Node 22+ by absolute path still
711
+ * gets a Node 22+ daemon when an older `node` comes first on PATH. Bun clients
712
+ * (source checkouts, tests) use `node` from PATH, since the daemon is a Node
713
+ * artifact. KIBI_NODE_PATH overrides both.
714
+ */
715
+ export function daemonNodePath(environment = process.env) {
716
+ if (environment.KIBI_NODE_PATH)
717
+ return environment.KIBI_NODE_PATH;
718
+ return "Bun" in globalThis ? "node" : process.execPath;
719
+ }
672
720
  function daemonEntry() {
673
721
  const moduleDirectory = path.dirname(fileURLToPath(import.meta.url));
674
722
  // Packed clients keep the daemon beside engine.js. Source-tree repository
@@ -827,7 +875,7 @@ export class EngineClient {
827
875
  catch {
828
876
  if (!allowSpawn)
829
877
  return;
830
- const nodePath = process.env.KIBI_NODE_PATH ?? "node";
878
+ const nodePath = daemonNodePath();
831
879
  const entry = daemonEntry();
832
880
  const lockPath = engineStartLockPath(this.workspaceRoot, this.branch);
833
881
  const startDeadline = Date.now() + this.timeout;
@@ -915,6 +963,10 @@ export class EngineClient {
915
963
  }
916
964
  attachSocket(socket) {
917
965
  this.inputBuffer = Buffer.alloc(0);
966
+ // An idle connection must not keep its client alive: a host that is done
967
+ // with an MCP server or CLI command lets it exit while the shared daemon
968
+ // keeps serving. request() holds the socket while a reply is pending.
969
+ socket.unref();
918
970
  socket.on("data", (chunk) => {
919
971
  if (this.socket !== socket)
920
972
  return;
@@ -983,10 +1035,13 @@ export class EngineClient {
983
1035
  release = resolve;
984
1036
  });
985
1037
  await previous;
1038
+ let held = null;
986
1039
  try {
987
1040
  const socket = this.socket;
988
1041
  if (socket === null || socket.destroyed)
989
1042
  throw new Error("Kibi engine is not connected");
1043
+ socket.ref();
1044
+ held = socket;
990
1045
  const id = ++this.requestId;
991
1046
  const limits = this.readLimits !== undefined &&
992
1047
  READ_LIMITED_METHODS.has(request.method)
@@ -1039,6 +1094,8 @@ export class EngineClient {
1039
1094
  return value;
1040
1095
  }
1041
1096
  finally {
1097
+ if (held !== null && this.pending.size === 0)
1098
+ held.unref();
1042
1099
  release();
1043
1100
  }
1044
1101
  }
@@ -1301,6 +1358,7 @@ export class EngineClient {
1301
1358
  return 0;
1302
1359
  }
1303
1360
  }
1361
+ /** Resolves false when no daemon answered and none was started. */
1304
1362
  async stop(startIfMissing = true) {
1305
1363
  const socketPath = engineSocketPath(this.workspaceRoot, this.branch);
1306
1364
  if (!this.isRunning()) {
@@ -1309,14 +1367,29 @@ export class EngineClient {
1309
1367
  }
1310
1368
  catch {
1311
1369
  if (!startIfMissing)
1312
- return;
1370
+ return false;
1313
1371
  throw new Error("Unable to start Kibi engine for stop request");
1314
1372
  }
1315
1373
  }
1316
1374
  if (!this.isRunning() && existsSync(socketPath)) {
1317
1375
  throw new Error(`Kibi engine socket remains present but is not reachable: ${socketPath}`);
1318
1376
  }
1377
+ // A draining daemon has no listener but still counts as stopped here.
1378
+ const found = this.isRunning() || this.daemonProcessAlive();
1319
1379
  await this.shutdownConnectedDaemon();
1380
+ return found;
1381
+ }
1382
+ daemonProcessAlive() {
1383
+ const pid = this.getPid();
1384
+ if (pid <= 0)
1385
+ return false;
1386
+ try {
1387
+ process.kill(pid, 0);
1388
+ return true;
1389
+ }
1390
+ catch {
1391
+ return false;
1392
+ }
1320
1393
  }
1321
1394
  async terminate() {
1322
1395
  // Closing a client connection releases the engine; the daemon remains
@@ -1643,7 +1716,15 @@ export async function runEngineDaemon(requestedOptions) {
1643
1716
  : { maxOutputBytes: options.maxOutputBytes }),
1644
1717
  });
1645
1718
  const session = new EngineSession(prolog, branchPath);
1646
- await session.boot();
1719
+ try {
1720
+ await session.boot();
1721
+ }
1722
+ catch (error) {
1723
+ // A failed boot (store_locked, a module load error) leaves the SWI child
1724
+ // running, which keeps this daemon alive with no socket.
1725
+ await prolog.terminate().catch(() => undefined);
1726
+ throw error;
1727
+ }
1647
1728
  let attachedIdentity = readEngineAttachmentIdentity(branchPath);
1648
1729
  const serverPrologIdentity = engineSwiplIdentity();
1649
1730
  const serverPackageVersions = enginePackageVersions();
@@ -2099,7 +2180,12 @@ export async function runEngineDaemon(requestedOptions) {
2099
2180
  return result;
2100
2181
  }
2101
2182
  case "status":
2102
- return prolog.query("kb_storage_status(Status), atom_json_dict(Json, Status, [])");
2183
+ // Qualified: kb.pl loads library(http/json), but SWI-Prolog 9.0 does
2184
+ // not autoload it into `user`, where its toplevel then waits on a
2185
+ // "correct to kb:json_write_dict?" prompt instead of answering. A
2186
+ // string binding reaches the client as JSON text; an atom would
2187
+ // arrive Prolog-quoted and fail to parse.
2188
+ return prolog.query("kb_storage_status(Status), with_output_to(string(Json), json:json_write_dict(current_output, Status, [width(0)]))");
2103
2189
  case "checkpoint": {
2104
2190
  queryCache.clear();
2105
2191
  freshnessCache = null;
@@ -2,6 +2,10 @@ import { type RankedPredicateSchema } from "./predicate-ranker.js";
2
2
  export declare const MIN_APPLICABILITY_SCORE = 0.62;
3
3
  export declare const STRONG_APPLICABILITY_SCORE = 0.8;
4
4
  export declare const WEAK_CANDIDATE_MARGIN = 0.06;
5
+ export interface SemanticApplicabilityOptions {
6
+ /** The caller selected this schema by its exact ID (schemaId). */
7
+ readonly explicitSchema?: boolean;
8
+ }
5
9
  export interface SemanticApplicability {
6
10
  readonly eligible: boolean;
7
11
  readonly reasons: readonly string[];
@@ -12,5 +16,5 @@ export interface SemanticApplicability {
12
16
  * function deliberately does not inspect argument values: complete-looking
13
17
  * terms cannot make a semantically unrelated schema eligible.
14
18
  */
15
- export declare function evaluateSemanticApplicability(ranked: RankedPredicateSchema, text: string): SemanticApplicability;
19
+ export declare function evaluateSemanticApplicability(ranked: RankedPredicateSchema, text: string, options?: SemanticApplicabilityOptions): SemanticApplicability;
16
20
  //# sourceMappingURL=predicate-applicability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"predicate-applicability.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAoX1C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,MAAM,GACX,qBAAqB,CA2EvB"}
1
+ {"version":3,"file":"predicate-applicability.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAiZ1C,MAAM,WAAW,4BAA4B;IAC3C,kEAAkE;IAClE,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CA2FvB"}
@@ -348,12 +348,31 @@ function specificityEvidence(schema, text) {
348
348
  }, 0);
349
349
  return Math.min(1, hits / Math.max(3, values.length / 2));
350
350
  }
351
+ function nameTokens(name) {
352
+ return (name.toLowerCase().match(/[a-z0-9]+/g) ?? []).filter((token) => token.length > 2);
353
+ }
354
+ function claimMentions(text, token) {
355
+ return new RegExp(`\\b${token}`, "i").test(text);
356
+ }
357
+ /**
358
+ * Names of an explicitly selected schema that the claim does not state: an
359
+ * argument name counts as stated when every word of it appears in the claim,
360
+ * the predicate name when any of its words does.
361
+ */
362
+ function unstatedSchemaNames(schema, text) {
363
+ const predicateTokens = nameTokens(schema.predicate_name);
364
+ const missing = schema.argument_names.filter((name) => !nameTokens(name).every((token) => claimMentions(text, token)));
365
+ return predicateTokens.length > 0 &&
366
+ !predicateTokens.some((token) => claimMentions(text, token))
367
+ ? [schema.predicate_name, ...missing]
368
+ : missing;
369
+ }
351
370
  /**
352
371
  * Evaluate semantic fit after retrieval and before argument binding. The
353
372
  * function deliberately does not inspect argument values: complete-looking
354
373
  * terms cannot make a semantically unrelated schema eligible.
355
374
  */
356
- export function evaluateSemanticApplicability(ranked, text) {
375
+ export function evaluateSemanticApplicability(ranked, text, options = {}) {
357
376
  const schema = ranked.schema;
358
377
  const rule = INTENT_RULES[schema.predicate_name];
359
378
  const usageHints = usageHintsForSchema(schema);
@@ -402,11 +421,25 @@ export function evaluateSemanticApplicability(ranked, text) {
402
421
  if (negativeHints > 0) {
403
422
  reasons.push("usage guidance says this schema is not for the supplied intent");
404
423
  }
405
- const score = round(ranked.score * 0.42 +
424
+ const computed = round(ranked.score * 0.42 +
406
425
  Math.min(1, positive) * 0.58 -
407
426
  Math.min(1, negative) * 0.46);
427
+ // A schema the caller chose by ID whose predicate and every argument the
428
+ // claim names is reviewed evidence the lexical score cannot see, for example
429
+ // a project-local schema with no keywords. Contradictory cues above still
430
+ // reject it.
431
+ const unstated = options.explicitSchema
432
+ ? unstatedSchemaNames(schema, text)
433
+ : [];
434
+ const namedByClaim = options.explicitSchema === true && unstated.length === 0;
435
+ const score = namedByClaim
436
+ ? Math.max(computed, MIN_APPLICABILITY_SCORE)
437
+ : computed;
408
438
  if (score < MIN_APPLICABILITY_SCORE) {
409
439
  reasons.push(`applicability score ${score.toFixed(2)} is below conservative threshold ${MIN_APPLICABILITY_SCORE.toFixed(2)}`);
440
+ if (unstated.length > 0) {
441
+ reasons.push(`the claim does not name ${unstated.join(", ")} from the selected schema ${schema.predicate_name}`);
442
+ }
410
443
  }
411
444
  return {
412
445
  eligible: reasons.length === 0 && score >= MIN_APPLICABILITY_SCORE,
@@ -1 +1 @@
1
- {"version":3,"file":"suggest-predicates.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/suggest-predicates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,0CAA0C,CAAC;AA2BlD,OAAO,KAAK,EAIV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AA+H9B,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,EACzE,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,GACzE,MAAM,CAIR;AAED,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,IAAI,CACR,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,EACD,KAAK,EAAE,IAAI,CACT,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,GACA,MAAM,CAKR;AA+ID,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,IAAI,EAAE,qBAAqB,EAC3B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,uBAAuB,CAAC,CA8ZlC;AA+WD,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
1
+ {"version":3,"file":"suggest-predicates.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/suggest-predicates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,0CAA0C,CAAC;AA2BlD,OAAO,KAAK,EAIV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AA+H9B,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,EACzE,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,GACzE,MAAM,CAIR;AAED,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,IAAI,CACR,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,EACD,KAAK,EAAE,IAAI,CACT,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,GACA,MAAM,CAKR;AA+ID,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,IAAI,EAAE,qBAAqB,EAC3B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,uBAAuB,CAAC,CAgalC;AA+WD,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
@@ -298,7 +298,9 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
298
298
  // Stage 2: semantic eligibility. A complete binding list cannot bypass this
299
299
  // gate, and every rejected candidate remains inspectable when retrieved.
300
300
  const initialCandidates = retrieved.map((ranked) => {
301
- const applicability = evaluateSemanticApplicability(ranked, text);
301
+ const applicability = evaluateSemanticApplicability(ranked, text, {
302
+ explicitSchema: Boolean(args.schemaId),
303
+ });
302
304
  return buildSuggestion(ranked.schema, text, subject, ranked.score, args.argumentBindings, args.polarityHint, {
303
305
  eligibility: applicability.eligible ? "eligible" : "rejected",
304
306
  rejectionReasons: applicability.reasons,
@@ -7,11 +7,13 @@ type TransactionInput = {
7
7
  };
8
8
  export declare function buildUpsertCommitGoal(input: TransactionInput): string;
9
9
  /**
10
- * Goal that stages the same entity and relationships the commit goal would
11
- * and runs the commit-time contradiction check inside a transaction that is
12
- * always rolled back (kb_preview_upsert_contradiction/3). It succeeds when
13
- * the commit would pass the check and fails with the commit's error when it
14
- * would not; it never writes.
10
+ * Goal that stages the same entity and relationships the commit goal would,
11
+ * inside a transaction that is always rolled back
12
+ * (kb_preview_upsert_contradiction/4), and runs the commit's own refusal
13
+ * rules: missing relationship endpoints, invalid directions, mixed symbol
14
+ * roles and, unless skipped, the requirement contradiction check. It
15
+ * succeeds when the commit would accept the write and fails with the
16
+ * commit's error when it would not; it never writes.
15
17
  */
16
18
  export declare function buildUpsertContradictionPreviewGoal(input: TransactionInput): string;
17
19
  type WhatIfInput = TransactionInput & {
@@ -1 +1 @@
1
- {"version":3,"file":"contradictions.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/contradictions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AASrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;CAC1C,CAAC;AAGF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAOrE;AAGD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,gBAAgB,GACtB,MAAM,CAOR;AAiBD,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAgB/E;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,MAAM,CAER;AAGD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,MAAM,CAER;AAED,oEAAoE;AAEpE,wBAAgB,0BAA0B,CACxC,MAAM,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ED,oEAAoE;AAEpE,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAClC,MAAM,CAKR;AAGD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAe9B;AAGD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,iBAAiB,GACzB,MAAM,CAOR"}
@@ -9,16 +9,18 @@ export function buildUpsertCommitGoal(input) {
9
9
  }
10
10
  // implements REQ-kibi-operation-interface-parity
11
11
  /**
12
- * Goal that stages the same entity and relationships the commit goal would
13
- * and runs the commit-time contradiction check inside a transaction that is
14
- * always rolled back (kb_preview_upsert_contradiction/3). It succeeds when
15
- * the commit would pass the check and fails with the commit's error when it
16
- * would not; it never writes.
12
+ * Goal that stages the same entity and relationships the commit goal would,
13
+ * inside a transaction that is always rolled back
14
+ * (kb_preview_upsert_contradiction/4), and runs the commit's own refusal
15
+ * rules: missing relationship endpoints, invalid directions, mixed symbol
16
+ * roles and, unless skipped, the requirement contradiction check. It
17
+ * succeeds when the commit would accept the write and fails with the
18
+ * commit's error when it would not; it never writes.
17
19
  */
18
20
  export function buildUpsertContradictionPreviewGoal(input) {
19
21
  const type = String(input.entity.type);
20
22
  const relationships = input.relationships.map((relationship) => `rel(${String(relationship.type)}, '${escapeAtom(String(relationship.from))}', '${escapeAtom(String(relationship.to))}', ${buildRelationshipMetadata(relationship)})`);
21
- return `kb_preview_upsert_contradiction(${type}, ${buildPropertyList(input.entity)}, [${relationships.join(", ")}])`;
23
+ return `kb_preview_upsert_contradiction(${type}, ${buildPropertyList(input.entity)}, [${relationships.join(", ")}], ${input.skipContradictionCheck ? "true" : "false"})`;
22
24
  }
23
25
  function upsertBatchEntry(input) {
24
26
  const type = String(input.entity.type);
@@ -106,6 +106,21 @@ export declare function renderSourceDocument(input: UpsertInput, entity: Readonl
106
106
  * "unknown" and keeps the previous behaviour.
107
107
  */
108
108
  export declare function isUntrackedByGit(workspaceRoot: string, relative: string): boolean;
109
+ /**
110
+ * The authored document an upsert publishes, resolved and rendered without
111
+ * writing: the target path (with its containment checks), the current bytes
112
+ * and the bytes the write would publish. writeSourceForUpsert publishes
113
+ * exactly this, and a kb_upsert dry run renders it so a path or format the
114
+ * write would refuse is refused by the dry run too.
115
+ */
116
+ export declare function renderSourceWrite(input: UpsertInput, entity: Readonly<Record<string, unknown>>, existing: Readonly<Record<string, unknown>> | undefined, context: OperationContext & {
117
+ readonly fs: NonNullable<OperationContext["fs"]>;
118
+ }, sourceDocumentOverride?: string): Promise<{
119
+ absolute: string;
120
+ relative: string;
121
+ before: string | undefined;
122
+ after: string;
123
+ }>;
109
124
  export declare function writeSourceForUpsert(input: UpsertInput, entity: Readonly<Record<string, unknown>>, existing?: Readonly<Record<string, unknown>>, context?: OperationContext, sourceDocumentOverride?: string): Promise<{
110
125
  receipt: SourceWriteReceipt;
111
126
  rollback: () => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"source-authoring.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/source-authoring.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAOjF,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAmBH,wBAAgB,yBAAyB,CACvC,aAAa,EA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