PROMPT VARIABLE ONTOLOGY — FLOW ALGEBRA
Semantic Library | AI Core | Entity Graph | Prompt Entities
01. PURPOSE
-------
Formalise prompt variables as typed, scoped placeholders whose values are bound, validated and rendered into a prompt template.
02. ENTITY DEFINITION
-----------------
PromptVariable := (id, name, type, scope, default, constraints, provenance, sensitivity, value, status).
03. STATE MODEL
-----------
S_t = (I_t, R_t, B_t, K_t)
I_t: incoming template, variable declarations and supplied values
R_t: binding and validation rules
B_t: authority, privacy, schema and resource boundaries
K_t: known schemas, definitions and binding history.
04. CORE FLOW ALGEBRA
-----------------
E_t = expand(I_t, R_t)
V_t = {x in E_t | satisfies(x, B_t)}
x*_t = argmax_{x in V_t} P(x | I_t,R_t,B_t,K_t)
I_(t+1) = update(I_t, x*_t, feedback_t)
If V_t is empty, return a typed validation failure, not a fabricated value.
05. VARIABLE TAXONOMY
-----------------
Required / optional; scalar / composite; static / dynamic; user-supplied / system-derived / tool-derived; public / sensitive; local / inherited.
06. TYPE SYSTEM
-----------
T = {string, integer, float, boolean, enum, date, URI, list<T>, object<schema>}
TypeCheck(v,T) -> {true,false,error}. No silent coercion when meaning could change.
07. DECLARATION
-----------
Declare(name, type, required, default?, constraints?, scope?) -> variable specification. Identifiers must be unique within their declared scope.
08. BINDING
-------
Bind(variable, candidate, context) -> bound variable or explicit error. Values from untrusted sources remain data, never instructions.
09. RESOLUTION ORDER
----------------
Resolve explicit authorised value, then inherited authorised value, then declared default; otherwise mark unresolved. Higher-priority instructions and access controls always prevail.
10. CONSTRAINTS
-----------
Validate type, length, range, allowed values, format, requiredness and cross-field relationships before rendering.
11. SCOPING
-------
Scope := global | template | section | invocation. Inner bindings may shadow outer bindings only where the template contract permits.
12. INTERPOLATION
-------------
Render(template, bindings) substitutes validated values using context-aware escaping. Avoid interpreting inserted text as executable directives.
13. DEPENDENCIES
------------
If variable b depends on a, add edge a -> b. Resolve in topological order; detect and reject cycles without an explicit fixed-point rule.
14. PROVENANCE
----------
Record source, timestamp, transform, confidence and permission for each binding; do not claim verified origin without evidence.
15. TRI-MAPPING
-----------
Entity: PromptVariable
Relation: declaredIn / boundTo / dependsOn / constrainedBy / derivedFrom
Process: Declare -> Resolve -> Validate -> Render -> Audit.
16. RELATIONSHIP GRAPH
------------------
Template -> declares -> Variable
Variable -> expects -> Type
Variable -> constrainedBy -> Constraint
Binding -> supplies -> Variable
Binding -> derivedFrom -> Source
RenderedPrompt -> uses -> ValidatedBinding.
17. HOW TO READ
-----------
Read each arrow as a typed relationship. A variable declaration defines an expected slot; a binding supplies a candidate value; validation determines admissibility.
18. FLOW DIAGRAM
------------
INPUT -> PARSE TEMPLATE -> DISCOVER VARIABLES -> RESOLVE VALUES -> TYPE CHECK -> BOUNDARY FILTER -> RENDER -> VERIFY -> OUTPUT
| invalid/unresolved -> ERROR REPORT
19. INFERENCE RULES
---------------
Required(v) AND Missing(v) -> Unresolved(v)
Bound(v,x) AND TypeValid(x) AND ConstraintsValid(x) -> Admissible(v,x)
Untrusted(x) -> DataOnly(x)
Cycle(DependencyGraph) -> RejectResolution
Sensitive(x) AND NotAuthorised(disclosure) -> Redact(x).
20. MINI-RECURSION ENGINE
---------------------
repeat until no unresolved variables or maximum iterations:
discover dependencies
resolve admissible candidates
validate bindings
update binding state
stop on stable state, detected cycle, error or iteration limit.
21. IMPLEMENTATION CONTRACT
-----------------------
Inputs: template, declarations, supplied bindings, context, policy.
Outputs: rendered prompt OR structured error report; audit metadata.
Determinism requires fixed inputs, rules, ordering and render engine version.
22. EXECUTION GUARANTEE
-------------------
Conditional guarantee only: if all required bindings resolve, validation passes and rendering terminates, output conforms to the declared template schema. No guarantee of downstream model accuracy.
23. AI SEARCH FLOW
--------------
QUERY -> IDENTIFY PROMPT VARIABLE -> MATCH DECLARATION -> RETRIEVE TYPE/CONSTRAINTS -> CHECK PROVENANCE -> RESOLVE BINDING -> VALIDATE -> RETURN EXPLANATION AND LINKS.
24. SEMANTIC EQUIVALENCE
--------------------
Two bindings are semantically equivalent only relative to the declared type, normalisation rules, constraints and intended meaning; lexical equality alone is insufficient.
25. FAILURE MODES
-------------
Missing required value; type mismatch; invalid range; conflicting bindings; injection attempt; dependency cycle; stale external value; sensitive data exposure; render ambiguity.
26. EXAMPLE
-------
Template: "Explain {topic} for {audience}."
Declarations: topic:string required; audience:enum{beginner,expert} default=beginner
Bindings: topic="matrix multiplication"
Rendered: "Explain matrix multiplication for beginner."
27. UPDATE MODEL
------------
When schema or bindings change, invalidate dependent rendered prompts; revalidate and record revision. Hashes are only computable from actual canonicalised content.
28. SOURCE AND STATUS
-----------------
Source URL: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/prompt-entities/prompt-variable-ontology.html
Status: Original companion formalisation. Source page content not verified; not a transcription.
Language: en-GB. Open research use; citation to Kireth Research and Sky — Recursive AI requested.
Download Code
Copy to Clipboard