Skip to content

feat(product): identify this crate's backend traffic as opencompany - #513

Merged
senamakel merged 5 commits into
tinyhumansai:mainfrom
YellowSnnowmann:feat/376-opencompany-product-identity
Aug 9, 2026
Merged

feat(product): identify this crate's backend traffic as opencompany#513
senamakel merged 5 commits into
tinyhumansai:mainfrom
YellowSnnowmann:feat/376-opencompany-product-identity

Conversation

@YellowSnnowmann

@YellowSnnowmann YellowSnnowmann commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Important

Blocked on tinyhumansai/openhuman#5437 merging. That PR adds the openhuman_core::api::product_identity surface this consumes; until it lands and vendor/openhuman is bumped to include it, this branch does not compile. The pin bump is deliberately not part of this diff — see Submodule pin below.

Summary

Attributes this process's TinyHumans backend traffic to opencompany via the x-sdk-name header, so the backend can tell OpenCompany users apart from OpenHuman and Medulla users who share the same login.

Two halves, because OpenCompany reaches the backend two different ways:

  • Through the embedded core — one install_into_embedded_core() call during startup sets openhuman_core's process-wide product identity, which tags every IntegrationClient the harness builds (media, Composio, web search).
  • Through this crate's own reqwest clients — five call sites that bypass openhuman_core entirely and therefore inherit nothing from that call. These are the majority of OpenCompany's backend traffic, including the sole production inference path.

src/product.rs is the single source of truth for the string "opencompany"; feedback::tinyhumans::PRODUCT now re-exports it instead of holding a second literal.

API Or Behavior Changes

No breaking changes. No public signature changes, no removals. feedback::tinyhumans::PRODUCT keeps its type and value — only its definition moved behind crate::product::PRODUCT_IDENTITY.

New public API (all additive): opencompany::product::{PRODUCT_IDENTITY, PRODUCT_IDENTITY_HEADER, product_identity_header, install_into_embedded_core}. The module is ungated; install_into_embedded_core is #[cfg(feature = "openhuman")].

Behavior change: requests to the TinyHumans backend now carry one additional ~20-byte header. Nothing observable changes yet — the backend currently discards the value (extractSdkSourceFromRequest has no production caller, and trackUsage.ts destructures sdkSource only to drop it), so this is inert until tinyhumansai/backend#1214 lands.

Where the header is and is not attached

Client Target Tagged
openhuman_core's IntegrationClient (media / Composio / search) backend via install_into_embedded_core
HostedProvider (harness/provider.rs) api.tinyhumans.ai/openai/v1 — the sole production inference path yes, unconditional
TenantProvider via request_plan managed endpoint only when provider == "managed"
HostedEmbeddings (harness/embeddings.rs) same managed endpoint yes, unconditional
HttpSocketTransport (brain/medulla/http.rs) api.tinyhumans.ai/orchestration/v1 yes — one post_json helper covers /events and /world-diff
HttpTinyHumansClient (feedback/tinyhumans.rs) {api_url}/feedback/ingest yes
HttpHubIdentityExchange (server/hub_identity.rs) {api_url}/auth/me yes
OAuth exchange / revoke (server/ops/connections.rs) third-party providers no, deliberately
login_start_url (server/hub_identity.rs) builds a browser URL, sends no request n/a
economy/client.rs api.tiny.place — a different service no — out of scope for backend attribution

The provider == "managed" condition is the load-bearing decision here. INFERENCE_PROVIDERS is ["managed", "openrouter", "openai_compatible", "ollama"]; only managed is TinyHumans-owned. The other three are bring-your-own-key endpoints an operator points at OpenAI, OpenRouter, DeepSeek or a self-hosted Ollama. Sending them x-sdk-name would disclose which TinyHumans product a tenant runs to a company with no relationship to us, for no benefit to anyone. There is an explicit negative test for this; please don't "simplify" it into an unconditional attach.

