kibi-cli 2.21.0 → 2.22.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 (164) 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 +0 -1
  6. package/dist/commands/check.d.ts.map +1 -1
  7. package/dist/commands/check.js +47 -111
  8. package/dist/commands/doctor.d.ts.map +1 -1
  9. package/dist/commands/doctor.js +107 -5
  10. package/dist/commands/init-helpers.d.ts +14 -1
  11. package/dist/commands/init-helpers.d.ts.map +1 -1
  12. package/dist/commands/init-helpers.js +49 -10
  13. package/dist/commands/init.d.ts +1 -0
  14. package/dist/commands/init.d.ts.map +1 -1
  15. package/dist/commands/init.js +27 -4
  16. package/dist/commands/legacy-storage-migration.d.ts +46 -1
  17. package/dist/commands/legacy-storage-migration.d.ts.map +1 -1
  18. package/dist/commands/legacy-storage-migration.js +244 -9
  19. package/dist/commands/migrate.d.ts.map +1 -1
  20. package/dist/commands/migrate.js +150 -166
  21. package/dist/commands/sync/manifest.d.ts.map +1 -1
  22. package/dist/commands/sync/manifest.js +9 -0
  23. package/dist/commands/sync/persistence.d.ts.map +1 -1
  24. package/dist/commands/sync/persistence.js +4 -0
  25. package/dist/decision-firmness.d.ts +39 -0
  26. package/dist/decision-firmness.d.ts.map +1 -0
  27. package/dist/decision-firmness.js +115 -0
  28. package/dist/extractors/markdown.d.ts +2 -0
  29. package/dist/extractors/markdown.d.ts.map +1 -1
  30. package/dist/extractors/markdown.js +14 -0
  31. package/dist/extractors/symbols-coordinator.js +1 -0
  32. package/dist/intent-search.d.ts.map +1 -1
  33. package/dist/intent-search.js +28 -6
  34. package/dist/operations/migration/inventory-rederive.d.ts +40 -1
  35. package/dist/operations/migration/inventory-rederive.d.ts.map +1 -1
  36. package/dist/operations/migration/inventory-rederive.js +99 -8
  37. package/dist/operations/migration/requirement-status.d.ts +25 -0
  38. package/dist/operations/migration/requirement-status.d.ts.map +1 -0
  39. package/dist/operations/migration/requirement-status.js +105 -0
  40. package/dist/operations/migration/schema6.d.ts +27 -0
  41. package/dist/operations/migration/schema6.d.ts.map +1 -1
  42. package/dist/operations/migration/schema6.js +308 -7
  43. package/dist/operations/migration/supersedes-reason.d.ts +26 -0
  44. package/dist/operations/migration/supersedes-reason.d.ts.map +1 -0
  45. package/dist/operations/migration/supersedes-reason.js +69 -0
  46. package/dist/operations/migration/symbol-legacy-links.d.ts +51 -0
  47. package/dist/operations/migration/symbol-legacy-links.d.ts.map +1 -0
  48. package/dist/operations/migration/symbol-legacy-links.js +319 -0
  49. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  50. package/dist/operations/modeling/predicate-applyplan.js +10 -2
  51. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  52. package/dist/operations/modeling/predicate-loader.js +11 -0
  53. package/dist/operations/modeling/predicate-types.d.ts +32 -1
  54. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  55. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  56. package/dist/operations/modeling/suggest-predicates.js +175 -35
  57. package/dist/operations/mutation/context-warning.d.ts +12 -2
  58. package/dist/operations/mutation/context-warning.d.ts.map +1 -1
  59. package/dist/operations/mutation/context-warning.js +6 -6
  60. package/dist/operations/mutation/delete.d.ts +5 -1
  61. package/dist/operations/mutation/delete.d.ts.map +1 -1
  62. package/dist/operations/mutation/delete.js +223 -17
  63. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  64. package/dist/operations/mutation/serialization.js +1 -0
  65. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  66. package/dist/operations/mutation/source-authoring.js +130 -35
  67. package/dist/operations/mutation/types.d.ts +39 -1
  68. package/dist/operations/mutation/types.d.ts.map +1 -1
  69. package/dist/operations/mutation/upsert.d.ts +17 -2
  70. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  71. package/dist/operations/mutation/upsert.js +82 -13
  72. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  73. package/dist/operations/mutation/validate-upsert.js +40 -8
  74. package/dist/operations/planning/apply-plan.d.ts +6 -1
  75. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  76. package/dist/operations/planning/apply-plan.js +26 -5
  77. package/dist/public/impact/diagnostics.d.ts.map +1 -1
  78. package/dist/public/impact/diagnostics.js +24 -14
  79. package/dist/public/operations/catalog.d.ts +14 -5
  80. package/dist/public/operations/catalog.d.ts.map +1 -1
  81. package/dist/public/operations/check-executor.d.ts.map +1 -1
  82. package/dist/public/operations/check-executor.js +6 -0
  83. package/dist/public/operations/contracts.d.ts.map +1 -1
  84. package/dist/public/operations/contracts.js +35 -2
  85. package/dist/public/operations/decision-firmness.d.ts +34 -0
  86. package/dist/public/operations/decision-firmness.d.ts.map +1 -0
  87. package/dist/public/operations/decision-firmness.js +216 -0
  88. package/dist/public/operations/discovery-executors.d.ts +2 -0
  89. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  90. package/dist/public/operations/discovery-executors.js +25 -4
  91. package/dist/public/operations/migration-plan.d.ts +2 -0
  92. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  93. package/dist/public/operations/migration-plan.js +101 -16
  94. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  95. package/dist/public/operations/result-envelope.js +27 -1
  96. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  97. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  98. package/dist/public/operations/specs/check-rules.generated.js +6 -1
  99. package/dist/public/operations/specs/check.d.ts +1 -1
  100. package/dist/public/operations/specs/mutation-schemas.d.ts +5 -0
  101. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  102. package/dist/public/operations/specs/mutation-schemas.js +5 -0
  103. package/dist/public/operations/specs/mutation.d.ts +6 -2
  104. package/dist/public/operations/specs/mutation.d.ts.map +1 -1
  105. package/dist/public/operations/specs/mutation.js +6 -2
  106. package/dist/public/operations/specs/planning.d.ts +2 -2
  107. package/dist/public/operations/specs/planning.js +2 -2
  108. package/dist/public/operations/specs/upsert.d.ts +5 -0
  109. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  110. package/dist/public/operations/symbol-granularity-check.d.ts +18 -0
  111. package/dist/public/operations/symbol-granularity-check.d.ts.map +1 -0
  112. package/dist/public/operations/symbol-granularity-check.js +175 -0
  113. package/dist/public/schemas/entity.d.ts.map +1 -1
  114. package/dist/public/schemas/entity.js +11 -0
  115. package/dist/public/skills/kibi-traceability/SKILL.md +6 -4
  116. package/dist/public/skills/kibi-usage/SKILL.md +50 -10
  117. package/dist/public/skills/kibi-usage/resources/source-authoring.md +4 -2
  118. package/dist/public/symbol-granularity.d.ts +17 -0
  119. package/dist/public/symbol-granularity.d.ts.map +1 -1
  120. package/dist/public/symbol-granularity.js +21 -0
  121. package/dist/relationships/shards.d.ts +10 -0
  122. package/dist/relationships/shards.d.ts.map +1 -1
  123. package/dist/relationships/shards.js +27 -11
  124. package/dist/schemas/entity.schema.json +28 -0
  125. package/dist/search-answer.d.ts +31 -2
  126. package/dist/search-answer.d.ts.map +1 -1
  127. package/dist/search-answer.js +115 -17
  128. package/dist/traceability/evidence-model.d.ts +7 -3
  129. package/dist/traceability/evidence-model.d.ts.map +1 -1
  130. package/dist/traceability/staged-symbols-manifest.js +6 -5
  131. package/dist/traceability/validate.d.ts +14 -1
  132. package/dist/traceability/validate.d.ts.map +1 -1
  133. package/dist/traceability/validate.js +41 -0
  134. package/dist/types/entities.d.ts +4 -0
  135. package/dist/types/entities.d.ts.map +1 -1
  136. package/dist/utils/kb-manifest.d.ts +6 -0
  137. package/dist/utils/kb-manifest.d.ts.map +1 -1
  138. package/dist/utils/kb-manifest.js +6 -0
  139. package/dist/utils/rule-registry.generated.d.ts +26 -0
  140. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  141. package/dist/utils/rule-registry.generated.js +31 -0
  142. package/dist/utils/schema-version.d.ts +1 -1
  143. package/dist/utils/schema-version.d.ts.map +1 -1
  144. package/dist/utils/schema-version.js +3 -1
  145. package/package.json +3 -3
  146. package/schema/entities.pl +6 -0
  147. package/src/public/impact/diagnostics.ts +29 -17
  148. package/src/public/operations/check-executor.ts +13 -0
  149. package/src/public/operations/contracts.ts +39 -2
  150. package/src/public/operations/decision-firmness.ts +280 -0
  151. package/src/public/operations/discovery-executors.ts +29 -4
  152. package/src/public/operations/migration-plan.ts +100 -19
  153. package/src/public/operations/result-envelope.ts +34 -1
  154. package/src/public/operations/specs/check-rules.generated.ts +6 -1
  155. package/src/public/operations/specs/mutation-schemas.ts +6 -0
  156. package/src/public/operations/specs/mutation.ts +7 -2
  157. package/src/public/operations/specs/planning.ts +2 -2
  158. package/src/public/operations/symbol-granularity-check.ts +233 -0
  159. package/src/public/schemas/entity.ts +12 -0
  160. package/src/public/skills/kibi-traceability/SKILL.md +6 -4
  161. package/src/public/skills/kibi-usage/SKILL.md +50 -10
  162. package/src/public/skills/kibi-usage/resources/source-authoring.md +4 -2
  163. package/src/public/symbol-granularity.ts +37 -0
  164. package/src/schemas/entity.schema.json +28 -0
