Skip to content

refactor: adopt TinyInference managed models - #549

Merged
senamakel merged 1638 commits into
epic/8092-inference-outfrom
epic-8092-260-managed-models
Oct 20, 2026
Merged

senamakel merged 1638 commits into
epic/8092-inference-outfrom
epic-8092-260-managed-models

Conversation

@senamakel

Copy link
Copy Markdown
Owner

Managed chat and cloud embeddings duplicated implementation now owned by TinyInference. This change constructs TinyHumansModel and CloudEmbeddingModel directly, keeping OpenHuman's live credentials, endpoint policy, session-expiry events, and embedding egress guard in the host.

The host keeps the existing openhuman response-cache namespace, product model fallback, and sanitized invoke/stream diagnostics. Authentication failures use TinyInference's typed provenance. Rejected endpoint diagnostics contain only the URL origin; regression tests cover sensitive URL components and stored-key/session precedence. Generic usage, reasoning, transport, readiness, and pooling behavior now use the owning implementation and tests.

Refs #260
Part of tinyhumansai#8092

Component changes already merged into the fork epic:

  • TinyInference #34: typed managed authentication-failure provenance.
  • TinyInference #35: configurable cache namespace preserving the host cache identity.
  • TinyInference #36: typed failure observation retaining raw sanitized host diagnostics.
  • TinyAgents #150, #152, and #153: dependency pins. OpenHuman records actual TinyAgents merge 00d848b32788709f7d485ee1aa762e3c26d5201a, containing TinyInference merge bc88daca98da1e695f9e8338c43711f96fb8129a.

This branch also preserves the canonical upstream context through e9c9388 and the prior fork epic work, including #259, via normal merges. The broad comparison against the older fork epic base includes that context; the managed-model adoption is separately reviewable against baseline 6d65fde. All checkpoint and merge commits are retained.

Validation:

  • cargo clippy -p openhuman -p openhuman-cli -p openhuman-tinyhumans --all-targets -- -D warnings passed in the default configuration; the corresponding product-feature core/CLI strict check and TinyHumans product strict check passed. After the final test-fixture-only change, the affected core product all-target strict check also passed.
  • Root cargo check and desktop app cargo check: passed.
  • TinyHumans suite: 604 passed, including literal cache identity, blank-model fallback, typed callback, and credential/privacy regressions.
  • Privacy regression: reproduced the sensitive endpoint disclosure before the fix; matching default-graph test and embedding refusal test passed afterward.
  • Required pnpm debug rust inference --verbose -- --no-default-features --no-fail-fast: 607 passed, zero failed at b0c4833. The suite exposed two test setup omissions; the fixes serialize the cached-readiness fixture against explicit model overrides and register TinyHumans hooks before the raw-coverage alias test. This result is retained across the final one-line cap-test setup change: production code and every test matching the inference filter are unchanged; no full workspace rerun after that line is claimed.
  • Full pnpm rust:layout: passed, including 27 storage-schema owners. Runtime tests passed for prompt clock (3), agent-route context (4), registered-model host context (8), full flow-capability host tests (36), and existing prompt-builder compatibility (20). The latter two ran on the rebuilt final-source core test binary.
  • Actual managed-host BEFORE/AFTER capture: passed. All four raw request bodies are byte-identical using the same state path, ports, fixed clock, synthetic user, and generated cache identity. All requests returned HTTP 200. Main requests retain three messages and 24 tools; no normalization was used.
  • cargo fmt --all -- --check and git diff --check passed at final source.

This is an intermediate integration PR against the authorized senamakel fork epic branch. Final canonical upstream PRs are opened after the epic is complete.

senamakel and others added 30 commits October 20, 2026 13:07
This updates the test for resuming a non-paused run to also check for diagnostics when the expected error message is not present. This ensures better test coverage for error reporting in this scenario.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This test case is updated to assert that when a resume is refused, the associated run remains in a completed state. This ensures that the system correctly handles the state transition even when the resume operation fails.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This updates the test for resume decision logic to include more detailed diagnostics when a run is not paused. It now checks and logs the loaded version and file path of the "tinyflows" module if available.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This adds conditional logging within the validation tests when the OPENHUMAN_TINYFLOWS_RUN_DIAGNOSTICS environment variable is set. This helps in debugging structural issues during test runs.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This change updates the subproject commits across all vendor directories to their latest versions. This ensures all external dependencies are up to date.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updates the subproject commit hash for tinyflows to the latest version. This ensures the dependency is using the most recent code.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds the necessary SQLite database files for testing the tinyflows import functionality. These files ensure that tests have a complete and realistic environment to run against.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds a test case to verify that when an invalid flow record is present, the import process remains incomplete, allowing for retries. This ensures data integrity during flow imports.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updates the subproject commit hash for tinyagents to reflect the latest changes in the vendor directory.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…opes

