refactor(manifest): add TypedDict schema and eager validation
test / run tests/run_tests.py (pull_request) Successful in 20s

Move schema checks out of per-access getters into a single
manifest_validate pass invoked by manifest_resolve. Getters can now
assume bottles/agents are well-typed dicts and every agent has a
defined bottle, so the .get(...) or {} chains collapse. Behavior
change: a bad runtime / shape error anywhere in the manifest now
fails at load instead of on the N-th read.

Intermediate step toward replacing TypedDict with a dataclass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 21:08:54 -04:00
parent 7e0e256370
commit 36cb0c53bf
2 changed files with 199 additions and 93 deletions
+7 -6
View File
@@ -1,10 +1,11 @@
"""Unit: manifest_bottle_runtime — defaults to runc, accepts runsc,
rejects unknown values and non-strings."""
"""Unit: bottle runtime — manifest_bottle_runtime returns the configured
runtime (defaulting to runc); manifest_validate rejects unknown values,
non-strings, and empty strings."""
import unittest
from claude_bottle.log import Die
from claude_bottle.manifest import manifest_bottle_runtime
from claude_bottle.manifest import manifest_bottle_runtime, manifest_validate
def _bottle(runtime_value: object | None) -> dict:
@@ -34,15 +35,15 @@ class TestManifestBottleRuntime(unittest.TestCase):
def test_rejects_unknown_runtime(self):
with self.assertRaises(Die):
manifest_bottle_runtime(_bottle("kata-runtime"), "dev")
manifest_validate(_bottle("kata-runtime"))
def test_rejects_non_string(self):
with self.assertRaises(Die):
manifest_bottle_runtime(_bottle(42), "dev")
manifest_validate(_bottle(42))
def test_rejects_empty_string(self):
with self.assertRaises(Die):
manifest_bottle_runtime(_bottle(""), "dev")
manifest_validate(_bottle(""))
if __name__ == "__main__":