9The spec-10 §12.4 error taxonomy for the ``oct test`` v1.0 seed
10(Plan 189) - AS DATA. The library never calls ``sys.exit``; it raises
11:class:`OctTestError` carrying the stable §12.4 code, the error kind,
12and the severity, plus the kind → exit-code mapping the future v1.0
13CLI slice applies at its boundary.
17- Define the §12.4 stable identifiers the discovery layer emits
18 (``WORKSPACE_FILE_NOT_FOUND``, ``WORKSPACE_AND_PACKAGE_BOTH_PASSED``,
19 ``PACKAGE_UNKNOWN``, ``CWD_RESOLUTION_FAILED``).
20- Define and CATALOG the implementation-specific ``9xxx`` extension
21 codes this seed uses (§12.4 reserves the range and requires the
22 implementation to document its codes; ``IMPLEMENTATION_CODE_CATALOG``
24- Provide :class:`OctTestError` and its §11 ``errors[]``-entry
25 projection, and :func:`exit_code_for_kind` (configuration → 4,
26 orchestrator → 3, signal → 3 per §12.3/§12.6/§12.7).
32 L2: lifecycle events (none emitted here - pure data module)
33 L3: semantic details (none emitted here)
34 L4: deep tracing (none emitted here)
38- NO ``sys.exit`` and no I/O in this module - exits are data the CLI
39 maps later (Plan 189 pinned decision).
40- Two conditions never share a code (§12.8 house rule): the base
41 v0.25 loader rejecting an existing manifest is ``9101``; a
42 test-block/test-config content violation is ``9102``.
43- Every §12.4 stable identifier is its own value, so consumers can
44 compare against these constants or against the spec's literals.
48- oct.core.diagnostics (_dbg structured logger)
51from __future__
import annotations
52from oct.core.diagnostics
import _dbg
60KIND_CONFIGURATION: str =
"configuration"
63KIND_ORCHESTRATOR: str =
"orchestrator"
66KIND_SIGNAL: str =
"signal"
69SEVERITY_FATAL: str =
"fatal"
73SEVERITY_WARNING: str =
"warning"
82WORKSPACE_FILE_NOT_FOUND: str =
"WORKSPACE_FILE_NOT_FOUND"
86WORKSPACE_AND_PACKAGE_BOTH_PASSED: str =
"WORKSPACE_AND_PACKAGE_BOTH_PASSED"
91PACKAGE_UNKNOWN: str =
"PACKAGE_UNKNOWN"
95CWD_RESOLUTION_FAILED: str =
"CWD_RESOLUTION_FAILED"
106WORKSPACE_MANIFEST_INVALID: str =
"9101"
113MANIFEST_TEST_BLOCK_INVALID: str =
"9102"
118IMPLEMENTATION_CODE_CATALOG: dict[str, str] = {
120 WORKSPACE_MANIFEST_INVALID: (
121 "workspace manifest exists but the v0.25 base loader rejects "
122 "it (schema/version/name/subprojects/JSON failure)"
124 MANIFEST_TEST_BLOCK_INVALID: (
125 "workspace manifest base schema is valid but a §9 test block "
126 "or the top-level default_test_profile is invalid"
137EXIT_ORCHESTRATOR_ERROR: int = 3
140EXIT_CONFIGURATION_ERROR: int = 4
142_KIND_TO_EXIT: dict[str, int] = {
143 KIND_CONFIGURATION: EXIT_CONFIGURATION_ERROR,
144 KIND_ORCHESTRATOR: EXIT_ORCHESTRATOR_ERROR,
145 KIND_SIGNAL: EXIT_ORCHESTRATOR_ERROR,
150 """Return the §12 exit code for an error *kind*.
155 One of :data:`KIND_CONFIGURATION`, :data:`KIND_ORCHESTRATOR`,
161 ``4`` for configuration errors, ``3`` for orchestrator and
167 If *kind* is not one of the three taxonomy kinds (a caller
168 bug, not a runtime condition - VALIDATION_ERROR class).
170 func =
"exit_code_for_kind"
171 _dbg(
"OCT-TESTING", func, f
"mapping failure kind {kind!r} to an exit code", 4)
173 return _KIND_TO_EXIT[kind]
176 f
"unknown error kind {kind!r}; expected one of "
177 f
"{sorted(_KIND_TO_EXIT)}",
182 """A spec-10 taxonomy error carried as data (no exit applied).
187 A §12.4 stable identifier or a documented ``9xxx`` code.
189 Human-readable condition detail. For ``CWD_RESOLUTION_FAILED``
190 this is the ADR-T-12 pinned text, verbatim.
192 §11 error kind; the discovery layer only raises
193 :data:`KIND_CONFIGURATION`.
195 §11 severity; discovery errors are always
196 :data:`SEVERITY_FATAL`.
198 Dotted producer name, or ``"orchestrator"`` when config
199 validation itself is the immediate cause (§12.4 population
208 kind: str = KIND_CONFIGURATION,
209 severity: str = SEVERITY_FATAL,
210 source: str =
"orchestrator",
212 super().
__init__(f
"{code}: {message}")
221 """The exit code the CLI slice maps this error to (§12)."""
225 """Project this error as a §11 report ``errors[]`` entry."""
236 "CWD_RESOLUTION_FAILED",
237 "EXIT_CONFIGURATION_ERROR",
238 "EXIT_ORCHESTRATOR_ERROR",
239 "IMPLEMENTATION_CODE_CATALOG",
240 "KIND_CONFIGURATION",
243 "MANIFEST_TEST_BLOCK_INVALID",
248 "WORKSPACE_AND_PACKAGE_BOTH_PASSED",
249 "WORKSPACE_FILE_NOT_FOUND",
250 "WORKSPACE_MANIFEST_INVALID",
251 "exit_code_for_kind",
None __init__(self, str code, str message, *, str kind=KIND_CONFIGURATION, str severity=SEVERITY_FATAL, str source="orchestrator")
dict[str, str] to_error_entry(self)
int exit_code_for_kind(str kind)