refactor(core_host): port the embedded core onto openhuman_core::Harness - #278
Draft
senamakel wants to merge 37 commits into
Draft
refactor(core_host): port the embedded core onto openhuman_core::Harness#278senamakel wants to merge 37 commits into
senamakel wants to merge 37 commits into
Conversation
Updated the pinned commit of the openhuman vendored dependency to include the latest upstream changes. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the tinyflows dependency to version 0.8 while keeping the "mock" feature enabled, picking up the latest bug fixes and improvements from the upstream crate. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the Cargo.lock file to reflect changes in dependencies, ensuring the lockfile remains in sync with the current Cargo.toml. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
…ate conflict The vendored tinycortex depends on tinymemory-api via a git URL, which caused Cargo to resolve it as a separate crate from the path copy in the vendor tree, producing type mismatch errors. This patch mirrors the entry from openhuman's own manifest, rebased onto the vendor path structure, to ensure both references resolve to the same crate. Also removes the stale tinyjuice entry. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Removed the duplicate git-sourced entry for tinymemory-api 0.1.1 and replaced all references to it with the local version, eliminating the need for a separate patched dependency. Also removed an unused patch entry for tinyjuice. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
When resolving a hostname, the code now checks for a missing host field and returns an appropriate error instead of panicking or producing an incorrect result. This ensures robust behavior when the host field is absent from the configuration. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
When the hostname field is absent from the host info response, the SDK now returns an empty string instead of failing to parse the response. This ensures compatibility with hosts that do not provide a hostname. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
When the hostname field is absent from the host info response, the SDK now returns an empty string instead of failing to parse the response. This prevents a crash when connecting to hosts that do not provide a hostname. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the openhuman vendor dependency to a newer version that includes a fix for a host-side crash when processing malformed input packets. The previous version did not properly validate packet boundaries, which could lead to a buffer over-read under certain conditions. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a fallback for when the hostname field is absent in the shared host context, defaulting to an empty string instead of failing. This prevents crashes in environments where the hostname is not provided. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
When resolving a hostname, the code now correctly handles the case where no host is present in the URI, preventing a panic that occurred when attempting to unwrap an empty host string. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Replaced the separate `bind_from_config`, `bind_workspace`, and `bind_action_dir` calls with a single `CoreSettings` struct that is resolved and installed atomically. This makes the core's configuration path explicit and consistent across the MCP server and local workflow host, and the first-writer-wins semantics prevent a late startup from overwriting settings that a more complete path already published. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a TokioTaskRunner to the capabilities builder so that spawn nodes run concurrently with their collecting gates, and set approvals to None with a comment explaining that the feature works through the existing resume mechanism even though the push surface is not yet implemented. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
…iew node kinds Extend the graph rendering helpers to support the new node kinds introduced in tinyflows 0.8. The wire names use the enum's snake_case serde spelling so they match what a saved document carries, the glyphs use arrows and symbols that convey the direction of branching or the need for human interaction, and the colour assignments keep concurrency nodes in the yellow control-flow group while placing the approval node in green alongside the entry point. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add explicit arms for Socket.IO transport failures in the `From<tinyhumans_sdk::Error>` implementation for `ClientError`, mapping them to `ClientError::Api` with no status or error code. This ensures that connection-level failures are reported as transport issues rather than API refusals, and that any future socket variant will cause a compile error until deliberately classified. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds descriptive fallback text for spawn, scatter, gather, gate, approval, and void nodes in the node summary function. Each node kind now returns a meaningful label that captures its purpose, such as "ticket" for spawns or "items" for scatters, making the graph more informative at a glance. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The turn construction is migrated from a `serde_json::json!` literal and task-local scopes to a typed builder on the harness, which owns the contract with `AgentChatParams` and eliminates silent runtime failures from field name mismatches. The origin scope and progress sink are now composed through the builder rather than as separate wrappers, and the ad-hoc `reply_text` helper is removed in favour of a structured `reply` field on the outcome. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Renamed the variable `core` to `harness` in the OpenHuman task execution function to better reflect that the value returned by `shared_with_hooks` is a harness rather than a core instance, improving code readability and reducing confusion about the variable's purpose. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Convert the error to a string before emitting it to the sink, ensuring the error message is consistently reported as a sentence across all harnesses. This avoids callers needing to know which harness produced the error, as `CoreError`'s `Display` already provides the method and domain message that operators read. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
…ngs value Replace four separate `std::env::set_var` calls and their associated binding functions with a single `CoreSettings` value that is resolved once and then installed for the embedded core. This eliminates the mutation of the current process's environment to configure an in-process library, keeping environment variables only for the child-process snapshot where they are genuinely needed. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The app loop now accesses authentication through the core's typed facade instead of free functions, and the boot process returns a harness that owns the core's lifetime. This simplifies the ownership model by keeping the harness alive while allowing the core to be cloned for shared use, and makes the auth API consistent across the codebase. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The login flow now extracts a harness from the pending core and clones the core from it, ensuring the shared install and runtime use the harness wrapper instead of the raw core. This preserves the harness context needed for proper lifecycle management during the sign-in process. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Re-exports `Session` and `Harness` from the core host module so that workspace crates like the TUI can reference them without a direct dependency on the `openhuman` crate, matching the existing pattern used for `AuthState`. The TUI call site is updated to use the new re-exported path. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Replace the pattern of binding individual environment variables for workspace, action directory, and API URLs with a single `CoreSettings::resolve` call that produces a settings object passed directly to `boot_for_auth` and `boot_with_hooks`. This eliminates the risk of mismatched bindings when the same configuration is used across multiple call sites, and makes the settings flow explicit rather than relying on ambient environment variables. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The `Harness` type was imported but never used in the module, causing a compiler warning. Removing it cleans up the unused import. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
… relogin The `AuthState` type was previously accessed through the nested `medulla::core_host::auth` module path, but has been re-exported at the `medulla::core_host` level. All references across the TUI crate and its tests are updated to use the shorter path. In the relogin flow, the harness now wraps the core in an `Arc` before passing it to the relogin function, ensuring the core's lifetime is properly managed by the harness. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Removed the hand-written `core_host::auth` module that wrapped the core's auth RPCs through `Core::raw`, and replaced all call sites with the new typed `core.auth()` facade. The old module existed as a bridge until the upstream core exposed a proper typed auth surface; that surface now exists, so the bridge is no longer needed. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
…on functions The workspace, action directory, and backend URL functions no longer write to the process environment; they return a `CoreSettings` struct instead. This removes the global mutex that serialised the test suite and lets every test case run in parallel. The old `bind_from_config` and `classify` helpers are replaced by `CoreSettings::resolve` and `CoreSettings::floor`, and the Medulla readiness classification tests were removed because they tested a function that no longer exists. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The `reply_text` function was re-exported from the run module under a `#[cfg(test)]` guard, but the only consumer was the test module itself, which imported it directly from the sibling module. Removing the conditional re-export eliminates a dead-code warning in non-test builds without affecting test coverage. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformat several chained method calls across the SDK and TUI to place each call on its own line, improving readability and aligning with the project's established style. Also collapse a multi-line function signature in `resolve_action_dir` to a single line for consistency with nearby declarations. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The variable `workspace_roots` was computed from the loaded configuration but never used anywhere in the application loop, so it has been removed to eliminate dead code and reduce unnecessary allocations. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The re-export of `with_progress_sink` from `core_contract.rs` was removed because it is no longer needed by external consumers, and the unused `serde_json::json` import was removed from the test file to eliminate a compiler warning. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
…ess` pattern The module documentation for `with_progress_sink` was outdated: the sink is now passed as an argument to `Turn::on_progress` rather than scoped by hand via a `tokio::task_local`. The doc block is updated to explain that the provider no longer needs to know about the scoping mechanism, and to clarify that `with_turn_cwd` remains manually scoped because it is read by Medulla's lifecycle hooks rather than by the core. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the pinned commit for the openhuman subproject to include the latest changes from its upstream repository. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Removed an unnecessary blank line between the use statements in the test file to improve code consistency and readability. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the pinned commit for the openhuman vendored subproject to include the latest upstream changes. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
openhuman_core::Harnessand the new typedembed::Core::agent()/auth()facades from openhuman#5668.core_host/auth.rsand its tests (222 lines). Every caller usescore.auth(); medulla's privateAuthStateprojection becomes a re-export of the core's.std::env::set_varcalls that configured the core.CoreSettings::resolve(env, config, home)returns a value;boot(settings)takes it.harness.turn(..).session(..).cwd(..).model(..).route(..).origin(..).on_progress(..).send(), deletingreply_textandscoped_originalong with both private copies of theRpcOutcomeenvelope heuristic.vendor/openhumanby 1047 commits (v0.63.7-era → v0.63.17 + #5668), with the manifest and API updates that requires.Net on the ported files: −854 / +553 lines.
Problem
Running one agent turn through the embedded core took ~2,100 lines of glue across 17 ordered steps, and the sharp edges were all in this repo's own comments:
std::env::set_varcalls, sequenced before a constructor they do not appear in, replicated at six call sites. Process-global, inherited by every child, and increasingly hostile in newer Rust editions.execution.rs:240documented thatAgentChatParamscarries norename_all, so the hand-built params depended on an unmarked naming coincidence — an upstream rename would fail silently at runtime.{result, logs}envelope unwrapper (auth.rsstrict,execution.rsloose).AuthStatemirror of the core's response, decoded by hand out of that envelope.core_host/tests.rsneeded a process-wide mutex and had to clear four environment variables around every case, because the functions under test wrote to the environment.Solution
Settings are values, not environment variables.
CoreSettings { workspace, action_dir, backend_url }is resolved once and handed toboot. The precedence is unchanged and still ours — an operator who exportedOPENHUMAN_WORKSPACEstill wins — but it is a parameter now instead of a convention about call ordering.One nuance worth reviewing: the lazy boot path genuinely has no caller to hand settings to (a workflow
agentnode runs deep inside the engine, and the dispatch signature belongs to every harness). That is replaced by a typedOnceLock<CoreSettings>incore_host. Still process-global — same problem — but the blast radius changes: a cell this crate owns affects this process's core, whereOPENHUMAN_WORKSPACEaffected every library in the process and every child it spawned.The TUI still writes those variables into its child-process env snapshot, and should: OpenHuman's picker entry and the harness CLIs are spawned processes. What changed is that we no longer mutate this process's environment to talk to a library living inside it.
backend_urlalso collapses two bindings into one — with noOPENHUMAN_MEDULLA_BASE_URLoverride, the core's Medulla client falls through to the sameapi_url.Two things deliberately not folded in:
with_turn_cwdis still scoped by hand. It is read by Medulla's process-global lifecycle hooks, not by the core, so there is nothing upstream that could take it as an argument.boot_for_authkeeps usingCoreBuilderrather thanHarness. It is a short-lived core for one question, and claiming the process's single harness slot for it would refuse a later real boot in the same process.The vendor bump is unrelated churn but unavoidable, since the new API lives upstream. It cost:
tinyflows0.6→0.8[patch."https://github.com/tinyhumansai/tinymemory"]tinymemory-apiresolves as both a git copy (viatinycortex) and a path copy, producing a wall of E0308s about twoMemoryTainttypestinyjuicepatchNodeKindvariants covered in 4 matchesSpawn/Scatter/Gather/Gate/Approval/VoidCapabilitiesfieldstasksset to the engine'sTokioTaskRunnersospawn/gategenuinely overlap;approvals: Noneuntil we have a review surface to push atCommit history is the
auto-commithook's granular checkpoints, left as-is rather than squashed.Impact
DomainSet::embedded()/ServiceSet::embedded()), same one-core-per-process rule — now enforced from both sides, sinceHarness::buildreturnsAlreadyRunningrather than silently sharing process-global state.core_host/tests.rswent 295 → 189 lines and lost its environment mutex entirely — the cases are independent values now and run in parallel. That the lock could be deleted is the point of the change, not a side effect.Validation
cargo test --workspace— 70 test binaries, 0 failurescargo clippy --workspace --all-targets— cleancargo fmt --all --check— cleanRelated
vendor/openhumanatmainonce #5668 lands, then mark ready