Generate: richer LLM context (examples, prior model, persistence)
Three changes to the :generate-model hook, one theme — context
flows from state the user can see and edit:
- Every top-level
models/*.lispdemo rides the system prompt verbatim (idiom; ~35 KB atopmodel-reference.md). - A non-empty
:modelfield rides the user message as advisory prior art (erase = fresh start). - The hook
be-update=s =:description/:modelfrom the action:datapayload before generating, so browser state is what gets stored and prompted.
Implemented 2026-09-27 per generate-context-plan.org (no deviations):
lisp/model.lisp:generate-model-example-files(top-level glob, depth-one regex — excludesmodels/test/andmodels/local/by construction),generate-model-example- block(per-file;; --- path ---banner, unreadable/empty skipped),generate-model-examples-text(framing),generate- model-system-prompt(reference + examples, rebuilt per call);generate-model-user-messageextracted (instruction, optional advisory prior-model block, description last);generate-model-llm-callnow takes (description prior-model) —*generate-model-llm-override*signature widened to match; the hook resolves both fields from:datawhen present (browser always posts both keys), fails fast on an empty resolved description,be-update=s exactly those two fields as the acting user before spawning the worker (nil =:dataprogrammatic callers skip the update — record-only path unchanged), and passes the resolved strings to the worker. Worker keeps the pre-update record snapshot (only:idis read downstream; re-reading would race the status column). System prompt ≈ 118k chars live-verified; nomodels/test/leak.tests/generator-tests.lisp: pinned demo set (10 names — forces a conscious token-budget re-check when a demo lands), examples-block skip on unreadable file, user-message prior present/absent + ordering, system prompt carries demos and no fixture blocks, Step 3 persist-with-:data / prior-model-to-LLM / skip-without-:data; override call sites updated to the new 2-arg signature.(run-generator-tests): 78 checks, 0 fail.docs/hook-registry.md/docs/model-reference.md::generate- modelrows updated (system prompt = reference + all top-levelmodels/demos; prior-model in user message;:datapersistence before generating).
Notes:
models/shopping.lisp(a generated-model demo from this morning's quality testing) had been trashed before this session; restored from Trash to satisfy the pinned-set test (it was never in git — shows as untracked; decide whether to commit or re-trash it).- Fixture-name leak assertions use
models/test/block-marker andbi-m2m-test: the stringsm2m-test/static-select- testappear insidemodel-reference.mdprose itself, so they can't be asserted absent. - Live staging smoke (fresh/tweak/erase/regenerate quality diff)
still pending — needs the Model Bank staging site and a real
llm-config.
Follow-up (same day, Donnie's design): failed-attempt capture in
the :model field replaces the earlier embed-the-text-in-the-error
experiment (reverted — parse error in model text is a one-line
message again, 180-char status cap restored). On validation
failure, apply-generated-model-text (now taking the prior model
value) writes the failed model with a one-line ;; failed: <error>
first line + normal header + cleaned body — only when the field
is empty or already starts with ;; failed: = (=failed-model-p);
a working model is never clobbered (erase the field to opt in).
Writes via be-set-field-value (raw column write — the failed
text is invalid, be-update would fail the validation that just
failed). Multi-line errors collapse via generate-model-error-
line so the marker stays one line. LLM-call failures (no
artifact) remain status-only. Bonus: the failed model + error
line ride the prior-model block on the next Generate verbatim.
Live-smoked all three branches (empty → capture; already-failed →
replace; working → untouched).
- Slot
- 28400
- Status
- 60 Done
- Tags
- mvp, backend, ai
- Contributors
- Donnie