Skip to content

fix(openhuman): advertise plain object tool schemas for strict providers - #131

Merged
senamakel merged 2 commits into
mainfrom
hivemind-strict-schema
Oct 11, 2026
Merged

senamakel merged 2 commits into
mainfrom
hivemind-strict-schema

Conversation

@senamakel

@senamakel senamakel commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Problem

hivemind_read advertised a JSON schema with a top-level oneOf (with not/anyOf inside). OpenAI-strict providers reject this. Surplus Intelligence returned:

400 "Invalid schema for function 'hivemind_read': schema must have type 'object' and not have 'oneOf'/'anyOf'/'allOf'/'enum'/'const'/'not' at the top level."

That killed a tinyrsi hive lead's turn, and with it the whole epoch.

Fix

  • Kind::schema() now always emits a plain {type: object, properties, required, additionalProperties: false} schema.
  • The one-destination rule is restated in the hive_id / agent_id / thread / after field descriptions.
  • Runtime enforcement in Kind::validate is unchanged: exactly one of hive_id/agent_id, and thread only with hive_id.

Tests

  • New regression test tools::direct_test::every_tool_schema_is_plain_object_for_strict_providers walks every Kind (managed set included) and asserts that no schema has a top-level oneOf/anyOf/allOf/enum/const/not. It fails on the old code and passes with the fix.
  • read_schema_and_validator_require_exactly_one_destination updated: it now checks for an empty required list and for the field descriptions instead of the old oneOf length. The validator assertions are unchanged.
  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings and cargo test --workspace all pass locally.

Summary by CodeRabbit

  • Improvements
    • Read tool schemas now describe how to choose between hive and agent destinations, when a thread is required, and how to use the after cursor.
    • Read schemas no longer expose multiple alternative schema shapes. Existing runtime validation of read options remains in place.

Strict OpenAI-compatible providers reject top-level combinators such as
oneOf, anyOf and not, so the Read tool's cross-field rules now live in
field descriptions and are enforced at runtime by validate. Tests assert
that every tool schema is a plain object with no forbidden keywords.

Auto-committed-on: macbook
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1943c938-3f54-4328-8969-18302ff9b6a2

📥 Commits

Reviewing files that changed from the base of the PR and between 2c87028 and 44928ef.


📒 Files selected for processing (2)
  • crates/tinyhivemind-openhuman/src/tools/direct_test.rs
  • crates/tinyhivemind-openhuman/src/tools/types.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

The Read tool schema now describes its cross-field rules on individual fields instead of using top-level schema combinators. Tests check the Read field descriptions and verify the required schema shape across all tools.

Changes

Read Tool Schema

Layer / File(s) Summary
Read schema and validation
crates/tinyhivemind-openhuman/src/tools/types.rs, crates/tinyhivemind-openhuman/src/tools/direct_test.rs
The Read schema adds field descriptions for destination, thread, and cursor rules, and returns the object schema without top-level combinators. Tests check the Read descriptions and verify that every tool schema has the expected object shape and excludes the listed top-level keywords.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix


Merge Risk | ⚪ Minimal · up to 44928

Merge Risk: ⚪ Minimal · up to 44928

The Read tool now advertises a plain object schema that strict-validating providers accept, and argument rules are still enforced when tools run. No blocking risk remains.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 44928

The advertised schema becomes less restrictive, but tool execution still rejects invalid destination combinations before reading messages. Existing identity, membership, and visibility checks remain in place. No material security risk introduced by this change was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The schema change does not expand the inspected Read path beyond the actor-peer transcript or authorized hive view already available through coordinator reads. The destination selectors and downstream access checks are unchanged.

Security Findings and Attack Paths

  • inferred — Removing provider-level destination constraints can allow invalid combinations to be submitted, but the inspected Tool execution path rejects missing destinations, dual destinations, and agent_id with thread before message reads. No schema-only bypass was identified on this path.

Trust Boundaries and Controls

  • observed — Coordinator reads retain independent controls: direct reads require known identities and filter the actor-peer conversation; hive reads require a known actor, hive membership, visible messages, and a valid visible thread root. These controls do not depend on provider schema enforcement.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: emitting plain object tool schemas for strict providers.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit reads the fields in rows,
And finds where hive or agent goes.
“No thread with agent,” the notes declare,
A cursor marks the place to spare.
The schema’s clear; I hop with care.

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

Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel merged commit c2ad418 into main Oct 11, 2026
9 checks passed
@tinysweeper

tinysweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Tiny Sweeper reviewed this change across 5 lane(s) and found 0 active actionable finding(s). Detailed lane evidence and any incomplete work are listed below.

State: Ready for maintainer review
Priority: none
Reviewed head: 44928ef67575
Updated: 2026-10-12T19:06:24Z

Review snapshot

Change surface Files Review signal Count
Production 1 Active findings 0
Tests 1 Noted findings 0
Documentation 0 Resolved findings 0
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

What changed

The change removes the top-level `oneOf` combinator from the `hivemind_read` tool schema and moves the exactly-one-destination rule into per-field descriptions, with the runtime `validate` path continuing to enforce it. A new regression test asserts every tool schema is a plain object with no top-level combinators or `enum`/`const`/`not`, and the existing exactly-one-destination test was updated to check required is empty and that destination field descriptions carry guidance text.

Features

  • Modified — Plain object schemas for strict providers: Removes the top-level `oneOf` combinator from the read tool schema so strict OpenAI-compatible providers that reject top-level combinators accept the schema; cross-field destination rules now live in field descriptions and remain enforced at runtime by `validate`. (crates/tinyhivemind-openhuman/src/tools/types.rs#impl Kind {)
  • Added — Per-field schema descriptions: Attaches human-readable guidance to individual fields (hive_id, agent_id, thread, after) describing the exactly-one-destination and threading constraints, replacing the machine-readable combinator used previously. (crates/tinyhivemind-openhuman/src/tools/types.rs#impl Kind {)

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

Findings

No active actionable findings.

Before merge

None.

How this fits together

flowchart LR
  n0["...validator_require_exactly_one_destination<br/>changed"]:::changed
  n1["...serves_direct_replies_as_its_bound_caller<br/>changed"]:::changed
  n2["as_str"]:::impacted
  n3["clone"]:::impacted
  n4["tool"]:::impacted
  n5["wave_parking"]:::impacted
  n0 -->|calls| n2
  n0 -->|tests| n2
  n1 -->|calls| n3
  n1 -->|tests| n3
  n1 -->|calls| n4
  n5 -->|calls| n2
  n5 -->|tests| n2
  n5 -->|calls| n3
  n5 -->|tests| n3
  classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
  classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
  classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
  classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Loading
Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 2 files; 0 findings.

security

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 2 files; 0 findings.

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: This change removes the top-level `oneOf` combinator from the `hivemind_read` schema and moves the exactly-one-destination rule into per-field descriptions, with the runtime `validate` path (already covered by `read_schema_and_validator_require_exactly_one_destination`) continuing to enforce it. The new tests pin the reachable behaviour: every tool schema is a plain object with no top-level combinators or `enum`/`const`/`not`, and the non-`oneOf` fields carry guidance text mentioning the destination fields. I was unable to read the body of `types.rs` beyond the diff (lookup budget spent), so I could not independently verify that the schema-building loop still emits every field exactly once and that `field_description`'s matches are exhaustive for the intended fields; within the diff itself the change looks sound and no reportable defect is visible.

commits

  • Conclusion: Neutral
  • Scope reviewed: all assigned evidence
  • Lane summary: Nothing sensitive found in what this pull request commits.

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The diff removes the top-level `oneOf` from `Kind::Read`'s schema, adds per-field descriptions for the read tool, and adds a regression test asserting every `Kind` schema is a plain object; runtime validation in `Kind::validate` is untouched, matching the description. The one test assertion the change touched still holds: all three described fields contain "hive_id" or "agent_id", so I found no defect to report.
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash
  • Spend: $0.001459
  • Tokens: 205549 input · 9276 output · 15488 cached · 177 embedding
Head State Pass summary
44928ef67575 incomplete 0 active finding(s), 0 resolved finding(s) (at 2026-10-12T18:30:14Z)
44928ef67575 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-10-12T19:06:24Z)

tinysweeper 0.1.2

@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, but could not review everything, so this is not an approval: crates/tinyhivemind-openhuman/src/tools/types.rs.

             $0.0042 · 200,057 in / 45,379 out · 19,648 cached (10%) · ladder/vectors-oai3, deepseek-v4.1-flash, glm-5.3-flash · 177 embedded
critique:    $0.0016 · 73,445 in  / 24,321 out · 19,456 cached (26%) · deepseek-v4.1-flash
security:    $0.0014 · 69,440 in  / 8,062 out  · 0 cached (0%)       · deepseek-v4.1-flash
tests:       $0.0003 · 31,739 in  / 4,171 out  · 128 cached (0%)     · glm-5.3-flash
description: $0.0005 · 22,335 in  / 5,701 out  · 64 cached (0%)      · deepseek-v4.1-flash, glm-5.3-flash

@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.0015 · 205,549 in / 9,276 out · 15,488 cached (8%) · ladder/vectors-oai3, deepseek-v4.1-flash · 177 embedded
critique:    $0.0005 · 71,575 in  / 2,128 out · 4,224 cached (6%)  · deepseek-v4.1-flash
security:    $0.0003 · 62,096 in  / 1,172 out · 5,504 cached (9%)  · deepseek-v4.1-flash
tests:       $0.0003 · 38,004 in  / 2,032 out · 1,920 cached (5%)  · deepseek-v4.1-flash
description: $0.0003 · 31,155 in  / 3,272 out · 3,840 cached (12%) · deepseek-v4.1-flash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant