kibi-cli 2.26.3 → 2.27.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 (91) hide show
  1. package/dist/cli-operation-metadata.d.ts +1 -1
  2. package/dist/cli-operation-metadata.js +1 -1
  3. package/dist/commands/doctor.d.ts.map +1 -1
  4. package/dist/commands/doctor.js +2 -1
  5. package/dist/commands/migrate.d.ts.map +1 -1
  6. package/dist/commands/migrate.js +24 -0
  7. package/dist/commands/sync/persistence.d.ts +10 -0
  8. package/dist/commands/sync/persistence.d.ts.map +1 -1
  9. package/dist/commands/sync/persistence.js +24 -0
  10. package/dist/commands/sync.d.ts.map +1 -1
  11. package/dist/commands/sync.js +5 -1
  12. package/dist/diagnostics.d.ts +6 -0
  13. package/dist/diagnostics.d.ts.map +1 -1
  14. package/dist/diagnostics.js +25 -9
  15. package/dist/intent-search.d.ts +2 -0
  16. package/dist/intent-search.d.ts.map +1 -1
  17. package/dist/intent-search.js +5 -0
  18. package/dist/operations/bootstrap/activation.d.ts +6 -0
  19. package/dist/operations/bootstrap/activation.d.ts.map +1 -1
  20. package/dist/operations/bootstrap/activation.js +22 -0
  21. package/dist/operations/bootstrap/claim-restatement.d.ts +2 -0
  22. package/dist/operations/bootstrap/claim-restatement.d.ts.map +1 -1
  23. package/dist/operations/bootstrap/conflict-review.d.ts +16 -0
  24. package/dist/operations/bootstrap/conflict-review.d.ts.map +1 -0
  25. package/dist/operations/bootstrap/conflict-review.js +59 -0
  26. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  27. package/dist/operations/bootstrap/generate.js +17 -4
  28. package/dist/operations/bootstrap/types.d.ts +5 -0
  29. package/dist/operations/bootstrap/types.d.ts.map +1 -1
  30. package/dist/operations/migration/entity-type.d.ts +35 -0
  31. package/dist/operations/migration/entity-type.d.ts.map +1 -0
  32. package/dist/operations/migration/entity-type.js +89 -0
  33. package/dist/operations/migration/schema6.d.ts.map +1 -1
  34. package/dist/operations/migration/schema6.js +32 -0
  35. package/dist/operations/mutation/symbol-granularity.d.ts +1 -1
  36. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  37. package/dist/operations/mutation/symbol-granularity.js +37 -7
  38. package/dist/operations/mutation/upsert.d.ts +9 -1
  39. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  40. package/dist/operations/mutation/upsert.js +43 -7
  41. package/dist/operations/mutation/validation.d.ts.map +1 -1
  42. package/dist/operations/mutation/validation.js +21 -0
  43. package/dist/operations/planning/compile-intent.d.ts +16 -0
  44. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  45. package/dist/operations/planning/compile-intent.js +118 -5
  46. package/dist/operations/planning/conflict-review.d.ts +69 -0
  47. package/dist/operations/planning/conflict-review.d.ts.map +1 -0
  48. package/dist/operations/planning/conflict-review.js +133 -0
  49. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +8 -0
  50. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
  51. package/dist/operations/semantic-advisor/ingestion-boundary.js +43 -2
  52. package/dist/public/impact/analyzer.d.ts.map +1 -1
  53. package/dist/public/impact/analyzer.js +26 -2
  54. package/dist/public/impact/requirement-statements.d.ts +29 -0
  55. package/dist/public/impact/requirement-statements.d.ts.map +1 -0
  56. package/dist/public/impact/requirement-statements.js +127 -0
  57. package/dist/public/operations/catalog.d.ts +26 -2
  58. package/dist/public/operations/catalog.d.ts.map +1 -1
  59. package/dist/public/operations/check-format-shared.d.ts +1 -1
  60. package/dist/public/operations/check-format-shared.d.ts.map +1 -1
  61. package/dist/public/operations/check-format-shared.js +19 -4
  62. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  63. package/dist/public/operations/discovery-executors.js +20 -13
  64. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  65. package/dist/public/operations/migration-plan.js +7 -2
  66. package/dist/public/operations/result-envelope.d.ts +2 -0
  67. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  68. package/dist/public/operations/result-envelope.js +21 -9
  69. package/dist/public/operations/specs/check.d.ts +1 -1
  70. package/dist/public/operations/specs/check.js +1 -1
  71. package/dist/public/operations/specs/planning.d.ts +25 -1
  72. package/dist/public/operations/specs/planning.d.ts.map +1 -1
  73. package/dist/public/operations/specs/planning.js +16 -1
  74. package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
  75. package/dist/public/skills/kibi-usage/SKILL.md +11 -1
  76. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  77. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  78. package/dist/utils/config.d.ts +8 -0
  79. package/dist/utils/config.d.ts.map +1 -1
  80. package/dist/utils/config.js +10 -0
  81. package/package.json +2 -2
  82. package/src/public/impact/analyzer.ts +38 -2
  83. package/src/public/impact/requirement-statements.ts +171 -0
  84. package/src/public/operations/check-format-shared.ts +27 -4
  85. package/src/public/operations/discovery-executors.ts +20 -13
  86. package/src/public/operations/migration-plan.ts +12 -4
  87. package/src/public/operations/result-envelope.ts +18 -4
  88. package/src/public/operations/specs/check.ts +1 -1
  89. package/src/public/operations/specs/planning.ts +17 -1
  90. package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
  91. package/src/public/skills/kibi-usage/SKILL.md +11 -1
