docs(agent): the memory rule pointed at a header the build removed - #154
Conversation
AGENT.md told contributors to route dynamic memory through deps/geist/heap.h, resolved via -Ideps/geist. That header is in libgeist's private src/base/, and that include path was dropped with the arena wrapper in v0.3.1 so geistshell depends on the engine's public headers only. The rule was therefore unfollowable: no file includes heap.h, and the few places that genuinely need dynamic memory call malloc directly. State the actual architecture — caller-provided buffers by default, heap.h deliberately out of reach, and the narrow cases where malloc is allowed with a reason written at the call site. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LkBr39Z2JxHU1SL63VyPC9
b9564a8 to
ff1d512
Compare
|
Rebased onto The rebase also invalidated one of this PR's own claims, so I corrected it in the same commit. The text said malloc/calloc had exactly one justified home in the core (the macOS process table). Since #155 that is no longer true: the geistd adapter allocates four vocabulary-sized buffers in Re-verified against current
A document that misstates the codebase is the exact failure this PR exists to fix, so it seemed worth not shipping a second instance of it. Generated by Claude Code |
Raspberry Pi 5 —
|
What
.agent/AGENT.mdtold contributors to route all dynamic memory throughdeps/geist/heap.h, "resolved via-Ideps/geist". Neither half is reachable any more:heap.hlives in libgeist's privatesrc/base/, not in its public include directory.-I$(GEIST_DIR)was dropped with the arena wrapper in v0.3.1 so geistshell does not depend on engine internals — the Makefile comment aboveCPPFLAGSsays exactly that, andCPPFLAGSnow carries-I$(GEIST_DIR)/includeonly.So the rule is unfollowable as written: no file in the tree includes
heap.h, and the handful of places that genuinely need dynamic memory callmallocdirectly — the only option the build leaves them.Change
State the architecture that actually holds:
heap.his deliberately out of reach; do not reintroduce the include path or vendor a copy.mallocneeds a reason written at the call site. Today that is the macOS process table, whose size only the kernel knows (src/machine/backend_macos.c, which carries such a comment), plus file slurping in the CLI surface.No code changes — this only makes the rule match the build.
Testing
Not applicable:
.agent/AGENT.mdis not a build input.Two things this PR deliberately leaves alone
mallocsites insrc/cli/main.ccarry no reason at the call site, which the rule asks for (old wording and new). Adding those comments is a separate, tiny change.heap_alloc_count()in tests, geistshell has no CI gate for this rule — it holds by review. Worth considering, but out of scope here.Found while reading the runtime; the README's pin line was stale the same way, but
fix/workdir-and-reserved-memory-namesalready fixes that, so this PR does not touch it.🤖 Generated with Claude Code
https://claude.ai/code/session_01LkBr39Z2JxHU1SL63VyPC9
Generated by Claude Code