Export model: unify template-source resolution behind resolve-template-source#52
Merged
Merged
Conversation
…e-source
cljs_project (view-context tpl-child-sub-aliases + core-group-body)
and vanilla_js/codegen (template-iteration-expr) each ran the same
three-way cond — source-sub > source-field-owner > stateful-host
auto-fallback — to decide where a template instance's records come
from. Three plugins, three branches, one fact about the document.
Move the resolution into bareforge.export.model/resolve-template-source.
It returns a tagged map (`{:kind :source-sub | :source-field |
:auto-host …}`) and each call site switches on `:kind` to format the
target-specific sub-ref string. The three sites lose ~50 lines of
duplicated logic; both plugins gain a hardened `:auto-host` branch
in core-group-body (was `:else "::!no-source-for-template"` before,
now matches the demo-store auto-host pattern correctly).
Five new tests pin the precedence (source-sub wins over field /
auto-host), the owner-resolution path, the no-owner / no-host nil
cases, and the demo-store cart-item auto-host fallback.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Follow-up to #51 and the final piece of the audit's item 6. Three places — `cljs_project`'s `view-context` (template-instance require aliases) + `core-group-body` (root-level template iteration), and `vanilla_js/codegen`'s `template-iteration-expr` — each ran the same three-way `cond` to decide where a template instance's records come from:
Three plugins, three branches, one fact about the document. Lift it into `bareforge.export.model/resolve-template-source`, which returns a tagged map: `{:kind :source-sub :sub …}` / `{:kind :source-field :owner-ns … :field …}` / `{:kind :auto-host :owner-ns … :field-name …}`. Each call site now `case`s on `:kind` to format its target-specific sub-ref string.
Behaviour deltas
Test plan
Item 6 status
With this merged, audit item 6 ("plugins re-derive facts the model should own") is done — both plugins now consume `action-target-of-group-ns`, `resolve-explicit-field-owners`, `find-sub-groups`'s carried source-* fields, and `resolve-template-source` instead of redoing the math per plugin.
🤖 Generated with Claude Code