refactor(sdk): externalize template ref detection from CoerceMapForStruct#14
Merged
Merged
Conversation
…ruct
CoerceMapForStruct previously used a hardcoded regex to detect ${...}
template references, which could diverge from the resolver's actual
parsing logic. This refactors the detection into a caller-injected
`isDeferred func(string) bool` predicate so that the coercion layer
stays agnostic of template syntax.
Key changes:
- CoerceMapForStruct and RoundConfigFromMap accept an isDeferred
predicate; nil means no deferred-value removal.
- Export variable.ContainsRef, which reuses refPattern and mirrors
lookup's dot-separated scope.name requirement.
- LLMNode stores isDeferred at build time so SetConfig reuses the
same predicate for both build and execute phases.
- bridge_llm passes nil (script overrides are concrete values).
- Add end-to-end executor tests covering build→resolve→execute→restore
cycle, string-typed board vars, and partial template interpolation.
- Add CoerceMapForStruct tests for malformed refs (${}, ${ }, truncated).
Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CoerceMapForStructandRoundConfigFromMapnow accept anisDeferred func(string) boolpredicate instead of using a hardcoded regex. This eliminates the risk of divergence between the coercion layer and the resolver's actual${scope.name}parsing logic.variable.ContainsRef: a single source of truth for detecting resolvable references, reusingrefPatternand mirroringlookup's dot-separated path requirement.isDeferredonLLMNode: injected at build time viaregister.go, reused bySetConfigat execute time, so both phases handle unresolved template refs consistently.${},${ }, truncated${).Test plan
go build ./...passesgo test ./sdk/...passes (all packages)Made with Cursor