This change updates `DocScope` to optionally hold a `StorageBackend` reference, allowing scopes to be registered with a specific backend instead of defaulting to the local storage backend. This is useful for boot-time migrations that need to operate against a known backend.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The backend field was removed from RegistrationKey as it was not being used correctly in the scope registration logic. This simplifies the key structure and cleans up the registration process.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This updates the subproject commit hash for tinyagents to the latest version. This ensures the dependency is using the most recent code.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…ests.rs,crates/openhuman-core/s

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduces an `Incomplete` outcome variant to better track legacy imports that could not be fully processed. This allows the import process to signal that some records were skipped and the import should remain open for a retry.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This refactors the flow import process to use a bounded batch import contract with TinyFlows. It replaces direct report counting with an `ImportTotals` struct to track found, written, and skipped records during the asynchronous batch processing.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This updates the commit hashes for all vendored subprojects to their latest versions. This ensures all external dependencies are up to date.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This updates the expected module name in the resume decision tests to reflect a recent change in the module's naming convention.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The `send_legacy_batch` function was removed from the import logic as it is no longer needed for current operations. This cleans up the storage import module.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This refactors the storage migration process to better handle TinyFlows catalog and schedule migrations. It introduces dedicated functions for catalog migration and ensures that flow scope readiness is checked before allowing workflow access.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduces `ensure_workflow_ready` to verify that the necessary workflow scope is ready before initializing various module proxies. This ensures that dependent services are available when the proxies are created.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This change updates the feature dependencies in Cargo.toml to use a more specific import path for flow reading and checkpoint reading. Additionally, it exports a new `catalog_proxy_for_migration` function in tinyflows.rs to support migration paths.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This change refactors how legacy flow imports are checked and handled during storage migration. It introduces `legacy_flow_import_pending` to correctly gate workflow access based on the presence and completion of legacy flow imports, improving migration robustness.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The catalog migration key is updated to include a pointer to the storage backend. This ensures that migrations are uniquely identified per backend instance, which is necessary for correct state tracking during imports.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This updates the dependencies listed in Cargo.lock by removing an outdated sha2 dependency. This ensures the project uses the latest compatible versions of its dependencies.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This introduces a helper function to count legacy records during tinyflows import. It logs a warning for each skipped legacy record and returns counts of found, written, and skipped records.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Removes stale shared memory and write-ahead log files from the tinyflows workspace fixtures. This cleans up the test environment by removing artifacts from previous runs.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This updates the test case to include enhanced logging when flows_create fails during resume tests. This helps in debugging issues related to flow creation within the test environment.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds a new test case to verify that when using a fallback storage backend, legacy catalog state is migrated correctly without importing files. This ensures backward compatibility during storage transitions.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
This change refactors how trigger configuration is compared during flow updates to use dedicated helper functions. This ensures that schedule rebinding logic correctly accounts for changes in trigger kind and configuration, rather than just comparing raw config objects.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds assertions to verify the state of the schedule job after updating flow inputs, ensuring that the input change is correctly persisted for regression testing.

Auto-committed-on: macbook
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test that drives an owner-typed managed model against a fixture server returning 401 and asserts the resulting SessionExpired event carries the invoke attribution and upstream error reason.

Auto-committed-on: dragonfly
Reformat the managed inference sources and their tests to satisfy rustfmt,
wrapping long import lists, call arguments, and match arms, and dropping a
stray trailing blank line. No behaviour changes.

Auto-committed-on: dragonfly
Attach an error observer to the managed chat model so provider and
non-provider failures during invoke, stream open, and in-band stream
items are logged with sanitized details. Readiness failures are skipped
to avoid noise.

Auto-committed-on: dragonfly
The managed-backend ownership check only matched the tinyhumans provider
label, so errors reported under the legacy OpenHuman label were not
treated as provider owned and their error codes were dropped. The check
now accepts both labels, with a test covering the legacy label and
confirming arbitrary providers are still excluded.

Auto-committed-on: dragonfly
…nership

Add a test asserting that a flattened owner error envelope still
classifies as rate limited, guarding the backend error code ownership
path against regressions.

Auto-committed-on: dragonfly
Update the vendored tinyagents submodule to the latest upstream commit.

