Pattern Abstract Grammar

Pattern Abstract Grammar

Structured instructions for LLMs

KeywordsA1

The keywords fall into categories by the job they do in a line, and every keyword is uppercase because that is the form the model has seen most in code. Every keyword outside the prepositions grounds to a record in the ontology's reasoning collection, so the vocabulary is derived rather than invented, and the lists below are read from the grammar's own records.

Semantic operationsA1.1

A document names one of the semantic operations for every external effect. One adapter per harness maps each operation to a tool, and the short tool forms an adapter accepts are its aliases, never the grammar's vocabulary.

DISCOVER_RESOURCES
Find resources by pattern · the adapter maps GLOB to itDISCOVER_RESOURCES "<pattern>" INTO <resources>
READ_RESOURCE
Read one resource · the adapter maps READ to itREAD_RESOURCE <resource> INTO <content>
SEARCH_CONTENT
Search content for a term · the adapter maps GREP to itSEARCH_CONTENT <content> FOR <term> INTO <matches>
ANALYZE_CONTENT
Analyze content against criteriaANALYZE_CONTENT <content> AGAINST <criteria> INTO <findings>
EXTRACT_FACTS
Isolate fields from content, preserving its meaningEXTRACT_FACTS <fields> FROM <content> INTO <facts>
CALCULATE_METRIC
Derive a measure from factsCALCULATE_METRIC <measure> FROM <facts> INTO <value>
COMPOSE_ARTIFACT
Compose an artifact from facts using a shapeCOMPOSE_ARTIFACT <artifact> FROM <facts> USING <shape>
VALIDATE_ARTIFACT
Validate an artifact against a schemaVALIDATE_ARTIFACT <artifact> AGAINST <schema>
PERSIST_ARTIFACT
Persist an artifact to a destination · the adapter maps WRITE and EDIT to it, and a refusal is named before itPERSIST_ARTIFACT <artifact> TO <destination>
EXECUTE_TOOL
Execute a command with a bound · the adapter maps BASH to itEXECUTE_TOOL <command> WITH timeout: <bound> INTO <result>
REQUEST_DECISION
Ask a party to decide · the adapter maps ASK_USER to it, and resolves it absent for a bounded readerREQUEST_DECISION <party> WITH options: [<a>, <b>] INTO <choice>
REPORT_RESULT
Report an artifact to the parties whose next work it createsREPORT_RESULT <artifact> TO <parties>

Node keywordsA1.2

These tokens make up the node form, which is the unit of a document. They cover the header with its four-slot tag, the contract, the substrate stage at which the node's artifact comes to be, and the slots and limits a document declares.

NODE
A node header · the unit of a document, one decision, one gate# NODE <n> — <NAME> [<layer> · <axis> · <math type> · yields: <shape>]
CONTRACT
A node's contract · input, transform, constraints, output, handoffCONTRACT:
YIELDS
The shape a node's decision resolves toyields: <set | boolean | edge-list | ranking | procedure | artifact>
GENESIS
The substrate stage the node's artifact comes to be at · phase order follows it@genesis: <existence | difference | relation | structure | transformation | constraint | emergence>
PRESERVES
The distinctions a transform keeps · a lowering names what a later check needspreserves: <distinction>, <distinction>
OUTPUT_CONTRACT
The one record the next node reads, as an assignment# OUTPUT CONTRACT
LIMIT
A declared limit · stated where a reader would otherwise assume the oppositeLIMIT <name>: "<what the document cannot do>"
SLOT
A slot's state · resolved, absent or deferred, declared by the adapterSLOT {<namespace>.<name>}: RESOLVED | ABSENT | DEFERRED

Validation keywordsA1.3

These tokens make up the handoff gate. They cover a check with its evidence and the population it was measured over, the refusal before a write, the standing of the read set, and the three verdicts, with unknown routed to blocked.

ASSERT
Hard assertionASSERT condition
REQUIRE
Prerequisite checkREQUIRE dependency
HANDOFF
Gate marker · the evidence-bearing gate that closes a nodeHANDOFF GATE (evidence-bearing):
GATE
Checkpoint markerHANDOFF GATE:
CHECK
A check in a gate · a claim about the output with the evidence that settles it[check] <claim> (evidence: <what settles it>)
POPULATION
The set a check ranges over, measured · zero of zero is not evidenceover: <set> measured: <n> / <N>
REFUSE
Where a node refuses to continue · named before the irreversible writerefuse: <condition> before <write>
FRESHNESS
The fingerprints an artifact was derived from · a semantic property, never a timestampfreshness: <inputs fingerprint> + <code fingerprint>
STANDING
Whether the read set moved beneath the verdict · a non-empty moved set withdraws the standing, never the verdictstanding: moved-set <set>
UNKNOWN
The third verdict · an unmeasured or unevidenced claim, never a passunknown → BLOCKED
BLOCKED
The closure of an unknown or an unanswered decision · external input is owedresult: ... | unknown → BLOCKED
PROMOTE
Move a candidate into accepted state · only on a clean verdict, never on productionpromote: <candidate> ON clean verdict
PUBLISH
Cross the boundary to the external system · the party that crosses it is namedpublish: <artifact> BY <party>
RESULT
The result line · the next node on pass, the repair owner on failure, blocked on unknownresult: pass → NODE <n+1> | <failure> → REPAIR (owner: <node>) | unknown → BLOCKED
REPAIR
The repair edge · re-enters at the earliest node that can supply the missing evidenceREPAIR (owner: NODE <n>)
RULE_ID
The gate's identity, the node it closesrule_id: "<NODE NAME>"

Report keywordsA1.4

A verdict is written as a report so that a later checker can challenge it. The report's fields record what was measured, over what, from which inputs, and whether the three termination conditions coincide.

SUBJECT
The node or stage the report is aboutsubject: <node>
VERDICT
The value returned · pass, fail or unknownverdict: pass | fail | unknown
DOMAIN
The population declared and the population measureddomain: declared <N> measured <n>
POPULATIONS
The partitions, each measured · their sum is the wholepopulations: <part> <n>, <part> <n>
INPUTS
The inputs read, by identity and fingerprintinputs: <identity> <fingerprint>
CODE
The fingerprint of the code that produced the verdictcode: <fingerprint>
OUTPUT
The artifact written, by identity and fingerprintoutput: <identity> <fingerprint>
REFUSALS
How many times the stage refused, and whyrefusals: <n> [<reason>]
OBSERVED
What runtime observation located, kept apart from the verdictobserved: <n> [<location>]
UNRESOLVED
What stays open, and whyunresolved: <n> [<reason>]
COMPLETION
Saturated, complete and verified · the three that must coincidecompletion: saturated <bool> complete <bool> verified <bool>

Invariant keywordsA1.5

An invariant record states a property in a form that could be false, the set it quantifies over, the parties it binds, and the objector that would disagree if it stopped holding. A record with no objector declares none, and the missing check stands as declared debt.

INVARIANT
The record head · a property the topology relies on, with its set, its parties and its objectorINVARIANT <name>: <property> over: <set> binds: <parties> objector: <check | none>
PROPERTY
The property, in a form that could be falseINVARIANT one-writer: a record has exactly one writer ...
OVER
The set the property quantifies overover: every record on the surface
BINDS
The parties the property constrains · who must receive itbinds: every party writing there
OBJECTOR
What would disagree if the property stopped holding · a check, or none as declared debtobjector: [check] one open fence per record | none

Meta keywordsA1.6

The meta block and the node tags state what the document is for, which source grounds which, what it trusts, what it may touch and what it declares outside itself, and how far repair may recurse.

META
Metadata block%% META %%:
USE
Template usageUSE TEMPLATE name
CUE
The one-line reminder a reader executes at a node@cue: "<reminder>"
RECURSION_LIMIT
A bound on repair, declared in the meta blockrecursion_limit: <bound>
PURPOSE
What a node decides, in one sentence@purpose: "<what this node decides>"
AXIS_QUESTION
The question a node's axis asks@axis_question: "<the question>"
TRUST
What is trusted as evidence and what stays a claimtrust: tool_output = TRUSTED, prior_knowledge = UNTRUSTED
JURISDICTION
What the document may touch, and what is declared outside itjurisdiction: <in scope> | external: <declared outside>
PRIORITY
The authority tiers · which source grounds which, highest firstpriority: <governing document> > <ontology> > <template> > <task>
TEMPLATE
Template referenceUSE TEMPLATE validation

Action keywordsA1.7

A directive inside a node's transform opens with one of these verbs. Each grounds to a reasoning mode or a loop node, and the ones that name an effect lower to a semantic operation.

READ
Input acquisition · lowers to READ_RESOURCEREAD file INTO data
WRITE
Output generation · lowers to PERSIST_ARTIFACTWRITE content TO file
EXECUTE
Action invocation · lowers to EXECUTE_TOOLEXECUTE command WITH params
CREATE
Construction · lowers to COMPOSE_ARTIFACTCREATE artifact FROM template
DELETE
Removal · an irreversible write, refused before it landsDELETE file_path
FIND
Discovery · lowers to DISCOVER_RESOURCESFIND pattern IN scope
ANALYZE
Inspection · lowers to ANALYZE_CONTENTANALYZE target FOR condition
VALIDATE
Verification · lowers to VALIDATE_ARTIFACTVALIDATE state AGAINST schema
VERIFY
Confirmation against evidenceVERIFY condition
EXTRACT
Isolation · lowers to EXTRACT_FACTSEXTRACT data FROM source
COLLECT
AggregationCOLLECT items INTO container
FILTER
SelectionFILTER items WHERE condition
COMPARE
ComparisonCOMPARE a AGAINST b
CONVERT
Transformation · a lowering that names what it preservesCONVERT data TO format
MERGE
CombinationMERGE sources INTO target
SPLIT
DivisionSPLIT data BY delimiter
SORT
OrderingSORT items BY criteria
RANK
Prioritization · the ranking a worth gate readsRANK items BY score
LINK
Association · a declared edge, never a name matchLINK source TO target
REPORT
Output · lowers to REPORT_RESULTREPORT findings
ADD
Add to collectionADD item TO list
APPEND
Append to endAPPEND value TO array
INSERT
Insert at positionINSERT item AT index
REMOVE
Remove from collectionREMOVE item FROM list
MOVE
Relocation · a create at the destination, read before it landsMOVE file TO destination
COPY
Duplication · a second derivation of one fact, declared as suchCOPY file TO backup
BACKUP
Preservation of the last accepted state before a mutationBACKUP file TO location
RESTORE
Recovery of the last accepted stateRESTORE FROM backup
LOAD
Resource acquisition · lowers to READ_RESOURCELOAD config FROM file
SEND
Communication · lowers to REPORT_RESULTSEND message TO recipient
WAIT
Timing control · waiting has a commandWAIT FOR condition
ATTEMPT
Trial operationATTEMPT operation
FAIL
Error termination · loud at the boundaryFAIL WITH message
EXIT
Exit executionEXIT 1
RETURN
Return value · how a bounded reader endsRETURN result
ITERATE
RepetitionITERATE operation
INVESTIGATE
Deep analysisINVESTIGATE issue
DETERMINE
Decision makingDETERMINE outcome
ENFORCE
Constraint applicationENFORCE rule
EVIDENCE
Proof provisionEVIDENCE claim
PROPAGATE
Change distribution · the ripple through declared dependenciesPROPAGATE updates
FINALIZE
CompletionFINALIZE operation
REDUCE
Aggregation · a fusion that drops nothing liveREDUCE items TO value
RENAME
Name modification · every referencing surface enumerated firstRENAME file TO newname
ORDER
ArrangementORDER items BY key
MARK
AnnotationMARK item AS complete
PREDICT
Infer a future statePREDICT outcome FROM model
CLASSIFY
Group by kindCLASSIFY item BY type
EXPLAIN
Identify the mechanismEXPLAIN behavior
REFLECT
Discover the principle behind the examplesREFLECT ON outcome
ABSTRACT
Remove irrelevant detailABSTRACT pattern FROM cases
GENERALIZE
Extend examples into a principleGENERALIZE FROM examples
DESCRIBE
Characterize an objectDESCRIBE structure
FORMALIZE
Express symbolicallyFORMALIZE rule AS predicate

Control flow keywordsA1.8

These keywords mirror the flow control constructs of programming languages.

IF
Conditional executionIF condition: action
ELSE
Alternative branchELSE: alternative
FOR
Iteration startFOR EACH item IN list:
EACH
Iterator markerFOR EACH x IN items:
WHILE
Conditional loopWHILE condition: action
TRY
Exception handling startTRY: risky_op
CATCH
Exception handlerCATCH: handle_error
EXCEPT
Exception alternativeEXCEPT: recovery
FINALLY
Cleanup blockFINALLY: cleanup
MATCH
Pattern matchingMATCH value:
CASE
Match branchCASE pattern: action
DEFAULT
Fallback case · a declared default, never a masked failureDEFAULT: fallback
WHEN
Event triggerWHEN event: action
UNLESS
Negated conditionalUNLESS condition: action
UNTIL
Loop terminatorUNTIL done
GUARD
Early exit checkGUARD cond ELSE: exit
BREAK
Exit loopBREAK
CONTINUE
Skip iterationCONTINUE
GOTO
Jump to labelGOTO label
START
Flow start markerSTART process
END
Flow end markerEND
STOP
TerminationSTOP
LOOP
Loop markerLOOP BACKTO step
STEP
Step markerSTEP 1: action
RULE
Rule definitionRULE name: body
IN
Containment testitem IN collection
MATCHES
Pattern testvalue MATCHES pattern

Declaration keywordsA1.9

These keywords declare the variables and types that hold a document's state.

SET
Variable assignmentSET name = value
DECLARE
Typed declarationDECLARE x: string
DEFINE
Constant definitionDEFINE PI = 3.14
LET
Local bindingLET temp = expr
CONST
Immutable valueCONST MAX = 100

Modifier keywordsA2.1

A modifier qualifies and strengthens a line inside a property. It never heads a block, because a block head states no set, no parties and no objector, and the invariant record carries all three.

MUST
Mandatory requirement · a modifier inside a propertyMUST validate first
NEVER
Prohibition · a modifier inside a propertyNEVER delete without backup
ALWAYS
Invariance · a modifier inside a propertyALWAYS log changes
REQUIRED
Necessity markerREQUIRED field
MANDATORY
Obligation markerMANDATORY check
CRITICAL
Repair ordering among failures, never a softer verdictCRITICAL validation
ABSOLUTE
No exceptionsABSOLUTE rule
FORBIDDEN
Absolute prohibitionFORBIDDEN: direct DB

Coordination keywordsA2.2

A shared surface makes this structure explicit. It consists of the surface, its records, each with exactly one writer, the addressed items inside them, the typed edges between records, the states derived from those edges, the reader classes, and the one operation that posts and waits. The waiting, locking and retry tokens describe the same model from one party's turn.

AWAIT
Async wait · waiting has a command, a turn never ends to waitAWAIT op INTO result
PARALLEL
Concurrent executionPARALLEL: tasks END
DELEGATE
Task handoff · a bounded reader receives a task and returnsDELEGATE task TO reader
QUEUE
Task queuingQUEUE operation
RETRY
Retry on failure · bounded by a declared limitRETRY operation
LOCK
Resource lock · the barrier around an exclusive writeLOCK resource
UNLOCK
Release lockUNLOCK resource
SURFACE
A file parties read and write · its key declared in the header, never derived from the pathSURFACE <key>:
RECORD
One addressable claim inside a surface · exactly one writerRECORD <id> subject: <key>
ITEM
An addressed span inside a record · its id allocated by the toolITEM <id> TO <reader>: <claim>
PARENT
Edge · the target reduces this surface upwardPARENT <surface>
SATISFIED_BY
Edge · the record resolves when the artifact existsSATISFIED_BY <artifact>
BLOCKS
Edge · the target cannot close firstBLOCKS <record>
ANSWERS
Edge · this record acts on the targetANSWERS <record>
REFUTES
Edge · this record contradicts the target with evidenceREFUTES <record>
SUPERSEDES
Edge · this record replaces the targetSUPERSEDES <record>
OPEN
Derived state · an unresolved outbound edge, never writtenstate: OPEN
ABSORBED
Derived state · the satisfying artifact exists, so it is extracted, then deletedstate: ABSORBED
READER
A party's class, derived from what it received · participant or boundedREADER <party> AS participant | bounded
BARRIER
Proceed with an exclusive write only once every peer is parkedBARRIER ON <surface>
SWAP
Compare-and-swap on the writer's own span · refuses an overlap with its diffSWAP <span> AGAINST <read>
WAIT
Post and wait as one operation · reports the diff since this reader last lookedWAIT ON <surface> AS <reader> INTO <diff>

