instar 1.3.340 → 1.3.342

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,54 @@
1
+ export interface PendingInjectRecord {
2
+ /** tmux session name the inject targets (also the record's key). */
3
+ tmuxSession: string;
4
+ /** The message queued for injection (may be a bootstrap-file pointer). */
5
+ initialMessage: string;
6
+ /** Telegram topic the message belongs to, when known. */
7
+ telegramTopicId?: number;
8
+ /** ISO timestamp the record was written (spawn time). */
9
+ createdAt: string;
10
+ }
11
+ export declare class PendingInjectStore {
12
+ private dir;
13
+ constructor(stateDir: string);
14
+ /** Key → filename. tmux session names are already shell-safe, but clamp anyway. */
15
+ private fileFor;
16
+ /** Write (or overwrite) the pending record for a session. Never throws —
17
+ * a failed durability write must not block the spawn itself. */
18
+ record(entry: Omit<PendingInjectRecord, 'createdAt'> & {
19
+ createdAt?: string;
20
+ }): void;
21
+ /** Remove the record after a verified inject. Never throws. */
22
+ clear(tmuxSession: string): void;
23
+ /** All surviving records (corrupt files are skipped, reported via return). */
24
+ list(): {
25
+ records: PendingInjectRecord[];
26
+ corrupt: string[];
27
+ };
28
+ }
29
+ export interface PendingInjectSweepDeps {
30
+ sessionAlive(tmuxSession: string): boolean;
31
+ /** Re-deliver through the normal readiness path; resolves once injected (or throws). */
32
+ redeliver(record: PendingInjectRecord): Promise<void>;
33
+ /** Loud reporting for the cases recovery cannot fix on its own. */
34
+ reportLoss(record: PendingInjectRecord, reason: string): void;
35
+ now?: () => number;
36
+ /** Records older than this are expired (reported, not re-injected). Default 6h. */
37
+ maxAgeMs?: number;
38
+ }
39
+ export interface PendingInjectSweepResult {
40
+ redelivered: string[];
41
+ expired: string[];
42
+ deadSession: string[];
43
+ failed: string[];
44
+ }
45
+ /**
46
+ * Boot-time recovery over surviving records. Decision per record:
47
+ * - older than maxAge → expire + reportLoss (stale enough that re-injecting
48
+ * mid-conversation would confuse more than help)
49
+ * - tmux session still alive → redeliver via the readiness path, clear on success
50
+ * - tmux session gone → reportLoss + clear (the bridge respawns on the
51
+ * user's next message; the loss is now VISIBLE)
52
+ */
53
+ export declare function sweepPendingInjects(store: PendingInjectStore, deps: PendingInjectSweepDeps): Promise<PendingInjectSweepResult>;
54
+ //# sourceMappingURL=PendingInjectStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PendingInjectStore.d.ts","sourceRoot":"","sources":["../../src/core/PendingInjectStore.ts"],"names":[],"mappings":"AA8BA,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,cAAc,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,GAAG,CAAS;gBAER,QAAQ,EAAE,MAAM;IAI5B,mFAAmF;IACnF,OAAO,CAAC,OAAO;IAKf;qEACiE;IACjE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAkBpF,+DAA+D;IAC/D,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAehC,8EAA8E;IAC9E,IAAI,IAAI;QAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;CA8B9D;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3C,wFAAwF;IACxF,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,mEAAmE;IACnE,UAAU,CAAC,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9D,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,kBAAkB,EACzB,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,wBAAwB,CAAC,CAkCnC"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * PendingInjectStore — durable record of in-flight initial-message injects.
3
+ *
4
+ * THE GAP THIS CLOSES (finding 8d300555, 2026-06-06): when a session is
5
+ * spawned with an initial message, the inject happens AFTER an async
6
+ * readiness wait (codex can take tens of seconds to boot). That pending
7
+ * inject was process-local state — a server restart in the window between
8
+ * spawn and inject silently dropped the user's message. The live incident:
9
+ * the auto-updater's scheduled restart (60s delay) killed the server while
10
+ * the fresh-spawned codex session was still booting; tmux survived showing
11
+ * an idle prompt, the bootstrap file sat unconsumed on disk, the operator
12
+ * waited 50+ minutes, and nothing anywhere knew a message had been lost.
13
+ *
14
+ * The store is one JSON file per pending inject, keyed by tmux session name,
15
+ * under `<stateDir>/pending-injects/`. Records are written at spawn time and
16
+ * cleared ONLY after the inject actually runs. Boot-time recovery
17
+ * (SessionManager.recoverPendingInjects) sweeps survivors: a still-alive
18
+ * session gets the message re-delivered through the normal readiness path; a
19
+ * dead session is reported loudly (DegradationReporter) and expired — never
20
+ * silently dropped.
21
+ *
22
+ * Delivery semantics are deliberately AT-LEAST-ONCE: if the server dies
23
+ * after the inject but before the clear, the next boot re-injects a
24
+ * duplicate. A duplicated message to an agent session is recoverable noise;
25
+ * a silently dropped user message is not.
26
+ */
27
+ import fs from 'node:fs';
28
+ import path from 'node:path';
29
+ import { SafeFsExecutor } from './SafeFsExecutor.js';
30
+ export class PendingInjectStore {
31
+ dir;
32
+ constructor(stateDir) {
33
+ this.dir = path.join(stateDir, 'pending-injects');
34
+ }
35
+ /** Key → filename. tmux session names are already shell-safe, but clamp anyway. */
36
+ fileFor(tmuxSession) {
37
+ const safe = tmuxSession.replace(/[^a-zA-Z0-9._-]/g, '_').slice(0, 200);
38
+ return path.join(this.dir, `${safe}.json`);
39
+ }
40
+ /** Write (or overwrite) the pending record for a session. Never throws —
41
+ * a failed durability write must not block the spawn itself. */
42
+ record(entry) {
43
+ try {
44
+ fs.mkdirSync(this.dir, { recursive: true });
45
+ const full = {
46
+ tmuxSession: entry.tmuxSession,
47
+ initialMessage: entry.initialMessage,
48
+ ...(entry.telegramTopicId !== undefined ? { telegramTopicId: entry.telegramTopicId } : {}),
49
+ createdAt: entry.createdAt ?? new Date().toISOString(),
50
+ };
51
+ fs.writeFileSync(this.fileFor(entry.tmuxSession), JSON.stringify(full, null, 2));
52
+ }
53
+ catch (err) {
54
+ // @silent-fallback-ok a durable-ledger write must NEVER break the spawn it
55
+ // is protecting — warn with context and continue; a missed record only
56
+ // means this one inject isn't restart-recoverable (the pre-fix behavior).
57
+ console.warn(`[PendingInjectStore] record failed for "${entry.tmuxSession}" (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
58
+ }
59
+ }
60
+ /** Remove the record after a verified inject. Never throws. */
61
+ clear(tmuxSession) {
62
+ try {
63
+ SafeFsExecutor.safeUnlinkSync(this.fileFor(tmuxSession), {
64
+ operation: 'PendingInjectStore.clear',
65
+ });
66
+ }
67
+ catch (err) {
68
+ if (err?.code !== 'ENOENT') {
69
+ // Already-cleared (ENOENT) is the expected no-op; anything else is
70
+ // non-fatal — a stale record is re-examined (and expired) by the next
71
+ // boot sweep, so we report rather than throw into the inject path.
72
+ console.warn(`[PendingInjectStore] clear failed for "${tmuxSession}" (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
73
+ }
74
+ }
75
+ }
76
+ /** All surviving records (corrupt files are skipped, reported via return). */
77
+ list() {
78
+ const records = [];
79
+ const corrupt = [];
80
+ let files = [];
81
+ try {
82
+ files = fs.readdirSync(this.dir).filter((f) => f.endsWith('.json'));
83
+ }
84
+ catch {
85
+ // @silent-fallback-ok no pending-injects dir yet (fresh install / nothing
86
+ // ever queued) is the normal empty case, not a degradation — return empty.
87
+ return { records, corrupt };
88
+ }
89
+ for (const f of files) {
90
+ try {
91
+ const parsed = JSON.parse(fs.readFileSync(path.join(this.dir, f), 'utf8'));
92
+ if (parsed && typeof parsed === 'object' &&
93
+ typeof parsed.tmuxSession === 'string' &&
94
+ typeof parsed.initialMessage === 'string' &&
95
+ typeof parsed.createdAt === 'string') {
96
+ records.push(parsed);
97
+ }
98
+ else {
99
+ corrupt.push(f);
100
+ }
101
+ }
102
+ catch {
103
+ corrupt.push(f);
104
+ }
105
+ }
106
+ return { records, corrupt };
107
+ }
108
+ }
109
+ /**
110
+ * Boot-time recovery over surviving records. Decision per record:
111
+ * - older than maxAge → expire + reportLoss (stale enough that re-injecting
112
+ * mid-conversation would confuse more than help)
113
+ * - tmux session still alive → redeliver via the readiness path, clear on success
114
+ * - tmux session gone → reportLoss + clear (the bridge respawns on the
115
+ * user's next message; the loss is now VISIBLE)
116
+ */
117
+ export async function sweepPendingInjects(store, deps) {
118
+ const result = { redelivered: [], expired: [], deadSession: [], failed: [] };
119
+ const now = deps.now ?? (() => Date.now());
120
+ const maxAgeMs = deps.maxAgeMs ?? 6 * 60 * 60 * 1000;
121
+ const { records, corrupt } = store.list();
122
+ for (const f of corrupt) {
123
+ console.warn(`[PendingInjectStore] corrupt pending-inject file skipped: ${f}`);
124
+ }
125
+ for (const record of records) {
126
+ const age = now() - Date.parse(record.createdAt);
127
+ if (!Number.isFinite(age) || age > maxAgeMs) {
128
+ deps.reportLoss(record, `record expired (age ${Math.round(age / 60000)}m > ${Math.round(maxAgeMs / 60000)}m)`);
129
+ store.clear(record.tmuxSession);
130
+ result.expired.push(record.tmuxSession);
131
+ continue;
132
+ }
133
+ if (!deps.sessionAlive(record.tmuxSession)) {
134
+ deps.reportLoss(record, 'target tmux session no longer exists');
135
+ store.clear(record.tmuxSession);
136
+ result.deadSession.push(record.tmuxSession);
137
+ continue;
138
+ }
139
+ try {
140
+ await deps.redeliver(record);
141
+ store.clear(record.tmuxSession);
142
+ result.redelivered.push(record.tmuxSession);
143
+ }
144
+ catch (err) {
145
+ // Keep the record — the NEXT boot retries. Failing loudly beats dropping.
146
+ deps.reportLoss(record, `redeliver failed: ${err instanceof Error ? err.message : String(err)}`);
147
+ result.failed.push(record.tmuxSession);
148
+ }
149
+ }
150
+ return result;
151
+ }
152
+ //# sourceMappingURL=PendingInjectStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PendingInjectStore.js","sourceRoot":"","sources":["../../src/core/PendingInjectStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAarD,MAAM,OAAO,kBAAkB;IACrB,GAAG,CAAS;IAEpB,YAAY,QAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED,mFAAmF;IAC3E,OAAO,CAAC,WAAmB;QACjC,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED;qEACiE;IACjE,MAAM,CAAC,KAAsE;QAC3E,IAAI,CAAC;YACH,EAAE,CAAC,SAAS,CA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,0BAA0B;IAgClC,OAAO,CAAC,gBAAgB;IAmJxB,OAAO,CAAC,6BAA6B;CAoCtC"}
@@ -3311,6 +3311,28 @@ Every session shutoff — and every REFUSED shutoff (protected, not-lease-holder
3311
3311
  else {
3312
3312
  result.skipped.push('CLAUDE.md: Reap-Log section already present');
3313
3313
  }
3314
+ // GuardPostureTripwire — a disabled guard is itself an incident. Tells the
3315
+ // agent the "did a monitor get switched off?" surface exists. Without it,
3316
+ // an agent asked "why didn't the watchdog catch this?" can't ground the
3317
+ // answer in the posture history (the 2026-06-05 batch-flip went invisible
3318
+ // for exactly this reason). Idempotent via content-sniffing on the
3319
+ // breadcrumb path.
3320
+ if (!content.includes('guard-posture.jsonl')) {
3321
+ const section = `
3322
+ ## Guard-Posture Tripwire (a disabled guard is itself an incident)
3323
+
3324
+ At every server boot the guard posture (every \`monitoring.*\` enabled flag + \`scheduler.enabled\`) is compared against the previous boot's posture. Any guard that went enabled→disabled triggers: a loud boot log line, one row in \`logs/guard-posture.jsonl\`, and ONE aggregated HIGH Attention item listing every newly-disabled guard. Re-enables get the breadcrumb only. Signal-only — nothing is ever auto-re-enabled; a deliberate disable just needs its Attention item acknowledged. (Born from the 2026-06-05 meltdown load-shed: five guards batch-flipped off by an emergency config edit, only one noticed.)
3325
+
3326
+ - If a user asks "why didn't the watchdog/sentinel/scheduler catch X?" — FIRST check \`logs/guard-posture.jsonl\` (and the current config) to see whether the guard was even running. A silently-disabled guard explains more incidents than a broken one.
3327
+ - If you ever disable a guard yourself as emergency load-shedding: say so to the user at the time, and expect the tripwire to raise the Attention item at the next boot — that item is the loop-closer that gets the guard turned back on.
3328
+ `;
3329
+ content += '\n' + section;
3330
+ patched = true;
3331
+ result.upgraded.push('CLAUDE.md: added Guard-Posture Tripwire section');
3332
+ }
3333
+ else {
3334
+ result.skipped.push('CLAUDE.md: Guard-Posture Tripwire section already present');
3335
+ }
3314
3336
  // AgentWorktreeReaper report (RESPONSIBLE-RESOURCE-USAGE — OS resource hygiene).
3315
3337
  // Tells the agent the "which stale worktrees can be reclaimed?" read-surface
3316
3338
  // exists. Without it, an agent asked about worktree disk/sprawl has no grounded