agent-bios 0.19.4 → 0.20.0
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.
- package/DEPENDENCIES.md +19 -5
- package/README.md +14 -19
- package/claude/agents/frontier.md +1 -1
- package/claude/guides/claude-prompting.md +475 -234
- package/claude/guides/cli-multi-model-workflow.md +4 -3
- package/claude/guides/gpt-prompting.md +235 -136
- package/claude/guides/session-distill-workflow.md +93 -43
- package/claude/guides/tooling-gotchas.md +3 -1
- package/codex/guides/claude-prompting.md +475 -234
- package/codex/guides/cli-multi-model-workflow.md +4 -3
- package/codex/guides/gpt-prompting.md +235 -136
- package/codex/guides/session-distill-workflow.md +93 -43
- package/codex/guides/tooling-gotchas.md +3 -1
- package/compose/assemble.py +4 -1
- package/compose/canary.sh +8 -6
- package/compose/host_platform.py +158 -15
- package/compose/instructions-state.py +183 -41
- package/compose/instructions_install.py +222 -27
- package/compose/instructions_session.py +250 -75
- package/compose/instructions_setup_cli.py +2 -36
- package/compose/instructions_store.py +160 -3
- package/compose/instructions_transaction.py +29 -5
- package/docs/advanced-launch.md +4 -0
- package/docs/releases/0.20.0.md +102 -0
- package/install.sh +42 -14
- package/launch/agent-launch.py +152 -18
- package/launch/agent-launch.toml +17 -7
- package/launch/agent-launch.zsh +104 -13
- package/launch/claude_subcommands.py +179 -0
- package/launch/shell_integration.py +7 -1
- package/learn/collect-learning.py +60 -9
- package/learn/migrate-learnings.py +70 -4
- package/learn/redact.py +2 -1
- package/package.json +36 -3
- package/provenance.json +1 -1
- package/session-cost.py +80 -9
- package/session-distill/coverage.json +6 -0
- package/session-distill/distill.py +2575 -0
- package/session-distill/grammar/__init__.py +0 -0
- package/session-distill/grammar/owner_lines.py +874 -0
- package/session-distill/originators.json +9 -0
- package/session-distill/packets/cross_review.md +31 -0
- package/session-distill/packets/form.md +86 -0
- package/session-distill/packets/judge.md +81 -0
- package/session-distill/packets/placement_contract.md +90 -0
- package/session-distill/packets/propose.md +124 -0
- package/session-distill/packets/read.md +57 -0
- package/session-distill/packets/reconsider.md +53 -0
- package/session-distill/packets/s7b.md +65 -0
- package/session-distill/packets/s9b.md +39 -0
- package/session-distill/packets/stitch.md +35 -0
- package/session-distill/packets/sweep.md +33 -0
- package/session-distill/runlib/__init__.py +0 -0
- package/session-distill/runlib/bound.py +1102 -0
- package/session-distill/runlib/breaker.py +467 -0
- package/session-distill/runlib/census.py +2347 -0
- package/session-distill/runlib/claims.py +420 -0
- package/session-distill/runlib/controls.py +902 -0
- package/session-distill/runlib/coverage.py +881 -0
- package/session-distill/runlib/declare.py +888 -0
- package/session-distill/runlib/delivery_evidence.py +1145 -0
- package/session-distill/runlib/derive.py +812 -0
- package/session-distill/runlib/destinations.py +3072 -0
- package/session-distill/runlib/dispatch.py +7939 -0
- package/session-distill/runlib/drift.py +1077 -0
- package/session-distill/runlib/entry.py +401 -0
- package/session-distill/runlib/evidence.py +890 -0
- package/session-distill/runlib/exposure.py +1162 -0
- package/session-distill/runlib/gate.py +2727 -0
- package/session-distill/runlib/gitread.py +79 -0
- package/session-distill/runlib/inventory.py +19624 -0
- package/session-distill/runlib/journal.py +1919 -0
- package/session-distill/runlib/ledger.py +3210 -0
- package/session-distill/runlib/ledger_compat.py +101 -0
- package/session-distill/runlib/ledger_migration.py +190 -0
- package/session-distill/runlib/lifecycle_intake.py +693 -0
- package/session-distill/runlib/lineage.py +454 -0
- package/session-distill/runlib/measures.py +249 -0
- package/session-distill/runlib/monitor.py +1180 -0
- package/session-distill/runlib/operations.py +522 -0
- package/session-distill/runlib/packet.py +838 -0
- package/session-distill/runlib/placement.py +1769 -0
- package/session-distill/runlib/projection.py +4090 -0
- package/session-distill/runlib/ranking.py +740 -0
- package/session-distill/runlib/receipts.py +200 -0
- package/session-distill/runlib/records.py +1965 -0
- package/session-distill/runlib/search.py +249 -0
- package/session-distill/runlib/sequencing.py +829 -0
- package/session-distill/runlib/sources.py +641 -0
- package/session-distill/runlib/stage_adjudicate.py +845 -0
- package/session-distill/runlib/stage_apply.py +1378 -0
- package/session-distill/runlib/stage_approvals.py +758 -0
- package/session-distill/runlib/stage_close.py +1220 -0
- package/session-distill/runlib/stage_confirm.py +929 -0
- package/session-distill/runlib/stage_delivery.py +3080 -0
- package/session-distill/runlib/stage_form.py +2576 -0
- package/session-distill/runlib/stage_judge.py +4248 -0
- package/session-distill/runlib/stage_propose.py +3307 -0
- package/session-distill/runlib/stage_read.py +5179 -0
- package/session-distill/runlib/stage_render.py +2739 -0
- package/session-distill/runlib/stage_retrieve.py +924 -0
- package/session-distill/runlib/stage_review_korean.py +1002 -0
- package/session-distill/runlib/stage_review_proposals.py +1292 -0
- package/session-distill/runlib/stagelock.py +412 -0
- package/session-distill/runlib/stop.py +1061 -0
- package/session-distill/runlib/targets.py +809 -0
- package/session-distill/runlib/usage.py +280 -0
- package/session-distill/runlib/validate.py +319 -0
- package/session-distill/runlib/views.py +4327 -0
- package/session-distill/schemas/adjudication.schema.json +35 -0
- package/session-distill/schemas/approval.schema.json +35 -0
- package/session-distill/schemas/census.schema.json +128 -0
- package/session-distill/schemas/checks.schema.json +207 -0
- package/session-distill/schemas/claim.schema.json +16 -0
- package/session-distill/schemas/confirmation.schema.json +24 -0
- package/session-distill/schemas/coverage.schema.json +66 -0
- package/session-distill/schemas/cross_review.schema.json +24 -0
- package/session-distill/schemas/event.schema.json +20 -0
- package/session-distill/schemas/evidence.schema.json +20 -0
- package/session-distill/schemas/expected_observation.schema.json +18 -0
- package/session-distill/schemas/form.schema.json +103 -0
- package/session-distill/schemas/intake.schema.json +71 -0
- package/session-distill/schemas/inventory.schema.json +872 -0
- package/session-distill/schemas/judge.schema.json +77 -0
- package/session-distill/schemas/ledger.schema.json +313 -0
- package/session-distill/schemas/observation.schema.json +16 -0
- package/session-distill/schemas/propose.schema.json +555 -0
- package/session-distill/schemas/read.schema.json +76 -0
- package/session-distill/schemas/reconsider.schema.json +122 -0
- package/session-distill/schemas/run.schema.json +150 -0
- package/session-distill/schemas/s7b.schema.json +200 -0
- package/session-distill/schemas/s9b.schema.json +28 -0
- package/session-distill/schemas/stitch.schema.json +25 -0
- package/session-distill/schemas/sweep.schema.json +25 -0
- package/session-distill/seats.json +149 -0
- package/session-distill/tables/allowed_pairs.json +257 -0
- package/session-distill/tables/controls.json +30 -0
- package/session-distill/tables/delivery_evidence.json +36 -0
- package/session-distill/tables/delivery_evidence_fixtures.json +731 -0
- package/session-distill/tables/destinations.json +684 -0
- package/session-distill/tables/drift_layers.json +68 -0
- package/session-distill/tables/exposure_rules.json +192 -0
- package/session-distill/tables/placement_rules.json +148 -0
- package/session-distill/tables/propose_fixtures.json +154 -0
- package/session-distill/tables/ranking.json +194 -0
- package/session-distill/tables/redundancy.json +10 -0
- package/session-distill/tables/structural_rules.json +44 -0
- package/session-distill/tables/transition_fixtures.json +398 -0
- package/session-distill/tables/transitions.json +69 -0
- package/session-distill/tables/unit_outcome.json +67 -0
- package/session-distill/tables/unit_outcome_fixtures.json +2364 -0
- package/wrappers/claude-run.sh +481 -33
- package/wrappers/claude_hermetic_evidence.py +1423 -0
- package/wrappers/codex-helm.sh +38 -7
- package/wrappers/codex-run.sh +183 -20
- package/wrappers/codex_frame_filter.py +1199 -0
- package/wrappers/codex_protocol.py +737 -0
- package/wrappers/jsonl_lines.py +65 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""What a window's follow-up of one expected observation resolves to, derived by code (design §11).
|
|
3
|
+
|
|
4
|
+
S3 finds each occasion and judges it: its exposure (`eligible`, or `exposure_unknown` when the window cannot show the
|
|
5
|
+
exposure rule held before the decision or action) and its verdict (`observed` or `not_observed`), with evidence ids.
|
|
6
|
+
Code sets every instance's coverage basis over the window's scope (design §5.4) and derives the resolution here, in
|
|
7
|
+
§11's order:
|
|
8
|
+
|
|
9
|
+
- **not_observed**: at least one eligible occasion not observed, whatever else is incomplete;
|
|
10
|
+
- **observed**: at least one eligible occasion, every eligible occasion observed, no `exposure_unknown` occasion, and
|
|
11
|
+
basis `source` or `view` (the basis is recorded with it: a view-based observed cannot rule out an unseen occasion
|
|
12
|
+
that was not observed);
|
|
13
|
+
- **no_occasion**: basis `source` and no occasion found;
|
|
14
|
+
- **pending** otherwise (basis incomplete, basis view for an absence, or `exposure_unknown` occasions), carried to the
|
|
15
|
+
next window.
|
|
16
|
+
|
|
17
|
+
The result is the ledger's resolution (`schemas/ledger.schema.json` `$defs.resolution`) without `run` and `window`,
|
|
18
|
+
which the stage that stores it adds (WP-21). An occasion shown not exposed (before the application, an old pin) is no
|
|
19
|
+
occasion of the applied item: the exposure predicate WP-21 builds excludes it before this derivation, so an instance
|
|
20
|
+
here is eligible or exposure_unknown and nothing else (plan amendment of 2026-11-03, row 6; WP-08 commit 4).
|
|
21
|
+
|
|
22
|
+
This module is pure: standard library only, no runlib import, no file read, no clock. Failures are named by their
|
|
23
|
+
first word: RESOLUTION_INPUT.
|
|
24
|
+
|
|
25
|
+
measures.py --self-test
|
|
26
|
+
"""
|
|
27
|
+
import json
|
|
28
|
+
import pathlib
|
|
29
|
+
import sys
|
|
30
|
+
|
|
31
|
+
RESOLUTIONS = ("not_observed", "observed", "no_occasion", "pending") # design §11, in its order
|
|
32
|
+
BASES = ("incomplete", "view", "source") # design §5.4
|
|
33
|
+
EXPOSURES = ("eligible", "exposure_unknown") # design §11
|
|
34
|
+
VERDICTS = ("observed", "not_observed") # design §11
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ResolutionInput(ValueError):
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def counts_of(instances):
|
|
42
|
+
"""The ledger's counts: eligible occasions, their observed and not observed, and the exposure_unknown ones."""
|
|
43
|
+
eligible = [i for i in instances if i["exposure"] == "eligible"]
|
|
44
|
+
return {"eligible": len(eligible),
|
|
45
|
+
"observed": sum(i["verdict"] == "observed" for i in eligible),
|
|
46
|
+
"not_observed": sum(i["verdict"] == "not_observed" for i in eligible),
|
|
47
|
+
"exposure_unknown": sum(i["exposure"] == "exposure_unknown" for i in instances)}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def input_problems(instances, basis):
|
|
51
|
+
"""Why `instances` and `basis` are not one expected observation's instances in one scope, as a list."""
|
|
52
|
+
problems = []
|
|
53
|
+
if basis not in BASES:
|
|
54
|
+
problems.append(f"RESOLUTION_INPUT basis {basis!r} is none of {list(BASES)}")
|
|
55
|
+
if len({i["expected_id"] for i in instances}) > 1:
|
|
56
|
+
problems.append(f"RESOLUTION_INPUT instances of {sorted({i['expected_id'] for i in instances})}: a resolution "
|
|
57
|
+
"is derived for one expected observation")
|
|
58
|
+
for n, i in enumerate(instances):
|
|
59
|
+
if i["exposure"] not in EXPOSURES:
|
|
60
|
+
problems.append(f"RESOLUTION_INPUT instance {n} exposure {i['exposure']!r} is none of {list(EXPOSURES)}")
|
|
61
|
+
if i["verdict"] not in VERDICTS:
|
|
62
|
+
problems.append(f"RESOLUTION_INPUT instance {n} verdict {i['verdict']!r} is none of {list(VERDICTS)}")
|
|
63
|
+
if i["basis"] != basis:
|
|
64
|
+
problems.append(f"RESOLUTION_INPUT instance {n} has basis {i['basis']!r}, and its scope's is {basis!r}: an "
|
|
65
|
+
"instance's basis is its scope's, set by code")
|
|
66
|
+
locators = [i["occasion_locator"] for i in instances]
|
|
67
|
+
if len(set(locators)) != len(locators):
|
|
68
|
+
problems.append(f"RESOLUTION_INPUT occasions repeat: {sorted(o for o in set(locators) if locators.count(o) > 1)}")
|
|
69
|
+
return problems
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def derive_resolution(instances, basis):
|
|
73
|
+
"""`{resolution, basis, counts, occasions}` of one expected observation's `instances` in a scope of `basis`."""
|
|
74
|
+
problems = input_problems(instances, basis)
|
|
75
|
+
if problems:
|
|
76
|
+
raise ResolutionInput("; ".join(problems))
|
|
77
|
+
counts = counts_of(instances)
|
|
78
|
+
if counts["not_observed"]:
|
|
79
|
+
resolution = "not_observed"
|
|
80
|
+
elif (counts["eligible"] and counts["observed"] == counts["eligible"] and not counts["exposure_unknown"]
|
|
81
|
+
and basis in ("source", "view")):
|
|
82
|
+
resolution = "observed"
|
|
83
|
+
elif basis == "source" and not instances:
|
|
84
|
+
resolution = "no_occasion"
|
|
85
|
+
else:
|
|
86
|
+
resolution = "pending"
|
|
87
|
+
return {"resolution": resolution, "basis": basis, "counts": counts,
|
|
88
|
+
"occasions": sorted(i["occasion_locator"] for i in instances)}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# ---------------------------------------------------------------- the O9 fixtures (design §15), as far as §11 derives
|
|
92
|
+
|
|
93
|
+
def fx_instance(n, exposure="eligible", verdict="observed", basis="source", expected="eo-1"):
|
|
94
|
+
return {"expected_id": expected, "occasion_locator": f"view-a#{n}/message/content", "exposure": exposure,
|
|
95
|
+
"verdict": verdict, "basis": basis, "evidence_ids": [f"ev-{n}"]}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def fx_scope(sessions=(), sources=None):
|
|
99
|
+
"""A scope for `views.coverage_basis`: one accounted source, and sessions given as (status, view, source, unprocessed)."""
|
|
100
|
+
return {"sources": sources if sources is not None else [{"accounted": True, "directory_present": True}],
|
|
101
|
+
"sessions": [{"status": s, "view_complete": v, "source_complete": c, "unprocessed": u} for s, v, c, u in sessions]}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
DONE = ("read_complete", True, True, False) # a session read to the end, every omission expanded
|
|
105
|
+
SKIPPED = ("read_complete", True, False, False) # view complete with one skipped span
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def o9_fixtures():
|
|
109
|
+
"""`[(name, scope, instances, expected resolution)]`: the O9 rows whose outcome §11's derivation decides. A row about
|
|
110
|
+
exposure itself (an old installer on the receipt, a removed wrapper's carrier, a compiler digest, a loading record,
|
|
111
|
+
a recovery begun by another installer, a pre-receipt transaction) is the predicate's, WP-21's; a row about reading
|
|
112
|
+
(the search forcing an expansion, a skipped span's match) reaches this derivation as the instances and the basis
|
|
113
|
+
reading left, and S3's self-test runs it through the reader."""
|
|
114
|
+
def i(*args, **kwargs):
|
|
115
|
+
return fx_instance(*args, **kwargs)
|
|
116
|
+
source, view = fx_scope([DONE, DONE]), fx_scope([DONE, SKIPPED])
|
|
117
|
+
return [
|
|
118
|
+
("O9 one observed, one not observed, one pre-application (excluded by exposure), one exposure_unknown: not "
|
|
119
|
+
"observed wins", source, [i(1), i(2, verdict="not_observed"), i(4, exposure="exposure_unknown")], "not_observed"),
|
|
120
|
+
("O9 only observed and exposure_unknown occasions: pending", source,
|
|
121
|
+
[i(1), i(2, exposure="exposure_unknown")], "pending"),
|
|
122
|
+
("O9 the only match lies in a skipped span: no occasion on basis view is pending", view, [], "pending"),
|
|
123
|
+
("O9 the paraphrased occasion the search misses behind an identical head and tail: no occasion refused, basis "
|
|
124
|
+
"view, pending", view, [], "pending"),
|
|
125
|
+
("O9 observed occasions in a window with one skipped span: observed on basis view", view,
|
|
126
|
+
[i(1, basis="view"), i(2, basis="view")], "observed"),
|
|
127
|
+
("O9 observed occasions in a window with a missing transcript: pending", fx_scope([DONE, ("known_absent", False,
|
|
128
|
+
False, False)]), [i(1, basis="incomplete")], "pending"),
|
|
129
|
+
("O9 a request, then a guide read, then the correct action: exposed and observed", source, [i(1)], "observed"),
|
|
130
|
+
("O9 a source-complete window with no occasion: no occasion", source, [], "no_occasion"),
|
|
131
|
+
("O9 observed occasions in a window with a deferred session: pending", fx_scope([DONE, ("deferred", False, False,
|
|
132
|
+
False)]), [i(1, basis="incomplete")], "pending"),
|
|
133
|
+
("O9 observed occasions in a window with a failed session: pending", fx_scope([DONE, ("failed", False, False,
|
|
134
|
+
False)]), [i(1, basis="incomplete")], "pending"),
|
|
135
|
+
("O9 observed occasions in a window with a partially read session: pending", fx_scope([DONE, ("read_partial",
|
|
136
|
+
True, False, False)]), [i(1, basis="incomplete")], "pending"),
|
|
137
|
+
("O9 an occasion whose exposure was not recorded: exposure_unknown leaves it pending", source,
|
|
138
|
+
[i(1, exposure="exposure_unknown")], "pending"),
|
|
139
|
+
("F04 one source left unaccounted: an absence is pending", fx_scope([DONE], [{"accounted": True,
|
|
140
|
+
"directory_present": True}, {"accounted": False, "directory_present": True}]), [], "pending"),
|
|
141
|
+
("F04 one source left unaccounted: an observed occasion is pending", fx_scope([DONE], [{"accounted": True,
|
|
142
|
+
"directory_present": True}, {"accounted": False, "directory_present": True}]), [i(1, basis="incomplete")],
|
|
143
|
+
"pending"),
|
|
144
|
+
("a not-observed occasion in an incomplete scope is still not observed", fx_scope([DONE, ("failed", False, False,
|
|
145
|
+
False)]), [i(1, basis="incomplete"), i(2, verdict="not_observed", basis="incomplete")], "not_observed"),
|
|
146
|
+
("a not-observed occasion whose exposure is unknown is no eligible one: pending", source,
|
|
147
|
+
[i(1, exposure="exposure_unknown", verdict="not_observed")], "pending"),
|
|
148
|
+
]
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def fixture_problems(name, scope, instances, want, basis_of):
|
|
152
|
+
"""What is wrong with one fixture's derivation, naming the fixture."""
|
|
153
|
+
basis = basis_of(scope)
|
|
154
|
+
try:
|
|
155
|
+
got = derive_resolution(instances, basis)
|
|
156
|
+
except ResolutionInput as exc:
|
|
157
|
+
return [f"{name}: {exc}"]
|
|
158
|
+
return [] if got["resolution"] == want else [f"{name}: derived {got['resolution']!r} on basis {basis!r}, expected {want!r}"]
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def self_test():
|
|
162
|
+
failures = []
|
|
163
|
+
here = pathlib.Path(__file__).resolve().parents[1]
|
|
164
|
+
sys.path.insert(0, str(here))
|
|
165
|
+
from runlib import views # the basis predicate the reader uses; the self-test reads it, the module does not
|
|
166
|
+
|
|
167
|
+
fixtures = o9_fixtures()
|
|
168
|
+
for name, scope, instances, want in fixtures:
|
|
169
|
+
failures += fixture_problems(name, scope, instances, want, views.coverage_basis)
|
|
170
|
+
for other in RESOLUTIONS:
|
|
171
|
+
if other != want and not any(name in p for p in fixture_problems(name, scope, instances, other,
|
|
172
|
+
views.coverage_basis)):
|
|
173
|
+
failures.append(f"{name}: expecting {other!r} instead does not fail by the fixture's name")
|
|
174
|
+
def derived(label, instances, basis):
|
|
175
|
+
"""The resolution, or None with the refusal named under `label`: a control that raises names itself."""
|
|
176
|
+
try:
|
|
177
|
+
return derive_resolution(instances, basis)
|
|
178
|
+
except ResolutionInput as exc:
|
|
179
|
+
failures.append(f"{label}: refused as {exc}")
|
|
180
|
+
return None
|
|
181
|
+
|
|
182
|
+
reached = {(derived(name, inst, views.coverage_basis(scope)) or {}).get("resolution")
|
|
183
|
+
for name, scope, inst, _w in fixtures} - {None} # a refused fixture is named above, not sorted here
|
|
184
|
+
if reached != set(RESOLUTIONS):
|
|
185
|
+
failures.append(f"the fixtures reach {sorted(reached)}, and §11 has {sorted(RESOLUTIONS)}: a branch is unexercised")
|
|
186
|
+
|
|
187
|
+
# The rule over every vocabulary combination: each branch exactly where §11 puts it.
|
|
188
|
+
for basis in BASES:
|
|
189
|
+
for shape in ((), ("eligible", "observed"), ("eligible", "not_observed"), ("exposure_unknown", "observed")):
|
|
190
|
+
inst = [fx_instance(1, *shape, basis=basis)] if shape else []
|
|
191
|
+
got = (derived(f"one occasion {shape or 'none'} on basis {basis}", inst, basis) or {}).get("resolution")
|
|
192
|
+
want = ("not_observed" if shape == ("eligible", "not_observed") else
|
|
193
|
+
"observed" if shape == ("eligible", "observed") and basis != "incomplete" else
|
|
194
|
+
"no_occasion" if not shape and basis == "source" else "pending")
|
|
195
|
+
if got != want:
|
|
196
|
+
failures.append(f"one occasion {shape or 'none'} on basis {basis}: derived {got!r}, expected {want!r}")
|
|
197
|
+
|
|
198
|
+
# The result is the ledger's resolution without run and window, and the vocabularies are the schemas'.
|
|
199
|
+
schemas = here / "schemas"
|
|
200
|
+
ledger = json.loads((schemas / "ledger.schema.json").read_text(encoding="utf-8"))["$defs"]
|
|
201
|
+
observation = json.loads((schemas / "observation.schema.json").read_text(encoding="utf-8"))["properties"]
|
|
202
|
+
got = derived("the result's shape", [fx_instance(1)], "source") or {"counts": {}}
|
|
203
|
+
if set(got) | {"run", "window"} != set(ledger["resolution"]["required"]):
|
|
204
|
+
failures.append(f"the result's keys {sorted(got)} plus run and window are not the ledger resolution's "
|
|
205
|
+
f"{sorted(ledger['resolution']['required'])}")
|
|
206
|
+
if set(got["counts"]) != set(ledger["counts"]["required"]):
|
|
207
|
+
failures.append(f"the counts {sorted(got['counts'])} are not the ledger's {sorted(ledger['counts']['required'])}")
|
|
208
|
+
for label, mine, theirs in (("resolution", RESOLUTIONS, ledger["resolution"]["properties"]["resolution"]["enum"]),
|
|
209
|
+
("ledger basis", BASES, ledger["resolution"]["properties"]["basis"]["enum"]),
|
|
210
|
+
("instance basis", BASES, observation["basis"]["enum"]),
|
|
211
|
+
("exposure", EXPOSURES, observation["exposure"]["enum"]),
|
|
212
|
+
("verdict", VERDICTS, observation["verdict"]["enum"])):
|
|
213
|
+
if set(mine) != set(theirs):
|
|
214
|
+
failures.append(f"the {label} vocabulary {sorted(mine)} is not the schema's {sorted(theirs)}")
|
|
215
|
+
|
|
216
|
+
# Inputs that are not one expected observation's instances in one scope are refused by name.
|
|
217
|
+
for label, instances, basis, needle in (
|
|
218
|
+
("a basis outside §5.4", [], "partial", "RESOLUTION_INPUT basis 'partial'"),
|
|
219
|
+
("two expected observations", [fx_instance(1), fx_instance(2, expected="eo-2")], "source", "a resolution is derived for one"),
|
|
220
|
+
("an instance of another scope's basis", [fx_instance(1, basis="view")], "source", "an instance's basis is its scope's"),
|
|
221
|
+
("a third exposure", [fx_instance(1, exposure="not_exposed")], "source", "exposure 'not_exposed'"),
|
|
222
|
+
("a third verdict", [fx_instance(1, verdict="unclear")], "source", "verdict 'unclear'"),
|
|
223
|
+
("one occasion twice", [fx_instance(1), fx_instance(1)], "source", "occasions repeat")):
|
|
224
|
+
try:
|
|
225
|
+
derive_resolution(instances, basis)
|
|
226
|
+
failures.append(f"{label}: derived, and it should be refused")
|
|
227
|
+
except ResolutionInput as exc:
|
|
228
|
+
if needle not in str(exc):
|
|
229
|
+
failures.append(f"{label}: refused as {exc}, expected {needle!r}")
|
|
230
|
+
counted = derived("the counts", [fx_instance(1), fx_instance(2, verdict="not_observed"),
|
|
231
|
+
fx_instance(3, exposure="exposure_unknown", verdict="not_observed")], "source") or {}
|
|
232
|
+
if counted.get("counts") != {"eligible": 2, "observed": 1, "not_observed": 1, "exposure_unknown": 1} or \
|
|
233
|
+
counted.get("occasions") != [f"view-a#{n}/message/content" for n in (1, 2, 3)]:
|
|
234
|
+
failures.append(f"the counts and occasions keep every instance, the exposure_unknown one apart: {counted}")
|
|
235
|
+
|
|
236
|
+
for failure in failures:
|
|
237
|
+
print(f"measures --self-test [FAIL] {failure}")
|
|
238
|
+
if failures:
|
|
239
|
+
return 1
|
|
240
|
+
print(f"measures --self-test: OK ({len(fixtures)} O9 and F04 fixtures, each failing by name when its expected "
|
|
241
|
+
"resolution is flipped; every branch of §11 reached; the result is the ledger's resolution; inputs that are "
|
|
242
|
+
"not one observation in one scope refused)")
|
|
243
|
+
return 0
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
if __name__ == "__main__":
|
|
247
|
+
if "--self-test" not in sys.argv[1:]:
|
|
248
|
+
sys.exit("usage: measures.py --self-test")
|
|
249
|
+
sys.exit(self_test())
|