Skip to content

Validation: Validation Pipeline ​

The core of Cage is not Transform, but Validation.

Validation is split into stages and executed level by level:

text
Parse
  |
  v
Schema
  |
  v
Type
  |
  v
Value
  |
  v
Table
  |
  v
Reference
  |
  v
Semantic
  |
  v
Game Rules

Each level corresponds to a validation level and a family of error codes:

LevelNameWhat Is CheckedError Code Family
L0Parsewhether the input can be parsed correctlyE0001 family
L1Schemawhether the structure conforms to the SchemaE1001 family
L2Typewhether types matchE1101 family
L3Valuewhether values are within constraintsE1201 family
L4Tableinternal consistency of a single tableE1301 family
L5Referencecross-configuration referencesE1401 family
L6Semanticexpressions / combinatorial logicE1501 family
L7Game Rulebusiness plugin validationE1601 family

L0 Syntax ​

First, check whether the input can be parsed correctly. For example:

yaml
foo:
    - a
      - b

The YAML itself is invalid. Cage:

text
ERROR E0001 — Syntax Error
  Source: config/test.yaml | Format: yaml | Line: 3
  Message: YAML syntax error: did not find expected ',' or ']' at line 3 column 7, while parsing a flow sequence at line 2 column 7
  Hint: Check YAML syntax - common issues: indentation, missing colons, unquoted special characters

For text-based Sources (JSON/YAML/CSV), syntax errors are pinpointed down to the line number.

L1 Schema ​

Checks that the configuration structure conforms to the Schema.

A missing field:

text
ERROR E1001 — Missing Required Field
  Source: ./config/Item.json | Format: json | Row: 1 | Field: price
  Table: Item
  Row: 0
  Field: price
  Message: Missing required field
  Hint: Add required field 'price' to this row

Unknown fields (warning by default, escalated to an error when warnings_as_errors = true):

text
WARNING E1002 — Unknown Field
  Source: ./config/Item.json | Format: json | Row: 1 | Field: pric
  Table: Item
  Row: 0
  Field: pric
  Message: Unknown field not defined in schema
  Hint: Remove this field or add it to the schema

E9006 Field Visibility Conflict (Profile Semantics) ​

targets decides which profile views a field/table is visible in (empty = all profiles; the "*" wildcard is equivalent to empty). Trimming views is a routine operation, but when a field that is structurally indispensable gets hidden by a profile, that is a conflict — it reports E9006 instead of silently filtering it out:

  • a required field without a default is hidden by the current profile;
  • a primary key field is hidden;
  • a unique-constraint member is hidden;
  • for a reference field in a visible table, its target table or target field is hidden (a dangling reference after projection).

A required field that has a default, a non-required field, or a whole table dropped by targets are all legitimate views and raise no error. The check runs against the complete schema (profile only trims the artifact view and does not exempt data validation), and both cage check/build --profile <p> and cage gen run with this semantics. --env (per-environment constraint overrides, design §48) is orthogonal to profiles and takes effect before them: environment patches are applied onto the baseline fields first (required changes accordingly), and E9006 is judged by the resolved required — once the environment tightens things, being hidden by the sub-profile is a conflict. Example:

text
ERROR E9006 — Field Visibility Conflict
  Source: schema | Field: secret
  Table: Account
  Field: secret
  Message: Required field hidden by profile
  Hint: field 'secret' is required and targets ["server"], which hides it from profile 'client'; remove 'targets', add 'client', or give the field a default

L2 Type ​

For example:

text
Level = "abc"

Schema:

yaml
      level:
        name: level
        type: { kind: UInt32 }

The error:

text
ERROR E1101 — Type Mismatch
  Source: ./config/Item.json | Format: json | Row: 1 | Col: Level | Field: Level
  Table: Item
  Row: 0
  Field: Level
  Value: {"type":"String","value":"abc"}
  Message: Type mismatch
  Hint: Expected type: UInt32, got: string

Map fields are validated key by key and value by value: keys are gated by key_type (string keys are always valid; int keys must be numeric strings parseable via parse::<i64>), values are recursively validated against value_type, and mismatches likewise go through E1101 (the hint shows the expected type spelled as map<key, value>); an empty map is always valid.

L3 Value ​

A correct type does not mean a reasonable value. Schema:

yaml
      level:
        name: level
        type: { kind: UInt32 }
        min: 1
        max: 100

Data:

text
level = 999

Result:

text
ERROR E1201 — Value Out of Range
  Source: ./config/Item.json | Format: json | Row: 1 | Col: level | Field: level
  Table: Item
  Row: 0
  Field: level
  Value: {"type":"Int","value":999}
  Message: Value exceeds maximum
  Hint: Maximum allowed: 100

Supported value constraints:

text
min / max               数值范围(E1201)
min_length / max_length 字符串长度(E1202)
pattern                 正则匹配(E1203)
enum_values             枚举取值域(E1204)。命名枚举(type: {kind: Enum, value: 名})
                        的成员资格同在本层、同走 E1204——对顶层 enums: 声明的成员做
                        检查;只查字符串值,非字符串类型失配归 L2(E1101),
                        悬空枚举名归 L1(E1004)
min_items / max_items   数组元素个数(E1205)

unique belongs to L4 (E1301/E1302) and required to L1 (E1001); neither is checked at this level.

L4 Table ​

Checks the internal consistency of a single table. For example, IDs must be unique. The data:

text
10001
10002
10001

Result:

text
ERROR E1301 — Duplicate Primary Key
  Table: Item
  Row: 4
  Value: ["10001"]
  Message: Duplicate primary key
  Hint: First occurrence at row 2

It can also check:

text
组合唯一(unique_constraints,E1302)
排序要求(order_by,E1304)

L5 Reference ​

One of the most important capabilities in game configuration. For example:

Item

text
ID
10001
10002
10003

Monster

text
ID       DropItemID
20001    10001
20002    10002
20003    99999

Schema:

yaml
      drop_item_id:
        name: drop_item_id
        type: { kind: UInt32 }
        reference:
          table: Item
          field: id

Cage:

text
ERROR E1401 — Reference Target Not Found
  Table: Monster
  Row: 3
  Field: DropItemID
  Value: 99999
  Message: Referenced target does not exist
  Hint: No Item with id=99999 found

References Should Not Only Validate Existence ​

text
Monster.DropItemID
        |
        v
Item.ID

The Item exists (Item[10001]), but Item[10001].Type = QuestItem, while Monster drops only allow Weapon / Armor / Consumable. Use compatible_with to declare the values the target field must be compatible with; violations report E1411:

text
ERROR E1411 — Reference Field Constraint Violation
  Source: ./config/Item.json | Format: json | Row: 1 | Col: drop_item_id | Field: drop_item_id
  Table: Monster
  Row: 0
  Field: drop_item_id
  Value: {"type":"Int","value":10001}
  Message: Referenced object field value not compatible
  Hint: Referenced Item.type = 'QuestItem', allowed: Weapon, Armor, Consumable

The reference check surface breaks into four row-level categories (plus the schema-level cycle check E1403 below); implementation status:

text
Existence        存在性          已实装(E1401)
Predicate        谓词约束         已实装(E1410,断言在引用目标行上求值)
Cardinality      基数            已实装(E1404,源侧口径:one/optional 单值、many 数组逐元素)
Compatibility    兼容性          已实装(E1411,compatible_with 字段级约束)

Table-Level Reference Cycles (E1403, Implemented) ​

After the row-by-row reference checks, L5 performs schema-level cycle detection: when the reference graph (DependencyGraph::from_schema) contains cycles, each cycle reports one E1403 WARNING, with the cycle path written into the diagnostic message (starting from the smallest table name, deduplicated across starting points — two tables referencing each other report only one):

text
WARNING E1403 — Circular Reference
  Source: schema | Table: Item

Circular reference: Item → Kit → Item

Self-references (such as an unlock chain Stage.next → Stage.id) count as cycles under the reference graph's own contract and are flagged the same way. Cycles do not block the build — generation is single-pass and incremental propagation is safe for cycles — but they make the library API's topological_sort / build_order fail, so the author is warned with a WARNING rather than an error (an ERROR would wrongly reject legitimate mutually-referencing schemas); with warnings_as_errors = true it escalates to an error (exit code 1).

