# control_flow

> Every PAG keyword record, with what grounds it and how it is checked.

Page: Ontology · Grammar
Canonical: https://banes-lab.com/ontology/grammar#pag-keywords-control-flow

Listed in [Ontology · Grammar](https://banes-lab.com/api/pages/ontology/grammar.md), after [action](https://banes-lab.com/ontology/grammar/pag-keywords-action.md) and before [declaration](https://banes-lab.com/ontology/grammar/pag-keywords-declaration.md).

Every PAG keyword record, with what grounds it and how it is checked.

### IF

Details

Meaning
Conditional execution

Example
IF condition: action

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### ELSE

Details

Meaning
Alternative branch

Example
ELSE: alternative

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### FOR

Details

Meaning
Iteration start

Example
FOR EACH item IN list:

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### EACH

Details

Meaning
Iterator marker

Example
FOR EACH x IN items:

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### WHILE

Details

Meaning
Conditional loop

Example
WHILE condition: action

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### TRY

Details

Meaning
Exception handling start

Example
TRY: risky_op

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### CATCH

Details

Meaning
Exception handler

Example
CATCH: handle_error

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### EXCEPT

Details

Meaning
Exception alternative

Example
EXCEPT: recovery

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### FINALLY

Details

Meaning
Cleanup block

Example
FINALLY: cleanup

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### MATCH

Details

Meaning
Pattern matching

Example
MATCH value:

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### CASE

Details

Meaning
Match branch

Example
CASE pattern: action

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### DEFAULT

Details

Meaning
Fallback case · a declared default, never a masked failure

Example
DEFAULT: fallback

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### WHEN

Details

Meaning
Event trigger

Example
WHEN event: action

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### UNLESS

Details

Meaning
Negated conditional

Example
UNLESS condition: action

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### UNTIL

Details

Meaning
Loop terminator

Example
UNTIL done

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### GUARD

Details

Meaning
Early exit check

Example
GUARD cond ELSE: exit

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### BREAK

Details

Meaning
Exit loop

Example
BREAK

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### CONTINUE

Details

Meaning
Skip iteration

Example
CONTINUE

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### GOTO

Details

Meaning
Jump to label

Example
GOTO label

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### START

Details

Meaning
Flow start marker

Example
START process

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### END

Details

Meaning
Flow end marker

Example
END

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### STOP

Details

Meaning
Termination

Example
STOP

Grounds
[node:ter-stop](https://banes-lab.com/records/reasoning/node-ter-stop.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### LOOP

Details

Meaning
Loop marker

Example
LOOP BACKTO step

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### STEP

Details

Meaning
Step marker

Example
STEP 1: action

Grounds
[representation:computation](https://banes-lab.com/records/reasoning/representation-computation.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### RULE

Details

Meaning
Rule definition

Example
RULE name: body

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### IN

Details

Meaning
Containment test

Example
item IN collection

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

### MATCHES

Details

Meaning
Pattern test

Example
value MATCHES pattern

Grounds
[representation:logic](https://banes-lab.com/records/reasoning/representation-logic.md)

How it is checked

Checked by
a structured-document validator that parses each document against the grammar and reports every defect by its shape

Population
Every agent and template document the validator walks, and every occurrence of the keyword in them

Freshness
A verdict stands until the grammar data or a document that uses the keyword changes

Refusal
The validation stage fails the gate on any defect code, so a document with a malformed keyword does not ship

Observation
None, because a keyword is static text in a document, and nothing observes it while a run executes

Evidence
Watched to fire and to accept: a suite plants a retired head in a real template and validates every agent and template on disk clean

Authoritative side
The grammar data, which every keyword in a document conforms to

Depends on
Not answered

Shape it refuses
Not answered

## Links to

- [Logic](https://banes-lab.com/records/reasoning/representation-logic.md)
- [Computation](https://banes-lab.com/records/reasoning/representation-computation.md)
- [Stop Condition](https://banes-lab.com/records/reasoning/node-ter-stop.md)
