Repository navigation
feat(core): preflight explicit hard requirements - #64
Merged
senamakel merged 19 commits intoOct 27, 2026
Merged
Conversation
Update the vendored tinybus submodule to the latest upstream commit. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
…constraints Add tests asserting that a spec requiring CPU is refused before any box is stored, and that requiring only supported constraints still allows creation. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Box specs can now carry a list of constraints the caller requires the selected sandbox to enforce fully, and every backend refuses to create a box whose hard requirements it cannot satisfy. The field defaults to empty so previously stored specs still load. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test asserting that a spec requiring CPU as a hard constraint is rejected when the backend can only enforce it on a best-effort basis, while the plan check still reports the best-effort enforcement. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test asserting that a passthrough sandbox refuses a spec with explicit hard requirements, returning ConstraintNotEnforced, and that nothing is persisted to the store when it does. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinybus submodule to the latest upstream commit. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add an `# Errors` section to the `require_spec` doc comment explaining that it returns `Error::ConstraintNotEnforced` when an explicit requirement is unsupported or only best effort. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test that deserializes a spec with the hard_requirements field removed and asserts it defaults to an empty collection, guarding backward compatibility with older serialized specs. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Replaced the `?` operators with `expect` calls in the older-specs default test so serialization and deserialization failures report which step failed. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add serde_json to the dev-dependencies of tinybox-core so tests can build and inspect JSON values, with the lockfile updated to match. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The legacy spec test now returns boxed errors instead of panicking on serialization and deserialization failures, and reports a non-object serialization as an error rather than an expect. This keeps the test consistent with the fallible style used elsewhere. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The v1 box spec now carries hard_requirements through to the v2 body instead of dropping them, and the driver record encoding round-trips the field so stored boxes keep their constraints. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Added a test asserting that stored records without a hard_requirements field decode with an empty list, and updated the serialization expectation to include the field. This guards backward compatibility for records written before the field existed. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformatted the JSON encoding setup in the test for older stored records so the error mapping closure is laid out consistently. No behaviour change. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Replace the is_empty assertions in the passthrough and sandbox tests with assert_eq against an empty slice, so a failure reports the actual stored contents instead of just false. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Replace the is_empty assertions in the spec and record tests with assert_eq against an empty array so a failure shows the actual contents of hard_requirements. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test asserting that creating a sandbox with an unsupported hard requirement fails with ConstraintNotEnforced and leaves the store empty, confirming the check happens before anything is persisted. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The create path called require_spec right after spec.validate, which already covers the same checks, so the extra call was removed to avoid duplicate work. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Call require_spec during create so unsupported specs are rejected before any network policy checks or container setup runs. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an explicit
BoxSpec::hard_requirementslist so callers can distinguish mandatory constraints from soft resource defaults. Existing specs deserialize with an empty list. New spec-aware check/require methods report the backend's enforcement, and create paths refuse unsupported or BestEffort requirements before mutating the store.Tests cover Namespace CPU refusal before storage, acceptance of supported filesystem/network requirements, MicroVM BestEffort CPU refusal, passthrough refusal, and legacy spec deserialization.
Part of tinyhumansai#27
Part of tinyhumansai/openhuman#8369
Validation:
cargo fmt --all -- --checkcargo test -p tinybox-corecargo clippy -p tinybox-core --all-targets -- -D warningscargo test -p tinybox-linux preflightcargo clippy -p tinybox-linux --all-targets -- -D warningscargo test -p tinybox-microvmcargo clippy -p tinybox-microvm --all-targets -- -D warningscargo test -p tinybox-dockercargo clippy -p tinybox-docker --all-targets -- -D warnings