L6 Semantic ​

Schema solves the structural problem; Semantic Validation solves: whether the data makes sense when combined.

For example:

text
MinLevel <= MaxLevel
BuyPrice >= SellPrice
Skill.Cost >= 0
Monster.DropTableID 必须存在

Expression rules can be defined:

yaml
      level:
        name: level
        type: { kind: Int32 }
        rules:
          - name: level_range
            assert: min_level <= max_level

Rule declarations are parsed along with the Schema (name/assert/message/warning_only are all present); the evaluator is implemented around single comparison assertionsoperand OP operand (operands are field references — bare names or backtick-quoted names — and numeric/string/boolean literals; operators == != <= >= < >). Evaluation semantics:

  • The numeric family (Int/UInt/Float) is compared numerically: Int/UInt use exact i128 arithmetic, and once Float is involved f64 is used; strings compare lexicographically; booleans order false < true.
  • If a referenced field is missing on that row or is null (an optional field left at its default) → the rule takes no stance on that row, treated as passing.
  • If the two sides are not comparable in type (e.g. string vs int, arrays/objects/bytes) → an E1501 violation is recorded and the hint names the types on both sides; never silently passed.
  • If the assertion is false → E1501 (message is preferred as the hint; the default renders Assertion '<assert>' failed); warning_only: true downgrades to WARNING.
  • A defective rule is a schema error: if the assertion fails to parse or references a field not declared in the table, E1004 is reported once per rule (independent of row count, reported even for empty tables), and that rule is not evaluated against any row. The same defect in a reference predicate (L5) is reported at L5 under the same code.

More complex business judgments (cross-row, arithmetic, multi-condition combinations) still belong to the L7 game-rule plugins.

L7 Game Rule (Business Plugins, Implemented) ​

Complex game business logic should not all be crammed into the Schema DSL. The layering should be:

text
Schema
Expression
Code Validator

Business validation is built as plugins (Rust traits, registered in-process):

rust
pub trait GameRuleValidator: Send + Sync {
    fn name(&self) -> &'static str;
    fn validate(&self, schema: &Schema, document: &Document) -> Vec<Diagnostic>;
}

// The sample rule package is opt-in (review P3-1): an embedder selects the
// package explicitly, and the project policy selects it in cage.toml:
let mut registry = GameRuleRegistry::with_packages(&[RulePackage::SamplePowerCurve]);
registry.register(Box::new(DropTableValidator));
let diagnostics = registry.run(&schema, &document);

The built-in sample rule power_curve is an explicitly-selected package, not a default: Cage is a generic configuration tool, so a project that needs the sample's numeric curve declares it in cage.toml —

toml
[validation]
rule_packages = ["power_curve"]

— rather than every L7 project running the curve. When the package is selected, a table containing both level/attack fields validates attack <= level * 100 + 50, and violations report E1601 (row-level location, hint includes the computation):

text
ERROR E1601 — Game Rule Validation Failed
  Source: config/monster.json | Row: 1
  Table: Monster
  Message: Game rule violation: power curve
  Hint: power_curve: attack 500 exceeds the level 1 cap 150 (level * 100 + 50)

Rule package versioning, parameters and capability (review P3-2) ​

A package is the reusable unit across projects: a name, a shipped version, a declared capability and (optionally) editable parameters. Per-package configuration rides in [validation.rule_packages_config.<name>], keyed by the package name —

toml
[validation]
rule_packages = ["power_curve"]

[validation.rule_packages_config.power_curve]
version = "1.0.0"
params = { slope = 50, intercept = 0 }
  • Version pinning (upgrade-compatibility check). version is a semver-ish pin ("1", "1.0.0", "*"). None accepts whatever the installed cage ships. A pin on the same major version is accepted (semver: the same major stays behavior-compatible); a pin on a different major — or one that does not parse — is a hard usage error (exit 2) naming the shipped version. The project must migrate its pin; a rule of unknown behavior never runs silently. (cage-core ships power_curve at version 1.0.0.)
  • Parameter editing. The package's own keys — power_curve takes slope and intercept for attack <= level * slope + intercept (defaults 100/50). An unknown key or a non-numeric value is a hard usage error at registry build, never a silently-ignored override.
  • Capability declaration. Each package declares the schema fields it needs (power_curve → level and attack in some table). When the schema satisfies none of them, the selected package reports E1609 and fails the check instead of running nothing — a selected rule that the schema cannot support is a defect, not a vacuous pass.
  • Cross-project reuse. The same selection block — name, pin, parameters — works in any project with no per-project code; the package is stateless and name-addressed.
  • A [validation.rule_packages_config] key that names a package not in rule_packages is a hard usage error (configuring a package the project did not select).

Besides the trait plugin path, the rule engine also carries a declarative data-driven channel (RuleConfig entries registered via GameRuleRegistry::with_rules, design §53): the built-in rule kinds skill_item_category / reference_cycle / drop_reward / dungeon_stage / client_server_field produce E1604–E1608 and are covered by library tests. They are not yet wired into cage check — the CLI's L7 registry is assembled from the project (built-ins plus every plugins/<id> worker directory) but does not read declarative RuleConfig entries yet, so today those are reachable only by embedders who assemble a registry in-process.

This way Cage Core does not need to understand specific game business. For the execution model choice (in-process trait → dynamic library → sandbox) and the trust boundary, see Architecture: Security and Isolation; for the full comparison table and the layered decision, see the repository design draft docs/design.md §17.1 "Finalized Plugin Sandbox Plan".

Level-by-Level Execution ​

These levels do not all have to be executed:

bash
cage check                      # 执行 L0–L6(默认 --level semantic)
cage check --level schema       # 只做 Schema 层
cage check --level reference    # 只做到引用层
cage check --level gamerule     # 加上 L7 业务规则插件

See CLI for details.

Project Validation Policy ([validation], review P2-5) ​

The CLI default level is semantic, which never reaches the L7 pass. A project that needs its plugin rules to actually run declares that in cage.toml instead of relying on every operator to pass --level gamerule:

toml
[validation]
required_level = "gamerule"
required_plugins = ["drop_rewards", "quest_consistency"]
rule_packages = ["power_curve"]

[validation.rule_packages_config.power_curve]
version = "1.0.0"
params = { slope = 100, intercept = 50 }
  • required_level — the minimum level the CLI must run. It raises the default; it is never silently lowered. An unparseable value is a hard error (exit code 2), never a silent downgrade to a level that skips the declared rules.
  • required_plugins — plugin ids that must be discovered and run. An id not present under plugins/ fails validation with E1602 instead of passing silently; declaring plugins forces the L7 pass to run even without a required_level.
  • rule_packages — built-in game-specific sample rule packages to run (review P3-1). A non-empty list forces the L7 pass; an unknown name is a hard usage error (exit 2), never a silent "select nothing". A key in rule_packages_config naming a package that is not in rule_packages is likewise a hard usage error.
  • rule_packages_config.<name> (review P3-2) — per-package configuration: version pins the package (a pin on a different major than the shipped version is a hard usage error — the upgrade-compatibility check; "*" accepts any), and params edits the package's own parameters (e.g. power_curve's slope/intercept for attack <= level * slope + intercept; an unknown key or non-numeric value is a hard usage error).

The policy is applied by cage check, cage build, the LSP editor lane and the web editor's /api/validate/data precheck — the same rule set for local runs, the editor and CI. The page can no longer show "rules passed" while the build ran no plugin, nor can a build "pass" while a required plugin is missing.

Diagnostics: First-Class Citizens ​

Each error carries at least:

text
Code
Severity
Source
Location
Table
Row
Column
Field
Value
Message
Hint

A full example (as it actually renders):

text
ERROR E1401 — Reference Target Missing
  Source: config/Monster.json | Sheet: Monster | Col: G27
  Table: Monster
  Row: 20003
  Field: DropItemID
  Value: 99999
  Message: reference target not found: Item.id = 99999
  Hint: Add Item[99999] or change DropItemID.

Supported severity levels:

text
ERROR
WARNING
INFO

The CLI and Web UI already consume these diagnostics directly; on the IDE side cage lsp (stdio Language Server, sharing the check pipeline) and the packaged VSCode extension are integrated.

