[#79] Redesign the AI Lisp API: namespaces, read/write separation, file-vs-game forms #81
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Winnie/bankwars!81
Loading…
Reference in a new issue
No description provided.
Delete branch "79-api-clean"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #79.
What changed
Identifiable namespaces. Every game-defined name lives in exactly one of four READ-ONLY namespaces:
bank-*(own state),market-*(public state),game-*(clock),(config 'key)(configuration, quoted as always). The caps are now config keys:(config 'deposit-rate-cap)/(config 'loan-rate-cap)— the two loose top-level symbols are gone.Explicit read-only vs behavior-write separation. All queries are pure; the ONLY forms that mutate the game are the seven imperative actions (
set-deposit-rate,bid-loans,bid-loan,offer-bond,take-bonds,revoke-offers,bid-acquisition). The interpreter rejects any filedefine/set!of a game-owned name, so the boundary is enforced, not just documented.Explicit file-vs-game definitions. New forms:
(defun name (params) body…)for functions,(defvar name init)for file-global state,(define-hook name (params) body…)for engine entry points — validated at load against the six known hooks, so a typo'd hook dies loudly instead of silently no-op'ing. Three file helpers that wore themarket-prefix (mill'smarket-max-term, vault'smarket-avg-term/market-best-price) and vault'smarket-bleeds-usstate were renamed: file names may not wear game prefixes.Reads naturally as Lisp.
condgains a properelseclause (both bare and(else)form), retiring the((> 1 0) …)/(1 …)hacks; unquoted or unknown(config …)keys are now errors instead of silent zeros.All brains migrated. The four mains and all ten specialists (one-mechanism + the six hybrids), logic untouched — each main keeps its structurally distinct world model (empire's funding-horizon term structure, mill's per-loan actuary, vault's cushion + book quality, adapt's regime inference).
dist/ai/release copies synced.Documented and tested.
docs/ai-api.mdis the full contract (namespaces, hooks, list shapes, language reference, enforcement rules, minimal brain, migration table); README's AI section rewritten. Newapi79_test.gopins namespace reads, read-only protection, hook validation, defun/defvar/set!, andcond else;TestReadAIFilescovers all 14 files;TestAllBrainsLoadAndHooksRunloads every brain and calls every hook.Verification
go build+go test .all pass (6 new API tests green),go vet ./...clean at every commit.[aierrors, 0 ACCT/CF DIVERGENCE; same for specialist-roster smokes.