Spaces:
Sleeping
Sleeping
Bytecode Simplification Plan
Goal
Keep the useful part of bytecode, a deterministic execution stream, but remove the bitpacking and remove the extra semantic layers we built on top of it.
Principles
- One instruction model.
- One execution path.
- One choice metadata source.
- No parallel runtime-plan stack.
- No bitfield archaeology for authors or debuggers.
Target Shape
- Pseudocode remains the authoring input.
- The compiler lowers pseudocode into one explicit instruction IR.
- That IR uses named enums and explicit fields instead of packed bit positions.
- Rust executes that IR directly.
- Packed bytecode exists only as a compatibility export or import format, not as the thing we think in.
What To Remove
- Separate
runtime_planas a second semantic representation. - Duplicate
choice_flagsandchoice_countderivation paths. - Launcher and Rust heuristics that infer interaction state from legacy packed values.
- Any code that needs both the old and new models to understand a single ability.
What To Keep
- The actual opcode sequence ordering.
- The existing Rust handler family that already knows how to resolve effects.
- The parser that turns text into structured ability objects.
- Compatibility conversion for old data until migration is complete.
Implementation Steps
- Revert to the bytecode-only baseline and keep the tree stable.
- Define a single explicit instruction IR with enum-backed fields.
- Make the compiler emit that IR directly.
- Add one serializer that can still emit packed bytecode if needed.
- Make Rust consume the explicit IR first.
- Keep bytecode only as a fallback boundary, not as a parallel architecture.
- Add regression tests for choice-heavy cards before removing compatibility code.
- Delete duplicated semantic or runtime-plan plumbing once parity is proven.
Success Criteria
- A card can be inspected in one place and understood without bit math.
- Pending interactions render from one prompt contract.
- The Rust engine has one normal path for execution.
- Bytecode is an implementation detail again, not a second architecture.
Practical Rule
If a new layer does not remove an old layer, it should not survive long-term. The next simplification should collapse structure, not add another translation pass.