Skip to content

fix: native module resolution breaks validation loop for ha:pdf#111

Merged
simongdavies merged 2 commits intohyperlight-dev:mainfrom
simongdavies:fix-native-module-validation
May 7, 2026
Merged

fix: native module resolution breaks validation loop for ha:pdf#111
simongdavies merged 2 commits intohyperlight-dev:mainfrom
simongdavies:fix-native-module-validation

Conversation

@simongdavies
Copy link
Copy Markdown
Member

The module resolution loop checked only Object.keys(newSources) to decide whether to continue resolving. Native modules (like ha:ziplib) have no .js source — only module.json metadata — so the loop broke early with valid=false and an empty errors array, producing the cryptic 'Validation failed: •' message.

Root cause: ha:pdf imports ha:ziplib (native). The resolution loop loaded ziplib.json but not ziplib.js (doesn't exist). Since newSources was empty, it broke out of the loop before passing the JSON metadata to the validator. The validator then couldn't confirm ziplib was resolved, returning valid=false with no errors.

Fix: check all three sources (newSources, newModuleJsons, newDtsSources) before deciding nothing was found. This allows native module metadata to flow through and lets the validator recognise them as resolved.

Applied to both register_handler and register_module validation loops.

The module resolution loop checked only Object.keys(newSources) to
decide whether to continue resolving. Native modules (like ha:ziplib)
have no .js source — only module.json metadata — so the loop broke
early with valid=false and an empty errors array, producing the
cryptic 'Validation failed: •' message.

Root cause: ha:pdf imports ha:ziplib (native). The resolution loop
loaded ziplib.json but not ziplib.js (doesn't exist). Since
newSources was empty, it broke out of the loop before passing the
JSON metadata to the validator. The validator then couldn't confirm
ziplib was resolved, returning valid=false with no errors.

Fix: check all three sources (newSources, newModuleJsons, newDtsSources)
before deciding nothing was found. This allows native module metadata
to flow through and lets the validator recognise them as resolved.

Applied to both register_handler and register_module validation loops.

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 7, 2026 12:41
@simongdavies simongdavies added the bug Something isn't working label May 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an early-exit bug in the handler/module validation dependency-resolution loop so that native modules (which may only have module.json / .d.ts and no .js) are still treated as “newly resolved” and passed into the analysis guest for deep validation.

Changes:

  • Update the “no progress” detection in the validation loop to consider newModuleJsons and newDtsSources in addition to newSources.
  • Apply the same “check all three” condition in both the shared validateHandlerCode() path and the register_handler tool’s local validation loop.

Comment thread src/agent/index.ts Outdated
Comment thread src/agent/index.ts
…wording

- Changed 'no ha:/host: prefix' to 'missing ha: or host: prefix'
  to avoid confusion with the slash character
- Note: registerModuleImpl loop doesn't have the early-break pattern
  so it was never affected by the bug (commit message corrected)

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
@simongdavies simongdavies merged commit 5f9f20e into hyperlight-dev:main May 7, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants