kibi-cli 2.21.2 → 2.22.1

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 (113) hide show
  1. package/dist/cli-register-foundation.d.ts.map +1 -1
  2. package/dist/cli-register-foundation.js +1 -0
  3. package/dist/commands/check.d.ts +0 -1
  4. package/dist/commands/check.d.ts.map +1 -1
  5. package/dist/commands/check.js +47 -111
  6. package/dist/commands/doctor.d.ts.map +1 -1
  7. package/dist/commands/doctor.js +108 -6
  8. package/dist/commands/init-helpers.d.ts +16 -2
  9. package/dist/commands/init-helpers.d.ts.map +1 -1
  10. package/dist/commands/init-helpers.js +52 -10
  11. package/dist/commands/init.d.ts +1 -0
  12. package/dist/commands/init.d.ts.map +1 -1
  13. package/dist/commands/init.js +12 -1
  14. package/dist/commands/legacy-storage-migration.d.ts +46 -1
  15. package/dist/commands/legacy-storage-migration.d.ts.map +1 -1
  16. package/dist/commands/legacy-storage-migration.js +219 -9
  17. package/dist/commands/migrate.d.ts +37 -0
  18. package/dist/commands/migrate.d.ts.map +1 -1
  19. package/dist/commands/migrate.js +72 -188
  20. package/dist/commands/sync/manifest.d.ts.map +1 -1
  21. package/dist/commands/sync/manifest.js +9 -0
  22. package/dist/extractors/symbols-coordinator.js +1 -0
  23. package/dist/intent-search.d.ts.map +1 -1
  24. package/dist/intent-search.js +28 -6
  25. package/dist/operations/migration/inventory-rederive.d.ts +40 -1
  26. package/dist/operations/migration/inventory-rederive.d.ts.map +1 -1
  27. package/dist/operations/migration/inventory-rederive.js +99 -8
  28. package/dist/operations/migration/requirement-status.d.ts +25 -0
  29. package/dist/operations/migration/requirement-status.d.ts.map +1 -0
  30. package/dist/operations/migration/requirement-status.js +105 -0
  31. package/dist/operations/migration/schema6.d.ts +25 -0
  32. package/dist/operations/migration/schema6.d.ts.map +1 -1
  33. package/dist/operations/migration/schema6.js +265 -7
  34. package/dist/operations/migration/symbol-legacy-links.d.ts +51 -0
  35. package/dist/operations/migration/symbol-legacy-links.d.ts.map +1 -0
  36. package/dist/operations/migration/symbol-legacy-links.js +319 -0
  37. package/dist/operations/mutation/context-warning.d.ts +12 -2
  38. package/dist/operations/mutation/context-warning.d.ts.map +1 -1
  39. package/dist/operations/mutation/context-warning.js +6 -6
  40. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  41. package/dist/operations/mutation/source-authoring.js +130 -35
  42. package/dist/operations/mutation/types.d.ts +2 -1
  43. package/dist/operations/mutation/types.d.ts.map +1 -1
  44. package/dist/operations/mutation/upsert.d.ts +17 -2
  45. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  46. package/dist/operations/mutation/upsert.js +28 -11
  47. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  48. package/dist/operations/mutation/validate-upsert.js +40 -8
  49. package/dist/operations/mutation/validation.d.ts.map +1 -1
  50. package/dist/operations/mutation/validation.js +43 -1
  51. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  52. package/dist/operations/planning/apply-plan.js +34 -10
  53. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
  54. package/dist/operations/semantic-advisor/ingestion-boundary.js +25 -1
  55. package/dist/operations/semantic-advisor/stored-ledger-drift.d.ts +19 -0
  56. package/dist/operations/semantic-advisor/stored-ledger-drift.d.ts.map +1 -0
  57. package/dist/operations/semantic-advisor/stored-ledger-drift.js +78 -0
  58. package/dist/public/impact/diagnostics.d.ts.map +1 -1
  59. package/dist/public/impact/diagnostics.js +24 -14
  60. package/dist/public/operations/catalog.d.ts +3 -3
  61. package/dist/public/operations/check-executor.d.ts.map +1 -1
  62. package/dist/public/operations/check-executor.js +3 -0
  63. package/dist/public/operations/contracts.d.ts.map +1 -1
  64. package/dist/public/operations/contracts.js +6 -1
  65. package/dist/public/operations/decision-firmness.d.ts +3 -1
  66. package/dist/public/operations/decision-firmness.d.ts.map +1 -1
  67. package/dist/public/operations/decision-firmness.js +13 -3
  68. package/dist/public/operations/discovery-executors.d.ts +2 -0
  69. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  70. package/dist/public/operations/discovery-executors.js +24 -2
  71. package/dist/public/operations/migration-plan.d.ts +15 -0
  72. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  73. package/dist/public/operations/migration-plan.js +130 -17
  74. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  75. package/dist/public/operations/result-envelope.js +27 -1
  76. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  77. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  78. package/dist/public/operations/specs/check-rules.generated.js +2 -1
  79. package/dist/public/operations/specs/check.d.ts +1 -1
  80. package/dist/public/operations/specs/planning.d.ts +2 -2
  81. package/dist/public/operations/specs/planning.js +2 -2
  82. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  83. package/dist/public/operations/specs/semantic.js +26 -1
  84. package/dist/public/operations/symbol-granularity-check.d.ts +18 -0
  85. package/dist/public/operations/symbol-granularity-check.d.ts.map +1 -0
  86. package/dist/public/operations/symbol-granularity-check.js +175 -0
  87. package/dist/public/skills/kibi-usage/SKILL.md +8 -3
  88. package/dist/public/symbol-granularity.d.ts +17 -0
  89. package/dist/public/symbol-granularity.d.ts.map +1 -1
  90. package/dist/public/symbol-granularity.js +21 -0
  91. package/dist/traceability/evidence-model.d.ts +7 -3
  92. package/dist/traceability/evidence-model.d.ts.map +1 -1
  93. package/dist/traceability/staged-symbols-manifest.js +6 -5
  94. package/dist/traceability/validate.d.ts +14 -1
  95. package/dist/traceability/validate.d.ts.map +1 -1
  96. package/dist/traceability/validate.js +41 -0
  97. package/dist/utils/rule-registry.generated.d.ts +5 -0
  98. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  99. package/dist/utils/rule-registry.generated.js +6 -0
  100. package/package.json +3 -3
  101. package/src/public/impact/diagnostics.ts +29 -17
  102. package/src/public/operations/check-executor.ts +7 -0
  103. package/src/public/operations/contracts.ts +6 -1
  104. package/src/public/operations/decision-firmness.ts +18 -2
  105. package/src/public/operations/discovery-executors.ts +28 -2
  106. package/src/public/operations/migration-plan.ts +147 -20
  107. package/src/public/operations/result-envelope.ts +34 -1
  108. package/src/public/operations/specs/check-rules.generated.ts +2 -1
  109. package/src/public/operations/specs/planning.ts +2 -2
  110. package/src/public/operations/specs/semantic.ts +37 -2
  111. package/src/public/operations/symbol-granularity-check.ts +233 -0
  112. package/src/public/skills/kibi-usage/SKILL.md +8 -3
  113. package/src/public/symbol-granularity.ts +37 -0
