interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / docs / one_layer / DIAGNOSTICS_V1.md

105 lines · 5405 bytes Raw Blame History Rendered
1# Omega Stable Diagnostics Specification (v1)
2
3Defined under milestone A of issue #655 and essay priorities 1/2.
4Replaces unstructured human-only compiler errors and ad-hoc JSON with a deterministic, line-oriented plain-text diagnostic stream emitted directly by `omc.om` (the single authoritative front end).
5
6## 1. Wire Format and Syntax
7
8The diagnostics stream is UTF-8 plain text consisting of:
91. Exactly one version line as the first non-comment line.
102. Zero or more diagnostic record lines (one record per line).
11
12Comments begin with `#` or `note ` and are ignored.
13Blank lines (containing only ASCII whitespace) are ignored.
14
15### 1.1 Version Line
16
17The stream MUST begin with:
18```text
19omega-diag v1
20```
21
22A valid program that passes all checks produces zero diagnostic records:
23```text
24omega-diag v1
25```
26(Exits with returncode 0.)
27
28Both `check` and `next` complete their stdout writes before reporting success.
29A failed or zero-progress write exits with compiler output error 2.
30`next` streams completed query records rather than buffering the entire visible
31function/name list; a legal query is not limited by the diagnostic message pool.
32The category, large-query, and `/dev/full` regression controls live in
33`tests/diagnostics/experiment_issue655.sh`.
34
35### 1.2 Record Line Format
36
37Each diagnostic record occupies exactly one line with whitespace-separated fields:
38
39```text
40<profile> <category> <span=start-end> <finality> <repairable> [<constraints>...]
41```
42
43Example:
44```text
45om1 TYPE span=42-47 FINAL REPAIRABLE code=7 expect=uint found=short
46om2 SYNTAX span=108-112 INCOMPLETE REPAIRABLE code=15 expect=end
47om1 NAME span=15-20 UNKNOWN REPAIRABLE code=3 name=helper
48```
49
50## 2. Field Definitions and Ordering
51
52Fields MUST appear in this exact order:
53
541. **`profile`**:
55 The language profile: `om1` or `om2`.
56 Example: `om1`, `om2`.
57
582. **`category`**:
59 The coarse error class, uppercase ASCII:
60 - `SYNTAX`: Malformed grammar, misplaced token, unexpected delimiter (omc codes 4, 5, 6, 9, 15, 16, 22).
61 - `TYPE`: Type mismatch, invalid conversion, sign error (omc codes 7, 11, 19).
62 - `NAME`: Unknown identifier, duplicate name, reserved word reuse (omc codes 3, 10, 13).
63 - `CAPACITY`: Resource pool exhaustion, register spill limit, memory table bounds (omc codes 12, 14, 23, 24).
64 - `RANGE`: Value out of representable bounds, shift count overflow (omc codes 8, 21).
65 - `FLOW`: Unreachable code, missing return, control flow violation (omc codes 17, 18).
66 - `CONTRACT`: Precondition/postcondition violation, invariant, layout constraint (omc codes 27, 28, 29, 30).
67
683. **`source_byte_span`**:
69 Formatted exactly as `span=<start>-<end>` where `<start>` and `<end>` are 0-indexed decimal byte offsets into the original source file.
70 `<start>` is inclusive; `<end>` is exclusive (`start <= end`).
71 Byte offsets are calculated against the raw input bytes prior to any compiler-prepended mode directives.
72
734. **`finality`**:
74 Certainty of the defect given incomplete prefixes:
75 - `FINAL`: Irreparable defect in completed statements (e.g. type conflict, invalid literal, malformed expression). No continuation can make this prefix valid without changing earlier tokens.
76 - `INCOMPLETE`: Error caused by premature termination or missing closure (e.g. unclosed `if`/`while`/`fn` block, cut token at EOF). A continuation can resolve this error by supplying the missing tokens.
77 - `UNKNOWN`: Undeclared identifier (e.g. call to an unparsed function or forward struct). A future declaration in the same compilation unit may resolve it.
78
795. **`repairable`**:
80 Indicates whether code editing can resolve the issue:
81 - `REPAIRABLE`: Can be repaired by modifying or appending Omega code.
82 - `UNREPAIRABLE`: Hardware or architectural limit reached (compiler capacity, pool limit).
83 Repairability is independent of finality: a `FINAL` or `UNKNOWN` record is still
84 `REPAIRABLE` unless its code is a capacity failure (12, 14, 23 or 24).
85 The compiler emits exactly one space between fields, including before `code=`.
86
876. **`constraints`** (Optional):
88 Trailing whitespace-delimited key-value pairs or token descriptions providing additional structured context:
89 - `code=<N>`: Exact omc error code (e.g. `code=7`).
90 - `expect=<cls>`: Expected token class or type (e.g. `expect=type`, `expect=end`).
91 - `found=<tok>`: Encountered token or identifier (e.g. `found=short`).
92 - `name=<id>`: Relevant identifier name.
93
94## 3. Rejection of Malformed Input
95
96A parser or downstream agent reading this format MUST reject malformed input with a non-zero exit status. Specifically:
97
981. **`MALFORMED_VERSION`**: The first non-comment non-empty line does not match `^omega-diag v1$`.
992. **`MALFORMED_FIELD_COUNT`**: A diagnostic record line contains fewer than 5 whitespace-separated fields.
1003. **`MALFORMED_PROFILE`**: Field 1 is not one of `om1`, `om2`.
1014. **`MALFORMED_CATEGORY`**: Field 2 is not one of the 7 specified uppercase category strings (`SYNTAX`, `TYPE`, `NAME`, `CAPACITY`, `RANGE`, `FLOW`, `CONTRACT`).
1025. **`MALFORMED_SPAN`**: Field 3 does not match `^span=[0-9]+-[0-9]+$` or has `start > end`.
1036. **`MALFORMED_FINALITY`**: Field 4 is not one of `FINAL`, `INCOMPLETE`, `UNKNOWN`.
1047. **`MALFORMED_REPAIRABLE`**: Field 5 is not one of `REPAIRABLE`, `UNREPAIRABLE`.
1058. **`MALFORMED_ENCODING`**: Line contains non-ASCII characters or CR (`\r`) line endings.