QPSG Canonical Rules Reference


JSON reference designed for upload into Sources as a canonical working guide for Quantum Parse Syntax

Grammar.

Version: v1.0 | Lineage: Vault ® Canon ® Codex ® QPSG | Generated: 2026-03-18T03:19:06Z

Embedded JSON

{

"document": {

"title": "QPSG Canonical Rules Reference",

"system_name": "Quantum Parse Syntax Grammar",

"version": "v1.0",

"intended_use": "Source-uploadable canonical JSON reference for QPSG parsing, validation, linting, receipt generation, and anti-"status": "working canon for Phase 1 / Phase 2 bridge",

"lineage": [

"Vault",

"Canon",

"Codex",

"QPSG"

],

"generated_utc": "2026-03-18T03:19:06Z"

},

"design_principles": {

"parser_strategy": [

"syntax-first",

"semantic-second",

"deterministic-header-and-section-parsing",

"regex-guardrails-for-drift-detection"

],

"architecture": {

"core_language": [

"TypeScript",

"Node.js"

],

"frontend": "Next.js / Vercel",

"python_adapter": "FastAPI over HTTP to Node core",

"receipt_model": "Merkle root + dual seal"

},

"anti_drift": [

"json-schema-validated registry",

"uppercase canonical labels for structural keys",

"rule linter rejects malformed section pipes",

"dual-sign receipt binds content root to policy seal"

]

},

"lexical_tokens": {

"WORD": "Text run not otherwise classified as punctuation or newline.",

"DASH": "-",

"COLON": ":",

"COMMA": ",",

"DOT": ".",

"QUOTE": "\"",

"PIPE": "|",

"NEWLINE": "\\n"

},

"document_shape": {

"root_node": {

"kind": "CLAUSE",

"label": "DOCUMENT"

},

"line_grouping_rule": "Input is grouped by newline into phrase lines before higher-level interpretation.",

"core_line_types": [

"CLAIM-HEADER",

"RUN-COMMAND",

"OUTPUT-HEADER",

"SECTION",

"RECEIPT-LINE",

"LINEAGE-PIPE",

"LINE"

]

},

"clause_inventory": {

"CLAIM": {

"purpose": "Declares the governing claim or thesis.",

"required": true,

"examples": [

"FOR THE CLAIM OF THE OCTASYNC LINK IS WITH THE UNITY OF THE PROJECTS AND THE LIFE OF THE VAULT."

]

},

"RUN": {

"purpose": "Declares executable or procedural commands.",

"required": false,

"examples": [

"CREATE.PROJECT.LEDGER.W - path=/vault/projects/qpsg_app/ledger.json"

]

},

"OUTPUT": {

"purpose": "Declares target output structures and key-value payloads.",

"required": false,

"examples": [

"PROJECT.QPSG| INITIALIZED=true| SEAL8=DEADBEEF"

]

},

"RECEIPT": {

"purpose": "Carries deterministic execution receipt metadata.",

"required": false,

"examples": [

"RECEIPT|ts=2025-10-13T01:33:00-07:00|source=INITIATE.QPSG.PROJECT.W|seal8=b7e3d9f4"

]

},

"LINEAGE": {

"purpose": "Declares the lineage chain for authority and inheritance.",

"required": false,

"examples": [

"LINEAGE|V,C,X,Q",

"LINEAGE=V®C®X®Q"

]

}

},

"phrase_inventory": {

"CLAIM-HEADER": {

"kind": "PHRASE",

"pattern_role": "Canonical header line",

"parse_role": "Top-priority header detection"

},

"RUN-COMMAND": {

"kind": "PHRASE",

"pattern_role": "Executable command line ending in .W",

"parse_role": "Operational instruction"

},

"OUTPUT-HEADER": {

"kind": "PHRASE",

"pattern_role": "Structured output declaration",

"parse_role": "Serializable output surface"

},

"SECTION": {

"kind": "PHRASE",

"pattern_role": "Pipe-delimited label and key-value sections",

"parse_role": "Structured field container"

},

"RECEIPT-LINE": {

"kind": "PHRASE",

"pattern_role": "Receipt metadata line",

"parse_role": "Execution proof"

},

"LINEAGE-PIPE": {

"kind": "PHRASE",

"pattern_role": "Lineage authority declaration",

"parse_role": "Authority chain"

},

"LINE": {

"kind": "PHRASE",

"pattern_role": "Fallback line",

"parse_role": "Unclassified content pending semantic overlay"

}

},

"canonical_rules": [

{

"id": "qpsg.claim.header",

"label": "CLAIM-HEADER",

"weight": 100,

"pattern": "^FOR THE CLAIM OF( .+)$",

"example"

: "FOR THE CLAIM OF THE OCTASYNC LINK IS WITH THE UNITY OF THE PROJECTS AND THE LIFE OF THE VAULT.",

"notes": "Highest-precedence header rule."

},

{

"id": "qpsg.run.command",

"label": "RUN-COMMAND",

"weight": 90,

"pattern": "^[A-Z][A-Z0-9\\._]+\\.W(?: .*)?$",

"example": "CREATE.PROJECT.LEDGER.W - path=/vault/projects/qpsg_app/ledger.json",

"notes": "Operational command; canonical command stem is uppercase with dots."

},

{

"id": "qpsg.output.header",

"label": "OUTPUT-HEADER",

"weight": 80,

"pattern": "^OUTPUT:|^OUTPUT\\.|^PROJECT\\.[A-Z0-9_\\.-]+\\|",

"example": "PROJECT.QPSG| INITIALIZED=true| SEAL8=DEADBEEF",

"notes": "Structured output or project state declaration."

},

{

"id": "qpsg.receipt.line",

"label": "RECEIPT-LINE",

"weight": 70,

"pattern": "^RECEIPT\\|.*ts=.+\\|.*source=.+\\|.*seal8=[A-Fa-f0-9]{8}.*$",

"example": "RECEIPT|ts=2025-10-13T01:33:00-07:00|source=INITIATE.QPSG.PROJECT.W|seal8=b7e3d9f4",

"notes": "Receipt line must carry timestamp, source, and seal8."

},

{

"id": "qpsg.lineage.pipe",

"label": "LINEAGE-PIPE",

"weight": 70,

"pattern": "^LINEAGE\\|[VCXQ](?:,[VCXQ])*$|^LINEAGE=V®C®X®Q$",

"example": "LINEAGE|V,C,X,Q",

"notes": "Canonical lineage declaration."

},

{

"id": "qpsg.section.pipe",

"label": "SECTION-PIPE",

"weight": 60,

"pattern": "^.*\\|.*$",

"example": "PROJECT.QPSG| INITIALIZED=true| SEAL8=DEADBEEF",

"notes": "Generic pipe-delimited section; refined by linter."

},

{

"id": "qpsg.keyvalue.upper",

"label": "KEY-VALUE-UPPER",

"weight": 50,

"pattern": "^[A-Z][A-Z0-9_\\-]*=.+$",

"example": "SEAL8=f3c8d2b9",

"notes": "Canonical structural key rule for uppercase field names."

}

],

"peg_grammar_contract": {

"goal": "Deterministic parsing for header and section lines before semantic overlay.",

"header_rule": "Header = 'FOR THE CLAIM OF' + LineRest",

"section_rule": "SectionLine = Label? '|' PairList",

"pair_rule": "Pair = Key '=' Value",

"label_rule": "Label = [A-Za-z0-9_.-]+",

"key_rule": "Key = [A-Z0-9_-]+",

"value_rule": "Value = any non-pipe, non-newline content trimmed",

"fallback_behavior": "If PEG parse fails or is unavailable, parser uses regex guardrail mode and emits a warning diagnostic."

},

"validation_contract": {

"required_checks": [

{

"name": "claim_header_presence",

"severity": "error",

"rule": "Document must contain at least one CLAIM-HEADER phrase."

},

{

"name": "section_presence",

"severity": "warn",

"rule": "Document should contain at least one SECTION phrase."

}

],

"future_hooks": [

"rule-weight escalation",

"typed lineage node validation",

"semantic overlay role consistency",

"cross-line receipt integrity checks"

]

},

"linter_contract": {

"purpose": "Reject malformed structural lines before semantic or patent-grade signing.",

"rules": [

{

"name": "section_requires_pairs",

"severity": "error",

"rule": "Any line containing a pipe must include at least one KEY=VALUE pair after the label."

},

{

"name": "keys_must_be_uppercase",

"severity": "error",

"rule": "Pipe-section keys must match ^[A-Z0-9_-]+$."

},

{

"name": "explicit_key_value_form",

"severity": "error",

"rule": "Every structural field after a pipe must be in KEY=VALUE form."

},

{

"name": "top_level_key_uppercase",

"severity": "error",

"rule": "Standalone lines using '=' for structural assignment must use uppercase canonical keys."

}

]

},

"receipt_spec": {

"hash_algorithm": "sha256",

"merkle_root": {

"definition": "Binary Merkle reduction over sha256 leaf hashes; odd terminal leaf duplicates itself."

},

"seal8": {

"definition": "First 8 hex characters of sha256(input)."

},

"dual_sign": {

"definition": {

"m

erkleRoot": "merkleRoot(leaves)",

"seal8": "seal8(merkleRoot)",

"dualSeal8": "seal8(merkleRoot + policySeal)"

},

"purpose": "Bind content integrity to policy integrity."

},

"example": {

"parts": [

"a",

"b",

"c"

],

"policySeal": "f3c8d2b9"

}

},

"api_contract": {

"parse": {

"method": "POST",

"path": "/api/parse",

"input": {

"text": "string"

},

"output": {

"ast": "QpsgNode",

"diagnostics": "list"

}

},

"validate": {

"method": "POST",

"path": "/api/validate",

"input": {

"text": "string"

},

"output": {

"parse": "ParseResult",

"validate": "Validation",

"lint": "LintResult"

}

},

"sign": {

"method": "POST",

"path": "/api/sign",

"input": {

"parts": [

"string"

],

"policySeal": "string"

},

"output": {

"merkleRoot": "string",

"seal8": "string",

"dualSeal8": "string"

}

},

"verify": {

"method": "POST",

"path": "/api/verify",

"input": {

"parts": [

"string"

],

"merkleRoot": "string"

},

"output": {

"ok": "boolean",

"computed": "string",

"claimed": "string"

}

}

},

"python_adapter_contract": {

"mode": "HTTP mirror to Node core",

"recommended_stack": "FastAPI + httpx",

"mirrored_endpoints": [

"/parse",

"/validate"

],

"benefit": "Python workflows can consume a single source of grammar truth without diverging parser logic."

},

"ast_contract": {

"node_types": {

"CLAUSE": {

"fields": [

"kind",

"label",

"text",

"children"

]

},

"PHRASE": {

"fields": [

"kind",

"role",

"text",

"children"

]

},

"TOKEN": {

"fields": [

"kind",

"token"

]

}

},

"document_example": {

"kind": "CLAUSE",

"label": "DOCUMENT",

"text": "",

"children": [

{

"kind": "PHRASE",

"role": "CLAIM-HEADER",

"text": "FOR THE CLAIM OF THE OCTASYNC LINK IS WITH THE UNITY OF THE PROJECTS AND THE LIFE OF THE VAULT.",

"children": []

},

{

"kind": "PHRASE",

"role": "SECTION",

"text": "PROJECT.QPSG|INITIALIZED=true|SEAL8=DEADBEEF",

"children": []

}

]

}

},

"examples": {

"minimal_valid": [

"FOR THE CLAIM OF THE OCTASYNC LINK IS WITH THE UNITY OF THE PROJECTS AND THE LIFE OF THE VAULT.",

"PROJECT.QPSG| INITIALIZED=true| SEAL8=DEADBEEF"

],

"with_receipt": [

"FOR THE CLAIM OF THE OCTASYNC LINK IS WITH THE UNITY OF THE PROJECTS AND THE LIFE OF THE VAULT.",

"PROJECT.QPSG| INITIALIZED=true| SEAL8=DEADBEEF",

"RECEIPT|ts=2025-10-13T01:33:00-07:00|source=INITIATE.QPSG.PROJECT.W|seal8=b7e3d9f4",

"LINEAGE|V,C,X,Q"

],

"lint_failure_examples": [

"PROJECT.QPSG| initialized=true| seal8=deadbeef",

"PROJECT.QPSG| INITIALIZED true",

"project=bad"

]

}

}