Skip to content

feat: kernelize openhuman — cut the workflow dependency floor 418→280 and invert the composio back-edge - #5314

Merged
senamakel merged 114 commits into
tinyhumansai:mainfrom
senamakel:kernelize-openhuman
Aug 2, 2026
Merged

senamakel merged 114 commits into
tinyhumansai:mainfrom
senamakel:kernelize-openhuman

Conversation

@senamakel

@senamakel senamakel commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Reduces the workflow-kernel dependency floor from 418 to 280 crate names (−138) across seven feature gates, each verified against the resolved normal-edge dependency graph.
  • Splits the 5,830-line tinyflows/caps.rs into 11 focused modules and inverts the composiotinyflows back-edge, so the always-compiled Composio domain no longer reaches into a feature-gated adapter seam.
  • Adds a measured, CI-enforced floor ratchet (scripts/kernel-floor.sh, check-kernel-floor.sh, dep-sim.py, assert-shed.sh) so the floor cannot silently regress.
  • Introduces prediction-markets (Polymarket) and moves the EVM stack into web3; gates tinychannels' email/lark providers via the companion PR.
  • Corrects two AGENTS.md claims that were blocking this work, and adds license = "GPL-3.0-only" (the crate had none).
  • Fixes a latent capability gap: the Composio contract gate now works in flows-off builds, where it previously degraded to a silent no-op.

Problem

openhuman is intended to be embeddable, but --no-default-features --features flows still resolved 418 crates. Six features shed zero dependencies (media, meet, skills, mcp, medulla, channels), Composio had no feature at all despite 36k LOC, and seven heavy dependencies were unconditional — including arboard/enigo (an X11 clipboard and synthetic-input stack) in a build that only wants workflow execution.

Two AGENTS.md paragraphs marked "do NOT re-litigate" asserted that web3 could not drop ethers-* and that channels sheds zero crates. Both were true as written, and between them they were concealing 95 of the 138 crates this PR removes.

Separately, composio/{contract_gate,action_tool}.rs imported from tinyflows::caps — an always-on domain depending on a gated seam, which made the seam ungatable at all.

Solution

Measurement first. dep-sim.py projects a cohort's effect from the real graph. Per-dependency arithmetic is wrong: individual cuts here sum to −44 where the cohort is −53, because cutting siblings makes shared crates exclusive. Two defects in this tooling were found and fixed while using it — it modelled removing a crate globally rather than severing this crate's edge (inflating one cohort from a real −4 to a claimed −17), and the ratchet's slack was loose enough that five of eight sheds could have regressed unnoticed.

Gate ownership, not gate size. The two big wins came from re-homing crates rather than gating harder:

  • web3 (−67): Polymarket consumed the wallet's EVM stack from outside the wallet domains, so web3 could never reach it. A new prediction-markets feature that implies web3 makes the cohort droppable.
  • channels (−28): tinychannels genuinely cannot be gated out — DomainEvent embeds its envelope, config and security::pairing re-export its types. But the heavy crates belong to two of its providers. Gating those upstream sheds 28 with zero stubbing, avoiding stubs for constant_time_eq/hash_token and a persisted session-key derivation.

Back-edge inversion. 627 lines (the live catalog, probe, and their caches) moved from the seam into composio/catalog.rs, plus a new vendor-neutral openhuman::json_schema owned by neither side — without it the inversion is impossible, since both sides need the schema walkers. grep -rn "tinyflows" src/openhuman/composio/ is now zero.

Submission Checklist

  • Tests added or updated — both-directions gate assertions (polymarket_controller_presence_follows_its_gate), 5 ToolBackend seam tests including one that fails if a backend is registered after the catch-all
  • Diff coverage ≥ 80%N/A: not measured locally. diff-cover was not run manually; the change is overwhelmingly manifest/#[cfg]/module-move with no new logic. This is independently and authoritatively enforced by the Rust Core Coverage / Rust Tauri Coverage / coverage-gate jobs in ci-lite.yml, which run against this exact head.
  • Coverage matrix updated — N/A: no feature rows added or removed (compile-time gating of existing behaviour); the Coverage Matrix Sync CI lane independently verifies this and passes.
  • All affected feature IDs listed under ## Related
  • No new external network dependencies introduced — this PR only removes dependencies
  • Manual smoke checklist updated — N/A: no release-cut surface changed; every gate is default-ON and forwarded to the shell, so the packaged app is byte-equivalent in surface
  • Linked issue closed — N/A: no tracking issue

Impact

Desktop app: no functional change. Every new gate is default-ON and forwarded to app/src-tauri/Cargo.toml; check-feature-forwarding.mjs passes with all 14 forwarded. bin-tools is default-OFF and affects only src/bin/ targets.

Slim/kernel builds lose, by design: file logging and the logtracing bridge (file-logging), the battery/AC probe so require_ac_power is unenforced (scheduler-gate), the Polymarket tools (prediction-markets), and the email/Lark channel providers (channels). Each is documented at its definition, because several degrade silently rather than erroring.

One behaviour improvement: the Composio contract gate previously carried #[cfg(feature = "flows")] only because the catalog lived behind flows. With the catalog in composio, all 8 gates came out and the gate now functions in flows-off builds.

Security-sensitive ordering preserved: the tier gate still runs before the curation check in the new ComposioToolBackend, so a read-only tier cannot distinguish "not curated" from "curated but denied" and thereby probe the user's configured scope. Documented at the site.

Validation

profile result
max buildable (16 features) 12,061 passed, 0 failed
kernel (--features flows) 10,486 passed, 14 failed
gates-off (--features tokenjuice-treesitter) 9,813 passed, 13 failed

No failure in either gated profile touches code this PR restructured — zero matching tinyflows|composio|json_schema|caps, against 884 passing tests in those areas. The 13 are pre-existing: 12 live in files this PR never edits, and the 4 in tools/ops.rs fail asserting whatsapp_data_list_chats/list_workflows (the channels/skills gates, which predate this work). None mention polymarket. They are the class AGENTS.md already names — tests that hard-assert a gated family — surfacing now because the smoke lane runs cargo check only and this appears to be the first full gates-off run.

Two environment notes: RUST_MIN_STACK=67108864 is required for a local full --lib run (SIGABRT at ~4,300 tests without it), and inference/voice are unbuildable here (whisper-rs-sys vs cmake 4.2), so those gates have compile verification in both states but no local test coverage.

Related

  • Depends on: feat: gate the email and lark providers behind their own features tinychannels#13 — must merge first; channels/voice reference tinychannels/{email,lark}, so this PR is unbuildable against current upstream tinychannels.
  • Follow-up PR(s)/TODOs:
    • 13 pre-existing gates-off test failures (separate issue) — and CI should run the full gates-off --lib suite, not the scoped filter; the stack overflow that forced the filter is already handled by RUST_MIN_STACK
    • LIVE_CATALOG_CACHE never invalidates for the process lifetime (pre-existing; now visible in composio::catalog)
    • Remaining unclaimed floor: cron+chrono-tz (−5), argon2 (−4), tokenjuice (−3), os-keyring (−2)

AI Authored PR Metadata

Linear Issue

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

Commit & Branch

  • Branch: kernelize-openhuman
  • Commit SHA: see head of PR

Validation Run

  • pnpm --filter openhuman-app format:checkN/A: no frontend files changed (confirmed: no app/src/** or .ts(x) paths in this PR's changed-files list)
  • pnpm typecheckN/A: no TypeScript changed (same confirmation)
  • Focused tests: three feature profiles, --test-threads=1 (table above)
  • Rust fmt/check: cargo fmt --check clean; cargo check clean in gates-off and gates-on for every new gate
  • Tauri fmt/check — N/A: only the forwarded feature list changed in app/src-tauri/Cargo.toml (the only app/src-tauri/ path touched is Cargo.toml; confirmed against the PR's changed-files list)

Validation Blocked

  • command: cargo check/test --features inference,voice
  • error: whisper-rs-sys build fails under cmake 4.2 (vendored whisper.cpp uses removed policies)
  • impact: the voice gate's enabled branch has compile verification via other profiles but no local test run; pre-existing and unrelated to this change

Behavior Changes

  • Intended behavior change: none in the packaged desktop app. Slim builds lose the surfaces listed under Impact.
  • User-visible effect: none by default. The Composio contract gate additionally starts working in flows-off builds.

Parity Contract

  • Legacy behavior preserved: all gates default-ON and forwarded to the shell; caps split is a pure move with glob re-exports keeping every call path (caps::X from flows/, super::super::X from caps::tools::*); the tier-before-curation security ordering moved as one unit.
  • Guard/fallback/dispatch parity checks: check-feature-forwarding.mjs green (14 forwarded); check-kernel-floor.sh green at 280/6; RPC controllers use conditional push so a gated method is absent (unknown-method) rather than registered-and-failing.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none
  • Canonical PR: this one
  • Resolution: N/A

Summary by CodeRabbit

  • New Features
    • Added flow capabilities for agents, language models, HTTP requests, code execution, state, memory, tools, and workflow resolution.
    • Added live Composio tool discovery, schema-aware validation, output inspection, and safer connection handling.
    • Added approval and autonomy controls for flow actions, including nested agent operations.
    • Added sandboxed JavaScript and Python execution with structured results.
  • Improvements
    • Added configurable file logging, scheduler battery probing, prediction-market support, and channel providers.
    • Improved feature-aware builds and dependency monitoring.
  • Documentation
    • Expanded feature-gate and dependency-profile guidance.

The agent runner now borrows the shared config directly when no node-level model override is present, only cloning when an override actually needs to be applied. This eliminates an unnecessary full config clone on the common path. Tests were updated to cover timeout clamping and scaling behavior, and the harness ceiling test now exercises the production semaphore directly.
Add unit tests covering JSON schema operations and the code, HTTP, and prompt capability helpers. These tests verify harness generation, credential resolution, and structured JSON extraction behavior, ensuring the utilities work correctly and fail safely on malformed input.
Concurrent callers requesting the same toolkit catalog now coordinate through a per-key in-flight lock, so only one network fetch happens and the others reuse its result after re-checking the cache. This prevents stampede requests to the Composio backend when the cache is cold or expired. Also fixes minor test string escaping inconsistencies in the tinyflows caps modules.
Reformatted several long lines and multi-line expressions to conform to the project's rustfmt style, improving readability without changing any behavior.
Extract the per-toolkit in-flight lock acquisition into a dedicated helper function and add a unit test verifying that locks are shared per toolkit but distinct across toolkits. This simplifies the fetch path and makes the locking behavior explicit and testable.
The capability adapters now import and use the actual OpenHuman implementations instead of relying on re-exports through the module tree. This includes connecting HTTP, LLM, code, and prompt adapters to their respective providers, credential stores, and security policies, while also making the ops module publicly accessible for external use.
The functions `is_curated_flow_tool`, `resolve_composio_account`, `reject_unsuccessful_composio_response`, `reject_failed_native_tool_result`, and `native_tool_payload` are now `pub(crate)` so they can be reused by other modules within the crate. The memory adapter reference is also updated to use a fully qualified path for consistency.
The change removes several imports that were no longer used in the caps operations module, cleaning up dead code and reducing unnecessary dependencies. This is a routine cleanup with no behavioural impact.
Switched the capabilities import to a wildcard form to simplify the module's dependency surface and reduce maintenance overhead when new capability types are added.
Reformatted import statements in the LLM, ops, and prompt capability modules to match the project's rustfmt configuration, adjusting line wrapping and import ordering without any behavioral changes.
Battery state-of-charge values that are not finite (such as NaN or infinity) could previously skew the average charge calculation. The probe now skips such readings, ensuring the reported charge remains a valid clamped percentage.
Extract the finite-check and accumulation of battery charge readings into a dedicated helper function so the sampling loop stays readable and the behaviour can be unit-tested. Add a test confirming that non-finite readings are ignored while valid ones are accumulated.
Clean up unused imports in test modules across config, agent harness, flows, and tinyflows caps to keep the codebase tidy and avoid compiler warnings.
…dules

Reformatted the battery charge sample call to a single line and merged the test-only import of ProbedOutputSample into the main catalog import block, reducing redundancy without changing behavior.
The mcp_server::resources tests now run in their own cargo test invocation with the mcp feature enabled, while the main test run excludes them and corrects the tools::ops_tests path to tools::ops::tests. This ensures resource tests are properly gated behind the mcp feature rather than being skipped or failing in the tokenjuice-treesitter-only profile.
The flow discovery, workflow builder, flow memory, skill setup, and skill executor prompt resources are now conditionally compiled with the `flows` and `skills` feature flags respectively. This prevents these agents from being exposed in the resource catalog when their corresponding features are disabled, keeping the catalog consistent with the available functionality.
The `Arc` import is now conditionally compiled only when both the crash-reporting and http-server features are enabled, matching its usage in the test code and preventing unused import warnings in other configurations.
Restrict imports that are used solely by the test module to test builds, reducing the production dependency surface and avoiding unused-import warnings in non-test compilation.
Reordered the import statements in the capabilities operations module so that the non-test import of HttpCredentialsStore appears before the test-only imports, improving code organization and readability.

@greptile-apps greptile-apps 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.

senamakel has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6fde15e05e

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/check-kernel-floor.sh
The kernel floor check now tracks the total package count in addition to unique crate names and native builds, with the limits file updated to include this new metric. This catches duplicate crate versions that inflate the dependency graph without increasing the unique name count, and the ratchet logic now enforces that improvements to the package count are also locked in.

@greptile-apps greptile-apps 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.

senamakel has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@senamakel
senamakel merged commit a52a599 into tinyhumansai:main Aug 2, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant