oracular 0.3.0 → 0.5.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.
@@ -0,0 +1,141 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://yuribenjamin.github.io/oracular/config.schema.json",
4
+ "title": "oracular config",
5
+ "description": "Everything createState needs: intents with their priors and signals, plus engine-wide options. Every duration is in the unit of the timestamps you pass as `at` (milliseconds when you use Date.now()). The engine checks the same rules at run time and rejects unknown keys; `$schema` is allowed here so a JSON file can point at this schema, and `oracular replay` drops it before handing the file to the engine.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["intents"],
9
+ "properties": {
10
+ "$schema": {
11
+ "type": "string",
12
+ "description": "Where this schema lives, for editors. Not part of the config: strip it before calling createState, or let `oracular replay` do it."
13
+ },
14
+ "intents": {
15
+ "type": "object",
16
+ "description": "One entry per thing the user might be about to do, keyed by the intent's name.",
17
+ "minProperties": 1,
18
+ "propertyNames": { "$ref": "#/$defs/name" },
19
+ "additionalProperties": { "$ref": "#/$defs/intent" }
20
+ },
21
+ "episodeTimeout": {
22
+ "$ref": "#/$defs/duration",
23
+ "description": "Idle gap after which the current episode ends on its own. Omit to end episodes only through endEpisode."
24
+ },
25
+ "learning": {
26
+ "$ref": "#/$defs/learning",
27
+ "description": "How the engine learns from the user's own outcomes."
28
+ },
29
+ "reveal": {
30
+ "$ref": "#/$defs/reveal",
31
+ "description": "Reveal defaults for every intent."
32
+ }
33
+ },
34
+ "$defs": {
35
+ "name": {
36
+ "type": "string",
37
+ "minLength": 1,
38
+ "not": { "const": "__proto__" }
39
+ },
40
+ "duration": {
41
+ "type": "number",
42
+ "exclusiveMinimum": 0
43
+ },
44
+ "bounded": {
45
+ "type": "number",
46
+ "exclusiveMinimum": 0,
47
+ "maximum": 1000000
48
+ },
49
+ "weight": {
50
+ "type": "number",
51
+ "minimum": -1000000,
52
+ "maximum": 1000000,
53
+ "not": { "const": 0 },
54
+ "description": "Initial weight of a signal, in pseudo-counts. Positive is evidence for the intent, negative against."
55
+ },
56
+ "intent": {
57
+ "type": "object",
58
+ "additionalProperties": false,
59
+ "required": ["prior", "priorStrength", "halfLife", "signals"],
60
+ "properties": {
61
+ "prior": {
62
+ "type": "number",
63
+ "exclusiveMinimum": 0,
64
+ "exclusiveMaximum": 1,
65
+ "description": "Prior probability of the intent, strictly between 0 and 1."
66
+ },
67
+ "priorStrength": {
68
+ "$ref": "#/$defs/bounded",
69
+ "description": "Strength of the prior as a pseudo-count."
70
+ },
71
+ "halfLife": {
72
+ "$ref": "#/$defs/duration",
73
+ "description": "Half-life of evidence. Evidence decays back toward the prior."
74
+ },
75
+ "signals": {
76
+ "type": "object",
77
+ "description": "Event name → initial weight.",
78
+ "propertyNames": { "$ref": "#/$defs/name" },
79
+ "additionalProperties": { "$ref": "#/$defs/weight" }
80
+ },
81
+ "outcome": {
82
+ "type": "string",
83
+ "minLength": 1,
84
+ "description": "Event name that confirms the intent happened, e.g. checkout.completed."
85
+ },
86
+ "resetOnOutcome": {
87
+ "type": "boolean",
88
+ "description": "Reset the evidence to the prior when the outcome arrives. Default true."
89
+ },
90
+ "saturate": {
91
+ "type": "boolean",
92
+ "description": "Repeats of a signal within one episode add less. Default: true when episodeTimeout is set, false otherwise."
93
+ },
94
+ "reveal": {
95
+ "$ref": "#/$defs/reveal",
96
+ "description": "Reveal defaults for this intent."
97
+ }
98
+ }
99
+ },
100
+ "reveal": {
101
+ "type": "object",
102
+ "additionalProperties": false,
103
+ "properties": {
104
+ "threshold": {
105
+ "type": "number",
106
+ "minimum": 0,
107
+ "maximum": 1,
108
+ "description": "Probability the intent must reach. Default 0.5."
109
+ },
110
+ "z": {
111
+ "type": "number",
112
+ "minimum": 0,
113
+ "description": "How many standard deviations below p must still clear the threshold. Default 1.28."
114
+ },
115
+ "cooldown": {
116
+ "type": "number",
117
+ "minimum": 0,
118
+ "description": "How long after a reveal or the outcome the intent stays quiet. Default: the intent's halfLife."
119
+ }
120
+ }
121
+ },
122
+ "learning": {
123
+ "type": "object",
124
+ "additionalProperties": false,
125
+ "properties": {
126
+ "halfLife": {
127
+ "$ref": "#/$defs/duration",
128
+ "description": "Half-life of learned hit/miss counts. Omit for no forgetting."
129
+ },
130
+ "gain": {
131
+ "$ref": "#/$defs/bounded",
132
+ "description": "A perfectly predictive signal converges to gain × |initial weight|. Default 2."
133
+ },
134
+ "priorEpisodes": {
135
+ "$ref": "#/$defs/bounded",
136
+ "description": "Pseudo-count behind the developer's initial weight: how many observed episodes it takes to weigh as much as the prior. Default 10."
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }