Skip to content

llm.template — Template Registry

Auto-documented module: spanforge.namespaces.template

The llm.template.* namespace records when prompt templates are registered, modified, or validated in the template registry (RFC-0001 §3).

Payload classes

ClassEvent typeDescription
TemplateRegisteredPayloadllm.template.registeredA template was added to the registry
TemplateVariableBoundPayloadllm.template.variable.boundA variable was bound in a template
TemplateValidationFailedPayloadllm.template.validation.failedTemplate validation failed

TemplateRegisteredPayload — key fields

FieldTypeRequiredDescription
template_idstrRegistry identifier for the template
versionstrSemantic version of the template
template_hashstrSHA-256 of the template source (64 lowercase hex chars)
variable_nameslist[str]Names of declared template variables
variable_countint | NoneCount of declared variables
languagestr | NoneTemplate language (e.g. "jinja2", "mustache")
char_countint | NoneCharacter length of the template source
registered_bystr | NoneIdentity of the registrant
is_activebool | NoneWhether this is the active version
tagsdict[str, str] | NoneMetadata tags (key-value pairs)

Example

import hashlib
from spanforge import Event, EventType
from spanforge.namespaces.template import TemplateRegisteredPayload

source = "Dear {{ customer_name }}, thank you for contacting support."
template_hash = hashlib.sha256(source.encode()).hexdigest()

payload = TemplateRegisteredPayload(
    template_id="support-reply-v3",
    version="3.0.0",
    template_hash=template_hash,
    variable_names=["customer_name", "product"],
    variable_count=2,
    language="jinja2",
    registered_by="eng@company.com",
    is_active=True,
    tags={"team": "support", "env": "prod"},
)

event = Event(
    event_type=EventType.TEMPLATE_REGISTERED,
    source="template-svc@1.0.0",
    org_id="org_01HX",
    payload=payload.to_dict(),
)