instar 1.3.354 → 1.3.356

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.
@@ -1 +1 @@
1
- {"version":3,"file":"QuotaExhaustionDetector.d.ts","sourceRoot":"","sources":["../../src/monitoring/QuotaExhaustionDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAqB,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAiElG;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,GAC7B,0BAA0B,CAkE5B;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAkBvI;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAc/E"}
1
+ {"version":3,"file":"QuotaExhaustionDetector.d.ts","sourceRoot":"","sources":["../../src/monitoring/QuotaExhaustionDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAqB,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAiElG;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,GAC7B,0BAA0B,CAkE5B;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAwCvI;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAc/E"}
@@ -150,8 +150,30 @@ export function detectContextExhaustion(tmuxOutput) {
150
150
  if (!match) {
151
151
  return { matched: false, pattern: null, confidence: 'medium' };
152
152
  }
153
- const strongSignals = ['conversation too long', 'conversation is too long', 'error during compaction'];
154
- const isStrong = strongSignals.some(s => output.includes(s));
153
+ // FALSE-POSITIVE GUARD (RUN-2 2026-06-06, topic 13435 flood). The bare phrase
154
+ // "conversation (is) too long" appears as ordinary CONTENT whenever a session
155
+ // discusses the conversation-too-long failure mode — an autonomous session
156
+ // working ON that feature, a quoted error, or the recovery NOTICE this very
157
+ // detector triggers ("Session hit \"conversation too long\" …"), which re-enters
158
+ // the pane and self-amplifies one false positive into a flood. A REAL Claude
159
+ // Code exhaustion error always renders WITH its CLI recovery framing — the
160
+ // "press esc twice …" hint or an "error during compaction" line (see the
161
+ // realistic fixture in the unit tests). Require that framing: the bare phrase,
162
+ // alone, is content, not a live CLI error.
163
+ const bareExhaustionPhrases = ['conversation too long', 'conversation is too long'];
164
+ // Both wordings of the CLI recovery hint ("esc"/"escape"), kept anchored on
165
+ // "twice" so it matches the real too-long prompt but not an unrelated
166
+ // "press escape to stop" working-indicator line.
167
+ const cliErrorFrames = ['press esc twice', 'press escape twice', 'error during compaction'];
168
+ const hasBarePhrase = bareExhaustionPhrases.some(s => output.includes(s));
169
+ const hasCliFrame = cliErrorFrames.some(s => output.includes(s));
170
+ if (hasBarePhrase && !hasCliFrame) {
171
+ // Phrase present only as content/narration — not the framed CLI error. (A
172
+ // non-phrase soft signal like "context limit" is unaffected: hasBarePhrase
173
+ // is false, so this guard does not apply and existing behavior is preserved.)
174
+ return { matched: false, pattern: null, confidence: 'medium' };
175
+ }
176
+ const isStrong = hasBarePhrase || output.includes('error during compaction');
155
177
  return { matched: true, pattern: match, confidence: isStrong ? 'high' : 'medium' };
156
178
  }
157
179
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"QuotaExhaustionDetector.js","sourceRoot":"","sources":["../../src/monitoring/QuotaExhaustionDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,oCAAoC;AACpC,MAAM,cAAc,GAAG;IACrB,kBAAkB;IAClB,YAAY;IACZ,KAAK;IACL,iBAAiB;IACjB,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,UAAU;IACV,SAAS;IACT,qBAAqB;CACtB,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;IACf,uBAAuB;IACvB,kBAAkB;IAClB,0BAA0B;IAC1B,uBAAuB;IACvB,mCAAmC;IACnC,yCAAyC;CAC1C,CAAC;AAEF,MAAM,oCAAoC,GAAG;IAC3C,wBAAwB;IACxB,+BAA+B;IAC/B,6BAA6B;IAC7B,oCAAoC;IACpC,kCAAkC;IAClC,qBAAqB;CACtB,CAAC;AAEF,MAAM,oCAAoC,GAAG;IAC3C,uBAAuB;IACvB,0BAA0B;IAC1B,yBAAyB;IACzB,yCAAyC;CAC1C,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,SAAS;IACT,SAAS;IACT,aAAa;IACb,sBAAsB;IACtB,QAAQ;IACR,gBAAgB;IAChB,eAAe;IACf,WAAW;CACZ,CAAC;AAEF,MAAM,oBAAoB,GAAG;IAC3B,eAAe;IACf,UAAU;IACV,oBAAoB;IACpB,WAAW;IACX,GAAG;IACH,gBAAgB;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,UAA8B;IAE9B,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,EAAE,KAAK,EAAE,SAAS,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IAAI,CAAC;YACH,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1C,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,uDAAuD;YACvD,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBAC3C,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.354",
3
+ "version": "1.3.356",
4
4
  "description": "Coherence infrastructure for self-evolving AI agents — on the Claude Code or Codex subscription you already have.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-06-06T07:43:24.044Z",
5
- "instarVersion": "1.3.354",
4
+ "generatedAt": "2026-06-06T08:09:49.249Z",
5
+ "instarVersion": "1.3.356",
6
6
  "entryCount": 199,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -11,7 +11,7 @@
11
11
  "domain": "identity",
12
12
  "sourcePath": "src/core/PostUpdateMigrator.ts",
13
13
  "installedPath": ".instar/hooks/instar/session-start.sh",
14
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
14
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
15
15
  "since": "2025-01-01"
16
16
  },
17
17
  "hook:dangerous-command-guard": {
@@ -20,7 +20,7 @@
20
20
  "domain": "safety",
21
21
  "sourcePath": "src/core/PostUpdateMigrator.ts",
22
22
  "installedPath": ".instar/hooks/instar/dangerous-command-guard.sh",
23
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
23
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
24
24
  "since": "2025-01-01"
25
25
  },
26
26
  "hook:grounding-before-messaging": {
@@ -29,7 +29,7 @@
29
29
  "domain": "safety",
30
30
  "sourcePath": "src/core/PostUpdateMigrator.ts",
31
31
  "installedPath": ".instar/hooks/instar/grounding-before-messaging.sh",
32
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
32
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
33
33
  "since": "2025-01-01"
34
34
  },
35
35
  "hook:compaction-recovery": {
@@ -38,7 +38,7 @@
38
38
  "domain": "identity",
39
39
  "sourcePath": "src/core/PostUpdateMigrator.ts",
40
40
  "installedPath": ".instar/hooks/instar/compaction-recovery.sh",
41
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
41
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
42
42
  "since": "2025-01-01"
43
43
  },
44
44
  "hook:external-operation-gate": {
@@ -47,7 +47,7 @@
47
47
  "domain": "safety",
48
48
  "sourcePath": "src/core/PostUpdateMigrator.ts",
49
49
  "installedPath": ".instar/hooks/instar/external-operation-gate.js",
50
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
50
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
51
51
  "since": "2025-01-01"
52
52
  },
53
53
  "hook:deferral-detector": {
@@ -56,7 +56,7 @@
56
56
  "domain": "safety",
57
57
  "sourcePath": "src/core/PostUpdateMigrator.ts",
58
58
  "installedPath": ".instar/hooks/instar/deferral-detector.js",
59
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
59
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
60
60
  "since": "2025-01-01"
61
61
  },
62
62
  "hook:self-stop-guard": {
@@ -65,7 +65,7 @@
65
65
  "domain": "coherence",
66
66
  "sourcePath": "src/core/PostUpdateMigrator.ts",
67
67
  "installedPath": ".instar/hooks/instar/self-stop-guard.js",
68
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
68
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
69
69
  "since": "2025-01-01"
70
70
  },
71
71
  "hook:post-action-reflection": {
@@ -74,7 +74,7 @@
74
74
  "domain": "evolution",
75
75
  "sourcePath": "src/core/PostUpdateMigrator.ts",
76
76
  "installedPath": ".instar/hooks/instar/post-action-reflection.js",
77
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
77
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
78
78
  "since": "2025-01-01"
79
79
  },
80
80
  "hook:external-communication-guard": {
@@ -83,7 +83,7 @@
83
83
  "domain": "safety",
84
84
  "sourcePath": "src/core/PostUpdateMigrator.ts",
85
85
  "installedPath": ".instar/hooks/instar/external-communication-guard.js",
86
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
86
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
87
87
  "since": "2025-01-01"
88
88
  },
89
89
  "hook:scope-coherence-collector": {
@@ -92,7 +92,7 @@
92
92
  "domain": "coherence",
93
93
  "sourcePath": "src/core/PostUpdateMigrator.ts",
94
94
  "installedPath": ".instar/hooks/instar/scope-coherence-collector.js",
95
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
95
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
96
96
  "since": "2025-01-01"
97
97
  },
98
98
  "hook:scope-coherence-checkpoint": {
@@ -101,7 +101,7 @@
101
101
  "domain": "coherence",
102
102
  "sourcePath": "src/core/PostUpdateMigrator.ts",
103
103
  "installedPath": ".instar/hooks/instar/scope-coherence-checkpoint.js",
104
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
104
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
105
105
  "since": "2025-01-01"
106
106
  },
107
107
  "hook:free-text-guard": {
@@ -110,7 +110,7 @@
110
110
  "domain": "safety",
111
111
  "sourcePath": "src/core/PostUpdateMigrator.ts",
112
112
  "installedPath": ".instar/hooks/instar/free-text-guard.sh",
113
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
113
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
114
114
  "since": "2025-01-01"
115
115
  },
116
116
  "hook:claim-intercept": {
@@ -119,7 +119,7 @@
119
119
  "domain": "coherence",
120
120
  "sourcePath": "src/core/PostUpdateMigrator.ts",
121
121
  "installedPath": ".instar/hooks/instar/claim-intercept.js",
122
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
122
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
123
123
  "since": "2025-01-01"
124
124
  },
125
125
  "hook:claim-intercept-response": {
@@ -128,7 +128,7 @@
128
128
  "domain": "coherence",
129
129
  "sourcePath": "src/core/PostUpdateMigrator.ts",
130
130
  "installedPath": ".instar/hooks/instar/claim-intercept-response.js",
131
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
131
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
132
132
  "since": "2025-01-01"
133
133
  },
134
134
  "hook:stop-gate-router": {
@@ -137,7 +137,7 @@
137
137
  "domain": "safety",
138
138
  "sourcePath": "src/core/PostUpdateMigrator.ts",
139
139
  "installedPath": ".instar/hooks/instar/stop-gate-router.js",
140
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
140
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
141
141
  "since": "2025-01-01"
142
142
  },
143
143
  "hook:auto-approve-permissions": {
@@ -146,7 +146,7 @@
146
146
  "domain": "safety",
147
147
  "sourcePath": "src/core/PostUpdateMigrator.ts",
148
148
  "installedPath": ".instar/hooks/instar/auto-approve-permissions.js",
149
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
149
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
150
150
  "since": "2025-01-01"
151
151
  },
152
152
  "job:health-check": {
@@ -1538,7 +1538,7 @@
1538
1538
  "type": "subsystem",
1539
1539
  "domain": "updates",
1540
1540
  "sourcePath": "src/core/PostUpdateMigrator.ts",
1541
- "contentHash": "aa88c10ba4816114371a58fa15df8d18a92580fbb861c2c3007cab4a85d5e4d2",
1541
+ "contentHash": "b8227d4a75bfe3ca1a9d0fee53580167a5dbc4e67fe458af11ae66aed1a1d0a0",
1542
1542
  "since": "2025-01-01"
1543
1543
  },
1544
1544
  "subsystem:scheduler": {
@@ -0,0 +1,45 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ Fixed a false-positive in context-exhaustion detection that could flood a topic with
9
+ duplicate "conversation too long" notices. The detector (`detectContextExhaustion`)
10
+ matched the bare phrase "conversation too long" anywhere in a session's terminal
11
+ output, with no check that it was an actual CLI error versus ordinary content. A
12
+ session that merely discussed the failure mode — or the recovery notice the detector
13
+ itself emits ("Session hit 'conversation too long'…") — re-tripped detection, and
14
+ because the notice text re-enters the pane, one false positive amplified into a flood
15
+ of duplicate notices and spurious respawns on a perfectly healthy session.
16
+
17
+ The detector now requires the real CLI error framing — the "Press esc twice…" hint or
18
+ an "error during compaction" line — for the bare phrase to count. The bare phrase
19
+ alone is treated as content. Real exhaustion errors always carry that framing, so
20
+ genuine recovery is unaffected; the self-amplifying flood and the content
21
+ false-positive are both eliminated.
22
+
23
+ ## What to Tell Your User
24
+
25
+ If you ever saw a burst of repeated "conversation too long" messages while your
26
+ session was actually working fine, that was a false alarm — now fixed. Real
27
+ out-of-room recovery still works exactly as before. Nothing for you to do.
28
+
29
+ ## Summary of New Capabilities
30
+
31
+ - Context-exhaustion detection no longer fires on the phrase appearing as content or
32
+ in its own recovery notice — it requires the real CLI error framing.
33
+ - Eliminates the self-amplifying "conversation too long" notice flood.
34
+ - No behavior change for genuine context-exhaustion recovery.
35
+
36
+ ## Evidence
37
+
38
+ - Unit (`tests/unit/context-exhaustion-recovery.test.ts`): real framed error detected;
39
+ bare phrase rejected; recovery-notice text rejected; agent narration rejected; a
40
+ mixed pane (narration + real framed error) still detected. 31 passing.
41
+ - Unit (`tests/unit/presence-proxy-context-exhaustion.test.ts`): standby detection on
42
+ realistic framed snapshots; non-error content not detected. 14 passing.
43
+ - SessionRecovery recovery-behavior tests updated to realistic framed fixtures and
44
+ still green (recovery still triggers on real exhaustion).
45
+ - Full typecheck clean.
@@ -0,0 +1,38 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ The `session-start` hook now injects the verified `<topic-operator>` block at
9
+ session boot (Know Your Principal standard, security-build increment 2c). It
10
+ fetches `/topic-operator/session-context?topicId=$INSTAR_TELEGRAM_TOPIC` (the route
11
+ shipped in #906) and, when the topic has a verified operator, hands the agent a
12
+ short block naming that operator — so the agent reasons with its authenticated
13
+ principal from message one. This is the READ side of the operator binding; it
14
+ cannot itself seat anyone (the store established the operator only from the
15
+ platform-verified sender).
16
+
17
+ ## What to Tell Your User
18
+
19
+ Nothing user-facing changes. Foundation wiring (experimental) for the Caroline
20
+ identity-bleed security fix: the agent now SEES its verified operator at session
21
+ start when one is bound, but no conversational behavior changes and nothing is
22
+ gated. Auto-binding on inbound and the cross-principal guard are later increments.
23
+
24
+ ## Summary of New Capabilities
25
+
26
+ - Session-start injection of the `<topic-operator>` block (fail-open: no topic /
27
+ unbound topic / store unavailable → nothing injected). Reaches existing agents
28
+ automatically — the `instar/` session-start hook is rewritten on every update.
29
+
30
+ ## Evidence
31
+
32
+ Verified by 3 Tier-3 E2E lifecycle tests
33
+ (`tests/e2e/topic-operator-hook-injection-lifecycle.test.ts`): Phase 1 asserts the
34
+ generated hook source wires the fetch; Phase 2 extracts the exact block and runs
35
+ it against a live server, proving it emits the `<topic-operator>` block when a
36
+ topic is bound and nothing when unbound. The analog hook suites
37
+ (PostUpdateMigrator-bootSelfKnowledge, migration-parity-hooks,
38
+ OrgIntentManager-session-start-format) stay green. Clean `tsc --noEmit`.
@@ -0,0 +1,62 @@
1
+ # Side-effects review — context-exhaustion false-positive fix
2
+
3
+ **Change:** `detectContextExhaustion` (QuotaExhaustionDetector) now requires the
4
+ real CLI error framing ("press esc twice" or "error during compaction") for the
5
+ bare "conversation (is) too long" phrase. The bare phrase as content no longer
6
+ matches.
7
+
8
+ **Signal vs authority (Phase 1):** This IS a decision point — the detector's verdict
9
+ gates a destructive action (SessionMonitor kills + respawns the session and notifies
10
+ the user). It is a SIGNAL feeding the SessionMonitor authority; this change makes the
11
+ signal correct, it does not add or move authority. The fix narrows a brittle
12
+ substring match that was producing false positives with blocking-equivalent
13
+ consequences (forced respawns + user notices) — exactly the "brittle check with
14
+ real-world authority" failure `docs/signal-vs-authority.md` warns about.
15
+
16
+ 1. **Over-block (false positive — the bug):** FIXED. Before, the bare phrase as
17
+ content (a session discussing the failure mode, a quoted error, or the recovery
18
+ notice itself) was flagged as live exhaustion → spurious respawn + user notice,
19
+ self-amplifying into a flood (RUN-2 2026-06-06, topic 13435, ~27 notices on a
20
+ healthy session). Now the bare phrase without CLI framing is not matched.
21
+
22
+ 2. **Under-block (could a REAL error now be missed?):** No real loss. Every
23
+ realistic exhaustion fixture in the unit tests carries the CLI framing ("press
24
+ esc twice" and/or "error during compaction") — that is how Claude Code actually
25
+ renders the error. The guard only removes matches that lack any framing, which
26
+ are content, not live errors. Residual: if a future Claude Code version renders
27
+ the error WITHOUT the esc hint or compaction line, it would be missed — the frame
28
+ list is a one-line extension and is documented as the tuning point.
29
+
30
+ 3. **Level-of-abstraction fit:** Correct layer. The fix is in the detector (the pure
31
+ function that decides), not in SessionMonitor (the actor). One change fixes every
32
+ consumer (SessionMonitor, PresenceProxy standby). The soft, non-phrase patterns
33
+ (context limit, token limit) are deliberately left unchanged — they are not the
34
+ observed bug and gating them risks under-detection; scoped to the live bug, not
35
+ a hypothetical.
36
+
37
+ 4. **Signal vs authority compliance:** Compliant. Detector stays a signal; the fix
38
+ reduces its false-positive rate without changing where authority lives.
39
+
40
+ 5. **Interactions:** The same `detectContextExhaustion` feeds SessionMonitor's
41
+ proactive check and PresenceProxy. Both now benefit. The self-amplification path
42
+ (recovery notice → pane → re-detect) is closed because the notice lacks CLI
43
+ framing. classifySessionDeath (the POST-death classifier) shares the bare-phrase
44
+ pattern but runs on a dead session's final output where the flood/respawn harm
45
+ does not apply; left as-is to keep this fix scoped to the live false-positive
46
+ (noted as a known sibling, not a deferral of THIS bug).
47
+
48
+ 6. **External surfaces:** Reduces user-facing noise (fewer false "conversation too
49
+ long" notices). No API/schema change. Behavior depends on tmux pane content,
50
+ which is what it already read; no new timing/runtime dependence.
51
+
52
+ 7. **Rollback cost:** Trivial — revert the commit. Pure-function change, no data
53
+ migration, no state. Worst case on revert is the original false-positive returns.
54
+
55
+ **Tier:** 1 (a guard added to one pure function + realistic test fixtures; no route,
56
+ no migration, no persistent state). No CLAUDE.md template change: this is an internal
57
+ detector hardening, not a new agent-invocable capability.
58
+
59
+ **No deferrals:** the fix is complete — detector guard + both-sides unit coverage
60
+ (real-error-detected, bare-phrase-rejected, recovery-notice-rejected, narration-
61
+ rejected, mixed-pane-still-detected) + updated realistic fixtures. classifySessionDeath
62
+ is a distinct surface (post-death), not a withheld part of this fix.
@@ -0,0 +1,79 @@
1
+ # Side-effects review — Topic Operator session-start injection (Know Your Principal #898, increment 2c)
2
+
3
+ ## What this change does
4
+ Adds one fetch-block to the generated `session-start` hook
5
+ (`PostUpdateMigrator.getHookContent('session-start')`) that injects the
6
+ `<topic-operator>` block at session boot — the READ side of the operator binding
7
+ shipped in #904 (store) and #906 (routes). When a topic has a verified operator,
8
+ the agent now reasons with it from message one.
9
+
10
+ ## Blast radius
11
+ - **One template string edit, additive.** The block is appended after the
12
+ existing ORG-INTENT and AUTO-LEARNED-PREFERENCES injection blocks and before the
13
+ SESSION-BOOT-SELF-KNOWLEDGE block — modeled byte-for-byte on those two
14
+ precedents (same `curl -sf --max-time 4` + `python3` present/block parse + echo).
15
+ - **Fail-open, three guards.** The block only runs when `$INSTAR_TELEGRAM_TOPIC`
16
+ AND `$PORT` AND `$TOKEN` are all set. `curl -sf` emits nothing on any non-2xx
17
+ (route 503 when the store is unavailable, or `{present:false}` for an unbound
18
+ topic), so an unbound topic or an old server injects nothing — the session
19
+ continues normally. A non-Telegram session (no topic env) skips entirely.
20
+ - **No new route, class, config key, or dependency.** It consumes the
21
+ `/topic-operator/session-context` route that already shipped in #906.
22
+ - **Bearer token stays in the header** (never the URL/query), matching the other
23
+ injection blocks.
24
+
25
+ ## The security property
26
+ The injected block names the operator established ONLY from the platform-verified
27
+ sender id (the store guarantees this by construction — #904). The hook merely
28
+ surfaces that verified binding; it cannot itself seat anyone. So this read-side
29
+ change cannot introduce a Caroline-class identity bleed — it can only make the
30
+ ALREADY-verified operator visible to the agent at boot.
31
+
32
+ ## Compaction parity (constitutional)
33
+ The same fetch is ALSO wired into `getCompactionRecovery()` — its compaction twin —
34
+ so the verified operator is re-injected after a context reset, not presumed to
35
+ survive in the compaction summary (the `session-context-compaction-parity` standard
36
+ from PR #811, enforced by `tests/unit/session-context-compaction-parity.test.ts`).
37
+ This is thematically load-bearing for Know Your Principal: an agent that loses its
38
+ verified-operator awareness post-compaction is exactly the identity gap this feature
39
+ closes. The twin block mirrors the SESSION-BOOT-SELF-KNOWLEDGE re-injection
40
+ precedent (own `TOPIC_OP_PORT`/`TOPIC_OP_TOKEN` resolution, same fail-open contract),
41
+ and the injector is NOT added to the parity allowlist (the allowlist only shrinks).
42
+
43
+ ## Migration parity
44
+ The `session-start` hook lives in the always-overwritten `instar/` hook set:
45
+ `migrateHooks()` rewrites `hooks/instar/session-start.sh` from
46
+ `getSessionStartHook()` on EVERY update run (PostUpdateMigrator.ts:1958). So this
47
+ block reaches existing agents automatically on their next update — no dedicated
48
+ migration needed, and the migration-parity-hooks unit suite stays green.
49
+
50
+ ## Agent awareness (deliberately deferred)
51
+ No CLAUDE.md template section is added in this increment. The injected
52
+ `<topic-operator>` block is self-describing (it carries its own "do not attribute
53
+ to any other name" instruction), and the governing behavior is already in the
54
+ ratified #898 "Know Your Principal" constitution standard. The operator-binding
55
+ feature's agent-awareness capability section will be added ONCE, as a coherent
56
+ whole, when the feature is end-to-end (after the Inc-2d inbound auto-bind and the
57
+ Inc-3 guard) — rather than fragmenting it across increments. The feature-delivery
58
+ and docs-coverage gates pass without it.
59
+
60
+ ## Framework generality
61
+ Framework-agnostic. The block is emitted into the generic session-start hook that
62
+ every framework's session runs; the `<topic-operator>` payload is plain text any
63
+ harness injects. The topic is resolved from `$INSTAR_TELEGRAM_TOPIC`, the same env
64
+ the existing topic-context block uses — not coupled to Claude Code, Codex, or
65
+ Gemini.
66
+
67
+ ## Tests
68
+ - Tier 3 (E2E): `tests/e2e/topic-operator-hook-injection-lifecycle.test.ts` (3) —
69
+ Phase 1 asserts the generated hook SOURCE wires the fetch; Phase 2 extracts the
70
+ exact block and runs it against a LIVE server, proving it emits the
71
+ `<topic-operator>` block when a topic is bound and nothing when unbound.
72
+ - Tier 1/2 for the store + route shipped in #904/#906; the analog hook suites
73
+ (PostUpdateMigrator-bootSelfKnowledge, migration-parity-hooks,
74
+ OrgIntentManager-session-start-format) stay green.
75
+
76
+ ## Rollback
77
+ Revert the single template-string block in PostUpdateMigrator.ts + delete the E2E
78
+ test. The next update rewrites the hook without the block; nothing else depends
79
+ on it.
@@ -0,0 +1,47 @@
1
+ # ELI16 — Telling the agent who its boss is, the moment it wakes up
2
+
3
+ ## The one-sentence version
4
+ When the agent starts a conversation, it now gets handed a little note that says
5
+ "the verified boss of this chat is X" — so it knows from the very first message
6
+ who it's working for, instead of guessing from names it reads later.
7
+
8
+ ## The backstory
9
+ We've been fixing a real problem: an agent on a shared computer slowly started
10
+ treating a *different real person* (call her Caroline) as its boss, because the
11
+ mix-up lived inside the agent's own writing where nothing was watching. To fix it
12
+ we built three pieces:
13
+
14
+ 1. A filing cabinet (`TopicOperatorStore`) that remembers, per conversation, who
15
+ the verified boss is — and the rule is strict: the boss is decided ONLY by the
16
+ verified ID of whoever actually sent the message, never by a name typed in a
17
+ document.
18
+ 2. Four web endpoints to read and set that binding (shipped last step).
19
+ 3. **This step:** actually handing the agent that "who's your boss" note at the
20
+ start of every conversation.
21
+
22
+ ## What this change adds
23
+ At session start, the agent already gets handed a few notes — the company's rules,
24
+ the preferences it has learned about you, and so on. This change adds one more
25
+ note to that pile: it quietly asks the server "who's the verified boss of this
26
+ chat?" and, if there's an answer, prints a short block telling the agent. The
27
+ block also reminds the agent: don't ever swap in some other name you happen to
28
+ read — an unfamiliar name in the boss's chair is a question to resolve, not a fact
29
+ to accept.
30
+
31
+ ## Why it's safe
32
+ - It only **adds** a note; it changes nothing else about how sessions start.
33
+ - It's careful: it only runs if there's actually a chat topic and the server is
34
+ reachable. If the server can't answer, or nobody's been set as boss yet, it
35
+ prints nothing and the session goes on exactly as before.
36
+ - It can't *make* anyone the boss — it only shows the boss who was already
37
+ verified the safe way. So there's no way for this to repeat the Caroline mix-up.
38
+ - Every agent gets it automatically the next time it updates, because this note
39
+ lives in the startup script that always gets refreshed on update.
40
+
41
+ ## What's still coming
42
+ Right now a boss gets recorded either by a one-time manual call, or — in the next
43
+ step — automatically whenever the verified boss sends a message. After that, a
44
+ final step will let the agent's own safety checker USE this binding to catch
45
+ itself if it ever credits a decision to the wrong person. This step is the
46
+ "agent can SEE its boss" piece; the "agent gets corrected if it forgets" piece
47
+ comes next.