Skip to content

16.9 English mode — the question writes the goal

question → goal (a final MATCH … RETURN) → plan → compiled query → rows
one model call no model

plan({question}) (or a question body) hands the question to the same text-to-Cypher generator kg_ask uses, told the world’s schema and the facts its steps can make — each with its description and what it needs (text, an identity) — the facts declared that nothing makes, and the names the steps already bind, which the goal must not reuse (§16.3·4).

  • Prefer the world. When stored or live data answers the question, the goal reads only world labels, and the answer says worldOnly: true: no steps, no projection. A goal reads a fact only when the question needs what only a step makes.
  • Checked without a model. Each written goal must be one read-only query, typed, with no parameters, over declared labels only — then it is planned exactly as a goal would be, with the caller’s inputs.
  • A missing input is a question back. A goal reachable only from text no one supplied answers needsInput ({type: 'text', why}), carrying the goal, so supplying the input plans that goal without writing it again.
  • A goal that cannot be reached is rewritten, then declined. A fact nothing makes, or a goal that does not compile beside its steps, is sent back to the generator with every reason so far — up to three attempts — and then the answer is declined, naming what nothing makes. It is never a guessed answer.
  • Both layers are shown. The answer carries the question, the goal written from it, and the plan made of that goal. Writing the goal is the one model call run: false makes. A question with run: true writes the goal again; to run exactly what was shown, pass the returned goal as goal.

A question is not yet a field of a saved view; a view that should keep its answer pins the goal (§16.10).