State machine keywordsA2.3

A state machine makes a lifetime explicit, meaning the states a thing can be in and the transitions that are legal between them. In a coordinated document a state is derived from the graph and never written, so the machine declares what may happen, not what has.

STATE_MACHINE
Machine declaration · makes a lifetime or a derived-state set explicitSTATE_MACHINE workflow:
STATE
State definition · a state is derived from the graph, never writtenSTATE pending:
TRANSITION
State change ruleTRANSITION FROM a TO b
ON
Event triggerON approval
FROM
Source stateFROM pending
TO
Target stateTO approved
ENTRY
Entry actionENTRY: notify
EXIT
Exit actionEXIT: cleanup

DAG keywordsA2.4

A dependency graph makes explicit what depends on what, as declared by the referent and never inferred from a name. The loop spine of a document is one such graph, and a repair edge is a back-edge on it.

DAG
Graph declaration · makes a dependency graph explicit, and the loop spine is oneDAG pipeline:
DEPENDS_ON
Dependencies · declared by the referent, never inferred from a nameDEPENDS_ON [a, b]
AFTER
SequencingAFTER compile
BEFORE
Reverse sequencingBEFORE deploy
PARALLEL_GROUP
Parallel nodes · peers with no edge between themPARALLEL_GROUP: a, b
NODE
Node definitionNODE build:

Priority queue keywordsA2.5

A priority queue makes a ranking explicit, with the candidates ordered by a declared worth. The branch ranking a worth gate emits is one, and a peek returns the selected branch.

PRIORITY_QUEUE
Queue declaration · makes a ranking explicit, and the branch ranking a worth gate emits is onePRIORITY_QUEUE branches:
PRIORITY
Priority value · utility minus costPRIORITY = 10
ENQUEUE
Add to queueENQUEUE task TO q
DEQUEUE
Remove from queueDEQUEUE FROM q
PEEK
View top item · the selected branchPEEK queue
HEAPIFY
Reorder queueHEAPIFY queue
COMPARE_BY
Comparison functionCOMPARE_BY priority

Flowchart keywordsA2.6

A flowchart is the rendered projection of a declared structure. It shows a graph, a lifetime or a ranking to a reader, and it never carries a structure the document did not declare elsewhere.

FLOWCHART
Flow declaration · the rendered projection of a declared structureFLOWCHART process:
MERMAID
Diagram syntax · a rendering, never the structure itselfMERMAID flowchart:
LAYOUT
Flow directionLAYOUT vertical
SUBGRAPH
Nested groupSUBGRAPH auth:

Document type keywordsA2.7

These keywords name the document type in a declaration of the form THIS {TYPE} {VERB} description.

AGENT
Agent definitionTHIS AGENT PERFORMS...
WORKFLOW
Multi-node processTHIS WORKFLOW EXECUTES...
PROTOCOL
Standard proceduresTHIS PROTOCOL DEFINES...
POLICY
Constraint systemTHIS POLICY ENFORCES...
CHECKLIST
Task trackingTHIS CHECKLIST PROVIDES...
TEMPLATE
Reusable patternTHIS TEMPLATE IMPLEMENTS...
TASK
Single objectiveTHIS TASK EXECUTES...
INSTRUCTION
General guidanceTHIS INSTRUCTION IS...
PROMPT
Model interactionTHIS PROMPT IS...
COMMAND
Executable commandTHIS COMMAND EXECUTES...
TEST
Test specificationTHIS TEST PERFORMS...
DEBUG
Debugging sessionTHIS DEBUG RESOLVES...
VERIFICATION
Compliance verificationTHIS VERIFICATION PERFORMS...
DISTILLATION
Pattern distillationTHIS DISTILLATION DISTILLS...
AUDIT
Forensic auditTHIS AUDIT AUDITS...
TRANSLATION
Translation auditTHIS TRANSLATION AUDITS...
COMPOSITION
Document compositionTHIS COMPOSITION RENDERS...

Document verbsA2.8

These verbs follow the type in a document declaration.

IS
IdentityTHIS INSTRUCTION IS...
ENFORCES
ConstraintTHIS POLICY ENFORCES...
EXECUTES
ActionTHIS WORKFLOW EXECUTES...
HAS
PossessionTHIS AGENT HAS...
PERFORMS
BehaviorTHIS AGENT PERFORMS...
PROVIDES
OfferingTHIS CHECKLIST PROVIDES...
IMPLEMENTS
RealizationTHIS TEMPLATE IMPLEMENTS...
DEFINES
SpecificationTHIS PROTOCOL DEFINES...
MANAGES
ControlTHIS AGENT MANAGES...
COORDINATES
OrchestrationTHIS WORKFLOW COORDINATES...
GENERATES
CreationTHIS TEMPLATE GENERATES...
RESOLVES
ResolutionTHIS DEBUG RESOLVES...
FINDS
DiscoveryTHIS DEBUG FINDS...
FIXES
CorrectionTHIS DEBUG FIXES...
VERIFIES
VerificationTHIS VERIFICATION VERIFIES...
CLASSIFIES
ClassificationTHIS VERIFICATION CLASSIFIES...
DISTILLS
DistillationTHIS DISTILLATION DISTILLS...
ABSTRACTS
AbstractionTHIS DISTILLATION ABSTRACTS...
ELIMINATES
EliminationTHIS DISTILLATION ELIMINATES...
AUDITS
AuditTHIS AUDIT AUDITS...
MEASURES
MeasurementTHIS AUDIT MEASURES...
SCORES
ScoringTHIS AUDIT SCORES...
CORRECTS
CorrectionTHIS TRANSLATION CORRECTS...
RENDERS
RenderingTHIS COMPOSITION RENDERS...
COMPOSES
CompositionTHIS COMPOSITION COMPOSES...
FOLDS
FoldingTHIS COMPOSITION FOLDS...

Contextual keywordsA2.9

These prepositions and connectors state the relation between the operands of a line.

INTO
DestinationREAD file INTO data
WITH
AssociationEXECUTE WITH params
USING
InstrumentVALIDATE USING schema
AS
Alias/RoleBIND result AS alias
BETWEEN
Rangevalue BETWEEN 1 AND 10
AGAINST
Comparison targetVALIDATE AGAINST schema
BASED_ON
FoundationCREATE BASED_ON template
WITHOUT
ExclusionEXECUTE WITHOUT logging
WHERE
Filter conditionFIND WHERE x > 0
CONTENT
Data markerWRITE CONTENT data
NOT
NegationNOT condition
STYLE
FormattingSTYLE output
FOR
Purpose/IterationSEARCH FOR pattern
IN
ContainmentFIND key IN object
FROM
SourceEXTRACT FROM response
TO
TargetWRITE TO file

An adapter's aliasesA3.1

The aliases below belong to one adapter, and they are shown as an instance of a binding rather than as grammar. The grammar carries no tool name, so a document names the operation, and the binding for a harness maps its short forms to the operation and the operation to whichever tool performs it there. Another harness ships another table, and the document does not change.

READ
An alias for READ_RESOURCEREAD "<file>" INTO <content>
WRITE
An alias for PERSIST_ARTIFACTWRITE <content> TO <file>
EDIT
An alias for PERSIST_ARTIFACT over a spanEDIT <file> WITH before: "<span>", after: "<span>"
GLOB
An alias for DISCOVER_RESOURCESGLOB "<pattern>" INTO <files>
GREP
An alias for SEARCH_CONTENTGREP "<term>" IN <scope> INTO <matches>
BASH
An alias for EXECUTE_TOOLBASH "<command>" WITH timeout: <bound>
WEB_FETCH
An alias for READ_RESOURCE over a remote addressWEB_FETCH "<address>" INTO <content>
WEB_SEARCH
An alias for DISCOVER_RESOURCES over the webWEB_SEARCH "<query>" INTO <hits>
TASK
An alias for DELEGATE to a bounded readerTASK "<objective>" WITH agent: <role> → <result>
ASK_USER
An alias for REQUEST_DECISIONASK_USER "<question>" WITH options: [<a>, <b>]