refactor: build the pod script once behind an internal _plan seam#38
Merged
Conversation
emit_script and referenced_variables independently recomputed the closure and walked the same token sources, kept in agreement only by discipline. Introduce a single _plan(compose, options) -> PlannedScript traversal that renders each _run_tokens/pod_create_flags source once and collects its _Expand variables in the same pass; emit_script and referenced_variables become thin projections of .script and .variables. Behavior-preserving: the emitted script and the referenced-variable list are byte/element-identical. The pod-name guard stays in emit_script so referenced_variables keeps its no-validation behavior. Defers the store-internal render/vars split (planning/deferred.md). See planning/changes/2026-07-12.03-one-script-plan.md.
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.
emit_script(renders the pod script) andreferenced_variables(collects the$VARs the script expands at run time) independently recomputed the dependency closure and walked the same token sources, kept in agreement only by discipline. This introduces an internal_plan(compose, options) -> PlannedScriptthat does the single traversal; both public functions become thin projections of.scriptand.variables, so they cannot drift.Behavior-preserving: the emitted script is byte-identical and the referenced-variable list element-identical (verified by a before/after golden on a secrets+configs compose). 100% line coverage;
emit.pyis also 100% branch. No active drift existed today — this is a locality/fragility fix.Rationale and design forks:
planning/changes/2026-07-12.03-one-script-plan.md.What changed
_planwalks the closure once: each service's_run_tokensandpod_create_flagsrender into lines and have their_Expandvariables collected in the same pass.PlannedScript(script, variables)dataclass;emit_script/referenced_variableskeep their exact signatures as thin projections. cli.py and all tests unchanged.emit_script, soreferenced_variableskeeps its current no-validation behavior.planning/deferred.md.Not in scope
Per ADR 2026-07-10 this is an emit-internal seam, not the public
validate → emitseam — no typed compose model.