refactor(x): drop limits DI, read setting at default site; async fs

Address review: remove ITurnLimitsResolver, its bridge and container
registration. createTurn now defaults an omitted maxModelCalls straight
from the turn-limits config (lazy import, built-in fallback), with no
chat/headless distinction in the runtime — the chat UI passes its
optional chat override explicitly via the existing sessions:sendMessage
maxModelCalls field. turn_limits.ts now uses fs/promises throughout.
This commit is contained in:
Gagan 2026-07-21 20:58:53 +05:30
parent 7cb9c478ac
commit 7b05bf80cb
12 changed files with 91 additions and 145 deletions

View file

@ -512,13 +512,13 @@ Rules:
- `input` is the user message that defines this turn boundary.
- `autoPermission` defaults to `false` before persistence.
- `humanAvailable` is required explicitly.
- `maxModelCalls`, when omitted, is resolved at creation from the user's
turn-limit settings (`config/turn_limits.json`) via the injected
`ITurnLimitsResolver`: turns with `humanAvailable: true` use the chat
override when set, otherwise the global limit; headless turns always use
the global limit. Without a resolver (tests) it defaults to `50`. Spawned
sub-agents default to the global limit, which also caps the budget a
parent may grant them. Settings changes affect only newly created turns.
- `maxModelCalls`, when omitted, defaults at creation to the user's global
model-call limit (`config/turn_limits.json`, built-in default `50`). The
runtime makes no chat/headless distinction: the optional chat override is
the chat UI's job — its send path passes an explicit `maxModelCalls`.
Spawned sub-agents default to the global limit, which also caps the
budget a parent may grant them. Settings changes affect only newly
created turns.
- Persisted values are fully resolved and immutable.
The capability is named `humanAvailable`, not `headless`. `headless` describes