instar 1.3.445 → 1.3.447

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 (44) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +79 -22
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  5. package/dist/core/PostUpdateMigrator.js +14 -4
  6. package/dist/core/PostUpdateMigrator.js.map +1 -1
  7. package/dist/core/SessionManager.d.ts +1 -0
  8. package/dist/core/SessionManager.d.ts.map +1 -1
  9. package/dist/core/SessionManager.js +8 -0
  10. package/dist/core/SessionManager.js.map +1 -1
  11. package/dist/messaging/slack/SlackAdapter.d.ts +54 -2
  12. package/dist/messaging/slack/SlackAdapter.d.ts.map +1 -1
  13. package/dist/messaging/slack/SlackAdapter.js +88 -6
  14. package/dist/messaging/slack/SlackAdapter.js.map +1 -1
  15. package/dist/messaging/slack/types.d.ts +29 -0
  16. package/dist/messaging/slack/types.d.ts.map +1 -1
  17. package/dist/messaging/slack/types.js.map +1 -1
  18. package/dist/permissions/RelationshipAnomalyScorer.d.ts +123 -0
  19. package/dist/permissions/RelationshipAnomalyScorer.d.ts.map +1 -0
  20. package/dist/permissions/RelationshipAnomalyScorer.js +249 -0
  21. package/dist/permissions/RelationshipAnomalyScorer.js.map +1 -0
  22. package/dist/permissions/RelationshipBehaviorStore.d.ts +90 -0
  23. package/dist/permissions/RelationshipBehaviorStore.d.ts.map +1 -0
  24. package/dist/permissions/RelationshipBehaviorStore.js +156 -0
  25. package/dist/permissions/RelationshipBehaviorStore.js.map +1 -0
  26. package/dist/permissions/SlackPermissionObserver.d.ts +24 -0
  27. package/dist/permissions/SlackPermissionObserver.d.ts.map +1 -1
  28. package/dist/permissions/SlackPermissionObserver.js +35 -0
  29. package/dist/permissions/SlackPermissionObserver.js.map +1 -1
  30. package/dist/permissions/index.d.ts +2 -0
  31. package/dist/permissions/index.d.ts.map +1 -1
  32. package/dist/permissions/index.js +2 -0
  33. package/dist/permissions/index.js.map +1 -1
  34. package/dist/server/routes.d.ts.map +1 -1
  35. package/dist/server/routes.js +28 -2
  36. package/dist/server/routes.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/data/builtin-manifest.json +65 -65
  39. package/src/data/state-coherence-registry.json +12 -0
  40. package/src/templates/scripts/slack-reply.sh +26 -1
  41. package/upgrades/1.3.446.md +24 -0
  42. package/upgrades/1.3.447.md +27 -0
  43. package/upgrades/side-effects/slack-relationship-stepup.md +107 -0
  44. package/upgrades/side-effects/slack-thread-session.md +48 -0
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/messaging/slack/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAExD;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,cAAc,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,wCAAwC;IACxC,0BAA0B,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC/C,sDAAsD;IACtD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,8DAA8D;IAC9D,qBAAqB,CAAC,EAAE,MAAM,C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oB,EAAE,aAAa,CAAC,KAAK;IACzC,uBAAuB,EAAE,aAAa,CAAC,KAAK;IAC5C,oBAAoB,EAAE,aAAa,CAAC,KAAK;IACzC,oBAAoB,EAAE,aAAa,CAAC,KAAK;IACzC,uBAAuB,EAAE,aAAa,CAAC,KAAK;IAC5C,4BAA4B,EAAE,aAAa,CAAC,KAAK;IACjD,8BAA8B,EAAE,aAAa,CAAC,KAAK;IAEnD,oBAAoB;IACpB,WAAW,EAAE,aAAa,CAAC,KAAK;IAChC,YAAY,EAAE,aAAa,CAAC,KAAK;IACjC,YAAY,EAAE,aAAa,CAAC,KAAK;IACjC,uBAAuB,EAAE,aAAa,CAAC,KAAK;CAC7C,CAAC;AAEF,yEAAyE;AACzE,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC;AACxD,CAAC"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * RelationshipAnomalyScorer — the REAL relationship-aware second factor (Pillar 3,
3
+ * §7.2). It implements the existing `AnomalyScorer` interface (same slot the gate
4
+ * already consumes) and scores how far a request deviates from the principal's
5
+ * DETERMINISTIC behavioral baseline (RelationshipBehaviorStore), with a confidence.
6
+ *
7
+ * This is the production scorer that goes beyond the placeholder HeuristicAnomalyScorer:
8
+ * the Heuristic one reads a hand-injected baseline and only checks urgency + a single
9
+ * "never made this action" flag. This one reads a baseline built from real recorded
10
+ * history and composes FIVE deterministic, privacy-respecting SHAPE signals:
11
+ *
12
+ * 1. Out-of-character ACTION — this principal has an established repertoire but has
13
+ * never (or rarely) made this kind of request.
14
+ * 2. Tier ESCALATION — the request's tier is far above the principal's
15
+ * normal ceiling (they suddenly reach for the floor).
16
+ * 3. Off-CADENCE timing — the request arrives at an hour this principal almost
17
+ * never operates in.
18
+ * 4. Sudden URGENCY/pressure — urgency language from someone who is normally calm.
19
+ * 5. STYLE deviation — message length far outside their normal envelope
20
+ * (a coarse, content-free style fingerprint).
21
+ *
22
+ * ── Deny-by-default / conservative direction (documented choice) ────────────────
23
+ * Pillar 3 ships OBSERVE-ONLY (§7.6): a step-up is LOGGED, never live-challenged yet.
24
+ * The safe direction while observing is to AVOID FABRICATING step-ups: a no-baseline
25
+ * or thin-baseline principal scores LOW with LOW confidence, so we never invent a
26
+ * step-up we can't justify from history. Rationale: in observe mode an over-fire just
27
+ * pollutes the FP-rate measurement we're trying to take, and an under-fire is harmless
28
+ * (nothing is blocked). Once the FP rate is measured good and enforcement is enabled,
29
+ * the conservative-low-confidence stance is the right one too: a brand-new principal
30
+ * has no "out of character" because there is no "character" yet — flagging them as
31
+ * anomalous would be authority-by-suspicion, which the spec forbids (anomaly only
32
+ * RAISES the bar on a would-be-allowed floor action; it never invents one). The floor
33
+ * (RolePolicy) already protects the dangerous actions regardless of anomaly.
34
+ *
35
+ * ── Optional LLM style-check (fail-closed) ──────────────────────────────────────
36
+ * An LLM voice/style comparison MAY be added behind the established no-silent-
37
+ * degradation pattern (docs/specs/no-silent-degradation-to-brittle-fallback.md):
38
+ * the call is marked gating:true so the IntelligenceRouter provider-swaps on failure,
39
+ * and on ANY failure (no provider, throw, timeout, unparseable) we DO NOT widen — we
40
+ * simply omit the LLM's contribution and keep the deterministic score. The LLM can
41
+ * only ever ADD to the anomaly score (raise the bar), never lower it. It is OFF by
42
+ * default; the deterministic signals stand alone.
43
+ *
44
+ * Design: docs/specs/SLACK-ORG-INTEGRATION-SPEC.md §7.1–7.4, §7.6.
45
+ */
46
+ import type { Principal, RequestIntent, AnomalyAssessment } from './types.js';
47
+ import type { IntelligenceProvider } from '../core/types.js';
48
+ import { RelationshipBehaviorStore, type PrincipalBehaviorProfile } from './RelationshipBehaviorStore.js';
49
+ /** Tunable signal weights + thresholds. Defaults are conservative (lean toward NOT firing). */
50
+ export interface RelationshipAnomalyConfig {
51
+ /** Weight of the out-of-character-action signal. Default 0.45. */
52
+ atypicalActionWeight?: number;
53
+ /** Weight of the tier-escalation signal. Default 0.4. */
54
+ tierEscalationWeight?: number;
55
+ /** Weight of the off-cadence (unusual hour) signal. Default 0.2. */
56
+ offCadenceWeight?: number;
57
+ /** Weight of the sudden-urgency signal. Default 0.25. */
58
+ urgencyWeight?: number;
59
+ /** Weight of the style-deviation (length z-score) signal. Default 0.2. */
60
+ styleWeight?: number;
61
+ /**
62
+ * Minimum interaction count for a baseline to be "established" enough to make
63
+ * an out-of-character claim. Below this, action/style signals are suppressed
64
+ * (no character yet → no out-of-character). Default 5.
65
+ */
66
+ establishedMin?: number;
67
+ /**
68
+ * Share floor for the out-of-character-action signal (poisoning resistance).
69
+ * The signal fires when the requested action's SHARE of the principal's history is
70
+ * BELOW this (not only when never-seen) — so a patient attacker can't disable the
71
+ * highest-weight signal by seeding a single prior observation. Weight scales by how
72
+ * far below the floor the share sits (full at never-seen, →0 at the floor) so a
73
+ * genuinely-routine action never trips it. Default 0.10. (Phase-3 adversarial fix.)
74
+ */
75
+ rareActionShareFloor?: number;
76
+ /** Length z-score above which a message reads as style-deviant. Default 2.5. */
77
+ styleZThreshold?: number;
78
+ /** Hour fraction at/below which an arrival hour is "off-cadence". Default 0.02. */
79
+ offCadenceHourFraction?: number;
80
+ /** Now() for deterministic tests (drives hour-of-day). */
81
+ now?: () => Date;
82
+ /**
83
+ * Optional LLM style check (fail-closed). When provided, an out-of-style request
84
+ * may add to the anomaly score; any failure simply omits it (never widens).
85
+ */
86
+ intelligence?: IntelligenceProvider;
87
+ /** Enable the optional LLM style check. Default false (deterministic only). */
88
+ useLlmStyleCheck?: boolean;
89
+ /** LLM call timeout (ms). Default 6000. */
90
+ llmTimeoutMs?: number;
91
+ }
92
+ export declare class RelationshipAnomalyScorer {
93
+ private readonly store;
94
+ private readonly cfg;
95
+ constructor(store: RelationshipBehaviorStore, config?: RelationshipAnomalyConfig);
96
+ /**
97
+ * Score how out-of-character (principal, intent, text) is. Deterministic except
98
+ * for the OPTIONAL LLM style check (which only ever adds, and fails closed).
99
+ *
100
+ * Returns an `AnomalyAssessment` with a 0..1 score, reasons, and a `confidence`
101
+ * piggybacked onto the reasons via the score being suppressed under thin baselines.
102
+ * The gate consumes `score` against its `stepUpThreshold` and only ever RAISES a
103
+ * would-be-allowed floor action to step-up — never lowers any bar.
104
+ */
105
+ assess(principal: Principal, intent: RequestIntent, text: string): Promise<AnomalyAssessment>;
106
+ /**
107
+ * Pure deterministic scoring. Exposed via `assess`; broken out for unit testing.
108
+ * Returns the raw score, the contributing reasons, and a coarse confidence band
109
+ * derived from baseline depth.
110
+ */
111
+ deterministicScore(profile: PrincipalBehaviorProfile | undefined, intent: RequestIntent, text: string): {
112
+ score: number;
113
+ reasons: string[];
114
+ confidence: 'none' | 'low' | 'medium' | 'high';
115
+ };
116
+ /**
117
+ * Optional LLM style hit — fail-closed, add-only. Asks a fast model whether the
118
+ * message's VOICE matches a coarse description of the principal's normal style.
119
+ * On ANY failure or an unparseable / "matches" answer, returns null (no widening).
120
+ */
121
+ private llmStyleHit;
122
+ }
123
+ //# sourceMappingURL=RelationshipAnomalyScorer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelationshipAnomalyScorer.d.ts","sourceRoot":"","sources":["../../src/permissions/RelationshipAnomalyScorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EAIzB,KAAK,wBAAwB,EAC9B,MAAM,gCAAgC,CAAC;AAKxC,+FAA+F;AAC/F,MAAM,WAAW,yBAAyB;IACxC,kEAAkE;IAClE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yDAAyD;IACzD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,gBAAgB,CA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or (Pillar 3,
3
+ * §7.2). It implements the existing `AnomalyScorer` interface (same slot the gate
4
+ * already consumes) and scores how far a request deviates from the principal's
5
+ * DETERMINISTIC behavioral baseline (RelationshipBehaviorStore), with a confidence.
6
+ *
7
+ * This is the production scorer that goes beyond the placeholder HeuristicAnomalyScorer:
8
+ * the Heuristic one reads a hand-injected baseline and only checks urgency + a single
9
+ * "never made this action" flag. This one reads a baseline built from real recorded
10
+ * history and composes FIVE deterministic, privacy-respecting SHAPE signals:
11
+ *
12
+ * 1. Out-of-character ACTION — this principal has an established repertoire but has
13
+ * never (or rarely) made this kind of request.
14
+ * 2. Tier ESCALATION — the request's tier is far above the principal's
15
+ * normal ceiling (they suddenly reach for the floor).
16
+ * 3. Off-CADENCE timing — the request arrives at an hour this principal almost
17
+ * never operates in.
18
+ * 4. Sudden URGENCY/pressure — urgency language from someone who is normally calm.
19
+ * 5. STYLE deviation — message length far outside their normal envelope
20
+ * (a coarse, content-free style fingerprint).
21
+ *
22
+ * ── Deny-by-default / conservative direction (documented choice) ────────────────
23
+ * Pillar 3 ships OBSERVE-ONLY (§7.6): a step-up is LOGGED, never live-challenged yet.
24
+ * The safe direction while observing is to AVOID FABRICATING step-ups: a no-baseline
25
+ * or thin-baseline principal scores LOW with LOW confidence, so we never invent a
26
+ * step-up we can't justify from history. Rationale: in observe mode an over-fire just
27
+ * pollutes the FP-rate measurement we're trying to take, and an under-fire is harmless
28
+ * (nothing is blocked). Once the FP rate is measured good and enforcement is enabled,
29
+ * the conservative-low-confidence stance is the right one too: a brand-new principal
30
+ * has no "out of character" because there is no "character" yet — flagging them as
31
+ * anomalous would be authority-by-suspicion, which the spec forbids (anomaly only
32
+ * RAISES the bar on a would-be-allowed floor action; it never invents one). The floor
33
+ * (RolePolicy) already protects the dangerous actions regardless of anomaly.
34
+ *
35
+ * ── Optional LLM style-check (fail-closed) ──────────────────────────────────────
36
+ * An LLM voice/style comparison MAY be added behind the established no-silent-
37
+ * degradation pattern (docs/specs/no-silent-degradation-to-brittle-fallback.md):
38
+ * the call is marked gating:true so the IntelligenceRouter provider-swaps on failure,
39
+ * and on ANY failure (no provider, throw, timeout, unparseable) we DO NOT widen — we
40
+ * simply omit the LLM's contribution and keep the deterministic score. The LLM can
41
+ * only ever ADD to the anomaly score (raise the bar), never lower it. It is OFF by
42
+ * default; the deterministic signals stand alone.
43
+ *
44
+ * Design: docs/specs/SLACK-ORG-INTEGRATION-SPEC.md §7.1–7.4, §7.6.
45
+ */
46
+ import { meanLength, stdLength, hourFraction, } from './RelationshipBehaviorStore.js';
47
+ const URGENCY = /\b(urgent|urgently|asap|right now|immediately|before eod|by eod|end of day|emergency|hurry|quickly|can'?t wait)\b/i;
48
+ export class RelationshipAnomalyScorer {
49
+ store;
50
+ cfg;
51
+ constructor(store, config = {}) {
52
+ this.store = store;
53
+ this.cfg = {
54
+ atypicalActionWeight: config.atypicalActionWeight ?? 0.45,
55
+ tierEscalationWeight: config.tierEscalationWeight ?? 0.4,
56
+ offCadenceWeight: config.offCadenceWeight ?? 0.2,
57
+ urgencyWeight: config.urgencyWeight ?? 0.25,
58
+ styleWeight: config.styleWeight ?? 0.2,
59
+ establishedMin: config.establishedMin ?? 5,
60
+ rareActionShareFloor: config.rareActionShareFloor ?? 0.1,
61
+ styleZThreshold: config.styleZThreshold ?? 2.5,
62
+ offCadenceHourFraction: config.offCadenceHourFraction ?? 0.02,
63
+ now: config.now ?? (() => new Date()),
64
+ intelligence: config.intelligence,
65
+ useLlmStyleCheck: config.useLlmStyleCheck,
66
+ llmTimeoutMs: config.llmTimeoutMs,
67
+ };
68
+ }
69
+ /**
70
+ * Score how out-of-character (principal, intent, text) is. Deterministic except
71
+ * for the OPTIONAL LLM style check (which only ever adds, and fails closed).
72
+ *
73
+ * Returns an `AnomalyAssessment` with a 0..1 score, reasons, and a `confidence`
74
+ * piggybacked onto the reasons via the score being suppressed under thin baselines.
75
+ * The gate consumes `score` against its `stepUpThreshold` and only ever RAISES a
76
+ * would-be-allowed floor action to step-up — never lowers any bar.
77
+ */
78
+ async assess(principal, intent, text) {
79
+ const profile = this.store.profileFor(principal.slackUserId);
80
+ const { score, reasons, confidence } = this.deterministicScore(profile, intent, text);
81
+ // Optional LLM style check — fail-closed, ADD-ONLY. Skipped unless explicitly enabled
82
+ // AND we have an established baseline to compare against (no character → no check).
83
+ let finalScore = score;
84
+ const finalReasons = [...reasons];
85
+ if (this.cfg.useLlmStyleCheck &&
86
+ this.cfg.intelligence &&
87
+ profile &&
88
+ profile.interactionCount >= this.cfg.establishedMin) {
89
+ const llm = await this.llmStyleHit(profile, text);
90
+ if (llm) {
91
+ finalScore = Math.min(1, finalScore + llm.weight);
92
+ finalReasons.push(llm.reason);
93
+ }
94
+ }
95
+ return {
96
+ score: clamp01(finalScore),
97
+ reasons: confidence === 'none'
98
+ ? [] // no baseline → no defensible anomaly reason; stays low + silent
99
+ : finalReasons,
100
+ };
101
+ }
102
+ /**
103
+ * Pure deterministic scoring. Exposed via `assess`; broken out for unit testing.
104
+ * Returns the raw score, the contributing reasons, and a coarse confidence band
105
+ * derived from baseline depth.
106
+ */
107
+ deterministicScore(profile, intent, text) {
108
+ const isUrgent = URGENCY.test(text || '');
109
+ // ── No baseline / new principal → conservative: LOW anomaly, no step-up fabrication ──
110
+ if (!profile || profile.interactionCount <= 0) {
111
+ return { score: 0, reasons: [], confidence: 'none' };
112
+ }
113
+ const established = profile.interactionCount >= this.cfg.establishedMin;
114
+ const confidence = !established
115
+ ? 'low'
116
+ : profile.interactionCount >= this.cfg.establishedMin * 4
117
+ ? 'high'
118
+ : 'medium';
119
+ const hits = [];
120
+ // ── 1. Out-of-character ACTION (only when the baseline is established) ──
121
+ if (established) {
122
+ const seen = profile.actionCounts[intent.action] ?? 0;
123
+ const total = profile.interactionCount || 1;
124
+ const share = seen / total;
125
+ const floor = this.cfg.rareActionShareFloor;
126
+ // Poisoning resistance (Phase-3 adversarial fix): fire when the action is RARE
127
+ // (share below the floor), not only when never-seen. A patient attacker / slowly-
128
+ // compromised account can seed a single prior observation to zero out a `seen===0`
129
+ // check and permanently disable this highest-weight signal; a share floor keeps a
130
+ // rare-but-poisoned action flagged. Weight scales by how far below the floor the
131
+ // share sits (full at never-seen, →0 as share→floor) so a genuinely-routine action
132
+ // never trips it.
133
+ if (share < floor) {
134
+ const rarity = 1 - share / floor; // 1.0 when never seen; →0 as share→floor
135
+ hits.push({
136
+ weight: this.cfg.atypicalActionWeight * rarity,
137
+ reason: seen === 0
138
+ ? `out-of-character: established history (${profile.interactionCount} interactions) but never requested "${intent.action}"`
139
+ : `out-of-character: "${intent.action}" is rare for this principal (${seen}/${profile.interactionCount} ≈ ${Math.round(share * 100)}%, below the ${Math.round(floor * 100)}% floor)`,
140
+ });
141
+ }
142
+ }
143
+ // ── 2. Tier ESCALATION — request tier far above the principal's normal ceiling ──
144
+ if (established) {
145
+ const normalMaxTier = highestRoutineTier(profile);
146
+ if (intent.tier >= 4 && normalMaxTier <= 2) {
147
+ hits.push({
148
+ weight: this.cfg.tierEscalationWeight,
149
+ reason: `tier escalation: reaching a floor action (T${intent.tier}) when this principal normally tops out at T${normalMaxTier}`,
150
+ });
151
+ }
152
+ }
153
+ // ── 3. Off-CADENCE timing — arrival hour this principal almost never uses ──
154
+ if (established) {
155
+ const hour = this.cfg.now().getHours();
156
+ if (hourFraction(profile, hour) <= this.cfg.offCadenceHourFraction) {
157
+ hits.push({
158
+ weight: this.cfg.offCadenceWeight,
159
+ reason: `off-cadence: request at ${pad2(hour)}:00, an hour this principal almost never operates in`,
160
+ });
161
+ }
162
+ }
163
+ // ── 4. Sudden URGENCY/pressure from someone normally calm ──
164
+ if (isUrgent) {
165
+ const baselineUrgentRate = profile.interactionCount > 0 ? profile.urgentCount / profile.interactionCount : 0;
166
+ if (baselineUrgentRate <= 0.15) {
167
+ hits.push({
168
+ weight: this.cfg.urgencyWeight,
169
+ reason: 'sudden urgency/pressure language from a normally-calm principal',
170
+ });
171
+ }
172
+ }
173
+ // ── 5. STYLE deviation — message length far outside the normal envelope ──
174
+ if (established) {
175
+ const mean = meanLength(profile);
176
+ const std = stdLength(profile);
177
+ if (mean !== undefined && std !== undefined && std > 0) {
178
+ const z = Math.abs(((text || '').length - mean) / std);
179
+ if (z >= this.cfg.styleZThreshold) {
180
+ hits.push({
181
+ weight: this.cfg.styleWeight,
182
+ reason: `style deviation: message length is ${z.toFixed(1)}σ from this principal's norm`,
183
+ });
184
+ }
185
+ }
186
+ }
187
+ const score = clamp01(hits.reduce((s, h) => s + h.weight, 0));
188
+ return { score, reasons: hits.map((h) => h.reason), confidence };
189
+ }
190
+ /**
191
+ * Optional LLM style hit — fail-closed, add-only. Asks a fast model whether the
192
+ * message's VOICE matches a coarse description of the principal's normal style.
193
+ * On ANY failure or an unparseable / "matches" answer, returns null (no widening).
194
+ */
195
+ async llmStyleHit(profile, text) {
196
+ const intel = this.cfg.intelligence;
197
+ if (!intel)
198
+ return null; // no provider → fail closed (no contribution)
199
+ try {
200
+ const mean = meanLength(profile);
201
+ const topActions = Object.entries(profile.actionCounts)
202
+ .sort((a, b) => b[1] - a[1])
203
+ .slice(0, 5)
204
+ .map(([a]) => a)
205
+ .join(', ');
206
+ const prompt = 'You compare whether a new message matches a person\'s established style. ' +
207
+ 'Reply with ONLY one word: MATCH or MISMATCH.\n\n' +
208
+ `Established style summary: typical request types are [${topActions}]; ` +
209
+ `typical message length ~${mean !== undefined ? Math.round(mean) : 'unknown'} chars; ` +
210
+ `${profile.interactionCount} prior interactions.\n` +
211
+ `New message: ${JSON.stringify((text || '').slice(0, 500))}\n\n` +
212
+ 'Does the new message clearly MISMATCH this person\'s established style?';
213
+ const raw = await intel.evaluate(prompt, {
214
+ model: 'fast',
215
+ maxTokens: 8,
216
+ temperature: 0,
217
+ timeoutMs: this.cfg.llmTimeoutMs ?? 6000,
218
+ attribution: { component: 'RelationshipAnomalyScorer', category: 'gate', gating: true },
219
+ });
220
+ const verdict = (raw || '').trim().toUpperCase();
221
+ // Only a CLEAR mismatch adds. Anything else (MATCH, empty, unparseable) → no contribution.
222
+ if (verdict.startsWith('MISMATCH')) {
223
+ return { weight: this.cfg.styleWeight, reason: 'LLM style check: message voice does not match this principal' };
224
+ }
225
+ return null;
226
+ }
227
+ catch {
228
+ // No-silent-degradation: a style-check failure NEVER widens. We simply omit it.
229
+ return null;
230
+ }
231
+ }
232
+ }
233
+ /** The highest tier this principal has used in more than a trivial share of interactions. */
234
+ function highestRoutineTier(profile) {
235
+ let max = 0;
236
+ for (let t = 0; t <= 4; t++) {
237
+ const c = profile.tierCounts[t] ?? 0;
238
+ if (c > 0 && c / profile.interactionCount > 0.02)
239
+ max = t;
240
+ }
241
+ return max;
242
+ }
243
+ function clamp01(x) {
244
+ return Math.max(0, Math.min(1, x));
245
+ }
246
+ function pad2(n) {
247
+ return n < 10 ? `0${n}` : String(n);
248
+ }
249
+ //# sourceMappingURL=RelationshipAnomalyScorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelationshipAnomalyScorer.js","sourceRoot":"","sources":["../../src/permissions/RelationshipAnomalyScorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAIH,OAAO,EAEL,UAAU,EACV,SAAS,EACT,YAAY,GAEb,MAAM,gCAAgC,CAAC;AAExC,MAAM,OAAO,GACX,oHAAoH,CAAC;AAoDvH,MAAM,OAAO,yBAAyB;IACnB,KAAK,CAA4B;IACjC,GAAG,CAEsE;IAE1F,YAAY,KAAgC,EAAE,SAAoC,EAAE;QAClF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG;YACT,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,IAAI,IAAI;YACzD,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,IAAI,GAAG;YACxD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,GAAG;YAChD,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,IAAI;YAC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I;YAAE,GAAG,GAAG,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * RelationshipBehaviorStore — the durable, deterministic behavioral baseline per
3
+ * principal (Pillar 3, §7.1). This is the substrate the RelationshipAnomalyScorer
4
+ * reads to answer "does this request feel like THEM?".
5
+ *
6
+ * Why a dedicated store (vs reusing RelationshipManager):
7
+ * RelationshipManager is generic, cross-platform relationship memory (themes,
8
+ * notes, a free-text communicationStyle). It has no structured per-request history
9
+ * — no action-tier histogram, no time-of-day distribution, no message-shape stats
10
+ * — which is exactly what a CHEAP, DETERMINISTIC anomaly baseline needs. Rather
11
+ * than retrofit privacy-sensitive structured tracking onto the generic manager,
12
+ * this module keeps a small, Slack-permission-scoped, privacy-respecting baseline:
13
+ * SHAPE only (which action labels, what tier, what hour, how long the message was),
14
+ * NEVER message content. The seam mirrors the rest of the permissions module — it
15
+ * depends on nothing in core; the gate/observer inject it.
16
+ *
17
+ * Privacy: we store action LABELS, tier counts, hour-of-day counts, and coarse
18
+ * message-length stats. We do NOT store message text, topics, or any free text.
19
+ *
20
+ * State category: `slack-relationship-baselines` (state-coherence-registry.json).
21
+ * Design: docs/specs/SLACK-ORG-INTEGRATION-SPEC.md §7.1–7.2, §7.6.
22
+ */
23
+ /** A single recorded interaction's SHAPE (never content). */
24
+ export interface BehaviorObservation {
25
+ /** Action label from the intent classifier (e.g. 'read', 'prod-deploy'). */
26
+ action: string;
27
+ /** Sensitivity tier 0..4. */
28
+ tier: number;
29
+ /** Local hour-of-day 0..23 the request arrived. */
30
+ hour: number;
31
+ /** Message length in characters (coarse style signal). */
32
+ length: number;
33
+ /** Whether the message carried urgency/pressure language (cheap style signal). */
34
+ urgent: boolean;
35
+ }
36
+ /**
37
+ * The aggregated, privacy-respecting baseline for one principal. All counts; no
38
+ * content. Persisted as JSON; cheap to read and update.
39
+ */
40
+ export interface PrincipalBehaviorProfile {
41
+ slackUserId: string;
42
+ /** Total observations recorded — the DEPTH of the baseline (drives confidence). */
43
+ interactionCount: number;
44
+ /** Count per action label — the principal's normal repertoire. */
45
+ actionCounts: Record<string, number>;
46
+ /** Count per sensitivity tier (index 0..4). */
47
+ tierCounts: number[];
48
+ /** Count per local hour-of-day (index 0..23) — the principal's normal rhythm. */
49
+ hourCounts: number[];
50
+ /** Running mean + count of message length, for a coarse style baseline (Welford-free, count-weighted). */
51
+ lengthSum: number;
52
+ lengthSqSum: number;
53
+ /** How often this principal uses urgency language at baseline (0..1 derived from count). */
54
+ urgentCount: number;
55
+ /** First / last observation ISO timestamps. */
56
+ firstSeen: string;
57
+ lastSeen: string;
58
+ }
59
+ export declare class RelationshipBehaviorStore {
60
+ private readonly file;
61
+ private readonly now;
62
+ constructor(stateDir: string, now?: () => string);
63
+ get path(): string;
64
+ /**
65
+ * Record an observation for a principal, growing their baseline. Best-effort:
66
+ * a write failure is swallowed (this is observe-only infra; it must never break
67
+ * the message path). No-op for an unsafe key (defensive).
68
+ */
69
+ record(slackUserId: string, obs: BehaviorObservation): void;
70
+ /** The current baseline for a principal, or undefined if none recorded yet. */
71
+ profileFor(slackUserId: string | undefined): PrincipalBehaviorProfile | undefined;
72
+ /** All profiles (for the read route / inspection). */
73
+ all(): Record<string, PrincipalBehaviorProfile>;
74
+ private readAll;
75
+ private writeAll;
76
+ }
77
+ /** Mean message length, or undefined when there is no data. */
78
+ export declare function meanLength(prof: PrincipalBehaviorProfile): number | undefined;
79
+ /** Population standard deviation of message length, or undefined when <2 samples. */
80
+ export declare function stdLength(prof: PrincipalBehaviorProfile): number | undefined;
81
+ /** Fraction of baseline interactions in a given hour (0..1). */
82
+ export declare function hourFraction(prof: PrincipalBehaviorProfile, hour: number): number;
83
+ import type { BaselineProvider, PrincipalBaseline } from './AnomalyScorer.js';
84
+ import type { Principal } from './types.js';
85
+ export declare class StoreBaselineProvider implements BaselineProvider {
86
+ private readonly store;
87
+ constructor(store: RelationshipBehaviorStore);
88
+ baselineFor(principal: Principal): PrincipalBaseline | undefined;
89
+ }
90
+ //# sourceMappingURL=RelationshipBehaviorStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelationshipBehaviorStore.d.ts","sourceRoot":"","sources":["../../src/permissions/RelationshipBehaviorStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,6DAA6D;AAC7D,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,gBAAgB,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,+CAA+C;IAC/C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iFAAiF;IACjF,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,0GAA0G;IAC1G,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+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