kibi-plugin-builtin 0.2.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 (44) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/index.d.ts +34 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +72 -0
  5. package/dist/ontology/builtin-ontology-pack.d.ts +11 -0
  6. package/dist/ontology/builtin-ontology-pack.d.ts.map +1 -0
  7. package/dist/ontology/builtin-ontology-pack.js +78 -0
  8. package/dist/ontology/normalize.d.ts +7 -0
  9. package/dist/ontology/normalize.d.ts.map +1 -0
  10. package/dist/ontology/normalize.js +55 -0
  11. package/dist/ontology/predicate-rule.d.ts +26 -0
  12. package/dist/ontology/predicate-rule.d.ts.map +1 -0
  13. package/dist/ontology/predicate-rule.js +55 -0
  14. package/dist/ontology/predicate-rules-core.d.ts +94 -0
  15. package/dist/ontology/predicate-rules-core.d.ts.map +1 -0
  16. package/dist/ontology/predicate-rules-core.js +156 -0
  17. package/dist/ontology/predicate-rules-launcher.d.ts +58 -0
  18. package/dist/ontology/predicate-rules-launcher.d.ts.map +1 -0
  19. package/dist/ontology/predicate-rules-launcher.js +105 -0
  20. package/dist/ontology/predicate-rules-policy.d.ts +99 -0
  21. package/dist/ontology/predicate-rules-policy.d.ts.map +1 -0
  22. package/dist/ontology/predicate-rules-policy.js +167 -0
  23. package/dist/ontology/predicate-rules-product-tail.d.ts +57 -0
  24. package/dist/ontology/predicate-rules-product-tail.d.ts.map +1 -0
  25. package/dist/ontology/predicate-rules-product-tail.js +112 -0
  26. package/dist/ontology/predicate-rules-product.d.ts +84 -0
  27. package/dist/ontology/predicate-rules-product.d.ts.map +1 -0
  28. package/dist/ontology/predicate-rules-product.js +147 -0
  29. package/dist/semantic/builtin-classifier.d.ts +22 -0
  30. package/dist/semantic/builtin-classifier.d.ts.map +1 -0
  31. package/dist/semantic/builtin-classifier.js +134 -0
  32. package/dist/symbols/ts-morph-enrichment.d.ts +21 -0
  33. package/dist/symbols/ts-morph-enrichment.d.ts.map +1 -0
  34. package/dist/symbols/ts-morph-enrichment.js +371 -0
  35. package/dist/symbols/ts-morph-extractor.d.ts +8 -0
  36. package/dist/symbols/ts-morph-extractor.d.ts.map +1 -0
  37. package/dist/symbols/ts-morph-extractor.js +229 -0
  38. package/dist/symbols/ts-morph-granularity.d.ts +11 -0
  39. package/dist/symbols/ts-morph-granularity.d.ts.map +1 -0
  40. package/dist/symbols/ts-morph-granularity.js +98 -0
  41. package/dist/symbols/ts-morph-shared.d.ts +15 -0
  42. package/dist/symbols/ts-morph-shared.d.ts.map +1 -0
  43. package/dist/symbols/ts-morph-shared.js +71 -0
  44. package/package.json +42 -0
@@ -0,0 +1,112 @@
1
+ import { normalizeKey, normalizePredicateToken, normalizeSubjectKey, singularize, } from "./predicate-rule.js";
2
+ // implements REQ-capability-plugin-builtin-parity-v1
3
+ export const PRODUCT_TAIL_PREDICATE_RULES = [
4
+ {
5
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+throttled\s+for\s+(?<condition>.+?)\.?$/i,
6
+ name: "throttle_policy_rule",
7
+ arity: 2,
8
+ args: (g) => [
9
+ normalizeKey(g.subject ?? ""),
10
+ normalizePredicateToken(g.condition ?? ""),
11
+ ],
12
+ rationale: "Throttle-policy prose defines throttling behavior under high-frequency conditions and should be queryable as a predicate.",
13
+ },
14
+ {
15
+ pattern: /^(?:the\s+)?(?<subject>.+?)\s+initializes\s+after\s+(?:the\s+)?(?<ready>.+?)\s+is\s+ready\.?$/i,
16
+ name: "temporal_order",
17
+ arity: 3,
18
+ args: (g) => [
19
+ normalizeKey(g.subject ?? ""),
20
+ `${normalizeKey(g.ready ?? "")}_ready`,
21
+ "initializes",
22
+ ],
23
+ rationale: "Initializes-after prose defines temporal readiness ordering and should be queryable as a predicate.",
24
+ },
25
+ {
26
+ pattern: /^when\s+(?<trigger>.+?),\s*(?:the\s+)?(?<subject>[a-z][a-z\s_-]*?)\s+transitions?\s+from\s+(?<from>[a-z][a-z0-9_-]*)\s+to\s+(?<to>[a-z][a-z0-9_-]*)\.?$/i,
27
+ name: "state_transition",
28
+ arity: 4,
29
+ args: (g) => [
30
+ normalizeSubjectKey(g.subject ?? ""),
31
+ normalizePredicateToken(g.from ?? ""),
32
+ normalizePredicateToken(g.to ?? ""),
33
+ normalizePredicateToken(g.trigger ?? ""),
34
+ ],
35
+ rationale: "State transitions have source state, target state, and trigger; model them as predicate facts.",
36
+ },
37
+ {
38
+ pattern: /^(?<actor>[a-z][a-z\s_-]*?)\s+(?:must\s+not|cannot|can't|is\s+forbidden\s+to)\s+(?<action>[a-z][a-z_-]*)\s+(?<resource>.+?)\.?$/i,
39
+ name: "permission_rule",
40
+ arity: 4,
41
+ args: (g) => [
42
+ singularize(normalizeKey(g.actor ?? "")),
43
+ normalizePredicateToken(g.action ?? ""),
44
+ normalizePredicateToken(g.resource ?? ""),
45
+ "deny",
46
+ ],
47
+ rationale: "Prohibitions are negative permission rules and should preserve deny polarity.",
48
+ polarity: "deny",
49
+ },
50
+ {
51
+ pattern: /^(?:there\s+)?(?:must|shall|should)\s+be\s+at\s+most\s+one\s+(?<subject>[a-z][a-z\s_-]*?)\s+per\s+(?<scope>.+?)\.?$/i,
52
+ name: "uniqueness_constraint",
53
+ arity: 2,
54
+ args: (g) => [
55
+ normalizeKey(g.subject ?? ""),
56
+ (g.scope ?? "")
57
+ .split(/\s+per\s+/i)
58
+ .map(normalizePredicateToken)
59
+ .join(","),
60
+ ],
61
+ rationale: "Per-scope uniqueness is relational and should be modeled as a predicate rather than a generic count.",
62
+ },
63
+ {
64
+ pattern: /^(?:the\s+)?(?<subject>[a-z][a-z\s_-]*?)\s+defaults?\s+to\s+(?<value>[a-z][a-z0-9\s_-]*?)(?:\s+(?<property>mode|state|status))?\.?$/i,
65
+ name: "default_value",
66
+ arity: 3,
67
+ args: (g) => [
68
+ normalizeSubjectKey(g.subject ?? ""),
69
+ normalizeKey(g.property ?? "value"),
70
+ normalizeKey(g.value ?? ""),
71
+ ],
72
+ rationale: "Defaults are relational product behavior and should be explicit ontology predicates.",
73
+ },
74
+ {
75
+ pattern: /^(?<subject>.+?)\s+(?:terminal\s+)?states\s+are\s+(?<states>.+?)\.?$/i,
76
+ name: "state_membership",
77
+ arity: 2,
78
+ args: (g) => [
79
+ normalizeSubjectKey(g.subject ?? ""),
80
+ (g.states ?? "")
81
+ .split(/,|\band\b|\bor\b/i)
82
+ .map((value) => normalizePredicateToken(value.trim()))
83
+ .filter(Boolean)
84
+ .join(","),
85
+ ],
86
+ rationale: "State sets are relational workflow constraints and should be queryable as predicate facts.",
87
+ },
88
+ {
89
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+rate\s+limited\s+to\s+(?<count>\d+)\s+(?<action>[a-z][a-z\s_-]*?)\s+per\s+(?<window>[a-z]+)\.?$/i,
90
+ name: "rate_limit",
91
+ arity: 4,
92
+ args: (g) => [
93
+ `${normalizeKey(g.subject ?? "").replace(/_requests?$/, "")}.request`,
94
+ normalizePredicateToken(g.action ?? ""),
95
+ normalizePredicateToken(g.window ?? ""),
96
+ g.count ?? "",
97
+ ],
98
+ rationale: "Rate limits are bounded action-window constraints and now map to the production rate_limit predicate.",
99
+ },
100
+ {
101
+ pattern: /^only\s+(?<actor>[a-z][a-z\s_-]*?)\s+can\s+(?<action>[a-z][a-z_-]*)\s+(?<resource>.+?)(?:\s+when\s+.+)?\.?$/i,
102
+ name: "permission_rule",
103
+ arity: 4,
104
+ args: (g) => [
105
+ singularize(normalizeKey(g.actor ?? "")),
106
+ normalizeKey(g.action ?? ""),
107
+ normalizeKey(g.resource ?? ""),
108
+ "assert",
109
+ ],
110
+ rationale: "Actor/action/resource permission prose is better represented as an ontology predicate than a scalar property.",
111
+ },
112
+ ];
@@ -0,0 +1,84 @@
1
+ export declare const PRODUCT_PREDICATE_RULES: readonly [{
2
+ readonly pattern: RegExp;
3
+ readonly name: "release_gate_rule";
4
+ readonly arity: 3;
5
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
6
+ readonly rationale: "Release-gate prose defines required gates before distribution or deployment and should be queryable as a predicate.";
7
+ readonly accepts: (statement: string) => boolean;
8
+ }, {
9
+ readonly pattern: RegExp;
10
+ readonly name: "platform_consistency_rule";
11
+ readonly arity: 2;
12
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
13
+ readonly rationale: "Platform consistency prose defines synchronization across platforms and should be queryable as a predicate.";
14
+ }, {
15
+ readonly pattern: RegExp;
16
+ readonly name: "preservation_rule";
17
+ readonly arity: 3;
18
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
19
+ readonly rationale: "Preservation prose defines data preserved across deletion/removal boundaries and should be queryable as a predicate.";
20
+ }, {
21
+ readonly pattern: RegExp;
22
+ readonly name: "abstraction_boundary_rule";
23
+ readonly arity: 3;
24
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
25
+ readonly rationale: "Abstraction-boundary prose defines renderer/vendor-neutral persistence or contract constraints and should be queryable as a predicate.";
26
+ readonly accepts: (statement: string) => boolean;
27
+ }, {
28
+ readonly pattern: RegExp;
29
+ readonly name: "security_configuration_rule";
30
+ readonly arity: 3;
31
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
32
+ readonly rationale: "Security-configuration prose defines explicit infrastructure or database settings and should be queryable as a predicate.";
33
+ readonly accepts: (statement: string) => boolean;
34
+ }, {
35
+ readonly pattern: RegExp;
36
+ readonly name: "ordered_strategy_rule";
37
+ readonly arity: 3;
38
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
39
+ readonly rationale: "Ordered-strategy prose defines a required priority order and should be queryable as a predicate.";
40
+ }, {
41
+ readonly pattern: RegExp;
42
+ readonly name: "refresh_policy_rule";
43
+ readonly arity: 3;
44
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
45
+ readonly rationale: "Refresh-policy prose defines automatic refresh behavior and should be queryable as a predicate.";
46
+ }, {
47
+ readonly pattern: RegExp;
48
+ readonly name: "scoped_authorization_rule";
49
+ readonly arity: 3;
50
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
51
+ readonly rationale: "Scoped-authorization prose defines assignment/ownership-qualified authorization and should be queryable as a predicate.";
52
+ readonly accepts: (statement: string) => boolean;
53
+ }, {
54
+ readonly pattern: RegExp;
55
+ readonly name: "documentation_standard_rule";
56
+ readonly arity: 3;
57
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
58
+ readonly rationale: "Documentation-standard prose defines required documentation artifacts and should be queryable as a predicate.";
59
+ }, {
60
+ readonly pattern: RegExp;
61
+ readonly name: "warmup_policy_rule";
62
+ readonly arity: 2;
63
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
64
+ readonly rationale: "Warmup-policy prose defines a required warmup trigger and should be queryable as a predicate.";
65
+ }, {
66
+ readonly pattern: RegExp;
67
+ readonly name: "visual_layout_rule";
68
+ readonly arity: 3;
69
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
70
+ readonly rationale: "Visual-layout prose defines UI alignment requirements and should be queryable as a predicate.";
71
+ }, {
72
+ readonly pattern: RegExp;
73
+ readonly name: "enforcement_location_rule";
74
+ readonly arity: 2;
75
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
76
+ readonly rationale: "Enforcement-location prose defines the layer where a constraint is enforced and should be queryable as a predicate.";
77
+ }, {
78
+ readonly pattern: RegExp;
79
+ readonly name: "reconciliation_rule";
80
+ readonly arity: 4;
81
+ readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
82
+ readonly rationale: "Reconciliation prose defines trigger-based cleanup of stale records and should be queryable as a predicate.";
83
+ }];
84
+ //# sourceMappingURL=predicate-rules-product.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predicate-rules-product.d.ts","sourceRoot":"","sources":["../../src/ontology/predicate-rules-product.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkLS,CAAC"}
@@ -0,0 +1,147 @@
1
+ import { commaList, normalizeKey, normalizePredicateToken, } from "./predicate-rule.js";
2
+ // implements REQ-capability-plugin-builtin-parity-v1
3
+ export const PRODUCT_PREDICATE_RULES = [
4
+ {
5
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+pass\s+(?<gate>.+?)\s+before\s+(?<target>.+?)\.?$/i,
6
+ name: "release_gate_rule",
7
+ arity: 3,
8
+ args: (g) => [
9
+ normalizeKey(g.subject ?? ""),
10
+ normalizePredicateToken(g.gate ?? "gate"),
11
+ normalizeKey(g.target ?? ""),
12
+ ],
13
+ rationale: "Release-gate prose defines required gates before distribution or deployment and should be queryable as a predicate.",
14
+ accepts: (statement) => /\b(?:app store|build|deployment|distribution|release|testflight)\b/i.test(statement),
15
+ },
16
+ {
17
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+synchronize\s+across\s+(?<platforms>.+?)\.?$/i,
18
+ name: "platform_consistency_rule",
19
+ arity: 2,
20
+ args: (g) => [normalizeKey(g.subject ?? ""), commaList(g.platforms ?? "")],
21
+ rationale: "Platform consistency prose defines synchronization across platforms and should be queryable as a predicate.",
22
+ },
23
+ {
24
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+preserve\s+(?<preserved>.+?)\s+when\s+(?:the\s+)?(?<condition>.+?)\.?$/i,
25
+ name: "preservation_rule",
26
+ arity: 3,
27
+ args: (g) => [
28
+ normalizeKey(g.subject ?? ""),
29
+ normalizeKey(g.preserved ?? "preserved"),
30
+ normalizePredicateToken(g.condition ?? ""),
31
+ ],
32
+ rationale: "Preservation prose defines data preserved across deletion/removal boundaries and should be queryable as a predicate.",
33
+ },
34
+ {
35
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+persisted\s+as\s+(?<contract>.+?)\.?$/i,
36
+ name: "abstraction_boundary_rule",
37
+ arity: 3,
38
+ args: (g) => [
39
+ normalizeKey(g.subject ?? ""),
40
+ "persisted_as",
41
+ normalizePredicateToken(g.contract ?? ""),
42
+ ],
43
+ rationale: "Abstraction-boundary prose defines renderer/vendor-neutral persistence or contract constraints and should be queryable as a predicate.",
44
+ accepts: (statement) => /\b(?:neutral|contract|renderer|runtime|vendor)\b/i.test(statement),
45
+ },
46
+ {
47
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+have\s+explicit\s+(?<setting>[A-Za-z0-9_.-]+)\s+(?<value>[A-Za-z0-9_.-]+)\.?$/i,
48
+ name: "security_configuration_rule",
49
+ arity: 3,
50
+ args: (g) => [
51
+ normalizeKey(g.subject ?? ""),
52
+ normalizeKey(g.setting ?? ""),
53
+ normalizeKey(g.value ?? ""),
54
+ ],
55
+ rationale: "Security-configuration prose defines explicit infrastructure or database settings and should be queryable as a predicate.",
56
+ accepts: (statement) => /\b(?:database|deployment|function|rpc|search_path|security|trigger)\b/i.test(statement),
57
+ },
58
+ {
59
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+use\s+(?<kind>.+?)\s+in\s+priority\s+order\s+(?<values>.+?)\.?$/i,
60
+ name: "ordered_strategy_rule",
61
+ arity: 3,
62
+ args: (g) => [
63
+ normalizeKey(g.subject ?? ""),
64
+ normalizeKey(g.kind ?? "strategy"),
65
+ (g.values ?? "")
66
+ .split(/,|>/)
67
+ .map(normalizePredicateToken)
68
+ .filter(Boolean)
69
+ .join(","),
70
+ ],
71
+ rationale: "Ordered-strategy prose defines a required priority order and should be queryable as a predicate.",
72
+ },
73
+ {
74
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+automatically\s+refresh\s+(?<target>.+?)\s+without\s+requiring\s+manual\s+page\s+reload\.?$/i,
75
+ name: "refresh_policy_rule",
76
+ arity: 3,
77
+ args: (g) => [
78
+ normalizeKey(g.subject ?? ""),
79
+ normalizeKey(g.target ?? ""),
80
+ "automatic",
81
+ ],
82
+ rationale: "Refresh-policy prose defines automatic refresh behavior and should be queryable as a predicate.",
83
+ },
84
+ {
85
+ pattern: /^(?<actor>.+?)\s+(?:must|shall|should)\s+be\s+denied\s+(?<action>.+?)\.?$/i,
86
+ name: "scoped_authorization_rule",
87
+ arity: 3,
88
+ args: (g) => [
89
+ normalizeKey(g.actor ?? ""),
90
+ normalizeKey(g.action ?? ""),
91
+ "deny",
92
+ ],
93
+ rationale: "Scoped-authorization prose defines assignment/ownership-qualified authorization and should be queryable as a predicate.",
94
+ accepts: (statement) => /\b(?:assigned|unassigned|owner|member|scoped)\b/i.test(statement),
95
+ },
96
+ {
97
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+documented\s+in\s+(?<artifact>.+?)\.?$/i,
98
+ name: "documentation_standard_rule",
99
+ arity: 3,
100
+ args: (g) => [
101
+ normalizeKey(g.subject ?? ""),
102
+ "documented_in",
103
+ normalizeKey(g.artifact ?? ""),
104
+ ],
105
+ rationale: "Documentation-standard prose defines required documentation artifacts and should be queryable as a predicate.",
106
+ },
107
+ {
108
+ pattern: /^(?:the\s+)?(?<subject>.+?)\s+(?:must|shall|should)\s+warm\s+up\s+on\s+(?<trigger>.+?)\.?$/i,
109
+ name: "warmup_policy_rule",
110
+ arity: 2,
111
+ args: (g) => [normalizeKey(g.subject ?? ""), normalizeKey(g.trigger ?? "")],
112
+ rationale: "Warmup-policy prose defines a required warmup trigger and should be queryable as a predicate.",
113
+ },
114
+ {
115
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+remain\s+visually\s+aligned\s+with\s+(?<target>.+?)\.?$/i,
116
+ name: "visual_layout_rule",
117
+ arity: 3,
118
+ args: (g) => [
119
+ normalizeKey(g.subject ?? ""),
120
+ "aligned_with",
121
+ normalizeKey(g.target ?? ""),
122
+ ],
123
+ rationale: "Visual-layout prose defines UI alignment requirements and should be queryable as a predicate.",
124
+ },
125
+ {
126
+ pattern: /^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+enforced\s+at\s+(?<location>.+?)\.?$/i,
127
+ name: "enforcement_location_rule",
128
+ arity: 2,
129
+ args: (g) => [
130
+ normalizeKey(g.subject ?? ""),
131
+ normalizeKey(g.location ?? ""),
132
+ ],
133
+ rationale: "Enforcement-location prose defines the layer where a constraint is enforced and should be queryable as a predicate.",
134
+ },
135
+ {
136
+ pattern: /^on\s+(?<trigger>.+?),\s*(?<subject>.+?)\s+(?:must|shall|should)\s+reconcile\s+(?<target>.+?)\s+and\s+(?<action>clear\s+stale\s+.+?)\.?$/i,
137
+ name: "reconciliation_rule",
138
+ arity: 4,
139
+ args: (g) => [
140
+ normalizeKey(g.subject ?? ""),
141
+ normalizeKey(g.trigger ?? "trigger"),
142
+ normalizeKey(g.target ?? ""),
143
+ normalizeKey(g.action ?? "action"),
144
+ ],
145
+ rationale: "Reconciliation prose defines trigger-based cleanup of stale records and should be queryable as a predicate.",
146
+ },
147
+ ];
@@ -0,0 +1,22 @@
1
+ import type { SemanticClassifierInput, SemanticClassifierResult, SemanticClassifierV1, SemanticLane, SemanticSignalKind } from "kibi-plugin-sdk";
2
+ interface DetectedSignal {
3
+ readonly kind: SemanticSignalKind;
4
+ readonly evidence: string;
5
+ readonly candidateLane: SemanticLane;
6
+ readonly confidence: number;
7
+ }
8
+ export declare function detectSignals(prose: string): readonly DetectedSignal[];
9
+ /**
10
+ * Lane selection shared with the host analysis receipt.
11
+ * Host snake_case receipts may omit candidateLane; only `kind` is required.
12
+ */
13
+ export declare function chooseLane(signals: readonly {
14
+ readonly kind: SemanticSignalKind;
15
+ }[]): SemanticLane;
16
+ export declare class BuiltinSemanticClassifier implements SemanticClassifierV1 {
17
+ readonly id = "kibi-plugin-builtin.classifier";
18
+ classify(input: SemanticClassifierInput): SemanticClassifierResult;
19
+ }
20
+ export declare function createBuiltinSemanticClassifier(): SemanticClassifierV1;
21
+ export {};
22
+ //# sourceMappingURL=builtin-classifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin-classifier.d.ts","sourceRoot":"","sources":["../../src/semantic/builtin-classifier.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAEV,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAwDzB,UAAU,cAAc;IACtB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,CAetE;AAED;;;GAGG;AAEH,wBAAgB,UAAU,CACxB,OAAO,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,EAAE,GACxD,YAAY,CAoBd;AA4BD,qBAAa,yBAA0B,YAAW,oBAAoB;IACpE,QAAQ,CAAC,EAAE,oCAAoC;IAE/C,QAAQ,CAAC,KAAK,EAAE,uBAAuB,GAAG,wBAAwB;CAqBnE;AAGD,wBAAgB,+BAA+B,IAAI,oBAAoB,CAEtE"}
@@ -0,0 +1,134 @@
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
+ /** Same patterns as CLI analyze-prose SIGNAL_PATTERNS. */
19
+ const SIGNAL_PATTERNS = [
20
+ {
21
+ kind: "numeric_cardinality",
22
+ candidateLane: "strict_property",
23
+ confidence: 0.92,
24
+ pattern: /\b(?:(?:at\s+most|at\s+least|exactly|no\s+more\s+than|up\s+to|cap(?:ped)?\s+at)\s+)?(?:\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten)\b/i,
25
+ },
26
+ {
27
+ kind: "numeric_threshold",
28
+ candidateLane: "strict_property",
29
+ confidence: 0.86,
30
+ pattern: /\b(?:maximum|minimum|under|within|below|above|expires?|retained\s+for)\s+(?:\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten)\b/i,
31
+ },
32
+ {
33
+ kind: "conditional",
34
+ candidateLane: "predicate",
35
+ confidence: 0.82,
36
+ pattern: /\b(?:if|when|unless|except|only\s+if|provided\s+that)\b/i,
37
+ },
38
+ {
39
+ kind: "permission",
40
+ candidateLane: "predicate",
41
+ confidence: 0.8,
42
+ pattern: /\b(?:only|may|can|allowed|denied|forbidden|must\s+not|cannot|can't)\b/i,
43
+ },
44
+ {
45
+ kind: "state_or_default",
46
+ candidateLane: "predicate",
47
+ confidence: 0.74,
48
+ pattern: /\b(?:state|mode|defaults?\s+to|ready|disabled|enabled|terminal)\b/i,
49
+ },
50
+ {
51
+ kind: "normative_modal",
52
+ candidateLane: "observation_review",
53
+ confidence: 0.65,
54
+ // Modal-free validity, rejection, prohibition, and failure-outcome
55
+ // assertions are normative even when they omit must/shall.
56
+ pattern: /\b(?:must|shall|should|may|must\s+not|cannot|can't|invalid|unresolved|reject(?:ed|ion)?|prohibited|forbidden|fail(?:s|ed|ure)?\s+(?:clearly|explicitly|with)|required\s+outcome)\b/i,
57
+ },
58
+ ];
59
+ // implements REQ-capability-plugin-builtin-parity-v1
60
+ export function detectSignals(prose) {
61
+ const seen = new Set();
62
+ return SIGNAL_PATTERNS.flatMap((candidate) => {
63
+ const evidence = prose.match(candidate.pattern)?.[0];
64
+ if (!evidence || seen.has(candidate.kind))
65
+ return [];
66
+ seen.add(candidate.kind);
67
+ return [
68
+ {
69
+ kind: candidate.kind,
70
+ evidence,
71
+ candidateLane: candidate.candidateLane,
72
+ confidence: candidate.confidence,
73
+ },
74
+ ];
75
+ });
76
+ }
77
+ /**
78
+ * Lane selection shared with the host analysis receipt.
79
+ * Host snake_case receipts may omit candidateLane; only `kind` is required.
80
+ */
81
+ // implements REQ-capability-plugin-builtin-parity-v1
82
+ export function chooseLane(signals) {
83
+ if (signals.some(({ kind }) => kind === "numeric_cardinality" || kind === "numeric_threshold"))
84
+ return "strict_property";
85
+ if (signals.some(({ kind }) => kind === "conditional" ||
86
+ kind === "permission" ||
87
+ kind === "state_or_default"))
88
+ return "predicate";
89
+ return signals.some(({ kind }) => kind === "normative_modal")
90
+ ? "observation_review"
91
+ : "none";
92
+ }
93
+ function confidenceForLane(lane, signals) {
94
+ if (lane === "none" || signals.length === 0)
95
+ return 0;
96
+ const relevant = lane === "strict_property"
97
+ ? signals.filter(({ kind }) => kind === "numeric_cardinality" || kind === "numeric_threshold")
98
+ : lane === "predicate"
99
+ ? signals.filter(({ kind }) => kind === "conditional" ||
100
+ kind === "permission" ||
101
+ kind === "state_or_default")
102
+ : lane === "observation_review"
103
+ ? signals.filter(({ kind }) => kind === "normative_modal")
104
+ : signals;
105
+ const pool = relevant.length > 0 ? relevant : signals;
106
+ return Math.max(...pool.map((signal) => signal.confidence));
107
+ }
108
+ // implements REQ-capability-plugin-builtin-parity-v1
109
+ export class BuiltinSemanticClassifier {
110
+ id = "kibi-plugin-builtin.classifier";
111
+ classify(input) {
112
+ const decisions = input.propositions.map((proposition) => {
113
+ const signals = detectSignals(proposition.statement);
114
+ const lane = chooseLane(signals);
115
+ const decision = {
116
+ claimKey: proposition.claimKey,
117
+ lane,
118
+ confidence: confidenceForLane(lane, signals),
119
+ };
120
+ if (signals.length > 0) {
121
+ return {
122
+ ...decision,
123
+ signals: signals.map((signal) => signal.kind),
124
+ };
125
+ }
126
+ return decision;
127
+ });
128
+ return { decisions };
129
+ }
130
+ }
131
+ // implements REQ-capability-plugin-builtin-parity-v1
132
+ export function createBuiltinSemanticClassifier() {
133
+ return new BuiltinSemanticClassifier();
134
+ }
@@ -0,0 +1,21 @@
1
+ export interface SymbolCoordinates {
2
+ sourceLine: number;
3
+ sourceColumn: number;
4
+ sourceEndLine: number;
5
+ sourceEndColumn: number;
6
+ coordinatesGeneratedAt: string;
7
+ }
8
+ export interface ManifestSymbolEntry {
9
+ id: string;
10
+ title: string;
11
+ sourceFile?: string;
12
+ sourceLine?: number;
13
+ sourceColumn?: number;
14
+ sourceEndLine?: number;
15
+ sourceEndColumn?: number;
16
+ coordinatesGeneratedAt?: string;
17
+ links?: string[];
18
+ [key: string]: unknown;
19
+ }
20
+ export declare function enrichSymbolCoordinatesWithTsMorph(entries: ManifestSymbolEntry[], workspaceRoot: string): Promise<ManifestSymbolEntry[]>;
21
+ //# sourceMappingURL=ts-morph-enrichment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-morph-enrichment.d.ts","sourceRoot":"","sources":["../../src/symbols/ts-morph-enrichment.ts"],"names":[],"mappings":"AAmCA,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAGD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAKD,wBAAsB,kCAAkC,CACtD,OAAO,EAAE,mBAAmB,EAAE,EAC9B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAsEhC"}