The call site list was derived by enumerating every consumer of AppConfig::api_url (which defaults to DEFAULT_API_URL = "https://api.tinyhumans.ai") rather than by grepping the diff, which is how HttpHubIdentityExchange was caught — it was missed on the first pass.

Tests

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo build --all-targets
  • cargo test

Run as --features openhuman,tinycortex (the gated lane), since everything here is behind that feature set.

Added:

  • tests/product_identity.rs — the acceptance criterion proper: asserts the identity is the inherited openhuman default before install_into_embedded_core() and opencompany after. The before-assertion is the half that carries the weight; without it the test would still pass if the call were deleted outright. An integration target rather than a unit test because core's identity is process-global — an in-crate test would share it with parallel unit tests and the ordering assertion would surface as a flake. Gated on openhuman alone so scripts/ci/assert-integration-targets-run.sh sees a non-zero count rather than an empty binary.
  • src/product.rs — drift guard asserting our header name equals openhuman_core::api::PRODUCT_IDENTITY_HEADER and our identity differs from its default, so the two crates cannot diverge silently; plus a pin that feedback::tinyhumans::PRODUCT stays wired to the shared constant, so the duplicate literal cannot come back.
  • harness/provider.rsrequest_plan attaches the header for managed, and does not for openrouter (whose own attribution headers are asserted unaffected) or openai_compatible.
  • harness/embeddings.rs — wire-level proof: an axum stub on an ephemeral port captures a real request and asserts x-sdk-name: opencompany arrives. HostedEmbeddings was chosen of the direct clients because harness/ already compiles under plain --features openhuman, whereas the feedback and Medulla clients sit behind the tinyhumans / medulla features.

Documentation

src/product.rs's module doc is the reference for this: why the header exists, why the module is ungated, why each direct client must attach it itself, and why the value is defined exactly once. No separate doc page — the rule belongs next to the constant it governs.

Submodule pin

vendor/openhuman is intentionally not bumped in this diff. The openhuman_core::api::product_identity surface lands in tinyhumansai/openhuman#5437, which is not yet merged. Pinning a submodule at an unmerged branch commit would leave a dangling reference the moment that branch is rebased or squashed on merge.

