Skip to content

refactor: build the pod script once behind an internal _plan seam#38

Merged
lesnik512 merged 1 commit into
mainfrom
refactor/one-script-plan
Jul 12, 2026
Merged

refactor: build the pod script once behind an internal _plan seam#38
lesnik512 merged 1 commit into
mainfrom
refactor/one-script-plan

Conversation

@lesnik512

Copy link
Copy Markdown
Member

emit_script (renders the pod script) and referenced_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) -> PlannedScript that does the single traversal; both public functions become thin projections of .script and .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.py is 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

  • New internal _plan walks the closure once: each service's _run_tokens and pod_create_flags render into lines and have their _Expand variables collected in the same pass.
  • PlannedScript(script, variables) dataclass; emit_script/referenced_variables keep their exact signatures as thin projections. cli.py and all tests unchanged.
  • Pod-name validation stays in emit_script, so referenced_variables keeps its current no-validation behavior.
  • Defers the store-internal render/vars split to planning/deferred.md.

Not in scope

Per ADR 2026-07-10 this is an emit-internal seam, not the public validate → emit seam — no typed compose model.

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.
@lesnik512 lesnik512 merged commit 8d4ebf6 into main Jul 12, 2026
6 checks passed
@lesnik512 lesnik512 deleted the refactor/one-script-plan branch July 12, 2026 18:23
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