Axone Prolog Core Development
Use this workflow to implement behavior changes without breaking ISO-style error semantics, stream behavior, or deterministic VM state.
Architecture Context
- Use
references/architecture.md as canonical VM architecture context for instruction model, register semantics, and design intent.
- Read it before structural VM changes (opcode behavior, registers, execution flow) and before introducing new execution state.
Blockchain Execution Priority
- Treat this engine as an embedded blockchain VM: deterministic behavior is mandatory.
- Preserve ISO compliance where feasible, but keep project-specific deviations when needed for deterministic or secure execution.
- If a change introduces, removes, or alters a deviation from ISO behavior, update tests and update
README.md deviations accordingly.
- Prefer existing deterministic patterns used in this codebase (ordered maps, explicit permission checks, controlled stream IDs and reset state) over generic Go shortcuts.
Workflow
- Classify the change scope.
- Edit implementation in the primary file set.
- Add or update tests before broad refactors.
- Run focused tests for the changed area.
- Run full build and test parity commands.
- Update
README.md if user-visible behavior changed.
Classify Change Scope
- Change predicate semantics or exception behavior: edit
engine/builtin.go; mirror in engine/builtin_test.go.
- Change VM execution state, registration, hooks, or reset logic: edit
engine/vm.go; mirror in engine/vm_test.go.
- Change stream internals or file mode handling: edit
engine/stream.go and related engine/builtin.go sections; mirror in engine/stream_test.go and engine/builtin_test.go.
- Change parsing or tokenization behavior: edit
engine/parser.go or engine/lexer.go; mirror in engine/parser_test.go or engine/lexer_test.go.
- Change interpreter registration or public behavior: edit
interpreter.go; mirror in interpreter_test.go.
- Change CLI wrapper behavior: edit
cmd/1pl/interpreter.go; mirror in cmd/1pl/interpreter_test.go.
Read references/change-map.md for a quick change-to-test map and discovery commands.
Preserve Core Invariants
- Preserve deterministic behavior; avoid map-order-dependent logic and hidden runtime variability.
- Avoid introducing nondeterministic dependencies (wall clock, random data, unspecified iteration order) into core engine paths.
- Enforce determinism by construction: if behavior depends on external state (time, randomness, host I/O ordering), redesign the API so inputs are explicit and deterministic.
- Reuse existing exception constructors (
typeError, domainError, permissionError, existenceError, resourceError) and match nearby patterns.
- Preserve stream mode permissions:
- Keep
SetInput compatible with read and read_write.
- Keep
SetOutput compatible with write, append, and read_write.
- Preserve filesystem capability checks for write-like modes in
open/3 and open/4 (OpenFileFS path).
- Preserve reset behavior in
ResetEnv(), including stream ID and variable counter reset.
Test Workflow
- Run focused tests first by area (see
references/change-map.md).
- Run package-level tests for touched packages.
- Run full CI-parity build and test commands.
Read references/test-recipes.md for concrete command sets.
Completion Checklist
- Add at least one regression test for each behavior fix.
- For determinism-sensitive changes, prove determinism at design level:
- no hidden entropy in implementation paths;
- tests assert complete value/order/identity semantics, not partial fields;
- any non-deterministic source is injected as explicit input and controlled in tests.
- Confirm all touched tests pass locally.
- Confirm full build and race+coverage test command passes.
- Update docs when behavior changes are externally visible, including
README.md deviations if ISO/constraint boundaries changed.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: axone-prolog-core-development3description: Implement and review core changes in Axone's Go-based Prolog VM and interpreter with strict determinism for blockchain embedding. Use when editing predicate semantics, VM execution state, parser or lexer behavior, stream or filesystem I/O (open/*, read_write, set_stream_position), or interpreter wiring in engine/*.go, interpreter.go, and cmd/1pl/*, while preserving ISO compliance where feasible and maintaining explicit project deviations where required by blockchain constraints. Use when this capability is needed.4---56# Axone Prolog Core Development78Use this workflow to implement behavior changes without breaking ISO-style error semantics, stream behavior, or deterministic VM state.910## Architecture Context1112- Use `references/architecture.md` as canonical VM architecture context for instruction model, register semantics, and design intent.13- Read it before structural VM changes (opcode behavior, registers, execution flow) and before introducing new execution state.1415## Blockchain Execution Priority1617- Treat this engine as an embedded blockchain VM: deterministic behavior is mandatory.18- Preserve ISO compliance where feasible, but keep project-specific deviations when needed for deterministic or secure execution.19- If a change introduces, removes, or alters a deviation from ISO behavior, update tests and update `README.md` deviations accordingly.20- Prefer existing deterministic patterns used in this codebase (ordered maps, explicit permission checks, controlled stream IDs and reset state) over generic Go shortcuts.2122## Workflow23241. Classify the change scope.252. Edit implementation in the primary file set.263. Add or update tests before broad refactors.274. Run focused tests for the changed area.285. Run full build and test parity commands.296. Update `README.md` if user-visible behavior changed.3031## Classify Change Scope3233- Change predicate semantics or exception behavior: edit `engine/builtin.go`; mirror in `engine/builtin_test.go`.34- Change VM execution state, registration, hooks, or reset logic: edit `engine/vm.go`; mirror in `engine/vm_test.go`.35- Change stream internals or file mode handling: edit `engine/stream.go` and related `engine/builtin.go` sections; mirror in `engine/stream_test.go` and `engine/builtin_test.go`.36- Change parsing or tokenization behavior: edit `engine/parser.go` or `engine/lexer.go`; mirror in `engine/parser_test.go` or `engine/lexer_test.go`.37- Change interpreter registration or public behavior: edit `interpreter.go`; mirror in `interpreter_test.go`.38- Change CLI wrapper behavior: edit `cmd/1pl/interpreter.go`; mirror in `cmd/1pl/interpreter_test.go`.3940Read `references/change-map.md` for a quick change-to-test map and discovery commands.4142## Preserve Core Invariants4344- Preserve deterministic behavior; avoid map-order-dependent logic and hidden runtime variability.45- Avoid introducing nondeterministic dependencies (wall clock, random data, unspecified iteration order) into core engine paths.46- Enforce determinism by construction: if behavior depends on external state (time, randomness, host I/O ordering), redesign the API so inputs are explicit and deterministic.47- Reuse existing exception constructors (`typeError`, `domainError`, `permissionError`, `existenceError`, `resourceError`) and match nearby patterns.48- Preserve stream mode permissions:49 - Keep `SetInput` compatible with `read` and `read_write`.50 - Keep `SetOutput` compatible with `write`, `append`, and `read_write`.51- Preserve filesystem capability checks for write-like modes in `open/3` and `open/4` (`OpenFileFS` path).52- Preserve reset behavior in `ResetEnv()`, including stream ID and variable counter reset.5354## Test Workflow55561. Run focused tests first by area (see `references/change-map.md`).572. Run package-level tests for touched packages.583. Run full CI-parity build and test commands.5960Read `references/test-recipes.md` for concrete command sets.6162## Completion Checklist6364- Add at least one regression test for each behavior fix.65- For determinism-sensitive changes, prove determinism at design level:66 - no hidden entropy in implementation paths;67 - tests assert complete value/order/identity semantics, not partial fields;68 - any non-deterministic source is injected as explicit input and controlled in tests.69- Confirm all touched tests pass locally.70- Confirm full build and race+coverage test command passes.71- Update docs when behavior changes are externally visible, including `README.md` deviations if ISO/constraint boundaries changed.7273---74> Converted and distributed by [TomeVault](https://tomevault.io/claim/axone-protocol) — claim your Tome and manage your conversions.75<!-- tomevault:4.0:skill_md:2026-04-12 -->