compose-plugins 0.1.0__tar.gz → 0.3.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.
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/PKG-INFO +34 -9
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/README.md +33 -8
- compose_plugins-0.3.0/compose_plugins/__init__.py +31 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/conformance.py +162 -4
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/consent.py +242 -14
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/derive.py +18 -0
- compose_plugins-0.3.0/compose_plugins/errors.py +209 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/fixtures/__init__.py +11 -4
- compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_eula/EULA.txt +14 -0
- compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_eula/manifest.json +52 -0
- compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_v1/hello_world/plugin.py +54 -0
- compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_v2/__init__.py +0 -0
- compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_v2/hello_world/__init__.py +1 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/host.py +58 -2
- compose_plugins-0.3.0/compose_plugins/lifecycle.py +1193 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/manifest.py +465 -22
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/package.py +160 -1
- compose_plugins-0.3.0/compose_plugins/schema/__init__.py +8 -0
- compose_plugins-0.3.0/compose_plugins/schema/manifest-0.2.schema.json +226 -0
- compose_plugins-0.3.0/compose_plugins/schema/manifest-0.3.schema.json +265 -0
- compose_plugins-0.3.0/compose_plugins/store.py +364 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/version.py +1 -1
- compose_plugins-0.3.0/compose_plugins/web.py +512 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins.egg-info/PKG-INFO +34 -9
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins.egg-info/SOURCES.txt +20 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/pyproject.toml +3 -1
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_qa_wave1_rulings.py +6 -4
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_schema_file.py +29 -4
- compose_plugins-0.3.0/tests/test_v02_install_log.py +797 -0
- compose_plugins-0.3.0/tests/test_v02_license_eula.py +621 -0
- compose_plugins-0.3.0/tests/test_v02_record_decline.py +338 -0
- compose_plugins-0.3.0/tests/test_v02_schema_by_contract.py +99 -0
- compose_plugins-0.3.0/tests/test_v02_uninstall_confirm.py +218 -0
- compose_plugins-0.3.0/tests/test_v03_lifecycle.py +695 -0
- compose_plugins-0.3.0/tests/test_v03_manifest.py +458 -0
- compose_plugins-0.3.0/tests/test_v03_r27.py +514 -0
- compose_plugins-0.3.0/tests/test_v03_r27_round3.py +234 -0
- compose_plugins-0.3.0/tests/test_v03_reads_0_2.py +217 -0
- compose_plugins-0.3.0/tests/test_v03_uninstall_data.py +274 -0
- compose_plugins-0.3.0/tests/test_v03_warnings.py +385 -0
- compose_plugins-0.3.0/tests/test_v03_web.py +254 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_version.py +6 -5
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_wave2_lifecycle.py +3 -1
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_wave2_web.py +13 -1
- compose_plugins-0.1.0/compose_plugins/__init__.py +0 -15
- compose_plugins-0.1.0/compose_plugins/errors.py +0 -103
- compose_plugins-0.1.0/compose_plugins/lifecycle.py +0 -553
- compose_plugins-0.1.0/compose_plugins/schema/__init__.py +0 -6
- compose_plugins-0.1.0/compose_plugins/store.py +0 -66
- compose_plugins-0.1.0/compose_plugins/web.py +0 -286
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/LICENSE +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/_child.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/_probe.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/config.py +0 -0
- {compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v1 → compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_eula}/__init__.py +0 -0
- {compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v1 → compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_eula}/hello_world/__init__.py +0 -0
- {compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v1 → compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_eula}/hello_world/plugin.py +0 -0
- {compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v2 → compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_v1}/__init__.py +0 -0
- {compose_plugins-0.1.0/compose_plugins/fixtures/hello_world_v2 → compose_plugins-0.3.0/compose_plugins/fixtures/hello_world_v1}/hello_world/__init__.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/fixtures/hello_world_v1/manifest.json +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/fixtures/hello_world_v2/hello_world/plugin.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/fixtures/hello_world_v2/manifest.json +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/probe_client.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/runner.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins/schema/manifest-0.1.schema.json +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins.egg-info/dependency_links.txt +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins.egg-info/entry_points.txt +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins.egg-info/requires.txt +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/compose_plugins.egg-info/top_level.txt +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/setup.cfg +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_consent.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_consent_record_r9.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_host_name_r10.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_manifest.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_package.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_r21_permissions.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_r24_conformance_hooks.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_validator_readings.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_wave2_build.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_wave2_conformance.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_wave2_r18.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_wave2_r19.py +0 -0
- {compose_plugins-0.1.0 → compose_plugins-0.3.0}/tests/test_wave2_runner.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: compose-plugins
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: The shared plug-in contract library (manifest, consent, version rule) for ComposeIO and Gnomon hosts
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -12,9 +12,32 @@ Dynamic: license-file
|
|
|
12
12
|
# compose-plugins
|
|
13
13
|
|
|
14
14
|
The shared plug-in contract library for ComposeIO's ComposeServer and for
|
|
15
|
-
Gnomon, implementing the Shared Plug-in Contract v0.
|
|
16
|
-
`[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24
|
|
17
|
-
INSTALLED and CONSENTED to, plus the shared
|
|
15
|
+
Gnomon, implementing the Shared Plug-in Contract v0.3 (ComposeIO spec 95,
|
|
16
|
+
`[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24 plus its v0.2 delta plus the v0.3 delta,
|
|
17
|
+
section 18). It is the layer a plug-in is INSTALLED and CONSENTED to, plus the shared
|
|
18
|
+
manager that drives it. See `CHANGELOG.md` for what 0.3.0 changes and what was measured.
|
|
19
|
+
|
|
20
|
+
Contract 0.3 is an additive MINOR over 0.2 that FREEZES the manifest schema: optional
|
|
21
|
+
`capabilities` (`agent-messaging` is defined) and `warnings` (`{id, title, text}`, each
|
|
22
|
+
acknowledged on its own, its sha256 stored in the consent record); an optional
|
|
23
|
+
`Host.policy` hook (host-required warnings, refusal by policy) and `Host.data_dir`;
|
|
24
|
+
consent only at install and at an upgrade that widens or changes the EULA, a capability
|
|
25
|
+
or a warning; a refuse that always stops (an upgrade with no gate and `accepted=False`
|
|
26
|
+
raises `OperatorDeclined`); an operator-attributed lifecycle record in `installs.jsonl`
|
|
27
|
+
(`operator`, `result`, `consent_id`, new events `configure` and `decline`); an advisory
|
|
28
|
+
for grant-bearing `config_schema` fields; and a keep-or-delete choice for the plug-in's
|
|
29
|
+
data folder at uninstall. A host that mounts the web manager MUST keep every
|
|
30
|
+
state-changing route out of agents' reach (`[CXC-PC-V03-HOST-AGENT-BLOCK]`): the
|
|
31
|
+
library cannot tell a person from an agent.
|
|
32
|
+
|
|
33
|
+
Contract 0.2 is an additive MINOR over 0.1: optional manifest fields `license`
|
|
34
|
+
(an SPDX expression, informational) and `eula` (a package-relative UTF-8 text
|
|
35
|
+
file, shown verbatim at consent, its sha256 stored in the consent record);
|
|
36
|
+
`PluginManager.record_decline(prompt, *, decided_by)`; the append-only install
|
|
37
|
+
event log `installs.jsonl` and `PluginManager.install_log_findings()`; and a
|
|
38
|
+
confirm step in front of uninstall in the web manager. The one non-additive
|
|
39
|
+
change: the web manager's `POST .../uninstall` no longer uninstalls, it shows
|
|
40
|
+
the confirm screen.
|
|
18
41
|
|
|
19
42
|
One runtime dependency: `composebus==0.1.2` (the runtime `ComposePlugin` and
|
|
20
43
|
its `MessageType` names). No ComposeIO distribution is required, so a host
|
|
@@ -24,7 +47,7 @@ that is not ComposeIO can use the library on its own.
|
|
|
24
47
|
|
|
25
48
|
| module | what |
|
|
26
49
|
|---|---|
|
|
27
|
-
| `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON
|
|
50
|
+
| `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON Schemas, one per contract (`schema/manifest-0.1.schema.json` and `schema/manifest-0.2.schema.json`, both byte-identical to the compose-plugins 0.2.0 files, and `schema/manifest-0.3.schema.json`, frozen at the tag; `schema_for(manifest)` picks by the manifest's `contract`), generated from the validator's own patterns |
|
|
28
51
|
| `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
52
|
| `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
53
|
| `compose_plugins.consent` | consent content rendered from the manifest alone, the granted set, the widening rule, and the append-only consent-record store |
|
|
@@ -33,10 +56,10 @@ that is not ComposeIO can use the library on its own.
|
|
|
33
56
|
| `compose_plugins.config` | config validated against `config_schema` before the plug-in is instantiated; invalid config parks loudly |
|
|
34
57
|
| `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
58
|
| `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)
|
|
59
|
+
| `compose_plugins.store` | the install records (the registry), stored config, and the append-only install event log `InstallLog` with its findings |
|
|
37
60
|
| `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
61
|
| `compose_plugins.conformance` | the conformance script (below) |
|
|
39
|
-
| `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins |
|
|
62
|
+
| `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins, and `hello-world-eula` (contract 0.2, declares a EULA); unmodified since 0.2 |
|
|
40
63
|
|
|
41
64
|
```python
|
|
42
65
|
from compose_plugins.package import read_manifest
|
|
@@ -55,7 +78,9 @@ non-conformant. It runs the hello-world lifecycle in nine steps (install with
|
|
|
55
78
|
consent, configure, start, health, a publish/subscribe round trip, an upgrade
|
|
56
79
|
to v2 with re-consent and config migration, disable, re-enable, and uninstall
|
|
57
80
|
with the retained topic tombstoned and the consent record kept). It then runs
|
|
58
|
-
negative controls NC1 to
|
|
81
|
+
negative controls NC1 to NC10 (NC9: a non-widening upgrade with `accepted=False`
|
|
82
|
+
stops and writes one `decline` entry; NC10: a grant-bearing config property draws a
|
|
83
|
+
named advisory and is not refused), each of which must fail loudly. This happens once
|
|
59
84
|
per host and per isolation level the host supports. At the subprocess level it
|
|
60
85
|
also checks that the child holds no network socket and that a child crash is
|
|
61
86
|
reported as `failed(<reason>)`.
|
|
@@ -76,7 +101,7 @@ plus the two members added in spec 95 r24:
|
|
|
76
101
|
installed.
|
|
77
102
|
- `host_section(fixture: str) -> dict` (optional): this host's own valid
|
|
78
103
|
section for a fixture id: `hello-world-v1`, `hello-world-v2`, or a
|
|
79
|
-
negative-control id `NC1` to `
|
|
104
|
+
negative-control id `NC1` to `NC10`. Before every install it hands to the
|
|
80
105
|
host, the runner writes that value at `hosts.<target.host.name>`, so the
|
|
81
106
|
consented `manifest_sha256` covers it. A target without the hook gets `{}`
|
|
82
107
|
there. The shared fixtures never decide a host's section: each host owns its
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
# compose-plugins
|
|
2
2
|
|
|
3
3
|
The shared plug-in contract library for ComposeIO's ComposeServer and for
|
|
4
|
-
Gnomon, implementing the Shared Plug-in Contract v0.
|
|
5
|
-
`[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24
|
|
6
|
-
INSTALLED and CONSENTED to, plus the shared
|
|
4
|
+
Gnomon, implementing the Shared Plug-in Contract v0.3 (ComposeIO spec 95,
|
|
5
|
+
`[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24 plus its v0.2 delta plus the v0.3 delta,
|
|
6
|
+
section 18). It is the layer a plug-in is INSTALLED and CONSENTED to, plus the shared
|
|
7
|
+
manager that drives it. See `CHANGELOG.md` for what 0.3.0 changes and what was measured.
|
|
8
|
+
|
|
9
|
+
Contract 0.3 is an additive MINOR over 0.2 that FREEZES the manifest schema: optional
|
|
10
|
+
`capabilities` (`agent-messaging` is defined) and `warnings` (`{id, title, text}`, each
|
|
11
|
+
acknowledged on its own, its sha256 stored in the consent record); an optional
|
|
12
|
+
`Host.policy` hook (host-required warnings, refusal by policy) and `Host.data_dir`;
|
|
13
|
+
consent only at install and at an upgrade that widens or changes the EULA, a capability
|
|
14
|
+
or a warning; a refuse that always stops (an upgrade with no gate and `accepted=False`
|
|
15
|
+
raises `OperatorDeclined`); an operator-attributed lifecycle record in `installs.jsonl`
|
|
16
|
+
(`operator`, `result`, `consent_id`, new events `configure` and `decline`); an advisory
|
|
17
|
+
for grant-bearing `config_schema` fields; and a keep-or-delete choice for the plug-in's
|
|
18
|
+
data folder at uninstall. A host that mounts the web manager MUST keep every
|
|
19
|
+
state-changing route out of agents' reach (`[CXC-PC-V03-HOST-AGENT-BLOCK]`): the
|
|
20
|
+
library cannot tell a person from an agent.
|
|
21
|
+
|
|
22
|
+
Contract 0.2 is an additive MINOR over 0.1: optional manifest fields `license`
|
|
23
|
+
(an SPDX expression, informational) and `eula` (a package-relative UTF-8 text
|
|
24
|
+
file, shown verbatim at consent, its sha256 stored in the consent record);
|
|
25
|
+
`PluginManager.record_decline(prompt, *, decided_by)`; the append-only install
|
|
26
|
+
event log `installs.jsonl` and `PluginManager.install_log_findings()`; and a
|
|
27
|
+
confirm step in front of uninstall in the web manager. The one non-additive
|
|
28
|
+
change: the web manager's `POST .../uninstall` no longer uninstalls, it shows
|
|
29
|
+
the confirm screen.
|
|
7
30
|
|
|
8
31
|
One runtime dependency: `composebus==0.1.2` (the runtime `ComposePlugin` and
|
|
9
32
|
its `MessageType` names). No ComposeIO distribution is required, so a host
|
|
@@ -13,7 +36,7 @@ that is not ComposeIO can use the library on its own.
|
|
|
13
36
|
|
|
14
37
|
| module | what |
|
|
15
38
|
|---|---|
|
|
16
|
-
| `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON
|
|
39
|
+
| `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON Schemas, one per contract (`schema/manifest-0.1.schema.json` and `schema/manifest-0.2.schema.json`, both byte-identical to the compose-plugins 0.2.0 files, and `schema/manifest-0.3.schema.json`, frozen at the tag; `schema_for(manifest)` picks by the manifest's `contract`), generated from the validator's own patterns |
|
|
17
40
|
| `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
41
|
| `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
42
|
| `compose_plugins.consent` | consent content rendered from the manifest alone, the granted set, the widening rule, and the append-only consent-record store |
|
|
@@ -22,10 +45,10 @@ that is not ComposeIO can use the library on its own.
|
|
|
22
45
|
| `compose_plugins.config` | config validated against `config_schema` before the plug-in is instantiated; invalid config parks loudly |
|
|
23
46
|
| `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
47
|
| `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)
|
|
48
|
+
| `compose_plugins.store` | the install records (the registry), stored config, and the append-only install event log `InstallLog` with its findings |
|
|
26
49
|
| `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
50
|
| `compose_plugins.conformance` | the conformance script (below) |
|
|
28
|
-
| `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins |
|
|
51
|
+
| `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins, and `hello-world-eula` (contract 0.2, declares a EULA); unmodified since 0.2 |
|
|
29
52
|
|
|
30
53
|
```python
|
|
31
54
|
from compose_plugins.package import read_manifest
|
|
@@ -44,7 +67,9 @@ non-conformant. It runs the hello-world lifecycle in nine steps (install with
|
|
|
44
67
|
consent, configure, start, health, a publish/subscribe round trip, an upgrade
|
|
45
68
|
to v2 with re-consent and config migration, disable, re-enable, and uninstall
|
|
46
69
|
with the retained topic tombstoned and the consent record kept). It then runs
|
|
47
|
-
negative controls NC1 to
|
|
70
|
+
negative controls NC1 to NC10 (NC9: a non-widening upgrade with `accepted=False`
|
|
71
|
+
stops and writes one `decline` entry; NC10: a grant-bearing config property draws a
|
|
72
|
+
named advisory and is not refused), each of which must fail loudly. This happens once
|
|
48
73
|
per host and per isolation level the host supports. At the subprocess level it
|
|
49
74
|
also checks that the child holds no network socket and that a child crash is
|
|
50
75
|
reported as `failed(<reason>)`.
|
|
@@ -65,7 +90,7 @@ plus the two members added in spec 95 r24:
|
|
|
65
90
|
installed.
|
|
66
91
|
- `host_section(fixture: str) -> dict` (optional): this host's own valid
|
|
67
92
|
section for a fixture id: `hello-world-v1`, `hello-world-v2`, or a
|
|
68
|
-
negative-control id `NC1` to `
|
|
93
|
+
negative-control id `NC1` to `NC10`. Before every install it hands to the
|
|
69
94
|
host, the runner writes that value at `hosts.<target.host.name>`, so the
|
|
70
95
|
consented `manifest_sha256` covers it. A target without the hook gets `{}`
|
|
71
96
|
there. The shared fixtures never decide a host's section: each host owns its
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""compose_plugins — the shared plug-in contract library ([SPEC:CXC-PLUGIN-CONTRACT],
|
|
2
|
+
contract 0.3: spec 95 r24 plus its v0.2 delta, [DELTA:CXC-PLUGIN-CONTRACT-V0-2-DELTA],
|
|
3
|
+
plus the v0.3 delta, section 18 of spec 95 ([CXC-PC-V03-BASIS])).
|
|
4
|
+
|
|
5
|
+
The manifest validator and JSON Schema (``manifest``), the no-execution manifest
|
|
6
|
+
and EULA reader and the manifest_sha256 rule (``package``), the version rule
|
|
7
|
+
(``version``), consent content, granted sets, widening and the consent-record
|
|
8
|
+
store (``consent``), the ``Host`` protocol (``host``), the lifecycle operations
|
|
9
|
+
and ``record_decline`` (``lifecycle``), config validation (``config``),
|
|
10
|
+
``compose-plugin build`` and the drift check (``derive``), the in-process and
|
|
11
|
+
subprocess runner (``runner``), the registry, config and install-event-log
|
|
12
|
+
stores (``store``), the plain web Plugin Manager (``web``), and the conformance
|
|
13
|
+
script (``conformance``) with its hello-world fixtures. See README.md.
|
|
14
|
+
|
|
15
|
+
Contract 0.2 adds these exports ([CXC-PC-V02-STORES-COMPAT] manager-signatures);
|
|
16
|
+
contract 0.3 adds ``OperatorDeclined``, ``PolicyRefused`` and ``WarningAckRefused``
|
|
17
|
+
([CXC-PC-V03-STORES-COMPAT] manager-signatures).
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
__version__ = "0.3.0"
|
|
21
|
+
|
|
22
|
+
from .consent import eula_text_shown # noqa: E402
|
|
23
|
+
from .errors import ( # noqa: E402
|
|
24
|
+
EulaShaMismatch, InstallLogRefused, OperatorDeclined, PolicyRefused, PromptNotPrepared,
|
|
25
|
+
PromptStale, WarningAckRefused,
|
|
26
|
+
)
|
|
27
|
+
from .store import InstallLog, InstallLogFinding # noqa: E402
|
|
28
|
+
|
|
29
|
+
__all__ = ["EulaShaMismatch", "InstallLog", "InstallLogFinding", "InstallLogRefused",
|
|
30
|
+
"OperatorDeclined", "PolicyRefused", "PromptNotPrepared", "PromptStale",
|
|
31
|
+
"WarningAckRefused", "__version__", "eula_text_shown"]
|
|
@@ -42,7 +42,7 @@ from dataclasses import dataclass
|
|
|
42
42
|
from pathlib import Path
|
|
43
43
|
from typing import Any, Callable
|
|
44
44
|
|
|
45
|
-
from .errors import HostNameRefused, ManifestRefused, ManifestShaMismatch
|
|
45
|
+
from .errors import HostNameRefused, ManifestRefused, ManifestShaMismatch, OperatorDeclined
|
|
46
46
|
from .fixtures import package_dir
|
|
47
47
|
from .lifecycle import ConsentDenied
|
|
48
48
|
from .manifest import check_host_name
|
|
@@ -71,7 +71,7 @@ class Fail(AssertionError):
|
|
|
71
71
|
#: the script's own fixture ids, the only values ``host_section`` is called with
|
|
72
72
|
#: ([CXC-PC-CONFORMANCE-SCRIPT] ``host-section-hook``, spec 95 r24)
|
|
73
73
|
FIXTURE_IDS = ("hello-world-v1", "hello-world-v2",
|
|
74
|
-
"NC1", "NC2", "NC3", "NC4", "NC5", "NC6", "NC7", "NC8")
|
|
74
|
+
"NC1", "NC2", "NC3", "NC4", "NC5", "NC6", "NC7", "NC8", "NC9", "NC10")
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
class ConformanceRefused(Exception):
|
|
@@ -481,10 +481,18 @@ def _refused_at_install(r: Run, t, fixture: str, edit, must: "list[str]") -> Non
|
|
|
481
481
|
_nothing_installed(r, t)
|
|
482
482
|
|
|
483
483
|
|
|
484
|
+
def _next_minor(contract: str) -> str:
|
|
485
|
+
major, minor = contract.split(".")
|
|
486
|
+
return f"{major}.{int(minor) + 1}"
|
|
487
|
+
|
|
488
|
+
|
|
484
489
|
@_fresh
|
|
485
490
|
def nc3(r: Run, t) -> None:
|
|
486
|
-
|
|
487
|
-
|
|
491
|
+
# one MINOR newer than this host (spec 95 r24 wrote "0.2" for a 0.1 host;
|
|
492
|
+
# a 0.2 host accepts "0.2", so the control uses the next MINOR)
|
|
493
|
+
newer = _next_minor(HOST_CONTRACT)
|
|
494
|
+
_refused_at_install(r, t, "NC3", lambda d: d.update(contract=newer),
|
|
495
|
+
[newer, HOST_CONTRACT])
|
|
488
496
|
|
|
489
497
|
|
|
490
498
|
@_fresh
|
|
@@ -593,6 +601,154 @@ def nc8(r: Run, t) -> None:
|
|
|
593
601
|
check(t.manager.state(DOMAIN) == "installed", "hello-world's own manifest did not install")
|
|
594
602
|
|
|
595
603
|
|
|
604
|
+
def _web_decide(t, path: str, form: dict, decision: str) -> "tuple[str, str]":
|
|
605
|
+
"""POST ``form`` plus ``decision`` to the library's web manager mounted on the target's
|
|
606
|
+
manager under an empty prefix, as a same-origin request with a valid CSRF token and a
|
|
607
|
+
script-only identity (the target's own auth hook is replaced on the instance for the
|
|
608
|
+
call and put back). Returns (status, Location)."""
|
|
609
|
+
import io
|
|
610
|
+
from urllib.parse import urlencode
|
|
611
|
+
from .web import PluginManagerApp
|
|
612
|
+
host = t.host
|
|
613
|
+
had = "auth_hook" in vars(host)
|
|
614
|
+
old = vars(host).get("auth_hook")
|
|
615
|
+
host.auth_hook = lambda environ: environ.get("_conformance_operator")
|
|
616
|
+
try:
|
|
617
|
+
app = PluginManagerApp(t.manager)
|
|
618
|
+
ident = "conformance-operator"
|
|
619
|
+
body = urlencode({**form, "decision": decision, "csrf": app.csrf_token(ident)}).encode()
|
|
620
|
+
environ = {"REQUEST_METHOD": "POST", "SCRIPT_NAME": "", "PATH_INFO": path,
|
|
621
|
+
"CONTENT_LENGTH": str(len(body)), "wsgi.input": io.BytesIO(body),
|
|
622
|
+
"wsgi.url_scheme": "http", "HTTP_HOST": "127.0.0.1:8080",
|
|
623
|
+
"REMOTE_ADDR": "127.0.0.1", "_conformance_operator": ident}
|
|
624
|
+
out: dict = {}
|
|
625
|
+
app(environ, lambda status, headers: out.update(status=status, headers=dict(headers)))
|
|
626
|
+
return out["status"], out["headers"].get("Location", "")
|
|
627
|
+
finally:
|
|
628
|
+
if had:
|
|
629
|
+
host.auth_hook = old
|
|
630
|
+
else:
|
|
631
|
+
del host.auth_hook
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
@_fresh
|
|
635
|
+
def nc9(r: Run, t) -> None:
|
|
636
|
+
"""[CXC-PC-V03-NC-UPGRADE-DECLINED]: a non-widening upgrade with
|
|
637
|
+
``accepted=False`` aborts with no change and writes one ``decline`` entry."""
|
|
638
|
+
m = t.manager
|
|
639
|
+
r.install(t, r.fixture(t, "v1", "NC9"))
|
|
640
|
+
m.configure(DOMAIN, {"greeting": "nc9"})
|
|
641
|
+
m.enable(DOMAIN)
|
|
642
|
+
check(settle(t, lambda s: s == "running") == "running", "v1 did not reach running")
|
|
643
|
+
root = Path(t.host.state_root)
|
|
644
|
+
cfg = root / "config" / f"{DOMAIN}.json"
|
|
645
|
+
snap = lambda: ((root / "installs.json").read_bytes(), # noqa: E731
|
|
646
|
+
sorted(str(p.relative_to(t.host.install_root))
|
|
647
|
+
for p in t.host.install_root.rglob("*") if p.is_file()))
|
|
648
|
+
v1b = r.fixture(t, "v1", "NC9", lambda d: d.update(version="1.0.1"))
|
|
649
|
+
p = m.prepare_upgrade(v1b)
|
|
650
|
+
check(p.gate is False, "a version-only upgrade claims it needs the consent gate")
|
|
651
|
+
before, n_consent, n_log = snap(), len(m.consent.records()), len(m.install_log.events())
|
|
652
|
+
cfg_before = cfg.read_bytes()
|
|
653
|
+
log_before = [(e["seq"], e["consent_basis"], e["consent_id"]) for e in m.install_log.events()]
|
|
654
|
+
try:
|
|
655
|
+
m.upgrade(v1b, consented_sha256=p.manifest_sha256, operator=t.operator,
|
|
656
|
+
accepted=False)
|
|
657
|
+
except OperatorDeclined as exc:
|
|
658
|
+
r.observe("refusal", exc)
|
|
659
|
+
check("DECLINED by the operator" in str(exc), "the refusal does not say declined")
|
|
660
|
+
else:
|
|
661
|
+
raise Fail("a declined upgrade went ahead")
|
|
662
|
+
check(snap() == before, "installs.json or the install root changed")
|
|
663
|
+
check(len(m.consent.records()) == n_consent, "a consent record was written")
|
|
664
|
+
new = m.install_log.events()[n_log:]
|
|
665
|
+
r.observe("log entries added", [(e["event"], e.get("result")) for e in new])
|
|
666
|
+
check(len(new) == 1 and new[0]["event"] == "decline" and new[0]["result"] == "declined"
|
|
667
|
+
and new[0]["consent"] is None, "not exactly one decline entry")
|
|
668
|
+
check(m.record(DOMAIN)["version"] == "1.0.0" and m.state(DOMAIN) == "enabled",
|
|
669
|
+
"v1 is not still enabled")
|
|
670
|
+
# [CXC-PC-V03-RULING-CONFORMANCE-NC9]: the spec's full `expected` list
|
|
671
|
+
check(cfg.read_bytes() == cfg_before, "the stored config changed")
|
|
672
|
+
check(m.status(DOMAIN) == "running", f"v1 is not running ({m.status(DOMAIN)})")
|
|
673
|
+
check(new[0]["consent_basis"] == "none" and new[0]["consent_id"] is None,
|
|
674
|
+
"the decline entry carries a consent_basis or consent_id")
|
|
675
|
+
check([(e["seq"], e["consent_basis"], e["consent_id"])
|
|
676
|
+
for e in m.install_log.events()[:n_log]] == log_before,
|
|
677
|
+
"an earlier entry's consent_basis or consent_id changed")
|
|
678
|
+
# [CXC-PC-V03-RULING-CONFORMANCE-NC9] the web half: the web manager's no-gate upgrade
|
|
679
|
+
# screen, answered with Cancel and with Refuse, redirects to the plug-in's detail page
|
|
680
|
+
# and changes nothing; each writes one `decline` entry (the library's own half above)
|
|
681
|
+
for decision in ("cancel", "refuse"):
|
|
682
|
+
n_before = len(m.install_log.events())
|
|
683
|
+
st, location = _web_decide(t, f"/plugin/{DOMAIN}/upgrade/decide",
|
|
684
|
+
{"source": str(v1b), "sha256": p.manifest_sha256}, decision)
|
|
685
|
+
r.observe(f"web decision={decision}", f"{st} -> {location}")
|
|
686
|
+
check(st.startswith("303") and location == f"/plugin/{DOMAIN}",
|
|
687
|
+
f"web {decision}: not a 303 to the detail page ({st} {location})")
|
|
688
|
+
check(snap() == before and cfg.read_bytes() == cfg_before,
|
|
689
|
+
f"web {decision}: installs.json, the code tree or the config changed")
|
|
690
|
+
check(len(m.consent.records()) == n_consent, f"web {decision}: a consent record was written")
|
|
691
|
+
added = m.install_log.events()[n_before:]
|
|
692
|
+
check(len(added) == 1 and added[0]["event"] == "decline"
|
|
693
|
+
and added[0]["consent"] is None and added[0]["consent_id"] is None,
|
|
694
|
+
f"web {decision}: not exactly one decline entry")
|
|
695
|
+
check(m.record(DOMAIN)["version"] == "1.0.0" and m.status(DOMAIN) == "running",
|
|
696
|
+
f"web {decision}: v1 is not still running")
|
|
697
|
+
m.upgrade(v1b, consented_sha256=p.manifest_sha256, operator=t.operator, accepted=True)
|
|
698
|
+
check(m.record(DOMAIN)["version"] == "1.0.1", "the accepted upgrade did not upgrade")
|
|
699
|
+
check(len(m.consent.records()) == n_consent, "a no-gate upgrade wrote a consent record")
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
@_fresh
|
|
703
|
+
def nc10(r: Run, t) -> None:
|
|
704
|
+
"""[CXC-PC-V03-NC-GRANT-BEARING-CONFIG]: a 0.3 manifest whose config_schema
|
|
705
|
+
names a grant-bearing property draws one named advisory and is NOT refused;
|
|
706
|
+
the same manifest stating 0.2 draws none."""
|
|
707
|
+
cases = {
|
|
708
|
+
"target_host": ({"target_host": {"type": "string"}},
|
|
709
|
+
"config_schema/properties/target_host"),
|
|
710
|
+
"site": ({"site": {"type": "string", "format": "uri"}},
|
|
711
|
+
"config_schema/properties/site"),
|
|
712
|
+
"$defs": (None, "config_schema/$defs/endpoint/properties/data_path"),
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
def edit_for(name: str, contract: str):
|
|
716
|
+
def edit(d: dict) -> None:
|
|
717
|
+
d["contract"] = contract
|
|
718
|
+
props, _ = cases[name]
|
|
719
|
+
if props is not None:
|
|
720
|
+
d["config_schema"]["properties"].update(props)
|
|
721
|
+
else:
|
|
722
|
+
d["config_schema"]["$defs"] = {"endpoint": {"type": "object", "properties": {
|
|
723
|
+
"data_path": {"type": "string"}}}}
|
|
724
|
+
return edit
|
|
725
|
+
for name, (_, pointer) in cases.items():
|
|
726
|
+
for contract, want in (("0.3", [pointer]), ("0.2", [])):
|
|
727
|
+
tt = r.new_target()
|
|
728
|
+
try:
|
|
729
|
+
p = tt.manager.prepare_install(
|
|
730
|
+
r.fixture(tt, "v1", "NC10", edit_for(name, contract)))
|
|
731
|
+
got = [a.field for a in p.manifest.advisories]
|
|
732
|
+
r.observe(f"{name} stating {contract}: advisories", got)
|
|
733
|
+
check(got == want, f"{name} {contract}: advisories {got} != {want}")
|
|
734
|
+
line = f"config field {pointer} looks grant-bearing (structural check; not verified)"
|
|
735
|
+
check((line in p.content.text()) == bool(want), "consent line wrong")
|
|
736
|
+
tt.manager.install(p.source, consented_sha256=p.manifest_sha256,
|
|
737
|
+
operator=tt.operator, accepted=True)
|
|
738
|
+
check(tt.manager.state(DOMAIN) == "installed", f"{name} {contract} not installed")
|
|
739
|
+
finally:
|
|
740
|
+
tt.close()
|
|
741
|
+
tt = r.new_target()
|
|
742
|
+
try:
|
|
743
|
+
def plain(d: dict) -> None:
|
|
744
|
+
d["contract"] = "0.3"
|
|
745
|
+
d["config_schema"]["properties"]["repeat"] = {"type": "integer"}
|
|
746
|
+
p = tt.manager.prepare_install(r.fixture(tt, "v1", "NC10", plain))
|
|
747
|
+
check(list(p.manifest.advisories) == [], "greeting and repeat drew an advisory")
|
|
748
|
+
finally:
|
|
749
|
+
tt.close()
|
|
750
|
+
|
|
751
|
+
|
|
596
752
|
@_fresh
|
|
597
753
|
def nc_r15(r: Run, t) -> None:
|
|
598
754
|
_refused_at_install(r, t, "hello-world-v1",
|
|
@@ -642,6 +798,8 @@ STEPS: "tuple[Step, ...]" = (
|
|
|
642
798
|
Step("NC6", "widening-refused", "CXC-PC-NC-WIDENING-REFUSED", nc6),
|
|
643
799
|
Step("NC7", "host-provided-requirement", "CXC-PC-NC-HOST-PROVIDED-REQUIREMENT", nc7),
|
|
644
800
|
Step("NC8", "malformed-permission", "CXC-PC-NC-MALFORMED-PERMISSION", nc8),
|
|
801
|
+
Step("NC9", "upgrade-declined", "CXC-PC-V03-NC-UPGRADE-DECLINED", nc9),
|
|
802
|
+
Step("NC10", "grant-bearing-config", "CXC-PC-V03-NC-GRANT-BEARING-CONFIG", nc10),
|
|
645
803
|
Step("R15", "requirements-refused-in-v0.1", "CXC-PC-LIFECYCLE-INSTALL (r15)", nc_r15),
|
|
646
804
|
Step("H1", "degraded-empty-greeting", "CXC-PC-HELLO-V1 / LIFECYCLE-HEALTH", h1_degraded),
|
|
647
805
|
Step("L1", "runner-refuses-non-AF_UNIX", "CXC-PC-RUNNER-LOCAL-ONLY", l1_refuses_non_unix,
|