Skip to content

fix(channel): wait the configured approval window on channel cards - #18953

Merged
javenciu merged 2 commits into
kirodotdev:mainfrom
javenciu:fix/channel-approval-honors-window
Oct 13, 2026
Merged

javenciu merged 2 commits into
kirodotdev:mainfrom
javenciu:fix/channel-approval-honors-window

Conversation

@javenciu

@javenciu javenciu commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a channel approval card waits the operator's configured approval window (agent.tool_approval_timeout_secs), capped at 3600 s, and the expired-card notice quotes the window it actually used.

  • A channel approval card waited a fixed _APPROVAL_TIMEOUT_SECS = 3600 before the host declined it (asyncio.wait_for(approval_future, timeout=_APPROVAL_TIMEOUT_SECS) in _stream_task, src/kiro_crew/channel.py).
  • It never read agent.tool_approval_timeout_secs, whose documented meaning is "How long a chat turn waits for a human to answer a tool-approval prompt before declining it" (src/kiro_crew/config/sections.py). The dashboard turn honours that setting (chat_runner.py waits min(state.approval_timeout_for(slot), tool_approval_timeout_secs())).
  • On a channel, an operator who set a 30 s window still had the agent parked for an hour on an unanswered card, and the model was told "the channel approval card went unanswered for 3600s" whatever the setting said.

Why it matters

The setting is the operator's one control for how long an unanswered approval blocks work, and the channel surface ignored it. A channel agent waiting on nobody stays blocked for up to an hour, and the notice the model reads names a window the operator never chose.

Not a goal

  • Changing the default. With the setting absent, a channel card still waits 3600 s, as it does today. Bringing channels to the dashboard's default window would change every channel user's wait and is a separate decision.
  • A turn ceiling for channel turns. _stream_task is awaited without one, so a channel approval cannot outlive a turn ceiling; that is unchanged.
  • The dashboard's approval windows and turn_dispatch.tool_approval_timeout_secs. The channel module reads the config directly rather than importing that dashboard helper, which would reverse a layer.
  • The spec. docs/system-specs/modules/persistent-agent-channels.md says "asyncio.wait_for supplies the timeout" and does not state its length, so no spec text changes.

