Skip to content

Add native jail resource limit contract - #97

Merged
senamakel merged 6 commits into
mainfrom
epic-7328-native-resources
Oct 18, 2026
Merged

senamakel merged 6 commits into
mainfrom
epic-7328-native-resources

Conversation

@senamakel

Copy link
Copy Markdown
Member

Summary

Native jail requests can now carry the existing typed ResourceLimits vocabulary (CPU, memory, process count, disk) under optional resources. The TinyBus contract is version 1.22; requests without the field remain compatible. The Jail facade and native module preflight refuse any requested hard limit unless every corresponding constraint is reported Enforced, including when enforcement mode is Declared.

This change advertises no new resource enforcement. Current native backends do not enforce these limits, so requested limits fail before spawn. Future enforcement needs a safe launcher or owned cgroup/job lifecycle. Callers using raw JailBackend::spawn must call require_resources first; the public Jail facade does so automatically.

Hosts must check contract version 1.22 before sending resources, because older modules may ignore unknown JSON fields.

Closes tinybox#27; part of tinyhumansai/openhuman#7328.

Validation

  • Red-green regression coverage for Declared plus resource BestEffort; confirmed failure when native preflight was removed and pass after restore.
  • Rust 1.99: full workspace tests (--workspace --all-features), build (--workspace --all-targets --all-features), strict Clippy (-D warnings), format, rustdoc, and scripts/test-features.sh passed.
  • Declared MSRV Rust 1.88: strict workspace Clippy passed.
  • Targeted contract/jail/module regression tests and full affected package tests passed.
  • Existing fixture-dependent Docker/module E2E tests remain ignored unless their documented fixtures are configured.

…s/src/jail_tests.rs,crates/tiny

Auto-committed-on: dragonfly
Native jail resource limits are now treated as hard requirements even when
the caller accepts declared enforcement for filesystem, network, or
subprocess policy. The bus reuses the existing ResourceLimits type instead
of a duplicate struct, and the facade refuses requests with limits before
spawning when the backend cannot enforce them.

Auto-committed-on: dragonfly
@tinysweeper

tinysweeper Bot commented Oct 18, 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: Incomplete
Priority: none
Reviewed head: e4eff5f4ae3c
Updated: 2026-10-18T20:55:55Z

Review snapshot

Change surface Files Review signal Count
Production 5 Active findings 0
Tests 12 Noted findings 0
Documentation 4 Resolved findings 0
Configuration 0 Pending checks/questions 8

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

Features

None identified with supported citations.

Tests

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

  • Unreviewed: tinysweeper/tests

Findings

No active actionable findings.

Could not review: crates/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/lib.rs, crates/tinybox-jail/src/mod_tests.rs, tinysweeper/description, tinysweeper/tests

Before merge

  • Complete the critique review for crates/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/lib.rs, crates/tinybox-jail/src/mod_tests.rs.
  • Complete the security review for crates/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/mod_tests.rs, crates/tinybox-jail/src/lib.rs.
  • Complete the tests review for tinysweeper/tests.
  • Complete the description review for tinysweeper/description.

How this fits together

flowchart LR
  n0["NativeJailConfig<br/>changed"]:::changed
  n1["deny_read_defaults_empty_and_round_trips<br/>changed"]:::changed
  n2["...ker_facts_are_additive_and_default_safely<br/>changed"]:::changed
  n3["Jail<br/>changed"]:::changed
  n4["ResourceId"]:::impacted
  n5["JailBackend"]:::impacted
  n6["spawn_with"]:::impacted
  n7["ExecRequest"]:::impacted
  n8["SpawnRequest"]:::impacted
  n9["CreateRequest"]:::impacted
  n1 -->|uses| n0
  n2 -->|calls| n4
  n2 -->|tests| n4
  n2 -->|uses| n9
  n5 -->|uses| n3
  n6 -->|uses| n3
  n6 -->|uses| n5
  n7 -->|uses| n4
  n8 -->|uses| n4
  n8 -->|uses| n7
  n9 -->|uses| n4
  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: Neutral
  • Scope reviewed: incomplete; unanswered: crates/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/lib.rs, crates/tinybox-jail/src/mod_tests.rs
  • Lane summary: Reviewed 0 files; 0 findings. 3 files could not be reviewed: crates/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/lib.rs, crates/tinybox-jail/src/mod_tests.rs.

