@contractspec/example.versioned-knowledge-base 1.56.1 → 1.58.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 (76) hide show
  1. package/.turbo/turbo-build.log +53 -48
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +30 -0
  4. package/dist/browser/docs/index.js +44 -0
  5. package/dist/browser/docs/versioned-knowledge-base.docblock.js +44 -0
  6. package/dist/browser/entities/index.js +74 -0
  7. package/dist/browser/entities/models.js +74 -0
  8. package/dist/browser/events.js +101 -0
  9. package/dist/browser/example.js +35 -0
  10. package/dist/browser/handlers/index.js +115 -0
  11. package/dist/browser/handlers/memory.handlers.js +115 -0
  12. package/dist/browser/index.js +586 -0
  13. package/dist/browser/operations/index.js +257 -0
  14. package/dist/browser/operations/kb.js +257 -0
  15. package/dist/browser/versioned-knowledge-base.feature.js +36 -0
  16. package/dist/docs/index.d.ts +2 -1
  17. package/dist/docs/index.d.ts.map +1 -0
  18. package/dist/docs/index.js +45 -1
  19. package/dist/docs/versioned-knowledge-base.docblock.d.ts +2 -1
  20. package/dist/docs/versioned-knowledge-base.docblock.d.ts.map +1 -0
  21. package/dist/docs/versioned-knowledge-base.docblock.js +42 -28
  22. package/dist/entities/index.d.ts +2 -2
  23. package/dist/entities/index.d.ts.map +1 -0
  24. package/dist/entities/index.js +75 -3
  25. package/dist/entities/models.d.ts +127 -132
  26. package/dist/entities/models.d.ts.map +1 -1
  27. package/dist/entities/models.js +69 -145
  28. package/dist/events.d.ts +52 -58
  29. package/dist/events.d.ts.map +1 -1
  30. package/dist/events.js +92 -114
  31. package/dist/example.d.ts +2 -6
  32. package/dist/example.d.ts.map +1 -1
  33. package/dist/example.js +33 -46
  34. package/dist/handlers/index.d.ts +2 -2
  35. package/dist/handlers/index.d.ts.map +1 -0
  36. package/dist/handlers/index.js +116 -3
  37. package/dist/handlers/memory.handlers.d.ts +62 -64
  38. package/dist/handlers/memory.handlers.d.ts.map +1 -1
  39. package/dist/handlers/memory.handlers.js +110 -97
  40. package/dist/handlers/memory.handlers.test.d.ts +2 -0
  41. package/dist/handlers/memory.handlers.test.d.ts.map +1 -0
  42. package/dist/index.d.ts +13 -9
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +587 -11
  45. package/dist/node/docs/index.js +44 -0
  46. package/dist/node/docs/versioned-knowledge-base.docblock.js +44 -0
  47. package/dist/node/entities/index.js +74 -0
  48. package/dist/node/entities/models.js +74 -0
  49. package/dist/node/events.js +101 -0
  50. package/dist/node/example.js +35 -0
  51. package/dist/node/handlers/index.js +115 -0
  52. package/dist/node/handlers/memory.handlers.js +115 -0
  53. package/dist/node/index.js +586 -0
  54. package/dist/node/operations/index.js +257 -0
  55. package/dist/node/operations/kb.js +257 -0
  56. package/dist/node/versioned-knowledge-base.feature.js +36 -0
  57. package/dist/operations/index.d.ts +2 -2
  58. package/dist/operations/index.d.ts.map +1 -0
  59. package/dist/operations/index.js +257 -2
  60. package/dist/operations/kb.d.ts +252 -258
  61. package/dist/operations/kb.d.ts.map +1 -1
  62. package/dist/operations/kb.js +246 -244
  63. package/dist/versioned-knowledge-base.feature.d.ts +1 -6
  64. package/dist/versioned-knowledge-base.feature.d.ts.map +1 -1
  65. package/dist/versioned-knowledge-base.feature.js +35 -68
  66. package/package.json +141 -38
  67. package/tsdown.config.js +1 -2
  68. package/.turbo/turbo-build$colon$bundle.log +0 -47
  69. package/dist/docs/versioned-knowledge-base.docblock.js.map +0 -1
  70. package/dist/entities/models.js.map +0 -1
  71. package/dist/events.js.map +0 -1
  72. package/dist/example.js.map +0 -1
  73. package/dist/handlers/memory.handlers.js.map +0 -1
  74. package/dist/operations/kb.js.map +0 -1
  75. package/dist/versioned-knowledge-base.feature.js.map +0 -1
  76. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,257 @@
1
+ // src/entities/models.ts
2
+ import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
3
+ var SourceDocumentModel = defineSchemaModel({
4
+ name: "SourceDocument",
5
+ description: "Immutable raw source document metadata referencing a stored file.",
6
+ fields: {
7
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
8
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
9
+ authority: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
+ fetchedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
12
+ hash: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
+ fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
14
+ }
15
+ });
16
+ var SourceRefModel = defineSchemaModel({
17
+ name: "SourceRef",
18
+ description: "Reference to a source document used to justify a rule version.",
19
+ fields: {
20
+ sourceDocumentId: {
21
+ type: ScalarTypeEnum.String_unsecure(),
22
+ isOptional: false
23
+ },
24
+ excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
25
+ }
26
+ });
27
+ var RuleModel = defineSchemaModel({
28
+ name: "Rule",
29
+ description: "Curated rule (stable identity) with topic + jurisdiction scope.",
30
+ fields: {
31
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
33
+ topicKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
34
+ }
35
+ });
36
+ var RuleVersionModel = defineSchemaModel({
37
+ name: "RuleVersion",
38
+ description: "A versioned rule content with source references and approval status.",
39
+ fields: {
40
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
+ ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
42
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
+ topicKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
44
+ version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
+ sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false },
47
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
48
+ approvedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
49
+ approvedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
50
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
51
+ }
52
+ });
53
+ var KBSnapshotModel = defineSchemaModel({
54
+ name: "KBSnapshot",
55
+ description: "Published KB snapshot (as-of) referencing approved rule versions.",
56
+ fields: {
57
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
59
+ asOfDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },
60
+ includedRuleVersionIds: {
61
+ type: ScalarTypeEnum.String_unsecure(),
62
+ isArray: true,
63
+ isOptional: false
64
+ },
65
+ publishedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
66
+ }
67
+ });
68
+
69
+ // src/operations/kb.ts
70
+ import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
71
+ import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
72
+ var IngestSourceInput = defineSchemaModel2({
73
+ name: "KbIngestSourceInput",
74
+ description: "Ingest immutable source metadata referencing a stored file.",
75
+ fields: {
76
+ jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
77
+ authority: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
78
+ title: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
79
+ fetchedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
80
+ hash: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
81
+ fileId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
82
+ }
83
+ });
84
+ var UpsertRuleVersionInput = defineSchemaModel2({
85
+ name: "KbUpsertRuleVersionInput",
86
+ description: "Create a new draft rule version (immutable history).",
87
+ fields: {
88
+ ruleId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
89
+ content: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
90
+ sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false }
91
+ }
92
+ });
93
+ var ApproveRuleVersionInput = defineSchemaModel2({
94
+ name: "KbApproveRuleVersionInput",
95
+ description: "Approve a rule version (human verification).",
96
+ fields: {
97
+ ruleVersionId: {
98
+ type: ScalarTypeEnum2.String_unsecure(),
99
+ isOptional: false
100
+ },
101
+ approver: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
102
+ }
103
+ });
104
+ var PublishSnapshotInput = defineSchemaModel2({
105
+ name: "KbPublishSnapshotInput",
106
+ description: "Publish a snapshot for a jurisdiction as-of a date.",
107
+ fields: {
108
+ jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
109
+ asOfDate: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
110
+ }
111
+ });
112
+ var SearchKbInput = defineSchemaModel2({
113
+ name: "KbSearchInput",
114
+ description: "Search within a published snapshot.",
115
+ fields: {
116
+ snapshotId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
117
+ jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
118
+ query: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
119
+ }
120
+ });
121
+ var SearchKbResultItem = defineSchemaModel2({
122
+ name: "KbSearchResultItem",
123
+ description: "Search result referencing a specific rule version.",
124
+ fields: {
125
+ ruleVersionId: {
126
+ type: ScalarTypeEnum2.String_unsecure(),
127
+ isOptional: false
128
+ },
129
+ excerpt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
130
+ }
131
+ });
132
+ var SearchKbOutput = defineSchemaModel2({
133
+ name: "KbSearchOutput",
134
+ description: "Search results constrained to snapshot + jurisdiction.",
135
+ fields: {
136
+ items: { type: SearchKbResultItem, isArray: true, isOptional: false }
137
+ }
138
+ });
139
+ var KbIngestSourceContract = defineCommand({
140
+ meta: {
141
+ key: "kb.ingestSource",
142
+ title: "Ingest Source",
143
+ version: "1.0.0",
144
+ stability: "experimental",
145
+ owners: ["@examples"],
146
+ tags: ["knowledge", "sources", "ingestion"],
147
+ description: "Ingest immutable source document metadata.",
148
+ goal: "Store traceable source documents for curated KB.",
149
+ context: "Called when an admin uploads/records authoritative sources."
150
+ },
151
+ io: {
152
+ input: IngestSourceInput,
153
+ output: SourceDocumentModel
154
+ },
155
+ policy: { auth: "user" }
156
+ });
157
+ var KbUpsertRuleVersionContract = defineCommand({
158
+ meta: {
159
+ key: "kb.upsertRuleVersion",
160
+ title: "Upsert Rule Version",
161
+ version: "1.0.0",
162
+ stability: "experimental",
163
+ owners: ["@examples"],
164
+ tags: ["knowledge", "rules", "versioning"],
165
+ description: "Create a new draft rule version with source references.",
166
+ goal: "Propose curated knowledge updates with traceability.",
167
+ context: "Automation or curators propose draft rule versions."
168
+ },
169
+ io: {
170
+ input: UpsertRuleVersionInput,
171
+ output: RuleVersionModel,
172
+ errors: {
173
+ SOURCE_REFS_REQUIRED: {
174
+ description: "Rule version must cite at least one sourceRef",
175
+ http: 400,
176
+ gqlCode: "SOURCE_REFS_REQUIRED",
177
+ when: "sourceRefs is empty"
178
+ },
179
+ RULE_NOT_FOUND: {
180
+ description: "Rule does not exist",
181
+ http: 404,
182
+ gqlCode: "RULE_NOT_FOUND",
183
+ when: "ruleId is unknown"
184
+ }
185
+ }
186
+ },
187
+ policy: { auth: "user" }
188
+ });
189
+ var KbApproveRuleVersionContract = defineCommand({
190
+ meta: {
191
+ key: "kb.approveRuleVersion",
192
+ title: "Approve Rule Version",
193
+ version: "1.0.0",
194
+ stability: "experimental",
195
+ owners: ["@examples"],
196
+ tags: ["knowledge", "rules", "approval"],
197
+ description: "Approve a draft rule version.",
198
+ goal: "Human verification step before publishing snapshots.",
199
+ context: "Curators/experts approve proposed KB changes."
200
+ },
201
+ io: {
202
+ input: ApproveRuleVersionInput,
203
+ output: RuleVersionModel
204
+ },
205
+ policy: { auth: "user" }
206
+ });
207
+ var KbPublishSnapshotContract = defineCommand({
208
+ meta: {
209
+ key: "kb.publishSnapshot",
210
+ title: "Publish Snapshot",
211
+ version: "1.0.0",
212
+ stability: "experimental",
213
+ owners: ["@examples"],
214
+ tags: ["knowledge", "snapshots", "publishing"],
215
+ description: "Publish a KB snapshot for a jurisdiction.",
216
+ goal: "Create a stable snapshot that assistant answers can cite.",
217
+ context: "Publishing happens after approvals; snapshot is referenced by answers."
218
+ },
219
+ io: {
220
+ input: PublishSnapshotInput,
221
+ output: KBSnapshotModel,
222
+ errors: {
223
+ NO_APPROVED_RULES: {
224
+ description: "No approved rule versions available to publish",
225
+ http: 409,
226
+ gqlCode: "NO_APPROVED_RULES",
227
+ when: "jurisdiction has zero approved rule versions"
228
+ }
229
+ }
230
+ },
231
+ policy: { auth: "user" }
232
+ });
233
+ var KbSearchContract = defineQuery({
234
+ meta: {
235
+ key: "kb.search",
236
+ title: "Search KB",
237
+ version: "1.0.0",
238
+ stability: "experimental",
239
+ owners: ["@examples"],
240
+ tags: ["knowledge", "search", "snapshots"],
241
+ description: "Search within a published KB snapshot.",
242
+ goal: "Provide scoped retrieval for assistant answers.",
243
+ context: "Assistant queries curated rules from a specific snapshot."
244
+ },
245
+ io: {
246
+ input: SearchKbInput,
247
+ output: SearchKbOutput
248
+ },
249
+ policy: { auth: "user" }
250
+ });
251
+ export {
252
+ KbUpsertRuleVersionContract,
253
+ KbSearchContract,
254
+ KbPublishSnapshotContract,
255
+ KbIngestSourceContract,
256
+ KbApproveRuleVersionContract
257
+ };
@@ -0,0 +1,257 @@
1
+ // src/entities/models.ts
2
+ import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
3
+ var SourceDocumentModel = defineSchemaModel({
4
+ name: "SourceDocument",
5
+ description: "Immutable raw source document metadata referencing a stored file.",
6
+ fields: {
7
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
8
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
9
+ authority: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
+ fetchedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
12
+ hash: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
+ fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
14
+ }
15
+ });
16
+ var SourceRefModel = defineSchemaModel({
17
+ name: "SourceRef",
18
+ description: "Reference to a source document used to justify a rule version.",
19
+ fields: {
20
+ sourceDocumentId: {
21
+ type: ScalarTypeEnum.String_unsecure(),
22
+ isOptional: false
23
+ },
24
+ excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
25
+ }
26
+ });
27
+ var RuleModel = defineSchemaModel({
28
+ name: "Rule",
29
+ description: "Curated rule (stable identity) with topic + jurisdiction scope.",
30
+ fields: {
31
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
33
+ topicKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
34
+ }
35
+ });
36
+ var RuleVersionModel = defineSchemaModel({
37
+ name: "RuleVersion",
38
+ description: "A versioned rule content with source references and approval status.",
39
+ fields: {
40
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
+ ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
42
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
+ topicKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
44
+ version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
+ sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false },
47
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
48
+ approvedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
49
+ approvedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
50
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
51
+ }
52
+ });
53
+ var KBSnapshotModel = defineSchemaModel({
54
+ name: "KBSnapshot",
55
+ description: "Published KB snapshot (as-of) referencing approved rule versions.",
56
+ fields: {
57
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
+ jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
59
+ asOfDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },
60
+ includedRuleVersionIds: {
61
+ type: ScalarTypeEnum.String_unsecure(),
62
+ isArray: true,
63
+ isOptional: false
64
+ },
65
+ publishedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
66
+ }
67
+ });
68
+
69
+ // src/operations/kb.ts
70
+ import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
71
+ import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
72
+ var IngestSourceInput = defineSchemaModel2({
73
+ name: "KbIngestSourceInput",
74
+ description: "Ingest immutable source metadata referencing a stored file.",
75
+ fields: {
76
+ jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
77
+ authority: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
78
+ title: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
79
+ fetchedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
80
+ hash: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
81
+ fileId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
82
+ }
83
+ });
84
+ var UpsertRuleVersionInput = defineSchemaModel2({
85
+ name: "KbUpsertRuleVersionInput",
86
+ description: "Create a new draft rule version (immutable history).",
87
+ fields: {
88
+ ruleId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
89
+ content: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
90
+ sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false }
91
+ }
92
+ });
93
+ var ApproveRuleVersionInput = defineSchemaModel2({
94
+ name: "KbApproveRuleVersionInput",
95
+ description: "Approve a rule version (human verification).",
96
+ fields: {
97
+ ruleVersionId: {
98
+ type: ScalarTypeEnum2.String_unsecure(),
99
+ isOptional: false
100
+ },
101
+ approver: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
102
+ }
103
+ });
104
+ var PublishSnapshotInput = defineSchemaModel2({
105
+ name: "KbPublishSnapshotInput",
106
+ description: "Publish a snapshot for a jurisdiction as-of a date.",
107
+ fields: {
108
+ jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
109
+ asOfDate: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
110
+ }
111
+ });
112
+ var SearchKbInput = defineSchemaModel2({
113
+ name: "KbSearchInput",
114
+ description: "Search within a published snapshot.",
115
+ fields: {
116
+ snapshotId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
117
+ jurisdiction: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
118
+ query: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
119
+ }
120
+ });
121
+ var SearchKbResultItem = defineSchemaModel2({
122
+ name: "KbSearchResultItem",
123
+ description: "Search result referencing a specific rule version.",
124
+ fields: {
125
+ ruleVersionId: {
126
+ type: ScalarTypeEnum2.String_unsecure(),
127
+ isOptional: false
128
+ },
129
+ excerpt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
130
+ }
131
+ });
132
+ var SearchKbOutput = defineSchemaModel2({
133
+ name: "KbSearchOutput",
134
+ description: "Search results constrained to snapshot + jurisdiction.",
135
+ fields: {
136
+ items: { type: SearchKbResultItem, isArray: true, isOptional: false }
137
+ }
138
+ });
139
+ var KbIngestSourceContract = defineCommand({
140
+ meta: {
141
+ key: "kb.ingestSource",
142
+ title: "Ingest Source",
143
+ version: "1.0.0",
144
+ stability: "experimental",
145
+ owners: ["@examples"],
146
+ tags: ["knowledge", "sources", "ingestion"],
147
+ description: "Ingest immutable source document metadata.",
148
+ goal: "Store traceable source documents for curated KB.",
149
+ context: "Called when an admin uploads/records authoritative sources."
150
+ },
151
+ io: {
152
+ input: IngestSourceInput,
153
+ output: SourceDocumentModel
154
+ },
155
+ policy: { auth: "user" }
156
+ });
157
+ var KbUpsertRuleVersionContract = defineCommand({
158
+ meta: {
159
+ key: "kb.upsertRuleVersion",
160
+ title: "Upsert Rule Version",
161
+ version: "1.0.0",
162
+ stability: "experimental",
163
+ owners: ["@examples"],
164
+ tags: ["knowledge", "rules", "versioning"],
165
+ description: "Create a new draft rule version with source references.",
166
+ goal: "Propose curated knowledge updates with traceability.",
167
+ context: "Automation or curators propose draft rule versions."
168
+ },
169
+ io: {
170
+ input: UpsertRuleVersionInput,
171
+ output: RuleVersionModel,
172
+ errors: {
173
+ SOURCE_REFS_REQUIRED: {
174
+ description: "Rule version must cite at least one sourceRef",
175
+ http: 400,
176
+ gqlCode: "SOURCE_REFS_REQUIRED",
177
+ when: "sourceRefs is empty"
178
+ },
179
+ RULE_NOT_FOUND: {
180
+ description: "Rule does not exist",
181
+ http: 404,
182
+ gqlCode: "RULE_NOT_FOUND",
183
+ when: "ruleId is unknown"
184
+ }
185
+ }
186
+ },
187
+ policy: { auth: "user" }
188
+ });
189
+ var KbApproveRuleVersionContract = defineCommand({
190
+ meta: {
191
+ key: "kb.approveRuleVersion",
192
+ title: "Approve Rule Version",
193
+ version: "1.0.0",
194
+ stability: "experimental",
195
+ owners: ["@examples"],
196
+ tags: ["knowledge", "rules", "approval"],
197
+ description: "Approve a draft rule version.",
198
+ goal: "Human verification step before publishing snapshots.",
199
+ context: "Curators/experts approve proposed KB changes."
200
+ },
201
+ io: {
202
+ input: ApproveRuleVersionInput,
203
+ output: RuleVersionModel
204
+ },
205
+ policy: { auth: "user" }
206
+ });
207
+ var KbPublishSnapshotContract = defineCommand({
208
+ meta: {
209
+ key: "kb.publishSnapshot",
210
+ title: "Publish Snapshot",
211
+ version: "1.0.0",
212
+ stability: "experimental",
213
+ owners: ["@examples"],
214
+ tags: ["knowledge", "snapshots", "publishing"],
215
+ description: "Publish a KB snapshot for a jurisdiction.",
216
+ goal: "Create a stable snapshot that assistant answers can cite.",
217
+ context: "Publishing happens after approvals; snapshot is referenced by answers."
218
+ },
219
+ io: {
220
+ input: PublishSnapshotInput,
221
+ output: KBSnapshotModel,
222
+ errors: {
223
+ NO_APPROVED_RULES: {
224
+ description: "No approved rule versions available to publish",
225
+ http: 409,
226
+ gqlCode: "NO_APPROVED_RULES",
227
+ when: "jurisdiction has zero approved rule versions"
228
+ }
229
+ }
230
+ },
231
+ policy: { auth: "user" }
232
+ });
233
+ var KbSearchContract = defineQuery({
234
+ meta: {
235
+ key: "kb.search",
236
+ title: "Search KB",
237
+ version: "1.0.0",
238
+ stability: "experimental",
239
+ owners: ["@examples"],
240
+ tags: ["knowledge", "search", "snapshots"],
241
+ description: "Search within a published KB snapshot.",
242
+ goal: "Provide scoped retrieval for assistant answers.",
243
+ context: "Assistant queries curated rules from a specific snapshot."
244
+ },
245
+ io: {
246
+ input: SearchKbInput,
247
+ output: SearchKbOutput
248
+ },
249
+ policy: { auth: "user" }
250
+ });
251
+ export {
252
+ KbUpsertRuleVersionContract,
253
+ KbSearchContract,
254
+ KbPublishSnapshotContract,
255
+ KbIngestSourceContract,
256
+ KbApproveRuleVersionContract
257
+ };
@@ -0,0 +1,36 @@
1
+ // src/versioned-knowledge-base.feature.ts
2
+ import { defineFeature } from "@contractspec/lib.contracts";
3
+ var VersionedKnowledgeBaseFeature = defineFeature({
4
+ meta: {
5
+ key: "versioned-knowledge-base",
6
+ version: "1.0.0",
7
+ title: "Versioned Knowledge Base",
8
+ description: "Curated KB with immutable sources, rule versions, and published snapshots.",
9
+ domain: "knowledge",
10
+ owners: ["@examples"],
11
+ tags: ["knowledge", "versioning", "snapshots"],
12
+ stability: "experimental"
13
+ },
14
+ operations: [
15
+ { key: "kb.ingestSource", version: "1.0.0" },
16
+ { key: "kb.upsertRuleVersion", version: "1.0.0" },
17
+ { key: "kb.approveRuleVersion", version: "1.0.0" },
18
+ { key: "kb.publishSnapshot", version: "1.0.0" },
19
+ { key: "kb.search", version: "1.0.0" }
20
+ ],
21
+ events: [
22
+ { key: "kb.source.ingested", version: "1.0.0" },
23
+ { key: "kb.ruleVersion.created", version: "1.0.0" },
24
+ { key: "kb.ruleVersion.approved", version: "1.0.0" },
25
+ { key: "kb.snapshot.published", version: "1.0.0" }
26
+ ],
27
+ presentations: [],
28
+ opToPresentation: [],
29
+ presentationsTargets: [],
30
+ capabilities: {
31
+ requires: [{ key: "knowledge", version: "1.0.0" }]
32
+ }
33
+ });
34
+ export {
35
+ VersionedKnowledgeBaseFeature
36
+ };
@@ -1,2 +1,2 @@
1
- import { KbApproveRuleVersionContract, KbIngestSourceContract, KbPublishSnapshotContract, KbSearchContract, KbUpsertRuleVersionContract } from "./kb.js";
2
- export { KbApproveRuleVersionContract, KbIngestSourceContract, KbPublishSnapshotContract, KbSearchContract, KbUpsertRuleVersionContract };
1
+ export * from './kb';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}