Skip to content

Phase 5: Context normalization options#325

Merged
smn merged 7 commits intodevelopfrom
smn/phase-5-context-normalisation
Apr 19, 2026
Merged

Phase 5: Context normalization options#325
smn merged 7 commits intodevelopfrom
smn/phase-5-context-normalisation

Conversation

@smn
Copy link
Copy Markdown
Contributor

@smn smn commented Apr 4, 2026

Summary

  • Add lowercase_keys and coerce_strings options to Context.new/2
  • Add case-insensitive variable lookup in evaluator
  • skip_context_evaluation? kept as backwards-compatible alias

Depends on #324

Details

Context options: lowercase_keys: false preserves original key casing (atom keys still stringified). coerce_strings: false preserves all string values as-is. Default behavior (both true) unchanged. Options pass through build/2.

Case-insensitive lookup: Eval.case_insensitive_get/2 tries exact match first (fast path), falls back to case-insensitive key scan. Enables lowercase_keys: false without breaking expressions — the parser already lowercases variable names in the AST, so @firstname resolves against a "FirstName" key.

Engage audit: Engage already uses lowercase string keys in context maps. No engage changes needed — options are opt-in for consumers with case-sensitive external data.

Test plan

  • 18 new context tests (options, case-insensitive lookup, combined options, build passthrough)
  • Expression: 558 doctests + 320 tests, 0 failures
  • Engage: 301 tests, 0 failures

🤖 Generated with Claude Code

@smn smn force-pushed the smn/phase-4-parser-improvements branch from f9c2c7c to 5f80dc2 Compare April 4, 2026 20:26
@smn smn force-pushed the smn/phase-5-context-normalisation branch from 0d33c92 to 2987227 Compare April 4, 2026 20:26
santiagocardo
santiagocardo previously approved these changes Apr 17, 2026
Copy link
Copy Markdown
Contributor

@santiagocardo santiagocardo left a comment

Choose a reason for hiding this comment

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

Super nice 🔥

Comment thread test/expression/context_test.exs
@smn
Copy link
Copy Markdown
Contributor Author

smn commented Apr 17, 2026

Will look at merging this later. The earlier PRs don't seem to have merged into develop for some reason

smn and others added 5 commits April 18, 2026 12:40
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@smn smn force-pushed the smn/phase-5-context-normalisation branch from 2987227 to 1b8b8d2 Compare April 18, 2026 10:40
@smn smn changed the base branch from smn/phase-4-parser-improvements to develop April 18, 2026 10:44
@smn smn dismissed santiagocardo’s stale review April 18, 2026 10:44

The base branch was changed.

@smn smn requested a review from santiagocardo April 18, 2026 10:44
@smn
Copy link
Copy Markdown
Contributor Author

smn commented Apr 18, 2026

Sorry @santiagocardo this now has PRs 2, 3, and 4 merged in because somehow I managed to screw up the PR chain. Apologies. You already reviewed & approved this earlier so hoping you can still follow along.

Copy link
Copy Markdown
Contributor

@santiagocardo santiagocardo left a comment

Choose a reason for hiding this comment

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

LGTM!

@smn smn merged commit 934e738 into develop Apr 19, 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.

2 participants