@@ -1,6 +1,6 @@
1
1
  import type { OperationContext } from "../../public/operations/runtime-types.js";
2
2
  import type { OperationResult } from "../../public/operations/types.js";
3
- import { analyzeSemanticAdvisorInput } from "../semantic-advisor/analyze-prose.js";
3
+ import type { SemanticAdvisorReceipt } from "../semantic-advisor/types.js";
4
4
  import { type StoredEntityLookup } from "./stored-entity.js";
5
5
  import type { RelationshipInput, StagedUpsertState, UpsertInput, UpsertPayload, ValidatedUpsert } from "./types.js";
6
6
  export declare function assertRelationshipShardContained(workspaceRoot: string, shardPath: string): void;
@@ -15,11 +15,26 @@ export type UpsertValidationOptions = Readonly<{
15
15
  */
16
16
  readonly staged?: StagedUpsertState;
17
17
  }>;
18
+ /** The semantic advisor result an upsert reports; no receipt for a non-requirement. */
19
+ export type UpsertSemanticAnalysis = Readonly<{
20
+ readonly receipt: SemanticAdvisorReceipt | null;
21
+ readonly warnings: readonly string[];
22
+ }>;
23
+ /**
24
+ * The semantic advisor analyses requirement prose: its propositions, claim
25
+ * keys and inventory contract describe a requirement. Any other entity has no
26
+ * prose inventory, so analysing its title (the fallback prose) would report
27
+ * claim keys nothing declares, for example a fact whose claim_key derives
28
+ * from claim_text. Its upsert carries no receipt.
29
+ */
30
+ export declare function analyzeUpsertSemantics(payload: UpsertInput & {
31
+ readonly relationships: readonly RelationshipInput[];
32
+ }): UpsertSemanticAnalysis;
18
33
  export type UpsertValidation = Readonly<{
19
34
  readonly validated: ValidatedUpsert;
20
35
  /** The upsert's relationships merged with the entity's existing ones. */
21
36
  readonly relationships: readonly RelationshipInput[];
22
- readonly semantic: ReturnType<typeof analyzeSemanticAdvisorInput>;
37
+ readonly semantic: UpsertSemanticAnalysis;
23
38
  }>;
