Skip to content

chore: add dialyxir#36

Merged
joshrotenberg merged 2 commits intomainfrom
chore/add-dialyxir
Apr 10, 2026
Merged

chore: add dialyxir#36
joshrotenberg merged 2 commits intomainfrom
chore/add-dialyxir

Conversation

@joshrotenberg
Copy link
Copy Markdown
Collaborator

Summary

  • Add dialyxir dependency for static type analysis
  • Add dialyzer config to mix.exs with OTP-versioned PLT path
  • Add dialyzer step to CI workflow with PLT caching

Test plan

  • mix compile --warnings-as-errors passes
  • mix dialyzer completes
  • CI passes all steps

Dialyzer (newly enabled on this branch) flagged Session.stream/3
as invalid_contract: the function was storing a make_ref() in the
`session_id` field, which is typed as `String.t() | nil`.

Beyond the type mismatch, the underlying multi-turn-via-stream
mechanism was broken in three ways:

1. The reference placeholder meant the caller's returned session
   had a non-binary session_id, so any follow-up Session.send/3
   would fail the `when is_binary(sid)` guard in execute_turn.
2. maybe_capture_session_id/3 sent {ref, :session_id, sid}
   messages to the parent process but nothing ever received them.
3. It looked up "session_id" in event data, but Codex 0.119+
   emits the thread identifier as "thread_id", not "session_id",
   so even if the capture wired up correctly it would see nil.

The function is untested and the chain `Session.stream -> Session.send`
could never have worked. Rather than rebuilding the capture
machinery, return the session unchanged and document that
`stream/3` does not thread session_id — callers who need
multi-turn continuity should use `send/3`, which runs the turn
synchronously and updates session_id from the final events.

Removes the now-unused maybe_capture_session_id/3 helper.

Note: Session.send/3 has a related (but separate) bug where
`extract_session_id` also looks for "session_id" instead of
"thread_id", which means multi-turn via Session.send is silently
broken against Codex 0.119+. That is a runtime bug, not a
dialyzer issue, and will be fixed in a follow-up.
@joshrotenberg joshrotenberg merged commit 6b90dab into main Apr 10, 2026
2 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.

1 participant