Skip to content

policy_fn: make verdict timeouts configurable - #296

Merged
congwang-mk merged 1 commit into
mainfrom
approval-timeout-288
Oct 13, 2026
Merged

congwang-mk merged 1 commit into
mainfrom
approval-timeout-288

Conversation

@congwang-mk

Copy link
Copy Markdown
Contributor

Held policy verdicts currently expire after five seconds, which is too short for interactive human approval. This change makes the timeout configurable, including an unlimited wait, while preserving the five-second default.

Callback configuration now lives in PolicyFn in Rust, Python and Go. The C setter receives the callback and timeout together. This deliberately changes the SDK API without compatibility aliases before 1.0.

Shutdown cancels pending verdicts through CancellationToken, discards queued callbacks and joins the callback worker before releasing its data. Active callbacks can check cancellation cooperatively. Startup also allows approvals that exceed the previous five-second ceiling.

Validation:

  • Added coverage for finite and unlimited waits, shutdown, and SDK configuration.
  • Python: 650 passed, 15 skipped; Go suite passed before the final CancellationToken refactor.
  • Stopped the full Rust run due to low local disk space. No local builds or tests after the final refactor; GitHub CI will validate the final commit.
  • Diff whitespace checks passed.

Fixes #288

Held policy verdicts always expired after five seconds, leaving too
little time for interactive human approval.

Group callbacks and verdict timeouts in PolicyFn across Rust, Python
and Go. Keep the five-second default and allow an unlimited wait.
Pass the timeout alongside the callback through the C API and update
the examples and documentation for the new configuration.

Use CancellationToken to cancel pending verdicts on sandbox shutdown.
Discard expired and queued callbacks, expose cancellation to active
callbacks, and join the worker before releasing callback data. Allow
long approvals during startup without the old five-second ceiling.

Add coverage for deadlines, unlimited waits, cancellation and SDK
configuration. Final validation is delegated to GitHub CI because
local disk space is low.

Fixes #288

Signed-off-by: Cong Wang <cwang@multikernel.io>
@congwang-mk
congwang-mk merged commit 96011d2 into main Oct 13, 2026
23 checks passed
@congwang-mk
congwang-mk deleted the approval-timeout-288 branch October 13, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

policy_fn: make approval timeouts configurable

1 participant