24
39
  /**
25
40
  * The complete validation an upsert passes before its first write: schema,
@@ -1 +1 @@
1
- {"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAUxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AA8BnF,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,eAAe,EAChB,MAAM,YAAY,CAAC;AAgDpB,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,IAAI,CAkBN;AAwCD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,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AW,EAClB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CA2hBzC"}
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  import { OperationError } from "../../cli-errors.js";
5
+ import { DEFAULT_FIRMNESS, carriesFirmness, firmnessRef, isFirmness, } from "../../decision-firmness.js";
5
6
  import { readManifestWithCoordinateOverlay } from "../../extractors/manifest.js";
6
7
  import { extractManifestSymbolRecords } from "../../extractors/manifest.js";
7
8
  import { loadEntities } from "../../public/operations/discovery-entities.js";
@@ -47,6 +48,22 @@ function parseChangeKind(value) {
47
48
  ? normalized
48
49
  : null;
49
50
  }
51
+ /**
52
+ * The claim_key a written fact carries, derived from claim_text at
53
+ * validation when the payload did not supply it, echoed so the writer
54
+ * knows the grounding key without a kb_query.
55
+ */
56
+ // implements REQ-upsert-committed-claim-key
57
+ function storedClaimKey(entity) {
58
+ return entity.type === "fact" && typeof entity.claim_key === "string"
59
+ ? { claimKey: entity.claim_key }
60
+ : {};
61
+ }
62
+ // implements REQ-mcp-semantic-advisor-preflight
63
+ /** The written result's semantic advisor receipt, omitted for a non-requirement. */
64
+ function advisorReceipt(receipt) {
65
+ return receipt === null ? {} : { semanticAdvisor: receipt };
66
+ }
50
67
  function fileHash(pathname) {
51
68
  if (!existsSync(pathname))
52
69
  return null;
@@ -182,6 +199,21 @@ function reextractCanonicalSymbolEntity(symbolId, authoredRelativePath, workspac
182
199
  : { sourceFile: result.sourceFile }),
183
200
  };
184
201
  }
202
+ // implements REQ-mcp-semantic-advisor-preflight
203
+ /**
204
+ * The semantic advisor analyses requirement prose: its propositions, claim
205
+ * keys and inventory contract describe a requirement. Any other entity has no
206
+ * prose inventory, so analysing its title (the fallback prose) would report
207
+ * claim keys nothing declares, for example a fact whose claim_key derives
208
+ * from claim_text. Its upsert carries no receipt.
209
+ */
210
+ export function analyzeUpsertSemantics(payload) {
211
+ if (payload.type !== "req")
212
+ return { receipt: null, warnings: [] };
213
+ const semantic = analyzeSemanticAdvisorInput({ payload });
214
+ assertSemanticInventoryBoundary(payload, payload.relationships, semantic.receipt);
215
+ return semantic;
216
+ }
185
217
  // implements REQ-kibi-truthful-consistency
186
218
  /**
187
219
  * The complete validation an upsert passes before its first write: schema,
@@ -211,23 +243,58 @@ export async function validateUpsertForCommit(payload, context, options = {}) {
211
243
  await validateStrictLanePairing(prolog, validated.relationships, staged);
212
244
  await validateLiveRelationshipTargets(prolog, validated.entity, validated.relationships, staged);
213
245
  await validateSupersedesSourceHistory(prolog, validated.entity, validated.relationships, context.workspaceRoot, undefined, staged);
214
- const semantic = analyzeSemanticAdvisorInput({
215
- payload: { ...input, relationships },
216
- });
217
- assertSemanticInventoryBoundary({ ...input, relationships }, relationships, semantic.receipt);
246
+ const semantic = analyzeUpsertSemantics({ ...input, relationships });
218
247
  await assertLogicalGroundingClaimKeys(prolog, { ...input, relationships }, relationships, staged);
219
248
  await assertPredicateArgumentVocabulary(prolog, validated.entity, staged);
220
249
  // The origin the write records is added last: none of the checks above
221
250
  // reads it, and a rejected payload never pays for the stored-origin read.
222
251
  const recorded = await resolveUpsertOrigin(input, prolog, context.clock(), staged, lookup);
252
+ const decided = await resolveUpsertFirmness(recorded, staged, lookup);
223
253
  return {
224
- validated: recorded === input
254
+ validated: decided === input
225
255
  ? validated
226
- : validateUpsertInput(recorded, context.clock()),
256
+ : validateUpsertInput(decided, context.clock()),
227
257
  relationships,
228
258
  semantic,
229
259
  };
230
260
  }
261
+ /**
262
+ * The firmness a requirement or ADR write records. An update that omits
263
+ * `firmness` keeps the stored value, so the compiled entity matches the
264
+ * authored front matter. A decision left firm must name the human words it
265
+ * rests on, so an agent cannot promote its own choice: it is judged as it
266
+ * will be written, with the origin this write records and the stored
267
+ * `approval_ref` when the write omits one. kb_check enforces the same rule on
268
+ * authored sources.
269
+ */
270
+ // implements REQ-kb-decision-firmness
271
+ async function resolveUpsertFirmness(input, staged, lookup) {
272
+ if (!carriesFirmness(input.type))
273
+ return input;
274
+ const properties = input.properties;
275
+ if (properties.firmness !== undefined && properties.firmness !== "firm")
276
+ return input;
277
+ const stored = properties.firmness === undefined || properties.approval_ref === undefined
278
+ ? (staged?.entities.get(input.id) ?? (await lookup.entity()) ?? undefined)
279
+ : undefined;
280
+ const firmness = properties.firmness ?? stored?.firmness;
281
+ if (!isFirmness(firmness) || firmness === DEFAULT_FIRMNESS)
282
+ return input;
283
+ if (firmness === "firm" &&
284
+ firmnessRef({
285
+ type: input.type,
286
+ origin: properties.origin,
287
+ approval_ref: properties.approval_ref ?? stored?.approval_ref,
288
+ }) === undefined) {
289
+ throw new Error(`Entity validation failed: firmness: firm needs origin.ref${input.type === "req" ? " (or approval_ref)" : ""} pointing at the human words that state the rule; use firmness: default for a delegated or agent choice`);
290
+ }
291
+ return properties.firmness === firmness
292
+ ? input
293
+ : {
294
+ ...input,
295
+ properties: { ...input.properties, firmness },
296
+ };
297
+ }
231
298
  // implements REQ-kibi-operation-interface-parity
