Skip to content

refactor(sdk): externalize template ref detection from CoerceMapForStruct#14

Merged
lIang70 merged 1 commit into
mainfrom
refactor/externalize-template-ref-detection
Apr 16, 2026
Merged

refactor(sdk): externalize template ref detection from CoerceMapForStruct#14
lIang70 merged 1 commit into
mainfrom
refactor/externalize-template-ref-detection

Conversation

@lIang70

@lIang70 lIang70 commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Externalize template ref detection: CoerceMapForStruct and RoundConfigFromMap now accept an isDeferred func(string) bool predicate 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.
  • Export variable.ContainsRef: a single source of truth for detecting resolvable references, reusing refPattern and mirroring lookup's dot-separated path requirement.
  • Store isDeferred on LLMNode: injected at build time via register.go, reused by SetConfig at execute time, so both phases handle unresolved template refs consistently.
  • Add comprehensive test coverage: end-to-end executor tests (build → resolve → execute → restore), string-typed board vars, partial template interpolation, and malformed ref edge cases (${}, ${ }, truncated ${).

Test plan

  • go build ./... passes
  • go test ./sdk/... passes (all packages)
  • New tests cover: template ref build+execute cycle, string numeric board vars, partial refs, malformed refs kept, config restoration after execution

Made with Cursor

…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
@lIang70
lIang70 merged commit a1e0a9b into main Apr 16, 2026
8 checks passed
@lIang70
lIang70 deleted the refactor/externalize-template-ref-detection branch April 16, 2026 07:59
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