On this page
failure
Intent
A reusable domain/operation failure for exceptions, error DTOs, protocol errors, and documentation.
Exact selection subject:
subject: failure
The current Runtime IR is evidence, not authority. Target improvements needed for a usable template contract are called out explicitly.
Scope envelope
| Scope | Context |
|---|---|
each | failure: FailureContext |
all | failures: FailureContext[] |
| collection candidates | collects.group, collects.feature |
For collects.<dimension>, the singular collector is added beside the plural selected-subject array. A collector is valid only when ownership is semantically provable.
Context tree
| Context path | Type | Meaning / template use |
|---|---|---|
failure.id | string | Opaque stable semantic identity. |
failure.name | NameContext | Stable semantic identity and finite naming variants. |
failure.description | string|null | Human semantic description. |
failure.tags | string[] | Semantic classifiers; empty when none. |
failure.explanations | ExplanationContext[] | Advisory usage/security/implementation notes. |
failure.group | SemanticLinkContext|null | Owning semantic group. |
failure.feature | SemanticLinkContext|null | Canonical owning feature. |
failure.code | string | Stable semantic/business error code. |
failure.payload | TypeContext|null | Optional structured payload. |
Usage rules
codestays distinct from generated class names and transport-specific status codes.
Runtime IR implications to audit
- Current
Failureshould inherit universal semantic metadata because the pack contract permits tag filtering.
Template example — Jinja / Python exception
class {{ file.symbol }}(Exception):
code = "{{ failure.code }}"
{% if failure.payload %}
payload_type = {{ render_type(failure.payload) }}
{% endif %}
The example uses semantic context only. Any renderType/render_type helper shown is a pack-owned macro/partial consuming the documented TypeContext, not hidden Dryv context.
Audit questions
- Can a real failure pack generate code without parsing raw IR storage conventions?
- Is any field here present only because the current IR happens to store it?
- Does any nested item need first-class selection of its own?
Payload contract
Failure payload remains TypeContext, not SemanticValueContext.
Current failure semantics allow an arbitrary type expression, while SemanticValueContext models ValueRef-like carriers that distinguish reusable property/schema/unknown/dynamic values. Do not erase that distinction merely to reuse one context shape.