prometeu-runtime/docs/specs/pbs/files/PRs para Junie.md
Nilton Constantino 603c8e7862
pr 21
2026-01-29 17:16:01 +00:00

2.0 KiB

PR-22 — Make Allocation Shape Explicit in Core IR

Goal

Stop implicit / guessed heap layouts.

Required Changes

  • Replace any shape-less Alloc with:
Alloc { ty: TypeId, slots: u32 }

Rules:

  • TypeId comes from frontend type checking
  • slots is derived deterministically (struct fields / array size)

Tests

  • Allocating storage struct emits correct slots
  • Allocating array emits correct slots

PR-23 — Eliminate Invalid Call Fallbacks

Goal

Prevent invalid bytecode generation.

Required Changes

  • Remove all fallbacks to FunctionId(0) or equivalent

  • On unresolved symbols during lowering:

    • Emit canonical diagnostic (E_RESOLVE_UNDEFINED or E_LOWER_UNSUPPORTED)
    • Abort lowering

Tests

  • PBS program calling missing function → compile error
  • No Core IR or VM IR emitted

PR-24 — Validate Contract Calls in Frontend (Arity + Types)

Goal

Move contract validation to compile time.

Required Changes

  • During PBS type checking:

    • Validate argument count against contract signature
    • Validate argument types
  • Lower only validated calls to HostCall

Tests

  • Wrong arity → E_TYPE_MISMATCH
  • Correct call lowers to Core IR HostCall

PR-25 — Core IR Invariants Test Suite

Goal

Lock in correct semantics before touching the VM.

Required Invariants

  • Every Begin* has a matching End*
  • Gate passed to Begin* is available at End*
  • No storage writes without BeginMutate
  • No silent fallbacks

Tests

  • Property-style tests or golden IR assertions

STOP POINT

After PR-25:

  • Core IR correctly represents PBS HIP semantics
  • Lowering is deterministic and safe
  • VM is still unchanged

Only after this point may VM PRs begin.

Any VM work before this is a hard rejection.


Instruction to Junie

If any rule in this document is unclear:

  • Stop
  • Add a failing test
  • Document the ambiguity

Do not invent behavior.

This document is binding.