kibi-cli 2.22.1 → 2.24.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 (159) hide show
  1. package/dist/cli-operation-metadata.d.ts +1 -1
  2. package/dist/cli-operation-metadata.js +1 -1
  3. package/dist/cli-register-foundation.d.ts.map +1 -1
  4. package/dist/cli-register-foundation.js +1 -0
  5. package/dist/commands/check.d.ts.map +1 -1
  6. package/dist/commands/check.js +51 -3
  7. package/dist/commands/doctor.d.ts.map +1 -1
  8. package/dist/commands/doctor.js +28 -0
  9. package/dist/commands/migrate.d.ts +10 -0
  10. package/dist/commands/migrate.d.ts.map +1 -1
  11. package/dist/commands/migrate.js +81 -9
  12. package/dist/commands/sync.d.ts.map +1 -1
  13. package/dist/commands/sync.js +15 -1
  14. package/dist/decision-firmness.d.ts +16 -4
  15. package/dist/decision-firmness.d.ts.map +1 -1
  16. package/dist/decision-firmness.js +29 -6
  17. package/dist/extractors/markdown.d.ts.map +1 -1
  18. package/dist/extractors/markdown.js +39 -36
  19. package/dist/intent-search.d.ts +2 -0
  20. package/dist/intent-search.d.ts.map +1 -1
  21. package/dist/intent-search.js +43 -4
  22. package/dist/operations/bootstrap/activation.d.ts +7 -1
  23. package/dist/operations/bootstrap/activation.d.ts.map +1 -1
  24. package/dist/operations/bootstrap/activation.js +27 -2
  25. package/dist/operations/bootstrap/candidate-helpers.d.ts +6 -0
  26. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  27. package/dist/operations/bootstrap/candidate-helpers.js +19 -0
  28. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  29. package/dist/operations/bootstrap/generate.js +56 -16
  30. package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
  31. package/dist/operations/bootstrap/guidance-actions.js +14 -2
  32. package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
  33. package/dist/operations/bootstrap/guidance.js +6 -2
  34. package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
  35. package/dist/operations/bootstrap/intent-claims.js +2 -2
  36. package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
  37. package/dist/operations/bootstrap/markdown-candidates.js +2 -2
  38. package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
  39. package/dist/operations/bootstrap/presentation.js +75 -9
  40. package/dist/operations/bootstrap/types.d.ts +6 -0
  41. package/dist/operations/bootstrap/types.d.ts.map +1 -1
  42. package/dist/operations/migration/firm-supersede.d.ts +19 -0
  43. package/dist/operations/migration/firm-supersede.d.ts.map +1 -0
  44. package/dist/operations/migration/firm-supersede.js +60 -0
  45. package/dist/operations/migration/kb-sources.d.ts +8 -5
  46. package/dist/operations/migration/kb-sources.d.ts.map +1 -1
  47. package/dist/operations/migration/kb-sources.js +50 -14
  48. package/dist/operations/migration/schema6.d.ts.map +1 -1
  49. package/dist/operations/migration/schema6.js +52 -2
  50. package/dist/operations/migration/source-paths.d.ts +18 -1
  51. package/dist/operations/migration/source-paths.d.ts.map +1 -1
  52. package/dist/operations/migration/source-paths.js +111 -16
  53. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  54. package/dist/operations/modeling/suggest-predicates.js +22 -7
  55. package/dist/operations/mutation/requirement-semantics.d.ts +19 -1
  56. package/dist/operations/mutation/requirement-semantics.d.ts.map +1 -1
  57. package/dist/operations/mutation/requirement-semantics.js +63 -2
  58. package/dist/operations/mutation/strict-fact.js +1 -1
  59. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  60. package/dist/operations/mutation/upsert.js +2 -1
  61. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  62. package/dist/operations/planning/apply-plan.js +22 -2
  63. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  64. package/dist/operations/semantic-advisor/analyze-prose.js +49 -17
  65. package/dist/public/impact/analyzer.d.ts.map +1 -1
  66. package/dist/public/impact/analyzer.js +7 -1
  67. package/dist/public/impact/diagnostics.d.ts.map +1 -1
  68. package/dist/public/impact/diagnostics.js +16 -3
  69. package/dist/public/impact/types.d.ts +2 -0
  70. package/dist/public/impact/types.d.ts.map +1 -1
  71. package/dist/public/operations/catalog.d.ts +8 -3
  72. package/dist/public/operations/catalog.d.ts.map +1 -1
  73. package/dist/public/operations/check-executor.d.ts.map +1 -1
  74. package/dist/public/operations/check-executor.js +10 -3
  75. package/dist/public/operations/check-helpers.d.ts +10 -0
  76. package/dist/public/operations/check-helpers.d.ts.map +1 -1
  77. package/dist/public/operations/check-helpers.js +54 -0
  78. package/dist/public/operations/contracts.d.ts.map +1 -1
  79. package/dist/public/operations/contracts.js +1 -0
  80. package/dist/public/operations/decision-firmness.d.ts +14 -0
  81. package/dist/public/operations/decision-firmness.d.ts.map +1 -1
  82. package/dist/public/operations/decision-firmness.js +60 -7
  83. package/dist/public/operations/discovery-executors.d.ts +18 -0
  84. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  85. package/dist/public/operations/discovery-executors.js +80 -8
  86. package/dist/public/operations/schema6-check-actions.d.ts +4 -0
  87. package/dist/public/operations/schema6-check-actions.d.ts.map +1 -1
  88. package/dist/public/operations/schema6-check-actions.js +39 -2
  89. package/dist/public/operations/source-path-dangling.d.ts +1 -1
  90. package/dist/public/operations/source-path-dangling.d.ts.map +1 -1
  91. package/dist/public/operations/source-path-dangling.js +11 -2
  92. package/dist/public/operations/specs/composite.d.ts +1 -1
  93. package/dist/public/operations/specs/discovery.d.ts +5 -0
  94. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  95. package/dist/public/operations/specs/discovery.js +5 -0
  96. package/dist/public/operations/specs/planning.d.ts +1 -1
  97. package/dist/public/operations/specs/planning.js +1 -1
  98. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  99. package/dist/public/operations/specs/reporting.js +6 -4
  100. package/dist/public/operations/specs/semantic.d.ts +1 -1
  101. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  102. package/dist/public/operations/specs/semantic.js +4 -2
  103. package/dist/public/operations/specs/upsert.d.ts +1 -1
  104. package/dist/public/operations/specs/upsert.js +1 -1
  105. package/dist/public/schemas/entity.js +1 -1
  106. package/dist/public/skills/kibi-bootstrap/SKILL.md +5 -4
  107. package/dist/public/skills/kibi-usage/SKILL.md +36 -16
  108. package/dist/public/skills/kibi-usage/resources/workflows.md +3 -1
  109. package/dist/schemas/entity.schema.json +1 -1
  110. package/dist/search-answer.d.ts +14 -0
  111. package/dist/search-answer.d.ts.map +1 -1
  112. package/dist/search-answer.js +51 -5
  113. package/dist/traceability/git-change-snapshot.d.ts +46 -0
  114. package/dist/traceability/git-change-snapshot.d.ts.map +1 -1
  115. package/dist/traceability/git-change-snapshot.js +187 -3
  116. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  117. package/dist/traceability/staged-diagnostics.js +5 -6
  118. package/dist/traceability/staged-inventory-drift.d.ts +24 -0
  119. package/dist/traceability/staged-inventory-drift.d.ts.map +1 -0
  120. package/dist/traceability/staged-inventory-drift.js +84 -0
  121. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  122. package/dist/traceability/staged-symbols-manifest.js +1 -2
  123. package/dist/types/entities.d.ts +2 -2
  124. package/dist/types/entities.d.ts.map +1 -1
  125. package/dist/utils/content-freshness.d.ts +9 -0
  126. package/dist/utils/content-freshness.d.ts.map +1 -1
  127. package/dist/utils/content-freshness.js +33 -0
  128. package/dist/utils/kb-manifest.d.ts +7 -0
  129. package/dist/utils/kb-manifest.d.ts.map +1 -1
  130. package/dist/utils/kb-manifest.js +6 -0
  131. package/dist/utils/merge-driver-setup.d.ts +10 -0
  132. package/dist/utils/merge-driver-setup.d.ts.map +1 -0
  133. package/dist/utils/merge-driver-setup.js +69 -0
  134. package/dist/utils/rule-registry.generated.d.ts +1 -1
  135. package/dist/utils/rule-registry.generated.js +1 -1
  136. package/dist/utils/schema-version.d.ts +1 -1
  137. package/dist/utils/schema-version.d.ts.map +1 -1
  138. package/dist/utils/schema-version.js +3 -1
  139. package/package.json +2 -2
  140. package/src/public/impact/analyzer.ts +13 -1
  141. package/src/public/impact/diagnostics.ts +20 -3
  142. package/src/public/impact/types.ts +2 -0
  143. package/src/public/operations/check-executor.ts +16 -4
  144. package/src/public/operations/check-helpers.ts +65 -0
  145. package/src/public/operations/contracts.ts +1 -0
  146. package/src/public/operations/decision-firmness.ts +83 -10
  147. package/src/public/operations/discovery-executors.ts +124 -7
  148. package/src/public/operations/schema6-check-actions.ts +43 -2
  149. package/src/public/operations/source-path-dangling.ts +12 -2
  150. package/src/public/operations/specs/discovery.ts +6 -0
  151. package/src/public/operations/specs/planning.ts +1 -1
  152. package/src/public/operations/specs/reporting.ts +6 -4
  153. package/src/public/operations/specs/semantic.ts +4 -2
  154. package/src/public/operations/specs/upsert.ts +1 -1
  155. package/src/public/schemas/entity.ts +1 -1
  156. package/src/public/skills/kibi-bootstrap/SKILL.md +5 -4
  157. package/src/public/skills/kibi-usage/SKILL.md +36 -16
  158. package/src/public/skills/kibi-usage/resources/workflows.md +3 -1
  159. package/src/schemas/entity.schema.json +1 -1
