compose-plugins 0.0.0__tar.gz → 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. compose_plugins-0.1.0/PKG-INFO +93 -0
  2. compose_plugins-0.1.0/README.md +82 -0
  3. compose_plugins-0.1.0/compose_plugins/__init__.py +15 -0
  4. compose_plugins-0.1.0/compose_plugins/_child.py +117 -0
  5. compose_plugins-0.1.0/compose_plugins/_probe.py +51 -0
  6. compose_plugins-0.1.0/compose_plugins/config.py +27 -0
  7. compose_plugins-0.1.0/compose_plugins/conformance.py +705 -0
  8. compose_plugins-0.1.0/compose_plugins/consent.py +497 -0
  9. compose_plugins-0.1.0/compose_plugins/derive.py +206 -0
  10. compose_plugins-0.1.0/compose_plugins/errors.py +103 -0
  11. compose_plugins-0.1.0/compose_plugins/fixtures/__init__.py +17 -0
  12. compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v1/__init__.py +0 -0
  13. compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v1/hello_world/__init__.py +1 -0
  14. compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v1/hello_world/plugin.py +54 -0
  15. compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v1/manifest.json +51 -0
  16. compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v2/__init__.py +0 -0
  17. compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v2/hello_world/__init__.py +1 -0
  18. compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v2/hello_world/plugin.py +59 -0
  19. compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v2/manifest.json +60 -0
  20. compose_plugins-0.1.0/compose_plugins/host.py +119 -0
  21. compose_plugins-0.1.0/compose_plugins/lifecycle.py +553 -0
  22. compose_plugins-0.1.0/compose_plugins/manifest.py +963 -0
  23. compose_plugins-0.1.0/compose_plugins/package.py +345 -0
  24. compose_plugins-0.1.0/compose_plugins/probe_client.py +76 -0
  25. compose_plugins-0.1.0/compose_plugins/runner.py +391 -0
  26. compose_plugins-0.1.0/compose_plugins/schema/__init__.py +6 -0
  27. compose_plugins-0.1.0/compose_plugins/schema/manifest-0.1.schema.json +216 -0
  28. compose_plugins-0.1.0/compose_plugins/store.py +66 -0
  29. compose_plugins-0.1.0/compose_plugins/version.py +60 -0
  30. compose_plugins-0.1.0/compose_plugins/web.py +286 -0
  31. compose_plugins-0.1.0/compose_plugins.egg-info/PKG-INFO +93 -0
  32. compose_plugins-0.1.0/compose_plugins.egg-info/SOURCES.txt +55 -0
  33. compose_plugins-0.1.0/compose_plugins.egg-info/entry_points.txt +2 -0
  34. compose_plugins-0.1.0/compose_plugins.egg-info/requires.txt +1 -0
  35. compose_plugins-0.1.0/pyproject.toml +35 -0
  36. compose_plugins-0.1.0/tests/test_consent.py +302 -0
  37. compose_plugins-0.1.0/tests/test_consent_record_r9.py +187 -0
  38. compose_plugins-0.1.0/tests/test_host_name_r10.py +156 -0
  39. compose_plugins-0.1.0/tests/test_manifest.py +513 -0
  40. compose_plugins-0.1.0/tests/test_package.py +300 -0
  41. compose_plugins-0.1.0/tests/test_qa_wave1_rulings.py +556 -0
  42. compose_plugins-0.1.0/tests/test_r21_permissions.py +720 -0
  43. compose_plugins-0.1.0/tests/test_r24_conformance_hooks.py +240 -0
  44. compose_plugins-0.1.0/tests/test_schema_file.py +91 -0
  45. compose_plugins-0.1.0/tests/test_validator_readings.py +289 -0
  46. compose_plugins-0.1.0/tests/test_version.py +84 -0
  47. compose_plugins-0.1.0/tests/test_wave2_build.py +109 -0
  48. compose_plugins-0.1.0/tests/test_wave2_conformance.py +120 -0
  49. compose_plugins-0.1.0/tests/test_wave2_lifecycle.py +335 -0
  50. compose_plugins-0.1.0/tests/test_wave2_r18.py +255 -0
  51. compose_plugins-0.1.0/tests/test_wave2_r19.py +209 -0
  52. compose_plugins-0.1.0/tests/test_wave2_runner.py +276 -0
  53. compose_plugins-0.1.0/tests/test_wave2_web.py +309 -0
  54. compose_plugins-0.0.0/PKG-INFO +0 -16
  55. compose_plugins-0.0.0/README.md +0 -5
  56. compose_plugins-0.0.0/compose_plugins/__init__.py +0 -2
  57. compose_plugins-0.0.0/compose_plugins.egg-info/PKG-INFO +0 -16
  58. compose_plugins-0.0.0/compose_plugins.egg-info/SOURCES.txt +0 -8
  59. compose_plugins-0.0.0/pyproject.toml +0 -18
  60. {compose_plugins-0.0.0 → compose_plugins-0.1.0}/LICENSE +0 -0
  61. {compose_plugins-0.0.0 → compose_plugins-0.1.0}/compose_plugins.egg-info/dependency_links.txt +0 -0
  62. {compose_plugins-0.0.0 → compose_plugins-0.1.0}/compose_plugins.egg-info/top_level.txt +0 -0
  63. {compose_plugins-0.0.0 → compose_plugins-0.1.0}/setup.cfg +0 -0
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: compose-plugins
3
+ Version: 0.1.0
4
+ Summary: The shared plug-in contract library (manifest, consent, version rule) for ComposeIO and Gnomon hosts
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: composebus==0.1.2
10
+ Dynamic: license-file
11
+
12
+ # compose-plugins
13
+
14
+ The shared plug-in contract library for ComposeIO's ComposeServer and for
15
+ Gnomon, implementing the Shared Plug-in Contract v0.1 (ComposeIO spec 95,
16
+ `[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24). It is the layer a plug-in is
17
+ INSTALLED and CONSENTED to, plus the shared manager that drives it.
18
+
19
+ One runtime dependency: `composebus==0.1.2` (the runtime `ComposePlugin` and
20
+ its `MessageType` names). No ComposeIO distribution is required, so a host
21
+ that is not ComposeIO can use the library on its own.
22
+
23
+ ## What is in the package
24
+
25
+ | module | what |
26
+ |---|---|
27
+ | `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON Schema (`schema/manifest-0.1.schema.json`), generated from the validator's own patterns |
28
+ | `compose_plugins.package` | reading `manifest.json` from a directory or a wheel WITHOUT executing anything, and the `manifest_sha256` rule (exact bytes, no canonicalization) |
29
+ | `compose_plugins.version` | the contract version rule: a host accepts the same MAJOR and a MINOR at or below its own, and refuses anything newer, naming both versions |
30
+ | `compose_plugins.consent` | consent content rendered from the manifest alone, the granted set, the widening rule, and the append-only consent-record store |
31
+ | `compose_plugins.host` | the `Host` protocol each host implements: consent gate, install root, own host-section validator and renderer, auth hook, `extra_panels`, supported isolation levels |
32
+ | `compose_plugins.lifecycle` | `PluginManager`: install, configure, enable, disable, upgrade and uninstall, with the state machine of the contract |
33
+ | `compose_plugins.config` | config validated against `config_schema` before the plug-in is instantiated; invalid config parks loudly |
34
+ | `compose_plugins.derive` | `compose-plugin build` (writes `config_schema` and `bus` into `manifest.json` from the class) and the enable-time class/manifest drift check |
35
+ | `compose_plugins.runner` | running a plug-in in-process, or in a child process over an inherited `AF_UNIX` socketpair (never a network listener) |
36
+ | `compose_plugins.store` | the install records (the registry) and stored config |
37
+ | `compose_plugins.web` | the plain Plugin Manager: server-rendered HTML, a mountable WSGI app that is correct under any URL prefix, with the host's auth hook and CSRF defence |
38
+ | `compose_plugins.conformance` | the conformance script (below) |
39
+ | `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins |
40
+
41
+ ```python
42
+ from compose_plugins.package import read_manifest
43
+ from compose_plugins.manifest import validate_manifest
44
+
45
+ mf = read_manifest("path/to/plugin_dir_or.whl") # executes nothing
46
+ m = validate_manifest(mf.data, host="myhost",
47
+ section_validator=my_section_validator, package=mf.package)
48
+ ```
49
+
50
+ ## The conformance script
51
+
52
+ The contract is authoritative, and the conformance script is the arbiter
53
+ between hosts: a host that fails any step or negative control is
54
+ non-conformant. It runs the hello-world lifecycle in nine steps (install with
55
+ consent, configure, start, health, a publish/subscribe round trip, an upgrade
56
+ to v2 with re-consent and config migration, disable, re-enable, and uninstall
57
+ with the retained topic tombstoned and the consent record kept). It then runs
58
+ negative controls NC1 to NC8, each of which must fail loudly. This happens once
59
+ per host and per isolation level the host supports. At the subprocess level it
60
+ also checks that the child holds no network socket and that a child crash is
61
+ reported as `failed(<reason>)`.
62
+
63
+ python -m compose_plugins.conformance --target <module>:<factory> --isolation inprocess|subprocess
64
+
65
+ The factory is called as `factory(isolation, workdir)` and returns a TARGET
66
+ with `.manager`, `.bus`, `.host`, `.isolation`, `.operator` and `.close()`,
67
+ plus the two members added in spec 95 r24:
68
+
69
+ - `foreign_host: str` (REQUIRED): the name of another host. NC4's paired
70
+ positive control puts an unknown key inside `hosts.<foreign_host>` and
71
+ expects this host to ignore it and install the plug-in. The key is never put
72
+ in this host's own section, so the control runs unchanged on every host. The
73
+ runner refuses to run before step 1 if `foreign_host` is absent
74
+ ("foreign_host missing"), equals `target.host.name`, or breaks the host-name
75
+ rule; the refusal names the value, the exit status is 2, and nothing is
76
+ installed.
77
+ - `host_section(fixture: str) -> dict` (optional): this host's own valid
78
+ section for a fixture id: `hello-world-v1`, `hello-world-v2`, or a
79
+ negative-control id `NC1` to `NC8`. Before every install it hands to the
80
+ host, the runner writes that value at `hosts.<target.host.name>`, so the
81
+ consented `manifest_sha256` covers it. A target without the hook gets `{}`
82
+ there. The shared fixtures never decide a host's section: each host owns its
83
+ own.
84
+
85
+ The script prints the observed value for every step, and exits 0 only when
86
+ every step and control passes.
87
+
88
+ ## Tests
89
+
90
+ From a checkout of the ComposeIO repository:
91
+
92
+ pip install ./python/composebus ./python/compose_plugins -r python/compose_plugins/tests/requirements.txt
93
+ pytest python/compose_plugins/tests
@@ -0,0 +1,82 @@
1
+ # compose-plugins
2
+
3
+ The shared plug-in contract library for ComposeIO's ComposeServer and for
4
+ Gnomon, implementing the Shared Plug-in Contract v0.1 (ComposeIO spec 95,
5
+ `[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24). It is the layer a plug-in is
6
+ INSTALLED and CONSENTED to, plus the shared manager that drives it.
7
+
8
+ One runtime dependency: `composebus==0.1.2` (the runtime `ComposePlugin` and
9
+ its `MessageType` names). No ComposeIO distribution is required, so a host
10
+ that is not ComposeIO can use the library on its own.
11
+
12
+ ## What is in the package
13
+
14
+ | module | what |
15
+ |---|---|
16
+ | `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON Schema (`schema/manifest-0.1.schema.json`), generated from the validator's own patterns |
17
+ | `compose_plugins.package` | reading `manifest.json` from a directory or a wheel WITHOUT executing anything, and the `manifest_sha256` rule (exact bytes, no canonicalization) |
18
+ | `compose_plugins.version` | the contract version rule: a host accepts the same MAJOR and a MINOR at or below its own, and refuses anything newer, naming both versions |
19
+ | `compose_plugins.consent` | consent content rendered from the manifest alone, the granted set, the widening rule, and the append-only consent-record store |
20
+ | `compose_plugins.host` | the `Host` protocol each host implements: consent gate, install root, own host-section validator and renderer, auth hook, `extra_panels`, supported isolation levels |
21
+ | `compose_plugins.lifecycle` | `PluginManager`: install, configure, enable, disable, upgrade and uninstall, with the state machine of the contract |
22
+ | `compose_plugins.config` | config validated against `config_schema` before the plug-in is instantiated; invalid config parks loudly |
23
+ | `compose_plugins.derive` | `compose-plugin build` (writes `config_schema` and `bus` into `manifest.json` from the class) and the enable-time class/manifest drift check |
24
+ | `compose_plugins.runner` | running a plug-in in-process, or in a child process over an inherited `AF_UNIX` socketpair (never a network listener) |
25
+ | `compose_plugins.store` | the install records (the registry) and stored config |
26
+ | `compose_plugins.web` | the plain Plugin Manager: server-rendered HTML, a mountable WSGI app that is correct under any URL prefix, with the host's auth hook and CSRF defence |
27
+ | `compose_plugins.conformance` | the conformance script (below) |
28
+ | `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins |
29
+
30
+ ```python
31
+ from compose_plugins.package import read_manifest
32
+ from compose_plugins.manifest import validate_manifest
33
+
34
+ mf = read_manifest("path/to/plugin_dir_or.whl") # executes nothing
35
+ m = validate_manifest(mf.data, host="myhost",
36
+ section_validator=my_section_validator, package=mf.package)
37
+ ```
38
+
39
+ ## The conformance script
40
+
41
+ The contract is authoritative, and the conformance script is the arbiter
42
+ between hosts: a host that fails any step or negative control is
43
+ non-conformant. It runs the hello-world lifecycle in nine steps (install with
44
+ consent, configure, start, health, a publish/subscribe round trip, an upgrade
45
+ to v2 with re-consent and config migration, disable, re-enable, and uninstall
46
+ with the retained topic tombstoned and the consent record kept). It then runs
47
+ negative controls NC1 to NC8, each of which must fail loudly. This happens once
48
+ per host and per isolation level the host supports. At the subprocess level it
49
+ also checks that the child holds no network socket and that a child crash is
50
+ reported as `failed(<reason>)`.
51
+
52
+ python -m compose_plugins.conformance --target <module>:<factory> --isolation inprocess|subprocess
53
+
54
+ The factory is called as `factory(isolation, workdir)` and returns a TARGET
55
+ with `.manager`, `.bus`, `.host`, `.isolation`, `.operator` and `.close()`,
56
+ plus the two members added in spec 95 r24:
57
+
58
+ - `foreign_host: str` (REQUIRED): the name of another host. NC4's paired
59
+ positive control puts an unknown key inside `hosts.<foreign_host>` and
60
+ expects this host to ignore it and install the plug-in. The key is never put
61
+ in this host's own section, so the control runs unchanged on every host. The
62
+ runner refuses to run before step 1 if `foreign_host` is absent
63
+ ("foreign_host missing"), equals `target.host.name`, or breaks the host-name
64
+ rule; the refusal names the value, the exit status is 2, and nothing is
65
+ installed.
66
+ - `host_section(fixture: str) -> dict` (optional): this host's own valid
67
+ section for a fixture id: `hello-world-v1`, `hello-world-v2`, or a
68
+ negative-control id `NC1` to `NC8`. Before every install it hands to the
69
+ host, the runner writes that value at `hosts.<target.host.name>`, so the
70
+ consented `manifest_sha256` covers it. A target without the hook gets `{}`
71
+ there. The shared fixtures never decide a host's section: each host owns its
72
+ own.
73
+
74
+ The script prints the observed value for every step, and exits 0 only when
75
+ every step and control passes.
76
+
77
+ ## Tests
78
+
79
+ From a checkout of the ComposeIO repository:
80
+
81
+ pip install ./python/composebus ./python/compose_plugins -r python/compose_plugins/tests/requirements.txt
82
+ pytest python/compose_plugins/tests
@@ -0,0 +1,15 @@
1
+ """compose_plugins — the shared plug-in contract library ([SPEC:CXC-PLUGIN-CONTRACT],
2
+ contract 0.1, spec 95 revision r24).
3
+
4
+ The manifest validator and JSON Schema (``manifest``), the no-execution manifest
5
+ reader and the manifest_sha256 rule (``package``), the version rule
6
+ (``version``), consent content, granted sets, widening and the consent-record
7
+ store (``consent``), the ``Host`` protocol (``host``), the lifecycle operations
8
+ (``lifecycle``), config validation (``config``), ``compose-plugin build`` and
9
+ the drift check (``derive``), the in-process and subprocess runner
10
+ (``runner``), the registry and config stores (``store``), the plain web Plugin
11
+ Manager (``web``), and the conformance script (``conformance``) with its
12
+ hello-world fixtures. See README.md.
13
+ """
14
+
15
+ __version__ = "0.1.0"
@@ -0,0 +1,117 @@
1
+ """The CHILD side of the subprocess runner. Run as
2
+ ``python -m compose_plugins._child --fd N`` by the runner only.
3
+
4
+ It reads ``configure`` then ``start``, builds a PRIVATE in-process ComposeBus
5
+ (never started: no clock, no heartbeat, no connector), starts the plug-in on
6
+ it, and bridges: every message the plug-in emits on a declared publish becomes
7
+ a bus frame to the host; every bus frame from the host is replayed with source
8
+ ``_host`` (never echoed back). It polls ``health_reason()`` and reports
9
+ ``_ctl: health`` / ``_ctl: degraded`` on change. ``stop`` stops the plug-in and
10
+ exits 0. An exception in the plug-in exits non-zero with the reason on stderr.
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import argparse
15
+ import json
16
+ import socket
17
+ import sys
18
+ import threading
19
+ import traceback
20
+
21
+ from composebus.transport import BusMessage
22
+
23
+ from .derive import resolve_entry
24
+ from .runner import CTL_TO_CHILD, HOST_SOURCE, apply_to_bus, ctl_frame, frame_from_message
25
+
26
+ HEALTH_POLL_S = 0.2
27
+
28
+
29
+ def main(argv: "list[str] | None" = None) -> int:
30
+ ap = argparse.ArgumentParser()
31
+ ap.add_argument("--fd", type=int, required=True)
32
+ args = ap.parse_args(argv)
33
+ sock = socket.socket(fileno=args.fd)
34
+ rfile = sock.makefile("rb")
35
+ wlock = threading.Lock()
36
+
37
+ def send(data: bytes) -> None:
38
+ with wlock:
39
+ sock.sendall(data)
40
+
41
+ def read_obj() -> dict:
42
+ raw = rfile.readline()
43
+ if not raw:
44
+ raise SystemExit(0) # host closed the link
45
+ obj = json.loads(raw)
46
+ if not isinstance(obj, dict):
47
+ raise ValueError("frame is not a JSON object")
48
+ if "_ctl" in obj and obj["_ctl"] not in CTL_TO_CHILD:
49
+ print(f"protocol: _ctl {obj['_ctl']!r} refused", file=sys.stderr)
50
+ raise SystemExit(4)
51
+ return obj
52
+
53
+ cfg = read_obj()
54
+ if cfg.get("_ctl") != "configure":
55
+ print("protocol: first frame must be _ctl=configure", file=sys.stderr)
56
+ return 4
57
+ if read_obj().get("_ctl") != "start":
58
+ print("protocol: second frame must be _ctl=start", file=sys.stderr)
59
+ return 4
60
+ for p in reversed(cfg["sys_path"]):
61
+ sys.path.insert(0, p)
62
+ publishes = {tuple(x) for x in cfg["publishes"]}
63
+
64
+ from composebus.bus import ComposeIOBus
65
+ bus = ComposeIOBus(bus_id=f"child-{cfg['domain']}")
66
+
67
+ def forward(msg: BusMessage) -> None:
68
+ if msg.source == HOST_SOURCE:
69
+ return
70
+ if (msg.namespace, msg.type.name) in publishes:
71
+ send(frame_from_message(msg))
72
+
73
+ bus.on_message(forward)
74
+ try:
75
+ cls = resolve_entry(cfg["entry"])
76
+ plugin = cls(config=cfg["config"])
77
+ plugin.start(bus)
78
+ except Exception as exc:
79
+ traceback.print_exc(file=sys.stderr)
80
+ print(f"start raised {type(exc).__name__}: {exc}", file=sys.stderr)
81
+ return 3
82
+
83
+ stop = threading.Event()
84
+ last: "list[object]" = [object()]
85
+
86
+ def report() -> None:
87
+ probe = getattr(plugin, "health_reason", None)
88
+ reason = probe() if callable(probe) else None
89
+ if reason != last[0]:
90
+ last[0] = reason
91
+ send(ctl_frame("health", state="running") if reason is None
92
+ else ctl_frame("degraded", reason=reason))
93
+
94
+ report()
95
+
96
+ def poll() -> None:
97
+ while not stop.wait(HEALTH_POLL_S):
98
+ try:
99
+ report()
100
+ except Exception:
101
+ traceback.print_exc(file=sys.stderr)
102
+ stop.set()
103
+
104
+ threading.Thread(target=poll, daemon=True).start()
105
+ while True:
106
+ obj = read_obj()
107
+ if obj.get("_ctl") == "stop":
108
+ stop.set()
109
+ plugin.stop()
110
+ return 0
111
+ if "_ctl" in obj:
112
+ continue # configure/start again: ignored
113
+ apply_to_bus(bus, BusMessage.from_json(obj), HOST_SOURCE)
114
+
115
+
116
+ if __name__ == "__main__":
117
+ sys.exit(main())
@@ -0,0 +1,51 @@
1
+ """One-shot probe, run in a FRESH CHILD by ``compose_plugins.probe_client``.
2
+
3
+ python -m compose_plugins._probe --fd N
4
+ stdin: {"entry", "sys_path", "config", "nonce"} (read BEFORE plug-in code)
5
+ fd N: ONE line {"nonce", "resolve_error", "config_schema", "bus", "bus_error",
6
+ "config_errors"}, then fd N is closed.
7
+
8
+ stdout and stderr belong to the plug-in and are never read as the verdict.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import json
14
+ import os
15
+ import sys
16
+
17
+
18
+ def main() -> int:
19
+ ap = argparse.ArgumentParser()
20
+ ap.add_argument("--fd", type=int, required=True)
21
+ args = ap.parse_args()
22
+ req = json.loads(sys.stdin.read()) # before ANY plug-in code runs
23
+ fd, nonce = args.fd, req["nonce"]
24
+ for p in reversed(req["sys_path"]):
25
+ sys.path.insert(0, p)
26
+ from .config import config_errors
27
+ from .derive import BuildRefused, derive_bus, derive_config_schema, resolve_entry
28
+ out: dict = {"nonce": nonce, "resolve_error": None, "config_schema": None, "bus": None,
29
+ "bus_error": None, "config_errors": []}
30
+ try:
31
+ cls = resolve_entry(req["entry"])
32
+ except Exception as exc:
33
+ out["resolve_error"] = f"{type(exc).__name__}: {exc}"
34
+ else:
35
+ out["config_schema"] = derive_config_schema(cls)
36
+ try:
37
+ out["bus"] = derive_bus(cls)
38
+ except BuildRefused as exc:
39
+ out["bus_error"] = str(exc)
40
+ out["config_errors"] = config_errors(cls.Config, req["config"])
41
+ data = (json.dumps(out) + "\n").encode("utf-8")
42
+ view = memoryview(data)
43
+ while view:
44
+ n = os.write(fd, view)
45
+ view = view[n:]
46
+ os.close(fd) # nothing written later can reach the host
47
+ return 0
48
+
49
+
50
+ if __name__ == "__main__":
51
+ sys.exit(main())
@@ -0,0 +1,27 @@
1
+ """Config validated BEFORE instantiation ([CXC-PC-LIFECYCLE-CONFIG]).
2
+
3
+ The same call and the same ``config:<field>: <message>`` park taxonomy as spec
4
+ 87's ``validate_config`` ([CXC-CSL-CONFIG-VALIDATION]): construct
5
+ ``Config(**payload)`` directly. Kept here because compose_plugins must not
6
+ depend on composeio; ``tests/test_wave2_*`` checks the two produce identical
7
+ reasons.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ from typing import Any
12
+
13
+ from pydantic import ValidationError
14
+
15
+
16
+ def config_errors(config_model, payload: Any) -> "list[str]":
17
+ if not isinstance(payload, dict):
18
+ return [f"config:<root>: expected an object, got {type(payload).__name__}"]
19
+ try:
20
+ config_model(**payload)
21
+ return []
22
+ except ValidationError as exc:
23
+ out = []
24
+ for err in exc.errors():
25
+ loc = ".".join(str(p) for p in err.get("loc", ())) or "<root>"
26
+ out.append(f"config:{loc}: {err.get('msg', 'invalid')}")
27
+ return out