What changed (motivation → approach → change)

  • Symptom: a channel approval card ignores agent.tool_approval_timeout_secs and always waits 3600 s.
  • Root cause: _stream_task waited on the constant _APPROVAL_TIMEOUT_SECS, and the expired-card notice quoted the same constant.
  • Change, src/kiro_crew/channel.py:
    • New _channel_approval_window_secs() (src/kiro_crew/channel.py:1291). It returns the loaded agent.tool_approval_timeout_secs, capped at _APPROVAL_TIMEOUT_SECS, once the operator has written a number other than the default. While the setting is absent or holds the default it returns the cap, and it returns the cap when config cannot be read. The decision is src/kiro_crew/channel.py:1311-1317.
    • Whether a number was written is read from the config documents, never from the key's presence and never from the loaded number. KiroCrewConfig.save() writes every agent field through to_dict() (src/kiro_crew/config/loader.py:4306), and the gateway's first boot calls save (src/kiro_crew/cli_server.py:2999), so a config nobody edited already holds the default. The loader rules presence out as evidence (src/kiro_crew/config/loader.py:1616). A number equal to the default reads as unset, as embedding_threads does (src/kiro_crew/embeddings.py:1081).
    • The loaded number cannot answer it either, because the loader pulls a present key under the turn ceiling (src/kiro_crew/config/loader.py:3184-3186) and never touches an omitted one. With agent.chat_turn_timeout_secs at 300, a saved 600 and a written 500 both load as 240, and an omitted key loads as 600. So the choice is read before that pull.
    • New _written_approval_window() (src/kiro_crew/channel.py:1268) merges config.json and config.local.json with the loader's own _deep_merge, the overlay winning key by key (src/kiro_crew/channel.py:1279-1285), and reads the number with the loader's own _safe_int (src/kiro_crew/channel.py:1288): a numeric string or an integral float counts as the loader counts it, and anything else reads as the default. A document that cannot be read, or is not a JSON object, adds nothing, as in the load.
    • The wait is the loaded number, so it carries the loader's merge of config.local.json over config.json and its clamps: into 30..7200 s, then to at most 60 s below agent.chat_turn_timeout_secs. A configured zero arrives as 30 s, so no "not positive" branch is left, and the turn-ceiling arithmetic stays in the loader. Channels and the dashboard read the same validated number, and the loader logs a clamp when it applies.
    • _stream_task reads the window once per card with await asyncio.to_thread(_channel_approval_window_secs) (src/kiro_crew/channel.py:1692), off the event loop because it reads the config files. The read sits inside the card's existing ownership scope, so a cancel during it still clears the pending future.
    • The wait uses that window (src/kiro_crew/channel.py:1701), and the "went unanswered" notice quotes it (src/kiro_crew/channel.py:1762). An expired card is still declined.
    • _APPROVAL_TIMEOUT_SECS stays 3600 (src/kiro_crew/channel.py:69); its comment names it the cap and the default.
  • Rejected: importing dashboard.turn_dispatch.tool_approval_timeout_secs. It is a dashboard module, and its turn-budget bound is about the dashboard turn's ceiling, which a channel turn does not have.
  • Rejected: deciding from the loaded number alone, compared with the default or with a recomputed copy of the loader's pull under the turn ceiling. The pull gives a saved 600 and a written 500 the same loaded 240, so one of them is misread whichever way the comparison goes, and it skips an omitted key, which loads as 600 and not as 240. The documents hold the choice before that rewrite.
  • Rejected: taking the wait from the documents as well. The written number misses the loader's validation and clamps: a written 500 under a 300 s ceiling has to wait the 240 s the dashboard turn waits.
  • Rejected: always using the loaded value, even at the default. That moves every default channel card from 3600 s to 600 s (the field's default), which the Not-a-goal above rules out.

Backwards compatibility

Compatible for an install that never chose a window. With agent.tool_approval_timeout_secs absent from config.json, or at its default as KiroCrewConfig.save() writes it, a channel card waits 3600 s and the notice reads "3600s", exactly as before. That holds under a short agent.chat_turn_timeout_secs, where the loader loads a saved default lower (240 s under a 300 s ceiling) and an omitted key at 600 s.
Only an operator who set another value sees a different wait: their value as the loader leaves it, capped at 3600 s. The dashboard turn already waits that value. A window typed as exactly the default cannot be told from the saved one, so it keeps the 3600 s wait; 599 s and 601 s are honoured.
Removes nothing: the change adds two helpers and replaces the constant in one wait and one notice.

Tests

Red on this PR's previous head (rebased onto origin/main 315affc, pytest test/test_channel_approval_meta.py -n 0, 3 of 3 serial runs): 19 failed, 32 passed each. The review's two cases are among them: a written 500 under a 300 s turn ceiling waited 3600 s instead of 240 s, and an omitted key under it waited 600 s instead of 3600 s.
Red on origin/main 315affc (the test file copied onto it, same command, 3 of 3 serial runs): 18 failed, 33 passed each. The failures are the eighteen tests that expect a written window to be waited; the controls pass on main by design, they pin today's 3600 s.
After the fix: same command, 3 of 3 serial runs, 51 passed each. With the 27 neighbour files below, 28 files run serially: 859 passed.

Changed in test/test_channel_approval_meta.py. The tests write config.json with KiroCrewConfig().save(), or by hand for a typed value, and read it through the real loader. Only the unreadable-config case stubs the loader. _expire_one_card replaces the module's own asyncio binding with a namespace that delegates every other name to the real module, so wait_for reports the window it was given and expires at once, with no wall clock.

FAILED test/test_channel_approval_meta.py::test_a_window_the_loader_pulls_under_the_turn_ceiling_is_waited_as_pulled[300-500-240] - assert [3600] == [240]
FAILED test/test_channel_approval_meta.py::test_an_omitted_window_under_a_short_turn_ceiling_keeps_the_full_cap[300] - assert [600] == [3600]
FAILED test/test_channel_approval_meta.py::test_a_malformed_window_under_a_short_turn_ceiling_keeps_the_full_cap['soon'] - assert [600] == [3600]

The eighteen failures on main are the tests that expect 30, 60, 90 set in config.local.json, 1000, 599, 601, a zero raised to 30, a window pulled under a short turn ceiling, the numeric spellings of 500 and the overlay splits.

Neighbours: the other 21 test files that import kiro_crew.channel and six that pin the config loader's bounds and the import boundaries (test/test_transport_permission_floor.py left out: it builds paths under the real home directory). mypy, flake8, isort and black are clean on the changed files. scripts/check_black_formatting.py, scripts/check_subprocess_encoding.py, scripts/docs-lint.sh and scripts/check_comment_history.py with COMMENT_HISTORY_BASE_REF=origin/main pass. Eight one-line mutations of src/kiro_crew/channel.py are each caught: deciding from the loaded number (7 tests fail), reading config.json only (4), skipping the loader's integer reading (2), dropping the 3600 s cap (1), replacing the merge with the last document (1), deciding from the key's presence (16), and letting an unreadable (2) or non-object (1) overlay abort the read.

What each test pins:

  • test_an_unanswered_card_waits_the_configured_approval_window: a saved window of 30 s is waited, the card is declined, and the notice reads "went unanswered for 30s".
  • test_an_unanswered_card_waits_the_full_cap_when_no_window_is_set: control, an empty config.json waits 3600 s and the notice reads "3600s".
  • test_a_config_saved_with_defaults_keeps_the_full_cap: KiroCrewConfig().save() puts the default window in the file (asserted), and the card waits 3600 s.
  • test_the_default_window_under_a_short_turn_ceiling_keeps_the_full_cap: at ceilings of 300, 659, 660 and 14400 s the loader leaves 240, 599, 600 and 600 s of the saved default (asserted), and the card waits 3600 s each time.
  • test_a_window_set_under_a_short_turn_ceiling_is_waited: a set 60 s under a 300 s ceiling is waited.
  • test_a_window_the_loader_pulls_under_the_turn_ceiling_is_waited_as_pulled: a written 500, 240 or 7200 under a 300 s ceiling and a written 700 under 660 s load as 240, 240, 240 and 600 (asserted), the figures a saved default can load as, and the card waits that figure.
  • test_an_omitted_window_under_a_short_turn_ceiling_keeps_the_full_cap: with the key omitted, at ceilings of 300, 659, 660 and 14400 s the loader leaves the field default (asserted), and the card waits 3600 s.
  • test_a_numeric_string_or_integral_float_window_is_read_as_the_loader_reads_it: under a 300 s ceiling "500" and 500.0 are a choice (240 s) and "600" and 600.0 are the default (3600 s).
  • test_a_malformed_window_under_a_short_turn_ceiling_keeps_the_full_cap: "soon", true, null and 5.5 load as the field default (asserted) and wait 3600 s under a 300 s ceiling.
  • test_the_window_is_read_from_the_two_documents_as_the_loader_merges_them: five splits of the ceiling and the window across config.json and config.local.json; the overlay wins key by key, for whether a window was written as well as for its number.
  • test_an_overlay_the_loader_cannot_use_leaves_the_window_in_the_base: invalid JSON, a JSON array and an empty file as config.local.json are ignored by the loader, and the window in config.json is waited (240 s under a 300 s ceiling, asserted).
  • test_a_window_between_the_default_and_the_cap_is_waited: a set 1000 s is waited.
  • test_a_window_set_in_the_local_overlay_is_waited: a 90 s window set only in config.local.json, which the loader merges over config.json, is waited.
  • test_a_configured_window_above_the_cap_is_capped: a set 7200 s is capped at 3600 s.
  • test_a_zero_window_is_raised_by_the_loader_not_replaced_by_the_cap: a hand-written 0 loads as 30 and waits 30 s.
  • test_a_window_written_as_the_default_is_read_as_unset: 599 and 601 are waited; a hand-written 600 waits 3600 s.
  • test_a_malformed_window_keeps_the_full_cap: a window of the wrong type falls back to the default in the loader and waits 3600 s.
  • test_an_unreadable_config_keeps_the_full_cap: a config read that raises waits 3600 s.

Manual verification

N/A: the change is the wait's window and the notice's text. The tests drive the real _stream_task approval path with a fake provider and an unanswered card.

Related Issues

None found for the ignored window. Searched PRs and issues, open and merged, for _APPROVAL_TIMEOUT_SECS, channel approval timeout, tool_approval_timeout_secs channel, channel approval card unanswered and approval window channel. Related, about the notice rather than the window: PR #15083, PR #13574, issue #10555. Of the 20 open PRs that touch src/kiro_crew/channel.py or the test file, git merge-tree gives the same conflicted files on origin/main with and without this branch for every one (four of them already conflict in src/kiro_crew/channel.py with origin/main alone), so this branch adds no conflict to any of them.

Pattern harvest

Rule candidate: review-prompt
Pattern: one surface honours a configured window through a shared helper while a sibling surface waits on its own constant for the same concept.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable): not applicable, the spec does not state the wait's length
  • No secrets, credentials, or internal references in the diff

