Fair question — the rendering engine is in internal/template (~2,800 lines) and the YAML content does live in the template library's skeletons. What makes manifests complex isn't rendering; it's everything around it. Reading through the code, the ~2,400 lines in internal/deploy/manifests*.go break down like this:
1. One command, three verbs, two destinations (~600 lines). inspect, render, and create share a pipeline but with different policies: render buffers the entire stream before touching stdout (a partial render must never be piped to kubectl), create classifies every file (create/identical/conflict) and refuses to ever replace an existing file, inspect renders nothing at all. And there are two modes — GitOps (stage repo-relative, push a review branch) and local (stage flat, run kustomize build) — each with its own facts resolution, file rules, and fixture handling (manifests_local.go, 257 lines).
2. Deriving the model the templates consume (~365 lines, manifests_model.go). Raw topology is unsuitable for direct rendering: its json.RawMessage fields have unstable shapes, and Go map iteration is non-deterministic while a re-render must be byte-identical. So the CLI joins topology against scaffold records (two conventions — directory basename and values.appId), derives workloads from block kinds (extractor → CronJob, else Deployment), computes pub/sub scopes as app-ids, and sorts everything. Templates can't do this — it requires reading files the template never sees.
3. Trust boundaries the engine can't own. The renderer is deliberately dumb: it templates paths but doesn't iterate them, so overlays/{{ .env }} is rendered once per environment and mergeRendered enforces that everything outside overlays/ came out byte-identical across passes. That check, plus path-segment validation on names coming from a build the CLI doesn't own (topology), a repository it doesn't control (GitOps), and user flags — all has to live in the caller. Same for the protected-file classification: existing overlay files may hold pinned digests or human edits, so nothing is ever silently overwritten.
4. Safe publishing (~200 lines). Fresh review branch, scoped git add of exactly the staged paths, asserting the staged/committed tree is exactly those paths (the checkout is shared cache), then restoring the default branch — plus the trap of scanning placeholders while the branch is still checked out.
5. Host discovery and domain inference (~250 lines). Finding which system host to read (multi-system workspaces), running its graph verb (a dotnet build), inferring the domain from the GitOps tree vs. the workspace layout, and producing decent errors when it's ambiguous.