@contractspec/example.versioned-knowledge-base 1.44.1 → 1.45.1

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.
@@ -30,14 +30,13 @@ function createMemoryKbHandlers(store) {
30
30
  const rule = store.rules.get(input.ruleId);
31
31
  if (!rule) throw new Error("RULE_NOT_FOUND");
32
32
  const next = (store.nextRuleVersionNumberByRuleId.get(input.ruleId) ?? 0) + 1;
33
- store.nextRuleVersionNumberByRuleId.set(input.ruleId, next);
34
33
  const id = stableId("rv", `${input.ruleId}_${next}`);
35
34
  const ruleVersion = {
36
35
  id,
37
36
  ruleId: input.ruleId,
38
37
  jurisdiction: rule.jurisdiction,
39
38
  topicKey: rule.topicKey,
40
- version: next,
39
+ version: next.toString(),
41
40
  content: input.content,
42
41
  sourceRefs: input.sourceRefs,
43
42
  status: "draft",
@@ -1 +1 @@
1
- {"version":3,"file":"memory.handlers.js","names":["doc: SourceDocument","ruleVersion: RuleVersion","approved: RuleVersion","snapshot: KBSnapshot"],"sources":["../../src/handlers/memory.handlers.ts"],"sourcesContent":["interface SourceRef {\n sourceDocumentId: string;\n excerpt?: string;\n}\ninterface SourceDocument {\n id: string;\n jurisdiction: string;\n authority: string;\n title: string;\n fetchedAt: Date;\n hash: string;\n fileId: string;\n}\ninterface Rule {\n id: string;\n jurisdiction: string;\n topicKey: string;\n}\ninterface RuleVersion {\n id: string;\n ruleId: string;\n jurisdiction: string;\n topicKey: string;\n version: number;\n content: string;\n sourceRefs: SourceRef[];\n status: 'draft' | 'approved' | 'rejected';\n approvedBy?: string;\n approvedAt?: Date;\n createdAt: Date;\n}\ninterface KBSnapshot {\n id: string;\n jurisdiction: string;\n asOfDate: Date;\n includedRuleVersionIds: string[];\n publishedAt: Date;\n}\n\nexport interface MemoryKbStore {\n sources: Map<string, SourceDocument>;\n rules: Map<string, Rule>;\n ruleVersions: Map<string, RuleVersion>;\n snapshots: Map<string, KBSnapshot>;\n nextRuleVersionNumberByRuleId: Map<string, number>;\n}\n\nexport function createMemoryKbStore(): MemoryKbStore {\n return {\n sources: new Map(),\n rules: new Map(),\n ruleVersions: new Map(),\n snapshots: new Map(),\n nextRuleVersionNumberByRuleId: new Map(),\n };\n}\n\nexport interface MemoryKbHandlers {\n createRule(rule: Rule): Promise<Rule>;\n ingestSource(input: Omit<SourceDocument, 'id'>): Promise<SourceDocument>;\n upsertRuleVersion(input: {\n ruleId: string;\n content: string;\n sourceRefs: SourceRef[];\n }): Promise<RuleVersion>;\n approveRuleVersion(input: {\n ruleVersionId: string;\n approver: string;\n }): Promise<RuleVersion>;\n publishSnapshot(input: {\n jurisdiction: string;\n asOfDate: Date;\n }): Promise<KBSnapshot>;\n search(input: {\n snapshotId: string;\n jurisdiction: string;\n query: string;\n }): Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }>;\n}\n\nfunction stableId(prefix: string, value: string): string {\n return `${prefix}_${value.replace(/[^a-zA-Z0-9_-]/g, '_')}`;\n}\n\nexport function createMemoryKbHandlers(store: MemoryKbStore): MemoryKbHandlers {\n async function createRule(rule: Rule): Promise<Rule> {\n store.rules.set(rule.id, rule);\n return rule;\n }\n\n async function ingestSource(\n input: Omit<SourceDocument, 'id'>\n ): Promise<SourceDocument> {\n const id = stableId('src', `${input.jurisdiction}_${input.hash}`);\n const doc: SourceDocument = { id, ...input };\n store.sources.set(id, doc);\n return doc;\n }\n\n async function upsertRuleVersion(input: {\n ruleId: string;\n content: string;\n sourceRefs: SourceRef[];\n }): Promise<RuleVersion> {\n if (!input.sourceRefs.length) {\n throw new Error('SOURCE_REFS_REQUIRED');\n }\n const rule = store.rules.get(input.ruleId);\n if (!rule) {\n throw new Error('RULE_NOT_FOUND');\n }\n const next =\n (store.nextRuleVersionNumberByRuleId.get(input.ruleId) ?? 0) + 1;\n store.nextRuleVersionNumberByRuleId.set(input.ruleId, next);\n const id = stableId('rv', `${input.ruleId}_${next}`);\n const ruleVersion: RuleVersion = {\n id,\n ruleId: input.ruleId,\n jurisdiction: rule.jurisdiction,\n topicKey: rule.topicKey,\n version: next,\n content: input.content,\n sourceRefs: input.sourceRefs,\n status: 'draft',\n createdAt: new Date(),\n approvedAt: undefined,\n approvedBy: undefined,\n };\n store.ruleVersions.set(id, ruleVersion);\n return ruleVersion;\n }\n\n async function approveRuleVersion(input: {\n ruleVersionId: string;\n approver: string;\n }): Promise<RuleVersion> {\n const existing = store.ruleVersions.get(input.ruleVersionId);\n if (!existing) {\n throw new Error('RULE_VERSION_NOT_FOUND');\n }\n const approved: RuleVersion = {\n ...existing,\n status: 'approved',\n approvedBy: input.approver,\n approvedAt: new Date(),\n };\n store.ruleVersions.set(approved.id, approved);\n return approved;\n }\n\n async function publishSnapshot(input: {\n jurisdiction: string;\n asOfDate: Date;\n }): Promise<KBSnapshot> {\n const approved = [...store.ruleVersions.values()].filter(\n (rv) => rv.status === 'approved' && rv.jurisdiction === input.jurisdiction\n );\n if (approved.length === 0) {\n throw new Error('NO_APPROVED_RULES');\n }\n const includedRuleVersionIds = approved.map((rv) => rv.id).sort();\n const id = stableId(\n 'snap',\n `${input.jurisdiction}_${input.asOfDate.toISOString().slice(0, 10)}_${includedRuleVersionIds.length}`\n );\n const snapshot: KBSnapshot = {\n id,\n jurisdiction: input.jurisdiction,\n asOfDate: input.asOfDate,\n includedRuleVersionIds,\n publishedAt: new Date(),\n };\n store.snapshots.set(id, snapshot);\n return snapshot;\n }\n\n async function search(input: {\n snapshotId: string;\n jurisdiction: string;\n query: string;\n }): Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }> {\n const snapshot = store.snapshots.get(input.snapshotId);\n if (!snapshot) {\n throw new Error('SNAPSHOT_NOT_FOUND');\n }\n if (snapshot.jurisdiction !== input.jurisdiction) {\n throw new Error('JURISDICTION_MISMATCH');\n }\n const q = input.query.toLowerCase();\n const tokens = q\n .split(/\\s+/)\n .map((t) => t.trim())\n .filter(Boolean);\n const items = snapshot.includedRuleVersionIds\n .map((id) => store.ruleVersions.get(id))\n .filter((rv): rv is RuleVersion => Boolean(rv))\n .filter((rv) => {\n if (tokens.length === 0) return true;\n const hay = rv.content.toLowerCase();\n return tokens.every((token) => hay.includes(token));\n })\n .map((rv) => ({\n ruleVersionId: rv.id,\n excerpt: rv.content.slice(0, 120),\n }));\n return { items };\n }\n\n return {\n createRule,\n ingestSource,\n upsertRuleVersion,\n approveRuleVersion,\n publishSnapshot,\n search,\n };\n}\n"],"mappings":";AA+CA,SAAgB,sBAAqC;AACnD,QAAO;EACL,yBAAS,IAAI,KAAK;EAClB,uBAAO,IAAI,KAAK;EAChB,8BAAc,IAAI,KAAK;EACvB,2BAAW,IAAI,KAAK;EACpB,+CAA+B,IAAI,KAAK;EACzC;;AA0BH,SAAS,SAAS,QAAgB,OAAuB;AACvD,QAAO,GAAG,OAAO,GAAG,MAAM,QAAQ,mBAAmB,IAAI;;AAG3D,SAAgB,uBAAuB,OAAwC;CAC7E,eAAe,WAAW,MAA2B;AACnD,QAAM,MAAM,IAAI,KAAK,IAAI,KAAK;AAC9B,SAAO;;CAGT,eAAe,aACb,OACyB;EACzB,MAAM,KAAK,SAAS,OAAO,GAAG,MAAM,aAAa,GAAG,MAAM,OAAO;EACjE,MAAMA,MAAsB;GAAE;GAAI,GAAG;GAAO;AAC5C,QAAM,QAAQ,IAAI,IAAI,IAAI;AAC1B,SAAO;;CAGT,eAAe,kBAAkB,OAIR;AACvB,MAAI,CAAC,MAAM,WAAW,OACpB,OAAM,IAAI,MAAM,uBAAuB;EAEzC,MAAM,OAAO,MAAM,MAAM,IAAI,MAAM,OAAO;AAC1C,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,iBAAiB;EAEnC,MAAM,QACH,MAAM,8BAA8B,IAAI,MAAM,OAAO,IAAI,KAAK;AACjE,QAAM,8BAA8B,IAAI,MAAM,QAAQ,KAAK;EAC3D,MAAM,KAAK,SAAS,MAAM,GAAG,MAAM,OAAO,GAAG,OAAO;EACpD,MAAMC,cAA2B;GAC/B;GACA,QAAQ,MA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AEhC,MAAM,MAAM,CACZ,KAAK,MAAM,EAAE,MAAM,CAAC,CACpB,OAAO,QAAQ;AAalB,SAAO,EAAE,OAZK,SAAS,uBACpB,KAAK,OAAO,MAAM,aAAa,IAAI,GAAG,CAAC,CACvC,QAAQ,OAA0B,QAAQ,GAAG,CAAC,CAC9C,QAAQ,OAAO;AACd,OAAI,OAAO,WAAW,EAAG,QAAO;GAChC,MAAM,MAAM,GAAG,QAAQ,aAAa;AACpC,UAAO,OAAO,OAAO,UAAU,IAAI,SAAS,MAAM,CAAC;IACnD,CACD,KAAK,QAAQ;GACZ,eAAe,GAAG;GAClB,SAAS,GAAG,QAAQ,MAAM,GAAG,IAAI;GAClC,EAAE,EACW;;AAGlB,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"memory.handlers.js","names":["doc: SourceDocument","ruleVersion: RuleVersion","approved: RuleVersion","snapshot: KBSnapshot"],"sources":["../../src/handlers/memory.handlers.ts"],"sourcesContent":["interface SourceRef {\n sourceDocumentId: string;\n excerpt?: string;\n}\ninterface SourceDocument {\n id: string;\n jurisdiction: string;\n authority: string;\n title: string;\n fetchedAt: Date;\n hash: string;\n fileId: string;\n}\ninterface Rule {\n id: string;\n jurisdiction: string;\n topicKey: string;\n}\ninterface RuleVersion {\n id: string;\n ruleId: string;\n jurisdiction: string;\n topicKey: string;\n version: string;\n content: string;\n sourceRefs: SourceRef[];\n status: 'draft' | 'approved' | 'rejected';\n approvedBy?: string;\n approvedAt?: Date;\n createdAt: Date;\n}\ninterface KBSnapshot {\n id: string;\n jurisdiction: string;\n asOfDate: Date;\n includedRuleVersionIds: string[];\n publishedAt: Date;\n}\n\nexport interface MemoryKbStore {\n sources: Map<string, SourceDocument>;\n rules: Map<string, Rule>;\n ruleVersions: Map<string, RuleVersion>;\n snapshots: Map<string, KBSnapshot>;\n nextRuleVersionNumberByRuleId: Map<string, number>;\n}\n\nexport function createMemoryKbStore(): MemoryKbStore {\n return {\n sources: new Map(),\n rules: new Map(),\n ruleVersions: new Map(),\n snapshots: new Map(),\n nextRuleVersionNumberByRuleId: new Map(),\n };\n}\n\nexport interface MemoryKbHandlers {\n createRule(rule: Rule): Promise<Rule>;\n ingestSource(input: Omit<SourceDocument, 'id'>): Promise<SourceDocument>;\n upsertRuleVersion(input: {\n ruleId: string;\n content: string;\n sourceRefs: SourceRef[];\n }): Promise<RuleVersion>;\n approveRuleVersion(input: {\n ruleVersionId: string;\n approver: string;\n }): Promise<RuleVersion>;\n publishSnapshot(input: {\n jurisdiction: string;\n asOfDate: Date;\n }): Promise<KBSnapshot>;\n search(input: {\n snapshotId: string;\n jurisdiction: string;\n query: string;\n }): Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }>;\n}\n\nfunction stableId(prefix: string, value: string): string {\n return `${prefix}_${value.replace(/[^a-zA-Z0-9_-]/g, '_')}`;\n}\n\nexport function createMemoryKbHandlers(store: MemoryKbStore): MemoryKbHandlers {\n async function createRule(rule: Rule): Promise<Rule> {\n store.rules.set(rule.id, rule);\n return rule;\n }\n\n async function ingestSource(\n input: Omit<SourceDocument, 'id'>\n ): Promise<SourceDocument> {\n const id = stableId('src', `${input.jurisdiction}_${input.hash}`);\n const doc: SourceDocument = { id, ...input };\n store.sources.set(id, doc);\n return doc;\n }\n\n async function upsertRuleVersion(input: {\n ruleId: string;\n content: string;\n sourceRefs: SourceRef[];\n }): Promise<RuleVersion> {\n if (!input.sourceRefs.length) {\n throw new Error('SOURCE_REFS_REQUIRED');\n }\n const rule = store.rules.get(input.ruleId);\n if (!rule) {\n throw new Error('RULE_NOT_FOUND');\n }\n const next =\n (store.nextRuleVersionNumberByRuleId.get(input.ruleId) ?? 0) + 1;\n const id = stableId('rv', `${input.ruleId}_${next}`);\n const ruleVersion: RuleVersion = {\n id,\n ruleId: input.ruleId,\n jurisdiction: rule.jurisdiction,\n topicKey: rule.topicKey,\n version: next.toString(),\n content: input.content,\n sourceRefs: input.sourceRefs,\n status: 'draft',\n createdAt: new Date(),\n approvedAt: undefined,\n approvedBy: undefined,\n };\n store.ruleVersions.set(id, ruleVersion);\n return ruleVersion;\n }\n\n async function approveRuleVersion(input: {\n ruleVersionId: string;\n approver: string;\n }): Promise<RuleVersion> {\n const existing = store.ruleVersions.get(input.ruleVersionId);\n if (!existing) {\n throw new Error('RULE_VERSION_NOT_FOUND');\n }\n const approved: RuleVersion = {\n ...existing,\n status: 'approved',\n approvedBy: input.approver,\n approvedAt: new Date(),\n };\n store.ruleVersions.set(approved.id, approved);\n return approved;\n }\n\n async function publishSnapshot(input: {\n jurisdiction: string;\n asOfDate: Date;\n }): Promise<KBSnapshot> {\n const approved = [...store.ruleVersions.values()].filter(\n (rv) => rv.status === 'approved' && rv.jurisdiction === input.jurisdiction\n );\n if (approved.length === 0) {\n throw new Error('NO_APPROVED_RULES');\n }\n const includedRuleVersionIds = approved.map((rv) => rv.id).sort();\n const id = stableId(\n 'snap',\n `${input.jurisdiction}_${input.asOfDate.toISOString().slice(0, 10)}_${includedRuleVersionIds.length}`\n );\n const snapshot: KBSnapshot = {\n id,\n jurisdiction: input.jurisdiction,\n asOfDate: input.asOfDate,\n includedRuleVersionIds,\n publishedAt: new Date(),\n };\n store.snapshots.set(id, snapshot);\n return snapshot;\n }\n\n async function search(input: {\n snapshotId: string;\n jurisdiction: string;\n query: string;\n }): Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }> {\n const snapshot = store.snapshots.get(input.snapshotId);\n if (!snapshot) {\n throw new Error('SNAPSHOT_NOT_FOUND');\n }\n if (snapshot.jurisdiction !== input.jurisdiction) {\n throw new Error('JURISDICTION_MISMATCH');\n }\n const q = input.query.toLowerCase();\n const tokens = q\n .split(/\\s+/)\n .map((t) => t.trim())\n .filter(Boolean);\n const items = snapshot.includedRuleVersionIds\n .map((id) => store.ruleVersions.get(id))\n .filter((rv): rv is RuleVersion => Boolean(rv))\n .filter((rv) => {\n if (tokens.length === 0) return true;\n const hay = rv.content.toLowerCase();\n return tokens.every((token) => hay.includes(token));\n })\n .map((rv) => ({\n ruleVersionId: rv.id,\n excerpt: rv.content.slice(0, 120),\n }));\n return { items };\n }\n\n return {\n createRule,\n ingestSource,\n upsertRuleVersion,\n approveRuleVersion,\n publishSnapshot,\n search,\n };\n}\n"],"mappings":";AA+CA,SAAgB,sBAAqC;AACnD,QAAO;EACL,yBAAS,IAAI,KAAK;EAClB,uBAAO,IAAI,KAAK;EAChB,8BAAc,IAAI,KAAK;EACvB,2BAAW,IAAI,KAAK;EACpB,+CAA+B,IAAI,KAAK;EACzC;;AA0BH,SAAS,SAAS,QAAgB,OAAuB;AACvD,QAAO,GAAG,OAAO,GAAG,MAAM,QAAQ,mBAAmB,IAAI;;AAG3D,SAAgB,uBAAuB,OAAwC;CAC7E,eAAe,WAAW,MAA2B;AACnD,QAAM,MAAM,IAAI,KAAK,IAAI,KAAK;AAC9B,SAAO;;CAGT,eAAe,aACb,OACyB;EACzB,MAAM,KAAK,SAAS,OAAO,GAAG,MAAM,aAAa,GAAG,MAAM,OAAO;EACjE,MAAMA,MAAsB;GAAE;GAAI,GAAG;GAAO;AAC5C,QAAM,QAAQ,IAAI,IAAI,IAAI;AAC1B,SAAO;;CAGT,eAAe,kBAAkB,OAIR;AACvB,MAAI,CAAC,MAAM,WAAW,OACpB,OAAM,IAAI,MAAM,uBAAuB;EAEzC,MAAM,OAAO,MAAM,MAAM,IAAI,MAAM,OAAO;AAC1C,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,iBAAiB;EAEnC,MAAM,QACH,MAAM,8BAA8B,IAAI,MAAM,OAAO,IAAI,KAAK;EACjE,MAAM,KAAK,SAAS,MAAM,GAAG,MAAM,OAAO,GAAG,OAAO;EACpD,MAAMC,cAA2B;GAC/B;GACA,QAAQ,MAAM;GACd,cAAc,KAAK;GACnB,UAAU,KAAK;GACf,SAAS,KAAK,UAAU;GACxB,SAAS,MAAM;GACf,YAAY,MAAM;GAClB,QAAQ;GACR,2BAAW,IAAI,MAAM;GACrB,YAAY;G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,IAAI,GAAG,CAAC,CACvC,QAAQ,OAA0B,QAAQ,GAAG,CAAC,CAC9C,QAAQ,OAAO;AACd,OAAI,OAAO,WAAW,EAAG,QAAO;GAChC,MAAM,MAAM,GAAG,QAAQ,aAAa;AACpC,UAAO,OAAO,OAAO,UAAU,IAAI,SAAS,MAAM,CAAC;IACnD,CACD,KAAK,QAAQ;GACZ,eAAe,GAAG;GAClB,SAAS,GAAG,QAAQ,MAAM,GAAG,IAAI;GAClC,EAAE,EACW;;AAGlB,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -98,7 +98,7 @@ declare const KbUpsertRuleVersionContract: _contractspec_lib_contracts0.Operatio
98
98
  isOptional: false;
99
99
  };