232
299
  /**
233
300
  * A dry run is the former kb_validate_upsert preflight on the kb_upsert
@@ -271,7 +338,7 @@ export async function executeUpsert(input, context, options = {}) {
271
338
  let commitEntity;
272
339
  let relationshipCount = 0;
273
340
  let changeKind = null;
274
- let semanticAdvisor;
341
+ let semanticAdvisor = null;
275
342
  let compilerLock;
276
343
  let sourceMutationLock;
277
344
  let operationFailure;
@@ -460,7 +527,8 @@ export async function executeUpsert(input, context, options = {}) {
460
527
  updated: 0,
461
528
  relationships_created: validated.relationships.length,
462
529
  warnings: [...planRecoveryWarnings, ...semantic.warnings],
463
- semanticAdvisor: semantic.receipt,
530
+ ...advisorReceipt(semantic.receipt),
531
+ ...storedClaimKey(commitEntity ?? validated.entity),
464
532
  deferredCommit,
465
533
  ...(sourceWrite ? { sourceWrites: [sourceWrite.receipt] } : {}),
466
534
  },
@@ -536,10 +604,11 @@ export async function executeUpsert(input, context, options = {}) {
536
604
  ...semantic.warnings,
537
605
  ...coverage,
538
606
  ...idStyleWarnings,
539
- ...entityContextWarnings(input, commitEntity ?? validated.entity, context.workspaceRoot, sourceWrite?.receipt.path),
607
+ ...entityContextWarnings(input, commitEntity ?? validated.entity, context.workspaceRoot, { writtenPath: sourceWrite?.receipt.path }),
540
608
  ...shardWarnings,
541
609
  ],
542
- semanticAdvisor: semantic.receipt,
610
+ ...advisorReceipt(semantic.receipt),
611
+ ...storedClaimKey(commitEntity ?? validated.entity),
543
612
  ...(shardWarnings.length > 0
544
613
  ? {
545
614
  status: "committed_with_repairs",
@@ -573,9 +642,9 @@ export async function executeUpsert(input, context, options = {}) {
573
642
  ? "skipped"
574
643
  : "no-conflict",
575
644
  checked_req_id: input.id,
576
- strict_readiness: semantic.receipt.logic_readiness === "modeled"
645
+ strict_readiness: semantic.receipt?.logic_readiness === "modeled"
577
646
  ? "modeled"
578
- : semantic.receipt.candidate_lane,
647
+ : (semantic.receipt?.candidate_lane ?? "none"),
579
648
  },
580
649
  }
581
650
  : {}),
@@ -610,7 +679,7 @@ export async function executeUpsert(input, context, options = {}) {
610
679
  updated: changeKind === "updated" ? 1 : 0,
611
680
  relationships_created: relationshipCount,
612
681
  warnings: [...planRecoveryWarnings, detail],
613
- semanticAdvisor: semanticAdvisor,
682
+ ...advisorReceipt(semanticAdvisor),
614
683
  status: "committed_with_repairs",
615
684
  effectFailures: [
616
685
  {
@@ -1 +1 @@
1
- {"version":3,"file":"validate-upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validate-upsert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAYxE,OAAO,KAAK,EAIV,WAAW,EACX,qBAAqB,EACtB,MAAM,YAAY,CAAC;AA2MpB;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAgHjD"}
1
+ {"version":3,"file":"validate-upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validate-upsert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAWxE,OAAO,KAAK,EAIV,WAAW,EACX,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAiPpB;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAkHjD"}
@@ -1,13 +1,13 @@
1
1
  // implements REQ-kibi-operation-interface-parity
2
2
  import { escapeAtom } from "../../prolog/codec.js";
3
+ import { loadEntities } from "../../public/operations/discovery-entities.js";
3
4
  import { entityIdStyleWarnings } from "../../utils/entity-id-style.js";
4
- import { analyzeSemanticAdvisorInput } from "../semantic-advisor/analyze-prose.js";
5
- import { assertSemanticInventoryBoundary } from "../semantic-advisor/ingestion-boundary.js";
6
5
  import { entityContextWarnings } from "./context-warning.js";
7
6
  import { buildUpsertContradictionPreviewGoal, buildWhatIfAnalysisGoal, formatUpsertError, } from "./contradictions.js";
8
7
  import { validateRelationshipSources } from "./relationships.js";
8
+ import { canonicalSourcePath } from "./source-authoring.js";
9
9
  import { validateSymbolGranularity } from "./symbol-granularity.js";
10
- import { validateAppendOnlyProofReceipts, validateUpsertForCommit, } from "./upsert.js";
10
+ import { analyzeUpsertSemantics, validateAppendOnlyProofReceipts, validateUpsertForCommit, } from "./upsert.js";
11
11
  import { validateUpsertInput } from "./validation.js";
12
12
  import { symbolCoverageWarnings } from "./warnings.js";
13
13
  import { isBlockingWitness, parseWhatIfAnalysis } from "./what-if.js";
@@ -16,6 +16,37 @@ async function entityExists(prolog, id) {
16
16
  const result = await prolog.query(`once(kb_entity('${escapeAtom(id)}', _Type, _Props))`);
17
17
  return result.success;
18
18
  }
19
+ // implements REQ-kibi-operation-interface-parity, REQ-kb-entity-body-context
20
+ /**
21
+ * The authored document a real kb_upsert would update, resolved with the
22
+ * write's own rules (stored authored source, else the canonical lane path).
23
+ * The preview entity's `source` is the runtime marker, so without this the
24
+ * context warning would judge the statement instead of the existing body the
25
+ * write preserves. Undefined when the write would not touch a document.
26
+ */
27
+ async function previewDocumentPath(input, entity, context) {
28
+ if (context.fs === undefined || context.sourceFirst === false) {
29
+ return undefined;
30
+ }
31
+ try {
32
+ const existing = context.prolog === undefined
33
+ ? undefined
34
+ : (await loadEntities(context.prolog, {
35
+ id: input.id,
36
+ type: input.type,
37
+ }))[0];
38
+ const existingSource = typeof existing?.source === "string" ? existing.source : undefined;
39
+ if (input.document === undefined &&
40
+ existing !== undefined &&
41
+ !existingSource?.match(/\.(?:md|mdx|ya?ml|json)$/i)) {
42
+ return undefined;
43
+ }
44
+ return canonicalSourcePath(context, input, entity, existing);
45
+ }
46
+ catch {
47
+ return undefined;
48
+ }
49
+ }
19
50
  // implements REQ-kibi-operation-interface-parity, REQ-kibi-truthful-consistency
20
51
  /**
21
52
  * The commit-time contradiction check, run against a staged and rolled-back
@@ -130,11 +161,10 @@ async function validateWithoutStore(input, context) {
130
161
  await validateAppendOnlyProofReceipts(validated.entity, context);
131
162
  validateRelationshipSources(input.id, validated.relationships);
132
163
  await validateSymbolGranularity(validated.entity, validated.relationships, context);
133
- const relationships = validated.relationships;
134
- const semantic = analyzeSemanticAdvisorInput({
135
- payload: { ...input, relationships },
164
+ const semantic = analyzeUpsertSemantics({
165
+ ...input,
166
+ relationships: validated.relationships,
136
167
  });
137
- assertSemanticInventoryBoundary({ ...input, relationships }, relationships, semantic.receipt);
138
168
  return { entity: validated.entity, semantic };
139
169
  }
140
170
  // implements REQ-kibi-operation-interface-parity, REQ-kibi-truthful-consistency
@@ -194,7 +224,9 @@ export async function executeValidateUpsert(input, context) {
194
224
  ...semantic.warnings,
195
225
  ...coverageWarnings,
196
226
  ...idStyleWarnings,
197
- ...entityContextWarnings(input, entity, context.workspaceRoot),
227
+ ...entityContextWarnings(input, entity, context.workspaceRoot, {
228
+ targetPath: await previewDocumentPath(input, entity, context),
229
+ }),
198
230
  ],
199
231
  semanticAdvisor: semantic.receipt,
200
232
  normalizedPreview: entity,
@@ -17,7 +17,12 @@ export declare function orderBootstrapActions(actions: readonly BootstrapAction[
17
17
  * The apply itself repeats every check under the workspace lock.
18
18
  */
19
19
  export declare function preflightApplyPlan(args: ApplyPlanArgs, context: OperationContext): Promise<void>;
20
- export declare function executeApplyPlan(args: ApplyPlanArgs, context: OperationContext): Promise<{
20
+ export declare function executeApplyPlan(args: ApplyPlanArgs, context: OperationContext,
21
+ /**
22
+ * Called once the plan's commit is authoritative, for a caller that holds
23
+ * the workspace lock and must classify a later failure as committed.
24
+ */
25
+ onCommitted?: () => void): Promise<{
21
26
  content: Array<{
22
27
  type: "text";
23
28
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"apply-plan.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/apply-plan.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAEV,gBAAgB,EAGjB,MAAM,0CAA0C,CAAC;AASlD,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,uBAAuB,CAAC;AAgE/B,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AA6G9E,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,IAAI,CAMN;AAED,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AAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,EACnE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B,IAAI,CAaN;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,SAAS,cAAoB,GAC5B,eAAe,EAAE,CA2CnB;AAi1BD;;;;;;GAMG;AAEH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAiCf;AAyqDD,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB;AACzB;;;GAGG;AACH,WAAW,GAAE,MAAM,IAAsB,GACxC,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,eAAe,CAAC;CACpC,CAAC,CAmDD"}
@@ -16,7 +16,7 @@ import { canonicalFilesystemPath } from "../../utils/canonical-path.js";
16
16
  import { isDerivedKbPath } from "../../utils/kb-paths.js";
17
17
  import { bootstrapEmptyKbSnapshotId, bootstrapPlanHash, } from "../bootstrap/types.js";
18
18
  import { validateBootstrapPayload } from "../bootstrap/validation.js";
19
- import { SCHEMA6_AUTOMATIC_CODES, applySchema6MigrationAction, } from "../migration/schema6.js";
19
+ import { SCHEMA6_APPROVABLE_REVIEW_CODES, SCHEMA6_AUTOMATIC_CODES, applySchema6MigrationAction, } from "../migration/schema6.js";
20
20
  import { buildUpsertBatchCommitGoal, formatUpsertError, } from "../mutation/contradictions.js";
21
21
  import { executeDelete } from "../mutation/delete.js";
22
22
  import { PLAN_APPLY_JOURNAL_VERSION, contentHash, createPlanApplyJournal, isPlanApplyJournalId, openPlanApplyJournal, openPlanApplyJournalById, planRecoveryNotes, publishJournaledFiles, reconcilePendingSourceReceipts, recordPlanApplyJournal, recoverPlanApplyJournal, restoreJournaledFiles, settlePendingPlanApplyJournals, storeFingerprint, withPlanRecoveryNotes, } from "../mutation/plan-apply-journal.js";
@@ -273,7 +273,8 @@ function validateMigrationPlanShape(args) {
273
273
  for (const action of actions) {
274
274
  if (action.state !== "ready")
275
275
  throw new Error(`Migration apply failed: action '${action.id}' is blocked`);
276
- if (action.safety !== "automatic" || action.autoApplicable !== true)
276
+ if (!(action.safety === "automatic" && action.autoApplicable === true) &&
277
+ !isApprovableReviewAction(action))
277
278
  throw new Error(`Migration apply failed: action '${action.id}' is not automatic`);
278
279
  for (const dependency of action.dependsOn) {
279
280
  if (!selected.has(dependency))
@@ -282,6 +283,19 @@ function validateMigrationPlanShape(args) {
282
283
  }
283
284
  return actions;
284
285
  }
286
+ /**
287
+ * A review action Kibi can execute once a person approves it by id. Callers
288
+ * pass the approved ids explicitly; `kibi migrate --apply-safe` without
289
+ * `--approved-action` selects only automatic actions, so these never run on
290
+ * their own.
291
+ */
292
+ // implements REQ-agent-guided-migration-orchestration, REQ-cli-schema-migration
293
+ function isApprovableReviewAction(action) {
294
+ return (action.safety === "review" &&
295
+ action.autoApplicable === false &&
296
+ action.invocation.kind === "cli" &&
297
+ SCHEMA6_APPROVABLE_REVIEW_CODES.has(action.code));
298
+ }
285
299
  function topologicalActions(actions) {
286
300
  const byId = new Map(actions.map((action) => [action.id, action]));
287
301
  const result = [];
@@ -2052,11 +2066,16 @@ async function recordBootstrapLockReclaims(context, journalPath, reclaimed) {
2052
2066
  }, null, 2)}\n`);
2053
2067
  }
2054
2068
  // implements REQ-agent-guided-migration-orchestration, REQ-cli-canonical-runtime, REQ-KIBI-BOOTSTRAP-PLAN, REQ-kibi-change-to-proof-plan-compiler-v2, REQ-kibi-predicate-vocabulary-migration
2055
- export async function executeApplyPlan(args, context) {
2069
+ export async function executeApplyPlan(args, context,
2070
+ /**
2071
+ * Called once the plan's commit is authoritative, for a caller that holds
2072
+ * the workspace lock and must classify a later failure as committed.
2073
+ */
2074
+ onCommitted = () => undefined) {
2056
2075
  if (isBootstrapApplyArgs(args))
2057
2076
  preflightBootstrapActions(validateBootstrapPlanShape(args), context);
2058
2077
  if (!context.fs || context.sourceMutationLockHeld === true)
2059
- return executeApplyPlanUnlocked(args, context);
2078
+ return executeApplyPlanUnlocked(args, context, onCommitted);
2060
2079
  const applyingJournal = await applyingBootstrapJournal(args, context);
2061
2080
  const lock = await acquireWorkspaceMutationLock(context.workspaceRoot, applyingJournal === undefined
2062
2081
  ? {}
@@ -2083,6 +2102,7 @@ export async function executeApplyPlan(args, context) {
2083
2102
  sourceMutationLockHeld: true,
2084
2103
  }, () => {
2085
2104
  committed = true;
2105
+ onCommitted();
2086
2106
  });
2087
2107
  committed = true;
2088
2108
  return result;
@@ -2348,7 +2368,8 @@ async function applyMigrationAction(action, context) {
2348
2368
  applyProofIntegrationAction(action, context.workspaceRoot);
2349
2369
  return;
2350
2370
  default:
2351
- if (SCHEMA6_AUTOMATIC_CODES.has(action.code)) {
2371
+ if (SCHEMA6_AUTOMATIC_CODES.has(action.code) ||
2372
+ SCHEMA6_APPROVABLE_REVIEW_CODES.has(action.code)) {
2352
2373
  await applySchema6MigrationAction(action, context);
2353
2374
  return;
2354
2375
  }
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/public/impact/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAYrF,OAAO,KAAK,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,YAAY,CAAC;AA6FpB,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mCAAmC,GAC3C,oBAAoB,EAAE,CA+CxB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,oBAAoB,EAAE,CAsBxB;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,SAAS,oBAAoB,EAAE,GAC3C,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,SAAS,iBAAiB,EAAE,GACxC,OAAO,CAIT"}
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/public/impact/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAarF,OAAO,KAAK,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,YAAY,CAAC;AAoFpB,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mCAAmC,GAC3C,oBAAoB,EAAE,CAmExB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,oBAAoB,EAAE,CAsBxB;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,SAAS,oBAAoB,EAAE,GAC3C,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,SAAS,iBAAiB,EAAE,GACxC,OAAO,CAIT"}
@@ -1,14 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import { extractSymbolsFromStagedFile, } from "../../traceability/symbol-extract.js";
4
- import { ALLOWED_GRANULARITY_REASONS_PROSE, getBehavioralSymbolNames, getNonBehavioralSymbolNames, isAllowedGranularityReason, isTraceabilityRelationshipType, } from "../symbol-granularity.js";
5
- function isNarrowerSymbol(manifestSymbolName, candidate, sourceSymbols) {
6
- if (candidate.name === manifestSymbolName)
7
- return false;
8
- if (candidate.name.startsWith(`${manifestSymbolName}.`))
9
- return true;
10
- return !sourceSymbols.some((symbol) => symbol.name === manifestSymbolName);
11
- }
4
+ import { ALLOWED_GRANULARITY_REASONS_PROSE, getBehavioralSymbolNames, getNonBehavioralSymbolNames, isAllowedGranularityReason, isTraceabilityRelationshipType, narrowerSymbols, } from "../symbol-granularity.js";
12
5
  function hasTraceabilityRelationship(result) {
13
6
  return result.relationships.some((relationship) => isTraceabilityRelationshipType(relationship.type));
14
7
  }
@@ -62,6 +55,7 @@ function isChangedBehavioralReviewCandidate(symbol) {
62
55
  return false;
63
56
  return symbol.hunkRanges.length > 0;
64
57
  }
58
+ // implements REQ-cli-staged-impact-enforcement, REQ-cli-check
65
59
  export function createSymbolGranularityDiagnostics(options) {
66
60
  const diagnostics = [];
67
61
  for (const result of options.manifestResults) {
@@ -76,25 +70,41 @@ export function createSymbolGranularityDiagnostics(options) {
76
70
  if (hasValidGranularityReason(result))
77
71
  continue;
78
72
  const { candidateSymbols, sourceSymbols } = getGranularSymbolsForSourceFile(result.sourceFile, options);
79
- const narrowerSymbols = candidateSymbols.filter((symbol) => isNarrowerSymbol(result.entity.title, symbol, sourceSymbols));
80
- if (narrowerSymbols.length === 0)
73
+ const narrower = narrowerSymbols(result.entity.title, candidateSymbols, sourceSymbols);
74
+ if (narrower.length === 0)
81
75
  continue;
82
- const behavioralNames = getBehavioralSymbolNames(narrowerSymbols);
76
+ const behavioralNames = getBehavioralSymbolNames(narrower);
83
77
  if (behavioralNames.length === 0)
84
78
  continue;
85
- const nonBehavioralNames = getNonBehavioralSymbolNames(narrowerSymbols);
79
+ const nonBehavioralNames = getNonBehavioralSymbolNames(narrower);
86
80
  const ignoredSymbolsSuggestion = nonBehavioralNames.length > 0
87
81
  ? ` Non-behavioral symbols ignored for this decision: ${nonBehavioralNames.join(", ")}.`
88
82
  : "";
83
+ // A title the extractor does not produce (a private class member, a
84
+ // renamed or removed declaration) can never become granular by refresh:
85
+ // say so instead of only calling the link coarse.
86
+ const titleExtracted = sourceSymbols.some((symbol) => symbol.name === result.entity.title);
89
87
  diagnostics.push({
90
88
  id: "symbol_granularity_violation",
91
89
  severity: "error",
92
90
  blocking: true,
93
91
  category: "symbol",
92
+ entityId: result.entity.id,
93
+ ...(result.entity.source ? { source: result.entity.source } : {}),
94
94
  files: [result.entity.source, result.sourceFile],
95
95
  docs: ["docs/symbol-traceability-taxonomy.md"],
96
- message: `Symbol ${result.entity.id} links ${result.sourceFile} coarsely while granular symbols are available (behavioral only): ${behavioralNames.join(", ")}`,
97
- suggestion: `Move ownership/coverage/test relationships to the narrow behavioral symbol, add a manifest behavioral anchor, or add granularity_reason with ${ALLOWED_GRANULARITY_REASONS_PROSE} when the coarse symbol is intentional.${ignoredSymbolsSuggestion}`,
96
+ message: titleExtracted
97
+ ? `Symbol ${result.entity.id} links ${result.sourceFile} coarsely while granular symbols are available (behavioral only): ${behavioralNames.join(", ")}`
98
+ : `Symbol ${result.entity.id} names '${result.entity.title}', which the source extractor does not produce for ${result.sourceFile} (private class members and removed or renamed declarations are not tracked), so it links ${result.sourceFile} coarsely while granular symbols are available (behavioral only): ${behavioralNames.join(", ")}`,
99
+ suggestion: titleExtracted
100
+ ? `Move ownership/coverage/test relationships to the narrow behavioral symbol, add a manifest behavioral anchor, or add granularity_reason with ${ALLOWED_GRANULARITY_REASONS_PROSE} when the coarse symbol is intentional.${ignoredSymbolsSuggestion}`
101
+ : `Re-point this symbol's relationships to the public declaration that owns the behavior (one of: ${behavioralNames.join(", ")}) or remove the symbol; add granularity_reason with ${ALLOWED_GRANULARITY_REASONS_PROSE} only when coarse ownership is intentional.${ignoredSymbolsSuggestion}`,
102
+ evidence: {
103
+ sourceFile: result.sourceFile,
104
+ title: result.entity.title,
105
+ titleExtracted,
106
+ granularSymbols: behavioralNames,
107
+ },
98
108
  });
99
109
  }