@@ -1834,7 +1834,7 @@ export declare const OPERATION_CATALOG: readonly [{
1834
1834
  readonly type: "string";
1835
1835
  readonly enum: readonly string[];
1836
1836
  };
1837
- 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, 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.";
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.";
1838
1838
  };
1839
1839
  readonly sourceFiles: {
1840
1840
  readonly type: "array";
@@ -2207,7 +2207,7 @@ export declare const OPERATION_CATALOG: readonly [{
2207
2207
  readonly plan: {
2208
2208
  readonly type: "object";
2209
2209
  readonly required: readonly ["version", "planHash"];
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/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.";
2211
2211
  };
2212
2212
  readonly approvedActionIds: {
2213
2213
  readonly type: "array";
@@ -2215,7 +2215,7 @@ export declare const OPERATION_CATALOG: readonly [{
2215
2215
  readonly type: "string";
2216
2216
  readonly minLength: 1;
2217
2217
  };
2218
- 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).";
2219
2219
  };
2220
2220
  readonly recoveryJournalId: {
2221
2221
  readonly type: "string";
@@ -1 +1 @@
1
- {"version":3,"file":"check-executor.d.ts","sourceRoot":"","sources":["../../../src/public/operations/check-executor.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,iBAAiB,EAGjB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAY5B,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AAMvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,CAAC;AAC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CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,CAAC;AACxE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,6CAA6C,CAAC,EAAE,OAAO,CAAC;IACjE;;;;;;OAMG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAoFF;;;;;GAKG;AAEH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,MAAM,GACpB,SAAS,GAAG,IAAI,CAgClB;AAGD,wBAAsB,YAAY,CAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAqPxC"}
@@ -13,6 +13,7 @@ import { collectOriginReviewViolations } from "./origin-review.js";
13
13
  import { collectPredicateSchemaConformanceViolations } from "./predicate-schema-conformance.js";
14
14
  import { SOURCE_PATH_DANGLING_RULE, collectSourcePathDanglingViolations, } from "./source-path-dangling.js";
15
15
  import { collectSourceRelationshipParityViolations } from "./source-relationship-parity.js";
16
+ import { collectSymbolGranularityViolations } from "./symbol-granularity-check.js";
16
17
  import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
17
18
  export { buildStructuredContent, buildSummary, getEffectiveRules, resolveCheckRules, };
18
19
  // implements REQ-search-answer-hygiene
@@ -236,6 +237,7 @@ export async function executeCheck(args, context, options = {}) {
236
237
  const sourcePathFindings = rulesAllowlist.has(SOURCE_PATH_DANGLING_RULE)
237
238
  ? collectSourcePathDanglingViolations(workspaceRoot)
238
239
  : [];
240
+ const symbolGranularityFindings = await collectSymbolGranularityViolations(prolog, workspaceRoot, rulesAllowlist);
239
241
  const originReviewFindings = await collectOriginReviewViolations(prolog, rulesAllowlist, workspaceRoot);
240
242
  const entityContextFindings = collectEntityContextViolations(rulesAllowlist, workspaceRoot);
241
243
  const decisionFirmnessFindings = collectDecisionFirmnessViolations(rulesAllowlist, workspaceRoot);
@@ -245,6 +247,7 @@ export async function executeCheck(args, context, options = {}) {
245
247
  ...queryPlanViolations,
246
248
  ...sourceRelationshipParityViolations,
247
249
  ...sourcePathFindings,
250
+ ...symbolGranularityFindings,
248
251
  ...predicateConformanceFindings,
249
252
  ...originReviewFindings,
250
253
  ...entityContextFindings,
@@ -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+ZD,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,EAAE,OAAO,CAAC,CAAC,CAAC;AAsZpE;;uEAEuE;AACvE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAMrB;AAoaD,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"}
@@ -345,7 +345,12 @@ const BASE_DATA_SCHEMAS = {
345
345
  sourceType: stringValue,
346
346
  }),
347
347
  kb_skills_read: objectData({ content: stringValue }, ["content"]),
348
- kb_query: objectData({ entities: recordArray, count: integerValue, factQuery: recordValue }, ["entities", "count"]),
348
+ kb_query: objectData({
349
+ entities: recordArray,
350
+ count: integerValue,
351
+ factQuery: recordValue,
352
+ branchStore: recordValue,
353
+ }, ["entities", "count"]),
349
354
  kb_search: objectData({
350
355
  results: valueArray,
351
356
  count: integerValue,
@@ -28,7 +28,9 @@ export declare function unexplainedSupersedes(entities: readonly AuthoredEntity[
28
28
  /** The supersede edges of an entity, as the manifest acknowledges them. */
29
29
  export declare function supersedeAcknowledgements(id: string, edges: ReadonlyMap<string, Set<string>>): string[];
30
30
  /** Evaluate the firmness rules over authored requirements and ADRs. */
31
- export declare function evaluateDecisionFirmness(entities: readonly AuthoredEntity[], edges: ReadonlyMap<string, Set<string>>, rules?: ReadonlySet<string>, acknowledged?: ReadonlySet<string>): Violation[];
31
+ export declare function evaluateDecisionFirmness(entities: readonly AuthoredEntity[], edges: ReadonlyMap<string, Set<string>>, rules?: ReadonlySet<string>, acknowledged?: ReadonlySet<string>, options?: Readonly<{
32
+ schemaVersion?: number | null;
33
+ }>): Violation[];
32
34
  /** Read the authored decisions once and evaluate the selected rules. */
33
35
  export declare function collectDecisionFirmnessViolations(rules: ReadonlySet<string>, workspaceRoot: string): Violation[];
34
36
  //# sourceMappingURL=decision-firmness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decision-firmness.d.ts","sourceRoot":"","sources":["../../../src/public/operations/decision-firmness.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,qBAAqB,CAAC;AAE7B,wEAAwE;AAExE,eAAO,MAAM,+BAA+B,+BAA+B,CAAC;AAC5E,qEAAqE;AAErE,eAAO,MAAM,6BAA6B,6BAA6B,CAAC;AACxE,oEAAoE;AAEpE,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAC1E,6EAA6E;AAE7E,eAAO,MAAM,mCAAmC,mCACd,CAAC;AAGnC,eAAO,MAAM,uBAAuB,oIAK1B,CAAC;AAIX,0CAA0C;AAE1C,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,EAAE,CAS5E;AAED;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CA+B1B;AASD;;;;;GAKG;AAEH,wB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cAAc,EAAE,CAS5E;AAED;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CA+B1B;AASD;;;;;GAKG;AAEH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GACtC,cAAc,EAAE,CAQlB;AAED,2EAA2E;AAE3E,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GACtC,MAAM,EAAE,CAIV;AAED,uEAAuE;AAEvE,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EACvC,KAAK,GAAE,WAAW,CAAC,MAAM,CAAoC,EAC7D,YAAY,GAAE,WAAW,CAAC,MAAM,CAAa,EAC7C,OAAO,GAAE,QAAQ,CAAC;IAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAM,GACxD,SAAS,EAAE,CAoGb;AAED,wEAAwE;AAExE,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAC1B,aAAa,EAAE,MAAM,GACpB,SAAS,EAAE,CAWb"}
@@ -41,6 +41,13 @@ export const DECISION_FIRMNESS_RULES = [
41
41
  SUPERSEDES_REASON_ACKNOWLEDGED_RULE,
42
42
  ];
43
43
  const DECISION_LANES = ["requirements", "adr"];
44
+ /** The schema version from which a supersede must explain itself. */
45
+ const SUPERSEDES_REASON_SCHEMA_VERSION = 9;
46
+ /**
47
+ * Told on a KB older than schema 9: the pending schema upgrade acknowledges
48
+ * supersedes recorded before the rule existed, so no edit is required now.
49
+ */
50
+ const PRE_SCHEMA9_SUPERSEDES_NOTE = " Supersedes recorded before schema 9 are acknowledged by the plan's schema-config-upgrade (kibi migrate --yes); add the reason only when you next touch the requirement.";
44
51
  /** Every authored requirement and ADR. */
45
52
  // implements REQ-kb-decision-firmness
46
53
  export function listDecisionEntities(workspaceRoot) {
@@ -123,7 +130,9 @@ export function supersedeAcknowledgements(id, edges) {
123
130
  }
124
131
  /** Evaluate the firmness rules over authored requirements and ADRs. */
125
132
  // implements REQ-kb-decision-firmness
126
- export function evaluateDecisionFirmness(entities, edges, rules = new Set(DECISION_FIRMNESS_RULES), acknowledged = new Set()) {
133
+ export function evaluateDecisionFirmness(entities, edges, rules = new Set(DECISION_FIRMNESS_RULES), acknowledged = new Set(), options = {}) {
134
+ const preSchema9 = typeof options.schemaVersion === "number" &&
135
+ options.schemaVersion < SUPERSEDES_REASON_SCHEMA_VERSION;
127
136
  const findings = [];
128
137
  const superseded = supersededIds(edges);
129
138
  const byId = new Map(entities.map((entity) => [entity.id, entity]));
@@ -186,7 +195,7 @@ export function evaluateDecisionFirmness(entities, edges, rules = new Set(DECISI
186
195
  rule: SUPERSEDES_REASON_MISSING_RULE,
187
196
  entityId: entity.id,
188
197
  description: `${entity.id} supersedes ${unacknowledged.join(", ")} without a '## ${WHY_THIS_CHANGED_HEADING}' section of at least ${MIN_WHY_CHANGED_WORDS} words`,
189
- suggestion: `Add '## ${WHY_THIS_CHANGED_HEADING}' to the body: name the evidence (a failing test, a measured cost, a constraint the old decision missed, a new requirement) and answer the superseded decision's reasoning. A preference is not evidence; propose it instead of superseding.`,
198
+ suggestion: `Add '## ${WHY_THIS_CHANGED_HEADING}' to the body: name the evidence (a failing test, a measured cost, a constraint the old decision missed, a new requirement) and answer the superseded decision's reasoning. A preference is not evidence; propose it instead of superseding.${preSchema9 ? PRE_SCHEMA9_SUPERSEDES_NOTE : ""}`,
190
199
  source: entity.path,
191
200
  evidence: { type: entity.type, supersedes: unacknowledged },
192
201
  });
@@ -212,5 +221,6 @@ export function collectDecisionFirmnessViolations(rules, workspaceRoot) {
212
221
  if (!DECISION_FIRMNESS_RULES.some((rule) => rules.has(rule)))
213
222
  return [];
214
223
  const entities = listDecisionEntities(workspaceRoot);
215
- return evaluateDecisionFirmness(entities, authoredSupersedes(workspaceRoot, entities), rules, new Set(readKbManifest(workspaceRoot)?.supersedesReasonAcknowledged ?? []));
224
+ const manifest = readKbManifest(workspaceRoot);
225
+ return evaluateDecisionFirmness(entities, authoredSupersedes(workspaceRoot, entities), rules, new Set(manifest?.supersedesReasonAcknowledged ?? []), { schemaVersion: manifest?.schemaVersion ?? null });
216
226
  }
@@ -51,6 +51,8 @@ export type QueryPayload = {
51
51
  readonly entities: readonly Record<string, unknown>[];
52
52
  readonly count: number;
53
53
  readonly factQuery?: FactQueryPayload;
54
+ /** Present when an empty answer came from a store never compiled for this branch. */
55
+ readonly branchStore?: SearchBranchStoreNotice;
54
56
  };
55
57
  export declare const FACT_KINDS: readonly ["subject", "property_value", "predicate", "predicate_schema", "observation", "meta", "rule", "rule_schema"];
56
58
  export type SearchInput = {
@@ -1 +1 @@
1
- {"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,yBAAyB,EACzB,KAAK,qBAAqB,EAM3B,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK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,CAAC;QACzB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;KACpC,CAAC;IACF,QAAQ,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACnB,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,QAAQ,CACjD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACxB,EAAE,CAAC;QACJ,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;QACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACzD,CAAC;CACH,CAAC;AAqaF,wBAAsB,YAAY,CAChC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CA8DxC;AAmDD,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAoIzC;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAmVzC"}
@@ -448,8 +448,11 @@ export async function executeQuery(input, context) {
448
448
  ? entity
449
449
  : { ...entity, firmness };
450
450
  });
451
+ // An empty page from a never-compiled store says nothing about the
452
+ // authored entities, so the answer names the store state.
453
+ const storeNotice = indexedPage.count === 0 ? uncompiledSearchNotice(context) : null;
451
454
  const text = indexedPage.count === 0
452
- ? `No entities found${type ? ` of type '${type}'` : ""}.`
455
+ ? `No entities found${type ? ` of type '${type}'` : ""}.${storeNotice ? ` Note: ${storeNotice.detail} Run kibi sync before relying on query results.` : ""}`
453
456
  : `Found ${indexedPage.count} entities${type ? ` of type '${type}'` : ""}. Showing ${paginated.length} (offset ${offset}, limit ${limit}): ${paginated
454
457
  .map((entity) => {
455
458
  const entityId = String(entity.id ?? "").replace(/^file:\/\/.*\//, "");
@@ -458,7 +461,11 @@ export async function executeQuery(input, context) {
458
461
  .join(", ")}`;
459
462
  return {
460
463
  content: [{ type: "text", text }],
461
- structuredContent: { entities: paginated, count: indexedPage.count },
464
+ structuredContent: {
465
+ entities: paginated,
466
+ count: indexedPage.count,
467
+ ...(storeNotice ? { branchStore: storeNotice } : {}),
468
+ },
462
469
  };
463
470
  }
464
471
  catch (error) {
@@ -767,6 +774,13 @@ export async function executeStatus(_input, context) {
767
774
  : { proofSnapshotError: snapshotEvidence.error }),
768
775
  };
769
776
  const schemaStatus = readMigrationConfigStatus(context.workspaceRoot);
777
+ // implements REQ-agent-guided-migration-orchestration
778
+ // A schema upgrade plans the source rewrites kibi migrate performs with
779
+ // it; the planner loads only when an upgrade is due.
780
+ const sourcePlanner = schemaStatus.needsMigration
781
+ ? (await import("../../operations/migration/schema6.js"))
782
+ .buildSchema6MigrationFragment
783
+ : undefined;
770
784
  const migrationPlan = buildActionsFromStatus({
771
785
  workspaceRoot: context.workspaceRoot,
772
786
  branchAttachment: attachment,
@@ -781,6 +795,14 @@ export async function executeStatus(_input, context) {
781
795
  ? snapshotEvidence.snapshot.hash
782
796
  : null,
783
797
  configStatus: schemaStatus,
798
+ ...(sourcePlanner !== undefined
799
+ ? {
800
+ planSchemaUpgradeSources: (currentSchemaVersion) => sourcePlanner({
801
+ workspaceRoot: context.workspaceRoot,
802
+ currentSchemaVersion,
803
+ }),
804
+ }
805
+ : {}),
784
806
  });
785
807
  const listed = context.fs?.glob
786
808
  ? await context.fs.glob([
@@ -77,6 +77,8 @@ export declare function withoutActionCodes(plan: MigrationPlan, codes: ReadonlyS
77
77
  export declare function migrationAction(input: Partial<MigrationAction> & Pick<MigrationAction, "id" | "code">): MigrationAction;
78
78
  /** Migration code for mechanical predicate namespace/alias repairs. */
79
79
  export declare const PREDICATE_SCHEMA_ALIGNMENT_CODE = "predicate_schema_alignment";
80
+ /** Migration code of the grouped untracked-source parity findings. */
81
+ export declare const UNTRACKED_KNOWLEDGE_SOURCES_CODE = "untracked_knowledge_sources";
80
82
  export declare function buildActionsFromCheck(input: {
81
83
  violations?: readonly Readonly<Record<string, unknown>>[];
82
84
  qualityDiagnostics?: readonly Readonly<Record<string, unknown>>[];
@@ -85,6 +87,13 @@ export declare function buildActionsFromCoverage(input: {
85
87
  repairPlan?: Readonly<Record<string, unknown>>;
86
88
  symbolRepairPlan?: Readonly<Record<string, unknown>>;
87
89
  }): MigrationAction[];
90
+ /** Source-rewrite actions a schema upgrade performs, as its planner returns them. */
91
+ export type SchemaUpgradeSourceActions = Readonly<{
92
+ actions: readonly MigrationAction[];
93
+ /** Automatic actions that rewrite authored sources; the upgrade waits on them. */
94
+ sourceRewriteActionIds: readonly string[];
95
+ diagnostics: readonly string[];
96
+ }>;
88
97
  export type MigrationConfigStatus = Readonly<{
89
98
  status: "missing" | "invalid" | "older" | "current" | "newer";
90
99
  currentVersion: number | null;
@@ -106,6 +115,12 @@ export declare function buildActionsFromStatus(input: {
106
115
  kbSnapshotId?: string | null;
107
116
  workspaceSnapshot?: string | null;
108
117
  configStatus?: MigrationConfigStatus;
118
+ /**
119
+ * Plans the authored-source rewrites `kibi migrate --yes` performs on its
120
+ * way to the latest schema (the planner `kibi migrate` itself uses), so
121
+ * the schema upgrade declares every file it touches. Read-only.
122
+ */
123
+ planSchemaUpgradeSources?: (currentSchemaVersion: number | null) => SchemaUpgradeSourceActions;
109
124
  }): MigrationPlan;
110
125
  export {};
111
126
  //# sourceMappingURL=migration-plan.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-plan.d.ts","sourceRoot":"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MAAM,GACpB,qBAAqB,CA8BvB;AAwBD,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAcnD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrD,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC5D,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,CACzB,oBAAoB,EAAE,MAAM,GAAG,IAAI,KAChC,0BAA0B,CAAC;CACjC,GAAG,aAAa,CA0VhB"}
@@ -261,14 +261,80 @@ function predicateSchemaAlignmentAction(diagnostic) {
261
261
  }
262
262
  /** Migration code for mechanical predicate namespace/alias repairs. */
263
263
  export const PREDICATE_SCHEMA_ALIGNMENT_CODE = "predicate_schema_alignment";
264
+ /** Migration code of the grouped untracked-source parity findings. */
265
+ export const UNTRACKED_KNOWLEDGE_SOURCES_CODE = "untracked_knowledge_sources";
266
+ /**
267
+ * Every source-relationship-parity finding explained by untracked files
268
+ * (evidence `untrackedSources`) has one cause and one fix: the files Git
269
+ * does not track and no pending-source receipt covers. After a storage move
270
+ * that can be thousands of relationships, so they become one review action
271
+ * naming the files instead of one per relationship.
272
+ */
273
+ // implements REQ-agent-guided-migration-orchestration, REQ-kibi-source-relationship-parity
274
+ function untrackedSourceActionFromViolations(violations) {
275
+ const consumed = new Set();
276
+ const files = new Set();
277
+ const entityIds = new Set();
278
+ const relationships = [];
279
+ for (const [index, violation] of violations.entries()) {
280
+ if (violation.rule !== "source-relationship-parity")
281
+ continue;
282
+ const evidence = isRecord(violation.evidence) ? violation.evidence : {};
283
+ const sources = Array.isArray(evidence.untrackedSources)
284
+ ? evidence.untrackedSources.filter(isRecord)
285
+ : [];
286
+ if (sources.length === 0)
287
+ continue;
288
+ consumed.add(index);
289
+ for (const source of sources) {
290
+ if (typeof source.file === "string")
291
+ files.add(source.file);
292
+ if (typeof source.entityId === "string")
293
+ entityIds.add(source.entityId);
294
+ }
295
+ if (evidence.relationship !== undefined)
296
+ relationships.push(evidence.relationship);
297
+ }
298
+ if (consumed.size === 0)
299
+ return null;
300
+ const listed = [...files].sort();
301
+ return {
302
+ consumed,
303
+ action: migrationAction({
304
+ id: "untracked-knowledge-sources",
305
+ code: UNTRACKED_KNOWLEDGE_SOURCES_CODE,
306
+ category: "relationship",
307
+ safety: "review",
308
+ invocation: {
309
+ kind: "review",
310
+ instruction: `${consumed.size} authored relationship(s) are missing from the compiled KB because ${listed.length} file(s) declaring their endpoints are not tracked by Git and no pending-source receipt covers them: ${listed.join(", ")}. Stage them (git add; staging is enough, Kibi never stages files itself) or rewrite the entities with kb_upsert, then run kibi sync and rerun kibi migrate.`,
311
+ },
312
+ affectedEntityIds: [...entityIds],
313
+ affectedFiles: listed,
314
+ postconditions: [{ rule: "source-relationship-parity", findings: 0 }],
315
+ evidence: {
316
+ relationshipCount: consumed.size,
317
+ files: listed,
318
+ // A sample; the count above is the full number.
319
+ relationships: relationships.slice(0, 20),
320
+ },
321
+ dispositionRequired: true,
322
+ }),
323
+ };
324
+ }
264
325
  // implements REQ-agent-guided-migration-orchestration, REQ-kibi-predicate-vocabulary-migration, REQ-cli-schema-migration
265
326
  export function buildActionsFromCheck(input) {
266
327
  const actions = [];
267
328
  const lifecycle = lifecycleActionsFromViolations(input.violations ?? []);
268
329
  actions.push(...lifecycle.actions.map(migrationAction));
330
+ const untracked = untrackedSourceActionFromViolations(input.violations ?? []);
331
+ if (untracked !== null)
332
+ actions.push(untracked.action);
269
333
  for (const [index, violation] of (input.violations ?? []).entries()) {
270
334
  if (lifecycle.consumed.has(index))
271
335
  continue;
336
+ if (untracked?.consumed.has(index))
337
+ continue;
272
338
  const rule = typeof violation.rule === "string" ? violation.rule : "check";
273
339
  const entityId = typeof violation.entityId === "string" ? violation.entityId : "";
274
340
  const suggestion = typeof violation.suggestion === "string"
@@ -442,8 +508,20 @@ function readLegacySchemaVersion(workspaceRoot) {
442
508
  // implements REQ-agent-guided-migration-orchestration
443
509
  /** Migration action code of the automatic recompile of changed sources. */
444
510
  export const FRESHNESS_RESYNC = "freshness_resync";
511
+ // implements REQ-cli-status-pre-first-sync
512
+ /**
513
+ * Stale reasons one `kibi sync` clears: sources whose content changed since
514
+ * the last compilation, and a store compiled under another compiler contract
515
+ * (the sync discards that cache, re-imports every source and stamps the
516
+ * current contract).
517
+ */
518
+ const RESYNC_REASON_CODES = new Set([
519
+ ...MTIME_SOURCE_REASON_CODES,
520
+ "compiler_changed",
521
+ ]);
445
522
  export function buildActionsFromStatus(input) {
446
523
  const actions = [];
524
+ const diagnostics = [];
447
525
  const attachment = input.branchAttachment;
448
526
  const store = input.branchStore;
449
527
  const configStatus = input.configStatus ?? readMigrationConfigStatus(input.workspaceRoot);
@@ -488,14 +566,19 @@ export function buildActionsFromStatus(input) {
488
566
  }));
489
567
  }
490
568
  const storeState = typeof store?.state === "string" ? store.state : null;
491
- const legacyStorageMigrationRequired = legacyConfigExists(input.workspaceRoot);
569
+ // Legacy storage is evaluated whether or not the legacy config survives:
570
+ // legacy copies left beside a migrated .kb/ (moved, identical or stale)
571
+ // are the same finding 'kibi doctor' and 'kibi migrate' report.
572
+ // implements REQ-cli-schema-migration
573
+ const legacyStorage = planLegacyStorageMigration(input.workspaceRoot);
574
+ const legacyStorageMigrationRequired = legacyConfigExists(input.workspaceRoot) ||
575
+ legacyStorage.moves.length > 0 ||
576
+ legacyStorage.removals.length > 0 ||
577
+ legacyStorage.blockers.length > 0;
492
578
  // A legacy cutover that cannot move its files (a destination already
493
579
  // exists, a malformed config) is an operator decision, not an automatic
494
580
  // step that fails when applied and takes the compile with it.
495
- const legacyStorage = legacyStorageMigrationRequired
496
- ? planLegacyStorageMigration(input.workspaceRoot)
497
- : null;
498
- const legacyStorageBlocked = legacyStorage !== null && legacyStorage.blockers.length > 0;
581
+ const legacyStorageBlocked = legacyStorage.blockers.length > 0;
499
582
  if (storeState === "missing") {
500
583
  actions.push(migrationAction({
501
584
  id: "branch-store-ensure",
@@ -529,6 +612,20 @@ export function buildActionsFromStatus(input) {
529
612
  }
530
613
  if (configStatus.needsMigration || legacyStorageMigrationRequired) {
531
614
  const operatorOnly = configStatus.status === "newer" || legacyStorageBlocked;
615
+ // implements REQ-agent-guided-migration-orchestration, REQ-cli-schema-migration
616
+ // The source rewrites the migrate run performs (legacy-link marks, origin
617
+ // backfill, lifecycle repairs, ...) are planned as their own actions with
618
+ // their own files, and the upgrade waits on them, so approving it means
619
+ // approving them. Knowledge still outside .kb/ is planned after it moves.
620
+ const sources = !operatorOnly &&
621
+ !legacyStorageMigrationRequired &&
622
+ input.planSchemaUpgradeSources !== undefined
623
+ ? input.planSchemaUpgradeSources(configStatus.currentVersion)
624
+ : null;
625
+ if (sources !== null) {
626
+ actions.push(...sources.actions);
627
+ diagnostics.push(...sources.diagnostics);
628
+ }
532
629
  actions.push(migrationAction({
533
630
  id: "schema-config-upgrade",
534
631
  code: configStatus.status === "invalid"
@@ -542,28 +639,43 @@ export function buildActionsFromStatus(input) {
542
639
  invocation: legacyStorageBlocked
543
640
  ? {
544
641
  kind: "review",
545
- instruction: `The legacy .kb/config.json still names knowledge files outside .kb/ and Kibi cannot move them: ${legacyStorage?.blockers.join(" ")} Compare each legacy copy with its .kb/ copy and keep the current one: replace the .kb/ copy when the legacy one is newer, or remove (git rm) the legacy copy when it is a stale duplicate. Then run 'kibi migrate --yes' to retire .kb/config.json.`,
642
+ instruction: `Legacy knowledge files outside .kb/ cannot be migrated automatically: ${legacyStorage.blockers.join(" ")} Then run 'kibi migrate --yes'.`,
546
643
  }
547
644
  : { kind: "cli", command_argv: ["kibi", "migrate", "--yes"] },
548
645
  affectedFiles: [
549
646
  ".kb/manifest.json",
550
647
  ".kb/migrations",
551
648
  ".kb/config.json",
552
- ...(legacyStorage?.moves.map((move) => move.from) ?? []),
649
+ // The migrate run keeps the canonical derived entries ignored.
650
+ ".gitignore",
651
+ // Unplanned source rewrites can touch any authored .kb/ file.
652
+ ...(sources === null ? [".kb/"] : []),
653
+ ...legacyStorage.moves.map((move) => move.from),
654
+ ...legacyStorage.removals.map((removal) => removal.path),
553
655
  ],
554
656
  evidence: {
555
657
  configStatus,
556
- ...(legacyStorage === null
557
- ? {}
558
- : {
658
+ ...(sources === null
659
+ ? {
660
+ sourceRewrites: "Not planned as separate actions: kibi migrate --yes also marks coarse symbol links legacy-link, backfills origin and repairs lifecycle findings in authored .kb/ sources. The plan lists them as their own actions once the upgrade can run automatically on the canonical .kb/ layout.",
661
+ }
662
+ : {}),
663
+ ...(legacyStorageMigrationRequired
664
+ ? {
559
665
  legacyStorage: {
560
666
  moves: legacyStorage.moves,
667
+ removals: legacyStorage.removals,
668
+ conflicts: legacyStorage.conflicts,
561
669
  blockers: legacyStorage.blockers,
562
670
  legacyConfig: legacyStorage.legacyConfig,
563
671
  },
564
- }),
672
+ }
673
+ : {}),
565
674
  },
566
- dependsOn: storeState === "missing" ? ["branch-store-ensure"] : [],
675
+ dependsOn: [
676
+ ...(storeState === "missing" ? ["branch-store-ensure"] : []),
677
+ ...(sources?.sourceRewriteActionIds ?? []),
678
+ ],
567
679
  autoApplicable: !operatorOnly,
568
680
  }));
569
681
  }
@@ -598,10 +710,10 @@ export function buildActionsFromStatus(input) {
598
710
  // implements REQ-cli-status-pre-first-sync
599
711
  // Sources whose content changed since the last compilation (kb_status has
600
712
  // already dropped mtime-only reasons) are fixed by recompiling them: one
601
- // automatic `kibi sync`, not a review per file. An uncompiled store is
602
- // compiled by the step above, which also covers these files.
603
- const resyncReasons = (input.staleReasons ?? []).filter((reason) => typeof reason.code === "string" &&
604
- MTIME_SOURCE_REASON_CODES.has(reason.code));
713
+ // automatic `kibi sync`, not a review per file. A store compiled under
714
+ // another compiler contract is fixed by the same sync. An uncompiled store
715
+ // is compiled by the step above, which also covers these reasons.
716
+ const resyncReasons = (input.staleReasons ?? []).filter((reason) => typeof reason.code === "string" && RESYNC_REASON_CODES.has(reason.code));
605
717
  if (resyncReasons.length > 0 && uncompiled === undefined) {
606
718
  actions.push(migrationAction({
607
719
  id: "freshness-resync",
@@ -626,7 +738,7 @@ export function buildActionsFromStatus(input) {
626
738
  if (code === BRANCH_STORE_NOT_COMPILED)
627
739
  continue;
628
740
  // Planned above as one automatic resync (or covered by the compile).
629
- if (MTIME_SOURCE_REASON_CODES.has(code))
741
+ if (RESYNC_REASON_CODES.has(code))
630
742
  continue;
631
743
  const file = typeof reason.path === "string" ? reason.path : "";
632
744
  actions.push(migrationAction({
@@ -699,5 +811,6 @@ export function buildActionsFromStatus(input) {
699
811
  ],
700
812
  incompleteDomains,
701
813
  actions,
814
+ diagnostics,
702
815
  });
703
816
  }
@@ -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,EAA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AM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED;;;;;;;;;GASG;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, decision-firm-unreferenced, decision-firm-superseded, supersedes-reason-missing, supersedes-reason-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,EAoDlD,CAAC;AAGF,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,4oCACsmC,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"}