@lssm/example.locale-jurisdiction-gate 0.0.0-canary-20251217054315 → 0.0.0-canary-20251217060433
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 +41 -0
- package/.turbo/turbo-build.log +32 -17
- package/CHANGELOG.md +3 -27
- package/dist/contracts/assistant.d.ts +244 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/locale-jurisdiction-gate.docblock.d.ts +1 -0
- package/dist/entities/index.d.ts +2 -0
- package/dist/entities/models.d.ts +185 -0
- package/dist/events.d.ts +68 -0
- package/dist/example.d.ts +35 -0
- package/dist/handlers/demo.handlers.d.ts +58 -0
- package/dist/handlers/index.d.ts +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/locale-jurisdiction-gate.feature.d.ts +6 -0
- package/dist/policy/guard.d.ts +26 -0
- package/dist/policy/index.d.ts +3 -0
- package/dist/policy/types.d.ts +15 -0
- package/package.json +5 -5
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -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 };
|
package/dist/index.d.ts
ADDED
|
@@ -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,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,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/example.locale-jurisdiction-gate",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251217060433",
|
|
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",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"test": "bun test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@lssm/lib.contracts": "0.0.0-canary-
|
|
42
|
-
"@lssm/lib.schema": "0.0.0-canary-
|
|
41
|
+
"@lssm/lib.contracts": "0.0.0-canary-20251217060433",
|
|
42
|
+
"@lssm/lib.schema": "0.0.0-canary-20251217060433",
|
|
43
43
|
"zod": "^4.1.13"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
47
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
46
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251217060433",
|
|
47
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251217060433",
|
|
48
48
|
"tsdown": "^0.17.4",
|
|
49
49
|
"typescript": "^5.9.3"
|
|
50
50
|
},
|