Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T01:47:26.086Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

test-omega-installed-observation-waivers

272 lines · 10.2 KB · text
1#!/usr/bin/env python3
2"""Assert that a waived installed observation can never become a pass.
3
4A waiver records that an observation was *not* made. The failure this guards
5against is quiet and late: somebody edits `waived` to `passed`, or rolls a
6report with waivers up into a green status, and a proof record then claims an
7observation nobody performed. That is the exact class of claim the falsifier on
8omega#16 exists to prevent, so it is checked mechanically rather than by
9review.
10
11Run: `script/test-omega-installed-observation-waivers`
12"""
13
14from __future__ import annotations
15
16import json
17import sys
18import tempfile
19from copy import deepcopy
20from pathlib import Path
21
22sys.path.insert(0, str(Path(__file__).resolve().parent))
23
24from omega_identity_evidence import (  # noqa: E402
25    ACCESSIBILITY_CHECKS,
26    INSTALLED_OBSERVATIONS_SCHEMA,
27    IdentityEvidenceError,
28    MANUAL_JOURNEY_CHECKS,
29    WAIVABLE_CHECKS,
30    canonical_digest,
31    sha256_file,
32    validate_installed_observations,
33)
34
35CANDIDATE = "a" * 64
36WAIVED_CHECK = "screen-reader-output"
37
38FACTS: dict[str, dict[str, object]] = {
39    "identity-first-first-run": {
40        "identity_presented_before_editor_setup": True,
41        "identity_ready": True,
42    },
43    "theme-and-agent-setup-baseline": {
44        "theme_families": ["Aiur", "Ayu", "Gruvbox"],
45        "agent_setup_visible": True,
46    },
47    "zed-data-before-after-isolation": {
48        "zed_before_sha256": "b" * 64,
49        "zed_after_sha256": "b" * 64,
50        "unchanged": True,
51    },
52    "keyboard-focus-traversal": {
53        "all_controls_reachable": True,
54        "reverse_traversal": True,
55        "focus_visible": True,
56        "keyboard_activation": True,
57    },
58    "screen-reader-output": {
59        "assistive_technology": "macOS AXUIElement accessibility tree",
60        "identity_status_announced": True,
61        "controls_named": True,
62        "secret_value_exposed": False,
63    },
64    "viewport-360-pixels": {
65        "viewport_width_pixels": 360,
66        "horizontal_overflow": False,
67        "completion_action_visible": True,
68    },
69    "larger-ui-font": {
70        "ui_font_size_pixels": 24,
71        "content_clipped": False,
72        "completion_action_visible": True,
73    },
74    "light-theme": {"appearance": "light", "content_legible": True},
75    "dark-theme": {"appearance": "dark", "content_legible": True},
76    "high-contrast": {
77        "system_increase_contrast": True,
78        "content_legible": True,
79        "focus_indicator_visible": True,
80    },
81    "reduced-motion": {
82        "system_reduce_motion": True,
83        "motion_required_for_completion": False,
84    },
85}
86
87WAIVER = {
88    "owner_quote": "WE ARE NOT ADDING ASSISTIVE TECHNOLOGY AT THIS TIME IF ZED DOESNT HAVE IT",
89    "owner_direction_date": "2026-07-25T00:00:00Z",
90    "basis": "The candidate publishes no application accessibility tree.",
91    "upstream_parity": {
92        "product": "Zed",
93        "version": "1.12.0",
94        "method": "System Events AXUIElement read of the front window",
95        "observed": "entire contents = 0; direct children = close button",
96    },
97    "issue": "https://github.com/OpenAgentsInc/omega/issues/71",
98}
99
100
101def build_report(reference: dict[str, str], waive: bool) -> dict[str, object]:
102    def entry(check: str) -> dict[str, object]:
103        if waive and check == WAIVED_CHECK:
104            return {
105                "check": check,
106                "status": "waived",
107                "observed_at": "2026-07-25T12:00:00Z",
108                "waiver": deepcopy(WAIVER),
109                "evidence_refs": [dict(reference)],
110            }
111        return {
112            "check": check,
113            "status": "passed",
114            "observed_at": "2026-07-25T12:00:00Z",
115            "facts": deepcopy(FACTS[check]),
116            "evidence_refs": [dict(reference)],
117        }
118
119    report: dict[str, object] = {
120        "schema": INSTALLED_OBSERVATIONS_SCHEMA,
121        "candidate_digest": CANDIDATE,
122        "status": "passed_with_waivers" if waive else "passed",
123        "manual_journey": [entry(check) for check in sorted(MANUAL_JOURNEY_CHECKS)],
124        "accessibility": [entry(check) for check in sorted(ACCESSIBILITY_CHECKS)],
125        "waivers": [WAIVED_CHECK] if waive else [],
126    }
127    report["evidence_sha256"] = canonical_digest(report)
128    return report
129
130
131def check(root: Path, name: str, report: dict[str, object]) -> None:
132    path = root / f"{name}.json"
133    path.write_text(json.dumps(report), encoding="utf-8")
134    validate_installed_observations(path, CANDIDATE, root)
135
136
137def refuses(root: Path, name: str, report: dict[str, object], why: str) -> None:
138    report = deepcopy(report)
139    report.pop("evidence_sha256", None)
140    report["evidence_sha256"] = canonical_digest(report)
141    try:
142        check(root, name, report)
143    except IdentityEvidenceError:
144        return
145    raise AssertionError(f"the validator accepted {why}")
146
147
148def accepts(root: Path, name: str, report: dict[str, object], why: str) -> None:
149    try:
150        check(root, name, report)
151    except IdentityEvidenceError as error:
152        raise AssertionError(f"the validator refused {why}: {error}") from error
153
154
155def main() -> int:
156    with tempfile.TemporaryDirectory() as directory:
157        root = Path(directory)
158        evidence = root / "observation.txt"
159        evidence.write_text("installed observation fixture", encoding="utf-8")
160        reference = {"path": evidence.name, "sha256": sha256_file(evidence)}
161
162        clean = build_report(reference, waive=False)
163        accepts(root, "clean", clean, "a fully performed observation set")
164
165        waived = build_report(reference, waive=True)
166        accepts(root, "waived", waived, "a correctly recorded waiver")
167
168        # The whole point. A waived entry relabelled `passed` has no facts, so
169        # the shape check refuses it.
170        promoted = deepcopy(waived)
171        promoted["accessibility"] = [
172            {**entry, "status": "passed"} if entry["check"] == WAIVED_CHECK else entry
173            for entry in promoted["accessibility"]  # type: ignore[union-attr]
174        ]
175        refuses(root, "promoted", promoted, "a waived entry relabelled as passed")
176
177        # And relabelled *with* invented facts, which is the same lie told more
178        # carefully. The top-level waiver list still names the check.
179        fabricated = deepcopy(waived)
180        fabricated["accessibility"] = [
181            {
182                "check": WAIVED_CHECK,
183                "status": "passed",
184                "observed_at": entry["observed_at"],
185                "facts": deepcopy(FACTS[WAIVED_CHECK]),
186                "evidence_refs": entry["evidence_refs"],
187            }
188            if entry["check"] == WAIVED_CHECK
189            else entry
190            for entry in fabricated["accessibility"]  # type: ignore[union-attr]
191        ]
192        refuses(
193            root,
194            "fabricated",
195            fabricated,
196            "a waived entry rewritten as a pass with invented facts",
197        )
198
199        # A waiver may never roll up into a green status.
200        green = deepcopy(waived)
201        green["status"] = "passed"
202        refuses(root, "green", green, "a report with a waiver claiming `passed`")
203
204        # A waiver hidden from the summary is worse than a visible one.
205        hidden = deepcopy(waived)
206        hidden["waivers"] = []
207        refuses(root, "hidden", hidden, "a waiver missing from the summary list")
208
209        # A declared waiver with no waived entry would let a reader think a
210        # check was skipped when it was silently passed.
211        phantom = deepcopy(clean)
212        phantom["waivers"] = [WAIVED_CHECK]
213        phantom["status"] = "passed_with_waivers"
214        refuses(root, "phantom", phantom, "a declared waiver with no waived entry")
215
216        # A waived entry that also carries facts is neither shape.
217        both = deepcopy(waived)
218        both["accessibility"] = [
219            {**entry, "facts": deepcopy(FACTS[WAIVED_CHECK])}
220            if entry["check"] == WAIVED_CHECK
221            else entry
222            for entry in both["accessibility"]  # type: ignore[union-attr]
223        ]
224        refuses(root, "both", both, "a waived entry that also carries facts")
225
226        # Only checks that are genuinely unobservable may be waived. A
227        # 360-pixel viewport and a larger UI font are ordinary rendering
228        # conditions, so the waiver must not become a shortcut for them.
229        for check_name in sorted(ACCESSIBILITY_CHECKS - WAIVABLE_CHECKS):
230            shortcut = deepcopy(clean)
231            shortcut["accessibility"] = [
232                {
233                    "check": check_name,
234                    "status": "waived",
235                    "observed_at": entry["observed_at"],
236                    "waiver": deepcopy(WAIVER),
237                    "evidence_refs": entry["evidence_refs"],
238                }
239                if entry["check"] == check_name
240                else entry
241                for entry in shortcut["accessibility"]  # type: ignore[union-attr]
242            ]
243            shortcut["waivers"] = [check_name]
244            shortcut["status"] = "passed_with_waivers"
245            refuses(root, f"shortcut-{check_name}", shortcut, f"a waiver of {check_name}")
246
247        # An incomplete run must never validate, waiver or not.
248        incomplete = deepcopy(waived)
249        incomplete["status"] = "incomplete"
250        refuses(root, "incomplete", incomplete, "an incomplete observation set")
251
252        # A waiver with no upstream parity record cannot support the owner
253        # direction it cites, because the direction is conditioned on parity.
254        unbased = deepcopy(waived)
255        unbased["accessibility"] = [
256            {
257                **entry,
258                "waiver": {k: v for k, v in WAIVER.items() if k != "upstream_parity"},
259            }
260            if entry["check"] == WAIVED_CHECK
261            else entry
262            for entry in unbased["accessibility"]  # type: ignore[union-attr]
263        ]
264        refuses(root, "unbased", unbased, "a waiver with no upstream parity record")
265
266    print("ok: a waived installed observation cannot be promoted to passed")
267    return 0
268
269
270if __name__ == "__main__":
271    sys.exit(main())
272
Served at tenant.openagents/omega Member data and write actions are omitted.