kibi-cli 2.25.0 → 2.26.2

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 (102) hide show
  1. package/dist/cli-errors.d.ts +14 -0
  2. package/dist/cli-errors.d.ts.map +1 -1
  3. package/dist/cli-errors.js +31 -0
  4. package/dist/commands/check.d.ts.map +1 -1
  5. package/dist/commands/check.js +28 -0
  6. package/dist/commands/migrate.d.ts +2 -0
  7. package/dist/commands/migrate.d.ts.map +1 -1
  8. package/dist/commands/migrate.js +125 -6
  9. package/dist/commands/sync/cache.d.ts +30 -0
  10. package/dist/commands/sync/cache.d.ts.map +1 -1
  11. package/dist/commands/sync/cache.js +61 -0
  12. package/dist/commands/sync/extraction.d.ts +6 -0
  13. package/dist/commands/sync/extraction.d.ts.map +1 -1
  14. package/dist/commands/sync/extraction.js +4 -1
  15. package/dist/commands/sync.d.ts.map +1 -1
  16. package/dist/commands/sync.js +27 -1
  17. package/dist/intent-search.d.ts.map +1 -1
  18. package/dist/intent-search.js +14 -3
  19. package/dist/operations/bootstrap/claim-restatement.d.ts +37 -0
  20. package/dist/operations/bootstrap/claim-restatement.d.ts.map +1 -0
  21. package/dist/operations/bootstrap/claim-restatement.js +83 -0
  22. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  23. package/dist/operations/bootstrap/generate.js +23 -12
  24. package/dist/operations/bootstrap/intent-claims.d.ts +5 -2
  25. package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
  26. package/dist/operations/bootstrap/intent-claims.js +44 -4
  27. package/dist/operations/migration/requirement-status.d.ts +41 -2
  28. package/dist/operations/migration/requirement-status.d.ts.map +1 -1
  29. package/dist/operations/migration/requirement-status.js +75 -7
  30. package/dist/operations/migration/schema6.d.ts +9 -5
  31. package/dist/operations/migration/schema6.d.ts.map +1 -1
  32. package/dist/operations/migration/schema6.js +82 -13
  33. package/dist/operations/migration/symbol-coordinates-refresh.d.ts +36 -0
  34. package/dist/operations/migration/symbol-coordinates-refresh.d.ts.map +1 -0
  35. package/dist/operations/migration/symbol-coordinates-refresh.js +99 -0
  36. package/dist/operations/mutation/source-authoring.d.ts +9 -0
  37. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  38. package/dist/operations/mutation/source-authoring.js +50 -2
  39. package/dist/operations/mutation/stored-entity.d.ts +5 -0
  40. package/dist/operations/mutation/stored-entity.d.ts.map +1 -1
  41. package/dist/operations/mutation/types.d.ts +1 -1
  42. package/dist/operations/mutation/types.d.ts.map +1 -1
  43. package/dist/operations/mutation/uncompiled-source.d.ts +43 -0
  44. package/dist/operations/mutation/uncompiled-source.d.ts.map +1 -0
  45. package/dist/operations/mutation/uncompiled-source.js +115 -0
  46. package/dist/operations/mutation/upsert.d.ts +6 -0
  47. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  48. package/dist/operations/mutation/upsert.js +32 -5
  49. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  50. package/dist/operations/planning/apply-plan.js +4 -2
  51. package/dist/public/impact/analyzer.d.ts.map +1 -1
  52. package/dist/public/impact/analyzer.js +13 -3
  53. package/dist/public/impact/diagnostics.js +1 -1
  54. package/dist/public/impact/unowned-files.d.ts +31 -0
  55. package/dist/public/impact/unowned-files.d.ts.map +1 -0
  56. package/dist/public/impact/unowned-files.js +171 -0
  57. package/dist/public/operations/catalog.d.ts +2 -2
  58. package/dist/public/operations/discovery-entities.d.ts +11 -0
  59. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  60. package/dist/public/operations/discovery-entities.js +28 -0
  61. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  62. package/dist/public/operations/discovery-executors.js +13 -1
  63. package/dist/public/operations/migration-plan.d.ts +25 -0
  64. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  65. package/dist/public/operations/migration-plan.js +40 -0
  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 +1 -0
  69. package/dist/public/operations/source-relationship-parity.d.ts.map +1 -1
  70. package/dist/public/operations/source-relationship-parity.js +22 -7
  71. package/dist/public/operations/specs/check.d.ts +1 -1
  72. package/dist/public/operations/specs/check.js +1 -1
  73. package/dist/public/operations/specs/upsert.d.ts +1 -1
  74. package/dist/public/operations/specs/upsert.js +1 -1
  75. package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
  76. package/dist/public/skills/kibi-usage/SKILL.md +11 -5
  77. package/dist/search-answer.d.ts +9 -0
  78. package/dist/search-answer.d.ts.map +1 -1
  79. package/dist/search-answer.js +66 -3
  80. package/dist/traceability/git-change-snapshot.d.ts.map +1 -1
  81. package/dist/traceability/git-change-snapshot.js +44 -3
  82. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  83. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  84. package/dist/traceability/staged-migration.d.ts +13 -0
  85. package/dist/traceability/staged-migration.d.ts.map +1 -0
  86. package/dist/traceability/staged-migration.js +59 -0
  87. package/dist/traceability/staged-symbols-manifest.d.ts +11 -0
  88. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  89. package/dist/traceability/staged-symbols-manifest.js +50 -16
  90. package/package.json +2 -2
  91. package/src/public/impact/analyzer.ts +21 -7
  92. package/src/public/impact/diagnostics.ts +1 -1
  93. package/src/public/impact/unowned-files.ts +229 -0
  94. package/src/public/operations/discovery-entities.ts +36 -0
  95. package/src/public/operations/discovery-executors.ts +17 -1
  96. package/src/public/operations/migration-plan.ts +72 -0
  97. package/src/public/operations/result-envelope.ts +3 -0
  98. package/src/public/operations/source-relationship-parity.ts +22 -7
  99. package/src/public/operations/specs/check.ts +1 -1
  100. package/src/public/operations/specs/upsert.ts +1 -1
  101. package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
  102. package/src/public/skills/kibi-usage/SKILL.md +11 -5
@@ -9,7 +9,7 @@ export type UpsertInput = {
9
9
  readonly document?: {
10
10
  /** Workspace-relative authored source target. */
11
11
  readonly path?: string;
12
- /** Complete document bytes. Omit to preserve the existing body bytes. */
12
+ /** Complete document bytes. Omit to preserve the existing body (a changed requirement semantic_text replaces its statement). */
13
13
  readonly body?: string;
14
14
  };
15
15
  /** Validate and preview the write without mutating the KB. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAGlE,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,iDAAiD;QACjD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,yEAAyE;QACzE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAGF,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,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AE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;QAC/D,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS;YAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;YAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;YACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;SACxB,EAAE,CAAC;QACJ,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;KACxC,CAAC;CACH,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { OperationContext } from "../../public/operations/runtime-types.js";
2
+ import type { StoredEntityLookup } from "./stored-entity.js";
3
+ import type { RelationshipInput, UpsertInput } from "./types.js";
4
+ /**
5
+ * An authored document for an entity the compiled store does not hold: the
6
+ * file the source-first writer would merge an upsert into.
7
+ */
8
+ export type UncompiledAuthoredSource = Readonly<{
9
+ /** Workspace-relative path. */
10
+ path: string;
11
+ absolute: string;
12
+ content: string;
13
+ /**
14
+ * The entity as its file states it: the extracted entity when the file
15
+ * compiles, its front matter when it does not.
16
+ */
17
+ stored: Readonly<Record<string, unknown>>;
18
+ /** Why kibi sync cannot compile the file as authored; null when it can. */
19
+ extractionError: string | null;
20
+ }>;
21
+ /**
22
+ * The authored document an upsert of `input` would merge into although the
23
+ * store does not hold the entity: a file left out of the last sync (one sync
24
+ * could not extract, or one written since). Null when the writer would
25
+ * create a new file, writes a symbol manifest, or the file declares another
26
+ * entity. A file whose front matter does not parse is refused here: the
27
+ * writer could not merge into it either.
28
+ */
29
+ export declare function readUncompiledAuthoredSource(context: OperationContext, input: UpsertInput): Promise<UncompiledAuthoredSource | null>;
30
+ /**
31
+ * The store lookup for an upsert whose entity exists only in its authored
32
+ * file: the file's own state is what the write changes, so the stored
33
+ * ledger, origin and firmness checks read it.
34
+ */
35
+ export declare function authoredEntityLookup(source: UncompiledAuthoredSource): StoredEntityLookup;
36
+ /**
37
+ * Render the document the writer will leave and extract it as kibi sync
38
+ * will. A write that leaves the file uncompilable is refused, naming the
39
+ * file and the error, because the entity would stay invisible to every
40
+ * store-backed tool. Returns the relationships the written file declares.
41
+ */
42
+ export declare function assertAuthoredWriteCompiles(source: UncompiledAuthoredSource, input: UpsertInput, entity: Readonly<Record<string, unknown>>): readonly RelationshipInput[];
43
+ //# sourceMappingURL=uncompiled-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uncompiled-source.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/uncompiled-source.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAMjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE;;;GAGG;AAEH,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1C,2EAA2E;IAC3E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC,CAAC;AAMH;;;;;;;GAOG;AAEH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CA8C1C;AAED;;;;GAIG;AAEH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,wBAAwB,GAC/B,kBAAkB,CAKpB;AAED;;;;;GAKG;AAEH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,wBAAwB,EAChC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,SAAS,iBAAiB,EAAE,CAa9B"}
@@ -0,0 +1,115 @@
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 path from "node:path";
19
+ import { sourceExtractionRemediation } from "../../commands/sync/cache.js";
20
+ import { extractFromMarkdownString } from "../../extractors/markdown.js";
21
+ import { authoredFrontmatter, newEntitySourceTarget, renderSourceDocument, } from "./source-authoring.js";
22
+ function errorText(error) {
23
+ return error instanceof Error ? error.message : String(error);
24
+ }
25
+ /**
26
+ * The authored document an upsert of `input` would merge into although the
27
+ * store does not hold the entity: a file left out of the last sync (one sync
28
+ * could not extract, or one written since). Null when the writer would
29
+ * create a new file, writes a symbol manifest, or the file declares another
30
+ * entity. A file whose front matter does not parse is refused here: the
31
+ * writer could not merge into it either.
32
+ */
33
+ // implements REQ-kibi-uncompiled-source-visibility
34
+ export async function readUncompiledAuthoredSource(context, input) {
35
+ if (context.fs === undefined || context.sourceFirst === false)
36
+ return null;
37
+ if (input.type === "symbol")
38
+ return null;
39
+ const absolute = newEntitySourceTarget(context, input);
40
+ if (absolute === undefined || !/\.mdx?$/i.test(absolute))
41
+ return null;
42
+ let content;
43
+ try {
44
+ content = await context.fs.readFile(absolute);
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ const relative = path
50
+ .relative(context.workspaceRoot, absolute)
51
+ .replaceAll(path.sep, "/");
52
+ try {
53
+ const { entity } = extractFromMarkdownString(content, absolute);
54
+ if (entity.id !== input.id)
55
+ return null;
56
+ return {
57
+ path: relative,
58
+ absolute,
59
+ content,
60
+ stored: entity,
61
+ extractionError: null,
62
+ };
63
+ }
64
+ catch (error) {
65
+ const extractionError = errorText(error);
66
+ let frontmatter;
67
+ try {
68
+ frontmatter = authoredFrontmatter(content);
69
+ }
70
+ catch (parseError) {
71
+ throw new Error(`Upsert of ${input.id} refused: ${relative} exists but kibi sync cannot compile it (${extractionError}), and its front matter does not parse (${errorText(parseError)}), so the write cannot merge into it. Fix the front matter of ${relative}, run kibi sync, then retry.`);
72
+ }
73
+ if (frontmatter.id !== undefined && frontmatter.id !== input.id)
74
+ return null;
75
+ if (frontmatter.type !== undefined && frontmatter.type !== input.type)
76
+ return null;
77
+ return {
78
+ path: relative,
79
+ absolute,
80
+ content,
81
+ stored: { ...frontmatter, id: input.id, type: input.type },
82
+ extractionError,
83
+ };
84
+ }
85
+ }
86
+ /**
87
+ * The store lookup for an upsert whose entity exists only in its authored
88
+ * file: the file's own state is what the write changes, so the stored
89
+ * ledger, origin and firmness checks read it.
90
+ */
91
+ // implements REQ-kibi-uncompiled-source-visibility
92
+ export function authoredEntityLookup(source) {
93
+ return {
94
+ exists: async () => true,
95
+ entity: async () => source.stored,
96
+ };
97
+ }
98
+ /**
99
+ * Render the document the writer will leave and extract it as kibi sync
100
+ * will. A write that leaves the file uncompilable is refused, naming the
101
+ * file and the error, because the entity would stay invisible to every
102
+ * store-backed tool. Returns the relationships the written file declares.
103
+ */
104
+ // implements REQ-kibi-uncompiled-source-visibility
105
+ export function assertAuthoredWriteCompiles(source, input, entity) {
106
+ let after;
107
+ try {
108
+ after = renderSourceDocument(input, entity, source.content, source.path);
109
+ return extractFromMarkdownString(after, source.absolute).relationships.map((relationship) => ({ ...relationship }));
110
+ }
111
+ catch (error) {
112
+ const message = errorText(error);
113
+ throw new Error(`Upsert of ${input.id} refused: ${input.id} exists in ${source.path} but is not compiled${source.extractionError === null ? "" : ` (${source.extractionError})`}, and this write would leave the file uncompilable: ${message}. ${sourceExtractionRemediation(source.path, message)}`);
114
+ }
115
+ }
@@ -3,6 +3,7 @@ import type { OperationResult } from "../../public/operations/types.js";
3
3
  import type { SemanticAdvisorReceipt } from "../semantic-advisor/types.js";
4
4
  import { type StoredEntityLookup } from "./stored-entity.js";
5
5
  import type { RelationshipInput, StagedUpsertState, UpsertInput, UpsertPayload, ValidatedUpsert } from "./types.js";
6
+ import { type UncompiledAuthoredSource } from "./uncompiled-source.js";
6
7
  export declare function assertRelationshipShardContained(workspaceRoot: string, shardPath: string): void;
7
8
  export declare function validateAppendOnlyProofReceipts(entity: Readonly<Record<string, unknown>>, context: OperationContext, staged?: StagedUpsertState): Promise<void>;
8
9
  export declare function effectiveRelationships(input: UpsertInput, entity: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[], context: OperationContext, staged?: StagedUpsertState, lookup?: StoredEntityLookup): Promise<readonly RelationshipInput[]>;
@@ -32,6 +33,11 @@ export declare function analyzeUpsertSemantics(payload: UpsertInput & {
32
33
  }): UpsertSemanticAnalysis;
33
34
  export type UpsertValidation = Readonly<{
34
35
  readonly validated: ValidatedUpsert;
36
+ /**
37
+ * The authored file the write merges into although the store does not
38
+ * hold the entity; absent for an ordinary create or update.
39
+ */
40
+ readonly uncompiledSource?: UncompiledAuthoredSource;
35
41
  /** The upsert's relationships merged with the entity's existing ones. */
36
42
  readonly relationships: readonly RelationshipInput[];
37
43
  readonly semantic: UpsertSemanticAnalysis;
@@ -1 +1 @@
1
- {"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,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,EAAE,CAAC;CACtC,CAAC,CAAC;AAGH;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,WAAW,GAAG;IACrB,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACtD,GACA,sBAAsB,CASxB;AAGD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IACrD,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;CAC3C,CAAC,CAAC;AAGH;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CAyG3B;AAgDD,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C;;;;;;OAMG;IAEH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC,CAAC;AAyBH,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAiiBzC"}
@@ -27,6 +27,7 @@ import { storedEntityLookup, } from "./stored-entity.js";
27
27
  import { acquireSymbolCompilerLock, releaseSymbolCompilerLock, } from "./symbol-compiler-lock.js";
28
28
  import { validateSymbolGranularity } from "./symbol-granularity.js";
29
29
  import { refreshSymbolCoordinatesForManifest } from "./symbol-refresh.js";
30
+ import { assertAuthoredWriteCompiles, authoredEntityLookup, readUncompiledAuthoredSource, } from "./uncompiled-source.js";
30
31
  import { validateUpsertInput } from "./validation.js";
31
32
  import { scenarioCoverageWarnings, symbolCoverageWarnings, } from "./warnings.js";
32
33
  import { acquireWorkspaceMutationLock, releaseWorkspaceMutationLock, } from "./workspace-mutation-lock.js";
@@ -147,12 +148,14 @@ export async function effectiveRelationships(input, entity, relationships, conte
147
148
  // Relationships an earlier plan step adds from this entity will exist when
148
149
  // this upsert runs.
149
150
  const plannedOwn = (staged?.relationships ?? []).filter((relationship) => relationship.from === input.id);
150
- const exists = await (lookup ?? storedEntityLookup(prolog, input.id, input.type)).exists();
151
+ const resolved = lookup ?? storedEntityLookup(prolog, input.id, input.type);
152
+ const exists = await resolved.exists();
151
153
  if (!exists && plannedOwn.length === 0)
152
154
  return relationships;
153
155
  try {
154
156
  const current = exists
155
- ? (await existingRelationships(prolog, String(entity.id)))
157
+ ? (resolved.relationships ??
158
+ (await existingRelationships(prolog, String(entity.id))))
156
159
  // An upsert owns only relationships whose source is the upserted
157
160
  // entity. Incoming relationships must not be copied into its
158
161
  // validation or canonical source projection.
@@ -231,15 +234,32 @@ export async function validateUpsertForCommit(payload, context, options = {}) {
231
234
  // The payload must be valid on its own before the store is read.
232
235
  const checked = validateUpsertInput(payload, context.clock());
233
236
  validateRelationshipSources(payload.id, checked.relationships);
237
+ // Symbol granularity reads only the payload and its source file, and stored
238
+ // state never changes a symbol payload, so it runs before the store is read.
239
+ await validateSymbolGranularity(checked.entity, checked.relationships, context);
234
240
  // One read of the entity this upsert replaces, shared by the ledger merge
235
241
  // and the stored origin below.
236
- const lookup = storedEntityLookup(prolog, payload.id, payload.type);
242
+ let lookup = storedEntityLookup(prolog, payload.id, payload.type);
243
+ // implements REQ-kibi-uncompiled-source-visibility
244
+ // An entity missing from the store whose authored file exists (one sync
245
+ // could not extract, or one written since the last sync) is an update of
246
+ // that file, not a create: the writer merges into it. Judge the write
247
+ // against the file's own state so every stored-state check applies.
248
+ const uncompiledSource = staged?.entities.has(payload.id) === true || (await lookup.exists())
249
+ ? null
250
+ : await readUncompiledAuthoredSource(context, payload);
251
+ if (uncompiledSource !== null)
252
+ lookup = authoredEntityLookup(uncompiledSource);
237
253
  const input = await withStoredRequirementSemantics(payload, prolog, staged, lookup);
238
254
  const validated = input === payload ? checked : validateUpsertInput(input, context.clock());
255
+ if (uncompiledSource !== null)
256
+ lookup = {
257
+ ...lookup,
258
+ relationships: assertAuthoredWriteCompiles(uncompiledSource, input, validated.entity),
259
+ };
239
260
  if (options.allowReceiptsPrune !== true) {
240
261
  await validateAppendOnlyProofReceipts(validated.entity, context, staged);
241
262
  }
242
- await validateSymbolGranularity(validated.entity, validated.relationships, context);
243
263
  const relationships = await effectiveRelationships(input, validated.entity, validated.relationships, context, staged, lookup);
244
264
  await validateStrictLanePairing(prolog, validated.relationships, staged);
245
265
  await validateLiveRelationshipTargets(prolog, validated.entity, validated.relationships, staged);
@@ -259,6 +279,7 @@ export async function validateUpsertForCommit(payload, context, options = {}) {
259
279
  : validateUpsertInput(decided, context.clock()),
260
280
  relationships,
261
281
  semantic,
282
+ ...(uncompiledSource !== null ? { uncompiledSource } : {}),
262
283
  };
263
284
  }
264
285
  /**
@@ -370,7 +391,7 @@ export async function executeUpsert(input, context, options = {}) {
370
391
  // upserts cannot lose updates.
371
392
  compilerLock = await acquireSymbolCompilerLock(context.workspaceRoot);
372
393
  }
373
- const { validated, relationships, semantic } = await validateUpsertForCommit(input, context, {
394
+ const { validated, relationships, semantic, uncompiledSource } = await validateUpsertForCommit(input, context, {
374
395
  allowReceiptsPrune: options.allowReceiptsPrune === true,
375
396
  });
376
397
  relationshipCount = validated.relationships.length;
@@ -604,6 +625,12 @@ export async function executeUpsert(input, context, options = {}) {
604
625
  relationships_created: validated.relationships.length,
605
626
  warnings: [
606
627
  ...planRecoveryWarnings,
628
+ // implements REQ-kibi-uncompiled-source-visibility
629
+ ...(uncompiledSource !== undefined
630
+ ? [
631
+ `${input.id} was not in the compiled KB; this write updated its authored file ${uncompiledSource.path}${uncompiledSource.extractionError === null ? "" : `, which kibi sync could not compile before (${uncompiledSource.extractionError})`}. Run kibi sync to recompile it.`,
632
+ ]
633
+ : []),
607
634
  ...semantic.warnings,
608
635
  ...coverage,
609
636
  ...idStyleWarnings,
@@ -1 +1 @@
1
- {"version":3,"file":"apply-plan.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/apply-plan.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAEV,gBAAgB,EAGjB,MAAM,0CAA0C,CAAC;AASlD,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,uBAAuB,CAAC;AAiE/B,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AAqI9E,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,IAAI,CAMN;AAED,wBAAgB,mCAAmC,CACjD,SAAS,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,EACnE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B,IAAI,CAaN;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,SAAS,cAAoB,GAC5B,eAAe,EAAE,CA2CnB;AAi1BD;;;;;;GAMG;AAEH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAiCf;AAyqDD,wBAAsB,gBAAgB,CACpC,IAAI,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B,CACpC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB;AACzB;;;GAGG;AACH,WAAW,GAAE,MAAM,IAAsB,GACxC,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,eAAe,CAAC;CACpC,CAAC,CAmDD"}
@@ -2210,7 +2210,7 @@ async function applyMigrationPlan(args, context, onCommitted = () => undefined)
2210
2210
  const operationContext = context.prolog
2211
2211
  ? context
2212
2212
  : { ...context, prolog };
2213
- const [{ executeCheck }, { executeCoverage }, { mergeMigrationPlans }] = await Promise.all([
2213
+ const [{ executeCheck }, { executeCoverage }, { digestMigrationPlan, mergeMigrationPlans },] = await Promise.all([
2214
2214
  import("../../public/operations/check-executor.js"),
2215
2215
  import("../../public/operations/specs/reporting.js"),
2216
2216
  import("../../public/operations/migration-plan.js"),
@@ -2223,8 +2223,10 @@ async function applyMigrationPlan(args, context, onCommitted = () => undefined)
2223
2223
  coverage.structuredContent?.migrationPlan,
2224
2224
  symbolCoverage.structuredContent?.migrationPlan,
2225
2225
  ].filter((value) => value !== undefined);
2226
+ // The response reports what is left; the full plan, with every
2227
+ // review and execution action, stays with status, check and coverage.
2226
2228
  if (fragments.length > 0)
2227
- remainingPlan = mergeMigrationPlans(fragments);
2229
+ remainingPlan = digestMigrationPlan(mergeMigrationPlans(fragments));
2228
2230
  coverageSummary = coverage.structuredContent?.summary;
2229
2231
  }
2230
2232
  }
@@ -1 +1 @@
1
- {"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAsJlC"}
1
+ {"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAGpB,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAmKlC"}
@@ -11,6 +11,7 @@ import { normalizeSourceFile } from "./source-changes.js";
11
11
  import { collectSourceChanges, uniqueSorted } from "./source-changes.js";
12
12
  import { buildNextActions, collectLinkedEntities, formatExtractedSymbols, } from "./summaries.js";
13
13
  import { createSymbolQualityDiagnostics } from "./symbol-quality.js";
14
+ import { createUnownedFileDiagnostics } from "./unowned-files.js";
14
15
  export async function analyzeChangedFileImpact(options) {
15
16
  const workspaceRoot = path.resolve(options.workspaceRoot);
16
17
  const snapshot = options.staged
@@ -77,9 +78,20 @@ export async function analyzeChangedFileImpact(options) {
77
78
  const activeSourceFiles = new Set(sourceFiles);
78
79
  const activeManifestResults = manifestResults.filter((result) => result.sourceFile !== undefined &&
79
80
  activeSourceFiles.has(result.sourceFile));
81
+ const linkedSourceFiles = new Set(manifestResults
82
+ .filter((result) => result.relationships.some((relationship) => isTraceabilityRelationshipType(relationship.type)))
83
+ .map((result) => result.sourceFile)
84
+ .filter((file) => file !== undefined));
80
85
  const impactDiagnostics = options.includeImpactDiagnostics === false
81
86
  ? []
82
87
  : [
88
+ // Named files first: a file without links is the answer a scoped
89
+ // check most easily misreads as "no rule applies".
90
+ ...createUnownedFileDiagnostics({
91
+ workspaceRoot,
92
+ requestedFiles: [...filter],
93
+ linkedSourceFiles,
94
+ }),
83
95
  ...createSymbolGranularityDiagnostics({
84
96
  manifestResults: activeManifestResults,
85
97
  symbolsByFile,
@@ -93,9 +105,7 @@ export async function analyzeChangedFileImpact(options) {
93
105
  }),
94
106
  ...createSemanticReviewDiagnostics({
95
107
  symbolsByFile,
96
- linkedSourceFiles: new Set(activeManifestResults
97
- .filter((result) => result.relationships.some((relationship) => isTraceabilityRelationshipType(relationship.type)))
98
- .map((result) => result.sourceFile)),
108
+ linkedSourceFiles: new Set([...linkedSourceFiles].filter((file) => activeSourceFiles.has(file))),
99
109
  }),
100
110
  ];
101
111
  const maxDiagnostics = options.maxDiagnostics;
@@ -136,7 +136,7 @@ export function createSemanticReviewDiagnostics(options) {
136
136
  ? `Changed behavioral symbol ${symbol.name} is in a file no requirement owns, so no recorded intent covers the behavior it has after this change`
137
137
  : `Changed behavioral symbol ${symbol.name} needs semantic review against linked Kibi coverage: ${linkedTargets}`,
138
138
  suggestion: unlinked
139
- ? `If the change adds or alters behavior, record it with the change: kb_search({query:"<the behavior>", sourceLocations:[{path:"${file}"}]}) for a requirement that already describes it and link ${symbol.name} to it; if none does, kb_upsert a requirement with a scenario and link the symbol with implements. If behavior is unchanged (a refactor, renaming), say so in the final report instead.`
139
+ ? `If the change adds or alters behavior, record it as part of this change; that is part of finishing it, not a separate request, so it needs no permission: kb_search({query:"<the behavior>", sourceLocations:[{path:"${file}"}]}) for a requirement that already describes it and link ${symbol.name} to it; if none does, kb_upsert a requirement with a scenario and link the symbol with implements. If behavior is unchanged (a refactor, renaming), say so in the final report instead.`
140
140
  : `Use kb_search and kb_query for ${file}, then verify that ${linkedTargets} actually describe and test the changed behavior or UI copy. Update Kibi links or requirements/tests while the edit context is fresh.`,
141
141
  });
142
142
  }
@@ -0,0 +1,31 @@
1
+ import type { KibiImpactDiagnostic } from "../../traceability/staged-diagnostics.js";
2
+ /**
3
+ * The topic words of a workspace path, without layout, language and role
4
+ * words (`src/app/pages/coach-dashboard/coach-dashboard.html` -> `coach`,
5
+ * `dashboard`).
6
+ */
7
+ export declare function pathTopicWords(relativePath: string): string[];
8
+ export type RequirementCandidate = {
9
+ readonly id: string;
10
+ readonly title: string;
11
+ readonly status?: string;
12
+ };
13
+ /**
14
+ * Current requirements ranked by how many of the path's topic words their
15
+ * title shares, then by how often the title uses them, then by id; only
16
+ * those sharing at least one word.
17
+ */
18
+ export declare function rankRequirementCandidates(relativePath: string, requirements: readonly RequirementCandidate[], limit?: number): RequirementCandidate[];
19
+ export type UnownedFileDiagnosticsOptions = {
20
+ readonly workspaceRoot: string;
21
+ /** Workspace-relative files the check was asked about. */
22
+ readonly requestedFiles: readonly string[];
23
+ /** Files where some manifest symbol carries a traceability link. */
24
+ readonly linkedSourceFiles: ReadonlySet<string>;
25
+ };
26
+ /**
27
+ * One `source_file_unowned` note per requested file without a linked symbol,
28
+ * naming the current requirements whose titles share its path words.
29
+ */
30
+ export declare function createUnownedFileDiagnostics(options: UnownedFileDiagnosticsOptions): KibiImpactDiagnostic[];
31
+ //# sourceMappingURL=unowned-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unowned-files.d.ts","sourceRoot":"","sources":["../../../src/public/impact/unowned-files.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAqDrF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAS7D;AAGD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,SAAS,oBAAoB,EAAE,EAC7C,KAAK,GAAE,MAAuB,GAC7B,oBAAoB,EAAE,CAyBxB;AA+DD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,oEAAoE;IACpE,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAGF;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B,GACrC,oBAAoB,EAAE,CAqCxB"}
@@ -0,0 +1,171 @@
1
+ import { closeSync, openSync, readSync, readdirSync } from "node:fs";
2
+ import * as path from "node:path";
3
+ /**
4
+ * A file `kb_check` was asked about that no symbol links to a requirement.
5
+ * No link is not no rule, so the check says so and names the current
6
+ * requirements whose titles share the file's path words: candidates to
7
+ * confirm, never owners. Kibi's hooks name the same candidates before an edit
8
+ * (kibi-agent-core `requirement-candidates`), with the same word rules.
9
+ */
10
+ const REQUIREMENTS_DIR = path.join(".kb", "requirements");
11
+ const HEAD_BYTES = 4096;
12
+ const MAX_CANDIDATES = 3;
13
+ const MAX_TITLE = 100;
14
+ /** Path words that name a layout, a language or a role, not a behavior. */
15
+ const LAYOUT_WORDS = new Set(("src app apps lib libs source page pages component components view views " +
16
+ "screen screens package packages main index shared common core util utils " +
17
+ "helper helpers public static asset assets web client server frontend " +
18
+ "backend module modules feature features internal service services test " +
19
+ "tests spec specs dist build html htm tsx jsx mjs cjs vue svelte css scss " +
20
+ "less json yaml yml java swift php").split(" "));
21
+ /** Words of a title or path that carry no topic. */
22
+ const FILLER_WORDS = new Set(("the and for with must should shall may can are its their that this " +
23
+ "from into when each every all not req auto").split(" "));
24
+ const RETIRED_STATUS = /supersed|deprecat|reject|obsolete|retired|archived|removed/i;
25
+ /** Lowercase word stems of an identifier, path segment or title. */
26
+ function words(text) {
27
+ return text
28
+ .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
29
+ .toLowerCase()
30
+ .split(/[^a-z0-9]+/)
31
+ .filter((word) => word.length >= 3 && !/\d/.test(word))
32
+ .map((word) => word.length > 4 && word.endsWith("s") && !word.endsWith("ss")
33
+ ? word.slice(0, -1)
34
+ : word);
35
+ }
36
+ // implements REQ-kb-unowned-file-candidates
37
+ /**
38
+ * The topic words of a workspace path, without layout, language and role
39
+ * words (`src/app/pages/coach-dashboard/coach-dashboard.html` -> `coach`,
40
+ * `dashboard`).
41
+ */
42
+ export function pathTopicWords(relativePath) {
43
+ const segments = relativePath.split(/[\\/]/).filter(Boolean);
44
+ const last = segments.pop() ?? "";
45
+ const dot = last.indexOf(".");
46
+ const parts = dot >= 0 ? [last.slice(0, dot), last.slice(dot + 1)] : [last];
47
+ const found = [...segments, ...parts]
48
+ .flatMap(words)
49
+ .filter((word) => !LAYOUT_WORDS.has(word) && !FILLER_WORDS.has(word));
50
+ return [...new Set(found)];
51
+ }
52
+ // implements REQ-kb-unowned-file-candidates
53
+ /**
54
+ * Current requirements ranked by how many of the path's topic words their
55
+ * title shares, then by how often the title uses them, then by id; only
56
+ * those sharing at least one word.
57
+ */
58
+ export function rankRequirementCandidates(relativePath, requirements, limit = MAX_CANDIDATES) {
59
+ const topic = new Set(pathTopicWords(relativePath));
60
+ if (topic.size === 0)
61
+ return [];
62
+ const scored = [];
63
+ for (const requirement of requirements) {
64
+ if (requirement.status !== undefined &&
65
+ RETIRED_STATUS.test(requirement.status))
66
+ continue;
67
+ const matched = words(requirement.title).filter((word) => topic.has(word));
68
+ const shared = new Set(matched).size;
69
+ if (shared > 0)
70
+ scored.push({ requirement, shared, uses: matched.length });
71
+ }
72
+ scored.sort((a, b) => b.shared - a.shared ||
73
+ b.uses - a.uses ||
74
+ a.requirement.id.localeCompare(b.requirement.id));
75
+ return scored.slice(0, limit).map((entry) => entry.requirement);
76
+ }
77
+ function unquote(value) {
78
+ const trimmed = value.trim();
79
+ return /^(["']).*\1$/.test(trimmed) ? trimmed.slice(1, -1) : trimmed;
80
+ }
81
+ function readRequirementHead(file) {
82
+ let head;
83
+ try {
84
+ const descriptor = openSync(file, "r");
85
+ try {
86
+ const buffer = Buffer.alloc(HEAD_BYTES);
87
+ const bytes = readSync(descriptor, buffer, 0, buffer.length, 0);
88
+ head = buffer.subarray(0, bytes).toString("utf8");
89
+ }
90
+ finally {
91
+ closeSync(descriptor);
92
+ }
93
+ }
94
+ catch {
95
+ return undefined;
96
+ }
97
+ const lines = head.split(/\r?\n/);
98
+ if (lines[0]?.trim() !== "---")
99
+ return undefined;
100
+ const fields = {};
101
+ for (const line of lines.slice(1)) {
102
+ if (line.trim() === "---")
103
+ break;
104
+ const match = /^(id|title|status):\s*(.+)$/.exec(line);
105
+ if (match?.[1] && match[2])
106
+ fields[match[1]] = unquote(match[2]);
107
+ }
108
+ if (!fields.id || !fields.title)
109
+ return undefined;
110
+ return {
111
+ id: fields.id,
112
+ title: fields.title,
113
+ ...(fields.status ? { status: fields.status } : {}),
114
+ };
115
+ }
116
+ function readRequirementHeads(workspaceRoot) {
117
+ const directory = path.join(workspaceRoot, REQUIREMENTS_DIR);
118
+ let names;
119
+ try {
120
+ names = readdirSync(directory).filter((name) => name.endsWith(".md"));
121
+ }
122
+ catch {
123
+ return [];
124
+ }
125
+ return names
126
+ .map((name) => readRequirementHead(path.join(directory, name)))
127
+ .filter((requirement) => requirement !== undefined);
128
+ }
129
+ function truncate(text, limit) {
130
+ return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
131
+ }
132
+ /** Files the unowned note does not apply to: the KB itself and prose. */
133
+ function isKnowledgeOrProse(file) {
134
+ return file.startsWith(".kb/") || /\.mdx?$/i.test(file);
135
+ }
136
+ // implements REQ-kb-unowned-file-candidates
137
+ /**
138
+ * One `source_file_unowned` note per requested file without a linked symbol,
139
+ * naming the current requirements whose titles share its path words.
140
+ */
141
+ export function createUnownedFileDiagnostics(options) {
142
+ const files = [...new Set(options.requestedFiles)].filter((file) => !options.linkedSourceFiles.has(file) && !isKnowledgeOrProse(file));
143
+ if (files.length === 0)
144
+ return [];
145
+ const requirements = readRequirementHeads(options.workspaceRoot);
146
+ return files.map((file) => {
147
+ const candidates = rankRequirementCandidates(file, requirements);
148
+ const named = candidates
149
+ .map((candidate) => `${candidate.id} (${truncate(candidate.title, MAX_TITLE)})`)
150
+ .join("; ");
151
+ const lead = `No symbol in ${file} is linked to a requirement, so this check finds no owner for it; that does not mean no recorded rule covers the behavior it implements.`;
152
+ const record = "If none does and the change adds behavior, record a requirement with a scenario and link it with implements as part of this change; if behavior is unchanged, say so in the final report.";
153
+ return {
154
+ id: "source_file_unowned",
155
+ severity: "info",
156
+ blocking: false,
157
+ category: "requirement",
158
+ files: [file],
159
+ docs: ["docs/symbol-traceability-taxonomy.md"],
160
+ message: candidates.length > 0
161
+ ? `${lead} Requirements whose titles share its path words: ${named}.`
162
+ : lead,
163
+ suggestion: candidates.length > 0
164
+ ? `kb_query each candidate to see whether it describes the changed behavior; when one does, link the symbol that implements it (for markup, the component that renders it) with implements and name the requirement in the final report. ${record}`
165
+ : `kb_search({query:"<the behavior>", sourceLocations:[{path:${JSON.stringify(file)}}]}) for a requirement that already describes it. ${record}`,
166
+ evidence: {
167
+ candidates: candidates.map(({ id, title }) => ({ id, title })),
168
+ },
169
+ };
170
+ });
171
+ }