Warning Policy (Implemented) ​

The warning → error escalation policy is a top-level switch in cage.toml (default false):

toml
# 日常开发:警告只提示,不阻断构建
warnings_as_errors = false

# 生产构建 / CI 门禁:警告升级为错误
warnings_as_errors = true

When enabled, the same warning is treated as an error in cage build (exit code 1, no artifacts produced); when disabled, cage build succeeds as usual for configurations that contain only warnings. The warnings_as_errors gate on the CI side refers to GitHub Actions' -D warnings (the rustc lint layer), a different layer from this configuration option; both are running (see the repository's ci.yml).

Error Code Table ​

Error codes have the format E{category}{number}, where the category corresponds to the validation level; each code has its own documentation entry and is defined in cage-core::error::codes. The table is the full registry of definitions; codes marked "reserved" are defined (constant + title complete) but not yet thrown by any current code path — capability status is marked as it truly is, and the marker is removed once wired up.

L0 Parse ​

CodeMeaning
E0001Syntax error (also: L1 reuses this code to emit a Warning when "the schema has a required field but the document is missing the entire table")
E0002Unexpected end of input (reserved)
E0003Invalid character encoding (reserved)
E0004Malformed structure (e.g. a bad YAML mapping)

L1 Schema ​

CodeMeaning
E1001Missing required field
E1002Unknown field not defined in the Schema
E1003Duplicate field definition in the Schema (reserved)
E1004Dangling references within the Schema itself (pk/unique/enum/reference pointing to a nonexistent field, enum, or table; executed only on the Web API loading path, while cross-table circular dependencies are reported during build ordering as a code-less error); malformed assertions in semantic rules / reference predicates, or assertions referencing undeclared fields (reported once per rule during L5/L6 evaluation)
E1005Schema file missing or unreadable (reserved)

L2 Type ​

CodeMeaning
E1101Type mismatch
E1102Cannot coerce to the target type (reserved)
E1103Numeric overflow / underflow (reserved)
E1104Invalid enum variant (reserved)

L3 Value ​

CodeMeaning
E1201Numeric value out of range (min/max)
E1202String length out of bounds
E1203Regex does not match
E1204Enum value not allowed
E1205Array length out of bounds

L4 Table ​

CodeMeaning
E1301Duplicate primary key
E1302Duplicate composite unique key
E1303Missing required row (reserved)
E1304Row order violation
E1305Required table is empty (reserved)

L5 Reference ​

CodeMeaning
E1401Reference target does not exist
E1402Reference to a deleted entity (reserved)
E1403Circular reference (implemented: table-level reference cycle WARNING, escalated by warnings_as_errors)
E1404Cardinality violation (implemented, source-side semantics, settled on 2026-10-10: cardinality declares how this field references its target — one (default) and optional take a single value, where optional tolerates null while null is a violation under one; many requires an array and validates each element through E1401/E1410; shape mismatches (array with one, scalar with many, null with many) report this code and name the fix; unknown spellings report E1004. The target-side 1:1 reading was rejected — as the default one, it would wrongly reject all legitimate many-to-one configurations)
E1410Referenced target exists but the semantic predicate is not satisfied (the predicate is evaluated on the target row; a missing optional field on the target row is treated as taking no stance; incomparable types on the two sides also report this code)
E1411Referenced target violates a field constraint

L6 Semantic ​

CodeMeaning
E1501Assertion expression is false (or the two sides are incomparable in type; missing optional fields take no stance; warning_only downgrades to WARNING)
E1502Cross-field constraint violation (reserved)
E1503Expression evaluation error (e.g. division by zero) (reserved)

L7 Game Rule ​

CodeMeaning
E1601Plugin validator reported an error
E1602Plugin not found (reserved)
E1603Plugin execution failed (panic, timeout, etc.) (reserved)
E1604Declarative skill_item_category rule: a skill references an item in a disallowed category
E1605Declarative reference_cycle rule: a cross-table reference cycle
E1606Declarative drop_reward rule: a drop reward references an unknown item or carries an invalid quantity/weight
E1607Declarative dungeon_stage rule: a stage references an unknown monster group or reward
E1608Declarative client_server_field rule: a field visible to a profile depends on an entity hidden from that profile
E1609A selected rule package's declared capability is not satisfied by the schema (review P3-2): e.g. power_curve needs level/attack fields, and the schema declares neither — reported instead of a silent no-op

The E1604-E1608 codes are produced by the declarative game-rule engine (GameRuleRegistry::with_rules + RuleConfig, design §53); they are exercised by library tests but are not yet wired into cage check, whose L7 runs the PowerCurveValidator sample (E1601) only when the project selects its power_curve package via [validation] rule_packages (review P3-1), and reports E1609 when a selected package's capability is unmet (review P3-2).

Build / Target (Generation Time) ​

CodeMeaning
E9001No generator found for the target format (reserved)
E9002Target generation failed
E9003Deterministic build broken (output not reproducible)
E9004Manifest generation failed (reserved)
E9005Profile does not exist (reserved)
E9006Field visibility conflict

Editor (Editor Interchange, Phase Three) ​

CodeMeaning
E1701Editor-state document cannot be parsed into a Schema (syntax/shape/unknown kind), located by JSON path

Registry (Configuration Registry, Phase Three R Series) ​

CodeMeaning
E1801Publish conflict: republishing the same version with a different whole-package fingerprint (any difference in build_id/content_hash — data, schema, and --env environment changes all count; the registry does not rewrite history), illegal package/version names, index write failure
E1802Registry reference cannot be resolved: illegal registry: spec, package/version does not exist, illegal version requirement, explicit version not satisfying the [dependencies] pin, the migration chain's terminal version falling outside the pin (linked gate, design §46), no version in the range satisfies the requirement, [registry].path not configured, corrupted index, unreachable remote root (no cache fallback)
E1803Registry entry ledger verification failed (local tampering / added or removed files, or downloaded remote bytes not matching the ledger, or a corrupted remote ledger) — rejected on both the publish and the resolve sides; the registry verify full-ledger audit reports under the same code: corrupted entries, index records drifting from the ledger, and orphan directories with no index record

Remote Source (Remote Data Sources, S Series) ​

CodeMeaning
E1901Remote fetch failure: network / DNS / timeout (bounded retries exhausted), 404 or other non-auth error status, 429 without Retry-After / unparseable / above the 30s cap or rate-limit retries exhausted, pagination contract violations (non-array page / cycles / over 1000 pages / broken next links), non-canonical gsheet spec / illegal spreadsheet id (HTTP / Sheets sources wired up); DB connection failure / illegal DSN / session read-only pin failure / statement execution failure (DB source wired up)
E1902Remote authentication / authorization rejected (HTTP 401 / 403) (HTTP / Sheets sources wired up)
E1903Remote response shape invalid: Sheets response is not a row set / empty header row / majorDimension not ROWS (Sheets source shape gate wired up)
E1904Missing credentials: [remote.<scheme>].dsn_env / [remote.gsheets].credential_env not declared, or the declared env unset / empty (DB / Sheets sources wired up)
E1905Illegal remote query: not starting with SELECT, multiple statements (semicolons), comments, row-lock clauses, INTO, non-safe table names outside named queries (DB source wired up)
E1906Remote unreachable but fell back to the previous cached copy (offline-fallback WARNING — non-fatal, noted on stderr; happens only for transport-class failures, 404 / 401/403 never fall back; --no-cache disables the fallback and restores a hard E1901)

Bad JSON from the HTTP source (cage-source-http, design §45 S1) does not go through E1903 — it goes through the same Parse diagnostic as local files (E0001 with line/column location). The DB source's (cage-source-db, §45 S2) row set is canonical JSON produced by the adapter itself, so its shape cannot be invalid, and it likewise bypasses E1903. DB source loading order: parse spec → named query / table name resolution (E1905) → SELECT whitelist (E1905) → DSN env resolution (E1904) → connect (E1901) — the whitelist and credential checks both happen before any network contact. Sheets source (cage-source-sheets, §45 S3) loading order: parse spec and spreadsheet id (E1901) → credential env resolution (E1904) → fetch (401/403 → E1902, everything else → E1901) → shape gate (E1903) — spec and credential checks likewise happen before any network contact, error diagnostics only cite the gsheet:<id>/<tab> spec, and the API key never lands in logs. For all three sources, transport-class fetch failures (connection / DNS / timeout) fall back to the cached copy when one exists and emit an E1906 WARNING (--no-cache disables the fallback); 404 and 401/403 never fall back — stale bytes must not mask a remote deletion or a revoked access.

Artifact Distribution (Distribution, A Series) ​

CodeMeaning
E2101Distribution transport failure: bundle export could not read an entry (package / version missing, entry directory or ledger missing, illegal package / version name), could not write the bundle file; push transport failure (retries exhausted), status probe unreadable, remote index unreadable; presigned push with a malformed map / non-absolute http(s) URL / missing index.put / coverage gap (a failure before any PUT closes it) (wired up)
E2102Distribution target rejected credentials: the push status probe or any PUT received HTTP 401 / 403; the token only ever appears in request headers, never in error text or logs (wired up)
E2103Bundle ledger verification failed: the import side rejects unverified bytes at the verify_snapshot trust gate — structural problems (member path escapes, malformed index, missing ledger), trust-gate rejection, and index excerpts drifting from the ledger are all rejected before the ledger is written (wired up)
E2104Distribution target refused writes: a push PUT received 405 / 409 or another explicit 4xx — the server has no write channel; fall back to "local publish + static hosting" (wired up)
E2105Distribution credentials missing: --auth-env / [registry].auth_env not declared, or the declared env unset — fails before any network contact (wired up)
E2106Signing key unavailable: the environment variable named by --key-env is unset / empty / not base64 / not a 32-byte Ed25519 key, or the library rejected the key material, or keygen persistence and sidecar writing failed (wired up)
E2107Bundle signature verification failed: the .sig sidecar is missing or malformed, the algorithm name is unrecognized, or the detached ed25519 signature fails to verify under the trusted public key — the bundle was signed by a different key or its bytes were altered (wired up)

Migration (Migration, M Series) ​

CodeMeaning
E2001Migration rule file invalid: unreadable, not valid YAML, missing from / to / steps, from equal to to, empty steps, unknown transform name, malformed payload (wired up)
E2002Migration rule references invalid: a table / field referenced by a step does not exist in the from-schema, or the rename target collides with an existing table / field name (wired up)
E2003Migration step not satisfied by the data: the widening direction is unsafe (narrowing / cross-family / Int64·UInt64→Float64 precision loss), a row value exceeds the widened target's value domain, or a table or row field referenced by a step does not exist in the document — the whole run fails rather than silently dropping data (wired up)
E2004Post-migration revalidation failed: the migration artifacts do not pass the full L0–L6 stack under the new schema, and the error list is emitted alongside E2004 (wired up)

Source Convention (Excel Meta-Row Convention, X Series) ​

CodeMeaning
E2201Convention syntax: an unknown keyword, a value before any keyword, a duplicate keyword on one column, a marker cell with an unparseable form, preset and script both set, a preset declared while has_header is false, or an ambiguous workbook override (X1)
E2202Convention vocabulary: a value that does not resolve into the vocabulary — an unknown type expression, a boolean that is not true/false, an enum that is not a value list, a malformed reference cell (X1)
E2203Script will not start: path outside the project root, .. escape, not found, not a file, or the spawn failed (X1)
E2204Script exceeded script_timeout_secs (X1)
E2205Script exited non-zero; stderr is quoted and truncated (X1)
E2206Script output is unusable: not valid JSON, not the contract shape, or a contract version cage does not know (X1)
E2207Convention contradicts the data: a declared column name not in the header row, a meta-sheet name row that does not match, or a response whose table is not the sheet's table (X1)
E2208Schema drift: a meta-row declaration contradicts an adopted schema — a field the meta declares is absent or differently shaped, or the declared primary key differs (X2); the cell anchor names the exact declaration cell

Internal (System Level) ​

CodeMeaning
E9901Internal invariant broken (bug) (reserved)
E9902Source read I/O error
E9903Configuration error (CLI arguments, missing file) (reserved)
E9904Plugin loading failed (reserved)

Released under the Apache-2.0 license