Skip to content

refactor(runtime): read components, profile capabilities and hook contexts from explicit contexts (#7801) - #7880

Merged
senamakel merged 34 commits into
tinyhumansai:mainfrom
senamakel:fu-7801e-9
Oct 15, 2026
Merged

senamakel merged 34 commits into
tinyhumansai:mainfrom
senamakel:fu-7801e-9

Conversation

@senamakel

Copy link
Copy Markdown
Member

Summary

Part of #7801 (child of #7523). Moves a first batch of CoreContext::current() / scoped() readers onto explicit DispatchCtx / Arc<CoreContext> carriers. No behaviour change: an explicit context resolves to what the ambient read returned.

  • DispatchCtx::components() / domains(); about_app list/lookup/search, the RPC component gate (disabled_component_for_method), tokenjuice gate, sandbox sandbox_component_off / sandbox_disabled_by_host / resolve_sandbox_policy, cron flow-schedule component check and the module callbacks install take a context.
  • ProfileCapabilities::in_ctx, ProfileProviderSettings::in_ctx replace current(); admits / authorizes_approval / profiles::tools::admits_in / gate_verdict read through a context. The search module proxy (execute_tool, list_tools, refresh_loaded) and apply_search_settings take one.
  • fire_hooks, TurnOriginScope (reads the tool run carrier), the channel graph turn, relay turn derivation, session memory profile capture and threads run_to_completion hand over the caller's context instead of reading current() / scoped().
  • load_config_with_timeout is now a thin DispatchCtx::ambient() wrapper.

Tests

  • New regression tests: run_to_completion_runs_under_the_explicit_context (explicit ctx wins over the task scope; two contexts do not cross, concurrent and across awaits), an_explicit_context_decides_which_capabilities_are_disabled (about_app), updated fired_hooks_observe_the_firing_dispatchs_core_context (explicit ctx, no task scope) and the memory-ingest profile capture tests (explicit ctx).
  • cargo test -p openhuman --lib: 9543 passed, 1 failed (platform::startup::ops::tests::workspace_startup_migrates_transcripts_once, known pre-existing).
  • saas_mode_e2e 19/19, saas_profile_isolation_e2e 3/3, embed saas_profiles pass.
  • Not run: json_rpc_e2e.

Gates

cargo check (default, --no-default-features -p openhuman, product features --workspace --all-targets, app manifest), cargo build -p openhuman-cli --bin openhuman-core, pnpm rust:layout, agent-runtime boundary check, process-statics check, SaaS ambient ratchet (baseline only lost entries / moved lines).

Remaining

Production CoreContext::current( 17, scoped( 6, spawn_scoped 49, scope( 39. spawn_scoped -> tokio::spawn and the production scope( wrappers cannot go until the remaining DispatchCtx::ambient() readers (approval gate, flows caps, session builders, MCP client table, AgentDefinitionRegistry::current(), resolve_backend_transport, registry visibility) have carriers.

Refs #7801, #7523

Adds operations and schemas for the about_app platform module, exposing
app metadata through the runtime dispatch context so callers can query
build and version information.

Auto-committed-on: dragonfly
The scheduler now routes the output of a scheduled run through the
delivery path so results reach the configured channel instead of being
dropped. This restores the expected behaviour for cron jobs that rely on
their output being sent.

Auto-committed-on: dragonfly
Dispatch now consults the components gate before routing to a component, so
requests for components that are not enabled are rejected early instead of
failing deeper in the pipeline.

Auto-committed-on: dragonfly
Added schema types for the tokenjuice inference path and wired them into the runtime module so callers can validate and construct tokenjuice payloads through the shared runtime surface.

Auto-committed-on: dragonfly
…tion

Sandbox policy resolution and the component gate now take the caller's
DispatchCtx instead of reading the ambient core context, so component
state is read from the context the call actually runs under. Callers in
the sandbox schemas, shell tool, and tests were updated to pass their
context through.

Auto-committed-on: dragonfly
…olution

The flow code capability now builds a single ambient dispatch context and
passes it to both policy resolution and sandbox execution instead of
constructing one inline. Tests were updated to supply the dispatch context
to sandbox_component_off, which now takes it as a parameter.

Auto-committed-on: dragonfly
Session transcripts are now fed into the memory pipeline as they are produced, so
conversations become searchable without a separate import step. Tests cover the
ingest path for runtime sessions.

Auto-committed-on: dragonfly
The relay ops module is no longer referenced anywhere, so it has been
deleted to keep the providers tree free of dead code.

Auto-committed-on: dragonfly
Introduce capability definitions and provider settings for profiles so
profile configuration can describe what a provider supports and how it
should be configured.

Auto-committed-on: dragonfly
Introduce capability and tool profile definitions so profiles can declare
which capabilities and tools they expose. This provides the foundation for
resolving per-profile permissions.

Auto-committed-on: dragonfly
Host agent dispatch now builds and drives turns through the session host
instead of the previous direct path, so host agents share the same turn
lifecycle and profile handling as other sessions. Supporting changes wire
the profile factory, turn parts, memory engine, and profile tools into
that flow.

Auto-committed-on: dragonfly
Host agents are now wired into the session host builder and profile factory so sessions can be constructed with a host agent, and turn parts startup passes the host agent through. This lets the runtime launch sessions backed by host agents instead of only the default agent.

Auto-committed-on: dragonfly
Search requests can now be routed through a configurable proxy, with the
setting threaded through the config ops, search bus, and tools. This lets
deployments behind restricted networks reach external search providers.

Auto-committed-on: dragonfly
…s,crates/openhuman-core/src/mod

Auto-committed-on: dragonfly
Introduce a graph-based harness for the agent, providing the structure
needed to model agent execution as a graph of steps.

Auto-committed-on: dragonfly
Add tests exercising the sandbox operations to lock in current
behaviour and catch regressions in the ops layer.

Auto-committed-on: dragonfly
Adds tests exercising the browser computer tool's action handling so
regressions in click, type, and navigation behaviour are caught early.

Auto-committed-on: dragonfly
Introduce a post-commit hook that lets the learning sink observe committed
runtime session state. This wires the agent hooks into the session host so
learning updates are captured after each commit.

Auto-committed-on: dragonfly
Cover the hook dispatch paths around tool call start and completion so
regressions in ordering and payload handling are caught.

Auto-committed-on: dragonfly
Add tool registration for the tinyagents agent so its tools are wired
up the same way as the other agent implementations.

Auto-committed-on: dragonfly
Add tool registration support for the tinyagents agent so its tools are
wired up alongside the other agent implementations.

Auto-committed-on: dragonfly
Deleting a thread now removes its associated data instead of leaving it
behind. The purge path was previously unreachable from the delete flow,
so orphaned records accumulated over time.

Auto-committed-on: dragonfly
Adds tests covering the about app operations and the thread title and
cancellation operations, extending existing test modules to exercise
these paths.

Auto-committed-on: dragonfly
Reordered the DispatchCtx import to keep the use block sorted and condensed the comment explaining why hosted profiles skip the config-derived tool belt. No behaviour change.

Auto-committed-on: dragonfly
Bind the ambient dispatch context to a local before checking profile
capabilities, so the same value can be reused instead of being constructed
inline in the condition.

Auto-committed-on: dragonfly
The comment on from_config_for_agent still described the operator-selected factory carrying registration and permission bounds, which no longer matches the code path. Shortened it to state only that a hosted profile skips the ordinary config-derived belt.

Auto-committed-on: dragonfly
The ambient-context baseline entries for several crates were dropped and
the remaining line numbers shifted, reflecting the removal of those
CoreContext::current() call sites from the source tree.

Auto-committed-on: dragonfly
Add tests covering host profile resolution in the embed crate to
verify the expected profile is selected for host environments.

Auto-committed-on: dragonfly
Update the public agent harness test to call fire_hooks with the new
DispatchCtx argument, keeping the test in sync with the changed signature.

Auto-committed-on: dragonfly
apply_search_settings now takes the caller's DispatchCtx instead of
constructing an ambient one, so the module refresh runs under the
correct tenant. The remaining changes are rustfmt reflows and import
ordering with no behaviour change.

Auto-committed-on: dragonfly
Update the vendored tinyconnectors submodule to a newer revision.

Auto-committed-on: dragonfly
Update the vendored tinyconnectors submodule to commit 00c5609.

Auto-committed-on: dragonfly
@tinysweeper

tinysweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

⚠️ Review failed for ed8d7767da87. the review of #7880 did not finish within 900s

@senamakel
senamakel merged commit 24c2bb6 into tinyhumansai:main Oct 15, 2026
13 of 14 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-10-15T15:44:51.210866Z ed8d776 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.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fb588ff1-c774-4f98-a2a8-b9487f6f9114
📥 Commits

Reviewing files that changed from the base of the PR and between f6ae997 and ed8d776.

📒 Files selected for processing: 48
  • crates/openhuman-core/src/agent/harness/graph.rs
  • crates/openhuman-core/src/agent/hooks.rs
  • crates/openhuman-core/src/agent/hooks_tests.rs
  • crates/openhuman-core/src/agent/host_agents.rs
  • crates/openhuman-core/src/agent/session_host/builder/factory.rs
  • crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs
  • crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
  • crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs
  • crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
  • crates/openhuman-core/src/agent/tinyagents/host/learning_sink.rs
  • crates/openhuman-core/src/agent/tinyagents/tool_registration.rs
  • crates/openhuman-core/src/channels/providers/relay/ops.rs
  • crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
  • crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
  • crates/openhuman-core/src/config/ops/loader/load.rs
  • crates/openhuman-core/src/config/ops/search.rs
  • crates/openhuman-core/src/config/ops_loader_and_search_tests.rs
  • crates/openhuman-core/src/core/all/components_gate.rs
  • crates/openhuman-core/src/core/dispatch.rs
  • crates/openhuman-core/src/core/runtime/dispatch_ctx.rs
  • crates/openhuman-core/src/cron/scheduler/run_delivery.rs
  • crates/openhuman-core/src/flows/tinyflows/caps/code.rs
  • crates/openhuman-core/src/inference/tokenjuice/schemas.rs
  • crates/openhuman-core/src/memory/engine.rs
  • crates/openhuman-core/src/modules/runtime.rs
  • crates/openhuman-core/src/modules/search/proxy.rs
  • crates/openhuman-core/src/modules/search/proxy_tests.rs
  • crates/openhuman-core/src/platform/about_app/ops.rs
  • crates/openhuman-core/src/platform/about_app/ops_tests.rs
  • crates/openhuman-core/src/platform/about_app/schemas.rs
  • crates/openhuman-core/src/profiles/capabilities.rs
  • crates/openhuman-core/src/profiles/provider_settings.rs
  • crates/openhuman-core/src/profiles/tools.rs
  • crates/openhuman-core/src/sandbox/ops.rs
  • crates/openhuman-core/src/sandbox/ops_tests.rs
  • crates/openhuman-core/src/sandbox/schemas.rs
  • crates/openhuman-core/src/search/bus.rs
  • crates/openhuman-core/src/search/tools.rs
  • crates/openhuman-core/src/threads/ops/crud.rs
  • crates/openhuman-core/src/threads/ops/purge.rs
  • crates/openhuman-core/src/threads/ops/support.rs
  • crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rs
  • crates/openhuman-core/src/tinymemes/search.rs
  • crates/openhuman-core/src/tools/impl/system/shell.rs
  • crates/openhuman-core/src/tools/schemas/web_search.rs
  • crates/openhuman-embed/src/profiles/host_tests.rs
  • scripts/ci/saas-ambient-baseline.json
  • tests/in_process/agent_harness_public.rs
+---------------------------------------+
| `NaN` is not a valid user experience. |
+---------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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.

1 participant