@contractspec/example.versioned-knowledge-base 3.7.17 → 3.7.18
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.
- package/.turbo/turbo-build.log +42 -42
- package/CHANGELOG.md +10 -0
- package/dist/browser/docs/index.js +3 -27
- package/dist/browser/docs/versioned-knowledge-base.docblock.js +3 -27
- package/dist/browser/entities/index.js +1 -74
- package/dist/browser/entities/models.js +1 -74
- package/dist/browser/events.js +1 -101
- package/dist/browser/example.js +1 -35
- package/dist/browser/handlers/index.js +1 -115
- package/dist/browser/handlers/memory.handlers.js +1 -115
- package/dist/browser/index.js +4 -617
- package/dist/browser/knowledge-snapshot-publication.migration.js +2 -44
- package/dist/browser/operations/index.js +1 -257
- package/dist/browser/operations/kb.js +1 -257
- package/dist/browser/versioned-knowledge-base.feature.js +1 -41
- package/dist/docs/index.js +3 -27
- package/dist/docs/versioned-knowledge-base.docblock.js +3 -27
- package/dist/entities/index.js +1 -74
- package/dist/entities/models.js +1 -74
- package/dist/events.js +1 -101
- package/dist/example.js +1 -35
- package/dist/handlers/index.js +1 -115
- package/dist/handlers/memory.handlers.js +1 -115
- package/dist/index.js +4 -617
- package/dist/knowledge-snapshot-publication.migration.js +2 -44
- package/dist/node/docs/index.js +3 -27
- package/dist/node/docs/versioned-knowledge-base.docblock.js +3 -27
- package/dist/node/entities/index.js +1 -74
- package/dist/node/entities/models.js +1 -74
- package/dist/node/events.js +1 -101
- package/dist/node/example.js +1 -35
- package/dist/node/handlers/index.js +1 -115
- package/dist/node/handlers/memory.handlers.js +1 -115
- package/dist/node/index.js +4 -617
- package/dist/node/knowledge-snapshot-publication.migration.js +2 -44
- package/dist/node/operations/index.js +1 -257
- package/dist/node/operations/kb.js +1 -257
- package/dist/node/versioned-knowledge-base.feature.js +1 -41
- package/dist/operations/index.js +1 -257
- package/dist/operations/kb.js +1 -257
- package/dist/versioned-knowledge-base.feature.js +1 -41
- package/package.json +5 -5
|
@@ -1,50 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
OwnersEnum,
|
|
4
|
-
StabilityEnum,
|
|
5
|
-
TagsEnum
|
|
6
|
-
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
-
var KnowledgeSnapshotPublicationMigration = {
|
|
8
|
-
meta: {
|
|
9
|
-
key: "versioned-knowledge-base.migration.snapshot-publication",
|
|
10
|
-
version: "1.0.0",
|
|
11
|
-
title: "Knowledge Snapshot Publication Migration",
|
|
12
|
-
description: "Adds publication audit fields and validation checks for published knowledge snapshots.",
|
|
13
|
-
domain: "knowledge",
|
|
14
|
-
owners: [OwnersEnum.PlatformContent],
|
|
15
|
-
tags: ["knowledge", "migration", "snapshots", TagsEnum.Hygiene],
|
|
16
|
-
stability: StabilityEnum.Experimental
|
|
17
|
-
},
|
|
18
|
-
dependencies: ["versioned-knowledge-base.migration.bootstrap"],
|
|
19
|
-
plan: {
|
|
20
|
-
up: [
|
|
21
|
-
{
|
|
22
|
-
kind: "schema",
|
|
23
|
-
description: "Create the published snapshot audit table.",
|
|
24
|
-
sql: `
|
|
1
|
+
import{OwnersEnum as d,StabilityEnum as f,TagsEnum as j}from"@contractspec/lib.contracts-spec/ownership";var q={meta:{key:"versioned-knowledge-base.migration.snapshot-publication",version:"1.0.0",title:"Knowledge Snapshot Publication Migration",description:"Adds publication audit fields and validation checks for published knowledge snapshots.",domain:"knowledge",owners:[d.PlatformContent],tags:["knowledge","migration","snapshots",j.Hygiene],stability:f.Experimental},dependencies:["versioned-knowledge-base.migration.bootstrap"],plan:{up:[{kind:"schema",description:"Create the published snapshot audit table.",sql:`
|
|
25
2
|
CREATE TABLE kb_snapshot_publications (
|
|
26
3
|
snapshot_id TEXT PRIMARY KEY,
|
|
27
4
|
published_by TEXT NOT NULL,
|
|
28
5
|
published_at TIMESTAMPTZ NOT NULL,
|
|
29
6
|
source_count INTEGER NOT NULL,
|
|
30
7
|
rule_version_count INTEGER NOT NULL
|
|
31
|
-
);`
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
kind: "validation",
|
|
35
|
-
description: "Ensure snapshots have at least one approved rule version.",
|
|
36
|
-
assertion: "SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0"
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
down: [
|
|
40
|
-
{
|
|
41
|
-
kind: "schema",
|
|
42
|
-
description: "Remove the snapshot publication audit table.",
|
|
43
|
-
sql: "DROP TABLE IF EXISTS kb_snapshot_publications;"
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
export {
|
|
49
|
-
KnowledgeSnapshotPublicationMigration
|
|
50
|
-
};
|
|
8
|
+
);`},{kind:"validation",description:"Ensure snapshots have at least one approved rule version.",assertion:"SELECT COUNT(*) = 0 FROM kb_snapshots WHERE array_length(included_rule_version_ids, 1) = 0"}],down:[{kind:"schema",description:"Remove the snapshot publication audit table.",sql:"DROP TABLE IF EXISTS kb_snapshot_publications;"}]}};export{q as KnowledgeSnapshotPublicationMigration};
|
|
@@ -1,257 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineSchemaModel, ScalarTypeEnum } 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-spec";
|
|
71
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } 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
|
-
};
|
|
1
|
+
import{defineSchemaModel as s,ScalarTypeEnum as t}from"@contractspec/lib.schema";var p=s({name:"SourceDocument",description:"Immutable raw source document metadata referencing a stored file.",fields:{id:{type:t.String_unsecure(),isOptional:!1},jurisdiction:{type:t.String_unsecure(),isOptional:!1},authority:{type:t.String_unsecure(),isOptional:!1},title:{type:t.String_unsecure(),isOptional:!1},fetchedAt:{type:t.DateTime(),isOptional:!1},hash:{type:t.String_unsecure(),isOptional:!1},fileId:{type:t.String_unsecure(),isOptional:!1}}}),n=s({name:"SourceRef",description:"Reference to a source document used to justify a rule version.",fields:{sourceDocumentId:{type:t.String_unsecure(),isOptional:!1},excerpt:{type:t.String_unsecure(),isOptional:!0}}}),D=s({name:"Rule",description:"Curated rule (stable identity) with topic + jurisdiction scope.",fields:{id:{type:t.String_unsecure(),isOptional:!1},jurisdiction:{type:t.String_unsecure(),isOptional:!1},topicKey:{type:t.String_unsecure(),isOptional:!1}}}),o=s({name:"RuleVersion",description:"A versioned rule content with source references and approval status.",fields:{id:{type:t.String_unsecure(),isOptional:!1},ruleId:{type:t.String_unsecure(),isOptional:!1},jurisdiction:{type:t.String_unsecure(),isOptional:!1},topicKey:{type:t.String_unsecure(),isOptional:!1},version:{type:t.String_unsecure(),isOptional:!1},content:{type:t.String_unsecure(),isOptional:!1},sourceRefs:{type:n,isArray:!0,isOptional:!1},status:{type:t.String_unsecure(),isOptional:!1},approvedBy:{type:t.String_unsecure(),isOptional:!0},approvedAt:{type:t.DateTime(),isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1}}}),u=s({name:"KBSnapshot",description:"Published KB snapshot (as-of) referencing approved rule versions.",fields:{id:{type:t.String_unsecure(),isOptional:!1},jurisdiction:{type:t.String_unsecure(),isOptional:!1},asOfDate:{type:t.DateTime(),isOptional:!1},includedRuleVersionIds:{type:t.String_unsecure(),isArray:!0,isOptional:!1},publishedAt:{type:t.DateTime(),isOptional:!1}}});import{defineCommand as r,defineQuery as l}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as i,ScalarTypeEnum as e}from"@contractspec/lib.schema";var a=i({name:"KbIngestSourceInput",description:"Ingest immutable source metadata referencing a stored file.",fields:{jurisdiction:{type:e.String_unsecure(),isOptional:!1},authority:{type:e.String_unsecure(),isOptional:!1},title:{type:e.String_unsecure(),isOptional:!1},fetchedAt:{type:e.DateTime(),isOptional:!1},hash:{type:e.String_unsecure(),isOptional:!1},fileId:{type:e.String_unsecure(),isOptional:!1}}}),f=i({name:"KbUpsertRuleVersionInput",description:"Create a new draft rule version (immutable history).",fields:{ruleId:{type:e.String_unsecure(),isOptional:!1},content:{type:e.String_unsecure(),isOptional:!1},sourceRefs:{type:n,isArray:!0,isOptional:!1}}}),O=i({name:"KbApproveRuleVersionInput",description:"Approve a rule version (human verification).",fields:{ruleVersionId:{type:e.String_unsecure(),isOptional:!1},approver:{type:e.String_unsecure(),isOptional:!1}}}),c=i({name:"KbPublishSnapshotInput",description:"Publish a snapshot for a jurisdiction as-of a date.",fields:{jurisdiction:{type:e.String_unsecure(),isOptional:!1},asOfDate:{type:e.DateTime(),isOptional:!1}}}),g=i({name:"KbSearchInput",description:"Search within a published snapshot.",fields:{snapshotId:{type:e.String_unsecure(),isOptional:!1},jurisdiction:{type:e.String_unsecure(),isOptional:!1},query:{type:e.String_unsecure(),isOptional:!1}}}),_=i({name:"KbSearchResultItem",description:"Search result referencing a specific rule version.",fields:{ruleVersionId:{type:e.String_unsecure(),isOptional:!1},excerpt:{type:e.String_unsecure(),isOptional:!0}}}),d=i({name:"KbSearchOutput",description:"Search results constrained to snapshot + jurisdiction.",fields:{items:{type:_,isArray:!0,isOptional:!1}}}),w=r({meta:{key:"kb.ingestSource",title:"Ingest Source",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","sources","ingestion"],description:"Ingest immutable source document metadata.",goal:"Store traceable source documents for curated KB.",context:"Called when an admin uploads/records authoritative sources."},io:{input:a,output:p},policy:{auth:"user"}}),B=r({meta:{key:"kb.upsertRuleVersion",title:"Upsert Rule Version",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","rules","versioning"],description:"Create a new draft rule version with source references.",goal:"Propose curated knowledge updates with traceability.",context:"Automation or curators propose draft rule versions."},io:{input:f,output:o,errors:{SOURCE_REFS_REQUIRED:{description:"Rule version must cite at least one sourceRef",http:400,gqlCode:"SOURCE_REFS_REQUIRED",when:"sourceRefs is empty"},RULE_NOT_FOUND:{description:"Rule does not exist",http:404,gqlCode:"RULE_NOT_FOUND",when:"ruleId is unknown"}}},policy:{auth:"user"}}),R=r({meta:{key:"kb.approveRuleVersion",title:"Approve Rule Version",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","rules","approval"],description:"Approve a draft rule version.",goal:"Human verification step before publishing snapshots.",context:"Curators/experts approve proposed KB changes."},io:{input:O,output:o},policy:{auth:"user"}}),K=r({meta:{key:"kb.publishSnapshot",title:"Publish Snapshot",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","snapshots","publishing"],description:"Publish a KB snapshot for a jurisdiction.",goal:"Create a stable snapshot that assistant answers can cite.",context:"Publishing happens after approvals; snapshot is referenced by answers."},io:{input:c,output:u,errors:{NO_APPROVED_RULES:{description:"No approved rule versions available to publish",http:409,gqlCode:"NO_APPROVED_RULES",when:"jurisdiction has zero approved rule versions"}}},policy:{auth:"user"}}),k=l({meta:{key:"kb.search",title:"Search KB",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","search","snapshots"],description:"Search within a published KB snapshot.",goal:"Provide scoped retrieval for assistant answers.",context:"Assistant queries curated rules from a specific snapshot."},io:{input:g,output:d},policy:{auth:"user"}});export{B as KbUpsertRuleVersionContract,k as KbSearchContract,K as KbPublishSnapshotContract,w as KbIngestSourceContract,R as KbApproveRuleVersionContract};
|
|
@@ -1,257 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineSchemaModel, ScalarTypeEnum } 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-spec";
|
|
71
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } 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
|
-
};
|
|
1
|
+
import{defineSchemaModel as s,ScalarTypeEnum as t}from"@contractspec/lib.schema";var p=s({name:"SourceDocument",description:"Immutable raw source document metadata referencing a stored file.",fields:{id:{type:t.String_unsecure(),isOptional:!1},jurisdiction:{type:t.String_unsecure(),isOptional:!1},authority:{type:t.String_unsecure(),isOptional:!1},title:{type:t.String_unsecure(),isOptional:!1},fetchedAt:{type:t.DateTime(),isOptional:!1},hash:{type:t.String_unsecure(),isOptional:!1},fileId:{type:t.String_unsecure(),isOptional:!1}}}),n=s({name:"SourceRef",description:"Reference to a source document used to justify a rule version.",fields:{sourceDocumentId:{type:t.String_unsecure(),isOptional:!1},excerpt:{type:t.String_unsecure(),isOptional:!0}}}),D=s({name:"Rule",description:"Curated rule (stable identity) with topic + jurisdiction scope.",fields:{id:{type:t.String_unsecure(),isOptional:!1},jurisdiction:{type:t.String_unsecure(),isOptional:!1},topicKey:{type:t.String_unsecure(),isOptional:!1}}}),o=s({name:"RuleVersion",description:"A versioned rule content with source references and approval status.",fields:{id:{type:t.String_unsecure(),isOptional:!1},ruleId:{type:t.String_unsecure(),isOptional:!1},jurisdiction:{type:t.String_unsecure(),isOptional:!1},topicKey:{type:t.String_unsecure(),isOptional:!1},version:{type:t.String_unsecure(),isOptional:!1},content:{type:t.String_unsecure(),isOptional:!1},sourceRefs:{type:n,isArray:!0,isOptional:!1},status:{type:t.String_unsecure(),isOptional:!1},approvedBy:{type:t.String_unsecure(),isOptional:!0},approvedAt:{type:t.DateTime(),isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1}}}),u=s({name:"KBSnapshot",description:"Published KB snapshot (as-of) referencing approved rule versions.",fields:{id:{type:t.String_unsecure(),isOptional:!1},jurisdiction:{type:t.String_unsecure(),isOptional:!1},asOfDate:{type:t.DateTime(),isOptional:!1},includedRuleVersionIds:{type:t.String_unsecure(),isArray:!0,isOptional:!1},publishedAt:{type:t.DateTime(),isOptional:!1}}});import{defineCommand as r,defineQuery as l}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as i,ScalarTypeEnum as e}from"@contractspec/lib.schema";var a=i({name:"KbIngestSourceInput",description:"Ingest immutable source metadata referencing a stored file.",fields:{jurisdiction:{type:e.String_unsecure(),isOptional:!1},authority:{type:e.String_unsecure(),isOptional:!1},title:{type:e.String_unsecure(),isOptional:!1},fetchedAt:{type:e.DateTime(),isOptional:!1},hash:{type:e.String_unsecure(),isOptional:!1},fileId:{type:e.String_unsecure(),isOptional:!1}}}),f=i({name:"KbUpsertRuleVersionInput",description:"Create a new draft rule version (immutable history).",fields:{ruleId:{type:e.String_unsecure(),isOptional:!1},content:{type:e.String_unsecure(),isOptional:!1},sourceRefs:{type:n,isArray:!0,isOptional:!1}}}),O=i({name:"KbApproveRuleVersionInput",description:"Approve a rule version (human verification).",fields:{ruleVersionId:{type:e.String_unsecure(),isOptional:!1},approver:{type:e.String_unsecure(),isOptional:!1}}}),c=i({name:"KbPublishSnapshotInput",description:"Publish a snapshot for a jurisdiction as-of a date.",fields:{jurisdiction:{type:e.String_unsecure(),isOptional:!1},asOfDate:{type:e.DateTime(),isOptional:!1}}}),g=i({name:"KbSearchInput",description:"Search within a published snapshot.",fields:{snapshotId:{type:e.String_unsecure(),isOptional:!1},jurisdiction:{type:e.String_unsecure(),isOptional:!1},query:{type:e.String_unsecure(),isOptional:!1}}}),_=i({name:"KbSearchResultItem",description:"Search result referencing a specific rule version.",fields:{ruleVersionId:{type:e.String_unsecure(),isOptional:!1},excerpt:{type:e.String_unsecure(),isOptional:!0}}}),d=i({name:"KbSearchOutput",description:"Search results constrained to snapshot + jurisdiction.",fields:{items:{type:_,isArray:!0,isOptional:!1}}}),w=r({meta:{key:"kb.ingestSource",title:"Ingest Source",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","sources","ingestion"],description:"Ingest immutable source document metadata.",goal:"Store traceable source documents for curated KB.",context:"Called when an admin uploads/records authoritative sources."},io:{input:a,output:p},policy:{auth:"user"}}),B=r({meta:{key:"kb.upsertRuleVersion",title:"Upsert Rule Version",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","rules","versioning"],description:"Create a new draft rule version with source references.",goal:"Propose curated knowledge updates with traceability.",context:"Automation or curators propose draft rule versions."},io:{input:f,output:o,errors:{SOURCE_REFS_REQUIRED:{description:"Rule version must cite at least one sourceRef",http:400,gqlCode:"SOURCE_REFS_REQUIRED",when:"sourceRefs is empty"},RULE_NOT_FOUND:{description:"Rule does not exist",http:404,gqlCode:"RULE_NOT_FOUND",when:"ruleId is unknown"}}},policy:{auth:"user"}}),R=r({meta:{key:"kb.approveRuleVersion",title:"Approve Rule Version",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","rules","approval"],description:"Approve a draft rule version.",goal:"Human verification step before publishing snapshots.",context:"Curators/experts approve proposed KB changes."},io:{input:O,output:o},policy:{auth:"user"}}),K=r({meta:{key:"kb.publishSnapshot",title:"Publish Snapshot",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","snapshots","publishing"],description:"Publish a KB snapshot for a jurisdiction.",goal:"Create a stable snapshot that assistant answers can cite.",context:"Publishing happens after approvals; snapshot is referenced by answers."},io:{input:c,output:u,errors:{NO_APPROVED_RULES:{description:"No approved rule versions available to publish",http:409,gqlCode:"NO_APPROVED_RULES",when:"jurisdiction has zero approved rule versions"}}},policy:{auth:"user"}}),k=l({meta:{key:"kb.search",title:"Search KB",version:"1.0.0",stability:"experimental",owners:["@examples"],tags:["knowledge","search","snapshots"],description:"Search within a published KB snapshot.",goal:"Provide scoped retrieval for assistant answers.",context:"Assistant queries curated rules from a specific snapshot."},io:{input:g,output:d},policy:{auth:"user"}});export{B as KbUpsertRuleVersionContract,k as KbSearchContract,K as KbPublishSnapshotContract,w as KbIngestSourceContract,R as KbApproveRuleVersionContract};
|
|
@@ -1,41 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineFeature } from "@contractspec/lib.contracts-spec";
|
|
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
|
-
knowledge: [{ key: "kb.knowledge.rules", version: "1.0.0" }],
|
|
34
|
-
docs: [
|
|
35
|
-
"docs.examples.versioned-knowledge-base.goal",
|
|
36
|
-
"docs.examples.versioned-knowledge-base.reference"
|
|
37
|
-
]
|
|
38
|
-
});
|
|
39
|
-
export {
|
|
40
|
-
VersionedKnowledgeBaseFeature
|
|
41
|
-
};
|
|
1
|
+
import{defineFeature as g}from"@contractspec/lib.contracts-spec";var j=g({meta:{key:"versioned-knowledge-base",version:"1.0.0",title:"Versioned Knowledge Base",description:"Curated KB with immutable sources, rule versions, and published snapshots.",domain:"knowledge",owners:["@examples"],tags:["knowledge","versioning","snapshots"],stability:"experimental"},operations:[{key:"kb.ingestSource",version:"1.0.0"},{key:"kb.upsertRuleVersion",version:"1.0.0"},{key:"kb.approveRuleVersion",version:"1.0.0"},{key:"kb.publishSnapshot",version:"1.0.0"},{key:"kb.search",version:"1.0.0"}],events:[{key:"kb.source.ingested",version:"1.0.0"},{key:"kb.ruleVersion.created",version:"1.0.0"},{key:"kb.ruleVersion.approved",version:"1.0.0"},{key:"kb.snapshot.published",version:"1.0.0"}],presentations:[],opToPresentation:[],presentationsTargets:[],capabilities:{requires:[{key:"knowledge",version:"1.0.0"}]},knowledge:[{key:"kb.knowledge.rules",version:"1.0.0"}],docs:["docs.examples.versioned-knowledge-base.goal","docs.examples.versioned-knowledge-base.reference"]});export{j as VersionedKnowledgeBaseFeature};
|