Verified locally against 0574d1ca9 (the #5437 head) with the pin moved in the working tree only. tinyagents lockstep holds at that commit — vendor/openhuman's own pin and this repo's are both 3e1dbea5, so the eventual bump should not need to move tinyagents.

Sequence to land: merge #5437 → bump vendor/openhuman to a main commit containing it → CI green here → merge this.

Related

Closes #376

Part of per-product Discord roles across TinyHumans:

Summary by CodeRabbit

  • New Features
    • Backend requests now identify the OpenCompany product consistently.
    • Embedded OpenHuman services use the OpenCompany product identity when available.
    • Managed inference, embeddings, feedback, and hub authentication requests include product identification.
  • Bug Fixes
    • Preserved third-party provider attribution headers while avoiding incorrect OpenCompany tagging.
  • Tests
    • Added coverage verifying product identity registration and request headers.

OpenCompany, OpenHuman and Medulla share a single TinyHumans login, so the
backend cannot attribute a request to a product from credentials alone. Every
backend-bound request this process makes now carries `x-sdk-name: opencompany`,
which the backend already parses.

OpenCompany reaches the backend two ways, and they need separate treatment:

- Through the embedded `openhuman_core`, whose `IntegrationClient` backs the
  media, Composio and web-search tools. One `install_into_embedded_core()` call
  during startup covers all of them. It has to run before any company runtime,
  agent harness or HTTP listener exists, because core reads the identity into a
  client's default headers at construction and would not retroactively re-tag a
  client that already exists.

- Through this crate's own `reqwest` clients, which bypass `openhuman_core`
  entirely and inherit nothing from that call. These carry the majority of the
  traffic, including the sole production inference path, so each attaches the
  header itself: `HostedProvider`, `HostedEmbeddings`, the Medulla
  `HttpSocketTransport`, the feedback hub client, and the hub identity
  exchange.

`request_plan` attaches the header only when the provider is `managed`. The
other three `INFERENCE_PROVIDERS` are bring-your-own-key endpoints pointed at
OpenAI, OpenRouter, DeepSeek or a self-hosted Ollama; sending them our product
identity would disclose which TinyHumans product a tenant runs to a company
with no relationship to us, and buy nothing. A test pins the negative case.

`src/product.rs` is the single source of truth for the string, so
`feedback::tinyhumans::PRODUCT` re-exports it rather than keeping a second
literal. The module is deliberately ungated: `harness/` sits behind the
`openhuman` feature but `brain/` and `feedback/` do not, and both need the
constant. Only the core-interop function is feature-gated.

`install_into_embedded_core` lives in the library rather than inline in the
binary so a test can reach it — the binary's `serve` arm cannot be exercised
from one, and an untested call is exactly where a product-attribution bug
would sit unnoticed, since nothing misbehaves when the identity is wrong.
Traffic is just silently counted as another product's.

The submodule pin is intentionally not bumped here: the API this consumes
lands in tinyhumansai/openhuman#5437, and pinning `vendor/openhuman` at an
unmerged branch commit would dangle once that branch is rebased or squashed.
Verified locally against that branch with the pin moved in the working tree
only.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@senamakel, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5be0667e-c697-46ff-b88e-cfb237b73963

📥 Commits

Reviewing files that changed from the base of the PR and between 82df495 and 8d9dbfa.

📒 Files selected for processing (1)
  • src/harness/provider.rs
📝 Walkthrough

Walkthrough

OpenCompany now centralizes its opencompany product identity, installs it into embedded OpenHuman, and sends x-sdk-name: opencompany on OpenCompany backend traffic. Managed-provider and integration tests verify header inclusion, provider exclusions, identity replacement, and sanitization.

Changes

Product identity setup

Layer / File(s) Summary
Identity definition and embedded-core setup
src/lib.rs, src/product.rs, src/bin/opencompany.rs, vendor/openhuman
The crate defines the shared product identity and header helper. The serve path installs the identity into embedded OpenHuman before runtime construction. The vendored core reference advances to support this integration.
Backend request header propagation
src/brain/medulla/http.rs, src/feedback/tinyhumans.rs, src/harness/embeddings.rs, src/harness/provider.rs, src/server/hub_identity.rs
Backend requests add x-sdk-name: opencompany. Managed providers receive the header, while third-party providers remain untagged. Tests cover embeddings, managed providers, OpenRouter attribution, and request headers.
Identity integration validation
tests/product_identity.rs
Integration tests verify replacement of the embedded-core default identity and validation through core sanitization.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OpenCompany
  participant openhuman_core
  participant Backend
  OpenCompany->>openhuman_core: Install opencompany identity
  OpenCompany->>Backend: Send backend request with x-sdk-name: opencompany
  Backend-->>OpenCompany: Return existing response
Loading

Possibly related issues

  • tinyhumansai/medulla#191 — Both changes add product identity headers to backend traffic through shared OpenHuman client plumbing.

Suggested reviewers: senamakel, oxoxdev

Poem

A rabbit hops through startup bright,
And tags each backend flight.
“opencompany,” headers say,
Core now knows the proper way.
Managed calls wear the sign,
Third-party paths stay in line. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: attributing backend traffic to the opencompany product.
Linked Issues check ✅ Passed The PR adds opencompany attribution, configures embedded-core identity, and tests header propagation and inherited-identity override required by issue #376.
Out of Scope Changes check ✅ Passed The reviewed changes support product attribution, provider scoping, embedded-core integration, and related test coverage.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

❤️ Share

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

@YellowSnnowmann
YellowSnnowmann marked this pull request as ready for review August 7, 2026 17:03

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@YellowSnnowmann

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@senamakel senamakel self-assigned this Aug 8, 2026
senamakel and others added 3 commits August 9, 2026 17:11
Updated the pinned commit for the openhuman subproject to incorporate upstream changes.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updates the version of the openhuman crate in the lock file from 0.63.6 to 0.63.7 to reflect a new release.

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

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

             $0.0041 · 54,382 in / 13,624 out · 47,519 cached (87%) · z-ai/glm-5.2
critique:    $0.0016 · 10,292 in / 6,553 out  · 9,159 cached (89%)  · z-ai/glm-5.2
security:    $0.0010 · 21,725 in / 2,637 out  · 18,783 cached (86%) · z-ai/glm-5.2
tests:       $0.0008 · 10,308 in / 2,723 out  · 8,967 cached (87%)  · z-ai/glm-5.2
description: $0.0006 · 12,057 in / 1,711 out  · 10,610 cached (88%) · z-ai/glm-5.2

Comment thread src/server/hub_identity.rs
@tinysweeper tinysweeper Bot added priority: p2 Soon. Real but survivable — a rough edge, a gap, a thing that will bite later. severity: medium labels Aug 9, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/harness/embeddings.rs (1)

515-516: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Apply rustfmt to this method chain.

Indent the .map() and .collect() calls as continuations of line 514. The changed test code must use standard rustfmt output.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/harness/embeddings.rs` around lines 515 - 516, Run rustfmt on the method
chain in the affected test, ensuring the map and collect calls are indented as
continuations of the preceding line according to standard Rust formatting.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/brain/medulla/http.rs`:
- Around line 70-81: Add focused local HTTP capture tests for each direct
transport and assert the exact centralized product-identity header value: in
src/brain/medulla/http.rs:70-81 cover the Medulla POST, in
src/feedback/tinyhumans.rs:229-241 cover feedback ingest, in
src/harness/provider.rs:674-687 cover HostedProvider::invoke, and in
src/server/hub_identity.rs:285-297 cover the /auth/me request. Keep each test
near its exercised module; no production behavior change is required.

---

Nitpick comments:
In `@src/harness/embeddings.rs`:
- Around line 515-516: Run rustfmt on the method chain in the affected test,
ensuring the map and collect calls are indented as continuations of the
preceding line according to standard Rust formatting.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1ef6551-63da-4298-8202-84affb5b280c

📥 Commits

Reviewing files that changed from the base of the PR and between c5ce1a7 and 82df495.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • src/bin/opencompany.rs
  • src/brain/medulla/http.rs
  • src/feedback/tinyhumans.rs
  • src/harness/embeddings.rs
  • src/harness/provider.rs
  • src/lib.rs
  • src/product.rs
  • src/server/hub_identity.rs
  • tests/product_identity.rs
  • vendor/openhuman

Comment thread src/brain/medulla/http.rs
…voke

Co-authored-by: Medulla <medulla@tinyhumans.ai>

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

             $0.0041 · 74,284 in / 9,272 out · 56,061 cached (75%) · openrouter/openai/text-embedding-3-small, z-ai/glm-5.2 · 677 embedded
critique:    $0.0023 · 29,619 in / 5,225 out · 16,953 cached (57%) · z-ai/glm-5.2
security:    $0.0005 · 12,481 in / 1,394 out · 11,108 cached (89%) · z-ai/glm-5.2
tests:       $0.0008 · 19,069 in / 1,955 out · 16,590 cached (87%) · z-ai/glm-5.2
description: $0.0004 · 13,115 in / 698 out   · 11,410 cached (87%) · z-ai/glm-5.2

Comment thread src/harness/provider.rs
@senamakel
senamakel merged commit f83bd6c into tinyhumansai:main Aug 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p2 Soon. Real but survivable — a rough edge, a gap, a thing that will bite later. severity: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Identify OpenCompany backend traffic as the opencompany product

2 participants