security

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: crates/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/mod_tests.rs, crates/tinybox-jail/src/lib.rs
  • Lane summary: Reviewed 0 files; 0 findings. 3 files could not be reviewed: crates/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/mod_tests.rs, crates/tinybox-jail/src/lib.rs.

tests

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: tinysweeper/tests
  • Lane summary: No reviewer produced a usable response.

commits

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

description

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: tinysweeper/description
  • Lane summary: No reviewer produced a usable response.
Evidence and run details
  • Models: ladder/vectors-oai3
  • Spend: $0.000099
  • Tokens: 0 input · 0 output · 0 cached · 763 embedding
Head State Pass summary
034ff041cc52 incomplete 0 active finding(s), 0 resolved finding(s) (at 2026-10-18T20:46:31Z)
e4eff5f4ae3c incomplete 0 active finding(s), 0 resolved finding(s) (at 2026-10-18T20:55:55Z)

tinysweeper 0.1.2

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 21 billable files and costs up to $5.25.

Or wait 8 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d816aa0-6c74-40f4-99ad-32717488730e
📥 Commits

Reviewing files that changed from the base of the PR and between 4c71249 and e4eff5f.

📒 Files selected for processing: 21
  • crates/tinybox-bus/src/jail.rs
  • crates/tinybox-bus/src/jail_tests.rs
  • crates/tinybox-bus/src/lib.rs
  • crates/tinybox-bus/src/lib_tests.rs
  • crates/tinybox-bus/src/stdio_tests.rs
  • crates/tinybox-jail/src/jail.rs
  • crates/tinybox-jail/src/jail_tests.rs
  • crates/tinybox-jail/src/lib.rs
  • crates/tinybox-jail/src/mod_tests.rs
  • crates/tinybox-module/src/tinybus_module/README.md
  • crates/tinybox-module/src/tinybus_module/mod_tests.rs
  • crates/tinybox-module/src/tinybus_module/native_jail.rs
  • crates/tinybox-module/src/tinybus_module/native_jail_tests.rs
  • crates/tinybox-module/src/tinybus_module/native_shell/mod_tests.rs
  • crates/tinybox-module/src/tinybus_module/resources_stdio_tests.rs
  • crates/tinybox-module/src/tinybus_module/resources_stream_tests.rs
  • crates/tinybox-module/src/tinybus_module/stdio_tests.rs
  • crates/tinybox-module/tests/module_e2e.rs
  • docs/specs/constraint-preflight.md
  • docs/specs/contract-1-21.md
  • docs/specs/contract-1-22.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T20:57:27.465090Z e4eff5f New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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/tinybox-bus/src/jail.rs, crates/tinybox-bus/src/jail_tests.rs, crates/tinybox-bus/src/lib.rs, crates/tinybox-bus/src/lib_tests.rs, crates/tinybox-bus/src/stdio_tests.rs, crates/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/jail_tests.rs, crates/tinybox-jail/src/lib.rs and 15 more.

$0.0001 · 0 in / 0 out · 713 embedded · ladder/vectors-oai3

@tinysweeper tinysweeper Bot added the priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. label Oct 18, 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: 034ff041cc

ℹ️ 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 crates/tinybox-jail/src/jail.rs
Adds a test asserting the facade rejects each zero resource limit even when the backend reports full enforcement, and that no command is spawned as a result.

Auto-committed-on: dragonfly
The backend preflight now calls validate on the requested resource
constraints so zero limits are rejected before spawning. The facade maps
zero-limit refusals to InvalidInput instead of Unsupported, and the test
backend builds its constraint support without relying on the removed
constructor.

Auto-committed-on: dragonfly
Reformatted the test function signature and the backend spawn method so each fits on one line, matching rustfmt output. No behaviour changed.

Auto-committed-on: dragonfly

@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/tinybox-jail/src/jail.rs, crates/tinybox-jail/src/lib.rs, crates/tinybox-jail/src/mod_tests.rs, tinysweeper/description, tinysweeper/tests.

$0.0001 · 0 in / 0 out · 763 embedded · ladder/vectors-oai3

@senamakel
senamakel merged commit 3cbd5d1 into main Oct 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant