[Conformance] Claude Code host: the shim stops waiting for the Guardian at 300 s, whatever timeout was negotiated

Aperta Adatta ai principianti
#614 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bun, typescript
Ambito
backend, security

Direzione di ricerca

Inizia nello shim di Claude Code, in refimpl/claude-code-read/hosts/claude-code/guardian-client.ts: il fetch alle righe 199-206 è limitato solo da AbortSignal.timeout(timeoutMs), quindi scatta prima il default di 5 minuti di inattività del socket di Bun, e il messaggio alla riga 218 riporta il timeout richiesto anziché il tempo trascorso. Leggi instrument §6.4 e hosts/claude-code/settings.json, poi riproduci con un Guardian stub che annuncia default_ms: 900000 e risponde a 360 s. Fatto significa che la decisione in ritardo ma dentro la finestra viene rispettata in entrambe le posture e che la voce di audit indica il tempo effettivamente atteso; vale la pena aggiungere un test unitario che non richieda un orologio da parete da 360 s.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

priority:P1 status:needs-triage type:conformance
What you ran

Claude Code 2.1.325 (claude-opus-5-5, -p, default permission mode) with the Claude Code shim from PR #597 (refimpl/claude-code-read at 201ddb3, on integration d3323ba), Bun 1.3.11 and the shipped hosts/claude-code/settings.json. In place of the reference Guardian I used a stub that answers handshake/hello with timeout_config.default_ms: 900000 and sends each decision 360 s after the request, well inside the negotiated window. The agent reads a file holding the AWS documentation example key. I ran 3 runs per case, with a fresh stub and session each time, and read what reached the model from the API requests that Claude Code records in the session transcript.

What you expected

Instrument §6.4 says the Observed Agent "MUST wait for the Guardian's decision, up to the negotiated timeout", and "When a decision does arrive within the timeout, the agent MUST honor it regardless of the posture." With 900 s negotiated, a decision at 360 s should be applied.

What happened

The shim stops waiting at 300 s and applies the failure posture.

Under deny, with a Guardian that would answer allow, PreToolUse returns a block at 300.05 s and the Read never runs (3/3). The Guardian would have allowed the call.

Under proceed, with a Guardian that would answer deny, PreToolUse returns at 300.05 s with no decision and the Read runs 60 s before the deny arrives (3/3). PostToolUse then gives up at 300.06 s as well and proceeds, so the key is in the next request to the model. The Guardian would have denied the call.

In both cases every audit entry records timeout with "guardianClient.post: no response within 900000ms". That is the negotiated value, not the 300 s the shim actually waited. The message comes from guardian-client.ts:218, which reports the timeout it was given rather than the time that passed.

The 300 s come from Bun's fetch, not from the shim's own timer:

  • guardian-client.ts:199-206 bounds the call with AbortSignal.timeout(timeoutMs) and nothing else;
  • the Bun reference for BunFetchRequestInit.timeout says it controls "the socket idle timeout for this request", with a default of 5 minutes, and "This is not a whole-request deadline; use AbortSignal.timeout(ms) for that";
  • in a standalone Bun 1.3.11 test against a server that never answers, AbortSignal.timeout(900000) alone fails with TimeoutError at 300.0 s, and adding timeout: false lets the call run until a 420 s abort, at 420.0 s (4 runs, 3 of them as separate processes).

The 300 s also run from the handshake's request, not from the step's own start. When a handshake/hello is answered after 4.5 s and the next request on that connection gets no answer, that request fails 295.5 s after it starts, 300.0 s after the hello started (3 pairs, each with its own server, in one process). The Bun reference says the timer "is reset on every byte sent or received", but on 1.3.11 the hello's response and the next request did not reset it. Through the shim, a PostToolUse that has to renegotiate first (session store not writable) still ends at 300.05 s (3/3).

With the default 5000 ms the shim waits the negotiated time. In a replay against a stub that never answers, the hook ends at about 5.07 s and the audit says no response within 5000ms. The gap opens only when a Guardian negotiates more than 300 s. The reference Guardian does not, since it advertises a fixed DEFAULT_TIMEOUT_MS = 5000 (packages/guardian/src/handshake.ts:82) with no setting to change it. Another Guardian can, because handshake.json gives default_ms a minimum of 1 and no maximum.

Related: #434 lists "A timeout or a late response under Claude Code" among the scenarios no run has covered, and these runs cover the timeout half. #435 is about a decision that arrives after the negotiated timeout, while here it arrives inside it. #269 is about the Guardian's OPA deadline, which is a different timer.

Current Priority Scope

Feeds conformance evidence

Lingua principale
TypeScript
Stelle
183
Fork
56
Merge medio
3g 1h
PR unite (30g)
67

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GenAI-Security-Project/agent-control-standard

Tutte le issue di GenAI-Security-Project/agent-control-standard

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.