kibi-cli 2.23.0 → 2.25.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 (78) 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/migrate.d.ts.map +1 -1
  4. package/dist/commands/migrate.js +23 -0
  5. package/dist/decision-firmness.d.ts +16 -4
  6. package/dist/decision-firmness.d.ts.map +1 -1
  7. package/dist/decision-firmness.js +29 -6
  8. package/dist/extractors/markdown.d.ts.map +1 -1
  9. package/dist/extractors/markdown.js +2 -1
  10. package/dist/firm-decision-edit.d.ts +30 -0
  11. package/dist/firm-decision-edit.d.ts.map +1 -0
  12. package/dist/firm-decision-edit.js +90 -0
  13. package/dist/intent-search.d.ts +2 -0
  14. package/dist/intent-search.d.ts.map +1 -1
  15. package/dist/intent-search.js +16 -5
  16. package/dist/operations/bootstrap/candidate-helpers.d.ts +6 -0
  17. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  18. package/dist/operations/bootstrap/candidate-helpers.js +19 -0
  19. package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
  20. package/dist/operations/bootstrap/intent-claims.js +2 -2
  21. package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
  22. package/dist/operations/bootstrap/markdown-candidates.js +2 -2
  23. package/dist/operations/migration/firm-supersede.d.ts +19 -0
  24. package/dist/operations/migration/firm-supersede.d.ts.map +1 -0
  25. package/dist/operations/migration/firm-supersede.js +60 -0
  26. package/dist/operations/migration/schema6.d.ts.map +1 -1
  27. package/dist/operations/migration/schema6.js +41 -0
  28. package/dist/operations/mutation/firm-decision-guard.d.ts +10 -0
  29. package/dist/operations/mutation/firm-decision-guard.d.ts.map +1 -0
  30. package/dist/operations/mutation/firm-decision-guard.js +71 -0
  31. package/dist/operations/mutation/requirement-semantics.d.ts +3 -1
  32. package/dist/operations/mutation/requirement-semantics.d.ts.map +1 -1
  33. package/dist/operations/mutation/requirement-semantics.js +13 -2
  34. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  35. package/dist/operations/mutation/upsert.js +2 -0
  36. package/dist/public/operations/catalog.d.ts +3 -3
  37. package/dist/public/operations/decision-firmness.d.ts +25 -1
  38. package/dist/public/operations/decision-firmness.d.ts.map +1 -1
  39. package/dist/public/operations/decision-firmness.js +134 -8
  40. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  41. package/dist/public/operations/discovery-executors.js +19 -6
  42. package/dist/public/operations/source-path-dangling.js +1 -1
  43. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  44. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  45. package/dist/public/operations/specs/check-rules.generated.js +2 -1
  46. package/dist/public/operations/specs/check.d.ts +1 -1
  47. package/dist/public/operations/specs/mutation-schemas.d.ts +1 -1
  48. package/dist/public/operations/specs/mutation-schemas.js +1 -1
  49. package/dist/public/operations/specs/upsert.d.ts +2 -2
  50. package/dist/public/operations/specs/upsert.js +1 -1
  51. package/dist/public/schemas/entity.js +1 -1
  52. package/dist/public/skills/kibi-bootstrap/SKILL.md +3 -3
  53. package/dist/public/skills/kibi-usage/SKILL.md +36 -14
  54. package/dist/schemas/entity.schema.json +1 -1
  55. package/dist/search-answer.d.ts.map +1 -1
  56. package/dist/search-answer.js +9 -1
  57. package/dist/types/entities.d.ts +2 -2
  58. package/dist/types/entities.d.ts.map +1 -1
  59. package/dist/utils/kb-manifest.d.ts +7 -0
  60. package/dist/utils/kb-manifest.d.ts.map +1 -1
  61. package/dist/utils/kb-manifest.js +6 -0
  62. package/dist/utils/rule-registry.generated.d.ts +5 -0
  63. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  64. package/dist/utils/rule-registry.generated.js +6 -0
  65. package/dist/utils/schema-version.d.ts +1 -1
  66. package/dist/utils/schema-version.d.ts.map +1 -1
  67. package/dist/utils/schema-version.js +3 -1
  68. package/package.json +1 -1
  69. package/src/public/operations/decision-firmness.ts +187 -17
  70. package/src/public/operations/discovery-executors.ts +28 -5
  71. package/src/public/operations/source-path-dangling.ts +1 -1
  72. package/src/public/operations/specs/check-rules.generated.ts +2 -1
  73. package/src/public/operations/specs/mutation-schemas.ts +1 -1
  74. package/src/public/operations/specs/upsert.ts +1 -1
  75. package/src/public/schemas/entity.ts +1 -1
  76. package/src/public/skills/kibi-bootstrap/SKILL.md +3 -3
  77. package/src/public/skills/kibi-usage/SKILL.md +36 -14
  78. package/src/schemas/entity.schema.json +1 -1