@@ -91,7 +91,7 @@ export declare const CLI_OPERATION_METADATA: readonly [{
91
91
  }, {
92
92
  readonly name: "kb_compile_intent";
93
93
  readonly cliName: "compile-intent";
94
- readonly description: "Compile complete change intent into a deterministic, snapshot-bound read-only plan. Reuses intent-aware discovery and semantic modeling, accounts for every proposition, reports contradiction witnesses, proposes traceability links, and emits dependency-ordered kb_upsert-style steps only for resolved typed claims. No mutation side effects.";
94
+ readonly description: "Compile complete change intent into a deterministic, snapshot-bound read-only plan. Reuses intent-aware discovery and semantic modeling, accounts for every proposition, reports contradiction witnesses, proposes traceability links, and emits dependency-ordered kb_upsert-style steps only for resolved typed claims. contradictionAnalysis.outcome is no_conflict only when the check could decide: an unmodeled proposition or a related current requirement without logic leaves it unresolved with reasons and reviewCandidates to compare and judge through conflictReviews. No mutation side effects.";
95
95
  }, {
96
96
  readonly name: "kb_apply_plan";
97
97
  readonly cliName: "apply-plan";
@@ -110,7 +110,7 @@ export const CLI_OPERATION_METADATA = [
110
110
  {
111
111
  name: "kb_compile_intent",
112
112
  cliName: "compile-intent",
113
- description: "Compile complete change intent into a deterministic, snapshot-bound read-only plan. Reuses intent-aware discovery and semantic modeling, accounts for every proposition, reports contradiction witnesses, proposes traceability links, and emits dependency-ordered kb_upsert-style steps only for resolved typed claims. No mutation side effects.",
113
+ description: "Compile complete change intent into a deterministic, snapshot-bound read-only plan. Reuses intent-aware discovery and semantic modeling, accounts for every proposition, reports contradiction witnesses, proposes traceability links, and emits dependency-ordered kb_upsert-style steps only for resolved typed claims. contradictionAnalysis.outcome is no_conflict only when the check could decide: an unmodeled proposition or a related current requirement without logic leaves it unresolved with reasons and reviewCandidates to compare and judge through conflictReviews. No mutation side effects.",
114
114
  },
115
115
  {
116
116
  name: "kb_apply_plan",
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAqGA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAGD,wBAAsB,aAAa,CACjC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAuH/B;AAED,wBAAsB,4BAA4B,CAChD,IAAI,GAAE,MAAM,OAAO,CAAC;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CACT,GACxC,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;;;;;;;;;MAkE3C;AAkGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAepB"}
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAyGA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAGD,wBAAsB,aAAa,CACjC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAuH/B;AAED,wBAAsB,4BAA4B,CAChD,IAAI,GAAE,MAAM,OAAO,CAAC;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CACT,GACxC,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;;;;;;;;;MAkE3C;AAkGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAepB"}
@@ -27,6 +27,7 @@ import { SwiplResolutionError, inspectSwiplBundle, probeRequiredLibraries, resol
27
27
  import { buildMigrationPlan, migrationAction, } from "../public/operations/migration-plan.js";
28
28
  import { resolveBranchAttachment, resolveReadBranchAttachment, } from "../utils/branch-resolver.js";
29
29
  import { branchStoreCompilation, inspectBranchStore, storeLockTakeoverReason, uncompiledBranchStoreReason, } from "../utils/branch-store.js";
30
+ import { LEGACY_KB_MIGRATION_COMMAND, LEGACY_KB_MIGRATION_NOTE, } from "../utils/config.js";
30
31
  import { resolveGitRepository, } from "../utils/git-repository-context.js";
31
32
  import { readKbManifestStatus } from "../utils/kb-manifest.js";
32
33
  import { MERGE_DRIVER_SETUP, manifestMergeDriverGaps, } from "../utils/merge-driver-setup.js";
@@ -612,7 +613,7 @@ function checkKbManifest() {
612
613
  message: "Not found",
613
614
  remediation: legacy.legacyConfig === "absent"
614
615
  ? "Run: kibi init"
615
- : "Run: kibi migrate --yes (it creates the manifest from the legacy .kb/config.json; do not run kibi init first)",
616
+ : `Run: ${LEGACY_KB_MIGRATION_COMMAND} (${LEGACY_KB_MIGRATION_NOTE})`,
616
617
  };
617
618
  }
618
619
  if (status.state !== "ok") {
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AA0DA,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,wCAAwC,CAAC;AAwBhD,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,uFAAuF;IACvF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB,EAAE,SAAS,GAAG,WAAW,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC3E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F,MAAM,WAAW,mBAAmB;IAClC,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,oBAAoB,CAAC;IAC5B,0EAA0E;IAC1E,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAgJD,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,OAAO,EACzB,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,MAAM,CAUR;AAwXD,wBAAgB,+BAA+B,IAAI;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAKtE;AAGD,wBAAsB,cAAc,CAClC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAsd9D;AAED;;;;GAIG;AAEH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAGzE;AA0XD;;;;;GAKG;AAEH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,GACpC,OAAO,CAOT"}
@@ -17,6 +17,8 @@
17
17
  */
18
18
  import { existsSync, mkdirSync, renameSync, writeFileSync, } from "node:fs";
19
19
  import * as path from "node:path";
20
+ import { countByType } from "../operations/migration/entity-body-context.js";
21
+ import { applyEntityTypeBackfill, planEntityTypeBackfill, } from "../operations/migration/entity-type.js";
20
22
  import { applySafeInventoryRederivations, planInventoryRederivation, } from "../operations/migration/inventory-rederive.js";
21
23
  import { applyOriginBackfill, planOriginBackfill, } from "../operations/migration/origin-backfill.js";
22
24
  import { applyDeliveredStatusMappings, planRequirementStatusMappings, } from "../operations/migration/requirement-status.js";
@@ -357,6 +359,24 @@ function mapLegacyRequirementStatuses(cwd, dryRun) {
357
359
  review: planRequirementStatusMappings(cwd),
358
360
  };
359
361
  }
362
+ /**
363
+ * State the folder-implied type on entity files without one, so the first
364
+ * kb_upsert on such a file changes only what it was asked to change.
365
+ * Returns how many files were (or, on a dry run, would be) rewritten.
366
+ */
367
+ // implements REQ-cli-migrate-entity-type-backfill
368
+ function stateFolderImpliedTypes(cwd, dryRun) {
369
+ const plan = dryRun
370
+ ? planEntityTypeBackfill(cwd)
371
+ : applyEntityTypeBackfill(cwd);
372
+ if (plan.targets.length > 0)
373
+ console.log(`${dryRun ? "dry run: would state" : "Stated"} the folder-implied type on ${plan.targets.length} entity file(s) without one (${Object.entries(countByType(plan.targets))
374
+ .map(([type, count]) => `${count} ${type}`)
375
+ .join(", ")}); no other line changes.`);
376
+ for (const skip of plan.skipped)
377
+ printWarning(`Type not stated for ${skip.path}: ${skip.reason}.`);
378
+ return plan.targets.length;
379
+ }
360
380
  /**
361
381
  * Print what a `kibi migrate --yes` run left for a person, naming the
362
382
  * requirements kibi sync cannot compile first. Returns false when nothing
@@ -467,6 +487,7 @@ export async function migrateCommand(options = {}) {
467
487
  const polarityCount = options.dryRun
468
488
  ? planPolarityValueBackfill(cwd).length
469
489
  : applyPolarityValueBackfill(cwd);
490
+ const typesStated = stateFolderImpliedTypes(cwd, options.dryRun === true);
470
491
  // Delivery statuses keep requirements out of the store at any version;
471
492
  // map them before the drift check, which only sees compiled requirements.
472
493
  const statuses = mapLegacyRequirementStatuses(cwd, options.dryRun === true);
@@ -476,6 +497,7 @@ export async function migrateCommand(options = {}) {
476
497
  const lifecycle = repairLifecycleFindings(cwd, options.dryRun === true);
477
498
  const legacyLinks = markLegacySymbolLinks(cwd, options.dryRun === true);
478
499
  const rewroteSources = polarityCount > 0 ||
500
+ typesStated > 0 ||
479
501
  statuses.mapped > 0 ||
480
502
  legacyLinks > 0 ||
481
503
  drift.rederived.length > 0 ||
@@ -569,6 +591,7 @@ export async function migrateCommand(options = {}) {
569
591
  console.log(`dry run: would record origin {kind: migration} on ${backfill.targets.length} authored entit(ies) without one.`);
570
592
  }
571
593
  }
594
+ stateFolderImpliedTypes(cwd, true);
572
595
  mapLegacyRequirementStatuses(cwd, true);
573
596
  rederiveDriftedInventories(cwd, true);
574
597
  repairLifecycleFindings(cwd, true);
@@ -600,6 +623,7 @@ export async function migrateCommand(options = {}) {
600
623
  ? "pending"
601
624
  : "not_applicable");
602
625
  const migratedAt = new Date().toISOString();
626
+ stateFolderImpliedTypes(cwd, false);
603
627
  const polarityValuesRewritten = applyPolarityValueBackfill(cwd);
604
628
  if (polarityValuesRewritten > 0)
605
629
  console.log(`Encoded ${polarityValuesRewritten} legacy polarity-only fact(s) as typed booleans.`);
@@ -12,6 +12,16 @@ export declare function retractEntitiesById(prolog: PrologProcess, entityIds: re
12
12
  /** Clear outgoing inline relationships for entities whose payload changed. */
13
13
  export declare function retractEntityRelationshipsById(prolog: PrologProcess, entityIds: readonly string[]): Promise<void>;
14
14
  export declare function retractRelationships(prolog: PrologProcess, relationships: readonly ExtractedRelationship[]): Promise<number>;
15
+ /** What the store holds after a sync, by entity type, plus relationships. */
16
+ export type StoreTotals = Readonly<{
17
+ entities: Record<string, number>;
18
+ relationships: number;
19
+ }>;
20
+ /**
21
+ * Count what the store holds after this sync. Undefined when the store
22
+ * cannot be counted; the summary then shows only what was imported.
23
+ */
24
+ export declare function queryStoreTotals(prolog: Pick<PrologProcess, "query">): Promise<StoreTotals | undefined>;
15
25
  export declare function persistEntities(prolog: PrologProcess, results: ExtractionResult[], entityIds: Set<string>, options?: {
16
26
  loadExistingEntityIds?: boolean;
17
27
  }): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/persistence.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA2HrD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB;AAuFD,iFAAi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AE,EAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,EACtB,OAAO,GAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GAChD,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAoRvD;AA4BD,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,MAAM,CAER;AAGD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,kBAAkB,EAAE,qBAAqB,EAAE,EAC3C,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GACvC,OAAO,CAAC;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAmO7D"}
@@ -284,6 +284,30 @@ async function tryResetPrologProcess(prolog) {
284
284
  return false;
285
285
  }
286
286
  }
287
+ /**
288
+ * Count what the store holds after this sync. Undefined when the store
289
+ * cannot be counted; the summary then shows only what was imported.
290
+ */
291
+ // implements REQ-cli-sync-summary-kb-totals
292
+ export async function queryStoreTotals(prolog) {
293
+ const result = await prolog
294
+ .query(
295
+ // kb_entity and kb_relationship need the type bound.
296
+ "findall(Type-Count, (member(Type, [req,scenario,test,adr,flag,event,symbol,fact]), aggregate_all(count, kb_entity(_, Type, _), Count), Count > 0), Counts), aggregate_all(count, (kibi_relationships:relationship_type(Rel), kb_relationship(Rel, _, _)), Relationships)")
297
+ .catch(() => undefined);
298
+ const counts = result?.success ? result.bindings?.Counts : undefined;
299
+ const relationships = result?.success
300
+ ? Number(result.bindings?.Relationships)
301
+ : Number.NaN;
302
+ if (typeof counts !== "string" || !Number.isInteger(relationships))
303
+ return undefined;
304
+ const entities = {};
305
+ for (const [, type, count] of counts.matchAll(/([a-z]+)-(\d+)/g)) {
306
+ if (type !== undefined && count !== undefined)
307
+ entities[type] = Number(count);
308
+ }
309
+ return { entities, relationships };
310
+ }
287
311
  export async function persistEntities(
288
312
  // implements REQ-009
289
313
  prolog, results, entityIds, options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA6BjE,OAAO,EAEL,yBAAyB,EAE1B,MAAM,gDAAgD,CAAC;AAGxD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,6BAA6B,CAAC;AA0BrC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAkCxE,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAmCD,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EACxB,4BAA4B,UAAQ,EACpC,4BAA4B,GAAE,4BAA4B,EAAO,GAChE,MAAM,EAAE,CAuGV;AAiFD,MAAM,WAAW,UAAW,SAAQ,WAAW;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,yBAAyB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,kBAAkB;IAC1B,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3E,UAAU,CAAC,EAAE,CACX,OAAO,EAAE,yBAAyB,GAAG;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,KACz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AAC"}
@@ -34,7 +34,7 @@ import { SYNC_CACHE_TTL_MS, SYNC_CACHE_VERSION, SYNC_COMPILER_FINGERPRINT, faile
34
34
  import { clearRecoveredPendingSourceReceipts, discoverSourceFiles, } from "./sync/discovery.js";
35
35
  import { normalizeExtractionSources, processExtractions, } from "./sync/extraction.js";
36
36
  import { normalizeManifestLayout, refreshManifestCoordinates, } from "./sync/manifest.js";
37
- import { persistEntities, persistRelationships, retractEntitiesById, retractEntitiesForSources, retractEntityRelationshipsById, retractRelationships, } from "./sync/persistence.js";
37
+ import { persistEntities, persistRelationships, queryStoreTotals, retractEntitiesById, retractEntitiesForSources, retractEntityRelationshipsById, retractRelationships, } from "./sync/persistence.js";
38
38
  import { atomicPublish, atomicPublishGeneration, cleanupStaging, createUniqueStagingPath, prepareStagingEnvironment, } from "./sync/staging.js";
39
39
  import { adoptUpsertOnlySymbolManifest, findUntrackedDocumentMatches, } from "./sync/untracked-targets.js";
40
40
  // Manual deletion of a written-but-unstaged source leaves a recovery receipt
@@ -990,6 +990,7 @@ export async function syncCommand(options = {}, runtime = {}) {
990
990
  }
991
991
  }
992
992
  const { relationshipCount, kbModified: relationshipsModified } = await persistRelationships(engineProlog, results, [...shardDeltaByKey.values()], { workspaceRoot });
993
+ const storeTotals = await queryStoreTotals(engineProlog);
993
994
  const kbModified = removedCount > 0 ||
994
995
  relationshipChanged ||
995
996
  entitiesModified ||
@@ -1039,6 +1040,7 @@ export async function syncCommand(options = {}, runtime = {}) {
1039
1040
  branch: currentBranch,
1040
1041
  timestamp: new Date().toISOString(),
1041
1042
  entityCounts,
1043
+ ...(storeTotals !== undefined ? { storeTotals } : {}),
1042
1044
  relationshipCount,
1043
1045
  success: true,
1044
1046
  published,
@@ -1143,6 +1145,7 @@ export async function syncCommand(options = {}, runtime = {}) {
1143
1145
  prolog.invalidateCache();
1144
1146
  }
1145
1147
  await runtime.beforeSave?.({ ...runtimeContext, kbModified });
1148
+ const storeTotals = await queryStoreTotals(prolog);
1146
1149
  const saveResult = await prolog.query("kb_save");
1147
1150
  if (!saveResult.success) {
1148
1151
  throw new SyncError(`Failed to save staging KB: ${saveResult.error || "Unknown error"}`);
@@ -1226,6 +1229,7 @@ export async function syncCommand(options = {}, runtime = {}) {
1226
1229
  branch: currentBranch,
1227
1230
  timestamp: new Date().toISOString(),
1228
1231
  entityCounts,
1232
+ ...(storeTotals !== undefined ? { storeTotals } : {}),
1229
1233
  relationshipCount,
1230
1234
  success: true,
1231
1235
  published,
@@ -17,7 +17,13 @@ export interface SyncSummary {
17
17
  branch: string;
18
18
  commit?: string;
19
19
  timestamp: string;
20
+ /** Entities this sync imported (changed sources only), by type. */
20
21
  entityCounts: Record<string, number>;
22
+ /** What the store holds after this sync, when counted. */
23
+ storeTotals?: Readonly<{
24
+ entities: Record<string, number>;
25
+ relationships: number;
26
+ }>;
21
27
  relationshipCount: number;
22
28
  success: boolean;
23
29
  published: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,kBAAkB,GAC1B,2BAA2B,GAC3B,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,YAAY,GACZ,kBAAkB,GAClB,oBAAoB,CAAC;AAEzB,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC;I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AAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,GACtB,UAAU,CAQZ;AAaD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA+D9D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,CASD"}
@@ -45,6 +45,16 @@ export function createInvalidAuthoringDiagnostic(filePath, embeddedTypes) {
45
45
  suggestion: `Move ${embeddedTypes.join(" and ")} to separate entity files and link them using 'links' with relationship types like 'specified_by' or 'verified_by'.`,
46
46
  };
47
47
  }
48
+ function pushCounts(lines, counts) {
49
+ const sortedTypes = Object.keys(counts).sort();
50
+ if (sortedTypes.length === 0) {
51
+ lines.push(" (none)");
52
+ return;
53
+ }
54
+ for (const type of sortedTypes) {
55
+ lines.push(` ${type}: ${counts[type]}`);
56
+ }
57
+ }
48
58
  /**
49
59
  * Format sync summary for CLI output
50
60
  */
@@ -57,18 +67,24 @@ export function formatSyncSummary(summary) {
57
67
  }
58
68
  lines.push(`Timestamp: ${summary.timestamp}`);
59
69
  lines.push("");
60
- // Entity counts by type
61
- lines.push("Entity Counts:");
62
- const sortedTypes = Object.keys(summary.entityCounts).sort();
63
- if (sortedTypes.length === 0) {
64
- lines.push(" (none)");
70
+ // A sync recompiles only changed sources, so what it imported is a delta;
71
+ // the store totals are what the KB holds now.
72
+ // implements REQ-cli-sync-summary-kb-totals
73
+ const totals = summary.storeTotals;
74
+ if (totals === undefined) {
75
+ lines.push("Entity Counts:");
76
+ pushCounts(lines, summary.entityCounts);
77
+ lines.push(`Total Relationships: ${summary.relationshipCount}`);
65
78
  }
66
79
  else {
67
- for (const type of sortedTypes) {
68
- lines.push(` ${type}: ${summary.entityCounts[type]}`);
69
- }
80
+ const entityTotal = Object.values(totals.entities).reduce((sum, count) => sum + count, 0);
81
+ const imported = Object.values(summary.entityCounts).reduce((sum, count) => sum + count, 0);
82
+ lines.push(`KB Totals: ${entityTotal} entities`);
83
+ pushCounts(lines, totals.entities);
84
+ lines.push(`KB Relationships: ${totals.relationships}`);
85
+ lines.push(`Imported This Sync (changed sources only): ${imported} entities, ${summary.relationshipCount} relationship records`);
86
+ pushCounts(lines, summary.entityCounts);
70
87
  }
71
- lines.push(`Total Relationships: ${summary.relationshipCount}`);
72
88
  lines.push("");
73
89
  lines.push(`Status: ${summary.success ? "✓ Success" : "✗ Failed"}`);
74
90
  lines.push(`Published: ${summary.published ? "Yes" : "No"}`);
@@ -63,6 +63,8 @@ type GraphEdge = Readonly<{
63
63
  }>;
64
64
  /** Workspace file paths the question names in its text, in order, once each. */
65
65
  export declare function questionPaths(query: string): string[];
66
+ /** The signal tokens intent ranking compares (stop words dropped, stemmed). */
67
+ export declare function intentTokens(value: string): readonly string[];
66
68
  /** Markdown bodies already read in this search, keyed by entity source. */
67
69
  export type MarkdownBodyCache = Map<string, string | null>;
68
70
  export declare function rankIntentEntities(entities: readonly Record<string, unknown>[], options: IntentSearchOptions, workspaceRoot: string, graphEdges?: readonly GraphEdge[], bodyCache?: MarkdownBodyCache): Promise<IntentSearchResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"intent-search.d.ts","sourceRoot":"","sources":["../src/intent-search.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,MAAM,MAAM,qBAAqB,GAC7B,QAAQ,GACR,SAAS,GACT,SAAS,GACT,aAAa,GACb,S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G,QAAQ,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC,CAAC;AA6IH,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAQrD;AA6ED,+EAA+E;AAE/E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAE7D;AA8SD,2EAA2E;AAE3E,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AA8B3D,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC5C,OAAO,EAAE,mBAAmB,EAC5B,aAAa,EAAE,MAAM,EACrB,UAAU,GAAE,SAAS,SAAS,EAAO,EACrC,SAAS,GAAE,iBAA6B,GACvC,OAAO,CAAC,kBAAkB,CAAC,CAuJ7B;AAoCD,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAO1E;AA8FD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAoD7B;AAGD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CA0C1E"}
@@ -198,6 +198,11 @@ function tokens(value) {
198
198
  .split(" ")
199
199
  .filter((token) => token.length > 0 && !STOP_WORDS.has(token))));
200
200
  }
201
+ /** The signal tokens intent ranking compares (stop words dropped, stemmed). */
202
+ // implements REQ-kibi-contradiction-review-candidates
203
+ export function intentTokens(value) {
204
+ return tokens(value);
205
+ }
201
206
  // Clause boundaries an agent writes when it packs several questions into one
202
207
  // query: "user roles: how many can a user have, support role".
203
208
  const CLAUSE_SEPARATOR = /[;:,!?\n]+|\.(?=\s|$)|\s[-\u2013\u2014]\s/;
@@ -1,6 +1,12 @@
1
1
  import type { OperationContext } from "../../public/operations/runtime-types.js";
2
2
  import type { ActivationPolicy, Candidate } from "./types.js";
3
3
  export declare function missingManifestActivation(vendored: boolean, projectSignal: boolean): ActivationPolicy;
4
+ /**
5
+ * A legacy `.kb/config.json` without a manifest holds knowledge written by an
6
+ * older Kibi: it is migrated, never initialized, so the first step is the one
7
+ * `kibi doctor` names.
8
+ */
9
+ export declare function legacyKbActivation(): ActivationPolicy;
4
10
  /**
5
11
  * On a seeded KB the plan may hold declared intent claims, already
6
12
  * deduplicated against the existing KB. Such a plan is applicable like a thin
@@ -1 +1 @@
1
- {"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/activation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAGjF,OAAO,KAAK,EAAE,gBAAgB,EAAmB,SAAS,EAAE,MAAM,YAAY,CAAC;AAI/E,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,OAAO,GACrB,gBAAgB,CAIlB;AAkED;;;;GAIG;AAGH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,gBAAgB,CAelB;AAyDD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,gBAAgB,EACzB,KAAK,GAAE,SAAS,MAAM,EAAO,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAyE3B"}
1
+ {"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/activation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAQjF,OAAO,KAAK,EAAE,gBAAgB,EAAmB,SAAS,EAAE,MAAM,YAAY,CAAC;AAI/E,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,OAAO,GACrB,gBAAgB,CAIlB;AAED;;;;GAIG;AAEH,wBAAgB,kBAAkB,IAAI,gBAAgB,CAWrD;AAkED;;;;GAIG;AAGH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,gBAAgB,CAelB;AAyDD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,gBAAgB,EACzB,KAAK,GAAE,SAAS,MAAM,EAAO,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CA8E3B"}
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { LEGACY_KB_MIGRATION_COMMAND, LEGACY_KB_MIGRATION_NOTE, readLegacyKbConfig, } from "../../utils/config.js";
2
3
  import { readKbManifestStatus } from "../../utils/kb-manifest.js";
3
4
  import { KB_PATHS } from "../../utils/kb-paths.js";
4
5
  // implements REQ-KIBI-BOOTSTRAP-PLAN
@@ -6,6 +7,24 @@ import { KB_PATHS } from "../../utils/kb-paths.js";
6
7
  export function missingManifestActivation(vendored, projectSignal) {
7
8
  return activationFor(vendored && !projectSignal ? "vendored_only" : "root_uninitialized");
8
9
  }
10
+ /**
11
+ * A legacy `.kb/config.json` without a manifest holds knowledge written by an
12
+ * older Kibi: it is migrated, never initialized, so the first step is the one
13
+ * `kibi doctor` names.
14
+ */
15
+ // implements REQ-legacy-kb-first-step-migrate
16
+ export function legacyKbActivation() {
17
+ return {
18
+ activationState: "root_partial",
19
+ activationMode: "repair_bootstrap",
20
+ applyBlocked: true,
21
+ allowCandidateGeneration: true,
22
+ allowDeclaredClaims: true,
23
+ reason: `Workspace has a legacy .kb/config.json and no .kb/manifest.json; run \`${LEGACY_KB_MIGRATION_COMMAND}\` (${LEGACY_KB_MIGRATION_NOTE}) before planning bootstrap knowledge.`,
24
+ handoffMessage: `This knowledge base was written by an older Kibi. Run \`${LEGACY_KB_MIGRATION_COMMAND}\` (${LEGACY_KB_MIGRATION_NOTE}), then check kb_status again.`,
25
+ nextOperation: LEGACY_KB_MIGRATION_COMMAND,
26
+ };
27
+ }
9
28
  function activationFor(state) {
10
29
  switch (state) {
11
30
  case "root_uninitialized":
@@ -138,6 +157,9 @@ export async function classifyActivation(context, files = []) {
138
157
  return relative.replaceAll("\\", "/");
139
158
  });
140
159
  const manifestStatus = readKbManifestStatus(context.workspaceRoot);
160
+ if (manifestStatus.state === "missing" &&
161
+ readLegacyKbConfig(context.workspaceRoot).kind !== "none")
162
+ return legacyKbActivation();
141
163
  if (manifestStatus.state === "missing") {
142
164
  const vendored = normalizedFiles.some((file) => file.startsWith("kibi/"));
143
165
  const projectSignalFromFiles = normalizedFiles.some((file) => !file.startsWith("kibi/") &&
@@ -3,6 +3,8 @@ export type ExistingRequirement = {
3
3
  readonly id: string;
4
4
  readonly title: string;
5
5
  readonly semanticText: string;
6
+ /** Whether it has a logical representation; unknown when not loaded. */
7
+ readonly modeled?: boolean;
6
8
  };
7
9
  /**
8
10
  * Token-set Jaccard at or above which a claim that is not an exact
@@ -1 +1 @@
1
- {"version":3,"file":"claim-restatement.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/claim-restatement.ts"],"names":[],"mappings":"AAKA,iEAAiE;AAEjE,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,wBAAwB,MAAsB,CAAC;AAG5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,+CAA+C;I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AC,MAAM,GAAG,SAAS,CAAC,EAAE,EAC3C,YAAY,EAAE,SAAS,mBAAmB,EAAE,GAC3C,gBAAgB,GAAG,IAAI,CAoCzB"}
@@ -0,0 +1,16 @@
1
+ import type { ExistingRequirement } from "./claim-restatement.js";
2
+ import type { Candidate } from "./types.js";
3
+ /**
4
+ * A planned intent claim is checked for contradictions only against current
5
+ * requirements that have a logical representation. For each planned claim,
6
+ * name the current requirements on the same topic that have none, so the
7
+ * reviewer compares them before approval instead of reading the plan as
8
+ * consistent: the diagnostic names both, and the candidate's evidence gains
9
+ * `review_against:<id>` for each. Ranking is the intent search kb_search uses,
10
+ * over the unmodeled requirements only.
11
+ */
12
+ export declare function withConflictReviewSignals(candidates: readonly Candidate[], requirements: readonly ExistingRequirement[], workspaceRoot: string): Promise<{
13
+ candidates: Candidate[];
14
+ diagnostics: string[];
15
+ }>;
16
+ //# sourceMappingURL=conflict-review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conflict-review.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/conflict-review.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;GAQG;AAEH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,YAAY,EAAE,SAAS,mBAAmB,EAAE,EAC5C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAyD7D"}
@@ -0,0 +1,59 @@
1
+ import { rankIntentEntities } from "../../intent-search.js";
2
+ import { MAX_REVIEW_CANDIDATES, REVIEW_CANDIDATE_MIN_SCORE, } from "../planning/conflict-review.js";
3
+ /**
4
+ * A planned intent claim is checked for contradictions only against current
5
+ * requirements that have a logical representation. For each planned claim,
6
+ * name the current requirements on the same topic that have none, so the
7
+ * reviewer compares them before approval instead of reading the plan as
8
+ * consistent: the diagnostic names both, and the candidate's evidence gains
9
+ * `review_against:<id>` for each. Ranking is the intent search kb_search uses,
10
+ * over the unmodeled requirements only.
11
+ */
12
+ // implements REQ-kibi-contradiction-review-candidates
13
+ export async function withConflictReviewSignals(candidates, requirements, workspaceRoot) {
14
+ const unmodeled = requirements
15
+ .filter((requirement) => requirement.modeled === false)
16
+ .map((requirement) => ({
17
+ id: requirement.id,
18
+ type: "req",
19
+ title: requirement.title,
20
+ semantic_text: requirement.semanticText,
21
+ }));
22
+ if (unmodeled.length === 0)
23
+ return { candidates: [...candidates], diagnostics: [] };
24
+ const titles = new Map(requirements.map((requirement) => [requirement.id, requirement.title]));
25
+ const diagnostics = [];
26
+ const reviewed = [];
27
+ for (const candidate of candidates) {
28
+ if (candidate.sourceKind !== "intent_claim" ||
29
+ candidate.entityType !== "req") {
30
+ reviewed.push(candidate);
31
+ continue;
32
+ }
33
+ const ranked = await rankIntentEntities(unmodeled, {
34
+ query: candidate.title,
35
+ type: "req",
36
+ minScore: REVIEW_CANDIDATE_MIN_SCORE,
37
+ }, workspaceRoot);
38
+ const related = ranked.matches
39
+ .slice(0, MAX_REVIEW_CANDIDATES)
40
+ .map((match) => String(match.entity.id ?? ""))
41
+ .filter(Boolean);
42
+ if (related.length === 0) {
43
+ reviewed.push(candidate);
44
+ continue;
45
+ }
46
+ const citation = candidate.evidence
47
+ .find((entry) => entry.startsWith("intent_claim:"))
48
+ ?.slice("intent_claim:".length) ?? candidate.sourcePath;
49
+ diagnostics.push(`conflict-review: Intent claim at ${citation} ("${candidate.title}") was not checked for contradictions against current requirement ${related.map((id) => `${id} ("${titles.get(id) ?? ""}")`).join(", ")}, which has no logical representation. Compare them before approval: on a contradiction show both to the human, then drop the claim or keep it and supersede the requirement after apply; record a conflict the human has not decided as a review:conflict observation fact.`);
50
+ reviewed.push({
51
+ ...candidate,
52
+ evidence: [
53
+ ...candidate.evidence,
54
+ ...related.map((id) => `review_against:${id}`),
55
+ ],
56
+ });
57
+ }
58
+ return { candidates: reviewed, diagnostics };
59
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/generate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAgBjF,OAAO,KAAK,EAGV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAGpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,SAAS,gBAAgB,EAAE,CAI7B;AA+BD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,OAAO,EAAE,MAAM,GACd;IACD,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAwJA;AAmND,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAwI9B"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/generate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAkBjF,OAAO,KAAK,EAGV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAGpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,SAAS,gBAAgB,EAAE,CAI7B;AA+BD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,OAAO,EAAE,MAAM,GACd;IACD,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAwJA;AA6ND,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAgJ9B"}
@@ -3,9 +3,11 @@ import path from "node:path";
3
3
  import { loadCurrentRequirementTexts, loadEntityIds, } from "../../public/operations/discovery-entities.js";
4
4
  import { executeStatus } from "../../public/operations/discovery-executors.js";
5
5
  import { readWorkspaceSnapshot } from "../../public/operations/workspace-snapshot.js";
6
+ import { loadReviewRequirements } from "../planning/conflict-review.js";
6
7
  import { stagedLogicalGroundingError, } from "../semantic-advisor/ingestion-boundary.js";
7
8
  import { claimPlanActivation } from "./activation.js";
8
9
  import { buildBootstrapCandidates, isProvenanceStubCandidate, } from "./candidates.js";
10
+ import { withConflictReviewSignals } from "./conflict-review.js";
9
11
  import { discoverBootstrap } from "./discovery.js";
10
12
  import { buildIntentClaimCandidates } from "./intent-claims.js";
11
13
  import { normalizeBootstrapContext, presentBootstrap } from "./presentation.js";
@@ -250,7 +252,7 @@ const NO_EXISTING_KNOWLEDGE = {
250
252
  * none (the CLI does so for status anyway); an unattached root never starts
251
253
  * one.
252
254
  */
253
- // implements REQ-bootstrap-intent-claim-accounting, REQ-bootstrap-claim-restatement
255
+ // implements REQ-bootstrap-intent-claim-accounting, REQ-bootstrap-claim-restatement, REQ-kibi-contradiction-review-candidates
254
256
  async function existingKnowledge(context, attached, withRequirements) {
255
257
  try {
256
258
  const prolog = context.prolog ?? (attached ? await context.ensureProlog?.() : undefined);
@@ -259,9 +261,16 @@ async function existingKnowledge(context, attached, withRequirements) {
259
261
  // Ids only: materializing every entity (receipt histories included)
260
262
  // just to build this set exceeds the bounded engine output.
261
263
  const ids = new Set((await loadEntityIds(prolog)).filter(Boolean));
262
- const requirements = withRequirements
264
+ const texts = withRequirements
263
265
  ? await loadCurrentRequirementTexts(prolog)
264
266
  : [];
267
+ const logic = await loadReviewRequirements(prolog, texts.map((requirement) => requirement.id));
268
+ const requirements = texts.map((requirement) => ({
269
+ ...requirement,
270
+ ...(logic.has(requirement.id)
271
+ ? { modeled: logic.get(requirement.id)?.modeled === true }
272
+ : {}),
273
+ }));
265
274
  return { ids, requirements };
266
275
  }
267
276
  catch (error) {
@@ -343,7 +352,7 @@ async function expectedSnapshots(context, evidencePaths) {
343
352
  };
344
353
  }
345
354
  }
346
- // implements REQ-KIBI-BOOTSTRAP-PLAN, REQ-kibi-operation-interface-parity, REQ-bootstrap-discovered-candidate-budget
355
+ // implements REQ-KIBI-BOOTSTRAP-PLAN, REQ-kibi-operation-interface-parity, REQ-bootstrap-discovered-candidate-budget, REQ-kibi-contradiction-review-candidates
347
356
  // implements REQ-KIBI-BOOTSTRAP-PLAN
348
357
  export async function executePlanBootstrap(args, context) {
349
358
  const declared = normalizeBootstrapContext(args.bootstrapContext);
@@ -392,8 +401,11 @@ export async function executePlanBootstrap(args, context) {
392
401
  suppressed: activationSuppressedClaims(declared, discovery.activation),
393
402
  diagnostics: [],
394
403
  };
404
+ // Planned claims next to prose-only current requirements name them for
405
+ // review: the plan cannot show they are consistent.
406
+ const reviewSignals = await withConflictReviewSignals(claimed.candidates, existing.requirements, context.workspaceRoot);
395
407
  const filteredSignals = filterSourceOnlySignals([...built.sourceOnlySignals, ...claimed.sourceOnlySignals], args.entityTypes);
396
- const selected = selectBootstrapCandidates([...built.candidates, ...claimed.candidates].filter((candidate) => candidate.confidence >= minConfidence), existingIds, args.entityTypes, maxCandidates);
408
+ const selected = selectBootstrapCandidates([...built.candidates, ...reviewSignals.candidates].filter((candidate) => candidate.confidence >= minConfidence), existingIds, args.entityTypes, maxCandidates);
397
409
  // Claims about the same subject share one subject fact.
398
410
  const shared = shareSubjectFacts(selected.candidates);
399
411
  const ignored = discovery.ignoredSources.map((sourcePath) => ({
@@ -441,6 +453,7 @@ export async function executePlanBootstrap(args, context) {
441
453
  ]
442
454
  : []),
443
455
  ...claimed.diagnostics,
456
+ ...reviewSignals.diagnostics,
444
457
  ...built.diagnostics,
445
458
  ...selected.diagnostics,
446
459
  ...shared.diagnostics,
@@ -113,6 +113,11 @@ export type ActivationPolicy = {
113
113
  readonly allowDeclaredClaims?: boolean;
114
114
  readonly reason: string;
115
115
  readonly handoffMessage?: string;
116
+ /**
117
+ * The command to run first when it is not the activation state's usual
118
+ * next step (a legacy KB is migrated, not initialized or repaired).
119
+ */
120
+ readonly nextOperation?: string;
116
121
  };
117
122
  export type BootstrapEvidence = {
118
123
  readonly provider: EvidenceProviderName;