100
100
  version: {
101
- type: _contractspec_lib_schema0.FieldType<number, number>;
101
+ type: _contractspec_lib_schema0.FieldType<string, string>;
102
102
  isOptional: false;
103
103
  };
104
104
  content: {
@@ -163,7 +163,7 @@ declare const KbApproveRuleVersionContract: _contractspec_lib_contracts0.Operati
163
163
  isOptional: false;
164
164
  };
165
165
  version: {
166
- type: _contractspec_lib_schema0.FieldType<number, number>;
166
+ type: _contractspec_lib_schema0.FieldType<string, string>;
167
167
  isOptional: false;
168
168
  };
169
169
  content: {
@@ -124,7 +124,7 @@ const KbIngestSourceContract = defineCommand({
124
124
  meta: {
125
125
  key: "kb.ingestSource",
126
126
  title: "Ingest Source",
127
- version: 1,
127
+ version: "1.0.0",
128
128
  stability: "experimental",
129
129
  owners: ["@examples"],
130
130
  tags: [
@@ -146,7 +146,7 @@ const KbUpsertRuleVersionContract = defineCommand({
146
146
  meta: {
147
147
  key: "kb.upsertRuleVersion",
148
148
  title: "Upsert Rule Version",
149
- version: 1,
149
+ version: "1.0.0",
150
150
  stability: "experimental",
151
151
  owners: ["@examples"],
152
152
  tags: [
@@ -182,7 +182,7 @@ const KbApproveRuleVersionContract = defineCommand({
182
182
  meta: {
183
183
  key: "kb.approveRuleVersion",
184
184
  title: "Approve Rule Version",
185
- version: 1,
185
+ version: "1.0.0",
186
186
  stability: "experimental",
187
187
  owners: ["@examples"],
188
188
  tags: [
@@ -204,7 +204,7 @@ const KbPublishSnapshotContract = defineCommand({
204
204
  meta: {
205
205
  key: "kb.publishSnapshot",
206
206
  title: "Publish Snapshot",
207
- version: 1,
207
+ version: "1.0.0",
208
208
  stability: "experimental",
209
209
  owners: ["@examples"],
210
210
  tags: [
@@ -232,7 +232,7 @@ const KbSearchContract = defineQuery({
232
232
  meta: {
233
233
  key: "kb.search",
234
234
  title: "Search KB",
235
- version: 1,
235
+ version: "1.0.0",
236
236
  stability: "experimental",
237
237
  owners: ["@examples"],
238
238
  tags: [
@@ -1 +1 @@
1
- {"version":3,"file":"kb.js","names":["defineSchemaModel"],"sources":["../../src/operations/kb.ts"],"sourcesContent":["import { defineCommand, defineQuery } from '@contractspec/lib.contracts';\nimport { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\n\nimport {\n KBSnapshotModel,\n RuleVersionModel,\n SourceDocumentModel,\n SourceRefModel,\n} from '../entities/models';\n\nconst IngestSourceInput = defineSchemaModel({\n name: 'KbIngestSourceInput',\n description: 'Ingest immutable source metadata referencing a stored file.',\n fields: {\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n authority: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n fetchedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n hash: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst UpsertRuleVersionInput = defineSchemaModel({\n name: 'KbUpsertRuleVersionInput',\n description: 'Create a new draft rule version (immutable history).',\n fields: {\n ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false },\n },\n});\n\nconst ApproveRuleVersionInput = defineSchemaModel({\n name: 'KbApproveRuleVersionInput',\n description: 'Approve a rule version (human verification).',\n fields: {\n ruleVersionId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n approver: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst PublishSnapshotInput = defineSchemaModel({\n name: 'KbPublishSnapshotInput',\n description: 'Publish a snapshot for a jurisdiction as-of a date.',\n fields: {\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n asOfDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst SearchKbInput = defineSchemaModel({\n name: 'KbSearchInput',\n description: 'Search within a published snapshot.',\n fields: {\n snapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n query: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst SearchKbResultItem = defineSchemaModel({\n name: 'KbSearchResultItem',\n description: 'Search result referencing a specific rule version.',\n fields: {\n ruleVersionId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nconst SearchKbOutput = defineSchemaModel({\n name: 'KbSearchOutput',\n description: 'Search results constrained to snapshot + jurisdiction.',\n fields: {\n items: { type: SearchKbResultItem, isArray: true, isOptional: false },\n },\n});\n\nexport const KbIngestSourceContract = defineCommand({\n meta: {\n key: 'kb.ingestSource',\n title: 'Ingest Source',\n version: 1,\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'sources', 'ingestion'],\n description: 'Ingest immutable source document metadata.',\n goal: 'Store traceable source documents for curated KB.',\n context: 'Called when an admin uploads/records authoritative sources.',\n },\n io: {\n input: IngestSourceInput,\n output: SourceDocumentModel,\n },\n policy: { auth: 'user' },\n});\n\nexport const KbUpsertRuleVersionContract = defineCommand({\n meta: {\n key: 'kb.upsertRuleVersion',\n title: 'Upsert Rule Version',\n version: 1,\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'rules', 'versioning'],\n description: 'Create a new draft rule version with source references.',\n goal: 'Propose curated knowledge updates with traceability.',\n context: 'Automation or curators propose draft rule versions.',\n },\n io: {\n input: UpsertRuleVersionInput,\n output: RuleVersionModel,\n errors: {\n SOURCE_REFS_REQUIRED: {\n description: 'Rule version must cite at least one sourceRef',\n http: 400,\n gqlCode: 'SOURCE_REFS_REQUIRED',\n when: 'sourceRefs is empty',\n },\n RULE_NOT_FOUND: {\n description: 'Rule does not exist',\n http: 404,\n gqlCode: 'RULE_NOT_FOUND',\n when: 'ruleId is unknown',\n },\n },\n },\n policy: { auth: 'user' },\n});\n\nexport const KbApproveRuleVersionContract = defineCommand({\n meta: {\n key: 'kb.approveRuleVersion',\n title: 'Approve Rule Version',\n version: 1,\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'rules', 'approval'],\n description: 'Approve a draft rule version.',\n goal: 'Human verification step before publishing snapshots.',\n context: 'Curators/experts approve proposed KB changes.',\n },\n io: {\n input: ApproveRuleVersionInput,\n output: RuleVersionModel,\n },\n policy: { auth: 'user' },\n});\n\nexport const KbPublishSnapshotContract = defineCommand({\n meta: {\n key: 'kb.publishSnapshot',\n title: 'Publish Snapshot',\n version: 1,\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'snapshots', 'publishing'],\n description: 'Publish a KB snapshot for a jurisdiction.',\n goal: 'Create a stable snapshot that assistant answers can cite.',\n context:\n 'Publishing happens after approvals; snapshot is referenced by answers.',\n },\n io: {\n input: PublishSnapshotInput,\n output: KBSnapshotModel,\n errors: {\n NO_APPROVED_RULES: {\n description: 'No approved rule versions available to publish',\n http: 409,\n gqlCode: 'NO_APPROVED_RULES',\n when: 'jurisdiction has zero approved rule versions',\n },\n },\n },\n policy: { auth: 'user' },\n});\n\nexport const KbSearchContract = defineQuery({\n meta: {\n key: 'kb.search',\n title: 'Search KB',\n version: 1,\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'search', 'snapshots'],\n description: 'Search within a published KB snapshot.',\n goal: 'Provide scoped retrieval for assistant answers.',\n context: 'Assistant queries curated rules from a specific snapshot.',\n },\n io: {\n input: SearchKbInput,\n output: SearchKbOutput,\n },\n policy: { auth: 'user' },\n});\n"],"mappings":";;;;;AAUA,MAAM,oBAAoBA,oBAAkB;CAC1C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,cAAc;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC3E,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACpE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EACjE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,QAAQ;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACtE;CACF,CAAC;AAEF,MAAM,yBAAyBA,oBAAkB;CAC/C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,QAAQ;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACrE,SAAS;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACtE,YAAY;GAAE,MAAM;GAAgB,SAAS;GAAM,YAAY;GAAO;EACvE;CACF,CAAC;AAEF,MAAM,0BAA0BA,oBAAkB;CAChD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,eAAe;GACb,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE;CACF,CAAC;AAEF,MAAM,uBAAuBA,oBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,cAAc;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC3E,U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AM;IACP;GACF;EACF;CACD,QAAQ,EAAE,MAAM,QAAQ;CACzB,CAAC;AAEF,MAAa,+BAA+B,cAAc;CACxD,MAAM;EACJ,KAAK;EACL,OAAO;EACP,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAS;GAAW;EACxC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EAAE,MAAM,QAAQ;CACzB,CAAC;AAEF,MAAa,4BAA4B,cAAc;CACrD,MAAM;EACJ,KAAK;EACL,OAAO;EACP,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAa;GAAa;EAC9C,aAAa;EACb,MAAM;EACN,SACE;EACH;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACR,QAAQ,EACN,mBAAmB;GACjB,aAAa;GACb,MAAM;GACN,SAAS;GACT,MAAM;GACP,EACF;EACF;CACD,QAAQ,EAAE,MAAM,QAAQ;CACzB,CAAC;AAEF,MAAa,mBAAmB,YAAY;CAC1C,MAAM;EACJ,KAAK;EACL,OAAO;EACP,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAU;GAAY;EAC1C,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EAAE,MAAM,QAAQ;CACzB,CAAC"}
1
+ {"version":3,"file":"kb.js","names":["defineSchemaModel"],"sources":["../../src/operations/kb.ts"],"sourcesContent":["import { defineCommand, defineQuery } from '@contractspec/lib.contracts';\nimport { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\n\nimport {\n KBSnapshotModel,\n RuleVersionModel,\n SourceDocumentModel,\n SourceRefModel,\n} from '../entities/models';\n\nconst IngestSourceInput = defineSchemaModel({\n name: 'KbIngestSourceInput',\n description: 'Ingest immutable source metadata referencing a stored file.',\n fields: {\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n authority: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n fetchedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n hash: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n fileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst UpsertRuleVersionInput = defineSchemaModel({\n name: 'KbUpsertRuleVersionInput',\n description: 'Create a new draft rule version (immutable history).',\n fields: {\n ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false },\n },\n});\n\nconst ApproveRuleVersionInput = defineSchemaModel({\n name: 'KbApproveRuleVersionInput',\n description: 'Approve a rule version (human verification).',\n fields: {\n ruleVersionId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n approver: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst PublishSnapshotInput = defineSchemaModel({\n name: 'KbPublishSnapshotInput',\n description: 'Publish a snapshot for a jurisdiction as-of a date.',\n fields: {\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n asOfDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst SearchKbInput = defineSchemaModel({\n name: 'KbSearchInput',\n description: 'Search within a published snapshot.',\n fields: {\n snapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n query: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst SearchKbResultItem = defineSchemaModel({\n name: 'KbSearchResultItem',\n description: 'Search result referencing a specific rule version.',\n fields: {\n ruleVersionId: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nconst SearchKbOutput = defineSchemaModel({\n name: 'KbSearchOutput',\n description: 'Search results constrained to snapshot + jurisdiction.',\n fields: {\n items: { type: SearchKbResultItem, isArray: true, isOptional: false },\n },\n});\n\nexport const KbIngestSourceContract = defineCommand({\n meta: {\n key: 'kb.ingestSource',\n title: 'Ingest Source',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'sources', 'ingestion'],\n description: 'Ingest immutable source document metadata.',\n goal: 'Store traceable source documents for curated KB.',\n context: 'Called when an admin uploads/records authoritative sources.',\n },\n io: {\n input: IngestSourceInput,\n output: SourceDocumentModel,\n },\n policy: { auth: 'user' },\n});\n\nexport const KbUpsertRuleVersionContract = defineCommand({\n meta: {\n key: 'kb.upsertRuleVersion',\n title: 'Upsert Rule Version',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'rules', 'versioning'],\n description: 'Create a new draft rule version with source references.',\n goal: 'Propose curated knowledge updates with traceability.',\n context: 'Automation or curators propose draft rule versions.',\n },\n io: {\n input: UpsertRuleVersionInput,\n output: RuleVersionModel,\n errors: {\n SOURCE_REFS_REQUIRED: {\n description: 'Rule version must cite at least one sourceRef',\n http: 400,\n gqlCode: 'SOURCE_REFS_REQUIRED',\n when: 'sourceRefs is empty',\n },\n RULE_NOT_FOUND: {\n description: 'Rule does not exist',\n http: 404,\n gqlCode: 'RULE_NOT_FOUND',\n when: 'ruleId is unknown',\n },\n },\n },\n policy: { auth: 'user' },\n});\n\nexport const KbApproveRuleVersionContract = defineCommand({\n meta: {\n key: 'kb.approveRuleVersion',\n title: 'Approve Rule Version',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'rules', 'approval'],\n description: 'Approve a draft rule version.',\n goal: 'Human verification step before publishing snapshots.',\n context: 'Curators/experts approve proposed KB changes.',\n },\n io: {\n input: ApproveRuleVersionInput,\n output: RuleVersionModel,\n },\n policy: { auth: 'user' },\n});\n\nexport const KbPublishSnapshotContract = defineCommand({\n meta: {\n key: 'kb.publishSnapshot',\n title: 'Publish Snapshot',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'snapshots', 'publishing'],\n description: 'Publish a KB snapshot for a jurisdiction.',\n goal: 'Create a stable snapshot that assistant answers can cite.',\n context:\n 'Publishing happens after approvals; snapshot is referenced by answers.',\n },\n io: {\n input: PublishSnapshotInput,\n output: KBSnapshotModel,\n errors: {\n NO_APPROVED_RULES: {\n description: 'No approved rule versions available to publish',\n http: 409,\n gqlCode: 'NO_APPROVED_RULES',\n when: 'jurisdiction has zero approved rule versions',\n },\n },\n },\n policy: { auth: 'user' },\n});\n\nexport const KbSearchContract = defineQuery({\n meta: {\n key: 'kb.search',\n title: 'Search KB',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@examples'],\n tags: ['knowledge', 'search', 'snapshots'],\n description: 'Search within a published KB snapshot.',\n goal: 'Provide scoped retrieval for assistant answers.',\n context: 'Assistant queries curated rules from a specific snapshot.',\n },\n io: {\n input: SearchKbInput,\n output: SearchKbOutput,\n },\n policy: { auth: 'user' },\n});\n"],"mappings":";;;;;AAUA,MAAM,oBAAoBA,oBAAkB;CAC1C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,cAAc;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC3E,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACpE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EACjE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,QAAQ;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACtE;CACF,CAAC;AAEF,MAAM,yBAAyBA,oBAAkB;C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Y;CAC1C,MAAM;EACJ,KAAK;EACL,OAAO;EACP,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAU;GAAY;EAC1C,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EAAE,MAAM,QAAQ;CACzB,CAAC"}
@@ -2,7 +2,7 @@
2
2
  const VersionedKnowledgeBaseFeature = {
3
3
  meta: {
4
4
  key: "versioned-knowledge-base",
5
- version: 1,
5
+ version: "1.0.0",
6
6
  title: "Versioned Knowledge Base",
7
7
  description: "Curated KB with immutable sources, rule versions, and published snapshots.",
8
8
  domain: "knowledge",
@@ -17,41 +17,41 @@ const VersionedKnowledgeBaseFeature = {
17
17
  operations: [
18
18
  {
19
19
  key: "kb.ingestSource",
20
- version: 1
20
+ version: "1.0.0"
21
21
  },
22
22
  {
23
23
  key: "kb.upsertRuleVersion",
24
- version: 1
24
+ version: "1.0.0"
25
25
  },
26
26
  {
27
27
  key: "kb.approveRuleVersion",
28
- version: 1
28
+ version: "1.0.0"
29
29
  },
30
30
  {
31
31
  key: "kb.publishSnapshot",
32
- version: 1
32
+ version: "1.0.0"
33
33
  },
34
34
  {
35
35
  key: "kb.search",
36
- version: 1
36
+ version: "1.0.0"
37
37
  }
38
38
  ],
39
39
  events: [
40
40
  {
41
41
  key: "kb.source.ingested",
42
- version: 1
42
+ version: "1.0.0"
43
43
  },
44
44
  {
45
45
  key: "kb.ruleVersion.created",
46
- version: 1
46
+ version: "1.0.0"
47
47
  },
48
48
  {
49
49
  key: "kb.ruleVersion.approved",
50
- version: 1
50
+ version: "1.0.0"
51
51
  },
52
52
  {
53
53
  key: "kb.snapshot.published",
54
- version: 1
54
+ version: "1.0.0"
55
55
  }
56
56
  ],
57
57
  presentations: [],
@@ -59,7 +59,7 @@ const VersionedKnowledgeBaseFeature = {
59
59
  presentationsTargets: [],
60
60
  capabilities: { requires: [{
61
61
  key: "knowledge",
62
- version: 1
62
+ version: "1.0.0"
63
63
  }] }
64
64
  };
65
65
 
@@ -1 +1 @@
1
- {"version":3,"file":"versioned-knowledge-base.feature.js","names":["VersionedKnowledgeBaseFeature: FeatureModuleSpec"],"sources":["../src/versioned-knowledge-base.feature.ts"],"sourcesContent":["import type { FeatureModuleSpec } from '@contractspec/lib.contracts';\n\nexport const VersionedKnowledgeBaseFeature: FeatureModuleSpec = {\n meta: {\n key: 'versioned-knowledge-base',\n version: 1,\n title: 'Versioned Knowledge Base',\n description:\n 'Curated KB with immutable sources, rule versions, and published snapshots.',\n domain: 'knowledge',\n owners: ['@examples'],\n tags: ['knowledge', 'versioning', 'snapshots'],\n stability: 'experimental',\n },\n operations: [\n { key: 'kb.ingestSource', version: 1 },\n { key: 'kb.upsertRuleVersion', version: 1 },\n { key: 'kb.approveRuleVersion', version: 1 },\n { key: 'kb.publishSnapshot', version: 1 },\n { key: 'kb.search', version: 1 },\n ],\n events: [\n { key: 'kb.source.ingested', version: 1 },\n { key: 'kb.ruleVersion.created', version: 1 },\n { key: 'kb.ruleVersion.approved', version: 1 },\n { key: 'kb.snapshot.published', version: 1 },\n ],\n presentations: [],\n opToPresentation: [],\n presentationsTargets: [],\n capabilities: {\n requires: [{ key: 'knowledge', version: 1 }],\n },\n};\n"],"mappings":";AAEA,MAAaA,gCAAmD;CAC9D,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,QAAQ;EACR,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAc;GAAY;EAC9C,WAAW;EACZ;CACD,YAAY;EACV;GAAE,KAAK;GAAmB,SAAS;GAAG;EACtC;GAAE,KAAK;GAAwB,SAAS;GAAG;EAC3C;GAAE,KAAK;GAAyB,SAAS;GAAG;EAC5C;GAAE,KAAK;GAAsB,SAAS;GAAG;EACzC;GAAE,KAAK;GAAa,SAAS;GAAG;EACjC;CACD,QAAQ;EACN;GAAE,KAAK;GAAsB,SAAS;GAAG;EACzC;GAAE,KAAK;GAA0B,SAAS;GAAG;EAC7C;GAAE,KAAK;GAA2B,SAAS;GAAG;EAC9C;GAAE,KAAK;GAAyB,SAAS;GAAG;EAC7C;CACD,eAAe,EAAE;CACjB,kBAAkB,EAAE;CACpB,sBAAsB,EAAE;CACxB,cAAc,EACZ,UAAU,CAAC;EAAE,KAAK;EAAa,SAAS;EAAG,CAAC,EAC7C;CACF"}
1
+ {"version":3,"file":"versioned-knowledge-base.feature.js","names":["VersionedKnowledgeBaseFeature: FeatureModuleSpec"],"sources":["../src/versioned-knowledge-base.feature.ts"],"sourcesContent":["import type { FeatureModuleSpec } from '@contractspec/lib.contracts';\n\nexport const VersionedKnowledgeBaseFeature: FeatureModuleSpec = {\n meta: {\n key: 'versioned-knowledge-base',\n version: '1.0.0',\n title: 'Versioned Knowledge Base',\n description:\n 'Curated KB with immutable sources, rule versions, and published snapshots.',\n domain: 'knowledge',\n owners: ['@examples'],\n tags: ['knowledge', 'versioning', 'snapshots'],\n stability: 'experimental',\n },\n operations: [\n { key: 'kb.ingestSource', version: '1.0.0' },\n { key: 'kb.upsertRuleVersion', version: '1.0.0' },\n { key: 'kb.approveRuleVersion', version: '1.0.0' },\n { key: 'kb.publishSnapshot', version: '1.0.0' },\n { key: 'kb.search', version: '1.0.0' },\n ],\n events: [\n { key: 'kb.source.ingested', version: '1.0.0' },\n { key: 'kb.ruleVersion.created', version: '1.0.0' },\n { key: 'kb.ruleVersion.approved', version: '1.0.0' },\n { key: 'kb.snapshot.published', version: '1.0.0' },\n ],\n presentations: [],\n opToPresentation: [],\n presentationsTargets: [],\n capabilities: {\n requires: [{ key: 'knowledge', version: '1.0.0' }],\n },\n};\n"],"mappings":";AAEA,MAAaA,gCAAmD;CAC9D,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,QAAQ;EACR,QAAQ,CAAC,YAAY;EACrB,MAAM;GAAC;GAAa;GAAc;GAAY;EAC9C,WAAW;EACZ;CACD,YAAY;EACV;GAAE,KAAK;GAAmB,SAAS;GAAS;EAC5C;GAAE,KAAK;GAAwB,SAAS;GAAS;EACjD;GAAE,KAAK;GAAyB,SAAS;GAAS;EAClD;GAAE,KAAK;GAAsB,SAAS;GAAS;EAC/C;GAAE,KAAK;GAAa,SAAS;GAAS;EACvC;CACD,QAAQ;EACN;GAAE,KAAK;GAAsB,SAAS;GAAS;EAC/C;GAAE,KAAK;GAA0B,SAAS;GAAS;EACnD;GAAE,KAAK;GAA2B,SAAS;GAAS;EACpD;GAAE,KAAK;GAAyB,SAAS;GAAS;EACnD;CACD,eAAe,EAAE;CACjB,kBAAkB,EAAE;CACpB,sBAAsB,EAAE;CACxB,cAAc,EACZ,UAAU,CAAC;EAAE,KAAK;EAAa,SAAS;EAAS,CAAC,EACnD;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/example.versioned-knowledge-base",
3
- "version": "1.44.1",
3
+ "version": "1.45.1",
4
4
  "description": "Example: curated, versioned knowledge base with immutable sources, rule versions, and published snapshots.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,13 +35,13 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "dependencies": {
38
- "@contractspec/lib.contracts": "1.44.1",
39
- "@contractspec/lib.schema": "1.44.1",
38
+ "@contractspec/lib.contracts": "1.45.1",
39
+ "@contractspec/lib.schema": "1.45.1",
40
40
  "zod": "^4.1.13"
41
41
  },
42
42
  "devDependencies": {
43
- "@contractspec/tool.tsdown": "1.44.1",
44
- "@contractspec/tool.typescript": "1.44.1",
43
+ "@contractspec/tool.tsdown": "1.45.1",
44
+ "@contractspec/tool.typescript": "1.45.1",
45
45
  "tsdown": "^0.18.3",
46
46
  "typescript": "^5.9.3"
47
47
  },
@@ -47,7 +47,7 @@ export const RuleVersionModel = defineSchemaModel({
47
47
  ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
48
48
  jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
49
49
  topicKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
50
- version: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
50
+ version: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
51
  content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
52
  sourceRefs: { type: SourceRefModel, isArray: true, isOptional: false },
53
53
  status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }, // draft|approved|rejected
package/src/events.ts CHANGED
@@ -17,7 +17,7 @@ const KbSourceIngestedPayload = defineSchemaModel({
17
17
  export const KbSourceIngestedEvent = defineEvent({
18
18
  meta: {
19
19
  key: 'kb.source.ingested',
20
- version: 1,
20
+ version: '1.0.0',
21
21
  description: 'Source document ingested (immutable).',
22
22
  stability: 'experimental',
23
23
  owners: ['@examples'],
@@ -43,7 +43,7 @@ const KbRuleVersionCreatedPayload = defineSchemaModel({
43
43
  export const KbRuleVersionCreatedEvent = defineEvent({
44
44
  meta: {
45
45
  key: 'kb.ruleVersion.created',
46
- version: 1,
46
+ version: '1.0.0',
47
47
  description: 'Rule version created (draft).',
48
48
  stability: 'experimental',
49
49
  owners: ['@examples'],
@@ -67,7 +67,7 @@ const KbRuleVersionApprovedPayload = defineSchemaModel({
67
67
  export const KbRuleVersionApprovedEvent = defineEvent({
68
68
  meta: {
69
69
  key: 'kb.ruleVersion.approved',
70
- version: 1,
70
+ version: '1.0.0',
71
71
  description: 'Rule version approved (human verified).',
72
72
  stability: 'experimental',
73
73
  owners: ['@examples'],
@@ -92,7 +92,7 @@ const KbSnapshotPublishedPayload = defineSchemaModel({
92
92
  export const KbSnapshotPublishedEvent = defineEvent({
93
93
  meta: {
94
94
  key: 'kb.snapshot.published',
95
- version: 1,
95
+ version: '1.0.0',
96
96
  description: 'KB snapshot published.',
97
97
  stability: 'experimental',
98
98
  owners: ['@examples'],
package/src/example.ts CHANGED
@@ -1,11 +1,18 @@
1
- const example = {
2
- id: 'versioned-knowledge-base',
3
- title: 'Versioned Knowledge Base',
4
- summary:
5
- 'Curated KB with immutable sources, reviewable rule versions, and published snapshots.',
6
- tags: ['knowledge', 'versioning', 'snapshots'],
7
- kind: 'knowledge',
8
- visibility: 'public',
1
+ import type { ExampleSpec } from '@contractspec/lib.contracts';
2
+
3
+ const example: ExampleSpec = {
4
+ meta: {
5
+ key: 'versioned-knowledge-base',
6
+ version: '1.0.0',
7
+ title: 'Versioned Knowledge Base',
8
+ description:
9
+ 'Curated KB with immutable sources, reviewable rule versions, and published snapshots.',
10
+ kind: 'knowledge',
11
+ visibility: 'public',
12
+ stability: 'experimental',
13
+ owners: ['@platform.core'],
14
+ tags: ['knowledge', 'versioning', 'snapshots'],
15
+ },
9
16
  docs: {
10
17
  rootDocId: 'docs.examples.versioned-knowledge-base',
11
18
  },
@@ -22,6 +29,6 @@ const example = {
22
29
  studio: { enabled: true, installable: true },
23
30
  mcp: { enabled: true },
24
31
  },
25
- } as const;
32
+ };
26
33
 
27
34
  export default example;
@@ -21,7 +21,7 @@ interface RuleVersion {
21
21
  ruleId: string;
22
22
  jurisdiction: string;
23
23
  topicKey: string;
24
- version: number;
24
+ version: string;
25
25
  content: string;
26
26
  sourceRefs: SourceRef[];
27
27
  status: 'draft' | 'approved' | 'rejected';
@@ -111,14 +111,13 @@ export function createMemoryKbHandlers(store: MemoryKbStore): MemoryKbHandlers {
111
111
  }
112
112
  const next =
113
113
  (store.nextRuleVersionNumberByRuleId.get(input.ruleId) ?? 0) + 1;
114
- store.nextRuleVersionNumberByRuleId.set(input.ruleId, next);
115
114
  const id = stableId('rv', `${input.ruleId}_${next}`);
116
115
  const ruleVersion: RuleVersion = {
117
116
  id,
118
117
  ruleId: input.ruleId,
119
118
  jurisdiction: rule.jurisdiction,
120
119
  topicKey: rule.topicKey,
121
- version: next,
120
+ version: next.toString(),
122
121
  content: input.content,
123
122
  sourceRefs: input.sourceRefs,
124
123
  status: 'draft',
@@ -86,7 +86,7 @@ export const KbIngestSourceContract = defineCommand({
86
86
  meta: {
87
87
  key: 'kb.ingestSource',
88
88
  title: 'Ingest Source',
89
- version: 1,
89
+ version: '1.0.0',
90
90
  stability: 'experimental',
91
91
  owners: ['@examples'],
92
92
  tags: ['knowledge', 'sources', 'ingestion'],
@@ -105,7 +105,7 @@ export const KbUpsertRuleVersionContract = defineCommand({
105
105
  meta: {
106
106
  key: 'kb.upsertRuleVersion',
107
107
  title: 'Upsert Rule Version',
108
- version: 1,
108
+ version: '1.0.0',
109
109
  stability: 'experimental',
110
110
  owners: ['@examples'],
111
111
  tags: ['knowledge', 'rules', 'versioning'],
@@ -138,7 +138,7 @@ export const KbApproveRuleVersionContract = defineCommand({
138
138
  meta: {
139
139
  key: 'kb.approveRuleVersion',
140
140
  title: 'Approve Rule Version',
141
- version: 1,
141
+ version: '1.0.0',
142
142
  stability: 'experimental',
143
143
  owners: ['@examples'],
144
144
  tags: ['knowledge', 'rules', 'approval'],
@@ -157,7 +157,7 @@ export const KbPublishSnapshotContract = defineCommand({
157
157
  meta: {
158
158
  key: 'kb.publishSnapshot',
159
159
  title: 'Publish Snapshot',
160
- version: 1,
160
+ version: '1.0.0',
161
161
  stability: 'experimental',
162
162
  owners: ['@examples'],
163
163
  tags: ['knowledge', 'snapshots', 'publishing'],
@@ -185,7 +185,7 @@ export const KbSearchContract = defineQuery({
185
185
  meta: {
186
186
  key: 'kb.search',
187
187
  title: 'Search KB',
188
- version: 1,
188
+ version: '1.0.0',
189
189
  stability: 'experimental',
190
190
  owners: ['@examples'],
191
191
  tags: ['knowledge', 'search', 'snapshots'],
@@ -3,7 +3,7 @@ import type { FeatureModuleSpec } from '@contractspec/lib.contracts';
3
3
  export const VersionedKnowledgeBaseFeature: FeatureModuleSpec = {
4
4
  meta: {
5
5
  key: 'versioned-knowledge-base',
6
- version: 1,
6
+ version: '1.0.0',
7
7
  title: 'Versioned Knowledge Base',
8
8
  description:
9
9
  'Curated KB with immutable sources, rule versions, and published snapshots.',
@@ -13,22 +13,22 @@ export const VersionedKnowledgeBaseFeature: FeatureModuleSpec = {
13
13
  stability: 'experimental',
14
14
  },
15
15
  operations: [
16
- { key: 'kb.ingestSource', version: 1 },
17
- { key: 'kb.upsertRuleVersion', version: 1 },
18
- { key: 'kb.approveRuleVersion', version: 1 },
19
- { key: 'kb.publishSnapshot', version: 1 },
20
- { key: 'kb.search', version: 1 },
16
+ { key: 'kb.ingestSource', version: '1.0.0' },
17
+ { key: 'kb.upsertRuleVersion', version: '1.0.0' },
18
+ { key: 'kb.approveRuleVersion', version: '1.0.0' },
19
+ { key: 'kb.publishSnapshot', version: '1.0.0' },
20
+ { key: 'kb.search', version: '1.0.0' },
21
21
  ],
22
22
  events: [
23
- { key: 'kb.source.ingested', version: 1 },
24
- { key: 'kb.ruleVersion.created', version: 1 },
25
- { key: 'kb.ruleVersion.approved', version: 1 },
26
- { key: 'kb.snapshot.published', version: 1 },
23
+ { key: 'kb.source.ingested', version: '1.0.0' },
24
+ { key: 'kb.ruleVersion.created', version: '1.0.0' },
25
+ { key: 'kb.ruleVersion.approved', version: '1.0.0' },
26
+ { key: 'kb.snapshot.published', version: '1.0.0' },
27
27
  ],
28
28
  presentations: [],
29
29
  opToPresentation: [],
30
30
  presentationsTargets: [],
31
31
  capabilities: {
32
- requires: [{ key: 'knowledge', version: 1 }],
32
+ requires: [{ key: 'knowledge', version: '1.0.0' }],
33
33
  },
34
34
  };