Skip to content

Align runtime policy and standard turn harness across execution paths#1408

Open
chumyin wants to merge 1 commit into
devfrom
codex/agent-runtime-loop-autonomy-maturity-20260425
Open

Align runtime policy and standard turn harness across execution paths#1408
chumyin wants to merge 1 commit into
devfrom
codex/agent-runtime-loop-autonomy-maturity-20260425

Conversation

@chumyin
Copy link
Copy Markdown
Collaborator

@chumyin chumyin commented Apr 25, 2026

Summary

  • Problem:
    Runtime-scoped tool policy and standard turn execution had drifted across multiple surfaces, which made autonomy behavior harder to reason about and increased the risk of per-surface divergence.
  • Why it matters:
    The runtime should stay governed and flexible through one coherent policy path, and operator/runtime-truth surfaces need direct coverage when they summarize checkpoint state.
  • What changed:
    Introduced a typed SessionToolRuntimePolicy, reused it across conversation bootstrap and session status/runtime surfaces, refactored standard non-ACP agent_runtime result shaping through shared helpers, and added explicit turn-checkpoint renderer tests in session_runtime_truth_cli.rs.
  • What did not change (scope boundary):
    No broad turn-loop / turn-coordinator redesign, no new config knobs, and no unrelated channel/provider/browser work.

Linked Issues

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Security hardening
  • CI / workflow / release

Touched Areas

  • Kernel / policy / approvals
  • Contracts / protocol / spec
  • Daemon / CLI / install
  • Providers / routing
  • Tools
  • Browser automation
  • Channels / integrations
  • ACP / conversation / session runtime
  • Memory / context assembly
  • Config / migration / onboarding
  • Docs / contributor workflow
  • CI / release / workflows

Risk Track

  • Track A (routine / low-risk)
  • Track B (higher-risk / policy-impacting)

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • Rust tests match the touched packages / feature surface (for example cargo test --workspace --locked, cargo test --workspace --all-features --locked, task verify, task verify:changed, or equivalent exact commands documented below)
  • If full workspace / all-features Rust tests were not run locally, explain why and cite CI evidence or a known baseline blocker
  • Relevant architecture / dep-graph / docs checks for touched areas
  • Additional scenario, benchmark, or manual checks when behavior changed
  • If this changes config/env fallback, limits, or defaults: include before/after behavior and regression coverage for explicit path, fallback path, and boundary values
  • If tests mutate process-global env: document how state is restored or serialized

Commands and evidence:

rustfmt --check crates/app/src/tools/runtime_config.rs crates/app/src/conversation/runtime.rs crates/app/src/tools/session.rs crates/app/src/agent_runtime.rs crates/daemon/src/session_runtime_truth_cli.rs
./scripts/cargo-local-toolchain.sh test -p loong-app session_tool_runtime_policy -- --nocapture
./scripts/cargo-local-toolchain.sh test -p loong render_turn_checkpoint_summary --lib
./scripts/cargo-local-toolchain.sh check -p loong-app --lib
./scripts/cargo-local-toolchain.sh clippy -p loong-app --lib -- -D warnings

Results:

  • session_tool_runtime_policy tests passed in the clean isolated worktree.
  • render_turn_checkpoint_summary daemon tests passed in the clean isolated worktree.
  • loong-app library check passed.
  • loong-app library clippy -D warnings passed.
  • I did not run full workspace/all-features verification on this machine because isolated builds hit disk exhaustion under /private/tmp; this PR intentionally stays on the touched runtime seam.

User-visible / Operator-visible Changes

  • Session-scoped tool/runtime policy is now represented through a typed runtime policy path.
  • Standard non-ACP runtime turns reuse shared result-shaping helpers instead of per-path duplication.
  • Turn-checkpoint runtime-truth summaries now have explicit daemon unit coverage.

Failure Recovery

  • Fast rollback or disable path:
    Revert this commit if session-policy overlay or runtime-truth summary behavior regresses.
  • Observable failure symptoms reviewers should watch for:
    Session tool policy status diverging from conversation bootstrap behavior, or checkpoint runtime-truth summaries changing unexpectedly.

Reviewer Focus

  • crates/app/src/tools/runtime_config.rs: SessionToolRuntimePolicy shape and semantics.
  • crates/app/src/conversation/runtime.rs and crates/app/src/tools/session.rs: shared session-policy overlay application.
  • crates/app/src/agent_runtime.rs: standard non-ACP turn helper/result-shaping consolidation.
  • crates/daemon/src/session_runtime_truth_cli.rs: turn-checkpoint renderer coverage and behavior.

Session-scoped tool policy and standard turn execution had drifted into separate per-surface helpers. This consolidates the session policy overlay behind a typed SessionToolRuntimePolicy, reuses shared result-shaping for the standard runtime path, and adds daemon coverage for turn-checkpoint summary rendering so operator-facing runtime truth stays audited.

Constraint: The change had to stay inside the runtime/policy seam and remain isolated from unrelated dirty work in the primary tree
Rejected: Broader turn loop / turn coordinator refactor | too wide for this maturity pass and not required to remove the observed drift
Confidence: high
Scope-risk: moderate
Directive: Extend session-scoped runtime policy through SessionToolRuntimePolicy and shared turn helpers before adding new per-surface overlay or result-shaping code
Tested: rustfmt --check crates/app/src/tools/runtime_config.rs crates/app/src/conversation/runtime.rs crates/app/src/tools/session.rs crates/app/src/agent_runtime.rs crates/daemon/src/session_runtime_truth_cli.rs
Tested: ./scripts/cargo-local-toolchain.sh test -p loong-app session_tool_runtime_policy -- --nocapture
Tested: ./scripts/cargo-local-toolchain.sh test -p loong render_turn_checkpoint_summary --lib
Tested: ./scripts/cargo-local-toolchain.sh check -p loong-app --lib
Tested: ./scripts/cargo-local-toolchain.sh clippy -p loong-app --lib -- -D warnings
Not-tested: Full workspace / all-features verification on this machine due disk pressure in /private/tmp during isolated builds
@github-actions github-actions Bot added daemon Daemon binary, CLI entrypoints, and install flow. tools Tool runtime, policy adapters, and tool catalog behavior. conversation Conversation runtime, session flow, and prompt assembly. size: M Medium pull request: 201-500 changed lines. labels Apr 25, 2026
@chumyin chumyin marked this pull request as ready for review April 25, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conversation Conversation runtime, session flow, and prompt assembly. daemon Daemon binary, CLI entrypoints, and install flow. size: M Medium pull request: 201-500 changed lines. tools Tool runtime, policy adapters, and tool catalog behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: align runtime policy and standard turn harness across execution paths

1 participant