@javenciu
javenciu requested review from a team and KiroCrewCaptain as code owners October 10, 2026 21:40
@javenciu
javenciu requested a review from cruisercohen October 10, 2026 21:40
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 1724cfff6d9a8ebe626c2f680646df2a9e225938 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🟡 CONCERNS

Premise-level review of 1724cfff6d9a8ebe626c2f680646df2a9e225938 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

Keeping the 3600 s default costs a second config reader in channel.py, and that reader quietly ignores a window typed as exactly 600.

Not justified as shipped

  • Item 3 — oversized: the only job of _written_approval_window is to tell the 600 that save() writes apart from a 600 someone chose, and it can't do that: "A window typed as exactly the default cannot be told from the saved one, so it keeps the 3600 s wait." So channel.py re-reads both config documents with the loader's private _deep_merge/_safe_int, and "600 means unset" becomes a rule people have to learn. The reason given for not reusing the shared resolver, that it "would reverse a layer", doesn't hold on base: slack/handler.py:95 and slack/renderer.py:46 already import dashboard.turn_dispatch.tool_approval_timeout_secs.
    Clears when: a maintainer accepts that a typed 600 is ignored as the price of keeping 3600 as the channel default, or the chosen-detection is removed.

What this change ships

Inventory (6 items) — 5 justified

Intent: let an operator's approval-timeout setting decide how long an unanswered channel approval card blocks the agent. FIX.

  1. A channel approval card waits the configured agent.tool_approval_timeout_secs, capped at 3600 s — justified
  2. The expired-card notice gives the window that was actually used — justified
  3. Whether a window was chosen is decided by re-reading config.json/config.local.json; a typed 600 counts as unset — oversized
  4. The window is read from config once per card, off the event loop — justified
  5. If config can't be read, the card waits 3600 s — justified
  6. The constant's comment now calls 3600 the cap and the default — justified

[FIRST-PRINCIPLES-REVIEWED] 1724cff

Description read

[DESCRIPTION-READ] 159ed8413a125a4215cdc07a3c299a68cb91b758a77e972123b639f73a0f51c5

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — 🟡 CONCERNS

Design-level review of 1724cfff6d9a8ebe626c2f680646df2a9e225938 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

channel.py re-parses the config files to guess whether the operator picked a window, so a typed 600 reads as unset and waits 3600 s.

Watch

  • A second config reader. The patch says _written_approval_window() "merges config.json and config.local.json with the loader's own _deep_merge… reads the number with the loader's own _safe_int." That puts a copy of config resolution in the channel layer, built from private loader helpers. It reads the files apart from the KiroCrewConfig.load() call beside it. Today's tests match the two up by hand, but nothing keeps them in step. If read_config_document() later adds a step this copy lacks (a migration, a key rename, a new layer), the code that decides "did they choose a window" and the code that supplies the number can disagree. The card then silently waits 3600 s, or the clamped value, against what the operator set.
    Clears when: the loader owns this decision: it exposes the operator-written value or whether one was written (for example a field next to tool_approval_timeout_secs, or None for unset), and channel.py imports no private loader helpers.
  • One setting means different things on different surfaces. In the PR's own words, a window "typed as exactly the default cannot be told from the saved one, so it keeps the 3600 s wait". So an operator who sets 600 gets 600 s on the dashboard and on Slack, but 3600 s on other channels. slack/handler.py:3465 and slack/renderer.py:377 already call the shared turn_dispatch.tool_approval_timeout_secs(), with no 3600 s default. That also weakens the stated reason for not reusing that helper here ("would reverse a layer").
    Clears when: the description explains why channel cards should keep a different default from Slack cards, or the channel path uses the same source and default as Slack.

Suggestions

  • If keeping 3600 s as the channel default is the real requirement, give it its own key, such as channel.approval_timeout_secs, instead of guessing intent from the shared key's value.

[DESIGN-REVIEWED] 1724cff

Description read

[DESCRIPTION-READ] 32cb05b7d705fad5147161ada57eef82209e20af7975fa0e01a811905811f039

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 1724cfff6d9a8ebe626c2f680646df2a9e225938 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 1724cff

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 1724cfff6d9a8ebe626c2f680646df2a9e225938 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1724cff

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 10, 2026
@javenciu
javenciu force-pushed the fix/channel-approval-honors-window branch from 43470ae to 2bd19b3 Compare October 11, 2026 09:49
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 11, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR makes a channel approval card wait agent.tool_approval_timeout_secs (capped at 3600 s) instead of a fixed 3600 s, and makes the expired notice quote the window it used. The goal is right, but the way it tells "unset" from "set" does not work. _channel_approval_window_secs (channel.py:1272) treats the key's presence in raw config.json as an operator choice. I confirmed that the gateway's first boot writes a default config with cfg.save (cli_server.py:2941), and save() publishes asdict(self.agent), so every install carries tool_approval_timeout_secs: 600 that nobody chose. loader.py:1470 already warns that "Presence cannot carry the meaning safely" for this reason. On an ordinary install, every channel card therefore drops from 3600 s to 600 s. That breaks the body's "Compatible: exactly as before" and its Not-a-goal of keeping the default. The tests miss it because they patch _raw_config with a hand-built dict instead of a save()-written file. The configured <= 0 branch is also dead, since the loader clamps to at least 30 s. Fix: decide from the value, not the key. Either resolve a channel default in the loader, or take the loaded value and list the default change as Breaking. Then add a test that a config written by KiroCrewConfig().save() still waits the intended default. — crew-pr-reviewer (deep re-check)

@javenciu
javenciu force-pushed the fix/channel-approval-honors-window branch from 2bd19b3 to 3b158d9 Compare October 12, 2026 09:04
@javenciu

Copy link
Copy Markdown
Contributor Author

Rebased onto main (0a47021, no conflict) and fixed in a new commit on top of the PR's. _channel_approval_window_secs now decides from the loaded value, because the key's presence cannot tell set from unset.

Presence is not a choice. src/kiro_crew/channel.py:1285-1296 reads KiroCrewConfig.load(). A window equal to the default reads as unset and waits the 3600 s cap, so a config written by save() keeps the old wait; any other value is the operator's window, capped at 3600 s. I took the route _embed_threads takes for its default (src/kiro_crew/embeddings.py:1081) rather than moving channels to 600 s, which keeps the Not-a-goal. The cost is in the body: a window typed as exactly 600 s keeps the 3600 s wait, while 599 s and 601 s are honoured. The same decision covers a case the review did not name: under a chat_turn_timeout_secs below 660 s the loader lowers the saved 600 (src/kiro_crew/config/loader.py:3043), and that lowered value also reads as unset. A malformed value, which the loader replaces with the default, waits the cap too. If you would rather have one window for both surfaces, dropping the default check is a small change that moves the default to 600 s; say so and I will make it and list it as Breaking.

Tests. They now write config.json with KiroCrewConfig().save(), or by hand for a typed value, and read it through the real loader. _raw_config is no longer patched, and only the unreadable-config case stubs the loader. test_a_config_saved_with_defaults_keeps_the_full_cap is the test you asked for: on the previous head it fails with assert [600] == [3600]. Previous head: 8 failed, 18 passed in each of 3 runs. This head: 26 passed in each of 3 runs. Together with the 21 other test files that import kiro_crew.channel and six that pin the config loader's bounds and the import boundaries: 828 passed.

Dead branch. Confirmed with a run: a configured 0, -5 or 10 loads as 30 (src/kiro_crew/config/loader.py:3169 clamps into 30..7200), so configured <= 0 never ran. The branch and the docstring's "not positive" claim are gone (src/kiro_crew/channel.py:1281-1282), and test_a_zero_window_is_raised_by_the_loader_not_replaced_by_the_cap pins that a 0 waits 30 s.

A second miss in the same check. The old test read config.json alone (_raw_config, src/kiro_crew/config/loader.py:1535), so a window set only in config.local.json was ignored although the loader merges that file over config.json. The loaded value is the merged one. test_a_window_set_in_the_local_overlay_is_waited pins it; on the previous head it fails with assert [3600] == [90].

