@lssm/example.locale-jurisdiction-gate 0.0.0-canary-20251217054315 → 0.0.0-canary-20251217060804

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.
@@ -0,0 +1,35 @@
1
+ //#region src/example.d.ts
2
+ declare const example: {
3
+ readonly id: "locale-jurisdiction-gate";
4
+ readonly title: "Locale / Jurisdiction Gate";
5
+ readonly summary: "Fail-closed gating for assistant calls: locale + jurisdiction + kbSnapshotId + allowedScope must be explicit, answers must cite a snapshot.";
6
+ readonly tags: readonly ["policy", "locale", "jurisdiction", "assistant", "gating"];
7
+ readonly kind: "knowledge";
8
+ readonly visibility: "public";
9
+ readonly docs: {
10
+ readonly rootDocId: "docs.examples.locale-jurisdiction-gate";
11
+ };
12
+ readonly entrypoints: {
13
+ readonly packageName: "@lssm/example.locale-jurisdiction-gate";
14
+ readonly feature: "./feature";
15
+ readonly contracts: "./contracts";
16
+ readonly handlers: "./handlers";
17
+ readonly docs: "./docs";
18
+ };
19
+ readonly surfaces: {
20
+ readonly templates: true;
21
+ readonly sandbox: {
22
+ readonly enabled: true;
23
+ readonly modes: readonly ["markdown", "specs"];
24
+ };
25
+ readonly studio: {
26
+ readonly enabled: true;
27
+ readonly installable: true;
28
+ };
29
+ readonly mcp: {
30
+ readonly enabled: true;
31
+ };
32
+ };
33
+ };
34
+ //#endregion
35
+ export { example as default };
@@ -0,0 +1,58 @@
1
+ //#region src/handlers/demo.handlers.d.ts
2
+ type AllowedScope = 'education_only' | 'generic_info' | 'escalation_required';
3
+ interface AssistantAnswerIR {
4
+ locale: string;
5
+ jurisdiction: string;
6
+ allowedScope: AllowedScope;
7
+ sections: {
8
+ heading: string;
9
+ body: string;
10
+ }[];
11
+ citations: {
12
+ kbSnapshotId: string;
13
+ sourceType: string;
14
+ sourceId: string;
15
+ title?: string;
16
+ excerpt?: string;
17
+ }[];
18
+ disclaimers?: string[];
19
+ riskFlags?: string[];
20
+ refused?: boolean;
21
+ refusalReason?: string;
22
+ }
23
+ interface DemoAssistantHandlers {
24
+ answer(input: {
25
+ envelope: {
26
+ traceId: string;
27
+ locale: string;
28
+ kbSnapshotId: string;
29
+ allowedScope: AllowedScope;
30
+ regulatoryContext: {
31
+ jurisdiction: string;
32
+ };
33
+ };
34
+ question: string;
35
+ }): Promise<AssistantAnswerIR>;
36
+ explainConcept(input: {
37
+ envelope: {
38
+ traceId: string;
39
+ locale: string;
40
+ kbSnapshotId: string;
41
+ allowedScope: AllowedScope;
42
+ regulatoryContext: {
43
+ jurisdiction: string;
44
+ };
45
+ };
46
+ conceptKey: string;
47
+ }): Promise<AssistantAnswerIR>;
48
+ }
49
+ /**
50
+ * Deterministic demo assistant handlers (no LLM).
51
+ *
52
+ * - Validates envelope
53
+ * - Requires citations
54
+ * - Enforces allowedScope (education_only blocks actionable language)
55
+ */
56
+ declare function createDemoAssistantHandlers(): DemoAssistantHandlers;
57
+ //#endregion
58
+ export { DemoAssistantHandlers, createDemoAssistantHandlers };
@@ -0,0 +1,2 @@
1
+ import { DemoAssistantHandlers, createDemoAssistantHandlers } from "./demo.handlers.js";
2
+ export { DemoAssistantHandlers, createDemoAssistantHandlers };
@@ -0,0 +1,11 @@
1
+ import { AssistantAnswerContract, AssistantExplainConceptContract } from "./contracts/assistant.js";
2
+ import "./contracts/index.js";
3
+ import { AllowedScopeEnum, AssistantAnswerIRModel, AssistantAnswerSectionModel, AssistantCitationModel, LLMCallEnvelopeModel, RegulatoryContextModel, UserProfileModel } from "./entities/models.js";
4
+ import "./entities/index.js";
5
+ import { AssistantAnswerBlockedEvent, AssistantAnswerDeliveredEvent, AssistantAnswerRequestedEvent } from "./events.js";
6
+ import example from "./example.js";
7
+ import { DemoAssistantHandlers, createDemoAssistantHandlers } from "./handlers/demo.handlers.js";
8
+ import { AllowedScope, GateError, GateResult } from "./policy/types.js";
9
+ import { enforceAllowedScope, enforceCitations, validateEnvelope } from "./policy/guard.js";
10
+ import { LocaleJurisdictionGateFeature } from "./locale-jurisdiction-gate.feature.js";
11
+ export { AllowedScope, AllowedScopeEnum, AssistantAnswerBlockedEvent, AssistantAnswerContract, AssistantAnswerDeliveredEvent, AssistantAnswerIRModel, AssistantAnswerRequestedEvent, AssistantAnswerSectionModel, AssistantCitationModel, AssistantExplainConceptContract, DemoAssistantHandlers, GateError, GateResult, LLMCallEnvelopeModel, LocaleJurisdictionGateFeature, RegulatoryContextModel, UserProfileModel, createDemoAssistantHandlers, enforceAllowedScope, enforceCitations, example, validateEnvelope };
@@ -0,0 +1,6 @@
1
+ import { FeatureModuleSpec } from "@lssm/lib.contracts";
2
+
3
+ //#region src/locale-jurisdiction-gate.feature.d.ts
4
+ declare const LocaleJurisdictionGateFeature: FeatureModuleSpec;
5
+ //#endregion
6
+ export { LocaleJurisdictionGateFeature };
@@ -0,0 +1,26 @@
1
+ import { GateResult } from "./types.js";
2
+
3
+ //#region src/policy/guard.d.ts
4
+ interface EnvelopeLike {
5
+ locale?: string;
6
+ kbSnapshotId?: string;
7
+ allowedScope?: 'education_only' | 'generic_info' | 'escalation_required';
8
+ regulatoryContext?: {
9
+ jurisdiction?: string;
10
+ };
11
+ }
12
+ interface AnswerLike {
13
+ citations?: unknown[];
14
+ sections?: {
15
+ heading: string;
16
+ body: string;
17
+ }[];
18
+ refused?: boolean;
19
+ refusalReason?: string;
20
+ allowedScope?: 'education_only' | 'generic_info' | 'escalation_required';
21
+ }
22
+ declare function validateEnvelope(envelope: EnvelopeLike): GateResult<Required<EnvelopeLike>>;
23
+ declare function enforceCitations(answer: AnswerLike): GateResult<AnswerLike>;
24
+ declare function enforceAllowedScope(allowedScope: EnvelopeLike['allowedScope'], answer: AnswerLike): GateResult<AnswerLike>;
25
+ //#endregion
26
+ export { enforceAllowedScope, enforceCitations, validateEnvelope };
@@ -0,0 +1,3 @@
1
+ import { AllowedScope, GateError, GateResult } from "./types.js";
2
+ import { enforceAllowedScope, enforceCitations, validateEnvelope } from "./guard.js";
3
+ export { AllowedScope, GateError, GateResult, enforceAllowedScope, enforceCitations, validateEnvelope };
@@ -0,0 +1,15 @@
1
+ //#region src/policy/types.d.ts
2
+ type AllowedScope = 'education_only' | 'generic_info' | 'escalation_required';
3
+ interface GateError {
4
+ code: 'LOCALE_REQUIRED' | 'JURISDICTION_REQUIRED' | 'KB_SNAPSHOT_REQUIRED' | 'CITATIONS_REQUIRED' | 'SCOPE_VIOLATION';
5
+ message: string;
6
+ }
7
+ type GateResult<T> = {
8
+ ok: true;
9
+ value: T;
10
+ } | {
11
+ ok: false;
12
+ error: GateError;
13
+ };
14
+ //#endregion
15
+ export { AllowedScope, GateError, GateResult };
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "name": "@lssm/example.locale-jurisdiction-gate",
3
- "version": "0.0.0-canary-20251217054315",
3
+ "version": "0.0.0-canary-20251217060804",
4
4
  "description": "Example: enforce locale + jurisdiction + kbSnapshotId + allowed scope for assistant calls (fail-closed).",
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
- ".": "./src/index.ts",
11
- "./contracts": "./src/contracts/index.ts",
12
- "./contracts/assistant": "./src/contracts/assistant.ts",
13
- "./docs": "./src/docs/index.ts",
14
- "./docs/locale-jurisdiction-gate.docblock": "./src/docs/locale-jurisdiction-gate.docblock.ts",
15
- "./entities": "./src/entities/index.ts",
16
- "./entities/models": "./src/entities/models.ts",
17
- "./events": "./src/events.ts",
18
- "./example": "./src/example.ts",
19
- "./handlers": "./src/handlers/index.ts",
20
- "./handlers/demo.handlers": "./src/handlers/demo.handlers.ts",
21
- "./locale-jurisdiction-gate.feature": "./src/locale-jurisdiction-gate.feature.ts",
22
- "./policy": "./src/policy/index.ts",
23
- "./policy/guard": "./src/policy/guard.ts",
24
- "./policy/types": "./src/policy/types.ts",
10
+ ".": "./dist/index.js",
11
+ "./contracts": "./dist/contracts/index.js",
12
+ "./contracts/assistant": "./dist/contracts/assistant.js",
13
+ "./docs": "./dist/docs/index.js",
14
+ "./docs/locale-jurisdiction-gate.docblock": "./dist/docs/locale-jurisdiction-gate.docblock.js",
15
+ "./entities": "./dist/entities/index.js",
16
+ "./entities/models": "./dist/entities/models.js",
17
+ "./events": "./dist/events.js",
18
+ "./example": "./dist/example.js",
19
+ "./handlers": "./dist/handlers/index.js",
20
+ "./handlers/demo.handlers": "./dist/handlers/demo.handlers.js",
21
+ "./locale-jurisdiction-gate.feature": "./dist/locale-jurisdiction-gate.feature.js",
22
+ "./policy": "./dist/policy/index.js",
23
+ "./policy/guard": "./dist/policy/guard.js",
24
+ "./policy/types": "./dist/policy/types.js",
25
25
  "./*": "./*"
26
26
  },
27
27
  "scripts": {
@@ -38,13 +38,13 @@
38
38
  "test": "bun test"
39
39
  },
40
40
  "dependencies": {
41
- "@lssm/lib.contracts": "0.0.0-canary-20251217054315",
42
- "@lssm/lib.schema": "0.0.0-canary-20251217054315",
41
+ "@lssm/lib.contracts": "0.0.0-canary-20251217060804",
42
+ "@lssm/lib.schema": "0.0.0-canary-20251217060804",
43
43
  "zod": "^4.1.13"
44
44
  },
45
45
  "devDependencies": {
46
- "@lssm/tool.tsdown": "0.0.0-canary-20251217054315",
47
- "@lssm/tool.typescript": "0.0.0-canary-20251217054315",
46
+ "@lssm/tool.tsdown": "0.0.0-canary-20251217060804",
47
+ "@lssm/tool.typescript": "0.0.0-canary-20251217060804",
48
48
  "tsdown": "^0.17.4",
49
49
  "typescript": "^5.9.3"
50
50
  },