@contractspec/example.locale-jurisdiction-gate 3.7.6 → 3.7.10

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.
Files changed (83) hide show
  1. package/.turbo/turbo-build.log +72 -51
  2. package/AGENTS.md +50 -27
  3. package/CHANGELOG.md +21 -0
  4. package/README.md +87 -42
  5. package/dist/browser/entities/index.js +2 -2
  6. package/dist/browser/entities/models.js +2 -2
  7. package/dist/browser/events.js +1 -1
  8. package/dist/browser/forms/assistant-context.form.js +213 -0
  9. package/dist/browser/forms/index.js +213 -0
  10. package/dist/browser/index.js +362 -40
  11. package/dist/browser/locale-jurisdiction-gate.feature.js +66 -1
  12. package/dist/browser/operations/assistant.js +3 -3
  13. package/dist/browser/operations/index.js +3 -3
  14. package/dist/browser/policy/assistant-gate.policy.js +62 -0
  15. package/dist/browser/policy/index.js +62 -1
  16. package/dist/browser/translations/assistant-gate.en-GB.translation.js +48 -0
  17. package/dist/browser/translations/assistant-gate.en-US.translation.js +50 -0
  18. package/dist/browser/translations/assistant-gate.fr-FR.translation.js +52 -0
  19. package/dist/browser/translations/index.js +148 -0
  20. package/dist/contracts.test.d.ts +1 -0
  21. package/dist/entities/index.js +2 -2
  22. package/dist/entities/models.js +2 -2
  23. package/dist/events.js +1 -1
  24. package/dist/forms/assistant-context.form.d.ts +22 -0
  25. package/dist/forms/assistant-context.form.js +214 -0
  26. package/dist/forms/index.d.ts +1 -0
  27. package/dist/forms/index.js +214 -0
  28. package/dist/index.d.ts +5 -3
  29. package/dist/index.js +362 -40
  30. package/dist/locale-jurisdiction-gate.feature.js +66 -1
  31. package/dist/node/entities/index.js +2 -2
  32. package/dist/node/entities/models.js +2 -2
  33. package/dist/node/events.js +1 -1
  34. package/dist/node/forms/assistant-context.form.js +213 -0
  35. package/dist/node/forms/index.js +213 -0
  36. package/dist/node/index.js +362 -40
  37. package/dist/node/locale-jurisdiction-gate.feature.js +66 -1
  38. package/dist/node/operations/assistant.js +3 -3
  39. package/dist/node/operations/index.js +3 -3
  40. package/dist/node/policy/assistant-gate.policy.js +62 -0
  41. package/dist/node/policy/index.js +62 -1
  42. package/dist/node/translations/assistant-gate.en-GB.translation.js +48 -0
  43. package/dist/node/translations/assistant-gate.en-US.translation.js +50 -0
  44. package/dist/node/translations/assistant-gate.fr-FR.translation.js +52 -0
  45. package/dist/node/translations/index.js +148 -0
  46. package/dist/operations/assistant.js +3 -3
  47. package/dist/operations/index.js +3 -3
  48. package/dist/policy/assistant-gate.policy.d.ts +1 -0
  49. package/dist/policy/assistant-gate.policy.js +63 -0
  50. package/dist/policy/index.d.ts +2 -1
  51. package/dist/policy/index.js +62 -1
  52. package/dist/translations/assistant-gate.en-GB.translation.d.ts +1 -0
  53. package/dist/translations/assistant-gate.en-GB.translation.js +49 -0
  54. package/dist/translations/assistant-gate.en-US.translation.d.ts +1 -0
  55. package/dist/translations/assistant-gate.en-US.translation.js +51 -0
  56. package/dist/translations/assistant-gate.fr-FR.translation.d.ts +1 -0
  57. package/dist/translations/assistant-gate.fr-FR.translation.js +53 -0
  58. package/dist/translations/index.d.ts +3 -0
  59. package/dist/translations/index.js +149 -0
  60. package/package.json +105 -7
  61. package/src/contracts.test.ts +32 -0
  62. package/src/docs/locale-jurisdiction-gate.docblock.ts +21 -21
  63. package/src/entities/models.ts +87 -87
  64. package/src/events.ts +55 -55
  65. package/src/example.ts +28 -28
  66. package/src/forms/assistant-context.form.ts +112 -0
  67. package/src/forms/index.ts +1 -0
  68. package/src/handlers/demo.handlers.test.ts +46 -46
  69. package/src/handlers/demo.handlers.ts +133 -133
  70. package/src/index.ts +5 -3
  71. package/src/locale-jurisdiction-gate.feature.ts +40 -34
  72. package/src/operations/assistant.ts +82 -82
  73. package/src/policy/assistant-gate.policy.ts +65 -0
  74. package/src/policy/guard.test.ts +18 -18
  75. package/src/policy/guard.ts +75 -75
  76. package/src/policy/index.ts +2 -1
  77. package/src/policy/types.ts +12 -12
  78. package/src/translations/assistant-gate.en-GB.translation.ts +46 -0
  79. package/src/translations/assistant-gate.en-US.translation.ts +48 -0
  80. package/src/translations/assistant-gate.fr-FR.translation.ts +51 -0
  81. package/src/translations/index.ts +3 -0
  82. package/tsconfig.json +7 -15
  83. package/tsdown.config.js +7 -13
@@ -66,8 +66,69 @@ function enforceAllowedScope(allowedScope, answer) {
66
66
  }
67
67
  return { ok: true, value: answer };
68
68
  }
69
+
70
+ // src/policy/assistant-gate.policy.ts
71
+ import {
72
+ OwnersEnum,
73
+ StabilityEnum,
74
+ TagsEnum
75
+ } from "@contractspec/lib.contracts-spec/ownership";
76
+ import { definePolicy } from "@contractspec/lib.contracts-spec/policy";
77
+ var AssistantGatePolicy = definePolicy({
78
+ meta: {
79
+ key: "locale-jurisdiction-gate.policy.gate",
80
+ version: "1.0.0",
81
+ title: "Assistant Locale and Jurisdiction Gate",
82
+ description: "Requires explicit locale, jurisdiction, knowledge snapshot, and allowed scope before assistant requests may proceed.",
83
+ domain: "assistant",
84
+ scope: "operation",
85
+ owners: [OwnersEnum.PlatformFinance],
86
+ tags: [TagsEnum.I18n, "assistant", "policy", "jurisdiction"],
87
+ stability: StabilityEnum.Experimental
88
+ },
89
+ rules: [
90
+ {
91
+ effect: "deny",
92
+ actions: ["assistant.answer", "assistant.explainConcept"],
93
+ resource: { type: "assistant-call" },
94
+ conditions: [
95
+ {
96
+ expression: "!context.locale || !context.jurisdiction || !context.kbSnapshotId || !context.allowedScope"
97
+ }
98
+ ],
99
+ reason: "Assistant requests fail closed until locale, jurisdiction, kbSnapshotId, and allowedScope are explicit."
100
+ },
101
+ {
102
+ effect: "deny",
103
+ actions: ["assistant.answer", "assistant.explainConcept"],
104
+ resource: { type: "assistant-call" },
105
+ conditions: [
106
+ {
107
+ expression: "!['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '')"
108
+ }
109
+ ],
110
+ reason: "Only the explicitly reviewed assistant locales are permitted."
111
+ },
112
+ {
113
+ effect: "allow",
114
+ actions: ["assistant.answer", "assistant.explainConcept"],
115
+ resource: { type: "assistant-call" },
116
+ conditions: [
117
+ {
118
+ expression: "['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '') && !!context.jurisdiction && !!context.kbSnapshotId && !!context.allowedScope"
119
+ }
120
+ ],
121
+ reason: "Explicit context is present, so the request may continue to citation and scope validation."
122
+ }
123
+ ],
124
+ pii: {
125
+ fields: ["kbSnapshotId"],
126
+ retentionDays: 30
127
+ }
128
+ });
69
129
  export {
70
130
  validateEnvelope,
71
131
  enforceCitations,
72
- enforceAllowedScope
132
+ enforceAllowedScope,
133
+ AssistantGatePolicy
73
134
  };
@@ -0,0 +1,48 @@
1
+ // src/translations/assistant-gate.en-GB.translation.ts
2
+ import {
3
+ OwnersEnum,
4
+ StabilityEnum,
5
+ TagsEnum
6
+ } from "@contractspec/lib.contracts-spec/ownership";
7
+ import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
8
+ var AssistantGateMessagesEnGb = defineTranslation({
9
+ meta: {
10
+ key: "locale-jurisdiction-gate.translation.assistant-gate.en-GB",
11
+ version: "1.0.0",
12
+ domain: "assistant",
13
+ description: "British English messages for the assistant locale and jurisdiction gate.",
14
+ owners: [OwnersEnum.PlatformFinance],
15
+ stability: StabilityEnum.Experimental,
16
+ tags: [TagsEnum.I18n, "assistant", "policy"]
17
+ },
18
+ locale: "en-GB",
19
+ fallback: "en-US",
20
+ messages: {
21
+ "assistantGate.locale.label": { value: "Locale" },
22
+ "assistantGate.locale.description": {
23
+ value: "Select the reviewed locale for the assistant response."
24
+ },
25
+ "assistantGate.jurisdiction.label": { value: "Jurisdiction" },
26
+ "assistantGate.jurisdiction.placeholder": { value: "UK-FCA" },
27
+ "assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
28
+ "assistantGate.kbSnapshotId.placeholder": {
29
+ value: "kb_2026_03_20_policy_reviewed"
30
+ },
31
+ "assistantGate.allowedScope.label": { value: "Permitted scope" },
32
+ "assistantGate.allowedScope.educationOnly": {
33
+ value: "Educational content only"
34
+ },
35
+ "assistantGate.allowedScope.genericInfo": { value: "General information" },
36
+ "assistantGate.allowedScope.escalationRequired": {
37
+ value: "Escalation required"
38
+ },
39
+ "assistantGate.question.label": { value: "Question" },
40
+ "assistantGate.question.placeholder": {
41
+ value: "What may I say about this product in the selected jurisdiction?"
42
+ },
43
+ "assistantGate.submit.label": { value: "Generate response" }
44
+ }
45
+ });
46
+ export {
47
+ AssistantGateMessagesEnGb
48
+ };
@@ -0,0 +1,50 @@
1
+ // src/translations/assistant-gate.en-US.translation.ts
2
+ import {
3
+ OwnersEnum,
4
+ StabilityEnum,
5
+ TagsEnum
6
+ } from "@contractspec/lib.contracts-spec/ownership";
7
+ import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
8
+ var AssistantGateMessagesEnUs = defineTranslation({
9
+ meta: {
10
+ key: "locale-jurisdiction-gate.translation.assistant-gate.en-US",
11
+ version: "1.0.0",
12
+ domain: "assistant",
13
+ description: "US English messages for the assistant locale and jurisdiction gate.",
14
+ owners: [OwnersEnum.PlatformFinance],
15
+ stability: StabilityEnum.Experimental,
16
+ tags: [TagsEnum.I18n, "assistant", "policy"]
17
+ },
18
+ locale: "en-US",
19
+ messages: {
20
+ "assistantGate.locale.label": { value: "Locale" },
21
+ "assistantGate.locale.description": {
22
+ value: "Choose the reviewed locale for the assistant answer."
23
+ },
24
+ "assistantGate.locale.enUs": { value: "English (United States)" },
25
+ "assistantGate.locale.enGb": { value: "English (United Kingdom)" },
26
+ "assistantGate.locale.frFr": { value: "French (France)" },
27
+ "assistantGate.jurisdiction.label": { value: "Jurisdiction" },
28
+ "assistantGate.jurisdiction.placeholder": { value: "US-SEC" },
29
+ "assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
30
+ "assistantGate.kbSnapshotId.placeholder": {
31
+ value: "kb_2026_03_20_policy_reviewed"
32
+ },
33
+ "assistantGate.allowedScope.label": { value: "Allowed scope" },
34
+ "assistantGate.allowedScope.educationOnly": {
35
+ value: "Educational content only"
36
+ },
37
+ "assistantGate.allowedScope.genericInfo": { value: "Generic information" },
38
+ "assistantGate.allowedScope.escalationRequired": {
39
+ value: "Escalation required"
40
+ },
41
+ "assistantGate.question.label": { value: "Question" },
42
+ "assistantGate.question.placeholder": {
43
+ value: "What can I say about this product in the selected jurisdiction?"
44
+ },
45
+ "assistantGate.submit.label": { value: "Generate answer" }
46
+ }
47
+ });
48
+ export {
49
+ AssistantGateMessagesEnUs
50
+ };
@@ -0,0 +1,52 @@
1
+ // src/translations/assistant-gate.fr-FR.translation.ts
2
+ import {
3
+ OwnersEnum,
4
+ StabilityEnum,
5
+ TagsEnum
6
+ } from "@contractspec/lib.contracts-spec/ownership";
7
+ import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
8
+ var AssistantGateMessagesFrFr = defineTranslation({
9
+ meta: {
10
+ key: "locale-jurisdiction-gate.translation.assistant-gate.fr-FR",
11
+ version: "1.0.0",
12
+ domain: "assistant",
13
+ description: "French messages for the assistant locale and jurisdiction gate.",
14
+ owners: [OwnersEnum.PlatformFinance],
15
+ stability: StabilityEnum.Experimental,
16
+ tags: [TagsEnum.I18n, "assistant", "policy"]
17
+ },
18
+ locale: "fr-FR",
19
+ fallback: "en-US",
20
+ messages: {
21
+ "assistantGate.locale.label": { value: "Langue" },
22
+ "assistantGate.locale.description": {
23
+ value: "Sélectionnez la langue validée pour la réponse de l'assistant."
24
+ },
25
+ "assistantGate.jurisdiction.label": { value: "Juridiction" },
26
+ "assistantGate.jurisdiction.placeholder": { value: "FR-AMF" },
27
+ "assistantGate.kbSnapshotId.label": {
28
+ value: "Identifiant du snapshot documentaire"
29
+ },
30
+ "assistantGate.kbSnapshotId.placeholder": {
31
+ value: "kb_2026_03_20_policy_reviewed"
32
+ },
33
+ "assistantGate.allowedScope.label": { value: "Périmètre autorisé" },
34
+ "assistantGate.allowedScope.educationOnly": {
35
+ value: "Contenu éducatif uniquement"
36
+ },
37
+ "assistantGate.allowedScope.genericInfo": {
38
+ value: "Information générale"
39
+ },
40
+ "assistantGate.allowedScope.escalationRequired": {
41
+ value: "Escalade obligatoire"
42
+ },
43
+ "assistantGate.question.label": { value: "Question" },
44
+ "assistantGate.question.placeholder": {
45
+ value: "Que puis-je dire sur ce produit dans la juridiction sélectionnée ?"
46
+ },
47
+ "assistantGate.submit.label": { value: "Générer la réponse" }
48
+ }
49
+ });
50
+ export {
51
+ AssistantGateMessagesFrFr
52
+ };
@@ -0,0 +1,148 @@
1
+ // src/translations/assistant-gate.en-GB.translation.ts
2
+ import {
3
+ OwnersEnum,
4
+ StabilityEnum,
5
+ TagsEnum
6
+ } from "@contractspec/lib.contracts-spec/ownership";
7
+ import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
8
+ var AssistantGateMessagesEnGb = defineTranslation({
9
+ meta: {
10
+ key: "locale-jurisdiction-gate.translation.assistant-gate.en-GB",
11
+ version: "1.0.0",
12
+ domain: "assistant",
13
+ description: "British English messages for the assistant locale and jurisdiction gate.",
14
+ owners: [OwnersEnum.PlatformFinance],
15
+ stability: StabilityEnum.Experimental,
16
+ tags: [TagsEnum.I18n, "assistant", "policy"]
17
+ },
18
+ locale: "en-GB",
19
+ fallback: "en-US",
20
+ messages: {
21
+ "assistantGate.locale.label": { value: "Locale" },
22
+ "assistantGate.locale.description": {
23
+ value: "Select the reviewed locale for the assistant response."
24
+ },
25
+ "assistantGate.jurisdiction.label": { value: "Jurisdiction" },
26
+ "assistantGate.jurisdiction.placeholder": { value: "UK-FCA" },
27
+ "assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
28
+ "assistantGate.kbSnapshotId.placeholder": {
29
+ value: "kb_2026_03_20_policy_reviewed"
30
+ },
31
+ "assistantGate.allowedScope.label": { value: "Permitted scope" },
32
+ "assistantGate.allowedScope.educationOnly": {
33
+ value: "Educational content only"
34
+ },
35
+ "assistantGate.allowedScope.genericInfo": { value: "General information" },
36
+ "assistantGate.allowedScope.escalationRequired": {
37
+ value: "Escalation required"
38
+ },
39
+ "assistantGate.question.label": { value: "Question" },
40
+ "assistantGate.question.placeholder": {
41
+ value: "What may I say about this product in the selected jurisdiction?"
42
+ },
43
+ "assistantGate.submit.label": { value: "Generate response" }
44
+ }
45
+ });
46
+
47
+ // src/translations/assistant-gate.en-US.translation.ts
48
+ import {
49
+ OwnersEnum as OwnersEnum2,
50
+ StabilityEnum as StabilityEnum2,
51
+ TagsEnum as TagsEnum2
52
+ } from "@contractspec/lib.contracts-spec/ownership";
53
+ import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations/spec";
54
+ var AssistantGateMessagesEnUs = defineTranslation2({
55
+ meta: {
56
+ key: "locale-jurisdiction-gate.translation.assistant-gate.en-US",
57
+ version: "1.0.0",
58
+ domain: "assistant",
59
+ description: "US English messages for the assistant locale and jurisdiction gate.",
60
+ owners: [OwnersEnum2.PlatformFinance],
61
+ stability: StabilityEnum2.Experimental,
62
+ tags: [TagsEnum2.I18n, "assistant", "policy"]
63
+ },
64
+ locale: "en-US",
65
+ messages: {
66
+ "assistantGate.locale.label": { value: "Locale" },
67
+ "assistantGate.locale.description": {
68
+ value: "Choose the reviewed locale for the assistant answer."
69
+ },
70
+ "assistantGate.locale.enUs": { value: "English (United States)" },
71
+ "assistantGate.locale.enGb": { value: "English (United Kingdom)" },
72
+ "assistantGate.locale.frFr": { value: "French (France)" },
73
+ "assistantGate.jurisdiction.label": { value: "Jurisdiction" },
74
+ "assistantGate.jurisdiction.placeholder": { value: "US-SEC" },
75
+ "assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
76
+ "assistantGate.kbSnapshotId.placeholder": {
77
+ value: "kb_2026_03_20_policy_reviewed"
78
+ },
79
+ "assistantGate.allowedScope.label": { value: "Allowed scope" },
80
+ "assistantGate.allowedScope.educationOnly": {
81
+ value: "Educational content only"
82
+ },
83
+ "assistantGate.allowedScope.genericInfo": { value: "Generic information" },
84
+ "assistantGate.allowedScope.escalationRequired": {
85
+ value: "Escalation required"
86
+ },
87
+ "assistantGate.question.label": { value: "Question" },
88
+ "assistantGate.question.placeholder": {
89
+ value: "What can I say about this product in the selected jurisdiction?"
90
+ },
91
+ "assistantGate.submit.label": { value: "Generate answer" }
92
+ }
93
+ });
94
+
95
+ // src/translations/assistant-gate.fr-FR.translation.ts
96
+ import {
97
+ OwnersEnum as OwnersEnum3,
98
+ StabilityEnum as StabilityEnum3,
99
+ TagsEnum as TagsEnum3
100
+ } from "@contractspec/lib.contracts-spec/ownership";
101
+ import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations/spec";
102
+ var AssistantGateMessagesFrFr = defineTranslation3({
103
+ meta: {
104
+ key: "locale-jurisdiction-gate.translation.assistant-gate.fr-FR",
105
+ version: "1.0.0",
106
+ domain: "assistant",
107
+ description: "French messages for the assistant locale and jurisdiction gate.",
108
+ owners: [OwnersEnum3.PlatformFinance],
109
+ stability: StabilityEnum3.Experimental,
110
+ tags: [TagsEnum3.I18n, "assistant", "policy"]
111
+ },
112
+ locale: "fr-FR",
113
+ fallback: "en-US",
114
+ messages: {
115
+ "assistantGate.locale.label": { value: "Langue" },
116
+ "assistantGate.locale.description": {
117
+ value: "Sélectionnez la langue validée pour la réponse de l'assistant."
118
+ },
119
+ "assistantGate.jurisdiction.label": { value: "Juridiction" },
120
+ "assistantGate.jurisdiction.placeholder": { value: "FR-AMF" },
121
+ "assistantGate.kbSnapshotId.label": {
122
+ value: "Identifiant du snapshot documentaire"
123
+ },
124
+ "assistantGate.kbSnapshotId.placeholder": {
125
+ value: "kb_2026_03_20_policy_reviewed"
126
+ },
127
+ "assistantGate.allowedScope.label": { value: "Périmètre autorisé" },
128
+ "assistantGate.allowedScope.educationOnly": {
129
+ value: "Contenu éducatif uniquement"
130
+ },
131
+ "assistantGate.allowedScope.genericInfo": {
132
+ value: "Information générale"
133
+ },
134
+ "assistantGate.allowedScope.escalationRequired": {
135
+ value: "Escalade obligatoire"
136
+ },
137
+ "assistantGate.question.label": { value: "Question" },
138
+ "assistantGate.question.placeholder": {
139
+ value: "Que puis-je dire sur ce produit dans la juridiction sélectionnée ?"
140
+ },
141
+ "assistantGate.submit.label": { value: "Générer la réponse" }
142
+ }
143
+ });
144
+ export {
145
+ AssistantGateMessagesFrFr,
146
+ AssistantGateMessagesEnUs,
147
+ AssistantGateMessagesEnGb
148
+ };
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  // src/entities/models.ts
3
3
  import {
4
- ScalarTypeEnum,
5
4
  defineEnum,
6
- defineSchemaModel
5
+ defineSchemaModel,
6
+ ScalarTypeEnum
7
7
  } from "@contractspec/lib.schema";
8
8
  var AllowedScopeEnum = defineEnum("AllowedScope", [
9
9
  "education_only",
@@ -103,7 +103,7 @@ var AssistantAnswerIRModel = defineSchemaModel({
103
103
 
104
104
  // src/operations/assistant.ts
105
105
  import { defineCommand } from "@contractspec/lib.contracts-spec";
106
- import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
106
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
107
107
  var AssistantQuestionInput = defineSchemaModel2({
108
108
  name: "AssistantQuestionInput",
109
109
  description: "Input for assistant calls with mandatory envelope.",
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  // src/entities/models.ts
3
3
  import {
4
- ScalarTypeEnum,
5
4
  defineEnum,
6
- defineSchemaModel
5
+ defineSchemaModel,
6
+ ScalarTypeEnum
7
7
  } from "@contractspec/lib.schema";
8
8
  var AllowedScopeEnum = defineEnum("AllowedScope", [
9
9
  "education_only",
@@ -103,7 +103,7 @@ var AssistantAnswerIRModel = defineSchemaModel({
103
103
 
104
104
  // src/operations/assistant.ts
105
105
  import { defineCommand } from "@contractspec/lib.contracts-spec";
106
- import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
106
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
107
107
  var AssistantQuestionInput = defineSchemaModel2({
108
108
  name: "AssistantQuestionInput",
109
109
  description: "Input for assistant calls with mandatory envelope.",
@@ -0,0 +1 @@
1
+ export declare const AssistantGatePolicy: import("@contractspec/lib.contracts-spec/policy").PolicySpec;
@@ -0,0 +1,63 @@
1
+ // @bun
2
+ // src/policy/assistant-gate.policy.ts
3
+ import {
4
+ OwnersEnum,
5
+ StabilityEnum,
6
+ TagsEnum
7
+ } from "@contractspec/lib.contracts-spec/ownership";
8
+ import { definePolicy } from "@contractspec/lib.contracts-spec/policy";
9
+ var AssistantGatePolicy = definePolicy({
10
+ meta: {
11
+ key: "locale-jurisdiction-gate.policy.gate",
12
+ version: "1.0.0",
13
+ title: "Assistant Locale and Jurisdiction Gate",
14
+ description: "Requires explicit locale, jurisdiction, knowledge snapshot, and allowed scope before assistant requests may proceed.",
15
+ domain: "assistant",
16
+ scope: "operation",
17
+ owners: [OwnersEnum.PlatformFinance],
18
+ tags: [TagsEnum.I18n, "assistant", "policy", "jurisdiction"],
19
+ stability: StabilityEnum.Experimental
20
+ },
21
+ rules: [
22
+ {
23
+ effect: "deny",
24
+ actions: ["assistant.answer", "assistant.explainConcept"],
25
+ resource: { type: "assistant-call" },
26
+ conditions: [
27
+ {
28
+ expression: "!context.locale || !context.jurisdiction || !context.kbSnapshotId || !context.allowedScope"
29
+ }
30
+ ],
31
+ reason: "Assistant requests fail closed until locale, jurisdiction, kbSnapshotId, and allowedScope are explicit."
32
+ },
33
+ {
34
+ effect: "deny",
35
+ actions: ["assistant.answer", "assistant.explainConcept"],
36
+ resource: { type: "assistant-call" },
37
+ conditions: [
38
+ {
39
+ expression: "!['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '')"
40
+ }
41
+ ],
42
+ reason: "Only the explicitly reviewed assistant locales are permitted."
43
+ },
44
+ {
45
+ effect: "allow",
46
+ actions: ["assistant.answer", "assistant.explainConcept"],
47
+ resource: { type: "assistant-call" },
48
+ conditions: [
49
+ {
50
+ expression: "['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '') && !!context.jurisdiction && !!context.kbSnapshotId && !!context.allowedScope"
51
+ }
52
+ ],
53
+ reason: "Explicit context is present, so the request may continue to citation and scope validation."
54
+ }
55
+ ],
56
+ pii: {
57
+ fields: ["kbSnapshotId"],
58
+ retentionDays: 30
59
+ }
60
+ });
61
+ export {
62
+ AssistantGatePolicy
63
+ };
@@ -1,2 +1,3 @@
1
- export * from './types';
1
+ export * from './assistant-gate.policy';
2
2
  export * from './guard';
3
+ export * from './types';
@@ -67,8 +67,69 @@ function enforceAllowedScope(allowedScope, answer) {
67
67
  }
68
68
  return { ok: true, value: answer };
69
69
  }
70
+
71
+ // src/policy/assistant-gate.policy.ts
72
+ import {
73
+ OwnersEnum,
74
+ StabilityEnum,
75
+ TagsEnum
76
+ } from "@contractspec/lib.contracts-spec/ownership";
77
+ import { definePolicy } from "@contractspec/lib.contracts-spec/policy";
78
+ var AssistantGatePolicy = definePolicy({
79
+ meta: {
80
+ key: "locale-jurisdiction-gate.policy.gate",
81
+ version: "1.0.0",
82
+ title: "Assistant Locale and Jurisdiction Gate",
83
+ description: "Requires explicit locale, jurisdiction, knowledge snapshot, and allowed scope before assistant requests may proceed.",
84
+ domain: "assistant",
85
+ scope: "operation",
86
+ owners: [OwnersEnum.PlatformFinance],
87
+ tags: [TagsEnum.I18n, "assistant", "policy", "jurisdiction"],
88
+ stability: StabilityEnum.Experimental
89
+ },
90
+ rules: [
91
+ {
92
+ effect: "deny",
93
+ actions: ["assistant.answer", "assistant.explainConcept"],
94
+ resource: { type: "assistant-call" },
95
+ conditions: [
96
+ {
97
+ expression: "!context.locale || !context.jurisdiction || !context.kbSnapshotId || !context.allowedScope"
98
+ }
99
+ ],
100
+ reason: "Assistant requests fail closed until locale, jurisdiction, kbSnapshotId, and allowedScope are explicit."
101
+ },
102
+ {
103
+ effect: "deny",
104
+ actions: ["assistant.answer", "assistant.explainConcept"],
105
+ resource: { type: "assistant-call" },
106
+ conditions: [
107
+ {
108
+ expression: "!['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '')"
109
+ }
110
+ ],
111
+ reason: "Only the explicitly reviewed assistant locales are permitted."
112
+ },
113
+ {
114
+ effect: "allow",
115
+ actions: ["assistant.answer", "assistant.explainConcept"],
116
+ resource: { type: "assistant-call" },
117
+ conditions: [
118
+ {
119
+ expression: "['en-US', 'en-GB', 'fr-FR'].includes(context.locale ?? '') && !!context.jurisdiction && !!context.kbSnapshotId && !!context.allowedScope"
120
+ }
121
+ ],
122
+ reason: "Explicit context is present, so the request may continue to citation and scope validation."
123
+ }
124
+ ],
125
+ pii: {
126
+ fields: ["kbSnapshotId"],
127
+ retentionDays: 30
128
+ }
129
+ });
70
130
  export {
71
131
  validateEnvelope,
72
132
  enforceCitations,
73
- enforceAllowedScope
133
+ enforceAllowedScope,
134
+ AssistantGatePolicy
74
135
  };
@@ -0,0 +1 @@
1
+ export declare const AssistantGateMessagesEnGb: import("@contractspec/lib.contracts-spec/translations/spec").TranslationSpec;
@@ -0,0 +1,49 @@
1
+ // @bun
2
+ // src/translations/assistant-gate.en-GB.translation.ts
3
+ import {
4
+ OwnersEnum,
5
+ StabilityEnum,
6
+ TagsEnum
7
+ } from "@contractspec/lib.contracts-spec/ownership";
8
+ import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
9
+ var AssistantGateMessagesEnGb = defineTranslation({
10
+ meta: {
11
+ key: "locale-jurisdiction-gate.translation.assistant-gate.en-GB",
12
+ version: "1.0.0",
13
+ domain: "assistant",
14
+ description: "British English messages for the assistant locale and jurisdiction gate.",
15
+ owners: [OwnersEnum.PlatformFinance],
16
+ stability: StabilityEnum.Experimental,
17
+ tags: [TagsEnum.I18n, "assistant", "policy"]
18
+ },
19
+ locale: "en-GB",
20
+ fallback: "en-US",
21
+ messages: {
22
+ "assistantGate.locale.label": { value: "Locale" },
23
+ "assistantGate.locale.description": {
24
+ value: "Select the reviewed locale for the assistant response."
25
+ },
26
+ "assistantGate.jurisdiction.label": { value: "Jurisdiction" },
27
+ "assistantGate.jurisdiction.placeholder": { value: "UK-FCA" },
28
+ "assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
29
+ "assistantGate.kbSnapshotId.placeholder": {
30
+ value: "kb_2026_03_20_policy_reviewed"
31
+ },
32
+ "assistantGate.allowedScope.label": { value: "Permitted scope" },
33
+ "assistantGate.allowedScope.educationOnly": {
34
+ value: "Educational content only"
35
+ },
36
+ "assistantGate.allowedScope.genericInfo": { value: "General information" },
37
+ "assistantGate.allowedScope.escalationRequired": {
38
+ value: "Escalation required"
39
+ },
40
+ "assistantGate.question.label": { value: "Question" },
41
+ "assistantGate.question.placeholder": {
42
+ value: "What may I say about this product in the selected jurisdiction?"
43
+ },
44
+ "assistantGate.submit.label": { value: "Generate response" }
45
+ }
46
+ });
47
+ export {
48
+ AssistantGateMessagesEnGb
49
+ };
@@ -0,0 +1 @@
1
+ export declare const AssistantGateMessagesEnUs: import("@contractspec/lib.contracts-spec/translations/spec").TranslationSpec;
@@ -0,0 +1,51 @@
1
+ // @bun
2
+ // src/translations/assistant-gate.en-US.translation.ts
3
+ import {
4
+ OwnersEnum,
5
+ StabilityEnum,
6
+ TagsEnum
7
+ } from "@contractspec/lib.contracts-spec/ownership";
8
+ import { defineTranslation } from "@contractspec/lib.contracts-spec/translations/spec";
9
+ var AssistantGateMessagesEnUs = defineTranslation({
10
+ meta: {
11
+ key: "locale-jurisdiction-gate.translation.assistant-gate.en-US",
12
+ version: "1.0.0",
13
+ domain: "assistant",
14
+ description: "US English messages for the assistant locale and jurisdiction gate.",
15
+ owners: [OwnersEnum.PlatformFinance],
16
+ stability: StabilityEnum.Experimental,
17
+ tags: [TagsEnum.I18n, "assistant", "policy"]
18
+ },
19
+ locale: "en-US",
20
+ messages: {
21
+ "assistantGate.locale.label": { value: "Locale" },
22
+ "assistantGate.locale.description": {
23
+ value: "Choose the reviewed locale for the assistant answer."
24
+ },
25
+ "assistantGate.locale.enUs": { value: "English (United States)" },
26
+ "assistantGate.locale.enGb": { value: "English (United Kingdom)" },
27
+ "assistantGate.locale.frFr": { value: "French (France)" },
28
+ "assistantGate.jurisdiction.label": { value: "Jurisdiction" },
29
+ "assistantGate.jurisdiction.placeholder": { value: "US-SEC" },
30
+ "assistantGate.kbSnapshotId.label": { value: "Knowledge snapshot ID" },
31
+ "assistantGate.kbSnapshotId.placeholder": {
32
+ value: "kb_2026_03_20_policy_reviewed"
33
+ },
34
+ "assistantGate.allowedScope.label": { value: "Allowed scope" },
35
+ "assistantGate.allowedScope.educationOnly": {
36
+ value: "Educational content only"
37
+ },
38
+ "assistantGate.allowedScope.genericInfo": { value: "Generic information" },
39
+ "assistantGate.allowedScope.escalationRequired": {
40
+ value: "Escalation required"
41
+ },
42
+ "assistantGate.question.label": { value: "Question" },
43
+ "assistantGate.question.placeholder": {
44
+ value: "What can I say about this product in the selected jurisdiction?"
45
+ },
46
+ "assistantGate.submit.label": { value: "Generate answer" }
47
+ }
48
+ });
49
+ export {
50
+ AssistantGateMessagesEnUs
51
+ };
@@ -0,0 +1 @@
1
+ export declare const AssistantGateMessagesFrFr: import("@contractspec/lib.contracts-spec/translations/spec").TranslationSpec;