8Report-layer constants and pure mappings for the §20 stand-in (Plan 184).
12Pin everything the spec-10 section 11 and section 20.3 report
13contract fixes at the data level: the ``oct-test/v0.4`` schema stamp,
14the pinned ``supported_features`` values VERBATIM, the required-field
15path list, the documented 9xxx implementation-code catalog (section
1612.4 requires the implementation to document its extension codes in
17its own catalog — this module IS that catalog), and the section-4
22- ``SCHEMA_STAMP`` / ``SUPPORTED_FEATURES`` / ``REQUIRED_FIELD_PATHS``.
23- ``IMPLEMENTATION_ERROR_CODES`` — every 9xxx code the stand-in emits.
24- ``make_error`` / ``make_violation`` — the §11 pinned entry shapes.
25- ``compute_exit_and_status`` — §4 precedence (4 over 3 over 2 over 1
26 over 0) with the §12.3 interrupted-status carve-out.
38- ``supported_features`` values are the §20.3 pinned set verbatim; a
39 serial stand-in reports ``workers_auto: "deferred"``. Since Plan 240
40 the stand-in can also DISTRIBUTE, and ADR-T-11's v0.3 amendment
41 (readiness audit A-19) makes that one value run-dependent —
42 ``"deferred"`` when serial, ``"enforced"`` when the run resolved
43 ``auto`` and distributed. This constant stays the SERIAL baseline;
44 ``runner._features_for`` applies the parallel value per run, so the
45 pinned dict below is still exactly what a serial report carries.
46- Timeout counts drive the ``failed`` status class (§11 status rule):
47 ``failed`` exactly when ``summary.failed + summary.timeout > 0``.
51- oc_diagnostics (structured debug logging via _dbg)
53from __future__
import annotations
55from oc_diagnostics
import _dbg
58SCHEMA_STAMP: str =
"oct-test/v0.4"
61SUPPORTED_FEATURES: dict[str, str] = {
62 "cwd_chdir":
"enforced",
63 "env_mutation":
"enforced",
64 "owned_writes_outside_tmp":
"advisory",
65 "singleton_reset":
"deferred",
66 "lock_target_outside_tmp":
"deferred",
67 "network_marker":
"deferred",
68 "large_suite_pagination":
"deferred",
69 "workers_auto":
"deferred",
70 "error_code_catalog":
"enforced",
71 "signal_handling":
"enforced",
72 "per_test_timeout":
"enforced",
73 "single_package_walk":
"enforced",
78REQUIRED_FIELD_PATHS: tuple[str, ...] = (
90 "selection.pytest_args",
96 "contract_violations",
97 "artifacts.junit_xml",
99 "artifacts.ndjson_stream",
101 "supported_features",
106IMPLEMENTATION_ERROR_CODES: dict[str, str] = {
108 "9001": (
"WORKERS_INVALID — the --workers value is neither a positive "
109 "integer nor the token 'auto' (section 12.7 reserves invalid "
110 "worker counts for a documented 9xxx code)."),
111 "9002": (
"STANDIN_INTERNAL_ERROR — an unexpected exception escaped the "
112 "stand-in orchestrator; the exception class and message are "
113 "carried in the error message."),
115 "9003": (
"STANDIN_UNSUPPORTED_FLAG — a flag that exists in the section-4 "
116 "v1.0 grammar (--workspace, --ndjson) is not supported by the "
117 "section-20 stand-in; exit 4, configuration class (section "
118 "20.1: --workspace rejection is never exit 2)."),
119 "9004": (
"SEED_INVALID — the --seed value is not an integer."),
121 "9005": (
"PER_TEST_TIMEOUT_INVALID — the --per-test-timeout value is "
122 "not a positive integer number of seconds."),
124 "9006": (
"OUTPUT_TESTS_LIMIT_INVALID — the --output-tests-limit value "
125 "is not a positive integer (the flag itself is otherwise "
126 "accepted and ignored per the section-20.3 no-sink rule)."),
128 "9007": (
"WORKERS_CLAMPED — the requested --workers count exceeded the "
129 "workspace manifest's max_workers cap for this package and was "
130 "clamped to it; the run continued at the cap. Warning "
131 "severity: the run is valid, it simply used fewer workers "
132 "than asked for (Plan 240 P2)."),
133 "9008": (
"PYTEST_UNEXPECTED_EXIT — the in-process pytest run returned "
134 "an exit class the stand-in did not produce itself (internal "
135 "error or usage error); the pytest exit code is in the "
140STATUSES: tuple[str, ...] = (
141 "passed",
"failed",
"contract_violation",
"orchestrator_error",
142 "orchestrator_interrupted",
"configuration_error",
151 source: str =
"orchestrator",
153 """Build a §11 ``errors[]`` entry ``{kind, code, severity, message,
156 _dbg(
"OC_TESTING", func, f
"{kind}/{code}/{severity}", 4)
160 "severity": severity,
173 """Build a §11 ``contract_violations[]`` entry ``{rule_id, file,
174 nodeid, severity, message}`` (nodeid ``None`` for file/run-level
176 func =
"make_violation"
177 _dbg(
"OC_TESTING", func, f
"{rule_id}@{file}", 4)
182 "severity": severity,
191 orchestrator_error: bool,
192 error_violations: bool,
193 failed_or_timeout: bool,
195 """§4 exit precedence: 4 over 3 over 2 over 1 over 0.
197 ``interrupted`` and ``orchestrator_error`` share exit 3; the
198 interrupted STATUS wins when both hold (§12.6: an
199 ``ORCHESTRATOR_INTERRUPTED`` signal already forced exit 3).
201 func =
"compute_exit_and_status"
203 result = (4,
"configuration_error")
205 result = (3,
"orchestrator_interrupted")
206 elif orchestrator_error:
207 result = (3,
"orchestrator_error")
208 elif error_violations:
209 result = (2,
"contract_violation")
210 elif failed_or_timeout:
211 result = (1,
"failed")
213 result = (0,
"passed")
214 _dbg(
"OC_TESTING", func, f
"-> {result}", 4)
218_dbg(
"OC_TESTING",
"module",
"loaded", 4)
222 "SUPPORTED_FEATURES",
223 "REQUIRED_FIELD_PATHS",
224 "IMPLEMENTATION_ERROR_CODES",
228 "compute_exit_and_status",
dict make_violation(str rule_id, str file, str|None nodeid, str severity, str message)
dict make_error(str kind, str code, str severity, str message, str source="orchestrator")
tuple[int, str] compute_exit_and_status(*, bool fatal_config, bool interrupted, bool orchestrator_error, bool error_violations, bool failed_or_timeout)