Skip to content

Conversation

@GitJuhb
Copy link
Contributor

@GitJuhb GitJuhb commented Jan 10, 2026

Problem

The v2 branch fails to compile when used as a dependency because lib/jido/error.ex uses compile-time struct pattern matching on external packages (jido_signal, jido_action).

error: Jido.Signal.Error.InvalidInputError.__struct__/0 is undefined
lib/jido/error.ex:710:31: Jido.Error.determine_unified_type/1

Root Cause

Patterns like %Jido.Signal.Error.InvalidInputError{} require the struct module to be compiled before the pattern is expanded. When jido is pulled as a hex/git dependency, compilation order isn't guaranteed relative to the external packages.

Key Finding: The modules DO exist in jido_signal 1.1.0 and jido_action 1.0.0. This is NOT a missing module - it's a compile-time vs runtime struct expansion issue.

The v2 branch works fine when developing locally (because the maintainers have jido_signal/jido_action as local path deps), but fails when used as an external dependency.

Fix

Replace %Module.Name{} with %{__struct__: Module.Name} for cross-package structs. This defers struct checking to runtime instead of compile-time, allowing the code to compile before external packages are loaded.

# BEFORE (compile-time struct expansion - breaks cross-package)
defp determine_unified_type(%Jido.Signal.Error.InvalidInputError{}), do: :validation_error

# AFTER (runtime struct check - works cross-package)
defp determine_unified_type(%{__struct__: Jido.Signal.Error.InvalidInputError}), do: :validation_error

Testing

  • Tested compilation as a dependency in AgentTUI project
  • Jido v2 instance starts successfully and agent operations work

🤖 Generated with Claude Code

@mikehostetler
Copy link
Contributor

Thanks!!! I have some changes to push on this today too - it's coming together nicely

@mikehostetler mikehostetler changed the base branch from v2 to main January 15, 2026 22:29
mikehostetler added a commit to GitJuhb/jido that referenced this pull request Jan 16, 2026
…ackage errors

Merges the fix from PR agentjido#99 with main, keeping:
- unified_type/1 function name (matches main)
- %{__struct__: Module} pattern (fixes cross-package compilation)
- Return values from main (:internal, :routing_error vs :internal_server_error, :dispatch_error)
@mikehostetler mikehostetler force-pushed the fix/cross-package-struct-compilation branch from ae100bf to a133b00 Compare January 16, 2026 02:47
@mikehostetler mikehostetler merged commit 510b93c into agentjido:main Jan 16, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants