Warn against internal definitions in verified prompts
ober
efe25a84a634a7ccc1667343a93f7d26d1ef2b8c
--- a/src/jcode/core/verified-run.ss +++ b/src/jcode/core/verified-run.ss @@ -7074,7 +7074,7 @@ (if (string=? expert-guidance "") "" (string-append expert-guidance "\n"))) - "Jerboa binding rule: use def/define only for top-level declarations. Inside procedure, let, cond, and let-values bodies, bind locals with let, let*, named let, or existing returned variables; an internal def/define is an invalid context for definition even if an example suggests it.\n" + "Jerboa binding rule: use def/define only for top-level declarations. Inside procedure, let, cond, let-values, or a top-level constant initializer such as `(def PIECES (let ...))`, bind locals with let, let*, named let, or existing returned variables; an internal def/define is an invalid context for definition even if an example suggests it. Do not build constants by writing `(let () (def x ...) ...)`; use `let*` bindings or plain quoted/vector literals instead.\n" "Jerboa iteration rule: avoid Racket-style `for`, `for/list`, `for/vector`, and `in-range` unless the repository proves those exact forms work. Use named let recursion, `do`, or explicit list/vector builders so loop variables are ordinary lexical bindings.\n" "Workflow:\n" "1. read any files you need to understand first.\n" --- a/test/run.ss +++ b/test/run.ss @@ -5833,6 +5833,14 @@ (and (str-contains? s "<expert/>") (str-contains? s "openrouter/deepseek/deepseek-v4-pro")))))) +(check-pred! "verified-run: binding prompt forbids def in let initializers" + (workflow-system-prompt-template (coding-workflow "true" "/tmp")) + (lambda (s) + (and (str-contains? s "top-level constant initializer") + (str-contains? s "(def PIECES (let") + (str-contains? s "(let () (def x") + (str-contains? s "plain quoted/vector literals")))) + (let* ([vr-dir "/tmp"] [target "jcode-verified-mcp-budget.txt"] [target-path (string-append vr-dir "/" target)]