Repository navigation
Description
What's the problem
Child of #4223 (split: this issue bundled the .env and quadlet renderers plus the first Go module). The env-render row of the per-piece launcher (#4214, lib/pithead/00a-impl-launcher.sh) has no Go side: develop-v2.1.0 contains no go/ tree at all. .env byte building is Bash string work: render_env() (lib/pithead/33-render-env.sh, a fixed-order ~114-key heredoc, every value through dotenv_render_value) plus compose project identity compose_project_name() (lib/pithead/19-small-utilities.sh:63-85). Drift in this quoting changes what a running appliance applies.
What it impacts
Every apply and render on DIY and appliance paths; every stack boots from the rendered .env. Compose project identity decides which compose project every apply touches.
How I found it
Local-session split of #4223 after reading develop, the go-port/3811 branch and docs/dev/go-port/selection.md. go-port/3811 carries go/internal/config/env.go (a pure RenderEnv(pairs) serializer) and compose_project.go with unit tests, plus Bash wiring shapes (lib/pithead/33a-go-env-render.sh, 19c-go-compose-project.sh). develop's key list has since drifted (adds DASHBOARD_MODE, PITHEAD_DIAG_CONTAINERS, P2POOL_BACKUP_ARGS_B64, TELEGRAM_LEVEL, the conditional PAYOUT_NODE_REMOTE/PAYOUT_NODE_PROXY tail), so wiring is written against develop, not copied.
How important is it
High for the Go-port series: it is the first go/ module on develop and lands the CI build/parity plumbing every later piece reuses (#4227 requires each piece to preserve its harvest on develop). Shipped behavior stays Bash-default (Medium): the table default flips only in a release where all criteria hold.
Acceptance criteria
- A
go/module on develop buildsgo/bin/pitheadbeside the generated entry point; the binary serves helper mode selected byPITHEAD_GO_HELPER(NUL-delimited stdin pairs in, rendered bytes on stdout, exit 125 whenever it cannot safely render so Bash does it unchanged) — the contract the go-portconfig-env/config-compose-projecthelpers use, including the trailing producer-rc field and terminal.byte. RenderEnvandComposeProjectNameare harvested from origin/go-port/3811go/internal/config/env.goandcompose_project.gowith their unit tests; nothing else from that package (value computation stays Bash).render_env()andcompose_project_name()consult_pithead_impl_selected env-render; the pair feed reproduces develop's current heredoc key order exactly, including the PAYOUT_NODE tail keys only when PAYOUT_NODE_REMOTE=true. Bash remains the sole file writer and lock holder: same target paths, umask 077, chmod 600, and the tari-wallet-secret.env sidecar stays Bash. Any 125/nonzero/absent-binary path renders via the existing Bash heredoc unchanged.- A NEW parity file (Go test, build tag
parity, e.g. go/internal/config/env_parity_test.go + a new tests/go-parity/ oracle sourcing develop's live Bash) proves .env bytes and project identity equal between Go and Bash over the fixture set and every tier-covered config, with cases hitting every quoting trigger ($, ", ', \, leading/trailing space, space-then-#, tab/LF/CR), duplicate-key rejection, and unsupported-value fallback (Go 125 -> Bash bytes still identical to the no-selection run). - A CI Go workflow builds, vets, runs go unit tests and the parity tag; the shell.yml Go leg builds go/bin/pithead so
PITHEAD_TEST_IMPL-all-pieces actually reaches the Go side, and a test fails if that leg silently falls back. - Existing render and apply suites (tests/stack render suites, integration selftests) pass unchanged in both modes;
00a-impl-launcher.shand selection.md keep env-render default bash. - Go median wall time not above Bash on the render and apply dry paths; the measurement (commands, run count, medians) is pasted in the PR.
Possible solutions
Harvest the two files verbatim where they apply; write fresh wiring from develop's render_env shape (do not port go-port's 33a wholesale — its key list is stale). Keep go-port's 125-guard idiom (locale, file writability, binary checks). Run security-reviewer: the helper transports wallet keys/passwords/tokens on stdin/stdout only — never argv, never logs.
Parent: #4223
Worker brief: Test tier: tiers 1-3 green (new go workflow + shell matrix both legs) then tier4-e2e targeted (config rendering that compose must accept).
Objective: render the compose .env and compute compose project identity in Go under _pithead_impl_selected env-render; Bash stays the file writer and lock holder. One objective — do NOT touch lib/pithead/36-quadlet-units.sh (that is the sibling chunk 6b, which builds on this one's module and helper plumbing).
Start from: docs/dev/go-port/selection.md (Go-side contract + testing-both-modes), lib/pithead/00a-impl-launcher.sh (_pithead_impl_selected), lib/pithead/33-render-env.sh (the fixed 114-key heredoc is the ONLY source of truth for key order — develop drifted from go-port; also the conditional PAYOUT_NODE tail and the tari-wallet sidecar that stays Bash), lib/pithead/19-small-utilities.sh (dotenv_render_value, compose_project_name). Harvest exactly go/internal/config/env.go + compose_project.go and their _test.go files from origin/go-port/3811 (read with git show origin/go-port/3811:<path>; do not merge the branch); add go/go.mod, cmd/pithead/main.go, internal/cli dispatch with PITHEAD_GO_HELPER=config-env and =config-compose-project modeled on go-port's go/internal/cli/config_env.go and config_compose_project.go and its Bash helpers lib/pithead/33a-go-env-render.sh / 19c-go-compose-project.sh (fresh call sites, develop's key list). Exit 125 = Go declines, Bash renders unchanged; never let a Go failure change bytes.
New parity file with build tag parity + a tests/go-parity oracle script driving develop's Bash; compare bytes over fixtures (os/quadlet/fixture.env style env inputs, tests/stack dotenv fixtures) and tier-covered configs; include every quoting trigger and duplicate-key/unsupported fallback cases. Add Makefile build/test/parity targets and a GitHub workflow that runs them; make the shell.yml Go leg build go/bin/pithead and assert it is reached. Existing suites pass unchanged in both modes. Keep the table default bash (flip is release-time). Measure render/apply dry-path median wall time bash vs Go (no Docker on this Mac; dry paths only) and paste it in the PR.
Rules: no comments/docstrings in code; every behavior gets a test that fails without it; docs/dev/go-port/selection.md updated where this changes described behavior; ponytail pass, then verifier AND security-reviewer subagents in the foreground (secrets cross the Bash/Go boundary via stdin/stdout — check no argv leak, no logging, file modes unchanged). Draft PR off origin/develop-v2.1.0, three-section body, Part of #4223. Tier-4 submit only via bin/bench-submit with --base develop-v2.1.0.
Activity