@lssm/example.policy-safe-knowledge-assistant 1.41.0 → 1.42.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.
- package/.turbo/turbo-build$colon$bundle.log +35 -0
- package/.turbo/turbo-build.log +30 -13
- package/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -1
- package/dist/docs/policy-safe-knowledge-assistant.docblock.d.ts +1 -0
- package/dist/docs/policy-safe-knowledge-assistant.docblock.js +34 -13
- package/dist/docs/policy-safe-knowledge-assistant.docblock.js.map +1 -0
- package/dist/example.d.ts +35 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +47 -1
- package/dist/example.js.map +1 -0
- package/dist/feature.d.ts +7 -0
- package/dist/feature.d.ts.map +1 -0
- package/dist/feature.js +148 -1
- package/dist/feature.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -1
- package/dist/orchestrator/buildAnswer.d.ts +53 -0
- package/dist/orchestrator/buildAnswer.d.ts.map +1 -0
- package/dist/orchestrator/buildAnswer.js +77 -1
- package/dist/orchestrator/buildAnswer.js.map +1 -0
- package/dist/seed/fixtures.d.ts +35 -0
- package/dist/seed/fixtures.d.ts.map +1 -0
- package/dist/seed/fixtures.js +34 -1
- package/dist/seed/fixtures.js.map +1 -0
- package/dist/seed/index.d.ts +2 -0
- package/dist/seed/index.js +3 -1
- package/package.json +37 -27
- package/src/feature.ts +23 -22
- package/src/orchestrator/buildAnswer.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1,77 @@
|
|
|
1
|
-
import{enforceAllowedScope
|
|
1
|
+
import { enforceAllowedScope, enforceCitations, validateEnvelope } from "@lssm/example.locale-jurisdiction-gate/policy/guard";
|
|
2
|
+
|
|
3
|
+
//#region src/orchestrator/buildAnswer.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build a policy-safe assistant answer derived from KB search results.
|
|
6
|
+
*
|
|
7
|
+
* Deterministic: no LLM calls; if search yields no results, it refuses.
|
|
8
|
+
*/
|
|
9
|
+
async function buildPolicySafeAnswer(input) {
|
|
10
|
+
const env = validateEnvelope(input.envelope);
|
|
11
|
+
if (!env.ok) return {
|
|
12
|
+
locale: input.envelope.locale ?? "en-GB",
|
|
13
|
+
jurisdiction: input.envelope.regulatoryContext?.jurisdiction ?? "UNKNOWN",
|
|
14
|
+
allowedScope: input.envelope.allowedScope ?? "education_only",
|
|
15
|
+
sections: [{
|
|
16
|
+
heading: "Request blocked",
|
|
17
|
+
body: env.error.message
|
|
18
|
+
}],
|
|
19
|
+
citations: [],
|
|
20
|
+
disclaimers: ["This system refuses to answer without a valid envelope."],
|
|
21
|
+
riskFlags: [env.error.code],
|
|
22
|
+
refused: true,
|
|
23
|
+
refusalReason: env.error.code
|
|
24
|
+
};
|
|
25
|
+
const results = await input.kbSearch({
|
|
26
|
+
snapshotId: env.value.kbSnapshotId,
|
|
27
|
+
jurisdiction: env.value.regulatoryContext?.jurisdiction ?? "UNKNOWN",
|
|
28
|
+
query: input.question
|
|
29
|
+
});
|
|
30
|
+
const citations = results.items.map((item) => ({
|
|
31
|
+
kbSnapshotId: env.value.kbSnapshotId,
|
|
32
|
+
sourceType: "ruleVersion",
|
|
33
|
+
sourceId: item.ruleVersionId,
|
|
34
|
+
title: "Curated rule version",
|
|
35
|
+
excerpt: item.excerpt
|
|
36
|
+
}));
|
|
37
|
+
const draft = {
|
|
38
|
+
locale: env.value.locale,
|
|
39
|
+
jurisdiction: env.value.regulatoryContext?.jurisdiction ?? "UNKNOWN",
|
|
40
|
+
allowedScope: env.value.allowedScope,
|
|
41
|
+
sections: [{
|
|
42
|
+
heading: "Answer (KB-derived)",
|
|
43
|
+
body: results.items.length > 0 ? `This answer is derived from ${results.items.length} curated rule version(s) in the referenced snapshot.` : "No curated knowledge found in the referenced snapshot."
|
|
44
|
+
}],
|
|
45
|
+
citations,
|
|
46
|
+
disclaimers: ["Educational demo only."],
|
|
47
|
+
riskFlags: []
|
|
48
|
+
};
|
|
49
|
+
const scope = enforceAllowedScope(env.value.allowedScope, draft);
|
|
50
|
+
if (!scope.ok) return {
|
|
51
|
+
...draft,
|
|
52
|
+
sections: [{
|
|
53
|
+
heading: "Escalation required",
|
|
54
|
+
body: scope.error.message
|
|
55
|
+
}],
|
|
56
|
+
refused: true,
|
|
57
|
+
refusalReason: scope.error.code,
|
|
58
|
+
riskFlags: [...draft.riskFlags ?? [], scope.error.code]
|
|
59
|
+
};
|
|
60
|
+
const cited = enforceCitations(draft);
|
|
61
|
+
if (!cited.ok) return {
|
|
62
|
+
...draft,
|
|
63
|
+
sections: [{
|
|
64
|
+
heading: "Request blocked",
|
|
65
|
+
body: cited.error.message
|
|
66
|
+
}],
|
|
67
|
+
citations: [],
|
|
68
|
+
refused: true,
|
|
69
|
+
refusalReason: cited.error.code,
|
|
70
|
+
riskFlags: [...draft.riskFlags ?? [], cited.error.code]
|
|
71
|
+
};
|
|
72
|
+
return draft;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { buildPolicySafeAnswer };
|
|
77
|
+
//# sourceMappingURL=buildAnswer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildAnswer.js","names":["draft: AssistantAnswerIR"],"sources":["../../src/orchestrator/buildAnswer.ts"],"sourcesContent":["import {\n enforceAllowedScope,\n enforceCitations,\n validateEnvelope,\n} from '@lssm/example.locale-jurisdiction-gate/policy/guard';\n\ntype AllowedScope = 'education_only' | 'generic_info' | 'escalation_required';\n\nexport interface AssistantAnswerIR {\n locale: string;\n jurisdiction: string;\n allowedScope: AllowedScope;\n sections: { heading: string; body: string }[];\n citations: {\n kbSnapshotId: string;\n sourceType: string;\n sourceId: string;\n title?: string;\n excerpt?: string;\n }[];\n disclaimers?: string[];\n riskFlags?: string[];\n refused?: boolean;\n refusalReason?: string;\n}\n\nexport interface BuildAnswerInput {\n envelope: {\n traceId: string;\n locale: string;\n kbSnapshotId: string;\n allowedScope: AllowedScope;\n regulatoryContext: { jurisdiction: string };\n };\n question: string;\n kbSearch: (input: {\n snapshotId: string;\n jurisdiction: string;\n query: string;\n }) => Promise<{ items: { ruleVersionId: string; excerpt?: string }[] }>;\n}\n\n/**\n * Build a policy-safe assistant answer derived from KB search results.\n *\n * Deterministic: no LLM calls; if search yields no results, it refuses.\n */\nexport async function buildPolicySafeAnswer(\n input: BuildAnswerInput\n): Promise<AssistantAnswerIR> {\n const env = validateEnvelope(input.envelope);\n if (!env.ok) {\n return {\n locale: input.envelope.locale ?? 'en-GB',\n jurisdiction: input.envelope.regulatoryContext?.jurisdiction ?? 'UNKNOWN',\n allowedScope: input.envelope.allowedScope ?? 'education_only',\n sections: [{ heading: 'Request blocked', body: env.error.message }],\n citations: [],\n disclaimers: ['This system refuses to answer without a valid envelope.'],\n riskFlags: [env.error.code],\n refused: true,\n refusalReason: env.error.code,\n };\n }\n\n const results = await input.kbSearch({\n snapshotId: env.value.kbSnapshotId,\n jurisdiction: env.value.regulatoryContext?.jurisdiction ?? 'UNKNOWN',\n query: input.question,\n });\n\n const citations = results.items.map((item) => ({\n kbSnapshotId: env.value.kbSnapshotId,\n sourceType: 'ruleVersion',\n sourceId: item.ruleVersionId,\n title: 'Curated rule version',\n excerpt: item.excerpt,\n }));\n\n const draft: AssistantAnswerIR = {\n locale: env.value.locale,\n jurisdiction: env.value.regulatoryContext?.jurisdiction ?? 'UNKNOWN',\n allowedScope: env.value.allowedScope,\n sections: [\n {\n heading: 'Answer (KB-derived)',\n body:\n results.items.length > 0\n ? `This answer is derived from ${results.items.length} curated rule version(s) in the referenced snapshot.`\n : 'No curated knowledge found in the referenced snapshot.',\n },\n ],\n citations,\n disclaimers: ['Educational demo only.'],\n riskFlags: [],\n };\n\n const scope = enforceAllowedScope(env.value.allowedScope, draft);\n if (!scope.ok) {\n return {\n ...draft,\n sections: [{ heading: 'Escalation required', body: scope.error.message }],\n refused: true,\n refusalReason: scope.error.code,\n riskFlags: [...(draft.riskFlags ?? []), scope.error.code],\n };\n }\n\n const cited = enforceCitations(draft);\n if (!cited.ok) {\n return {\n ...draft,\n sections: [{ heading: 'Request blocked', body: cited.error.message }],\n citations: [],\n refused: true,\n refusalReason: cited.error.code,\n riskFlags: [...(draft.riskFlags ?? []), cited.error.code],\n };\n }\n\n return draft;\n}\n"],"mappings":";;;;;;;;AA+CA,eAAsB,sBACpB,OAC4B;CAC5B,MAAM,MAAM,iBAAiB,MAAM,SAAS;AAC5C,KAAI,CAAC,IAAI,GACP,QAAO;EACL,QAAQ,MAAM,SAAS,UAAU;EACjC,cAAc,MAAM,SAAS,mBAAmB,gBAAgB;EAChE,cAAc,MAAM,SAAS,gBAAgB;EAC7C,UAAU,CAAC;GAAE,SAAS;GAAmB,MAAM,IAAI,MAAM;GAAS,CAAC;EACnE,WAAW,EAAE;EACb,aAAa,CAAC,0DAA0D;EACxE,WAAW,CAAC,IAAI,MAAM,KAAK;EAC3B,SAAS;EACT,eAAe,IAAI,MAAM;EAC1B;CAGH,MAAM,UAAU,MAAM,MAAM,SAAS;EACnC,YAAY,IAAI,MAAM;EACtB,cAAc,IAAI,MAAM,mBAAmB,gBAAgB;EAC3D,OAAO,MAAM;EACd,CAAC;CAEF,MAAM,YAAY,QAAQ,MAAM,KAAK,UAAU;EAC7C,cAAc,IAAI,MAAM;EACxB,YAAY;EACZ,UAAU,KAAK;EACf,OAAO;EACP,SAAS,KAAK;EACf,EAAE;CAEH,MAAMA,QAA2B;EAC/B,QAAQ,IAAI,MAAM;EAClB,cAAc,IAAI,MAAM,mBAAmB,gBAAgB;EAC3D,cAAc,IAAI,MAAM;EACxB,UAAU,CACR;GACE,SAAS;GACT,MACE,QAAQ,MAAM,SAAS,IACnB,+BAA+B,QAAQ,MAAM,OAAO,wDACpD;GACP,CACF;EACD;EACA,aAAa,CAAC,yBAAyB;EACvC,WAAW,EAAE;EACd;CAED,MAAM,QAAQ,oBAAoB,IAAI,MAAM,cAAc,MAAM;AAChE,KAAI,CAAC,MAAM,GACT,QAAO;EACL,GAAG;EACH,UAAU,CAAC;GAAE,SAAS;GAAuB,MAAM,MAAM,MAAM;GAAS,CAAC;EACzE,SAAS;EACT,eAAe,MAAM,MAAM;EAC3B,WAAW,CAAC,GAAI,MAAM,aAAa,EAAE,EAAG,MAAM,MAAM,KAAK;EAC1D;CAGH,MAAM,QAAQ,iBAAiB,MAAM;AACrC,KAAI,CAAC,MAAM,GACT,QAAO;EACL,GAAG;EACH,UAAU,CAAC;GAAE,SAAS;GAAmB,MAAM,MAAM,MAAM;GAAS,CAAC;EACrE,WAAW,EAAE;EACb,SAAS;EACT,eAAe,MAAM,MAAM;EAC3B,WAAW,CAAC,GAAI,MAAM,aAAa,EAAE,EAAG,MAAM,MAAM,KAAK;EAC1D;AAGH,QAAO"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/seed/fixtures.d.ts
|
|
2
|
+
declare const DEMO_FIXTURES: {
|
|
3
|
+
readonly jurisdictions: readonly ["EU", "FR"];
|
|
4
|
+
readonly locales: readonly ["en-GB", "fr-FR"];
|
|
5
|
+
readonly demoOrgId: "org_demo";
|
|
6
|
+
readonly demoUserId: "user_demo";
|
|
7
|
+
readonly sources: {
|
|
8
|
+
readonly EU_SOURCE_1: {
|
|
9
|
+
readonly jurisdiction: "EU";
|
|
10
|
+
readonly authority: "DemoAuthority";
|
|
11
|
+
readonly title: "EU Demo Source v1";
|
|
12
|
+
readonly fetchedAt: Date;
|
|
13
|
+
readonly hash: "hash_eu_v1";
|
|
14
|
+
readonly fileId: "file_eu_v1";
|
|
15
|
+
};
|
|
16
|
+
readonly EU_SOURCE_2: {
|
|
17
|
+
readonly jurisdiction: "EU";
|
|
18
|
+
readonly authority: "DemoAuthority";
|
|
19
|
+
readonly title: "EU Demo Source v2";
|
|
20
|
+
readonly fetchedAt: Date;
|
|
21
|
+
readonly hash: "hash_eu_v2";
|
|
22
|
+
readonly fileId: "file_eu_v2";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
readonly rules: {
|
|
26
|
+
readonly EU_RULE_TAX: {
|
|
27
|
+
readonly id: "rule_eu_tax";
|
|
28
|
+
readonly jurisdiction: "EU";
|
|
29
|
+
readonly topicKey: "tax_reporting";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { DEMO_FIXTURES };
|
|
35
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","names":[],"sources":["../../src/seed/fixtures.ts"],"sourcesContent":[],"mappings":";cAAa;EAAA,SAAA,aA8BH,EAAA,SAAA,CAAA,IAAA,EAAA,IAAA,CAAA;;;;;;;;;0BAAA;;;;;;;;0BAAA"}
|
package/dist/seed/fixtures.js
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/seed/fixtures.ts
|
|
2
|
+
const DEMO_FIXTURES = {
|
|
3
|
+
jurisdictions: ["EU", "FR"],
|
|
4
|
+
locales: ["en-GB", "fr-FR"],
|
|
5
|
+
demoOrgId: "org_demo",
|
|
6
|
+
demoUserId: "user_demo",
|
|
7
|
+
sources: {
|
|
8
|
+
EU_SOURCE_1: {
|
|
9
|
+
jurisdiction: "EU",
|
|
10
|
+
authority: "DemoAuthority",
|
|
11
|
+
title: "EU Demo Source v1",
|
|
12
|
+
fetchedAt: /* @__PURE__ */ new Date("2026-01-01T00:00:00.000Z"),
|
|
13
|
+
hash: "hash_eu_v1",
|
|
14
|
+
fileId: "file_eu_v1"
|
|
15
|
+
},
|
|
16
|
+
EU_SOURCE_2: {
|
|
17
|
+
jurisdiction: "EU",
|
|
18
|
+
authority: "DemoAuthority",
|
|
19
|
+
title: "EU Demo Source v2",
|
|
20
|
+
fetchedAt: /* @__PURE__ */ new Date("2026-02-01T00:00:00.000Z"),
|
|
21
|
+
hash: "hash_eu_v2",
|
|
22
|
+
fileId: "file_eu_v2"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
rules: { EU_RULE_TAX: {
|
|
26
|
+
id: "rule_eu_tax",
|
|
27
|
+
jurisdiction: "EU",
|
|
28
|
+
topicKey: "tax_reporting"
|
|
29
|
+
} }
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { DEMO_FIXTURES };
|
|
34
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","names":[],"sources":["../../src/seed/fixtures.ts"],"sourcesContent":["export const DEMO_FIXTURES = {\n jurisdictions: ['EU', 'FR'] as const,\n locales: ['en-GB', 'fr-FR'] as const,\n demoOrgId: 'org_demo',\n demoUserId: 'user_demo',\n sources: {\n EU_SOURCE_1: {\n jurisdiction: 'EU',\n authority: 'DemoAuthority',\n title: 'EU Demo Source v1',\n fetchedAt: new Date('2026-01-01T00:00:00.000Z'),\n hash: 'hash_eu_v1',\n fileId: 'file_eu_v1',\n },\n EU_SOURCE_2: {\n jurisdiction: 'EU',\n authority: 'DemoAuthority',\n title: 'EU Demo Source v2',\n fetchedAt: new Date('2026-02-01T00:00:00.000Z'),\n hash: 'hash_eu_v2',\n fileId: 'file_eu_v2',\n },\n },\n rules: {\n EU_RULE_TAX: {\n id: 'rule_eu_tax',\n jurisdiction: 'EU',\n topicKey: 'tax_reporting',\n },\n },\n} as const;\n"],"mappings":";AAAA,MAAa,gBAAgB;CAC3B,eAAe,CAAC,MAAM,KAAK;CAC3B,SAAS,CAAC,SAAS,QAAQ;CAC3B,WAAW;CACX,YAAY;CACZ,SAAS;EACP,aAAa;GACX,cAAc;GACd,WAAW;GACX,OAAO;GACP,2BAAW,IAAI,KAAK,2BAA2B;GAC/C,MAAM;GACN,QAAQ;GACT;EACD,aAAa;GACX,cAAc;GACd,WAAW;GACX,OAAO;GACP,2BAAW,IAAI,KAAK,2BAA2B;GAC/C,MAAM;GACN,QAAQ;GACT;EACF;CACD,OAAO,EACL,aAAa;EACX,IAAI;EACJ,cAAc;EACd,UAAU;EACX,EACF;CACF"}
|
package/dist/seed/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/example.policy-safe-knowledge-assistant",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.1",
|
|
4
4
|
"description": "All-in-one template example: policy-safe knowledge assistant with locale/jurisdiction gating, versioned KB snapshots, HITL update pipeline, and learning hub.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./
|
|
11
|
-
"./docs": "./
|
|
12
|
-
"./docs/policy-safe-knowledge-assistant.docblock": "./
|
|
13
|
-
"./example": "./
|
|
14
|
-
"./feature": "./
|
|
15
|
-
"./orchestrator/buildAnswer": "./
|
|
16
|
-
"./seed": "./
|
|
17
|
-
"./seed/fixtures": "./
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./docs": "./dist/docs/index.js",
|
|
12
|
+
"./docs/policy-safe-knowledge-assistant.docblock": "./dist/docs/policy-safe-knowledge-assistant.docblock.js",
|
|
13
|
+
"./example": "./dist/example.js",
|
|
14
|
+
"./feature": "./dist/feature.js",
|
|
15
|
+
"./orchestrator/buildAnswer": "./dist/orchestrator/buildAnswer.js",
|
|
16
|
+
"./seed": "./dist/seed/index.js",
|
|
17
|
+
"./seed/fixtures": "./dist/seed/fixtures.js",
|
|
18
18
|
"./*": "./*"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"
|
|
21
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
22
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
23
|
+
"build": "bun build:types && bun build:bundle",
|
|
22
24
|
"build:bundle": "tsdown",
|
|
23
25
|
"build:types": "tsc --noEmit",
|
|
24
26
|
"dev": "bun build:bundle --watch",
|
|
@@ -29,24 +31,25 @@
|
|
|
29
31
|
"test": "bun test"
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@lssm/example.locale-jurisdiction-gate": "
|
|
33
|
-
"@lssm/example.versioned-knowledge-base": "
|
|
34
|
-
"@lssm/example.kb-update-pipeline": "
|
|
35
|
-
"@lssm/example.learning-patterns": "
|
|
36
|
-
"@lssm/lib.
|
|
37
|
-
"@lssm/lib.
|
|
38
|
-
"@lssm/lib.
|
|
39
|
-
"@lssm/lib.
|
|
40
|
-
"@lssm/lib.
|
|
41
|
-
"@lssm/lib.
|
|
42
|
-
"@lssm/
|
|
43
|
-
"@lssm/module.
|
|
44
|
-
"@lssm/module.
|
|
34
|
+
"@lssm/example.locale-jurisdiction-gate": "1.42.1",
|
|
35
|
+
"@lssm/example.versioned-knowledge-base": "1.42.1",
|
|
36
|
+
"@lssm/example.kb-update-pipeline": "1.42.1",
|
|
37
|
+
"@lssm/example.learning-patterns": "1.42.1",
|
|
38
|
+
"@lssm/lib.schema": "1.42.1",
|
|
39
|
+
"@lssm/lib.contracts": "1.42.1",
|
|
40
|
+
"@lssm/lib.identity-rbac": "1.42.1",
|
|
41
|
+
"@lssm/lib.jobs": "1.42.1",
|
|
42
|
+
"@lssm/lib.feature-flags": "1.42.1",
|
|
43
|
+
"@lssm/lib.files": "1.42.1",
|
|
44
|
+
"@lssm/lib.metering": "1.42.1",
|
|
45
|
+
"@lssm/module.audit-trail": "1.42.1",
|
|
46
|
+
"@lssm/module.notifications": "1.42.1",
|
|
47
|
+
"@lssm/module.learning-journey": "1.42.1"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
47
|
-
"@lssm/tool.tsdown": "
|
|
48
|
-
"@lssm/tool.typescript": "
|
|
49
|
-
"tsdown": "^0.
|
|
50
|
+
"@lssm/tool.tsdown": "1.42.1",
|
|
51
|
+
"@lssm/tool.typescript": "1.42.1",
|
|
52
|
+
"tsdown": "^0.18.3",
|
|
50
53
|
"typescript": "^5.9.3"
|
|
51
54
|
},
|
|
52
55
|
"publishConfig": {
|
|
@@ -61,6 +64,13 @@
|
|
|
61
64
|
"./seed": "./dist/seed/index.js",
|
|
62
65
|
"./seed/fixtures": "./dist/seed/fixtures.js",
|
|
63
66
|
"./*": "./*"
|
|
64
|
-
}
|
|
67
|
+
},
|
|
68
|
+
"registry": "https://registry.npmjs.org/"
|
|
69
|
+
},
|
|
70
|
+
"license": "MIT",
|
|
71
|
+
"repository": {
|
|
72
|
+
"type": "git",
|
|
73
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
74
|
+
"directory": "packages/examples/policy-safe-knowledge-assistant"
|
|
65
75
|
}
|
|
66
76
|
}
|
package/src/feature.ts
CHANGED
|
@@ -3,41 +3,42 @@ import type { FeatureModuleSpec } from '@lssm/lib.contracts';
|
|
|
3
3
|
export const PolicySafeKnowledgeAssistantFeature: FeatureModuleSpec = {
|
|
4
4
|
meta: {
|
|
5
5
|
key: 'policy-safe-knowledge-assistant',
|
|
6
|
+
version: 1,
|
|
6
7
|
title: 'Policy-safe Knowledge Assistant',
|
|
7
8
|
description:
|
|
8
9
|
'All-in-one example composing locale/jurisdiction gate + versioned KB + HITL pipeline + learning hub.',
|
|
9
10
|
domain: 'knowledge',
|
|
10
|
-
owners: ['examples'],
|
|
11
|
+
owners: ['@examples'],
|
|
11
12
|
tags: ['assistant', 'knowledge', 'policy', 'hitl', 'learning'],
|
|
12
13
|
stability: 'experimental',
|
|
13
14
|
},
|
|
14
15
|
operations: [
|
|
15
16
|
// Gate
|
|
16
|
-
{
|
|
17
|
-
{
|
|
17
|
+
{ key: 'assistant.answer', version: 1 },
|
|
18
|
+
{ key: 'assistant.explainConcept', version: 1 },
|
|
18
19
|
// KB
|
|
19
|
-
{
|
|
20
|
-
{
|
|
21
|
-
{
|
|
22
|
-
{
|
|
23
|
-
{
|
|
20
|
+
{ key: 'kb.ingestSource', version: 1 },
|
|
21
|
+
{ key: 'kb.upsertRuleVersion', version: 1 },
|
|
22
|
+
{ key: 'kb.approveRuleVersion', version: 1 },
|
|
23
|
+
{ key: 'kb.publishSnapshot', version: 1 },
|
|
24
|
+
{ key: 'kb.search', version: 1 },
|
|
24
25
|
// Pipeline
|
|
25
|
-
{
|
|
26
|
-
{
|
|
27
|
-
{
|
|
28
|
-
{
|
|
26
|
+
{ key: 'kbPipeline.runWatch', version: 1 },
|
|
27
|
+
{ key: 'kbPipeline.createReviewTask', version: 1 },
|
|
28
|
+
{ key: 'kbPipeline.submitDecision', version: 1 },
|
|
29
|
+
{ key: 'kbPipeline.publishIfReady', version: 1 },
|
|
29
30
|
],
|
|
30
31
|
events: [
|
|
31
|
-
{
|
|
32
|
-
{
|
|
33
|
-
{
|
|
34
|
-
{
|
|
35
|
-
{
|
|
36
|
-
{
|
|
37
|
-
{
|
|
38
|
-
{
|
|
39
|
-
{
|
|
40
|
-
{
|
|
32
|
+
{ key: 'assistant.answer.requested', version: 1 },
|
|
33
|
+
{ key: 'assistant.answer.blocked', version: 1 },
|
|
34
|
+
{ key: 'assistant.answer.delivered', version: 1 },
|
|
35
|
+
{ key: 'kb.source.ingested', version: 1 },
|
|
36
|
+
{ key: 'kb.ruleVersion.created', version: 1 },
|
|
37
|
+
{ key: 'kb.ruleVersion.approved', version: 1 },
|
|
38
|
+
{ key: 'kb.snapshot.published', version: 1 },
|
|
39
|
+
{ key: 'kb.change.detected', version: 1 },
|
|
40
|
+
{ key: 'kb.review.requested', version: 1 },
|
|
41
|
+
{ key: 'kb.review.decided', version: 1 },
|
|
41
42
|
],
|
|
42
43
|
presentations: [],
|
|
43
44
|
opToPresentation: [],
|
|
@@ -65,7 +65,7 @@ export async function buildPolicySafeAnswer(
|
|
|
65
65
|
|
|
66
66
|
const results = await input.kbSearch({
|
|
67
67
|
snapshotId: env.value.kbSnapshotId,
|
|
68
|
-
jurisdiction: env.value.regulatoryContext
|
|
68
|
+
jurisdiction: env.value.regulatoryContext?.jurisdiction ?? 'UNKNOWN',
|
|
69
69
|
query: input.question,
|
|
70
70
|
});
|
|
71
71
|
|
|
@@ -79,7 +79,7 @@ export async function buildPolicySafeAnswer(
|
|
|
79
79
|
|
|
80
80
|
const draft: AssistantAnswerIR = {
|
|
81
81
|
locale: env.value.locale,
|
|
82
|
-
jurisdiction: env.value.regulatoryContext
|
|
82
|
+
jurisdiction: env.value.regulatoryContext?.jurisdiction ?? 'UNKNOWN',
|
|
83
83
|
allowedScope: env.value.allowedScope,
|
|
84
84
|
sections: [
|
|
85
85
|
{
|