@lssm/example.versioned-knowledge-base 0.0.0-canary-20251213172311 → 0.0.0-canary-20251215220103

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.
@@ -1,6 +1,6 @@
1
1
  $ bun build:bundle && bun build:types
2
2
  $ tsdown
3
- ℹ tsdown v0.17.0 powered by rolldown v1.0.0-beta.53
3
+ ℹ tsdown v0.17.4 powered by rolldown v1.0.0-beta.53
4
4
  ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/versioned-knowledge-base/tsdown.config.js
5
5
  ℹ entry: src/events.ts, src/example.ts, src/feature.ts, src/index.ts, src/contracts/index.ts, src/contracts/kb.ts, src/docs/index.ts, src/docs/versioned-knowledge-base.docblock.ts, src/entities/index.ts, src/entities/models.ts, src/handlers/index.ts, src/handlers/memory.handlers.ts
6
6
  ℹ target: esnext
@@ -19,5 +19,5 @@ $ tsdown
19
19
  ℹ dist/handlers/index.js 0.15 kB │ gzip: 0.10 kB
20
20
  ℹ dist/docs/index.js 0.05 kB │ gzip: 0.07 kB
21
21
  ℹ 12 files, total: 15.02 kB
22
- ✔ Build complete in 66ms
22
+ ✔ Build complete in 77ms
23
23
  $ tsc --noEmit
package/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @lssm/example.versioned-knowledge-base
2
2
 
