Skip to content

fix(agent): build the hosted base with the session's own policy - #8576

Merged
senamakel merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/ts-e2e-027-no-placeholder-policy
Nov 6, 2026
Merged

senamakel merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/ts-e2e-027-no-placeholder-policy

Conversation

@M3gA-Mind

Copy link
Copy Markdown
Collaborator

Summary

  • Every agent turn logged "[openhuman:policy] autonomy policy DISABLED ([autonomy] enabled = false)", even with the policy enabled. The line came from a stand-in policy that the session builder made from Config::default() and then discarded.
  • build_session now hands the builder the policy its tools were built with, so no stand-in is made and the log reflects the session's real policy.

Problem

  • SessionHostBuilder::build (builder_build.rs) gave the hosted base a SecurityPolicy::from_config built from runtime_config. That config is the default for production sessions, so from_config logged the policy as disabled.
  • build_session.rs then replaced the hosted base with one carrying the session's own policy.
  • The stand-in was never used, but its log line misled anyone reading a turn's logs. It sent the TinySecurity E2E review down the wrong path while diagnosing TS-E2E-025.
  • Found by the TinySecurity E2E review (TS-E2E-027).

Solution

  • A pub(crate) SessionHostBuilder::security_policy setter. When it is set, build uses it for the hosted base; otherwise it builds the config-derived policy as before, so other builder callers are unchanged.
  • build_session passes Arc::clone(&security), the instance its tools hold and the one it already installs afterwards.
  • No behaviour change: the hosted base ends up with the same Arc as before. Only the discarded stand-in, and its log line, are gone.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy: the_hosted_base_carries_the_policy_the_caller_built pins that the built hosted base carries the caller's policy (Arc::ptr_eq). The unset path is covered by the existing builder tests.
  • Diff coverage ≥ 80%: the setter and both build branches are covered by builder tests. The one-line build_session call runs in the existing session suites. CI's diff-cover decides.
  • N/A: no feature row added, removed or renamed in docs/TEST-COVERAGE-MATRIX.md.
  • N/A: no matrix feature IDs affected; the review finding is listed under Related.
  • No new external network dependencies introduced.
  • N/A: no release-cut surface changes (docs/RELEASE-MANUAL-SMOKE.md).
  • N/A: no GitHub issue tracks this. It is TinySecurity E2E review finding TS-E2E-027.

Tests and red control

  • Red control: build ignores the setter, as on main. The new test fails at "the hosted base must carry the caller's policy, not a stand-in".

Validation (cuttlefish, CF-W1-fix-027-1)