An operator's window now reaching channel cards with no warning. No code change: that is the PR's intended effect for an operator who set a value, and the dashboard turn already waits that value. The body's Backwards compatibility section now says so. A config that was never edited, or holds only the saved default, keeps 3600 s. The review's own example, an operator who set 600 s, also keeps 3600 s, because 600 reads as the default.

The turn-ceiling clamp. Kept, and stated in the docstring (src/kiro_crew/channel.py:1281-1282) and the body. Reading the raw value with a 30..7200 clamp would need a second validator and would miss config.local.json (see above). The loader logs the clamp when it applies (src/kiro_crew/config/loader.py:3046).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 12, 2026
@javenciu

Copy link
Copy Markdown
Contributor Author

The new commit replaces the short fixed wait that the repo's wait-discipline ratchet (test/test_wait_discipline_ratchet.py) rejects in test/test_channel_approval_meta.py; it changes that file only.
The file counted 1 short fixed wait against a baseline of 0 and counts 0 again (one 5 s ceiling raised to 30 s); the ratchet passes on the head merged with main (c4c51aa), and the file passes 3 of 3 runs (26 tests each).

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 12, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 12, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 12, 2026
@javenciu
javenciu force-pushed the fix/channel-approval-honors-window branch 2 times, most recently from 11e9d72 to e0252f1 Compare October 12, 2026 20:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 12, 2026
@javenciu
javenciu enabled auto-merge (squash) October 12, 2026 22:49
@javenciu
javenciu requested a review from iamwhatever October 12, 2026 22:49

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR makes an unanswered channel approval card wait agent.tool_approval_timeout_secs (capped at 3600 s) instead of a fixed 3600 s, and makes the expiry notice quote the window it used. The new head e0252f1 fixes our earlier request: it decides from the loaded value instead of key presence, so a config written by save() keeps the 3600 s wait, the dead <=0 branch is gone, config.local.json is honoured, and the tests now go through a real save() and the real loader. But comparing the post-clamp loaded value with a recomputed default (channel.py:1285-1296) still mixes up the operator's choice with the loader's clamp, in both directions. I traced the two cases the Opus and GPT lanes raised on this head through loader.py:3179-3186 and both are real. (1) With chat_turn_timeout_secs=300 and tool_approval_timeout_secs=500, the loader clamps 500 to 240, which equals unset, so the card waits 3600 s; an operator who asked for a shorter window gets a 15x longer one, while 200 would be honoured. (2) With chat_turn_timeout_secs=300 and the key omitted, the clamp never runs (it only fires when the key is present), the loaded 600 does not equal unset (240), and the card expires at 600 s instead of keeping the 3600 s default. Neither has a posted disposition. Fix: decide "unset" from the merged raw value before the turn-ceiling clamp (key absent, or equal to the field default 600, means the 3600 s cap; otherwise use the loaded, clamped value, capped at 3600), drop the duplicated clamp formula, and add tests for the 300/500 and 300/absent cases. — crew-pr-reviewer (deep re-check)

A channel approval card waited a fixed _APPROVAL_TIMEOUT_SECS (3600 s)
before the host declined it, and never read
agent.tool_approval_timeout_secs, the documented window for how long a
turn waits for a human to answer a tool-approval prompt. The dashboard
turn honours that setting; on channels an operator who set 30 s still
had the agent parked for an hour, and the expired-card notice always
said "unanswered for 3600s".

_stream_task now reads the window once per card, off the loop and
inside the card's ownership scope, through the new
_channel_approval_window_secs: the configured value when the operator
set it, capped at 3600 s; 3600 s when the setting is absent, not
positive, or config cannot be read. The wait and the notice both use
that value. An expired card is still declined.
KiroCrewConfig.save writes every agent field, so a config.json nobody edited
already holds tool_approval_timeout_secs at its default, and the key's presence
says nothing about a choice. The loaded number says no more. The loader pulls
the window under the turn ceiling, so with chat_turn_timeout_secs at 300 a saved
600 and a written 500 both load as 240, and an omitted key loads as 600 because
the pull only runs on a present key.

The channel card now reads whether a number was chosen from config.json and
config.local.json merged the way the load merges them, with the number read the
way the load reads an integer, before any clamp. Absent, or equal to the default
of 600, is unset and the card waits the 3600 s cap as before. Any other number is
the operator's, and the card waits the loaded value, capped at 3600 s. The
recomputed default and its margin arithmetic leave channel.py. Exactly the
default cannot be pinned on a channel; any other number can.