Auto-committed-on: dragonfly
The host no longer wraps the crate-owned cloud embedding transport in a
ManagedEmbeddingModel; the registry now builds a CloudEmbeddingModel directly
with OpenHuman's credential resolver and egress guard, and per-turn routing is
handled by constructing a model per request instead of re-routing a shared one.
The managed chat model also drops its custom pooled HTTP client and the local
reasoning helper in favour of the crate defaults.

Auto-committed-on: dragonfly
…odel

Introduce an unreachable_embedder_with_chat helper so tests can supply an
approval chat context, and switch two session tests to build_cloud_model so
they exercise the same construction path as the rest of the suite.

Auto-committed-on: dragonfly
The provider-neutral helper that marked managed requests with a reasoning-off metadata flag and its test were deleted, as the behaviour is no longer needed.

Auto-committed-on: dragonfly
…odel

The cached probe test now registers a scripted chat model with a
provider probe hook and runs against a test core context instead of
seeding an app-session token, so the probe exercises the real provider
registration path.

Auto-committed-on: dragonfly
Reformatted imports, function signatures, and assertions in the readiness and managed embedding tests to match rustfmt output, and dropped a trailing blank line in the managed model module. No behaviour changes.

Auto-committed-on: dragonfly
…r refusal

Add a test asserting that when a managed bearer is refused for a foreign
endpoint, the resulting diagnostic does not leak the endpoint's user,
password, path, query, or the stored API key.

Auto-committed-on: dragonfly
Extend the managed bearer refusal test to also assert that URL fragments are redacted, and add a case without userinfo so the checks do not depend on credentials being present. The unused ChatModel import and the missing EmbeddingModel import are cleaned up alongside.

Auto-committed-on: dragonfly
Validation errors for unmanaged or insecure endpoints now report only the
URL origin instead of the full endpoint, so credentials embedded in userinfo
or path segments are not leaked into logs. Invalid and opaque URLs fall back
to a constant placeholder.

Auto-committed-on: dragonfly
Extend the managed embedding and model tests so the plaintext refusal path
asserts that path, query, fragment, and credential markers never leak into
the error, and add a test pinning endpoint_origin_for_log to origin-only
output with a constant fallback for unparseable endpoints.

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

Auto-committed-on: dragonfly
Add tests for managed bearer resolution around app-session expiry: an
expired session fails fast with its host classification intact, a future
expiry resolves, and an exp-less offline session resolves by presence.
Also assert a configured API key takes precedence over an expired session
and that a plaintext remote endpoint is refused before transport.

Auto-committed-on: dragonfly
Rename the exp-less app session test to say hosted rather than offline, matching the terminology used elsewhere, and reorder the credential imports.

Auto-committed-on: dragonfly
…ture

The cached probe readiness test now passes its scripted replies as an owned
vector instead of an array, matching the updated ScriptedModel::replies
signature.

Auto-committed-on: dragonfly
…sModel

Updated comments and the inference README to describe managed chat as
TinyInference's TinyHumansModel behind a host adapter that supplies the live
bearer resolver and failure policy, rather than a host-owned
OpenHumanBackendModel. The rename reflects the current ownership split and
clarifies that API-key credentials stay eligible for managed inference.

Auto-committed-on: dragonfly
The credentials README and an observability comment now describe the TinyHumans managed-inference and cloud-embedding host adapters resolving the bearer from the API key first and the stored app session otherwise, replacing stale references to the removed OpenHumanBackendModel path.

Auto-committed-on: dragonfly
Corrected a stray comma and semicolon in the credentials README and reflowed a comment in the observability module so the line stays within the width limit.

Auto-committed-on: dragonfly
Update the inference README to describe how the managed adapter delegates request construction and usage parsing to TinyInference, and how session expiry is detected locally before a request rather than inferred from the provider label. Also refresh stale comments in observability and the crate-native factory tests to match the current model naming and profile behaviour.

Auto-committed-on: dragonfly
The cached probe readiness test now takes the exclusive provider override
guard so it cannot race other tests that swap the global provider. Also
corrects a stale comment in the session-expiry matcher.

Auto-committed-on: dragonfly
The factory coverage test now calls the shared boot helper before acquiring
the environment lock, matching the other tests in this file so the runtime
is initialised consistently.

Auto-committed-on: dragonfly
The test now installs the shared model fixture before building its config, so the agent node runtime resolves against a deterministic model instead of whatever the ambient environment provides.

Auto-committed-on: dragonfly
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