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 +1 @@
1
- {"version":3,"file":"result-envelope.d.ts","sourceRoot":"","sources":["../../../src/public/operations/result-envelope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E,eAAO,MAAM,qBAAqB,EAAG,CAAU,CAAC;AAoChD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAS/B;AAoFD,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;IACtC,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;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,GACd,uBAAuB,CAYzB;AAaD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC3C,IAAI,CAKN"}
@@ -14,6 +14,29 @@ function diagnostics(value) {
14
14
  return [entry];
15
15
  });
16
16
  }
17
+ // Discovery operations whose empty answer may come from an uncompiled store.
18
+ const STORE_READ_OPERATIONS = new Set(["kb_search", "kb_query"]);
19
+ /**
20
+ * A search or query answered from a branch store that was never compiled
21
+ * reads an empty KB. The payload already names the store state; the envelope
22
+ * also raises it as a warning, so a caller that reads only `status` and
23
+ * `diagnostics` does not take the empty answer as "nothing governs this".
24
+ */
25
+ // implements REQ-cli-status-pre-first-sync, REQ-mcp-search-discovery
26
+ function uncompiledStoreDiagnostics(operation, row) {
27
+ const store = row?.branchStore;
28
+ if (!STORE_READ_OPERATIONS.has(operation) ||
29
+ !record(store) ||
30
+ store.state !== "not_compiled")
31
+ return [];
32
+ return [
33
+ {
34
+ ...(typeof store.code === "string" ? { code: store.code } : {}),
35
+ severity: "warning",
36
+ message: `${typeof store.detail === "string" ? `${store.detail} ` : ""}An empty answer here does not mean no requirement governs this; run \`kibi sync\` and ask again.`,
37
+ },
38
+ ];
39
+ }
17
40
  function nextActions(value) {
18
41
  if (!Array.isArray(value))
19
42
  return [];
@@ -152,7 +175,10 @@ export function toKibiResult(spec, data, options = {}) {
152
175
  ...spec.effects.map((effect) => effectStatus(effect, row, outcome)),
153
176
  ...extraFailedEffects(spec.effects, row),
154
177
  ],
155
- diagnostics: options.diagnostics ?? diagnostics(row?.diagnostics),
178
+ diagnostics: options.diagnostics ?? [
179
+ ...diagnostics(row?.diagnostics),
180
+ ...uncompiledStoreDiagnostics(String(spec.name), row),
181
+ ],
156
182
  nextActions: options.nextActions ?? nextActions(row?.nextActions),
157
183
  ...(resultError ? { error: resultError } : {}),
158
184
  };
@@ -1,5 +1,5 @@
1
1
  /** Every selectable kb_check rule name, registry order. */
2
2
  export declare const SELECTABLE_RULE_NAMES: readonly string[];
3
3
  /** Comma-separated "Allowed:" fragment for the kb_check rules description. */
4
- export declare const SELECTABLE_RULES_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";
4
+ export declare const SELECTABLE_RULES_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";
5
5
  //# sourceMappingURL=check-rules.generated.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-rules.generated.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/check-rules.generated.ts"],"names":[],"mappings":"AAUA,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAgDlD,CAAC;AAGF,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,2hCACq/B,CAAC"}
1
+ {"version":3,"file":"check-rules.generated.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/check-rules.generated.ts"],"names":[],"mappings":"AAUA,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAqDlD,CAAC;AAGF,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,gqCAC0nC,CAAC"}
@@ -12,6 +12,7 @@ export const SELECTABLE_RULE_NAMES = [
12
12
  "must-priority-coverage",
13
13
  "symbol-coverage",
14
14
  "symbol-traceability",
15
+ "symbol-granularity",
15
16
  "no-dangling-refs",
16
17
  "source-relationship-parity",
17
18
  "branch-store-not-compiled",
@@ -54,9 +55,13 @@ export const SELECTABLE_RULE_NAMES = [
54
55
  "predicate-schema-conformance",
55
56
  "entity-context-missing",
56
57
  "entity-context-acknowledged",
58
+ "decision-firm-unreferenced",
59
+ "decision-firm-superseded",
60
+ "supersedes-reason-missing",
61
+ "supersedes-reason-acknowledged",
57
62
  "policy-ownership",
58
63
  "policy-markers",
59
64
  ];
60
65
  // implements REQ-006
61
66
  /** Comma-separated "Allowed:" fragment for the kb_check rules description. */
62
- export const SELECTABLE_RULES_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";
67
+ export const SELECTABLE_RULES_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";
@@ -12,7 +12,7 @@ export declare const checkSpec: {
12
12
  readonly type: "string";
13
13
  readonly enum: readonly string[];
14
14
  };
15
- 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.";
15
+ 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.";
16
16
  };
17
17
  readonly sourceFiles: {
18
18
  readonly type: "array";
@@ -118,6 +118,11 @@ export declare const ENTITY_PROPERTIES_SCHEMA: {
118
118
  readonly minLength: 1;
119
119
  readonly description: "Requirement-only. Optional reference to the exception's approval decision record.";
120
120
  };
121
+ readonly firmness: {
122
+ readonly type: "string";
123
+ readonly enum: readonly ["firm", "default", "exploratory"];
124
+ 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.";
125
+ };
121
126
  readonly rationale: {
122
127
  readonly type: "string";
123
128
  readonly minLength: 1;
@@ -1 +1 @@
1
- {"version":3,"file":"mutation-schemas.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/mutation-schemas.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,gFASf,CAAC;AAWX,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;CA8CvB,CAAC"}
@@ -102,6 +102,11 @@ export const ENTITY_PROPERTIES_SCHEMA = {
102
102
  minLength: 1,
103
103
  description: "Requirement-only. Optional reference to the exception's approval decision record.",
104
104
  },
105
+ firmness: {
106
+ type: "string",
107
+ enum: ["firm", "default", "exploratory"],
108
+ 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.",
109
+ },
105
110
  rationale: {
106
111
  type: "string",
107
112
  minLength: 1,
@@ -35,7 +35,7 @@ export declare const validateUpsertSpec: {
35
35
  export declare const deleteSpec: {
36
36
  readonly name: "kb_delete";
37
37
  readonly cliName: "delete";
38
- 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.";
38
+ 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.";
39
39
  readonly businessInputSchema: {
40
40
  readonly type: "object";
41
41
  readonly oneOf: readonly [{
@@ -85,7 +85,11 @@ export declare const deleteSpec: {
85
85
  readonly approvedPlanHash: {
86
86
  readonly type: "string";
87
87
  readonly pattern: "^[a-fA-F0-9]{64}$";
88
- readonly description: "Exact hash returned by a prior authored-entity deletion plan.";
88
+ 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.";
89
+ };
90
+ readonly dryRun: {
91
+ readonly type: "boolean";
92
+ 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.";
89
93
  };
90
94
  };
91
95
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mutation.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAOvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAIxF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBuC,CAAC;AAEvE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CuC,CAAC"}
1
+ {"version":3,"file":"mutation.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAOvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAIxF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBuC,CAAC;AAEvE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDuC,CAAC"}
@@ -26,7 +26,7 @@ export const validateUpsertSpec = {
26
26
  export const deleteSpec = {
27
27
  name: "kb_delete",
28
28
  cliName: "delete",
29
- 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.",
29
+ 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.",
30
30
  businessInputSchema: {
31
31
  type: "object",
32
32
  oneOf: [
@@ -58,7 +58,11 @@ export const deleteSpec = {
58
58
  approvedPlanHash: {
59
59
  type: "string",
60
60
  pattern: "^[a-fA-F0-9]{64}$",
61
- description: "Exact hash returned by a prior authored-entity deletion plan.",
61
+ 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.",
62
+ },
63
+ dryRun: {
64
+ type: "boolean",
65
+ 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.",
62
66
  },
63
67
  },
64
68
  },
@@ -270,7 +270,7 @@ export declare const applyPlanSpec: {
270
270
  readonly plan: {
271
271
  readonly type: "object";
272
272
  readonly required: readonly ["version", "planHash"];
273
- 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.";
273
+ 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.";
274
274
  };
275
275
  readonly approvedActionIds: {
276
276
  readonly type: "array";
@@ -278,7 +278,7 @@ export declare const applyPlanSpec: {
278
278
  readonly type: "string";
279
279
  readonly minLength: 1;
280
280
  };
281
- readonly description: "Required for migration-plan.v2. Exact automatic action IDs explicitly approved for this application.";
281
+ 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).";
282
282
  };
283
283
  readonly recoveryJournalId: {
284
284
  readonly type: "string";
@@ -188,12 +188,12 @@ export const applyPlanSpec = {
188
188
  plan: {
189
189
  type: "object",
190
190
  required: ["version", "planHash"],
191
- 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.",
191
+ 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.",
192
192
  },
193
193
  approvedActionIds: {
194
194
  type: "array",
195
195
  items: { type: "string", minLength: 1 },
196
- description: "Required for migration-plan.v2. Exact automatic action IDs explicitly approved for this application.",
196
+ 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).",
197
197
  },
198
198
  recoveryJournalId: {
199
199
  type: "string",
@@ -135,6 +135,11 @@ export declare const upsertSpec: {
135
135
  readonly minLength: 1;
136
136
  readonly description: "Requirement-only. Optional reference to the exception's approval decision record.";
137
137
  };
138
+ readonly firmness: {
139
+ readonly type: "string";
140
+ readonly enum: readonly ["firm", "default", "exploratory"];
141
+ 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.";
142
+ };
138
143
  readonly rationale: {
139
144
  readonly type: "string";
140
145
  readonly minLength: 1;
@@ -1 +1 @@
1
- {"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/upsert.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAQvE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DuC,CAAC"}
1
+ {"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/upsert.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAQvE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DuC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Violation } from "../../utils/rule-registry.js";
2
+ import type { PrologPort } from "./runtime-types.js";
3
+ /**
4
+ * Full-check form of the staged gate's `symbol_granularity_violation`: a
5
+ * symbol with traceability relationships must not link its source file
6
+ * coarsely while narrower behavioral symbols are available, unless it carries
7
+ * an allowed granularity_reason.
8
+ */
9
+ export declare const SYMBOL_GRANULARITY_RULE = "symbol-granularity";
10
+ /**
11
+ * `symbol-granularity`: the staged gate's granularity predicate, evaluated
12
+ * for every symbol against its whole working-tree file, every declaration a
13
+ * candidate as if the file were fully staged. Only files of symbols the gate
14
+ * would judge are analyzed; a file the source analyzers cannot fully analyze
15
+ * is skipped.
16
+ */
17
+ export declare function collectSymbolGranularityViolations(prolog: Pick<PrologPort, "query">, workspaceRoot: string, rules: ReadonlySet<string>): Promise<Violation[]>;
18
+ //# sourceMappingURL=symbol-granularity-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbol-granularity-check.d.ts","sourceRoot":"","sources":["../../../src/public/operations/symbol-granularity-check.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAQ9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;GAKG;AAEH,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AA+J5D;;;;;;GAMG;AAEH,wBAAsB,kCAAkC,CACtD,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EACjC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GACzB,OAAO,CAAC,SAAS,EAAE,CAAC,CAYtB"}
@@ -0,0 +1,175 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { readFileSync, statSync } from "node:fs";
19
+ import * as path from "node:path";
20
+ import { createMaintenanceSourceAnalysisService } from "../../plugins/maintenance-source-analysis.js";
21
+ import { normalizeEntityId, parseEntityFromList, parseListOfLists, parseTriples, } from "../../prolog/codec.js";
22
+ import { extractSymbolsFromStagedFileAsync, } from "../../traceability/symbol-extract.js";
23
+ import { createSymbolGranularityDiagnostics } from "../impact/diagnostics.js";
24
+ import { createImpactManifestLookup } from "../impact/manifest.js";
25
+ import { normalizeSourceFile } from "../impact/source-changes.js";
26
+ import { isAllowedGranularityReason, isTraceabilityRelationshipType, } from "../symbol-granularity.js";
27
+ /**
28
+ * Full-check form of the staged gate's `symbol_granularity_violation`: a
29
+ * symbol with traceability relationships must not link its source file
30
+ * coarsely while narrower behavioral symbols are available, unless it carries
31
+ * an allowed granularity_reason.
32
+ */
33
+ // implements REQ-cli-check, REQ-cli-staged-impact-enforcement
34
+ export const SYMBOL_GRANULARITY_RULE = "symbol-granularity";
35
+ const SYMBOL_ROWS_QUERY = "findall([Id,symbol,Fields], (kb_entity(Id, symbol, Props), include([Key=_]>>memberchk(Key, [title,status,source,sourceFile,granularity_reason]), Props, Fields)), Rows)";
36
+ const SYMBOL_RELATIONSHIPS_QUERY = "findall([From,To,Type], (member(Type, [implements,covered_by,executable_for]), kb_relationship(Type, From, To), kb_entity(From, symbol, _)), Rels)";
37
+ function stringField(entity, key) {
38
+ const value = entity[key];
39
+ return typeof value === "string" && value.length > 0 ? value : undefined;
40
+ }
41
+ // implements REQ-cli-check
42
+ async function loadSymbolResults(prolog, workspaceRoot) {
43
+ const rows = await prolog.query(SYMBOL_ROWS_QUERY);
44
+ if (!rows.success) {
45
+ throw new Error(`symbol-granularity symbol projection failed: ${rows.error ?? "unknown error"}`);
46
+ }
47
+ const rels = await prolog.query(SYMBOL_RELATIONSHIPS_QUERY);
48
+ if (!rels.success) {
49
+ throw new Error(`symbol-granularity relationship projection failed: ${rels.error ?? "unknown error"}`);
50
+ }
51
+ const relationships = new Map();
52
+ for (const [rawFrom, rawTo, type] of parseTriples(rels.bindings.Rels ?? "[]")) {
53
+ const from = normalizeEntityId(rawFrom);
54
+ const current = relationships.get(from) ?? [];
55
+ current.push({ from, to: normalizeEntityId(rawTo), type });
56
+ relationships.set(from, current);
57
+ }
58
+ const results = [];
59
+ for (const row of parseListOfLists(rows.bindings.Rows ?? "[]")) {
60
+ const entity = parseEntityFromList(row);
61
+ const id = stringField(entity, "id");
62
+ const sourceFile = stringField(entity, "sourceFile");
63
+ if (id === undefined || sourceFile === undefined)
64
+ continue;
65
+ const granularityReason = stringField(entity, "granularity_reason");
66
+ results.push({
67
+ entity: {
68
+ id,
69
+ type: "symbol",
70
+ title: stringField(entity, "title") ?? "",
71
+ status: stringField(entity, "status") ?? "",
72
+ created_at: "",
73
+ updated_at: "",
74
+ source: stringField(entity, "source") ?? "",
75
+ ...(granularityReason !== undefined
76
+ ? { granularity_reason: granularityReason }
77
+ : {}),
78
+ },
79
+ relationships: relationships.get(id) ?? [],
80
+ sourceFile: normalizeSourceFile(workspaceRoot, sourceFile),
81
+ });
82
+ }
83
+ return results;
84
+ }
85
+ /**
86
+ * The symbols the staged gate would judge: they carry a traceability
87
+ * relationship and no allowed granularity_reason. Other symbols are exempt,
88
+ * so their source files need no analysis.
89
+ */
90
+ // implements REQ-cli-check
91
+ function granularityCandidates(results) {
92
+ return results.filter((result) => result.relationships.some((relationship) => isTraceabilityRelationshipType(relationship.type)) && !isAllowedGranularityReason(result.entity.granularity_reason));
93
+ }
94
+ function readRegularFile(absolutePath) {
95
+ try {
96
+ if (!statSync(absolutePath).isFile())
97
+ return null;
98
+ return readFileSync(absolutePath, "utf8");
99
+ }
100
+ catch {
101
+ return null;
102
+ }
103
+ }
104
+ // implements REQ-cli-check
105
+ async function analyzeFiles(files, results, workspaceRoot) {
106
+ const manifestLookup = createImpactManifestLookup(results);
107
+ const service = createMaintenanceSourceAnalysisService(workspaceRoot);
108
+ const analyses = new Map();
109
+ for (const file of files) {
110
+ const content = readRegularFile(path.resolve(workspaceRoot, file));
111
+ if (content === null)
112
+ continue;
113
+ try {
114
+ const analysis = await service.analyzeTextV2(file, content);
115
+ // Only a complete parser-backed analysis decides; the staged gate
116
+ // reports an incomplete one itself when the file is touched.
117
+ if (analysis.status !== "ok")
118
+ continue;
119
+ const symbols = await extractSymbolsFromStagedFileAsync({
120
+ path: file,
121
+ status: "M",
122
+ content,
123
+ hunkRanges: [{ start: 1, end: Number.MAX_SAFE_INTEGER }],
124
+ }, manifestLookup, { analyzeText: async () => analysis });
125
+ analyses.set(file, symbols);
126
+ }
127
+ catch {
128
+ // An analysis failure cannot decide anything for this file.
129
+ }
130
+ }
131
+ return analyses;
132
+ }
133
+ // implements REQ-cli-check
134
+ function granularityViolations(candidates, sourceSymbolsByFile, workspaceRoot) {
135
+ return createSymbolGranularityDiagnostics({
136
+ manifestResults: candidates.filter((result) => result.sourceFile !== undefined &&
137
+ sourceSymbolsByFile.has(result.sourceFile)),
138
+ symbolsByFile: new Map(),
139
+ sourceSymbolsByFile,
140
+ workspaceRoot,
141
+ }).map((diagnostic) => ({
142
+ rule: SYMBOL_GRANULARITY_RULE,
143
+ entityId: diagnostic.entityId ?? "",
144
+ description: diagnostic.message,
145
+ suggestion: diagnostic.suggestion,
146
+ ...(diagnostic.source !== undefined ? { source: diagnostic.source } : {}),
147
+ evidence: {
148
+ diagnosticId: diagnostic.id,
149
+ ...(diagnostic.evidence ?? {}),
150
+ },
151
+ }));
152
+ }
153
+ /**
154
+ * `symbol-granularity`: the staged gate's granularity predicate, evaluated
155
+ * for every symbol against its whole working-tree file, every declaration a
156
+ * candidate as if the file were fully staged. Only files of symbols the gate
157
+ * would judge are analyzed; a file the source analyzers cannot fully analyze
158
+ * is skipped.
159
+ */
160
+ // implements REQ-cli-check, REQ-cli-staged-impact-enforcement
161
+ export async function collectSymbolGranularityViolations(prolog, workspaceRoot, rules) {
162
+ if (!rules.has(SYMBOL_GRANULARITY_RULE))
163
+ return [];
164
+ const results = await loadSymbolResults(prolog, workspaceRoot);
165
+ const candidates = granularityCandidates(results);
166
+ const files = [
167
+ ...new Set(candidates.map((result) => result.sourceFile ?? "")),
168
+ ]
169
+ .filter((file) => file.length > 0)
170
+ .sort();
171
+ if (files.length === 0)
172
+ return [];
173
+ const analyses = await analyzeFiles(files, results, workspaceRoot);
174
+ return granularityViolations(candidates, analyses, workspaceRoot);
175
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/public/schemas/entity.ts"],"names":[],"mappings":"AAwTA,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA4ZzC,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/public/schemas/entity.ts"],"names":[],"mappings":"AAwTA,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAwazC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -333,6 +333,11 @@ const entitySchema = {
333
333
  text_ref: { type: "string" },
334
334
  // Provenance of any authored entity: who wrote it and on what authority.
335
335
  origin: ENTITY_ORIGIN_SCHEMA,
336
+ firmness: {
337
+ type: "string",
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.",
340
+ },
336
341
  expects: {
337
342
  type: "string",
338
343
  enum: ["success", "rejection", "error"],
@@ -680,6 +685,12 @@ const entitySchema = {
680
685
  },
681
686
  },
682
687
  },
688
+ {
689
+ if: {
690
+ properties: { type: { enum: ["req", "adr"] } },
691
+ },
692
+ else: { not: { required: ["firmness"] } },
693
+ },
683
694
  {
684
695
  if: {
685
696
  properties: { type: { const: "scenario" } },
@@ -43,10 +43,12 @@ sequential `kb_upsert`, then run final check and coverage. Kibi authors tracked
43
43
  files transactionally but never Git-stages or commits them. Do not read or edit
44
44
  `.kb` directly.
45
45
 
46
- Use `kb_delete` only for intentional cleanup. Authored entity deletion returns a
47
- hash-bound approval plan; requirements normally evolve through a new
48
- requirement linked with `supersedes`. Relationship deletes patch shards while
49
- preserving unrelated records.
46
+ Use `kb_delete` only for intentional cleanup; `dryRun: true` previews any
47
+ delete without writing. Authored entity deletion returns `outcome:
48
+ plan_returned` with a hash-bound plan whose `nextActions[0].input` is the exact
49
+ `kb_apply_plan` input; requirements return `supersession_required` and evolve
50
+ through a new requirement linked with `supersedes`. Relationship deletes patch
51
+ shards while preserving unrelated records.
50
52
 
51
53
  ## Typed recovery and proof
52
54
 
@@ -2,7 +2,7 @@
2
2
  id: kibi-usage
3
3
  name: Kibi Usage
4
4
  description: Use Kibi's source-first, exact-Git, migration-aware, proof-aware operations safely across MCP or the trusted local CLI, including partial completion repair.
5
- version: 2.15.3
5
+ version: 2.16.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -188,8 +188,9 @@ returns `status: error`, `MIGRATION_PLAN_REFUSED` and `data.outcome:
188
188
  refused`: nothing changed, so read the action `detail` and get a new plan.
189
189
  `data.outcome: reconciliation_required` (status success) means an action
190
190
  failed mid-way: inspect its effect before retrying. `kb_delete` of an
191
- authored entity returns status success with `deleted: 0`; its `errors` say
192
- why nothing was deleted. If the status is
191
+ authored entity returns status success with `deleted: 0` and `outcome:
192
+ plan_returned` (or `supersession_required` for a requirement): nothing was
193
+ deleted yet, and `nextActions` names the call that does it. If the status is
193
194
  `committed_with_repairs`, the mutation already committed: inspect failed effects,
194
195
  execute each required repair action in order, and never retry the original
195
196
  operation. Record effect failures, followed actions, and unsafe retries in
@@ -302,12 +303,18 @@ authored. Each one is the order the write path accepts.
302
303
  between the two writes `kb_check` reports the requirement until the
303
304
  second lands.
304
305
  3. **Deleting authored entities.** `kb_delete` on an authored entity that
305
- is not a requirement (scenario, test, fact, ADR, …) returns a hash-bound
306
- `kibi.entity-deletion-plan.v1` in `deletionPlan`; apply it unchanged with
307
- `kb_apply_plan` (`plan` plus `approvedPlanHash: plan.planHash`). For an
308
- authored requirement the plan carries `supersessionRequired: true` and
309
- `kb_apply_plan` refuses it (`REQUIREMENT_SUPERSESSION_REQUIRED`): Kibi
310
- never deletes an authored requirement. Evolve it instead with a new
306
+ is not a requirement (scenario, test, fact, ADR, …) writes nothing and
307
+ returns `outcome: plan_returned` with a hash-bound
308
+ `kibi.entity-deletion-plan.v1` in `deletionPlan`. After review, run
309
+ `nextActions[0]` unchanged: `kb_apply_plan` with its `input` (`plan` plus
310
+ `approvedPlanHash: plan.planHash`), or repeat the `kb_delete` call with
311
+ `approvedPlanHash` to apply the freshly computed plan in one step (a
312
+ changed source fails with `DELETE_PLAN_HASH_MISMATCH`). `dryRun: true`
313
+ previews relationship and direct deletes without writing. For an
314
+ authored requirement the result is `outcome: supersession_required`, the
315
+ plan carries `supersessionRequired: true` and both routes refuse it
316
+ (`REQUIREMENT_SUPERSESSION_REQUIRED`): Kibi never deletes an authored
317
+ requirement. Evolve it instead with a new
311
318
  requirement linked by `supersedes` and close the old one, or, for an
312
319
  agent-origin requirement nobody approved and nothing links to, upsert it
313
320
  with `status: closed` (keep its `title`); it stays on disk as history. A
@@ -342,6 +349,29 @@ human sets `approved_by`; `kb_check` flags approvals an agent recorded without
342
349
  corroboration. Never fill in an approval yourself. Record why a requirement
343
350
  exists in `rationale`, or link the ADR that explains it.
344
351
 
352
+ ## Decision firmness
353
+
354
+ Requirements and ADRs carry `firmness`, which says what you may do with them.
355
+ Search answers, `kb_query` rows and hook snippets show it (snippets label only
356
+ `[firm]` and `[exploratory]`; an unlabeled decision is `default`).
357
+
358
+ - `firm`: a human stated it as a rule. Follow it; to change it, ask first.
359
+ `kb_check` blocks a firm decision without `origin.ref` to their words, and
360
+ a replacement of a firm decision that is not itself firm.
361
+ - `default` (when absent): a delegated or agent choice. Follow it unless the
362
+ task gives evidence against it; then supersede it in the same change and
363
+ list it under "Decisions I changed" for review, without asking first.
364
+ - `exploratory`: a flagged guess; revisit it when you touch the area.
365
+
366
+ Set `firmness` from what a human actually said: only their stated rule is
367
+ `firm` (with `origin.ref`); "do whatever" or your own pick is `default`; a
368
+ guess is `exploratory`. A supersede needs `## Why this changed` in the new
369
+ entity's body (at least 12 words): name the evidence (a failing test, a
370
+ measured cost, a constraint the old decision missed, a new requirement) and
371
+ answer the old decision's reasoning; `kb_check` blocks it otherwise. A
372
+ preference is not evidence: propose it instead of superseding. Kibi checks
373
+ only that a firm decision has a reference; never cite words nobody said.
374
+
345
375
  Conditional clauses ("only when", "only if", "must not ... unless") compile
346
376
  into typed `forbid` rules linked by `requires_rule`, not property facts; one
347
377
  `kb_model` or `kb_compile_intent` cannot translate stays an `ontology_gap`.
@@ -421,7 +451,17 @@ a second grounding link would fail, so keep the existing link or apply the
421
451
  `kb_delete` of the old link, requirement link; between the last two `kb_check`
422
452
  reports both `logic-coverage` and `strict-req-fact-pairing` for the
423
453
  requirement, as `expected.kbCheckAfterStep` states; run `kb_check` after the
424
- last step and apply `rollback` if it is not clean); `provide_argument_bindings` and `record_ontology_gap` mean
454
+ last step and apply `rollback` if it is not clean). `keep_existing_grounding`
455
+ means the requirement already links a predicate fact with the candidate's
456
+ `canonical_key` (`existingGrounding[].matchedBy` is `canonical_key` when the
457
+ claim was worded differently), so write nothing. `extend_requirement` means
458
+ the requirement's proposition ledger has no entry for this text, so a link
459
+ cannot be made and no fact is planned: add the clause to the requirement's
460
+ prose (`mode: "requirement"`, or `kb_upsert` with the extended `semantic_text`
461
+ and the ledger `mode: "analyze"` returns) and call `mode: "predicates"` again.
462
+ Read `decisionConflicts` and its warnings whenever `plan` is null: they name
463
+ the stored decision facts the candidate would contradict and the requirements
464
+ that own them. `provide_argument_bindings` and `record_ontology_gap` mean
425
465
  the same as for an ungrounded claim, and the gap observation is not a grounding
426
466
  link, so write it exactly as returned (tags, `claim_text`, `document.body`, no
427
467
  `claim_key`, no relationships). Record an ontology gap only when no returned schema fits the
@@ -23,8 +23,10 @@ drift diagnostic. Unresolved Git index conflicts are likewise blocking; Kibi
23
23
  never chooses a merge winner.
24
24
 
25
25
  Relationship upserts and relationship deletes patch only the canonical shard,
26
- preserving unrelated records. Authored entity deletion returns a hash-bound
27
- plan; approve that plan through `kb_apply_plan`. Evolve requirements with a new
26
+ preserving unrelated records. Authored entity deletion writes nothing and
27
+ returns a hash-bound plan (`outcome: plan_returned`); approve it by running the
28
+ returned `nextActions[0]` (`kb_apply_plan` with `{plan, approvedPlanHash}`)
29
+ unchanged, or by repeating `kb_delete` with `approvedPlanHash`. Evolve requirements with a new
28
30
  requirement and `supersedes`, rather than deleting the old semantic claim.
29
31
 
30
32
  On `committed_with_repairs`, inspect `effects` and execute the typed required