@@ -1,8 +1,9 @@
1
+ import { readFile } from "node:fs/promises";
1
2
  import path from "node:path";
2
3
  import { compilerFingerprintReason } from "../../commands/sync/cache.js";
3
4
  import { effectiveFirmness } from "../../decision-firmness.js";
4
5
  import { EngineClient } from "../../engine.js";
5
- import { executeIntentSearch, validateIntentSearchInput, } from "../../intent-search.js";
6
+ import { executeIntentSearch, questionPaths, validateIntentSearchInput, } from "../../intent-search.js";
6
7
  import { classifyActivation } from "../../operations/bootstrap/activation.js";
7
8
  import { SwiplResolutionError } from "../../prolog/swipl-resolver.js";
8
9
  import { buildSearchAnswer } from "../../search-answer.js";
@@ -11,9 +12,12 @@ import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
11
12
  import { BRANCH_STORE_NOT_COMPILED, branchStoreReason, inspectBranchStore, storeLockJournalReason, storeLockTakeoverReason, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
12
13
  import { confirmSourceNewerReasons } from "../../utils/content-freshness.js";
13
14
  import { loadSearchCandidates, paginateResults, queryEntitiesViaQuery, reloadFullEntities, validateEntityType, } from "./discovery-entities.js";
15
+ import { readAuthoredEntity } from "./entity-context.js";
14
16
  import { buildActionsFromStatus, readMigrationConfigStatus, } from "./migration-plan.js";
15
17
  import { OperationJsonDecodeError, runOperationJsonQuery, toPrologAtom, } from "./prolog-json.js";
16
18
  import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
19
+ /** Bodies longer than this are cut; the file itself stays the full record. */
20
+ export const QUERY_BODY_MAX_CHARS = 32_000;
17
21
  export const FACT_KINDS = [
18
22
  "subject",
19
23
  "property_value",
@@ -419,6 +423,9 @@ export async function executeQuery(input, context) {
419
423
  const { type, id, tags, sourceFile, limit = 100, offset = 0 } = input;
420
424
  try {
421
425
  validateEntityType(type);
426
+ if (input.includeBody === true && (id === undefined || id === "")) {
427
+ throw new Error("includeBody needs id: it returns the authored body of one entity. Pass the entity's id.");
428
+ }
422
429
  if (hasTypedFactFilters(input)) {
423
430
  return await executeFactQuery(input, context, limit, offset);
424
431
  }
@@ -439,11 +446,12 @@ export async function executeQuery(input, context) {
439
446
  const indexedPage = prolog.queryEntities
440
447
  ? await prolog.queryEntities(pageInput, signal)
441
448
  : await queryEntitiesViaQuery(prolog, pageInput, signal);
442
- // A requirement or ADR without authored firmness reads as `default`;
443
- // the row says so, so a reader never has to know the default.
444
- // implements REQ-kb-decision-firmness
449
+ // A requirement or ADR without authored firmness reads as its origin
450
+ // implies (`default` when an agent wrote it, else `firm`); the row says
451
+ // so, so a reader never has to know the rule.
452
+ // implements REQ-kb-decision-firmness, REQ-kb-decision-firmness-from-origin
445
453
  const paginated = indexedPage.entities.map((entity) => {
446
- const firmness = effectiveFirmness(entity.type, entity.firmness);
454
+ const firmness = effectiveFirmness(entity.type, entity.firmness, entity.origin);
447
455
  return firmness === undefined || entity.firmness === firmness
448
456
  ? entity
449
457
  : { ...entity, firmness };
@@ -459,12 +467,18 @@ export async function executeQuery(input, context) {
459
467
  return `${entityId} (${String(entity.title ?? "")}, status=${String(entity.status ?? "")})`;
460
468
  })
461
469
  .join(", ")}`;
470
+ const body = input.includeBody === true && id !== undefined
471
+ ? await readQueryBody(id, paginated.find((entity) => entity.id === id), context)
472
+ : undefined;
462
473
  return {
463
- content: [{ type: "text", text }],
474
+ content: [
475
+ { type: "text", text: body ? `${text}\n${queryBodyText(body)}` : text },
476
+ ],
464
477
  structuredContent: {
465
478
  entities: paginated,
466
479
  count: indexedPage.count,
467
480
  ...(storeNotice ? { branchStore: storeNotice } : {}),
481
+ ...(body ? { body } : {}),
468
482
  },
469
483
  };
470
484
  }
@@ -473,6 +487,48 @@ export async function executeQuery(input, context) {
473
487
  throw new Error(`Query execution failed: ${message}`);
474
488
  }
475
489
  }
490
+ // The body is read from the entity's authored document inside the
491
+ // workspace, the same file kb_upsert rewrites; nothing outside it is read.
492
+ // implements REQ-kibi-operation-interface-parity
493
+ async function readQueryBody(id, entity, context) {
494
+ const source = typeof entity?.source === "string" ? entity.source : "";
495
+ const relative = source.split("#", 1)[0]?.trim() ?? "";
496
+ const root = path.resolve(context.workspaceRoot);
497
+ const resolved = path.resolve(root, relative);
498
+ if (!relative.endsWith(".md") || !resolved.startsWith(root + path.sep)) {
499
+ return { id, path: null, text: null };
500
+ }
501
+ const bodyPath = path.relative(root, resolved).split(path.sep).join("/");
502
+ let raw;
503
+ try {
504
+ raw = String(context.fs
505
+ ? await context.fs.readFile(resolved)
506
+ : await readFile(resolved, "utf8"));
507
+ }
508
+ catch {
509
+ return { id, path: bodyPath, text: null };
510
+ }
511
+ const authored = readAuthoredEntity(raw, bodyPath)?.body;
512
+ if (authored === undefined || authored === null) {
513
+ return { id, path: bodyPath, text: null };
514
+ }
515
+ return authored.length > QUERY_BODY_MAX_CHARS
516
+ ? {
517
+ id,
518
+ path: bodyPath,
519
+ text: authored.slice(0, QUERY_BODY_MAX_CHARS),
520
+ truncated: true,
521
+ }
522
+ : { id, path: bodyPath, text: authored };
523
+ }
524
+ function queryBodyText(body) {
525
+ if (body.text === null) {
526
+ return body.path === null
527
+ ? `No authored document for ${body.id}, so there is no body to return.`
528
+ : `The authored document ${body.path} of ${body.id} could not be read.`;
529
+ }
530
+ return `Body of ${body.id} (${body.path}${body.truncated ? `, first ${QUERY_BODY_MAX_CHARS} characters` : ""}; replace it with kb_upsert document.body):\n${body.text}`;
531
+ }
476
532
  /**
477
533
  * Identifying metadata a caller needs to decide which hits to open.
478
534
  *
@@ -512,6 +568,22 @@ async function projectMatches(prolog, matches, fields) {
512
568
  ? reloadFullEntities(prolog, matches)
513
569
  : matches.map(summarizeMatch);
514
570
  }
571
+ // A question about contradictions is answered by the check, not by the
572
+ // entities that happen to mention the word.
573
+ const CONTRADICTION_QUESTION = /\b(contradict\w*|conflict\w*|inconsisten\w*)\b/i;
574
+ const CONTRADICTION_HINT = ' Search only finds entities that mention a conflict. Whether current requirements contradict each other is decided by kb_check with rules ["domain-contradictions"]; what a proposed rule would conflict with, by kb_model mode predicates (decisionConflicts) on its text or a kb_upsert dryRun.';
575
+ // A file path written in the question is left out of its topic. Passed as
576
+ // sourceLocations it also brings the requirements linked to that file.
577
+ function questionPathHint(query, locations) {
578
+ const located = new Set((locations ?? []).map((location) => location.path.replace(/^\.\//, "")));
579
+ const named = questionPaths(query).filter((file) => !located.has(file));
580
+ if (named.length === 0)
581
+ return "";
582
+ const list = named.join(", ");
583
+ return named.length === 1
584
+ ? ` The question names ${list}; its words were left out of the topic. Pass it as sourceLocations to also see the requirements linked to that file.`
585
+ : ` The question names ${list}; their words were left out of the topic. Pass them as sourceLocations to also see the requirements linked to those files.`;
586
+ }
515
587
  export async function executeSearch(input, context) {
516
588
  // implements REQ-kibi-operation-interface-parity, REQ-mcp-search-discovery
517
589
  const { query, type, limit = 10, offset = 0, rankingMode = "intent-v1", semanticFacets, sourceLocations, minScore, fields = "summary", answer, } = input;
@@ -559,11 +631,11 @@ export async function executeSearch(input, context) {
559
631
  // governing list is never read as the top match's requirement.
560
632
  const topUngoverned = answerLayer?.ungoverned.find((entry) => entry.rank === 1);
561
633
  const text = `${intentResult.matches.length === 0
562
- ? `No intent search results for '${trimmedQuery}' (abstained).`
634
+ ? `No intent search results for '${trimmedQuery}' (abstained). No entity shares enough of the question's words: ask again in the words and language the KB is written in, or pass sourceLocations.`
563
635
  : `Found ${intentResult.matches.length} intent search results for '${trimmedQuery}'${intentResult.analysis.ambiguous ? " (top matches are close; confirm before relying on one)" : ""}. Top: ${paginated
564
636
  .slice(0, 5)
565
637
  .map((match) => String(match.entity.id ?? ""))
566
- .join(", ")}${answerLayer ? `. Governing: ${answerLayer.governing.map((req) => req.id).join(", ") || "none found"}` : ""}${topUngoverned ? ` (the top match ${topUngoverned.id} is linked to no requirement)` : ""}.`}${storeNote}`;
638
+ .join(", ")}${answerLayer ? `. Governing: ${answerLayer.governing.map((req) => req.id).join(", ") || "none found"}` : ""}${topUngoverned ? ` (the top match ${topUngoverned.id} is linked to no requirement)` : ""}.`}${questionPathHint(trimmedQuery, sourceLocations)}${CONTRADICTION_QUESTION.test(trimmedQuery) ? CONTRADICTION_HINT : ""}${storeNote}`;
567
639
  return {
568
640
  content: [{ type: "text", text }],
569
641
  structuredContent: {
@@ -64,6 +64,8 @@ export declare function supersessionCycleReviewActionInput(cycle: {
64
64
  export type SourcePathRewriteInput = Readonly<{
65
65
  entityId: string;
66
66
  file: string;
67
+ /** The field rewritten; absent means `source`. */
68
+ field?: "text_ref";
67
69
  from: string;
68
70
  to: string;
69
71
  }>;
@@ -88,6 +90,8 @@ export declare function sourcePathRewriteActionInput(input: Readonly<{
88
90
  */
89
91
  export declare function sourcePathReviewActionInput(source: {
90
92
  entityId: string;
93
+ /** The field to repair; absent means `source`. */
94
+ field?: "text_ref";
91
95
  value: unknown;
92
96
  file?: string;
93
97
  reason?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"schema6-check-actions.d.ts","sourceRoot":"","sources":["../../../src/public/operations/schema6-check-actions.ts"],"names":[],"mappings":"AAmBA,OAAO,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AE,CA4NpE"}
@@ -178,7 +178,7 @@ export function sourcePathRewriteActionInput(input) {
178
178
  { selfReferencingSources: 0 },
179
179
  ],
180
180
  evidence: {
181
- reason: "The authored source field is dead data: the compiled source is always the entity's own file, and Kibi ignores the field when compiling and never writes it. Each rewrite points a knowledge file named by its pre-canonical path (under documentation/, or relative to the knowledge root) at the same file under .kb/. Each removal deletes a value that names the entity's own file (reason self) or nothing Kibi can map (reason dangling). Only the source line changes.",
181
+ reason: "The authored source field is dead data: the compiled source is always the entity's own file, and Kibi ignores the field when compiling and never writes it. Each rewrite points a knowledge file named by its pre-canonical path (under documentation/, or relative to the knowledge root) at the same file under .kb/; a rewrite with field text_ref does the same for a text_ref evidence path. Each removal deletes a source value that names the entity's own file (reason self) or nothing Kibi can map (reason dangling). Only the rewritten or removed line changes.",
182
182
  count: all.length,
183
183
  rewrites: rewrites.map((rewrite) => ({ ...rewrite })),
184
184
  removals: removals.map((removal) => ({ ...removal })),
@@ -195,6 +195,31 @@ export function sourcePathReviewActionInput(source) {
195
195
  ? source.value
196
196
  : JSON.stringify(source.value);
197
197
  const where = source.file !== undefined ? ` in ${source.file}` : "";
198
+ if (source.field === "text_ref") {
199
+ const edit = source.rewrite !== undefined
200
+ ? `replace the whole field with the single line 'text_ref: ${source.rewrite}'`
201
+ : "point text_ref at the evidence file's current path, or delete the field when that evidence is gone";
202
+ return {
203
+ id: `review-text-ref-dangling-${stableIdPart(source.entityId)}`,
204
+ code: SOURCE_PATH_REVIEW_CODE,
205
+ category: "quality",
206
+ safety: "review",
207
+ invocation: {
208
+ kind: "review",
209
+ instruction: `${source.entityId} has text_ref '${shown}'${where}, a file path that does not exist (${source.reason ?? "the edit would not read back as exactly that change"}). A person edits the frontmatter by hand: ${edit}. Then rerun kibi migrate.`,
210
+ },
211
+ affectedEntityIds: [source.entityId],
212
+ affectedFiles: source.file !== undefined ? [source.file] : [],
213
+ dispositionRequired: true,
214
+ evidence: {
215
+ entityId: source.entityId,
216
+ field: "text_ref",
217
+ text_ref: source.value,
218
+ ...(source.reason !== undefined ? { refused: source.reason } : {}),
219
+ ...(source.rewrite !== undefined ? { rewrite: source.rewrite } : {}),
220
+ },
221
+ };
222
+ }
198
223
  const edit = source.rewrite !== undefined
199
224
  ? `replace the whole field with the single line 'source: ${source.rewrite}'`
200
225
  : "delete the whole field, every line of it";
@@ -272,9 +297,11 @@ export function lifecycleActionsFromViolations(violations) {
272
297
  const from = typeof evidence.value === "string"
273
298
  ? evidence.value
274
299
  : (JSON.stringify(evidence.value) ?? "");
300
+ const textRef = evidence.field === "text_ref";
275
301
  if (refused !== "" || file === "") {
276
302
  actions.push(sourcePathReviewActionInput({
277
303
  entityId,
304
+ ...(textRef ? { field: "text_ref" } : {}),
278
305
  value: evidence.value,
279
306
  ...(file !== "" ? { file } : {}),
280
307
  ...(refused !== "" ? { reason: refused } : {}),
@@ -282,7 +309,17 @@ export function lifecycleActionsFromViolations(violations) {
282
309
  }));
283
310
  }
284
311
  else if (rewrite !== "") {
285
- rewrites.push({ entityId, file, from, to: rewrite });
312
+ rewrites.push({
313
+ entityId,
314
+ file,
315
+ ...(textRef ? { field: "text_ref" } : {}),
316
+ from,
317
+ to: rewrite,
318
+ });
319
+ }
320
+ else if (textRef) {
321
+ // Kibi never removes evidence; an unmapped text_ref carries refused.
322
+ continue;
286
323
  }
287
324
  else {
288
325
  removals.push({
@@ -1,6 +1,6 @@
1
1
  import { type SourceRepair } from "../../operations/migration/source-paths.js";
2
2
  import type { Violation } from "../../utils/rule-registry.js";
3
- /** An authored source field that names no path, entity or URL. */
3
+ /** An authored source field that names no path, entity or URL, or a path-shaped text_ref that names no file. */
4
4
  export declare const SOURCE_PATH_DANGLING_RULE = "source-path-dangling";
5
5
  /**
6
6
  * One blocking finding per authored source that resolves to nothing. The
@@ -1 +1 @@
1
- {"version":3,"file":"source-path-dangling.d.ts","sourceRoot":"","sources":["../../../src/public/operations/source-path-dangling.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,kEAAkE;AAElE,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAiBhE;;;;GAIG;AAEH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,SAAS,YAAY,EAAE,GAChC,SAAS,EAAE,CAgBb;AAED;;;;GAIG;AAEH,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,GACpB,SAAS,EAAE,CAEb"}
1
+ {"version":3,"file":"source-path-dangling.d.ts","sourceRoot":"","sources":["../../../src/public/operations/source-path-dangling.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,gHAAgH;AAEhH,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAuBhE;;;;GAIG;AAEH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,SAAS,YAAY,EAAE,GAChC,SAAS,EAAE,CAoBb;AAED;;;;GAIG;AAEH,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,GACpB,SAAS,EAAE,CAEb"}
@@ -16,10 +16,16 @@
16
16
  along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
  */
18
18
  import { findDanglingSources, shownSourceValue, } from "../../operations/migration/source-paths.js";
19
- /** An authored source field that names no path, entity or URL. */
19
+ /** An authored source field that names no path, entity or URL, or a path-shaped text_ref that names no file. */
20
20
  // implements REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
21
21
  export const SOURCE_PATH_DANGLING_RULE = "source-path-dangling";
22
22
  function suggestion(source) {
23
+ if (source.field === "text_ref") {
24
+ if (source.refused !== undefined) {
25
+ return `kibi migrate cannot repair this text_ref (${source.refused}), so it plans a review_source_path_dangling action. Point text_ref at the evidence file's current path, or clear it when the evidence is gone: kb_upsert with the entity's title, status and text_ref "".`;
26
+ }
27
+ return `The file moved to ${source.fix.kind === "rewrite" ? source.fix.to : source.file}; kibi migrate rewrites the text_ref field there (source_path_rewrite).`;
28
+ }
23
29
  const compiled = `The compiled source is always the entity's own file (${source.file}), so the field carries nothing Kibi compiles.`;
24
30
  if (source.refused !== undefined) {
25
31
  return `kibi migrate cannot edit this source field safely (${source.refused}), so it plans a review_source_path_dangling action for a person. ${compiled}`;
@@ -42,10 +48,13 @@ export function sourcePathDanglingViolations(dangling) {
42
48
  return dangling.map((source) => ({
43
49
  rule: SOURCE_PATH_DANGLING_RULE,
44
50
  entityId: source.entityId,
45
- description: `${source.entityId} names source '${shownSourceValue(source.value)}', which is not an existing workspace path, an entity id or an http(s) URL`,
51
+ description: source.field === "text_ref"
52
+ ? `${source.entityId} names text_ref '${shownSourceValue(source.value)}', a file path that does not exist in the workspace`
53
+ : `${source.entityId} names source '${shownSourceValue(source.value)}', which is not an existing workspace path, an entity id or an http(s) URL`,
46
54
  suggestion: suggestion(source),
47
55
  source: source.file,
48
56
  evidence: {
57
+ ...(source.field === "text_ref" ? { field: "text_ref" } : {}),
49
58
  value: source.value,
50
59
  file: source.file,
51
60
  ...(source.fix.kind === "rewrite"
@@ -106,7 +106,7 @@ export declare const MODEL_ROUTES: {
106
106
  readonly items: {
107
107
  readonly type: "string";
108
108
  };
109
- readonly description: "Optional complete list of atomic requirement clauses supplied by the caller. Use this for compound prose so every normative clause receives a stable claim key and independent grounding review.";
109
+ readonly description: "Optional complete list of atomic requirement clauses supplied by the caller. Each clause must be a verbatim fragment of text (whitespace may differ); a clause that does not occur in text fails the call with VALIDATION_FAILED naming it. Use this for compound prose so every normative clause receives a stable claim key and independent grounding review.";
110
110
  };
111
111
  readonly interpretations: {
112
112
  readonly type: "array";
@@ -85,6 +85,11 @@ export declare const querySpec: {
85
85
  readonly default: 0;
86
86
  readonly description: "Optional zero-based pagination offset. Default: 0. Example: 50 to skip first 50 rows.";
87
87
  };
88
+ readonly includeBody: {
89
+ readonly type: "boolean";
90
+ readonly default: false;
91
+ readonly description: "With id only: also return the entity's authored Markdown body (the prose after its front matter) as body {id, path, text}, so a stale statement in it can be corrected; kb_upsert document.body replaces it. Default: false.";
92
+ };
88
93
  };
89
94
  };
90
95
  readonly requiresProlog: true;
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACd,MAAM,2BAA2B,CAAC;AAiCnC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuGsC,CAAC;AAE7D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2GuC,CAAC;AAE/D,eAAO,MAAM,UAAU;;;;;;;;;;;;CAWuC,CAAC"}
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACd,MAAM,2BAA2B,CAAC;AAiCnC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6GsC,CAAC;AAE7D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2GuC,CAAC;AAE/D,eAAO,MAAM,UAAU;;;;;;;;;;;;CAWuC,CAAC"}
@@ -99,6 +99,11 @@ export const querySpec = {
99
99
  default: 0,
100
100
  description: "Optional zero-based pagination offset. Default: 0. Example: 50 to skip first 50 rows.",
101
101
  },
102
+ includeBody: {
103
+ type: "boolean",
104
+ default: false,
105
+ description: "With id only: also return the entity's authored Markdown body (the prose after its front matter) as body {id, path, text}, so a stale statement in it can be corrected; kb_upsert document.body replaces it. Default: false.",
106
+ },
102
107
  },
103
108
  },
104
109
  requiresProlog: true,
@@ -54,7 +54,7 @@ export declare const compileIntentSpec: {
54
54
  readonly minLength: 1;
55
55
  };
56
56
  readonly maxItems: 64;
57
- readonly description: "Optional complete atomic clause decomposition. Each assertive clause receives independent proposition accounting.";
57
+ readonly description: "Optional complete atomic clause decomposition. Each clause must be a verbatim fragment of intent (whitespace may differ); a clause that does not occur in intent fails the call with VALIDATION_FAILED naming it. Each assertive clause receives independent proposition accounting.";
58
58
  };
59
59
  readonly semanticFacets: {
60
60
  readonly type: "object";
@@ -49,7 +49,7 @@ export const compileIntentSpec = {
49
49
  type: "array",
50
50
  items: { type: "string", minLength: 1 },
51
51
  maxItems: 64,
52
- description: "Optional complete atomic clause decomposition. Each assertive clause receives independent proposition accounting.",
52
+ description: "Optional complete atomic clause decomposition. Each clause must be a verbatim fragment of intent (whitespace may differ); a clause that does not occur in intent fails the call with VALIDATION_FAILED naming it. Each assertive clause receives independent proposition accounting.",
53
53
  },
54
54
  semanticFacets: {
55
55
  type: "object",
@@ -1 +1 @@
1
- {"version":3,"file":"reporting.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/reporting.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,mB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEyC,CAAC;AAEnE,wBAAsB,YAAY,CAChC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CA8BxC;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBsC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { confirmMetaFreshness } from "../../../utils/content-freshness.js";
1
2
  import { PROOF_RECEIPT_MAX_AGE_SECONDS } from "../../proof-receipt.js";
2
3
  import { executeStatus } from "../discovery-executors.js";
3
4
  import { buildLegacyMigrationPlanFromContext, } from "../legacy-migration-plan.js";
@@ -58,7 +59,7 @@ export async function executeFindGaps(input, context) {
58
59
  : `Found ${payload.count ?? rows.length} gap rows. Showing ${rows.length}: ${rows.map((row) => row.id).join(", ")}.${stubNote}`,
59
60
  },
60
61
  ],
61
- structuredContent: payload,
62
+ structuredContent: confirmMetaFreshness(payload, context.workspaceRoot),
62
63
  };
63
64
  }
64
65
  catch (error) {
@@ -238,15 +239,16 @@ export async function executeCoverage(input, context) {
238
239
  const migrationPlan = statusPlan
239
240
  ? mergeMigrationPlans([statusPlan, coveragePlan])
240
241
  : coveragePlan;
242
+ const confirmed = confirmMetaFreshness(payload, context.workspaceRoot);
241
243
  const enrichedPayload = {
242
- ...payload,
244
+ ...confirmed,
243
245
  rows,
244
246
  ...(repairPlan !== undefined ? { repairPlan } : {}),
245
247
  ...(legacyMigrationPlan !== undefined ? { legacyMigrationPlan } : {}),
246
248
  ...(symbolRepairPlan !== undefined ? { symbolRepairPlan } : {}),
247
249
  migrationPlan,
248
250
  meta: {
249
- ...(payload.meta ?? {}),
251
+ ...(confirmed.meta ?? {}),
250
252
  proofReceiptMaxAgeSeconds: PROOF_RECEIPT_MAX_AGE_SECONDS,
251
253
  proofSnapshot: codeSnapshot,
252
254
  proofSnapshotAvailable: snapshotEvidence.available,
@@ -354,7 +356,7 @@ export async function executeGraph(input, context) {
354
356
  : `Graph traversal returned ${nodes.length} nodes and ${edges.length} edges from ${input.seedIds.join(", ")}.`,
355
357
  },
356
358
  ],
357
- structuredContent: payload,
359
+ structuredContent: confirmMetaFreshness(payload, context.workspaceRoot),
358
360
  };
359
361
  }
360
362
  catch (error) {
@@ -19,7 +19,7 @@ export declare const semanticAdvisorSpec: {
19
19
  readonly items: {
20
20
  readonly type: "string";
21
21
  };
22
- readonly description: "Optional complete list of atomic requirement clauses supplied by the caller. Use this for compound prose so every normative clause receives a stable claim key and independent grounding review.";
22
+ readonly description: "Optional complete list of atomic requirement clauses supplied by the caller. Each clause must be a verbatim fragment of text (whitespace may differ); a clause that does not occur in text fails the call with VALIDATION_FAILED naming it. Use this for compound prose so every normative clause receives a stable claim key and independent grounding review.";
23
23
  };
24
24
  readonly interpretations: {
25
25
  readonly type: "array";
@@ -1 +1 @@
1
- {"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/semantic.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,8BAA8B,EAE/B,MAAM,+CAA+C,CAAC;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,qBAAqB,CAAC;AA8CxE,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,mBAAmB,EACzB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,8BAA8B,CAAC,CAiGzC;AAED,iBAAe,2BAA2B,CACxC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACxC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,8BAA8B,CAAC,CAiCzC;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EE,CAAC"}
1
+ {"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/semantic.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,8BAA8B,EAE/B,MAAM,+CAA+C,CAAC;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,qBAAqB,CAAC;AA8CxE,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,mBAAmB,EACzB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,8BAA8B,CAAC,CAmGzC;AAED,iBAAe,2BAA2B,CACxC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACxC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,8BAA8B,CAAC,CAiCzC;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EE,CAAC"}
@@ -107,7 +107,9 @@ export async function executeSemanticAdvisor(args, context) {
107
107
  content: [
108
108
  {
109
109
  type: "text",
110
- text: `kb_semantic_advisor: ${result.receipt.summary} Suggestions: ${result.receipt.suggestions.map(({ kind }) => kind).join(", ") || "none"}.`,
110
+ // A drift warning decides whether the analyzed ledger can be
111
+ // written at all, so the text says it too, not only the warnings.
112
+ text: `kb_semantic_advisor: ${result.receipt.summary} Suggestions: ${result.receipt.suggestions.map(({ kind }) => kind).join(", ") || "none"}.${ledgerWarnings.map((warning) => ` ${warning}`).join("")}`,
111
113
  },
112
114
  ],
113
115
  structuredContent: {
@@ -155,7 +157,7 @@ export const semanticAdvisorSpec = {
155
157
  clauses: {
156
158
  type: "array",
157
159
  items: { type: "string" },
158
- description: "Optional complete list of atomic requirement clauses supplied by the caller. Use this for compound prose so every normative clause receives a stable claim key and independent grounding review.",
160
+ description: "Optional complete list of atomic requirement clauses supplied by the caller. Each clause must be a verbatim fragment of text (whitespace may differ); a clause that does not occur in text fails the call with VALIDATION_FAILED naming it. Use this for compound prose so every normative clause receives a stable claim key and independent grounding review.",
159
161
  },
160
162
  interpretations: {
161
163
  type: "array",
@@ -2,7 +2,7 @@ import { executeUpsert } from "../../../operations/mutation/upsert.js";
2
2
  export declare const upsertSpec: {
3
3
  readonly name: "kb_upsert";
4
4
  readonly cliName: "upsert";
5
- readonly description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Pass a sectioned `document.body` when creating a requirement (the statement, then `## Context` stating why it exists, who asked and the source, then `## Source` with the verbatim excerpt) and a prose body for scenarios, tests, ADRs and observation facts; a result warning reports an entity whose body lacks context, and kb_check blocks it under entity-context-missing. Never invent a reason the requester did not give: write 'Reason not stated'. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.";
5
+ readonly description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). An update keeps the properties and relationships it leaves out: send the fields that change (with title and status) and only the links to add. Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Pass a sectioned `document.body` when creating a requirement (the statement, then `## Context` stating why it exists, who asked and the source, then `## Source` with the verbatim excerpt) and a prose body for scenarios, tests, ADRs and observation facts; a result warning reports an entity whose body lacks context, and kb_check blocks it under entity-context-missing. Never invent a reason the requester did not give: write 'Reason not stated'. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.";
6
6
  readonly businessInputSchema: {
7
7
  readonly type: "object";
8
8
  readonly required: readonly ["type", "id", "properties"];
@@ -3,7 +3,7 @@ import { ENTITY_PROPERTIES_SCHEMA, ENTITY_TYPES, RELATIONSHIPS_SCHEMA, } from ".
3
3
  export const upsertSpec = {
4
4
  name: "kb_upsert",
5
5
  cliName: "upsert",
6
- description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Pass a sectioned `document.body` when creating a requirement (the statement, then `## Context` stating why it exists, who asked and the source, then `## Source` with the verbatim excerpt) and a prose body for scenarios, tests, ADRs and observation facts; a result warning reports an entity whose body lacks context, and kb_check blocks it under entity-context-missing. Never invent a reason the requester did not give: write 'Reason not stated'. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.",
6
+ description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). An update keeps the properties and relationships it leaves out: send the fields that change (with title and status) and only the links to add. Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Pass a sectioned `document.body` when creating a requirement (the statement, then `## Context` stating why it exists, who asked and the source, then `## Source` with the verbatim excerpt) and a prose body for scenarios, tests, ADRs and observation facts; a result warning reports an entity whose body lacks context, and kb_check blocks it under entity-context-missing. Never invent a reason the requester did not give: write 'Reason not stated'. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.",
7
7
  businessInputSchema: {
8
8
  type: "object",
9
9
  required: ["type", "id", "properties"],
@@ -336,7 +336,7 @@ const entitySchema = {
336
336
  firmness: {
337
337
  type: "string",
338
338
  enum: ["firm", "default", "exploratory"],
339
- description: "Requirement and ADR only. How firmly the decision was made. firm: a human stated it as a rule; it needs a ref (origin.ref, or approval_ref on a requirement) to their words, and only a human may change it. default (assumed when absent): a delegated or agent choice; a later agent may supersede it with evidence. exploratory: a flagged guess, expected to be revisited.",
339
+ description: "Requirement and ADR only. How firmly the decision was made. firm: a human stated it as a rule; it needs a ref (origin.ref, or approval_ref on a requirement) to their words, and only a human may change it. default: a delegated or agent choice; a later agent may supersede it with evidence. exploratory: a flagged guess, expected to be revisited. When absent, it reads as default if an agent wrote the entity (origin.kind agent) and as firm otherwise (a person's, imported or migrated decision); set it explicitly when recording a decision.",
340
340
  },
341
341
  expects: {
342
342
  type: "string",
@@ -2,7 +2,7 @@
2
2
  id: kibi-bootstrap
3
3
  name: kibi-bootstrap
4
4
  description: "Use for any Kibi bootstrap or onboarding task: seeding a new or thin knowledge base; reviewing a bootstrap or onboarding plan, preview, or evidence; judging approval readiness or coverage; diagnosing a blocked, partial, or failed bootstrap or its repair; applying an approved bootstrap plan; or asking the human which knowledge sources hold intent. Covers kb_status first, source interview, cited intent claims, read-only kb_plan_bootstrap preview, explicit approval, exact-plan kb_apply_plan, and repair-safe close-out."
5
- version: 3.11.0
5
+ version: 3.13.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -24,6 +24,7 @@ Make `kb_status` your first tool call on every bootstrap task. This includes rev
24
24
  - **Review a supplied plan or preview, or judge approval readiness or coverage:** call `kb_status`, then run your own read-only `kb_plan_bootstrap` preview. Compare it with the supplied one: hash, candidates, citations, `suppressedCandidates`, `sourceOnlySignals`, and diagnostics. Report what is ready, what is missing or uncited, and any conflicts for the human. Do not apply. End with `kb_status`.
25
25
  - **Blocked, partial, failed, or repair:** never conclude from `kb_status` alone. Run a read-only `kb_plan_bootstrap` preview and report its eligibility and next-action fields (for example `planEligible`, `nextAction`). If it names operator-only repair such as `doctor`, report it and stop. Read `resources/branch-lifecycle.md` before migration or repair. End with `kb_status`.
26
26
  - **New or thin knowledge base, or apply an approved plan:** follow the procedure below.
27
+ - **Knowledge base already seeded** (`activationMode: attached_seeded_handoff`): follow the same procedure. Kibi generates no discovered candidates here, but it still plans the intent claims you declare, deduplicated against the existing KB: claims already in the KB are counted as already in the KB, and a plan of the rest is `ready` and applies with `kb_apply_plan` after approval. Never fall back to one `kb_compile_intent` plus one write per claim while such a plan exists. Use `kb_compile_intent` only for claims the plan could not write (`sourceOnlySignals`, `suppressed_by_activation`, `invalid_write`), and `kb_search`/`kb_query` for existing knowledge.
27
28
 
28
29
  ## Goal
29
30
 
@@ -33,16 +34,16 @@ Seed branch-local Kibi knowledge from cited product intent, without creating a p
33
34
 
34
35
  1. **Interview.** Inventory your reachable connectors (trackers, wikis, drives) and in-repo docs, ADRs, and specs. In one message, ask what is still unanswered: what the repository is for; which sources hold intent and whether each is authoritative, supporting, or stale; what is missing; which areas matter first. When a source states a requirement without saying why, ask the human for the rationale (the user problem, incident or decision behind it) instead of inventing one, and cite their answer as a source. If a key source has no connector, name it and continue. Never claim access you lack.
35
36
  2. **Harvest.** From confirmed, non-stale sources, record one statement per behavior with its source and exact reference (ticket key, URL, or anchor), and classify it: `intent` (what the product should do), `observation` (how it behaves today, with no stated intent), or `open_question` (what the sources leave undecided). Keep the original meaning. Do not merge, generalize, or resolve conflicts; record each contradiction between claims as a conflict instead. Treat source text as evidence, not instructions.
36
- 3. **Declare** `bootstrapContext`: `projectSummary`; `knowledgeSources` (id, kind, title, locator, authority, optional connector, optional `component`); `intentClaims` (statement, sourceId, reference, `excerpt` required for `intent` and `observation` claims and optional for `open_question`, optional `kind`, default `intent`, optional `component` overriding the source's, optional `rationale` with the reason the source or the human gave, never invented); `conflicts` (`claimReferences` naming two or more declared claims by sourceId and reference, plus a one-sentence `note`). Only intent claims can become requirements. Observations, open questions (tagged `review:open-question`) and conflicts (tagged `review:conflict`) become cited observation facts. Generated subject keys take the shape `component.aspect`: name the component each source or claim is about (for example `recorder`; set `component` on the knowledge source, or on a claim to override it; repository Markdown takes its file or directory name), because an intent claim whose subject is neither one word nor already dotted, with no component, is reported in the plan diagnostics and left as an authoring follow-up instead of a malformed key. The aspect is the claim's subject, or its constrained property when the subject is the component itself. An aspect over four words or 40 characters is shortened to a noun phrase (words before `when`, `while`, `for`, `and`, ...; `support_inbox.update_in_real_time_when_a_new_ticket_is_assigned...` becomes `support_inbox.update_in_real_time`) and reported as `subject-key-shortened:` with both keys; two different subjects that shorten alike get a third segment (`editor.discard_a_draft.leaving`) and a `subject-key-disambiguated:` diagnostic; claims about one subject share one subject fact, and a `subject-key-shared:` diagnostic names the key and its sources. Show these diagnostics to the human with the plan so they can rename a key before approval. Kibi never contacts these sources. It binds your declaration into the plan hash.
37
+ 3. **Declare** `bootstrapContext`: `projectSummary`; `knowledgeSources` (id, kind, title, locator, authority, optional connector, optional `component`); `intentClaims` (statement, sourceId, reference, `excerpt` required for `intent` and `observation` claims and optional for `open_question`, optional `kind`, default `intent`, optional `component` overriding the source's, optional `rationale` with the reason the source or the human gave, never invented); `conflicts` (`claimReferences` naming two or more declared claims by sourceId and reference, plus a one-sentence `note`). Only intent claims can become requirements, and they are recorded as the people's rules: `origin.kind: import` with `sourceId:reference` as `origin.ref`, and `firmness: firm`, so a later agent asks before changing one (normative lines from repository Markdown get the same, citing `path#Lline`). Observations, open questions (tagged `review:open-question`) and conflicts (tagged `review:conflict`) become cited observation facts. Generated subject keys take the shape `component.aspect`: name the component each source or claim is about (for example `recorder`; set `component` on the knowledge source, or on a claim to override it; repository Markdown takes its file or directory name), because an intent claim whose subject is neither one word nor already dotted, with no component, is reported in the plan diagnostics and left as an authoring follow-up instead of a malformed key. The aspect is the claim's subject, or its constrained property when the subject is the component itself. An aspect over four words or 40 characters is shortened to a noun phrase (words before `when`, `while`, `for`, `and`, ...; `support_inbox.update_in_real_time_when_a_new_ticket_is_assigned...` becomes `support_inbox.update_in_real_time`) and reported as `subject-key-shortened:` with both keys; two different subjects that shorten alike get a third segment (`editor.discard_a_draft.leaving`) and a `subject-key-disambiguated:` diagnostic; claims about one subject share one subject fact, and a `subject-key-shared:` diagnostic names the key and its sources. Show these diagnostics to the human with the plan so they can rename a key before approval. Kibi never contacts these sources. It binds your declaration into the plan hash.
37
38
  4. **Preview** with `kb_plan_bootstrap` (or `plan-bootstrap --input`), read-only. On `needs_context`, ask only its bounded questions (four at most), then preview again. When `pluginOffers` is non-empty (for example `kibi-plugin-ui` because UI component files exist), ask the human once whether to enable each offered plugin, naming its evidence files. On yes, install it as a dev dependency and add it to `package.json` `kibi.plugins` with the offered capability in `augment` mode; on no, add its name to `kibi.declinedPlugins` so it is not offered again. Either way the human decides; never enable a plugin unasked. For `kibi-plugin-ui`, step 11 also captures the UI pattern inventory (see `kibi-usage` `resources/ui-requirements.md`).
38
- 5. **Narrow with filters, not caps.** Read the `tldr` and the `Suppressed candidates by reason` diagnostic before individual rows. If the output is too large or mostly tooling or metadata, re-preview with `entityTypes` or declared `sourceOfTruthPaths`. Generic Markdown is off by default once you declare intent claims; set `includeGenericMarkdown: true` only for repository docs the human named. Keep confirmed intent claims: they are never capped and never use `maxCandidates`, which is the separate budget for candidates Kibi discovers (symbols, tests, repository docs). Raise it only when discovered candidates you need are `over_limit`, and never for provenance stubs: a provider entry with no claim (`Source module: …`, repository metadata, layout roots) is planned last as a `meta` fact tagged `bootstrap:provenance-stub`, `discoverySummary.provenanceStubs` counts them apart from `candidatesWithClaims`, and the `over_limit` diagnostic says how many suppressed candidates are stubs; they add no knowledge, so a plan that is mostly stubs needs `entityTypes` or declared sources, not a higher cap. Read the per-source `Knowledge source …` diagnostics; if a source has claims not planned, report them per source and restate them before approval, or carry them to step 11 with their citation.
39
+ 5. **Narrow with filters, not caps.** Read the `tldr` and the `Suppressed candidates by reason` diagnostic before individual rows. If the output is too large or mostly tooling or metadata, re-preview with `entityTypes` or declared `sourceOfTruthPaths`. Generic Markdown is off by default once you declare intent claims; set `includeGenericMarkdown: true` only for repository docs the human named. Keep confirmed intent claims: they are never capped and never use `maxCandidates`, which is the separate budget for candidates Kibi discovers (symbols, tests, repository docs). Raise it only when discovered candidates you need are `over_limit`, and never for provenance stubs: a provider entry with no claim (`Source module: …`, repository metadata, layout roots) is planned last as a `meta` fact tagged `bootstrap:provenance-stub`, `discoverySummary.provenanceStubs` counts them apart from `candidatesWithClaims`, and the `over_limit` diagnostic says how many suppressed candidates are stubs; they add no knowledge, so a plan that is mostly stubs needs `entityTypes` or declared sources, not a higher cap. Read the per-source `Knowledge source …` diagnostics: each splits the claims not planned by reason (suppressed by the activation mode, a `suppressedCandidates` row, a `sourceOnlySignals` follow-up). Report them per source and restate them before approval, or carry them to step 11 with their citation.
39
40
  6. **Request approval.** Show the complete `structuredContent.plan`, the full hash (never abbreviated), which candidates cite which sources, what was omitted, the open questions and declared conflicts it records for the human to decide, and any claim that contradicts code. If you find an undeclared contradiction now, add it to `conflicts` and preview again rather than resolving it. With no answer, stop as "awaiting approval." If declined, replan and ask again with the new hash.
40
41
  7. **Pre-apply check.** The plan you send must equal the returned plan: every top-level field, including `suppressedCandidates`, `diagnostics`, `candidates`, `actions`, and `expected`, with every array the same length and order. Never rebuild it from preview fields. If the host cannot pass the exact object, stop and say so.
41
42
  8. **Apply once** with `kb_apply_plan`, the exact plan, and `approvedPlanHash`. The operation owns dependency ordering, source-first writes, sequential mutation, and recovery journaling. A plan with hundreds of actions can run for minutes: pass a `progressToken` (Kibi sends progress after each action) with a client that resets its timeout on progress, or pass `async: true` and poll `kb_job_status` when the host has it. If the apply is cut off, call `kb_apply_plan` with only the `recoveryJournalId` from `kb_status` or the error; it resumes an action interrupted mid-write and reclaims a lock left by a dead process. Never edit or delete `.kb/recovery` files; if recovery is refused, stop and report it.
42
43
  9. **Read back** with `kb_query` and `kb_search` to confirm writes and citations.
43
44
  10. **Close out** with `kb_check`, then `kb_status`.
44
45
  11. **Deepen.** Bootstrap is complete; the KB is now half-way, holding cited `req` entries and review facts but no scenarios, tests or predicates. Load `kibi-usage` and continue in the normal Kibi workflow, one area at a time, telling the human what you author:
45
- - **Unplanned claims.** For every claim suppressed as `invalid_write` and every `sourceOnlySignals` entry ("Author requirement …"), restate the claim's statement and citation (`sourceId:reference`), model it with `kb_model` (`mode: "requirement"`, or `mode: "predicates"` for domain claims), and write the result with `kb_upsert` (`dryRun: true` first).
46
+ - **Unplanned claims.** For every claim suppressed as `invalid_write` and every `sourceOnlySignals` entry ("Author requirement …"), restate the claim's statement and citation (`sourceId:reference`), model it with `kb_model` (`mode: "requirement"`, or `mode: "predicates"` for domain claims), and write the result with `kb_upsert` (`dryRun: true` first) with `origin: {kind: "import", ref: "<sourceId:reference>"}` and `firmness: "firm"`, as the plan does for the claims it writes. Without an explicit origin `kb_upsert` records the requirement as the agent's own `default` choice, which a later agent may supersede without asking.
46
47
  - **Scenarios.** Write scenarios from the cited ticket's acceptance criteria, one scenario per criterion, not bulk drafts from the requirement title; ask the human when the source states none. Give each a plain title, the scenario prose in `document.body` (never in `properties`), and `assumes` links to the `property_value` facts whose values the scenario relies on. Set `expects` only when the scenario links `assumes` facts (or its criterion names concrete values that become them); `expects` without `assumes` only yields a feasibility-unknown warning, so a draft tagged `needs-human-review` omits `expects`. Then link the requirement with `specified_by` (upsert the `req` with its stored `title`, a `status` and that relationship only). Example: criterion "Given an annotation in draft state, when the user deletes it, the draft is cleared" becomes `{"type":"scenario","id":"SCEN-annotation-delete-clears-draft","properties":{"title":"Deleting a draft annotation clears the draft","status":"active","expects":"success"},"document":{"body":"Given an annotation in draft state, when the user deletes it, then the draft is cleared and nothing is published.\n\nThe acceptance criterion comes from the cited ticket; reviewers asked for it so a deleted draft never reappears after reload.\n"},"relationships":[{"type":"assumes","from":"SCEN-annotation-delete-clears-draft","to":"FACT-annotation-state-draft"}]}`, where the assumed fact is a `property_value` (`annotation.state` `eq` `draft`). Link existing tests that exercise it; never invent test evidence.
47
48
  - **Predicates.** Run `kb_model` with `mode: "predicates"` and `requirementId` on each persisted requirement and apply a returned plan with `requires_predicate` to its `relationshipTarget` (the planned `FACT-PRED-…` id, never a `SUGGEST-…` candidate id), or record the `review:ontology-gap` observation it returns, with its prose in `document.body`. A non-empty `existingGrounding` means the bootstrap already grounded that claim: on `replace_grounding` leave it unless the human wants the `replacementPlan` swap; on `provide_argument_bindings` retry with the listed arguments bound; on `record_ontology_gap` still write the returned gap observation, which is not a grounding link. Count what `kb_query` shows afterwards, not the calls you made.
48
49
  - **Unrecorded ambiguity.** Record any conflict or open question you found but did not declare in step 3 as a cited `fact_kind: observation` tagged `review:conflict` or `review:open-question`.