fix(validator): load_primitive_meta called twice for same primitive #61

Closed
opened 2026-05-25 15:14:08 +02:00 by michael · 0 comments
Owner

Problem

core/validator/capabilities.lua calls load_primitive_meta (which calls
pcall(require, id)) twice for the same primitive when both checks run:

function M.check_primitive(primitive_id, modules_dir)
  local mod, err = load_primitive_meta(primitive_id, modules_dir)
  ...

function M.check_capabilities(primitive_id, modules_dir, policy)
  local mod, err = load_primitive_meta(primitive_id, modules_dir)
  ...

The module is loaded twice unnecessarily.

Fix

Let the caller load the module once and pass it to both functions,
or combine both checks into a single function that loads once.

Acceptance criteria

  • Primitive module loaded only once per validation run
  • Both checks (api_version + capabilities) still performed
## Problem `core/validator/capabilities.lua` calls `load_primitive_meta` (which calls `pcall(require, id)`) twice for the same primitive when both checks run: ```lua function M.check_primitive(primitive_id, modules_dir) local mod, err = load_primitive_meta(primitive_id, modules_dir) ... function M.check_capabilities(primitive_id, modules_dir, policy) local mod, err = load_primitive_meta(primitive_id, modules_dir) ... ``` The module is loaded twice unnecessarily. ## Fix Let the caller load the module once and pass it to both functions, or combine both checks into a single function that loads once. ## Acceptance criteria - [ ] Primitive module loaded only once per validation run - [ ] Both checks (api_version + capabilities) still performed
michael added this to the Basic Version milestone 2026-05-30 16:05:00 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/fragjan#61
No description provided.