The config.json read through _raw_config is gone, along with the "not positive"
branch: the loader raises a window under 30 s to 30 s, so that branch never ran.

The tests write config.json with KiroCrewConfig().save() or by hand and read it
through the real loader. They cover the saved default, a window the loader pulls
under a short turn ceiling, an omitted key under one, numeric spellings, a
malformed value, windows split across config.json and config.local.json, an
overlay the loader cannot use and a zero.
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 13, 2026
@javenciu
javenciu force-pushed the fix/channel-approval-honors-window branch from e0252f1 to 1724cff Compare October 13, 2026 01:10
@javenciu

Copy link
Copy Markdown
Contributor Author

Both cases are real, and the cause is wider than the two examples: comparing the loaded number with a recomputed default mixes the operator's choice with the loader's pull under the turn ceiling (src/kiro_crew/config/loader.py:3184-3186). I reproduced them against the real loader before changing anything. A written 500 under agent.chat_turn_timeout_secs: 300 loads as 240 and waited 3600 s. An omitted key under it loads as 600 and waited 600 s. The same comparison also misread a typed 240, a 7200, a 700 under a 660 s ceiling, a numeric string such as "500", and a malformed value under a short ceiling.

The amended second commit decides "unset" from the merged documents before the clamp, as the review asks:

  • _written_approval_window (src/kiro_crew/channel.py:1268) merges config.json and config.local.json with the loader's own _deep_merge and reads the key with the loader's own _safe_int (src/kiro_crew/channel.py:1279-1288). Absent, malformed, or equal to the field default of 600 means unset.
  • _channel_approval_window_secs (src/kiro_crew/channel.py:1291) waits the 3600 s cap while unset, and otherwise the loaded, clamped value capped at 3600 s (src/kiro_crew/channel.py:1311-1317). The recomputed default and the margin imports are gone from channel.py.

(1) A written 500 under a 300 s ceiling now waits the loaded 240 s: test_a_window_the_loader_pulls_under_the_turn_ceiling_is_waited_as_pulled[300-500-240].
(2) An omitted key under a 300 s ceiling now keeps the 3600 s cap: test_an_omitted_window_under_a_short_turn_ceiling_keeps_the_full_cap[300].

Both go through KiroCrewConfig().save() or a hand-written config.json and the real loader, in test/test_channel_approval_meta.py. The file also covers the typed 240, 7200 and 700 cases, numeric spellings, malformed values under a short ceiling, splits across config.local.json, and an overlay the loader ignores. Against the previous head 19 of its 51 tests fail; on this head all 51 pass, 3 of 3 serial runs each. Eight one-line mutations of the helper are each caught by at least one test. The wait-discipline ratchet passes on the head merged with main.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 13, 2026
@javenciu
javenciu requested a review from iamwhatever October 13, 2026 02:19

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR makes an unanswered channel approval card wait the operator's agent.tool_approval_timeout_secs (capped at 3600 s) instead of a fixed 3600 s, and the expiry notice now quotes the window it actually used. The new head 1724cff does what our last change request asked: _written_approval_window (channel.py:1268) decides "unset" from the merged config.json + config.local.json value BEFORE the loader's turn-ceiling clamp, and _channel_approval_window_secs then waits the loaded, clamped value capped at 3600 s. I traced both cases from our review through loader.py:3179-3186: a written 500 under a 300 s turn ceiling now waits the loaded 240 s, and an omitted key under that ceiling keeps the 3600 s cap. The read runs off the loop inside the post/wait ownership scope, and any config error falls back to the cap. I ran test/test_channel_approval_meta.py: 51 pass on the head, and 18 fail with main's channel.py swapped back in, so the tests prove the fix. The Design and First Principles CONCERNS (a second config reader built from loader helpers, and a typed 600 reading as unset) are real but advisory. The 600 trade-off is the one our review proposed and the docstring states it, so I accept it. The author should still post a disposition for each lane, and a loader-owned "was this written" flag would be a good follow-up. Checks are green and our earlier change request is fully met. — crew-pr-reviewer (deep re-check)

@javenciu
javenciu merged commit 86d3b23 into kirodotdev:main Oct 13, 2026
105 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants