@contractspec/lib.personalization 3.3.0 → 3.4.0

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.
File without changes
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from './store';
3
3
  export * from './tracker';
4
4
  export * from './analyzer';
5
5
  export * from './adapter';
6
+ export * from './preference-dimensions';
6
7
  import './docs';
File without changes
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Preference dimensions and bundle preference adapter.
3
+ * Aligns with specs/contractspec_modules_bundle_spec_2026-03-08 (05_personalization_model.md)
4
+ * and references/current_specs/01_preference_dimensions.md.
5
+ *
6
+ * Surface-runtime and other bundles may consume these types for 7-dimension personalization.
7
+ */
8
+ /** 7-dimension preference model. Each dimension is independent. */
9
+ export interface PreferenceDimensions {
10
+ guidance: 'none' | 'hints' | 'tooltips' | 'walkthrough' | 'wizard';
11
+ density: 'minimal' | 'compact' | 'standard' | 'detailed' | 'dense';
12
+ dataDepth: 'summary' | 'standard' | 'detailed' | 'exhaustive';
13
+ control: 'restricted' | 'standard' | 'advanced' | 'full';
14
+ media: 'text' | 'visual' | 'voice' | 'hybrid';
15
+ pace: 'deliberate' | 'balanced' | 'rapid';
16
+ narrative: 'top-down' | 'bottom-up' | 'adaptive';
17
+ }
18
+ /** Scope from which a preference value was resolved. Order: user → workspace-user → bundle → surface → entity → session. */
19
+ export type PreferenceScope = 'user' | 'workspace-user' | 'bundle' | 'surface' | 'entity' | 'session';
20
+ /** Resolved preference profile with source attribution and constraint notes per dimension. */
21
+ export interface ResolvedPreferenceProfile {
22
+ /** Canonical values after scope merge and constraint resolution. */
23
+ canonical: PreferenceDimensions;
24
+ /** Source scope per dimension (which layer provided the value). */
25
+ sourceByDimension: Partial<Record<keyof PreferenceDimensions, PreferenceScope>>;
26
+ /** Dimensions that were constrained (requested value not applied); value = reason. */
27
+ constrained: Partial<Record<keyof PreferenceDimensions, string>>;
28
+ /** Human-readable notes (e.g. constraint reasons, fallbacks). */
29
+ notes: string[];
30
+ }
31
+ /** Minimal context for preference resolution. Bundle runtimes pass a broader context (e.g. BundleContext). */
32
+ export interface PreferenceResolutionContext {
33
+ tenantId: string;
34
+ workspaceId?: string;
35
+ actorId?: string;
36
+ preferences: PreferenceDimensions;
37
+ capabilities: string[];
38
+ }
39
+ /** Adapter for resolving and persisting preferences in bundle runtimes. */
40
+ export interface BundlePreferenceAdapter {
41
+ resolve(ctx: PreferenceResolutionContext): Promise<ResolvedPreferenceProfile>;
42
+ savePreferencePatch(args: {
43
+ actorId: string;
44
+ workspaceId?: string;
45
+ patch: Partial<PreferenceDimensions>;
46
+ scope: 'user' | 'workspace-user' | 'surface';
47
+ }): Promise<void>;
48
+ }
@@ -0,0 +1 @@
1
+ // @bun
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/lib.personalization",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Behavior tracking, analysis, and adaptation helpers for ContractSpec personalization.",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -32,20 +32,20 @@
32
32
  "typecheck": "tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@contractspec/lib.bus": "3.3.0",
36
- "@contractspec/lib.schema": "3.3.0",
37
- "@contractspec/lib.contracts-spec": "3.3.0",
38
- "@contractspec/lib.knowledge": "3.3.0",
39
- "@contractspec/lib.overlay-engine": "3.3.0",
35
+ "@contractspec/lib.bus": "3.4.0",
36
+ "@contractspec/lib.schema": "3.4.0",
37
+ "@contractspec/lib.contracts-spec": "3.4.0",
38
+ "@contractspec/lib.knowledge": "3.4.0",
39
+ "@contractspec/lib.overlay-engine": "3.4.0",
40
40
  "@opentelemetry/api": "^1.9.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@opentelemetry/api": "^1.9.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@contractspec/tool.typescript": "3.3.0",
46
+ "@contractspec/tool.typescript": "3.4.0",
47
47
  "typescript": "^5.9.3",
48
- "@contractspec/tool.bun": "3.3.0"
48
+ "@contractspec/tool.bun": "3.4.0"
49
49
  },
50
50
  "exports": {
51
51
  ".": {
@@ -104,6 +104,13 @@
104
104
  "browser": "./dist/browser/docs/workflow-composition.docblock.js",
105
105
  "default": "./dist/docs/workflow-composition.docblock.js"
106
106
  },
107
+ "./preference-dimensions": {
108
+ "types": "./dist/preference-dimensions.d.ts",
109
+ "bun": "./dist/preference-dimensions.js",
110
+ "node": "./dist/node/preference-dimensions.js",
111
+ "browser": "./dist/browser/preference-dimensions.js",
112
+ "default": "./dist/preference-dimensions.js"
113
+ },
107
114
  "./store": {
108
115
  "types": "./dist/store.d.ts",
109
116
  "bun": "./dist/store.js",
@@ -185,6 +192,13 @@
185
192
  "browser": "./dist/browser/docs/workflow-composition.docblock.js",
186
193
  "default": "./dist/docs/workflow-composition.docblock.js"
187
194
  },
195
+ "./preference-dimensions": {
196
+ "types": "./dist/preference-dimensions.d.ts",
197
+ "bun": "./dist/preference-dimensions.js",
198
+ "node": "./dist/node/preference-dimensions.js",
199
+ "browser": "./dist/browser/preference-dimensions.js",
200
+ "default": "./dist/preference-dimensions.js"
201
+ },
188
202
  "./store": {
189
203
  "types": "./dist/store.d.ts",
190
204
  "bun": "./dist/store.js",