diff --git a/capd/imagelab.capd.patch.yaml b/capd/imagelab.capd.patch.yaml new file mode 100644 index 0000000..2479d7b --- /dev/null +++ b/capd/imagelab.capd.patch.yaml @@ -0,0 +1,11 @@ +# imagelab.capd.v0.yaml patch fragment +contracts: + rpc_dir: "rpc" + schema_dir: "schemas" + session_dir: "sessions" + skill_dir: "skills" + memory_dir: "memory" +validators: + executionDecision: "python -m validators.execution_decision" + skillManifest: "python -m validators.skill_manifest" + sessionReceipt: "python -m validators.session_receipt" diff --git a/validators/__init__.py b/validators/__init__.py new file mode 100644 index 0000000..bffe3f5 --- /dev/null +++ b/validators/__init__.py @@ -0,0 +1 @@ +"""Validator entrypoints for imagelab capability contract checks.""" diff --git a/validators/execution_decision.py b/validators/execution_decision.py new file mode 100644 index 0000000..5426cb6 --- /dev/null +++ b/validators/execution_decision.py @@ -0,0 +1,22 @@ +import json +import sys +from pathlib import Path + +EXPECTED_TYPE = 'ExecutionDecision' + + +def main() -> int: + if len(sys.argv) < 2: + print('usage: python -m validators.execution_decision ', file=sys.stderr) + return 2 + path = Path(sys.argv[1]) + data = json.loads(path.read_text(encoding='utf-8')) + if data.get('type') != EXPECTED_TYPE: + print(f'expected type={EXPECTED_TYPE!r}, got {data.get("type")!r}', file=sys.stderr) + return 1 + print(json.dumps({'ok': True, 'validated': EXPECTED_TYPE, 'path': str(path)})) + return 0 + + +if __name__ == '__main__': + raise SystemExit(main()) diff --git a/validators/session_receipt.py b/validators/session_receipt.py new file mode 100644 index 0000000..262dd4c --- /dev/null +++ b/validators/session_receipt.py @@ -0,0 +1,22 @@ +import json +import sys +from pathlib import Path + +EXPECTED_TYPE = 'SessionReceipt' + + +def main() -> int: + if len(sys.argv) < 2: + print('usage: python -m validators.session_receipt ', file=sys.stderr) + return 2 + path = Path(sys.argv[1]) + data = json.loads(path.read_text(encoding='utf-8')) + if data.get('type') != EXPECTED_TYPE: + print(f'expected type={EXPECTED_TYPE!r}, got {data.get("type")!r}', file=sys.stderr) + return 1 + print(json.dumps({'ok': True, 'validated': EXPECTED_TYPE, 'path': str(path)})) + return 0 + + +if __name__ == '__main__': + raise SystemExit(main()) diff --git a/validators/skill_manifest.py b/validators/skill_manifest.py new file mode 100644 index 0000000..73668e4 --- /dev/null +++ b/validators/skill_manifest.py @@ -0,0 +1,22 @@ +import json +import sys +from pathlib import Path + +EXPECTED_TYPE = 'SkillManifest' + + +def main() -> int: + if len(sys.argv) < 2: + print('usage: python -m validators.skill_manifest ', file=sys.stderr) + return 2 + path = Path(sys.argv[1]) + data = json.loads(path.read_text(encoding='utf-8')) + if data.get('type') != EXPECTED_TYPE: + print(f'expected type={EXPECTED_TYPE!r}, got {data.get("type")!r}', file=sys.stderr) + return 1 + print(json.dumps({'ok': True, 'validated': EXPECTED_TYPE, 'path': str(path)})) + return 0 + + +if __name__ == '__main__': + raise SystemExit(main())