Skip to main content

Module goals

Module goals 

Source
Expand description

#172: /goal — one standing goal, worked on across turns.

A goal is not a loop and not a cron job. A loop re-sends the same prompt on a clock; a goal is a sentence about what the work is for, and after each turn a small model reads the turn and answers one of three words: keep going, it is done, or it is blocked. A “keep going” enqueues the next turn — through the front’s own run entry, like every other turn — and nothing else about the agent changes.

The behaviour is data: a goals row in the session store (sessions.db, foreign-keyed to the session so deleting a session deletes its goal) and one row per judgement in goal_turns. The runtime reads those rows; it does not grow a second loop. That is decision 11, and the reason this module holds no timer, no agent and no provider — only the words, the verdict and the arithmetic of a budget.

Three rules are the whole safety of it:

  • Garbage is not “done”. An answer that is not one of the three words is Verdict::Unreadable; it counts as “continue” once and then ends the goal, because a judge that cannot answer must not be asked forever and must never be read as success.
  • A budget ends it out loud. turns is capped, and reaching the cap writes a note rather than going quiet.
  • A gate is a command, not an opinion. --gate "<cmd>" must exit 0 before “done” is accepted; a failing gate turns a “done” back into a “continue” and says so.

Structs§

Goal
One session’s goal, as the store keeps it.
Judgement
One recorded judgement.

Enums§

Request
Everything after the /goal word.
State
Where a goal is.
Verdict
What one judgement decided, as a row in goal_turns.

Constants§

DEFAULT_BUDGET
How many turns a goal gets when nothing says otherwise. Twelve is enough for a job that takes a handful of steps, and few enough that a goal with no ending in sight costs minutes, not an hour.
MAX_BUDGET
The most a goal may be given. A bound in the thousands is a way of writing “forever” with a number that looks deliberate.

Functions§

apply
What a judgement does to a goal. Pure, so the whole state machine is testable without a model.
judge_prompt
The exact question a judgement asks. One word back, and the three words are the whole answer.
manage
Answer one /goal … line. The one implementation all three fronts call, so a verb means the same thing in the terminal and in the browser — including what it refuses.
parse
Parse a /goal line.
split_reply
Split an answer into the word and the rest of the line, so a judge that adds a sentence still has that sentence kept as the note.