feat(lisp): Normalize hyphenated keys to underscores at tool boundary#706
Conversation
PR Review: Normalize hyphenated keys to underscores at tool boundarySummaryThis PR normalizes hyphenated PTC-Lisp keyword keys (like What's Good
Issues (Must Fix)
Suggestions (Optional)
SecurityNo concerns. Key normalization is a string transformation with no security implications. DocumentationNo updates needed. This is an internal implementation detail that doesn't change the public API semantics - users still define fields with hyphens in PTC-Lisp. VerdictRequest Changes - The code duplication must be addressed before merge. Extract the identical |
PR Review: feat(lisp): Normalize hyphenated keys to underscores at tool boundarySummaryThis PR implements hyphen-to-underscore key normalization at the tool boundary, converting Clojure-style What's Good
Issues (Must Fix)
Suggestions (Optional)
SecurityNo concerns - this is a data transformation change with no security implications. DocumentationMUST FIX: Documentation must be updated to reflect the breaking change from atom keys to string keys. See Issue #3 above for specific files. VerdictRequest Changes - The implementation is correct and well-tested, but the code duplication and missing documentation updates must be addressed before merge. All fixes are mechanical and straightforward. 🤖 Generated with Claude Code |
Auto-Triage Summary
Total: 4 issues found
Context: The initial code duplication issue (normalize_return_keys/1 across 3 files) was successfully fixed by creating the KeyNormalizer module. The latest review identified residual duplication in eval.ex and validator.ex, plus missing documentation updates for the breaking change from atom to string keys. |
PR Review: Normalize hyphenated keys to underscores at tool boundarySummaryThis PR introduces key normalization at the tool boundary, converting Clojure-style hyphenated keywords (e.g., What's Good
Issues (Must Fix)
Suggestions (Optional)
SecurityNo concerns - this is a data transformation at the boundary with no security implications. DocumentationMUST FIX: Documentation examples throughout the guides need updating to reflect the breaking change from atom keys to string keys. See "Issues" section above for specific locations. VerdictRequest Changes - The implementation is solid, but the test bug must be fixed and documentation must be updated before merge. Both issues are mechanical and straightforward to resolve. |
Convert hyphenated PTC-Lisp keywords to underscored string keys at the
tool boundary, following Phoenix controller params conventions. LLMs
write Clojure-style `:was-improved`, Elixir tools receive
`%{"was_improved" => value}`.
Changes:
- eval.ex: Normalize tool argument keys (hyphen -> underscore)
- loop.ex: Normalize return value keys for multi-turn and single-shot
- sub_agent.ex: Normalize return values in run_single_shot mode
- json_mode.ex: Normalize return values in JSON mode
- validator.ex: Normalize field names when validating signatures
This creates consistency with how Elixir typically handles external
data (JSON, params) while allowing LLMs to use idiomatic Clojure-style
hyphenated keywords.
Closes #704
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ation The normalize_return_keys/1 and normalize_key/1 functions were duplicated identically in sub_agent.ex, loop.ex, and json_mode.ex (54 lines total). Extracted to a shared PtcRunner.SubAgent.KeyNormalizer module with proper documentation and doctests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use the centralized KeyNormalizer module instead of duplicating the hyphen-to-underscore conversion logic: - eval.ex: Replace private normalize_key/1 with KeyNormalizer.normalize_key/1 - validator.ex: Replace inline String.replace with KeyNormalizer.normalize_key/1 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
9ac33b5 to
081a39d
Compare
1. Add doctest runner for KeyNormalizer module 2. Update documentation to use string key access pattern: - docs/guides/subagent-getting-started.md - docs/guides/subagent-testing.md - docs/signature-syntax.md - docs/specs/json-output-mode.md The breaking change from atom keys to string keys is now properly reflected in all documentation examples. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: feat(lisp): Normalize hyphenated keys to underscores at tool boundarySummaryThis PR implements key normalization at the tool boundary, converting Clojure-style hyphenated keywords (e.g., What's Good
Issues (Must Fix)None found. Suggestions (Optional)
SecurityNo concerns - this is a string transformation at data boundaries with no security implications. DocumentationAll relevant documentation has been updated to reflect the breaking change from atom keys to string keys. The spec file changes in Spec Change AnalysisThe changes to VerdictApprove - The implementation is correct, well-tested, properly documented, and all previously identified issues (code duplication, missing docs) have been resolved. Ready to merge. 🤖 Generated with Claude Code |
Auto-Triage Summary
Total: 0 issues found
Context: All previously identified issues (code duplication, test bugs, missing documentation updates) have been resolved in subsequent commits. The latest review approved the PR with no issues found. The PR is mergeable and ready for merge. |
Summary
:was-improved, Elixir tools receive%{"was_improved" => value}Changes
eval.ex):stringify_keynow normalizes hyphens to underscoresloop.ex): Addednormalize_return_keysfor multi-turn and single-shot modessub_agent.ex): Return values normalized inrun_single_shotjson_mode.ex): Return values normalized inbuild_success_stepvalidator.ex): Field names normalized when looking up fieldsTest Plan
mix precommit)Breaking Change
Return values from SubAgent now use string keys instead of atom keys:
Closes #704
🤖 Generated with Claude Code
Fix Automation State
Fix attempts: 2/3