100
110
  return diagnostics;
@@ -1117,6 +1117,11 @@ export declare const OPERATION_CATALOG: readonly [{
1117
1117
  readonly minLength: 1;
1118
1118
  readonly description: "Requirement-only. Optional reference to the exception's approval decision record.";
1119
1119
  };
1120
+ readonly firmness: {
1121
+ readonly type: "string";
1122
+ readonly enum: readonly ["firm", "default", "exploratory"];
1123
+ readonly description: "req/adr only. firm = a human stated it as a rule (needs origin.ref to their words); default (when absent) = delegated or agent choice; exploratory = flagged guess.";
1124
+ };
1120
1125
  readonly rationale: {
1121
1126
  readonly type: "string";
1122
1127
  readonly minLength: 1;
@@ -1755,7 +1760,7 @@ export declare const OPERATION_CATALOG: readonly [{
1755
1760
  }, {
1756
1761
  readonly name: "kb_delete";
1757
1762
  readonly cliName: "delete";
1758
- readonly description: "Delete entities by ID. Use only for intentional removals after dependency checks. Do not use as a bulk cleanup shortcut. Side effects: mutates and saves KB; skips entities with dependents.";
1763
+ readonly description: "Delete entities by ID, or exact relationship triples. Use only for intentional removals after dependency checks. Do not use as a bulk cleanup shortcut. An entity authored in a Markdown or YAML source is not deleted directly: the call writes nothing and returns outcome plan_returned with a hash-bound deletionPlan and a nextActions entry holding the exact kb_apply_plan input ({plan, approvedPlanHash}); apply that unmodified, or repeat this call with approvedPlanHash = deletionPlan.planHash to apply the freshly computed plan in one step (a stale or different hash fails with DELETE_PLAN_HASH_MISMATCH and writes nothing). Authored requirements are never deleted: outcome supersession_required points to kb_upsert with a supersedes relationship. dryRun:true previews any delete and writes nothing. Side effects: mutates and saves KB and authored sources; skips entities with dependents; dryRun and plan_returned write nothing.";
1759
1764
  readonly businessInputSchema: {
1760
1765
  readonly type: "object";
1761
1766
  readonly oneOf: readonly [{
@@ -1805,7 +1810,11 @@ export declare const OPERATION_CATALOG: readonly [{
1805
1810
  readonly approvedPlanHash: {
1806
1811
  readonly type: "string";
1807
1812
  readonly pattern: "^[a-fA-F0-9]{64}$";
1808
- readonly description: "Exact hash returned by a prior authored-entity deletion plan.";
1813
+ readonly description: "With ids only: the deletionPlan.planHash a prior call for the same ids returned. The plan is recomputed and applied through kb_apply_plan when its hash still matches; a mismatch fails with DELETE_PLAN_HASH_MISMATCH and writes nothing. Not allowed with relationships or dryRun.";
1814
+ };
1815
+ readonly dryRun: {
1816
+ readonly type: "boolean";
1817
+ readonly description: "Preview without writing. Relationship and direct entity deletes run their preflight and return outcome dry_run with wouldDelete counts, the sourceWrites (paths and hashes) a commit would make, and skippedEffects. Authored ids return the same deletion plan as without dryRun.";
1809
1818
  };
1810
1819
  };
1811
1820
  };
@@ -1825,7 +1834,7 @@ export declare const OPERATION_CATALOG: readonly [{
1825
1834
  readonly type: "string";
1826
1835
  readonly enum: readonly string[];
1827
1836
  };
1828
- readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
1837
+ readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, symbol-granularity, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, decision-firm-unreferenced, decision-firm-superseded, supersedes-reason-missing, supersedes-reason-acknowledged, policy-ownership, policy-markers. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
1829
1838
  };
1830
1839
  readonly sourceFiles: {
1831
1840
  readonly type: "array";
@@ -2198,7 +2207,7 @@ export declare const OPERATION_CATALOG: readonly [{
2198
2207
  readonly plan: {
2199
2208
  readonly type: "object";
2200
2209
  readonly required: readonly ["version", "planHash"];
2201
- readonly description: "The complete kibi.bootstrap-plan.v1, kibi.compile-plan.v1, kibi.migration-plan.v2, or hash-bound kibi.entity-deletion-plan.v1 object. Migration plans require approvedActionIds and reject blocked/non-automatic actions.";
2210
+ readonly description: "The complete kibi.bootstrap-plan.v1, kibi.compile-plan.v1, kibi.migration-plan.v2, or hash-bound kibi.entity-deletion-plan.v1 object. Migration plans require approvedActionIds and reject blocked actions and review actions Kibi cannot execute.";
2202
2211
  };
2203
2212
  readonly approvedActionIds: {
2204
2213
  readonly type: "array";
@@ -2206,7 +2215,7 @@ export declare const OPERATION_CATALOG: readonly [{
2206
2215
  readonly type: "string";
2207
2216
  readonly minLength: 1;
2208
2217
  };
2209
- readonly description: "Required for migration-plan.v2. Exact automatic action IDs explicitly approved for this application.";
2218
+ readonly description: "Required for migration-plan.v2. Exact action IDs explicitly approved for this application: automatic actions, or review actions with a cli invocation that Kibi executes only when approved by id (for example semantic_inventory_rederive_drop_grounding).";
2210
2219
  };
2211
2220
  readonly recoveryJournalId: {
2212
2221
  readonly type: "string";
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/public/operations/catalog.ts"],"names":[],"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StructuredContent, buildSummary, } from "./check-format-shared.js";
6
6
  import { analyzeKbCheckImpact, collectQueryPlanSafetyViolations, getEffectiveRules, partitionCheckFindings, qualityDiagnosticsFromImpact, resolveCheckRules, stagedEntityIdStyleDiagnostics, } from "./check-helpers.js";
7
7
  import { collectCheckPolicyViolations } from "./check-policy-rules.js";
8
+ import { collectDecisionFirmnessViolations } from "./decision-firmness.js";
8
9
  import { executeStatus } from "./discovery-executors.js";
9
10
  import { collectEntityContextViolations } from "./entity-context.js";
10
11
  import { buildActionsFromCheck, buildMigrationPlan, mergeMigrationPlans, } from "./migration-plan.js";
@@ -12,6 +13,7 @@ import { collectOriginReviewViolations } from "./origin-review.js";
12
13
  import { collectPredicateSchemaConformanceViolations } from "./predicate-schema-conformance.js";
13
14
  import { SOURCE_PATH_DANGLING_RULE, collectSourcePathDanglingViolations, } from "./source-path-dangling.js";
14
15
  import { collectSourceRelationshipParityViolations } from "./source-relationship-parity.js";
16
+ import { collectSymbolGranularityViolations } from "./symbol-granularity-check.js";
15
17
  import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
16
18
  export { buildStructuredContent, buildSummary, getEffectiveRules, resolveCheckRules, };
17
19
  // implements REQ-search-answer-hygiene
@@ -235,17 +237,21 @@ export async function executeCheck(args, context, options = {}) {
235
237
  const sourcePathFindings = rulesAllowlist.has(SOURCE_PATH_DANGLING_RULE)
236
238
  ? collectSourcePathDanglingViolations(workspaceRoot)
237
239
  : [];
240
+ const symbolGranularityFindings = await collectSymbolGranularityViolations(prolog, workspaceRoot, rulesAllowlist);
238
241
  const originReviewFindings = await collectOriginReviewViolations(prolog, rulesAllowlist, workspaceRoot);
239
242
  const entityContextFindings = collectEntityContextViolations(rulesAllowlist, workspaceRoot);
243
+ const decisionFirmnessFindings = collectDecisionFirmnessViolations(rulesAllowlist, workspaceRoot);
240
244
  const checkPolicyFindings = await collectCheckPolicyViolations(prolog, rulesAllowlist, workspaceRoot);
241
245
  const partitioned = partitionCheckFindings([
242
246
  ...aggregatedFindings,
243
247
  ...queryPlanViolations,
244
248
  ...sourceRelationshipParityViolations,
245
249
  ...sourcePathFindings,
250
+ ...symbolGranularityFindings,
246
251
  ...predicateConformanceFindings,
247
252
  ...originReviewFindings,
248
253
  ...entityContextFindings,
254
+ ...decisionFirmnessFindings,
249
255
  ...checkPolicyFindings,
250
256
  ]);
251
257
  const violations = partitioned.violations;
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/public/operations/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAsZpE;;uEAEuE;AACvE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAMrB;AA+XD,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAC3C,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAa3C,CAAC;AAmDF,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAClD,YAAY,EAAE,MAAM,GACnB,IAAI,CAIN;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,SAAS,0BAA0B,EAAE,CAoBvC"}
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/public/operations/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM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