@@ -71,7 +71,7 @@ export declare const CLI_OPERATION_METADATA: readonly [{
71
71
  }, {
72
72
  readonly name: "kb_upsert";
73
73
  readonly cliName: "upsert";
74
- readonly description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Pass a sectioned `document.body` when creating a requirement (the statement, then `## Context` stating why it exists, who asked and the source, then `## Source` with the verbatim excerpt) and a prose body for scenarios, tests, ADRs and observation facts; a result warning reports an entity whose body lacks context, and kb_check blocks it under entity-context-missing. Never invent a reason the requester did not give: write 'Reason not stated'. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.";
74
+ readonly description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). An update keeps the properties and relationships it leaves out: send the fields that change (with title and status) and only the links to add. Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Pass a sectioned `document.body` when creating a requirement (the statement, then `## Context` stating why it exists, who asked and the source, then `## Source` with the verbatim excerpt) and a prose body for scenarios, tests, ADRs and observation facts; a result warning reports an entity whose body lacks context, and kb_check blocks it under entity-context-missing. Never invent a reason the requester did not give: write 'Reason not stated'. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.";
75
75
  }, {
76
76
  readonly name: "kb_delete";
77
77
  readonly cliName: "delete";
@@ -85,7 +85,7 @@ export const CLI_OPERATION_METADATA = [
85
85
  {
86
86
  name: "kb_upsert",
87
87
  cliName: "upsert",
88
- description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Pass a sectioned `document.body` when creating a requirement (the statement, then `## Context` stating why it exists, who asked and the source, then `## Source` with the verbatim excerpt) and a prose body for scenarios, tests, ADRs and observation facts; a result warning reports an entity whose body lacks context, and kb_check blocks it under entity-context-missing. Never invent a reason the requester did not give: write 'Reason not stated'. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.",
88
+ description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). An update keeps the properties and relationships it leaves out: send the fields that change (with title and status) and only the links to add. Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Pass a sectioned `document.body` when creating a requirement (the statement, then `## Context` stating why it exists, who asked and the source, then `## Source` with the verbatim excerpt) and a prose body for scenarios, tests, ADRs and observation facts; a result warning reports an entity whose body lacks context, and kb_check blocks it under entity-context-missing. Never invent a reason the requester did not give: write 'Reason not stated'. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.",
89
89
  },
90
90
  {
91
91
  name: "kb_delete",
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mapp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AAO,EAAE,mBAAmB,GAAG,MAAM,CAGzE;AA+WD;;;;;GAKG;AAEH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,GACpC,OAAO,CAOT"}
@@ -85,6 +85,12 @@ const SCHEMA_MIGRATION_STEPS = [
85
85
  to: 9,
86
86
  description: "Accept firmness on requirements and ADRs, and acknowledge in the manifest the current supersedes recorded without a 'Why this changed' section; no source file is rewritten and no reason is invented.",
87
87
  },
88
+ {
89
+ id: "firmness-from-origin-v10",
90
+ from: 9,
91
+ to: 10,
92
+ description: "Read a requirement or ADR without firmness as firm unless an agent wrote it, and acknowledge in the manifest the supersedes of such decisions recorded before; no source file is rewritten and no firmness is written.",
93
+ },
88
94
  ];
89
95
  function migrationStepsFor(fromVersion) {
90
96
  const start = Math.max(0, fromVersion ?? 0);
@@ -410,7 +416,9 @@ export async function migrateCommand(options = {}) {
410
416
  const polarityBackfill = planPolarityValueBackfill(cwd);
411
417
  const bodyContextStep = migrationSteps.some((step) => step.id === "entity-body-context-v8");
412
418
  const decisionFirmnessStep = migrationSteps.some((step) => step.id === "decision-firmness-v9");
419
+ const firmnessFromOriginStep = migrationSteps.some((step) => step.id === "firmness-from-origin-v10");
413
420
  const { mergeSupersedesAcknowledgements, planSupersedesReasonAcknowledgement, } = await import("../operations/migration/supersedes-reason.js");
421
+ const { mergeFirmSupersedeAcknowledgements, planFirmSupersedeAcknowledgement, } = await import("../operations/migration/firm-supersede.js");
414
422
  const { acknowledgedContextIds, applyContextMissingTags, applySemanticTextPins, countByType, planContextMissingTags, planSemanticTextPins, } = await import("../operations/migration/entity-body-context.js");
415
423
  if (options.dryRun) {
416
424
  if (polarityBackfill.length > 0)
@@ -432,6 +440,11 @@ export async function migrateCommand(options = {}) {
432
440
  if (unexplained.length > 0)
433
441
  console.log(`dry run: would acknowledge ${unexplained.length} supersede(s) recorded without a 'Why this changed' section (manifest only; no reason is written).`);
434
442
  }
443
+ if (firmnessFromOriginStep) {
444
+ const firmEdges = planFirmSupersedeAcknowledgement(cwd);
445
+ if (firmEdges.length > 0)
446
+ console.log(`dry run: would acknowledge ${firmEdges.length} supersede(s) of decisions that read as firm from schema 10 (manifest only; no firmness is written).`);
447
+ }
435
448
  if (storagePlan.moves.length > 0) {
436
449
  console.log(`dry run: would move ${storagePlan.moves.length} legacy knowledge file(s) into .kb/:`);
437
450
  for (const move of storagePlan.moves) {
@@ -512,6 +525,9 @@ export async function migrateCommand(options = {}) {
512
525
  const supersedesUnexplained = decisionFirmnessStep
513
526
  ? planSupersedesReasonAcknowledgement(cwd)
514
527
  : [];
528
+ const firmSupersedes = firmnessFromOriginStep
529
+ ? planFirmSupersedeAcknowledgement(cwd)
530
+ : [];
515
531
  const existingManifest = readKbManifest(cwd) ?? defaultKbManifest();
516
532
  writeKbManifest(cwd, {
517
533
  ...existingManifest,
@@ -532,9 +548,16 @@ export async function migrateCommand(options = {}) {
532
548
  supersedesReasonAcknowledged: mergeSupersedesAcknowledgements(existingManifest.supersedesReasonAcknowledged, supersedesUnexplained),
533
549
  }
534
550
  : {}),
551
+ ...(firmSupersedes.length > 0
552
+ ? {
553
+ firmSupersedeAcknowledged: mergeFirmSupersedeAcknowledgements(existingManifest.firmSupersedeAcknowledged, firmSupersedes),
554
+ }
555
+ : {}),
535
556
  });
536
557
  if (supersedesUnexplained.length > 0)
537
558
  console.log(`Acknowledged ${supersedesUnexplained.length} supersede(s) recorded without a 'Why this changed' section; new supersedes must explain themselves.`);
559
+ if (firmSupersedes.length > 0)
560
+ console.log(`Acknowledged ${firmSupersedes.length} supersede(s) of decisions without firmness that read as firm from schema 10; a new replacement of such a decision must be firm.`);
538
561
  const auditRecord = buildMigrationAuditRecord({
539
562
  branch,
540
563
  manifestPath: KB_MANIFEST_RELATIVE,
@@ -1,7 +1,7 @@
1
1
  /** Firmness values, firmest first. */
2
2
  export declare const FIRMNESS_VALUES: readonly ["firm", "default", "exploratory"];
3
3
  export type Firmness = (typeof FIRMNESS_VALUES)[number];
4
- /** The firmness of a decision that does not state one. */
4
+ /** The firmness of an agent-written decision that does not state one. */
5
5
  export declare const DEFAULT_FIRMNESS: Firmness;
6
6
  /** Entity types that carry firmness. */
7
7
  export declare const FIRMNESS_TYPES: readonly ["req", "adr"];
@@ -18,10 +18,22 @@ export declare function supersedeAcknowledgement(from: string, to: string): stri
18
18
  export declare function isFirmness(value: unknown): value is Firmness;
19
19
  export declare function carriesFirmness(type: unknown): boolean;
20
20
  /**
21
- * The firmness a decision is read with: the authored value, else `default`.
22
- * Undefined for types that carry no firmness.
21
+ * The firmness a decision is read with: the authored value, else what its
22
+ * origin implies. A decision an agent wrote (`origin.kind: agent`) without a
23
+ * firmness is a delegated choice, `default`. Any other decision without one
24
+ * (written by a person, imported from their documents, or carried over from
25
+ * before origins were recorded) is theirs, so it reads as `firm`: an agent
26
+ * asks before changing it. Undefined for types that carry no firmness.
23
27
  */
24
- export declare function effectiveFirmness(type: unknown, value: unknown): Firmness | undefined;
28
+ export declare function effectiveFirmness(type: unknown, value: unknown, origin?: unknown): Firmness | undefined;
29
+ /**
30
+ * Whether a decision's firmness comes from its origin rather than an authored
31
+ * `firmness` value. Rules that judge the author's own marking (a firm decision
32
+ * must cite the person's words) apply only to explicit values.
33
+ */
34
+ export declare function firmnessIsImplicit(type: unknown, value: unknown): boolean;
35
+ /** The `kind` of an origin record, or undefined when there is none. */
36
+ export declare function originKind(origin: unknown): string | undefined;
25
37
  /**
26
38
  * The reference that makes a firm decision traceable to a human's words:
27
39
  * `origin.ref`, or `approval_ref` on a requirement.
@@ -1 +1 @@
1
- {"version":3,"file":"decision-firmness.d.ts","sourceRoot":"","sources":["../src/decision-firmness.ts"],"names":[],"mappings":"AA4BA,sCAAsC;AAEtC,eAAO,MAAM,eAAe,6CAA8C,CAAC;AAG3E,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,0DAA0D;AAE1D,eAAO,MAAM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,+DAA+D;AAE/D,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAIxC;;;;GAIG;AAEH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzE;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAK5D;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAKtD;AAED;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,OAAO,GACf,QAAQ,GAAG,SAAS,CAItB;AAED;;;;GAIG;AAEH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAEzE;AAED,uEAAuE;AAEvE,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI9D;AAED;;;GAGG;AAEH,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,MAAM,GAAG,SAAS,CAcrB;AAMD;;;GAGG;AAEH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBxD"}
@@ -26,7 +26,7 @@ import { parseBodySections } from "./entity-body-context.js";
26
26
  /** Firmness values, firmest first. */
27
27
  // implements REQ-kb-decision-firmness
28
28
  export const FIRMNESS_VALUES = ["firm", "default", "exploratory"];
29
- /** The firmness of a decision that does not state one. */
29
+ /** The firmness of an agent-written decision that does not state one. */
30
30
  // implements REQ-kb-decision-firmness
31
31
  export const DEFAULT_FIRMNESS = "default";
32
32
  /** Entity types that carry firmness. */
@@ -59,14 +59,37 @@ export function carriesFirmness(type) {
59
59
  FIRMNESS_TYPES.includes(type));
60
60
  }
61
61
  /**
62
- * The firmness a decision is read with: the authored value, else `default`.
63
- * Undefined for types that carry no firmness.
62
+ * The firmness a decision is read with: the authored value, else what its
63
+ * origin implies. A decision an agent wrote (`origin.kind: agent`) without a
64
+ * firmness is a delegated choice, `default`. Any other decision without one
65
+ * (written by a person, imported from their documents, or carried over from
66
+ * before origins were recorded) is theirs, so it reads as `firm`: an agent
67
+ * asks before changing it. Undefined for types that carry no firmness.
64
68
  */
65
- // implements REQ-kb-decision-firmness
66
- export function effectiveFirmness(type, value) {
69
+ // implements REQ-kb-decision-firmness, REQ-kb-decision-firmness-from-origin
70
+ export function effectiveFirmness(type, value, origin) {
67
71
  if (!carriesFirmness(type))
68
72
  return undefined;
69
- return isFirmness(value) ? value : DEFAULT_FIRMNESS;
73
+ if (isFirmness(value))
74
+ return value;
75
+ return originKind(origin) === "agent" ? DEFAULT_FIRMNESS : "firm";
76
+ }
77
+ /**
78
+ * Whether a decision's firmness comes from its origin rather than an authored
79
+ * `firmness` value. Rules that judge the author's own marking (a firm decision
80
+ * must cite the person's words) apply only to explicit values.
81
+ */
82
+ // implements REQ-kb-decision-firmness-from-origin
83
+ export function firmnessIsImplicit(type, value) {
84
+ return carriesFirmness(type) && !isFirmness(value);
85
+ }
86
+ /** The `kind` of an origin record, or undefined when there is none. */
87
+ // implements REQ-kb-decision-firmness-from-origin
88
+ export function originKind(origin) {
89
+ if (origin === null || typeof origin !== "object")
90
+ return undefined;
91
+ const kind = origin.kind;
92
+ return typeof kind === "string" ? kind : undefined;
70
93
  }
71
94
  /**
72
95
  * The reference that makes a firm decision traceable to a human's words:
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/extractors/markdown.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,KAAK,QAAQ,EAGd,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC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EAAE,eAAe,CAAC;IACxB,aAAa,EAAE,qBAAqB,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAuMD,qBAAa,gBAAiB,SAAQ,KAAK;IAOhC,QAAQ,EAAE,MAAM;IANlB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;gBAG5B,OAAO,EAAE,MAAM,EACR,QAAQ,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;IAYM,QAAQ;CAUlB;AA2DD;;;;;GAKG;AAEH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQlE;AAED;;;;;GAKG;AAEH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAeD,wBAAgB,sBAAsB,CAEpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAkDV;AAiiBD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAElB;AAGD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAatE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASjE;AASD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQpE"}
@@ -521,7 +521,8 @@ function extractFromMarkdownContent(content, filePath) {
521
521
  entity.rationale = data.rationale;
522
522
  }
523
523
  // implements REQ-kb-decision-firmness
524
- // How firmly a requirement or ADR was decided; absent reads as default.
524
+ // How firmly a requirement or ADR was decided; when absent, readers derive
525
+ // it from the origin (default for an agent's write, else firm).
525
526
  if (data.firmness !== undefined) {
526
527
  if (!carriesFirmness(type) || !isFirmness(data.firmness)) {
527
528
  throw new FrontmatterError(carriesFirmness(type)
@@ -0,0 +1,30 @@
1
+ /** A requirement or ADR as authored: front matter and Markdown body. */
2
+ export type DecisionDocument = Readonly<{
3
+ type: string;
4
+ data: Readonly<Record<string, unknown>>;
5
+ body: string;
6
+ }>;
7
+ /** The parts of a decision's claim an in-place edit may change. */
8
+ export type DecisionClaimField = "title" | "statement" | "body" | "firmness";
9
+ /**
10
+ * The claim fields that differ between two versions of one decision. A
11
+ * requirement's claim is its title, its stated meaning and the statement its
12
+ * body derives (context sections may change freely); an ADR's claim is its
13
+ * title and whole body. Lowering a firm decision's firmness changes it too.
14
+ */
15
+ export declare function decisionClaimChanges(before: DecisionDocument, after: DecisionDocument): DecisionClaimField[];
16
+ /**
17
+ * Whether `after` cites human words `before` did not: the reference a person
18
+ * gave for this change. Kibi checks that a new reference is present, not that
19
+ * it is genuine.
20
+ */
21
+ export declare function citesNewHumanWords(before: DecisionDocument, after: DecisionDocument): boolean;
22
+ /**
23
+ * The claim fields an edit changes on a firm decision without citing new
24
+ * human words; empty when the edit is allowed. Only a decision that is firm
25
+ * before the edit is guarded.
26
+ */
27
+ export declare function unapprovedFirmEdit(before: DecisionDocument, after: DecisionDocument): DecisionClaimField[];
28
+ /** What to do instead of editing a firm decision in place. */
29
+ export declare function firmEditGuidance(type: string): string;
30
+ //# sourceMappingURL=firm-decision-edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firm-decision-edit.d.ts","sourceRoot":"","sources":["../src/firm-decision-edit.ts"],"names":[],"mappings":"AAqBA,wEAAwE;AAExE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,mEAAmE;AAEnE,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;AAiB7E;;;;;GAKG;AAEH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,gBAAgB,GACtB,kBAAkB,EAAE,CAsBtB;AAED;;;;GAIG;AAEH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAMT;AAED;;;;GAIG;AAEH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,gBAAgB,GACtB,kBAAkB,EAAE,CAStB;AAED,8DAA8D;AAE9D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -0,0 +1,90 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { effectiveFirmness, firmnessRef } from "./decision-firmness.js";
19
+ import { requirementSemanticText } from "./extractors/markdown.js";
20
+ function normalized(value) {
21
+ return typeof value === "string" ? value.replace(/\s+/g, " ").trim() : "";
22
+ }
23
+ /**
24
+ * What a requirement states: its authored `semantic_text`, else the
25
+ * statement its body derives. Context sections are not part of it.
26
+ */
27
+ function requirementStatement(document) {
28
+ const authored = normalized(document.data.semantic_text);
29
+ return authored !== ""
30
+ ? authored
31
+ : normalized(requirementSemanticText(document.body));
32
+ }
33
+ /**
34
+ * The claim fields that differ between two versions of one decision. A
35
+ * requirement's claim is its title, its stated meaning and the statement its
36
+ * body derives (context sections may change freely); an ADR's claim is its
37
+ * title and whole body. Lowering a firm decision's firmness changes it too.
38
+ */
39
+ // implements REQ-kb-firm-decision-edit
40
+ export function decisionClaimChanges(before, after) {
41
+ const changed = [];
42
+ if (normalized(before.data.title) !== normalized(after.data.title))
43
+ changed.push("title");
44
+ if (before.type === "req") {
45
+ if (requirementStatement(before) !== requirementStatement(after) ||
46
+ normalized(requirementSemanticText(before.body)) !==
47
+ normalized(requirementSemanticText(after.body)))
48
+ changed.push("statement");
49
+ }
50
+ else if (normalized(before.body) !== normalized(after.body)) {
51
+ changed.push("body");
52
+ }
53
+ if (effectiveFirmness(before.type, before.data.firmness, before.data.origin) ===
54
+ "firm" &&
55
+ effectiveFirmness(after.type, after.data.firmness, after.data.origin) !==
56
+ "firm")
57
+ changed.push("firmness");
58
+ return changed;
59
+ }
60
+ /**
61
+ * Whether `after` cites human words `before` did not: the reference a person
62
+ * gave for this change. Kibi checks that a new reference is present, not that
63
+ * it is genuine.
64
+ */
65
+ // implements REQ-kb-firm-decision-edit
66
+ export function citesNewHumanWords(before, after) {
67
+ const ref = firmnessRef({ type: after.type, ...after.data });
68
+ return (ref !== undefined &&
69
+ ref !== firmnessRef({ type: before.type, ...before.data }));
70
+ }
71
+ /**
72
+ * The claim fields an edit changes on a firm decision without citing new
73
+ * human words; empty when the edit is allowed. Only a decision that is firm
74
+ * before the edit is guarded.
75
+ */
76
+ // implements REQ-kb-firm-decision-edit
77
+ export function unapprovedFirmEdit(before, after) {
78
+ if (effectiveFirmness(before.type, before.data.firmness, before.data.origin) !==
79
+ "firm")
80
+ return [];
81
+ const changed = decisionClaimChanges(before, after);
82
+ if (changed.length === 0 || citesNewHumanWords(before, after))
83
+ return [];
84
+ return changed;
85
+ }
86
+ /** What to do instead of editing a firm decision in place. */
87
+ // implements REQ-kb-firm-decision-edit
88
+ export function firmEditGuidance(type) {
89
+ return `Ask the person who stated it. If they agree, either write the change with ${type === "req" ? "origin.ref or approval_ref" : "origin.ref"} pointing at their words, or supersede it with a new firmness: firm decision that cites them; otherwise leave it and propose the change`;
90
+ }
@@ -61,6 +61,8 @@ type GraphEdge = Readonly<{
61
61
  from: string;
62
62
  to: string;
63
63
  }>;
64
+ /** Workspace file paths the question names in its text, in order, once each. */
65
+ export declare function questionPaths(query: string): string[];
64
66
  /** Markdown bodies already read in this search, keyed by entity source. */
65
67
  export type MarkdownBodyCache = Map<string, string | null>;
66
68
  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,SAAS,CAAC;AAGd,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CACvC,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAC1D,CAAC;AAGF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC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AE,mBAAmB,EAC5B,aAAa,EAAE,MAAM,EACrB,UAAU,GAAE,SAAS,SAAS,EAAO,EACrC,SAAS,GAAE,iBAA6B,GACvC,OAAO,CAAC,kBAAkB,CAAC,CAqJ7B;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"}
@@ -128,14 +128,25 @@ function splitIdentifier(identifier) {
128
128
  function expandIdentifiers(value) {
129
129
  return value.replace(CAMEL_IDENTIFIER, (identifier) => `${identifier} ${splitIdentifier(identifier)}`);
130
130
  }
131
+ // A workspace file path written in the question: at least one directory
132
+ // and a file extension ("src/app/auth.service.ts"), not a URL.
133
+ const QUESTION_PATH = /(?<![\w:/.-])(?:\.{1,2}\/)?(?:[\w@~+-][\w@.~+-]*\/)+[\w@~+-][\w@.~+-]*\.[A-Za-z0-9]{1,8}(?![\w/])/g;
134
+ // implements REQ-kibi-intent-aware-source-discovery
135
+ /** Workspace file paths the question names in its text, in order, once each. */
136
+ export function questionPaths(query) {
137
+ return [
138
+ ...new Set([...query.matchAll(QUESTION_PATH)].map((match) => match[0].replace(/^\.\//, ""))),
139
+ ];
140
+ }
131
141
  /**
132
- * The question's topic text: identifiers expanded, and the paths it also
133
- * passes as `sourceLocations` removed. Those paths already reach the
134
- * search as source evidence; their words ("src", "services", "ts") are not
135
- * the topic and would only dilute the words that are.
142
+ * The question's topic text: identifiers expanded, and file paths removed,
143
+ * both the ones it passes as `sourceLocations` and the ones written in the
144
+ * question. A path's words ("src", "services", "ts") are not the topic and
145
+ * would only dilute the words that are; `sourceLocations` is how a path
146
+ * reaches the search as source evidence.
136
147
  */
137
148
  function topicText(query, locations = []) {
138
- let topic = query;
149
+ let topic = query.replace(QUESTION_PATH, " ");
139
150
  for (const location of locations) {
140
151
  const located = location.path.replace(/^\.\//, "");
141
152
  if (located.length > 0)
@@ -15,6 +15,12 @@ export declare function strictPlan(writeSet: StrictWriteSet): readonly Readonly<
15
15
  * more than its front matter.
16
16
  */
17
17
  export declare function withDocumentBody(step: Readonly<Record<string, unknown>>, body: string): Readonly<Record<string, unknown>>;
18
+ /**
19
+ * Record a requirement bootstrap read from a person's document as theirs: an
20
+ * import with a reference to the passage, and `firmness: firm`, so an agent
21
+ * asks before changing it instead of treating it as its own default choice.
22
+ */
23
+ export declare function asImportedRule(step: Readonly<Record<string, unknown>>, ref: string): Readonly<Record<string, unknown>>;
18
24
  /**
19
25
  * Where a deterministic bootstrap provider found an entry. No reason was
20
26
  * stated in the source, so the sentence records provenance instead of
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-helpers.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/candidate-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAIrE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,CAMtD;AAED,wBAAgB,MAAM,CACpB,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,CAAA;CAAE,EAE5D,MAAM,EAAE,CAAC,EACT,aAAa,GAAE,SAAS;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,EAAO,GACP,QAAQ,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B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,CAMR"}
@@ -69,6 +69,25 @@ export function strictPlan(writeSet) {
69
69
  export function withDocumentBody(step, body) {
70
70
  return { ...step, document: { body } };
71
71
  }
72
+ /**
73
+ * Record a requirement bootstrap read from a person's document as theirs: an
74
+ * import with a reference to the passage, and `firmness: firm`, so an agent
75
+ * asks before changing it instead of treating it as its own default choice.
76
+ */
77
+ // implements REQ-kb-decision-firmness
78
+ export function asImportedRule(step, ref) {
79
+ const properties = step.properties !== null && typeof step.properties === "object"
80
+ ? step.properties
81
+ : {};
82
+ return {
83
+ ...step,
84
+ properties: {
85
+ ...properties,
86
+ origin: { kind: "import", ref },
87
+ firmness: "firm",
88
+ },
89
+ };
90
+ }
72
91
  /**
73
92
  * Where a deterministic bootstrap provider found an entry. No reason was
74
93
  * stated in the source, so the sentence records provenance instead of
@@ -1 +1 @@
1
- {"version":3,"file":"intent-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/intent-claims.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,wBAAwB,EAGxB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAyOF;;;;;;;GAOG;AAEH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,kBAAkB,GAC/B,sBAAsB,CAyKxB"}
1
+ {"version":3,"file":"intent-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/intent-claims.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,wBAAwB,EAGxB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAyOF;;;;;;;GAOG;AAEH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,kBAAkB,GAC/B,sBAAsB,CA4KxB"}
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { renderRequirementBody } from "../../entity-body-context.js";
3
3
  import { buildStrictWriteSet } from "../../utils/strict-modeling.js";
4
- import { confidenceBand, strictPlan, upsert } from "./candidate-helpers.js";
4
+ import { asImportedRule, confidenceBand, strictPlan, upsert, } from "./candidate-helpers.js";
5
5
  import { claimFor, planSubjectKey, } from "./requirement-claims.js";
6
6
  /** How much a claim is trusted follows the authority the human assigned. */
7
7
  const AUTHORITY_CONFIDENCE = {
@@ -298,7 +298,7 @@ export function buildIntentClaimCandidates(declared, existingIds, minConfidence,
298
298
  to,
299
299
  })),
300
300
  applyPlan: strictPlan(writeSet).map((step) => step.type === "req"
301
- ? withClaimBody(withRationale(step, claim.rationale), claimBody(source, claim))
301
+ ? withClaimBody(asImportedRule(withRationale(step, claim.rationale), provenance), claimBody(source, claim))
302
302
  : step),
303
303
  });
304
304
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/markdown-candidates.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;CACnE,CAAC;AAyGF;;;;GAIG;AAEH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAYpB;AA4FD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,kBAAkB,GAC/B,oBAAoB,CAoFtB"}
1
+ {"version":3,"file":"markdown-candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/markdown-candidates.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;CACnE,CAAC;AAyGF;;;;GAIG;AAEH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAYpB;AA4FD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,kBAAkB,GAC/B,oBAAoB,CAoFtB"}
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { buildStrictWriteSet } from "../../utils/strict-modeling.js";
3
- import { bootstrapProvenance, confidenceBand, provenanceBody, provenanceRequirementBody, slug, strictPlan, upsert, withDocumentBody, } from "./candidate-helpers.js";
3
+ import { asImportedRule, bootstrapProvenance, confidenceBand, provenanceBody, provenanceRequirementBody, slug, strictPlan, upsert, withDocumentBody, } from "./candidate-helpers.js";
4
4
  import { claimFor, normalizeClaimStatement, planSubjectKey, } from "./requirement-claims.js";
5
5
  function headingSignals(heading, sourcePath, textRef, minConfidence) {
6
6
  const result = [];
@@ -150,7 +150,7 @@ function requirementCandidate(item, statement, line, heading, headingLine, exist
150
150
  to,
151
151
  })),
152
152
  applyPlan: strictPlan(writeSet).map((step) => step.type === "req"
153
- ? withDocumentBody(step, provenanceRequirementBody(statement, bootstrapProvenance("generic markdown", `${relativePath} line ${line}${heading ? ` under the heading "${heading}"` : ""}`, confidence), `${relativePath}#L${line}`))
153
+ ? withDocumentBody(asImportedRule(step, `${relativePath}#L${line}`), provenanceRequirementBody(statement, bootstrapProvenance("generic markdown", `${relativePath} line ${line}${heading ? ` under the heading "${heading}"` : ""}`, confidence), `${relativePath}#L${line}`))
154
154
  : step),
155
155
  };
156
156
  }
@@ -0,0 +1,19 @@
1
+ /** Migration action code for the schema 10 acknowledgement. */
2
+ export declare const FIRM_SUPERSEDE_ACKNOWLEDGE_CODE = "firm_supersede_acknowledge";
3
+ /**
4
+ * Supersede edges recorded before schema 10 that replace a decision which
5
+ * now reads as firm from its origin, by a decision that is not firm, and
6
+ * that the manifest does not acknowledge yet. Nothing in the sources
7
+ * changes: the manifest only records that these supersedes predate the
8
+ * rule. Read-only.
9
+ */
10
+ export declare function planFirmSupersedeAcknowledgement(workspaceRoot: string): string[];
11
+ /** The manifest list with the edges added, sorted and unique. */
12
+ export declare function mergeFirmSupersedeAcknowledgements(existing: readonly string[] | undefined, edges: readonly string[]): string[];
13
+ /**
14
+ * Record the acknowledged edges in the manifest; returns how many edges
15
+ * were acknowledged. Without a manifest there is no schema to upgrade from,
16
+ * so it refuses rather than report an acknowledgement it did not write.
17
+ */
18
+ export declare function applyFirmSupersedeAcknowledgement(workspaceRoot: string): number;
19
+ //# sourceMappingURL=firm-supersede.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firm-supersede.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/firm-supersede.ts"],"names":[],"mappings":"AAyBA,+DAA+D;AAE/D,eAAO,MAAM,+BAA+B,+BAA+B,CAAC;AAE5E;;;;;;GAMG;AAEH,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,GACpB,MAAM,EAAE,CASV;AAED,iEAAiE;AAEjE,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EACvC,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,EAAE,CAEV;AAED;;;;GAIG;AAEH,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,MAAM,GACpB,MAAM,CAiBR"}
@@ -0,0 +1,60 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { authoredSupersedes, implicitFirmSupersedes, listDecisionEntities, } from "../../public/operations/decision-firmness.js";
19
+ import { readKbManifest, writeKbManifest } from "../../utils/kb-manifest.js";
20
+ /** Migration action code for the schema 10 acknowledgement. */
21
+ // implements REQ-kb-decision-firmness-from-origin, REQ-cli-schema-migration
22
+ export const FIRM_SUPERSEDE_ACKNOWLEDGE_CODE = "firm_supersede_acknowledge";
23
+ /**
24
+ * Supersede edges recorded before schema 10 that replace a decision which
25
+ * now reads as firm from its origin, by a decision that is not firm, and
26
+ * that the manifest does not acknowledge yet. Nothing in the sources
27
+ * changes: the manifest only records that these supersedes predate the
28
+ * rule. Read-only.
29
+ */
30
+ // implements REQ-kb-decision-firmness-from-origin, REQ-cli-schema-migration
31
+ export function planFirmSupersedeAcknowledgement(workspaceRoot) {
32
+ const entities = listDecisionEntities(workspaceRoot);
33
+ const known = new Set(readKbManifest(workspaceRoot)?.firmSupersedeAcknowledged ?? []);
34
+ return implicitFirmSupersedes(entities, authoredSupersedes(workspaceRoot, entities)).filter((edge) => !known.has(edge));
35
+ }
36
+ /** The manifest list with the edges added, sorted and unique. */
37
+ // implements REQ-kb-decision-firmness-from-origin
38
+ export function mergeFirmSupersedeAcknowledgements(existing, edges) {
39
+ return [...new Set([...(existing ?? []), ...edges])].sort();
40
+ }
41
+ /**
42
+ * Record the acknowledged edges in the manifest; returns how many edges
43
+ * were acknowledged. Without a manifest there is no schema to upgrade from,
44
+ * so it refuses rather than report an acknowledgement it did not write.
45
+ */
46
+ // implements REQ-kb-decision-firmness-from-origin, REQ-cli-schema-migration
47
+ export function applyFirmSupersedeAcknowledgement(workspaceRoot) {
48
+ const edges = planFirmSupersedeAcknowledgement(workspaceRoot);
49
+ if (edges.length === 0)
50
+ return 0;
51
+ const manifest = readKbManifest(workspaceRoot);
52
+ if (manifest === null) {
53
+ throw new Error("Cannot acknowledge existing supersedes without .kb/manifest.json; run 'kibi migrate --yes', which writes the manifest and the acknowledgement together.");
54
+ }
55
+ writeKbManifest(workspaceRoot, {
56
+ ...manifest,
57
+ firmSupersedeAcknowledged: mergeFirmSupersedeAcknowledgements(manifest.firmSupersedeAcknowledged, edges),
58
+ });
59
+ return edges.length;
60
+ }