jg-agent-hq 13.5.0 → 13.5.1
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.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -0
- package/api/README.md +2 -2
- package/dist/actions/admission/admission.js +3 -3
- package/dist/store/control/admission/admission.model.js +12 -4
- package/dist/store/control/lifecycle/lifecycle.model.js +1 -1
- package/dist/store/control/observations/observations.model.js +1 -1
- package/docs/recovery.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 13.5.1
|
|
4
|
+
|
|
5
|
+
- Allow confirmed recovery of a known quarantined Codex identity in the current HQ runtime, including loaded active, idle and unloaded sessions, without restarting HQ. Verify the native turn before and after joining, retain paused queues and unresolved receipts, and send no settings or input. Healthy controls, pending dispatches and unverified identities remain refused.
|
|
6
|
+
|
|
3
7
|
## 13.5.0
|
|
4
8
|
|
|
5
9
|
- Quarantine attributable Claude interpretation, registry and persisted-evidence failures without terminating native work or other controlled sessions. Suspend rich interpretation and controls; require fresh native idle, a known empty full task snapshot and no unresolved requests before automatic cleanup. Partial task activity invalidates older emptiness, and ordinary idle parking cannot bypass quarantine.
|
package/README.md
CHANGED
|
@@ -77,6 +77,8 @@ Native execution settings, instructions, skills and tool permissions remain with
|
|
|
77
77
|
|
|
78
78
|
When Claude sends structurally valid evidence HQ cannot interpret, HQ suspends that session's controls and live interpretation while its native work continues. It closes the quarantined controller automatically only after fresh native idle, a known empty task snapshot and no unresolved requests establish that work has finished. Unknown evidence or an unanswered approval keeps it alive; confirmed `thread-close` with `interrupt: true` explicitly stops its owned process group, including unfinished background work. Identity and transport-integrity failures retain their shutdown handling.
|
|
79
79
|
|
|
80
|
+
A quarantined known Codex identity offers confirmed recovery in the current runtime without an HQ restart. Recovery verifies the native turn before and after joining, sends no input or settings, keeps earlier queues paused and leaves uncertain receipts unresolved. Automatic reconnect still refuses changed turns; inspect the session and close competing clients before confirming recovery.
|
|
81
|
+
|
|
80
82
|
After verified owned-group shutdown and controller release, that conversation becomes managed and inactive without restarting HQ. Resume retains its native identity and history. Unacknowledged input stays uncertain, earlier queued work stays paused, and pending approvals expire. Unconfirmed shutdown or a competing native terminal keeps ownership uncertain; another controlled conversation remains usable. See [Claude connection recovery](docs/recovery.md#claude-connection-recovery).
|
|
81
83
|
|
|
82
84
|
Approval reads return indexed, cursor-paginated pending, answered and expired metadata after reconnect or restart. Sensitive presentation is available only while the exact native request is live. Native permissions require explicit responses; unknown request kinds or scopes are denied. See [native replies and reconnect reads](api/README.md#thread-control-and-live-input).
|
package/api/README.md
CHANGED
|
@@ -293,13 +293,13 @@ Send `{ kind: 'action', action: { id, runtimeEpoch, command } }`. Generate one U
|
|
|
293
293
|
|
|
294
294
|
Message and queue input is a closed union: `{ kind: 'text', text }` or `{ kind: 'skill', skillId, arguments }`. Text is nonempty and at most 65,536 characters; skill arguments may be empty and cap at 16,384 characters. The envelope's UTF-8 limit still applies. A selected skill is resolved through the target thread's current native catalog before admission. Unavailable, missing or disabled selections cannot dispatch. Normal text needs no catalog read. Steering retains its `text` field and exact active-turn target, adding only optional top-level `files`. Text-only steers remain unchanged; skills and turn settings cannot be steered.
|
|
295
295
|
|
|
296
|
-
Names use lowercase ASCII letters, digits and hyphens, start with a letter or digit, and have at most 64 characters, the public `MAX_THREAD_NAME_LENGTH` from `jg-agent-hq/contracts`. The same bound applies to create, adopt, rename and managed-thread responses. Names are unique without regard to case in one state directory. Creation and adoption resolve collisions atomically with ordinal suffixes such as `build-usage-2`, truncating the base to keep the complete name within 64 characters. Explicit rename rejects an occupied or pending name. Provider/native-session pairs remain unique. At most 32 native sessions are controlled concurrently; close idle sessions to release capacity. Native discovery remains independent of that limit. Confirm that other native CLI controllers are closed before adoption, resume or recovery. An unloaded native status cannot prove another CLI has stopped. The runtime provides exclusive coordination within one canonical state directory; it does not impose a global lock on independent CLIs. Recovery
|
|
296
|
+
Names use lowercase ASCII letters, digits and hyphens, start with a letter or digit, and have at most 64 characters, the public `MAX_THREAD_NAME_LENGTH` from `jg-agent-hq/contracts`. The same bound applies to create, adopt, rename and managed-thread responses. Names are unique without regard to case in one state directory. Creation and adoption resolve collisions atomically with ordinal suffixes such as `build-usage-2`, truncating the base to keep the complete name within 64 characters. Explicit rename rejects an occupied or pending name. Provider/native-session pairs remain unique. At most 32 native sessions are controlled concurrently; close idle sessions to release capacity. Native discovery remains independent of that limit. Confirm that other native CLI controllers are closed before adoption, resume or recovery. An unloaded native status cannot prove another CLI has stopped. The runtime provides exclusive coordination within one canonical state directory; it does not impose a global lock on independent CLIs. Recovery requires inspected ownership evidence and a stopped producing runtime, except confirmed resume of a known quarantined Codex identity with no action in flight, which the current runtime can recover.
|
|
297
297
|
|
|
298
298
|
Version 13 expands the producer contract: a 12.x consumer's strict 32-character schema rejects a response containing a longer managed name. Run matching runtime and consumer releases. Storage remains compatible with 12.0.1, but a package downgrade first requires shortening all longer managed names with supported rename actions and resolving collisions; see [package downgrade](../docs/recovery.md#package-downgrade).
|
|
299
299
|
|
|
300
300
|
Codex may keep an idle native thread loaded after `thread/unsubscribe`, as when a terminal still holds it. An explicitly confirmed resume may reacquire that thread when its known managed control is inactive and managed, without settings overrides. Ordinary resume still refuses active native threads, uncertain managed ownership and already controlled idle sessions.
|
|
301
301
|
|
|
302
|
-
|
|
302
|
+
Explicit `thread-recover` with `recovery: { kind: 'resume' }` can rejoin a quarantined managed record's known Codex identity in the current runtime without restarting HQ, whether unloaded or still loaded idle or active. No action may remain in flight. The operator must inspect its ownership evidence and stop competing controllers that could submit work. HQ reads its current native turn, binds it before joining so reissued approvals find their turn, then verifies the same turn again before acknowledging recovery. It changes no settings, sends no input, leaves earlier queued entries paused and does not resolve uncertain input receipts. Unknown execution state, a mismatched workspace/identity or a changed turn refuses recovery. Healthy ownership and pending dispatches remain ineligible. Earlier queued receipts retain this recovery action as `relatedActionId`; completion and later automatic reconnects leave those entries paused until explicitly sent or cancelled. Recovery that attaches an identity after uncertain creation and ordinary adoption retain their existing unloaded-session checks.
|
|
303
303
|
|
|
304
304
|
Receipts separate `delivery` (`queued`, `submitted`, `acknowledged`, `uncertain`, `failed`, `canceled`) from nullable native turn `completion` (`completed`, `failed`, `interrupted`). Acknowledgement means the exact native request was accepted, not that the turn or tool completed. Permission replies remain submitted after a pipe write and become acknowledged only when Codex resolves the exact native request or Claude returns a tool-result block for the exact tool-use identity. Claude cancellation expires the prompt and leaves an unacknowledged written reply uncertain. Resolution does not prove a tool ran. The receipt includes managed and native identity, its nullable `provider`, digest, timestamps, safe failure classification and optional related action. Its `phase` is the native step the action takes now: `create`, `resume`, `name`, `turn`, `steer`, `interrupt`, `clean`, `close`, `delete` or `reply`. A create continues with `name` once its session exists, and with `turn` when it carries a first input; a close's `interrupt` continues with `clean` once the turn ends, and its `clean` with `close`; a deletion of a session the runtime runs takes `clean` and `close` before `delete`. An action that sends nothing native, such as queued input before it is sent, has none. Only selected receipts expose `nativeThreadId`, the native session of the action's thread once the runtime records it, undelivered `queuedInput` and the nullable complete native `result`; collection reads omit all three. Queued input retains prepared text, native skill identity, content-bound file references and explicit turn settings, never file bytes or skill content. It is cleared after delivery acknowledgement or cancellation.
|
|
305
305
|
|
|
@@ -185,9 +185,9 @@ export const createAdmission = (context, dispatcher) => {
|
|
|
185
185
|
const isKnownCodexRecovery = command.kind === 'thread-recover' &&
|
|
186
186
|
command.recovery.kind === 'resume' &&
|
|
187
187
|
thread.provider === 'codex' &&
|
|
188
|
-
!target.canAdopt;
|
|
188
|
+
(!target.canAdopt || thread.runtimeEpoch === epoch);
|
|
189
189
|
if (isKnownCodexRecovery) {
|
|
190
|
-
if (thread.ownership !== 'uncertain'
|
|
190
|
+
if (thread.ownership !== 'uncertain')
|
|
191
191
|
conflict();
|
|
192
192
|
if (!control.readReattachment || !control.reattachThread)
|
|
193
193
|
capabilityUnavailable();
|
|
@@ -196,7 +196,7 @@ export const createAdmission = (context, dispatcher) => {
|
|
|
196
196
|
if (read.thread.nativeId !== nativeId ||
|
|
197
197
|
(await resolveWorkspaceTarget(read.thread.workspaceRoot, roots)) !==
|
|
198
198
|
thread.workspaceRoot ||
|
|
199
|
-
!['idle', 'active'].includes(read.thread.nativeState))
|
|
199
|
+
!['notLoaded', 'idle', 'active'].includes(read.thread.nativeState))
|
|
200
200
|
conflict();
|
|
201
201
|
prepared.recoveryTurn = read.latestTurn && {
|
|
202
202
|
nativeTurnId: read.latestTurn.nativeId,
|
|
@@ -199,7 +199,13 @@ export class ControlAdmission extends ControlModel {
|
|
|
199
199
|
thread.workspace_root === proof.workspaceRoot;
|
|
200
200
|
if (proof && !isQuarantinedClose)
|
|
201
201
|
this._conflict();
|
|
202
|
-
|
|
202
|
+
const isVerifiedCodexRecovery = command.kind === 'thread-recover' &&
|
|
203
|
+
command.recovery.kind === 'resume' &&
|
|
204
|
+
thread.provider === 'codex' &&
|
|
205
|
+
thread.native_id !== null &&
|
|
206
|
+
thread.native_id === prepared.nativeId &&
|
|
207
|
+
prepared.recoveryTurn !== undefined;
|
|
208
|
+
this.__requireControl(isQuarantinedClose ? 'attached' : rule.control, thread, isVerifiedCodexRecovery);
|
|
203
209
|
if (isQuarantinedClose && thread.pending_action_id)
|
|
204
210
|
this._conflict();
|
|
205
211
|
if (rule.requiresNoPendingAction && thread.pending_action_id)
|
|
@@ -247,7 +253,8 @@ export class ControlAdmission extends ControlModel {
|
|
|
247
253
|
const isRunning = latest?.state === 'running';
|
|
248
254
|
// bind before joining so a reissued native request finds the exact active turn
|
|
249
255
|
this._statements.run('UPDATE agent_hq_thread SET active_turn_id = ?, last_turn_id = ?, last_turn_state = ?, state = ? WHERE id = ?', isRunning ? latest.nativeTurnId : null, latest && !isRunning ? latest.nativeTurnId : thread.last_turn_id, latest && !isRunning ? latest.state : thread.last_turn_state, latest?.state ?? 'idle', threadId);
|
|
250
|
-
|
|
256
|
+
// retain the pause across later completions and automatic reconnects in this runtime
|
|
257
|
+
this._statements.run("UPDATE agent_hq_action SET queue_ready = 0, related_action_id = ?, updated_at = ? WHERE thread_id = ? AND delivery = 'queued'", action.id, now, threadId);
|
|
251
258
|
}
|
|
252
259
|
if (isCreating)
|
|
253
260
|
this._statements.run('UPDATE agent_hq_action SET requested_name = ? WHERE id = ?', thread.name, action.id);
|
|
@@ -361,7 +368,7 @@ export class ControlAdmission extends ControlModel {
|
|
|
361
368
|
}
|
|
362
369
|
}
|
|
363
370
|
/** Requires the control the rule names over the thread. */
|
|
364
|
-
__requireControl(control, thread) {
|
|
371
|
+
__requireControl(control, thread, isVerifiedCodexRecovery = false) {
|
|
365
372
|
if (control === null)
|
|
366
373
|
return;
|
|
367
374
|
if (control === 'owned') {
|
|
@@ -388,7 +395,8 @@ export class ControlAdmission extends ControlModel {
|
|
|
388
395
|
!thread.native_id)
|
|
389
396
|
this._conflict();
|
|
390
397
|
}
|
|
391
|
-
else if (thread.ownership !== 'uncertain' ||
|
|
398
|
+
else if (thread.ownership !== 'uncertain' ||
|
|
399
|
+
(thread.runtime_epoch === this._epoch && !isVerifiedCodexRecovery))
|
|
392
400
|
this._conflict();
|
|
393
401
|
}
|
|
394
402
|
__requireIdle(thread) {
|
|
@@ -147,7 +147,7 @@ export class ControlLifecycle extends ControlModel {
|
|
|
147
147
|
if (finished) {
|
|
148
148
|
this._statements.run('UPDATE agent_hq_action SET completion = ?, updated_at = ? WHERE thread_id = ? AND native_turn_id = ? AND completion IS NULL', finished.state, now, thread.id, finished.nativeTurnId);
|
|
149
149
|
if (canDispatchQueued)
|
|
150
|
-
this._statements.run("UPDATE agent_hq_action SET queue_ready = 1 WHERE thread_id = ? AND expected_turn_id = ? AND delivery = 'queued'", thread.id, finished.nativeTurnId);
|
|
150
|
+
this._statements.run("UPDATE agent_hq_action SET queue_ready = 1 WHERE thread_id = ? AND expected_turn_id = ? AND delivery = 'queued' AND related_action_id IS NULL", thread.id, finished.nativeTurnId);
|
|
151
151
|
}
|
|
152
152
|
return { thread: this._managedThread(thread.id), canDispatchQueued };
|
|
153
153
|
});
|
|
@@ -114,7 +114,7 @@ export class ControlObservations extends ControlModel {
|
|
|
114
114
|
thread.ownership === 'managed';
|
|
115
115
|
this._statements.run('UPDATE agent_hq_thread SET active_turn_id = NULL, last_turn_id = ?, last_turn_state = ?, state = ?, updated_at = ? WHERE id = ?', observation.nativeTurnId, observation.state, thread.ownership === 'uncertain' ? 'unknown' : observation.state, now, thread.id);
|
|
116
116
|
if (mayAdvance)
|
|
117
|
-
this._statements.run("UPDATE agent_hq_action SET queue_ready = 1 WHERE thread_id = ? AND expected_turn_id = ? AND delivery = 'queued' AND runtime_epoch = ?", thread.id, observation.nativeTurnId, this._epoch);
|
|
117
|
+
this._statements.run("UPDATE agent_hq_action SET queue_ready = 1 WHERE thread_id = ? AND expected_turn_id = ? AND delivery = 'queued' AND runtime_epoch = ? AND related_action_id IS NULL", thread.id, observation.nativeTurnId, this._epoch);
|
|
118
118
|
else
|
|
119
119
|
this._statements.run("UPDATE agent_hq_action SET queue_ready = 0 WHERE thread_id = ? AND delivery = 'queued'", thread.id);
|
|
120
120
|
}
|
package/docs/recovery.md
CHANGED
|
@@ -56,7 +56,7 @@ A quarantined session can still be monitored while a CLI runs it. Native observa
|
|
|
56
56
|
|
|
57
57
|
A shared Codex daemon restart can interrupt every managed Codex session's live connection while HQ stays running. The runtime rechecks only its previously controlled sessions with no action in flight and rejoins matching native turns without changing settings or repeating input. Confirmed completions advance their waiting queues; unacknowledged actions and changed turns remain uncertain. Native command handles may have been lost, so rejoining establishes session control rather than successful command execution. See [runtime lifecycle](../api/README.md#runtime-lifecycle).
|
|
58
58
|
|
|
59
|
-
For a session left uncertain,
|
|
59
|
+
For a known Codex session left uncertain, inspect its native identity and close competing controllers before explicit recovery. The current HQ runtime can recover it once no action remains in flight; restarting HQ is unnecessary. Other recovery modes and providers retain their stopped-producing-runtime requirement. `thread-recover` with `recovery: { kind: 'resume' }` can rejoin its already known Codex identity whether unloaded or still held idle or active. The verified current turn is bound before joining and checked again afterward; no settings or input are sent. Reissued approvals can then be answered explicitly. Earlier queued entries stay paused, uncertain input receipts stay unresolved, and unknown state or a turn changing during the join leaves control uncertain. Never use attach/create to replace a known native identity or replay work to recover control.
|
|
60
60
|
|
|
61
61
|
Quarantined Codex records retain their producing epoch and turn evidence across shutdown. Earlier releases could instead leave a known record managed and inactive after shutdown; inspect that state and use a confirmed `thread-resume` only once its native session is idle or unloaded. Do not change ownership records by hand or replace the identity to bypass the native-state checks.
|
|
62
62
|
|
package/package.json
CHANGED