# seb_spec.gbnf
# Cherry-picked from sovereign-xml-compiler/grammars/sovereign_prompt.gbnf
# Extended: enforces valid SEB XML specification structure.
# Use with llama.cpp: --grammar-file seb_spec.gbnf
#
# This grammar makes it PHYSICALLY IMPOSSIBLE for the model to output
# malformed SEB XML specs. Token selection is masked at the softmax layer.
# Connection to Gates Normalization (PAR-004):
# G_P(D_M) = softmax(logits_M + b_P)
# b_P = -inf for grammar-violating tokens
# Sum over valid tokens = 1 (simplex constraint preserved)
root ::= seb-spec
seb-spec ::= "" ws
meta ws
axioms ws
layer* ws
pipeline? ws
genesis? ws
""
attrs ::= (ws attr)*
attr ::= [a-zA-Z_]+ "=\"" [^"]* "\""
meta ::= "" ws
"" semver "" ws
"" status-val "" ws
"" text "" ws
""
semver ::= [0-9]+ "." [0-9]+ "." [0-9]+
status-val ::= "DRAFT" | "FROZEN" | "ACTIVE" | "DEPRECATED"
axioms ::= "" ws axiom+ ws ""
axiom ::= "" text ""
layer ::= "" ws
layer-field* ws
artifacts? ws
""
layer-field ::= "" text "" ws
artifacts ::= "" ws artifact+ ws ""
artifact ::= "" ws
content? ws
""
content ::= "" ws text ws ""
pipeline ::= "" ws stage+ ws ""
stage ::= "" ws
stage-field* ws
gate? ws
""
stage-field ::= "" text "" ws
gate ::= "" text ""
genesis ::= "" ws constant+ ws ""
constant ::= ""
hex-string ::= [0-9a-fA-F]+
# SEB-specific element types
seb-element ::= "" | "" | "" | "" | "" |
"" | "" | "" | ""
text ::= [^<>\"]+
ws ::= [ \t\n\r]*