Check This PR (ddc04c9) main (6043171)
cargo fmt --check green —
pnpm rust:layout red only on artifacts/tiny_store_tests.rs 784/750, pre-existing (fixed by #8560) same
process-statics / module-boundaries green / green —
cargo check --locked, core without / with security-module green / green —
clippy -D warnings 19 errors, 0 new 19
agent::session_host::builder::builder_tests::session_definition_tests::the_hosted_base_carries_the_policy_the_caller_built pass n/a (new)
red control (build ignores the setter) fails: "the hosted base must carry the caller's policy, not a stand-in" —
agent::session_host:: (one process) 236 passed, 19 failed 235 passed, 19 failed: the same 19

The 19 agent::session_host:: failures are pre-existing and identical on main. This PR adds none.

Impact

  • Logs only: turns no longer log a disabled policy that is not in force. One fewer SecurityPolicy is built per session.

Related

  • TS-E2E finding: TS-E2E-027 (a misleading per-turn "autonomy policy DISABLED" log).
  • Follow-up PR(s)/TODOs: none.

AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/ts-e2e-027-no-placeholder-policy
  • Commit SHA: ddc04c9089729f3cea26b1eccf0e071ce042ada2

Validation Run

  • N/A: pnpm --filter openhuman-app format:check, no frontend change
  • N/A: pnpm typecheck, no TypeScript change
  • Focused tests: on cuttlefish (see table)
  • Rust fmt/check (if changed): on cuttlefish (see table)
  • N/A: Tauri fmt/check, no shell change

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: none; the hosted base carries the same policy as before.
  • User-visible effect: none; one misleading log line per turn is gone.

Parity Contract

  • Legacy behavior preserved: builder callers without a policy keep the config-derived one.
  • Guard/fallback/dispatch parity checks: N/A

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none
  • Canonical PR: this
  • Resolution (closed/superseded/updated): N/A

build() gave the hosted base a stand-in policy from Config::default(),
which build_session then replaced. Building it logged "autonomy policy
DISABLED" on every turn, even with the policy enabled. build_session now
passes the policy its tools were built with, so no stand-in is made; other
builder callers keep the config-derived policy.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 5 billable files and costs up to $1.25.

Or wait 50 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a041aed-7f3a-42f9-a4ff-55d6f998288f
Commits

Reviewing files that changed from the base of the PR and between 6043171 and ddc04c9.

Files selected for processing: 5

  • crates/openhuman-core/src/agent/session_host/builder/builder_build.rs
  • crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs
  • crates/openhuman-core/src/agent/session_host/builder/factory/build_session.rs
  • crates/openhuman-core/src/agent/session_host/builder/setters.rs
  • crates/openhuman-core/src/agent/session_host/builder_config.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T06:06:38.976041Z ddc04c9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tinysweeper

tinysweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Reviewed head: ddc04c9089729f3cea26b1eccf0e071ce042ada2

Verdict: Ready for maintainer review · Priority: none
Coverage: Reviewed 5 of 5 files.
Pull request purpose (title): fix(agent): build th…

Diagnostics and supporting details

Full summary

Pull request purpose (title): fix(agent): build the hosted base with the session's own policy. This pull request stops the session builder from manufacturing and then discarding a stand-in security policy whose log line falsely reported an autonomy policy as disabled on every agent turn. The builder gains a setter that lets a caller supply the session's own policy, `build` uses that policy for the hosted base when supplied and otherwise derives one from config exactly as before, and `build_session` passes its existing `Arc` through so the hosted base carries the same instance.

Review snapshot

Change surface Files Review signal Count
Production 4 Active findings 0
Tests 1 Noted findings 0
Documentation 0 Resolved findings 0
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

What changed

`SessionHostBuilder` now carries an optional `security_policy` field alongside `runtime_config`, defaulted to `None` in the builder's `new`, with a new `pub(crate) security_policy` setter that stores the caller's `Arc`. In `build`, the hosted base takes that policy when set and otherwise falls back to the previous `SecurityPolicy::from_config` construction, so builder callers that never call the setter behave as before. `build_session` supplies `Arc::clone(&security)` — the same instance its tools were built with and the one it already installs afterwards — so in that path the only observable change is that the discarded stand-in, and its misleading "autonomy policy DISABLED" line, are no longer produced. A new test asserts the hosted base holds the caller's policy by pointer identity. The latest-push delta is unavailable: the review state lacks a trusted base-to-head diff, so this describes the whole pull request and not a comparison against a previously reviewed head.

Features

  • Added — `SessionHostBuilder::security_policy` setter and backing field: Lets a caller hand the builder the policy the session's tools were already built with, exposed only crate-wide so external builder users are unaffected; the field initialises unset so existing construction paths keep working. (crates/openhuman-core/src/agent/session_host/builder/setters.rs impl SessionHostBuilder {, crates/openhuman-core/src/agent/session_host/builder_config.rs pub struct SessionHostBuilder {)
  • Modified — Hosted base policy selection in `SessionHostBuilder::build`: The hosted base now uses the caller-supplied policy when present and otherwise builds the config-derived policy as before, removing the throwaway stand-in and its per-turn disabled-policy log without changing other builder callers. (crates/openhuman-core/src/agent/session_host/builder/builder_build.rs impl SessionHostBuilder {)

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

Findings

No active actionable findings.

Before merge

None.

Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 5 files; 0 findings. _The code index is behind this pull request (indexed at `0ae5407d97f4`), so retrieved context may be out of date._

security

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 5 files; 0 findings. _The code index is behind this pull request (indexed at `0ae5407d97f4`), so retrieved context may be out of date._

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The tests lane answered with no findings, noting the new pointer-identity assertion prevents the fallback and the caller-supplied policy from being silently swapped, and that the unset path keeps the config-derived behaviour covered by the existing builder tests.
  • Lane summary: The change threads a caller-built `SecurityPolicy` through `SessionHostBuilder` into `OpenHumanHostBase` instead of always constructing a throwaway stand-in from config, and the new test `the_hosted_base_carries_the_policy_the_caller_built` genuinely pins that behaviour: `Arc::ptr_eq` against the caller's policy fails if the builder takes the `unwrap_or_else` fallback, so the fallback and the setter branch cannot silently swap. The factory pass-through is behaviourally narrower than the doc comment implies — in that path the hosted base is rebuilt with the same `security` Arc afterwards, so the only real effect there is not constructing the discarded stand-in (and its log line), which no test asserts — but that costs nothing and regresses nothing. No test file was left untouched despite the diff header's note. Nothing here warrants a blocking finding. _The code index is behind this pull request (indexed at `0ae5407d97f4`), so retrieved context may be out of date._

commits

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The commits lane answered with no sensitive content in committed files.
  • Lane summary: No sensitive content in committed files. _The code index is behind this pull request (indexed at `0ae5407d97f4`), so retrieved context may be out of date._

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The description matches the diff: it names the `SessionHostBuilder::security_policy` setter (with the promised `pub(crate)` visibility), the `build` branch that falls back to `SecurityPolicy::from_config` only when the setter is unset, the `build_session` call passing `Arc::clone(&security)`, and the new `Arc::ptr_eq` test, along with the red-control and validation notes. Nothing significant in the diff is left unmentioned, so the change is safe to merge as described. _The code index is behind this pull request (indexed at `0ae5407d97f4`), so retrieved context may be out of date._
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash
  • Spend: $0.016488
  • Tokens: 558876 input · 67241 output · 143360 cached · 216 embedding
  • Updated: 2026-11-06T06:14:32Z
Head State Pass summary
ddc04c908972 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-11-06T06:14:32Z)

tinysweeper 0.1.2

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

tinysweeper found nothing blocking. Approving.

Diagnostics

Total spend: $0.0165

@tinysweeper tinysweeper Bot added the priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. label Nov 6, 2026
@senamakel
senamakel merged commit 249de5c into tinyhumansai:main Nov 6, 2026
21 of 23 checks passed
M3gA-Mind added a commit to mysma-9403/openhuman that referenced this pull request Nov 9, 2026
Resolve the one conflict in builder_build.rs with tinyhumansai#8576, which added an
explicit security_policy override to the session builder. Keep the
caller's policy when one is set; otherwise fall back to this branch's
SecurityPolicy::for_config(&hosted_config), so the default policy still
carries the account root.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants