fix: narrow child model-step sessions to child capabilities; propagate wall-time limits #373

Closed
nsaspy wants to merge 2 commits from fix/child-native-capability-narrowing into main
Owner

Summary

Two robustness fixes for the provider-native model-step path, both
surfaced by the paid lane's switch to glm-5.3-flash (PR #319) and
reviewed/tested locally before this PR:

  1. Capability narrowing for child sessions. completion_model_step_handler
    passed the PARENT capability set to the child provider-native direct
    session, so a child whose plan budget allots zero context operations was
    still handed the parent's context schemas. When the pinned glm model
    sporadically answered the CLI child session with a context_slice call,
    fail-closed preflight killed the whole batch
    (context_call_budget_exhausted, limit 0) — the last red step of main's
    paid lane. The same leak explained a hallucinated child
    context_slice in the depth-one completion test. The handler now
    receives the narrowed child capabilities (repo authority discipline:
    child capability sets only narrow, never widen).

  2. Wall-time propagation through skill compilation. The prompt compiler
    and skill-operation catch handlers wrapped time_limit_exceeded into
    phase faults (skill_compilation_failed), masking a completion
    wall-time limit that fired during skill compilation. Both handlers now
    rethrow time-limit exceptions unwrapped so the caller's deadline
    machinery maps them to timeouts. This removes the order-dependent
    rlm_subagent/rlm_subagent_deadline flake where
    child_completion_enforces_wall_time_budget nondeterministically
    reported skill_compilation_failed instead of timeout
    (reproduced ~2/6 paired runs before the fix, 6/6 green after).

Evidence

  • New deterministic test (red-first):
    rlm_child_model_session_narrows_to_child_capabilities asserts the
    child request's System message uses the no-context branch and its wire
    schemas contain no context_ tools.
  • Deterministic suite 1068/1068; design gate 59/59; subagent+deadline
    pair loop 6/6 green after the fixes.
  • Live with glm-5.3-flash: completion depth-one 2/2, CLI smoke 3/3,
    full core suite exit 0 (zero failures), repair suite exit 0.
## Summary Two robustness fixes for the provider-native model-step path, both surfaced by the paid lane's switch to glm-5.3-flash (PR #319) and reviewed/tested locally before this PR: 1. **Capability narrowing for child sessions.** `completion_model_step_handler` passed the PARENT capability set to the child provider-native direct session, so a child whose plan budget allots zero context operations was still handed the parent's context schemas. When the pinned glm model sporadically answered the CLI child session with a `context_slice` call, fail-closed preflight killed the whole batch (`context_call_budget_exhausted`, limit 0) — the last red step of main's paid lane. The same leak explained a hallucinated child `context_slice` in the depth-one completion test. The handler now receives the narrowed child capabilities (repo authority discipline: child capability sets only narrow, never widen). 2. **Wall-time propagation through skill compilation.** The prompt compiler and skill-operation catch handlers wrapped `time_limit_exceeded` into phase faults (`skill_compilation_failed`), masking a completion wall-time limit that fired during skill compilation. Both handlers now rethrow time-limit exceptions unwrapped so the caller's deadline machinery maps them to timeouts. This removes the order-dependent `rlm_subagent`/`rlm_subagent_deadline` flake where `child_completion_enforces_wall_time_budget` nondeterministically reported `skill_compilation_failed` instead of `timeout` (reproduced ~2/6 paired runs before the fix, 6/6 green after). ## Evidence - New deterministic test (red-first): `rlm_child_model_session_narrows_to_child_capabilities` asserts the child request's System message uses the no-context branch and its wire schemas contain no `context_` tools. - Deterministic suite 1068/1068; design gate 59/59; subagent+deadline pair loop 6/6 green after the fixes. - Live with glm-5.3-flash: completion depth-one 2/2, CLI smoke 3/3, full core suite exit 0 (zero failures), repair suite exit 0.
completion_model_step_handler passed the PARENT capability set to the
child provider-native direct session, so a child whose plan budget
allots zero context operations was nonetheless handed parent context
schemas (and the alias-inviting System text). When the pinned glm model
sporadically answered the CLI child session with a context_slice call,
fail-closed preflight killed the whole batch (context_call_budget_ex-
hausted, limit 0) — the same leak also surfaced as a hallucinated child
context_slice in the depth-one completion test. Child capability sets
only narrow by repo authority discipline; the handler now receives the
narrowed child capabilities.

TDD: rlm_child_model_session_narrows_to_child_capabilities (red-first:
the child request carried parent context schemas and the alias System
text) asserts the child System message uses the no-context branch and
the wire schemas contain no context_ tools.
fix(runtime): propagate wall-time limits through skill compilation
Some checks failed
Tree-sitter FFI / Direct SWI-Prolog Tree-sitter FFI (pull_request) Successful in 4m14s
CI / REAL OpenRouter integration (pull_request) Has been skipped
Nix flake / Flake package and clean runtime load (pull_request) Failing after 8s
CI / Deterministic unit and load checks (pull_request) Successful in 2m29s
Paid OpenRouter / Pinned paid OpenRouter integration (pull_request) Failing after 3m5s
Clean SWI pack install / Install and load copied pack (pull_request) Successful in 4m12s
87707a4096
The prompt compiler and skill operation catch handlers wrapped
time_limit_exceeded into phase faults (skill_compilation_failed), so a
completion wall-time limit firing during skill compilation was masked
instead of reaching the caller's deadline machinery. Both handlers now
rethrow time limit exceptions unwrapped. This fixes the order-dependent
rlm_subagent/rlm_subagent_deadline flake where
child_completion_enforces_wall_time_budget nondeterministically reported
skill_compilation_failed instead of timeout (reproduced ~2/6 paired
runs before, 6/6 green after).
nsaspy closed this pull request 2026-09-04 22:56:08 +00:00
Some checks failed
Tree-sitter FFI / Direct SWI-Prolog Tree-sitter FFI (pull_request) Successful in 4m14s
CI / REAL OpenRouter integration (pull_request) Has been skipped
Nix flake / Flake package and clean runtime load (pull_request) Failing after 8s
CI / Deterministic unit and load checks (pull_request) Successful in 2m29s
Paid OpenRouter / Pinned paid OpenRouter integration (pull_request) Failing after 3m5s
Clean SWI pack install / Install and load copied pack (pull_request) Successful in 4m12s

Pull request closed

Sign in to join this conversation.
No description provided.