3
- ## 0.0.0-canary-20251213172311
3
+ ## 0.0.0-canary-20251215220103
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - Updated dependencies [3086383]
8
- - @lssm/lib.contracts@0.0.0-canary-20251213172311
9
- - @lssm/lib.schema@0.0.0-canary-20251213172311
8
+ - @lssm/lib.contracts@0.0.0-canary-20251215220103
9
+ - @lssm/lib.schema@0.0.0-canary-20251215220103
package/README.md CHANGED
@@ -22,3 +22,4 @@ bun test
22
22
  ```
23
23
 
24
24
 
25
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/example.versioned-knowledge-base",
3
- "version": "0.0.0-canary-20251213172311",
3
+ "version": "0.0.0-canary-20251215220103",
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",
@@ -40,7 +40,7 @@
40
40
  "devDependencies": {
41
41
  "@lssm/tool.tsdown": "workspace:*",
42
42
  "@lssm/tool.typescript": "workspace:*",
43
- "tsdown": "^0.17.0",
43
+ "tsdown": "^0.17.4",
44
44
  "typescript": "^5.9.3"
45
45
  },
46
46
  "publishConfig": {
@@ -1,3 +1 @@
1
1
  export * from './kb';
2
-
3
-
@@ -35,7 +35,10 @@ const ApproveRuleVersionInput = defineSchemaModel({
35
35
  name: 'KbApproveRuleVersionInput',
36
36
  description: 'Approve a rule version (human verification).',
37
37
  fields: {
38
- ruleVersionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ ruleVersionId: {
39
+ type: ScalarTypeEnum.String_unsecure(),
40
+ isOptional: false,
41
+ },
39
42
  approver: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
40
43
  },
41
44
  });
@@ -63,7 +66,10 @@ const SearchKbResultItem = defineSchemaModel({
63
66
  name: 'KbSearchResultItem',
64
67
  description: 'Search result referencing a specific rule version.',
65
68
  fields: {
66
- ruleVersionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
69
+ ruleVersionId: {
70
+ type: ScalarTypeEnum.String_unsecure(),
71
+ isOptional: false,
72
+ },
67
73
  excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
68
74
  },
69
75
  });
@@ -153,7 +159,8 @@ export const KbPublishSnapshotContract = defineCommand({
153
159
  tags: ['knowledge', 'snapshots', 'publishing'],
154
160
  description: 'Publish a KB snapshot for a jurisdiction.',
155
161
  goal: 'Create a stable snapshot that assistant answers can cite.',
156
- context: 'Publishing happens after approvals; snapshot is referenced by answers.',
162
+ context:
163
+ 'Publishing happens after approvals; snapshot is referenced by answers.',
157
164
  },
158
165
  io: {
159
166
  input: PublishSnapshotInput,
@@ -187,5 +194,3 @@ export const KbSearchContract = defineQuery({
187
194
  },
188
195
  policy: { auth: 'user' },
189
196
  });
190
-
191
-
package/src/docs/index.ts CHANGED
@@ -1,3 +1 @@
1
1
  import './versioned-knowledge-base.docblock';
2
-
3
-
@@ -27,5 +27,3 @@ const docBlocks: DocBlock[] = [
27
27
  ];
28
28
 
29
29
  registerDocBlocks(docBlocks);
30
-
31
-
@@ -1,3 +1 @@
1
1
  export * from './models';
2
-
3
-
@@ -2,7 +2,8 @@ import { ScalarTypeEnum, defineSchemaModel } from '@lssm/lib.schema';
2
2
 
3
3
  export const SourceDocumentModel = defineSchemaModel({
4
4
  name: 'SourceDocument',
5
- description: 'Immutable raw source document metadata referencing a stored file.',
5
+ description:
6
+ 'Immutable raw source document metadata referencing a stored file.',
6
7
  fields: {
7
8
  id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
8
9
  jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
@@ -18,14 +19,18 @@ export const SourceRefModel = defineSchemaModel({
18
19
  name: 'SourceRef',
19
20
  description: 'Reference to a source document used to justify a rule version.',
20
21
  fields: {
21
- sourceDocumentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ sourceDocumentId: {
23
+ type: ScalarTypeEnum.String_unsecure(),
24
+ isOptional: false,
25
+ },
22
26
  excerpt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
23
27
  },
24
28
  });
25
29
 
26
30
  export const RuleModel = defineSchemaModel({
27
31
  name: 'Rule',
28
- description: 'Curated rule (stable identity) with topic + jurisdiction scope.',
32
+ description:
33
+ 'Curated rule (stable identity) with topic + jurisdiction scope.',
29
34
  fields: {
30
35
  id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
31
36
  jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
@@ -35,7 +40,8 @@ export const RuleModel = defineSchemaModel({
35
40
 
36
41
  export const RuleVersionModel = defineSchemaModel({
37
42
  name: 'RuleVersion',
38
- description: 'A versioned rule content with source references and approval status.',
43
+ description:
44
+ 'A versioned rule content with source references and approval status.',
39
45
  fields: {
40
46
  id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
47
  ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
@@ -53,7 +59,8 @@ export const RuleVersionModel = defineSchemaModel({
53
59
 
54
60
  export const KBSnapshotModel = defineSchemaModel({
55
61
  name: 'KBSnapshot',
56
- description: 'Published KB snapshot (as-of) referencing approved rule versions.',
62
+ description:
63
+ 'Published KB snapshot (as-of) referencing approved rule versions.',
57
64
  fields: {
58
65
  id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
59
66
  jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
@@ -66,5 +73,3 @@ export const KBSnapshotModel = defineSchemaModel({
66
73
  publishedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
67
74
  },
68
75
  });
69
-
70
-
package/src/events.ts CHANGED
@@ -5,7 +5,10 @@ const KbSourceIngestedPayload = defineSchemaModel({
5
5
  name: 'KbSourceIngestedPayload',
6
6
  description: 'Emitted when a source document is ingested.',
7
7
  fields: {
8
- sourceDocumentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
8
+ sourceDocumentId: {
9
+ type: ScalarTypeEnum.String_unsecure(),
10
+ isOptional: false,
11
+ },
9
12
  jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
13
  hash: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
14
  },
@@ -22,7 +25,10 @@ const KbRuleVersionCreatedPayload = defineSchemaModel({
22
25
  name: 'KbRuleVersionCreatedPayload',
23
26
  description: 'Emitted when a rule version draft is created.',
24
27
  fields: {
25
- ruleVersionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
+ ruleVersionId: {
29
+ type: ScalarTypeEnum.String_unsecure(),
30
+ isOptional: false,
31
+ },
26
32
  ruleId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
33
  jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
34
  status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
@@ -40,7 +46,10 @@ const KbRuleVersionApprovedPayload = defineSchemaModel({
40
46
  name: 'KbRuleVersionApprovedPayload',
41
47
  description: 'Emitted when a rule version is approved.',
42
48
  fields: {
43
- ruleVersionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
49
+ ruleVersionId: {
50
+ type: ScalarTypeEnum.String_unsecure(),
51
+ isOptional: false,
52
+ },
44
53
  approver: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
54
  },
46
55
  });
@@ -58,7 +67,10 @@ const KbSnapshotPublishedPayload = defineSchemaModel({
58
67
  fields: {
59
68
  snapshotId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
60
69
  jurisdiction: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
61
- includedRuleVersionsCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
70
+ includedRuleVersionsCount: {
71
+ type: ScalarTypeEnum.Int_unsecure(),
72
+ isOptional: false,
73
+ },
62
74
  },
63
75
  });
64
76
 
@@ -68,5 +80,3 @@ export const KbSnapshotPublishedEvent = defineEvent({
68
80
  description: 'KB snapshot published.',
69
81
  payload: KbSnapshotPublishedPayload,
70
82
  });
71
-
72
-
package/src/example.ts CHANGED
@@ -25,5 +25,3 @@ const example = {
25
25
  } as const;
26
26
 
27
27
  export default example;
28
-
29
-
package/src/feature.ts CHANGED
@@ -31,5 +31,3 @@ export const VersionedKnowledgeBaseFeature: FeatureModuleSpec = {
31
31
  requires: [{ key: 'knowledge', version: 1 }],
32
32
  },
33
33
  };
34
-
35
-
@@ -1,3 +1 @@
1
1
  export * from './memory.handlers';
2
-
3
-
@@ -51,7 +51,11 @@ describe('@lssm/example.versioned-knowledge-base memory handlers', () => {
51
51
  const store = createMemoryKbStore();
52
52
  const kb = createMemoryKbHandlers(store);
53
53
 
54
- await kb.createRule({ id: 'rule_eu', jurisdiction: 'EU', topicKey: 'topic' });
54
+ await kb.createRule({
55
+ id: 'rule_eu',
56
+ jurisdiction: 'EU',
57
+ topicKey: 'topic',
58
+ });
55
59
  const euDraft = await kb.upsertRuleVersion({
56
60
  ruleId: 'rule_eu',
57
61
  content: 'This is about reporting obligations',
@@ -75,5 +79,3 @@ describe('@lssm/example.versioned-knowledge-base memory handlers', () => {
75
79
  expect(ok.items.map((i) => i.ruleVersionId)).toEqual([euDraft.id]);
76
80
  });
77
81
  });
78
-
79
-
@@ -1,5 +1,8 @@
1
- type SourceRef = { sourceDocumentId: string; excerpt?: string };
2
- type SourceDocument = {
1
+ interface SourceRef {
2
+ sourceDocumentId: string;
3
+ excerpt?: string;
4
+ }
5
+ interface SourceDocument {
3
6
  id: string;
4
7
  jurisdiction: string;
5
8
  authority: string;
@@ -7,9 +10,13 @@ type SourceDocument = {
7
10
  fetchedAt: Date;
8
11
  hash: string;
9
12
  fileId: string;
10
- };
11
- type Rule = { id: string; jurisdiction: string; topicKey: string };
12
- type RuleVersion = {
13
+ }
14
+ interface Rule {
15
+ id: string;
16
+ jurisdiction: string;
17
+ topicKey: string;
18
+ }
19
+ interface RuleVersion {
13
20
  id: string;
14
21
  ruleId: string;
15
22
  jurisdiction: string;
@@ -21,14 +28,14 @@ type RuleVersion = {
21
28
  approvedBy?: string;
22
29
  approvedAt?: Date;
23
30
  createdAt: Date;
24
- };
25
- type KBSnapshot = {
31
+ }
32
+ interface KBSnapshot {
26
33
  id: string;
27
34
  jurisdiction: string;
28
35
  asOfDate: Date;
29
36
  includedRuleVersionIds: string[];
30
37
  publishedAt: Date;
31
- };
38
+ }
32
39
 
33
40
  export interface MemoryKbStore {
34
41
  sources: Map<string, SourceDocument>;
@@ -68,7 +75,7 @@ export interface MemoryKbHandlers {
68
75
  snapshotId: string;
69
76
  jurisdiction: string;
70
77
  query: string;
71
- }): Promise<{ items: Array<{ ruleVersionId: string; excerpt?: string }> }>;
78
+ }): Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }>;
72
79
  }
73
80
 
74
81
  function stableId(prefix: string, value: string): string {
@@ -171,7 +178,7 @@ export function createMemoryKbHandlers(store: MemoryKbStore): MemoryKbHandlers {
171
178
  snapshotId: string;
172
179
  jurisdiction: string;
173
180
  query: string;
174
- }): Promise<{ items: Array<{ ruleVersionId: string; excerpt?: string }> }> {
181
+ }): Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }> {
175
182
  const snapshot = store.snapshots.get(input.snapshotId);
176
183
  if (!snapshot) {
177
184
  throw new Error('SNAPSHOT_NOT_FOUND');
@@ -180,7 +187,10 @@ export function createMemoryKbHandlers(store: MemoryKbStore): MemoryKbHandlers {
180
187
  throw new Error('JURISDICTION_MISMATCH');
181
188
  }
182
189
  const q = input.query.toLowerCase();
183
- const tokens = q.split(/\s+/).map((t) => t.trim()).filter(Boolean);
190
+ const tokens = q
191
+ .split(/\s+/)
192
+ .map((t) => t.trim())
193
+ .filter(Boolean);
184
194
  const items = snapshot.includedRuleVersionIds
185
195
  .map((id) => store.ruleVersions.get(id))
186
196
  .filter((rv): rv is RuleVersion => Boolean(rv))
@@ -189,7 +199,10 @@ export function createMemoryKbHandlers(store: MemoryKbStore): MemoryKbHandlers {
189
199
  const hay = rv.content.toLowerCase();
190
200
  return tokens.every((token) => hay.includes(token));
191
201
  })
192
- .map((rv) => ({ ruleVersionId: rv.id, excerpt: rv.content.slice(0, 120) }));
202
+ .map((rv) => ({
203
+ ruleVersionId: rv.id,
204
+ excerpt: rv.content.slice(0, 120),
205
+ }));
193
206
  return { items };
194
207
  }
195
208
 
@@ -202,5 +215,3 @@ export function createMemoryKbHandlers(store: MemoryKbStore): MemoryKbHandlers {
202
215
  search,
203
216
  };
204
217
  }
205
-
206
-
package/src/index.ts CHANGED
@@ -11,5 +11,3 @@ export * from './feature';
11
11
  export { default as example } from './example';
12
12
 
13
13
  import './docs';
14
-
15
-
package/tsconfig.json CHANGED
@@ -9,3 +9,4 @@
9
9
  }
10
10
 
11
11
 
12
+