Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

FormaSL — Diagnostics Codes Contract

Status: STABLE (promoted per owner dispatch 2026-10-15 §3.3 after short semantic-sufficiency verification: floors preserved verbatim; no canonical code redefined; presentation layering and projection rules observable) Authority: NORMATIVE DECISION CONTRACT — diagnostic code floor, presentation layering, and editor-annotation separation Ratification: owner dispatch 2026-10-15 (D10-8 option B ratified: minimal successor contract; materialization authorized; production-code citation sync NOT authorized in the materialization mission) Decision basis: research/forma-analyzer-re-decision-closure @ 5ab196c4 (doc 02-D10-8-DIAGNOSTICS-AUTHORITY.md); genealogy 1c3299332 (adds docs/FORMASL-PROJECT-SYSTEM-FIOP-v0.2/governance/API-DIAGNOSTICS-CONTRACT.md) → 31788c70c (removes a 239-file documentary cleanup batch spanning several trees, including the whole FORMASL-PROJECT-SYSTEM-FIOP-v0.2 tree — 33 files; message mentions only SHA256SUMS.txt) = documentary withdrawal by tree cleanup, NOT individual normative revocation, no successor created Parent: ../FORMASL.md Depends on: ../contracts/post-p9/topics/T04.md (CLOSED_CANDIDATE), ../contracts/post-p9/assurance/api-construction-contract.md (CLOSED_CANDIDATE) Applied by (application context, NOT a normative dependency of this floor): FORMA-ANALYZER-FA-00-FOUNDATION-CONTRACT.md — the analyzer consumes this contract; this contract’s floor is defined entirely by §1–§3 below without normative dependence on any analyzer decision. Role: own what no living document owns after the withdrawal — the diagnostic CODE floor, the exit-code mapping, and the editor/LSP presentation layering — without redefining anything already owned elsewhere.


1. Authority map (classification honesty)

SourceClassJurisdiction
../contracts/post-p9/topics/T04.mdCLOSED_CANDIDATE authority (frozen post-p9 tree, MANIFEST.toml FROZEN + D235)programmatic surface: crate path crates/api; public operations check/inspect/run/realize; source-input identity and canonical ordering discipline; CheckedProgram opaque
../contracts/post-p9/assurance/api-construction-contract.mdCLOSED_CANDIDATE authoritypublic Rust API shape; Diagnostic { code, class, message, locus? } with class exactly normative_rejection | product_binding | driver | internal; the rule that a T04 function never invents a language rejection for a filesystem/argv failure (driver conditions stay outside T04, in CLI driver handling); CheckOutcome::Rejected diagnostics; unknown/ambiguous selector rejections
crates/api/src/diag.rs (closed enum + as_str)implementation fact + in-code authorityDiagnosticClass { NormativeRejection, ProductBinding, Driver, Internal } ↔ normative_rejection/product_binding/driver/internal; Diagnostic.code is a stable machine-readable string; normative rejections keep their contract-owned class code verbatim; primary_site is the source authority
crates/project/src/lib.rs, crates/cli/src/lib.rsimplementation factsProjectError → §10-style code floor citations; exit mapping behavior owned normatively by §2 item 5 below
API-DIAGNOSTICS-CONTRACT.md @ 1c3299332evidence only — NOT authorityhistorical text; consulted for continuity; restoration as authority would require explicit owner decision (not granted; option B ratified instead)
THIS documentnormative owner (ratified successor)the CODE FLOOR (existence, stability, extension discipline), the exit-code mapping as behavior, and the editor/LSP presentation layering

This contract RECONCILES the above and adds no new class, no new severity semantics, and no renaming.

2. Code floor (owned here)

  1. Class taxonomy is closed. Exactly the four classes above. A new class requires a ratified amendment of this contract. The enum in crates/api/src/diag.rs is the executable form; this contract and the enum MUST NOT diverge (gate DC-1).
  2. Codes are verbatim-stable. An existing code string is never renamed, re-spelled, or recycled with different meaning. Normative-rejection codes remain the contract-owned class codes verbatim, as implemented today.
  3. Extension discipline. New codes are added only with: owning class, canonical message class, provenance (producing pipeline stage), and an entry in this contract. No code is minted at presentation time (LSP adapter, editor annotations) — adapters select and render, never invent.
  4. No invented language rejections. Filesystem/argv/driver failures are not language rejections (T04 rule, preserved): they remain driver-class facts outside the canonical diagnostic stream.
  5. Exit-code mapping (preserved behavior, inherited from the historical §8 floor). The CLI aggregate exit-code mapping is frozen VERBATIM as it exists today and as the historical API-DIAGNOSTICS-CONTRACT.md §8 (@ 1c3299332) already specified — this contract PRESERVES it, it does not rewrite it: 0 = completed requested operation / passing test suite; 1 = product/semantic/project operation rejection or test expectation mismatch; 2 = CLI usage or invalid authored project/test/package specification/selection; 3 = driver/infrastructure/I-O failure; 4 = recognized operation/profile unsupported; 5 = resource exhausted. Implementation anchors: crates/cli/src/lib.rs (Io/ManifestNotFound → 3; invalid-authored set → 2; Unsupported → 4; ResourceExhausted → 5; else 1).

2.1 The §10 floor, reconciled (traceable code table)

Method: the historical §10 list (“Error taxonomy floor”, 1c3299332:docs/FORMASL-PROJECT-SYSTEM-FIOP-v0.2/governance/API-DIAGNOSTICS-CONTRACT.md — 33 codes, “Codes may be Rust enums internally. Message text is non-normative.”) was reconciled at this contract’s baseline by exact-token census over crates/{project,cli,api}/src (emitters) and crates/{project,conformance}/tests. Categories are exactly those ratified: required-by-current-authority AND implemented; historical without confirmed validity (NOT auto-promoted to requirement); and the one live reconciliation item recorded below. Implementation is evidence, never an independent source of normative authority.

REQUIRED + IMPLEMENTED — floor inherited by this contract (25 codes; §10 remains their authority):

PROJECT_INVALID_MANIFEST · PROJECT_MANIFEST_NOT_FOUND · PROJECT_MODE_CONFLICT ·
PROJECT_INVALID_ROOT · PROJECT_ROOT_SET_REQUIRED · WORKSPACE_MEMBER_CONFLICT ·
PACKAGE_REQUIREMENT_UNSATISFIED · PACKAGE_RESOLUTION_CONFLICT · LOCK_OUT_OF_DATE ·
PACKAGE_INTEGRITY_MISMATCH · PACKAGE_NOT_AVAILABLE_OFFLINE · MODULE_PROVIDER_MISSING ·
MODULE_PROVIDER_AMBIGUITY · MODULE_REVISION_UNAVAILABLE · UNDECLARED_PACKAGE_DEPENDENCY ·
SOURCE_COORDINATE_CONFLICT · SOURCE_REINTRODUCTION_REQUIRES_DECISION · TARGET_ROOT_MISSING ·
TEST_DEPENDENCY_CONFLICT · TEST_WORLD_INVALID · TEST_FILTER_NO_MATCH ·
PERSISTENT_FORMAT_UNSUPPORTED · PERSISTENT_SCHEMA_INVALID · PUBLICATION_RESOLUTION_FAILURE ·
RELEASE_COORDINATE_ALREADY_BOUND

HISTORICAL-UNCONFIRMED — present in historical §10, no current emitter or test found at baseline (8 codes; NOT auto-promoted to requirement by this contract; each requires its own future decision to be implemented or explicitly retired):

MODULE_REVISION_CONFLICT · SOURCE_INTEGRITY_CONFLICT · SOURCE_REVISION_CONFLICT ·
SOURCE_BINDING_CHANGED_REQUIRES_EXPLICIT_REBIND · CATALOG_SOURCE_MISMATCH ·
IMPORT_CLOSURE_FAILURE · TEST_EXPECTATION_MISMATCH · PACKAGE_NOT_PUBLISHABLE

Emission-mode footnote (census honesty): of the 25 codes above, 21 are returned as machine-readable code() discriminants by crates/project/src/lib.rs; the exceptions are MODULE_PROVIDER_MISSING, MODULE_PROVIDER_AMBIGUITY and MODULE_REVISION_UNAVAILABLE, which today occur only as prose fragments inside the detail text of ProjectError::RequirementUnsatisfied (whose code() is PACKAGE_REQUIREMENT_UNSATISFIED — crates/project/src/closure.rs), and PROJECT_MODE_CONFLICT, which today occurs only as a CLI message string (crates/cli/src/lib.rs, witnessed by crates/cli/tests/project_mode_witnesses.rs). Their floor membership is inherited from §10; promoting them to distinct machine-readable code() discriminants is an implementation WP, not a silent inference from this table.

Side note (referenced, not re-enumerated — no duplication): api-side normative-rejection codes (elaboration/formation/resolution families — the FormationRejection code arms (UNKNOWN_RELATION_ROLE … INVALID_UNBOUNDED_PATH_FORMATION), plus UNSUPPORTED_CONSTRUCT, UNRESOLVED_REFERENCE, AMBIGUOUS_REFERENCE, LOCUS_MAP_INCOHERENT, TYPE_BINDER_WHERE_TYPE_REQUIRED, emitted by crates/api/src/check.rs as contract-owned class codes) remain governed verbatim by the T04/api-construction authorities and crates/api/src/diag.rs as implemented.

Live floor extension recorded (reconciliation item, not hidden): PROJECT_SOURCE_HEADER_MISSING is emitted today by ProjectError::WorkingSourceRejected (crates/project/src/lib.rs:288), self-described there as an “extension of the API-DIAGNOSTICS §10 code floor”, but is absent from the historical 33-code §10 list. It is a LIVE implementation extension whose floor entry/provenance reconciliation belongs to the §5 future citation-sync WP; this contract records it without retroactively inventing historical authority. No material conflict between code and floor was found in this census beyond this recorded item; any later divergence MUST be recorded here, never hidden.

3. Presentation layering: three distinct layers (owned here)

Canonical FormaSL diagnostic  !=  Editorial annotation  !=  LSP Diagnostic (transport)
EditorAnnotation != Diagnostic
LSP Severity     != DiagnosticClass
  1. Canonical FormaSL diagnostic — produced ONLY by the production pipeline (admit_source, check, project system). Its code is verbatim-stable (§2) and travels through any projection intact. A canonical rejection remains canonical EVEN when computed over an unsaved buffer submitted through the canonical admission route (application context: FA-00 §3/§4.1): its provenance is the producing pipeline, not the storage state of the source. Presenting such rejections is required honesty; suppressing them because the source is unpublished is forbidden.
  2. Editorial annotation — produced by syntactic recovery, tolerant syntax, or operational editor state (application context: the FA-00 editor layer); zero semantic authority; never enters the canonical pipeline; never completes, admits, validates or selects anything; never promoted to canonical judgment.
  3. LSP Diagnostic — the protocol’s transport/presentation shape. It MAY carry either of the two above without transforming its origin. Minimal projection rules:
    • canonical diagnostics project with their canonical code VERBATIM and source identifying the canonical producer;
    • editorial annotations project with an EDITORIAL producer namespace (LSP source = the editorial producer identity, e.g. forma-editor) and codes ONLY inside that editorial namespace (e.g. editor-syntax/…); a fabricated canonical-shaped code for an annotation is FORBIDDEN;
    • severity is a presentation mapping (documented, monotone); it never re-classifies and never retro-feeds class, code, or pipeline decision;
    • document-version discipline: PublishDiagnosticsParams.version is optional per LSP 3.17; it is never fabricated from AnalysisVersion, and stale sets are discarded at the source (analyzer-side application of this discipline is specified in FA-00 §8 — application context, not a dependency of this floor).

4. Gates

GatePropertyFailure condition
DC-1contract ↔ diag.rs class-set equalityany string differs
DC-2no silent redefinitionsuccessor diff renames/recycles an existing code or alters a class string
DC-3presentation never re-classifiesadapter output changes code/class of a canonical diagnostic
DC-4annotation separationan EditorAnnotation is typed/read as Diagnostic anywhere
DC-5provenancea published diagnostic without canonical-pipeline provenance in its producer path
DC-6projection provenance/namespacean annotation projected with a fabricated canonical-shaped code, or a canonical code/class altered by projection
DC-7LSP version disciplinea version fabricated from AnalysisVersion, or a stale diagnostic set published after its analyzed input state was superseded

5. Outstanding synchronization obligation (future WP; NOT this materialization)

crates/project/src/lib.rs:82,181,267 and crates/cli/src/lib.rs:2537,2542 still cite the withdrawn “API-DIAGNOSTICS §10/§8”. The normative home of those floors is now THIS contract. Updating the citations touches production code and belongs to its own authorized WP; until then the citations are historically accurate pointers to the floor that this contract now owns.

6. Reopen rule

Reopen only for a material counterexample, a class/code collision with a superior authority, or explicit owner reconsideration. Presentation preferences never reopen the floor.