On this page

failure

Intent

A reusable domain/operation failure for exceptions, error DTOs, protocol errors, and documentation.

Exact selection subject:

yaml
subject: failure

The current Runtime IR is evidence, not authority. Target improvements needed for a usable template contract are called out explicitly.

Scope envelope

ScopeContext
eachfailure: FailureContext
allfailures: FailureContext[]
collection candidatescollects.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 pathTypeMeaning / template use
failure.idstringOpaque stable semantic identity.
failure.nameNameContextStable semantic identity and finite naming variants.
failure.descriptionstring|nullHuman semantic description.
failure.tagsstring[]Semantic classifiers; empty when none.
failure.explanationsExplanationContext[]Advisory usage/security/implementation notes.
failure.groupSemanticLinkContext|nullOwning semantic group.
failure.featureSemanticLinkContext|nullCanonical owning feature.
failure.codestringStable semantic/business error code.
failure.payloadTypeContext|nullOptional structured payload.

Usage rules

  • code stays distinct from generated class names and transport-specific status codes.

Runtime IR implications to audit

  • Current Failure should inherit universal semantic metadata because the pack contract permits tag filtering.

Template example — Jinja / Python exception

jinja
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.

Search in