refactor: dedupe launcher, installer, test harness #81

Merged
claudiomaradonna merged 4 commits from refactor-dedup into master 2026-11-21 19:05:47 +01:00
Collaborator

Why

The same maintainers keep the dispatcher, the installer, and the test
suite, and today four pieces of their logic exist in several copies, so
changing one means remembering the others: the installer reaches the
container engine through two paths (direct "$AZK_HOST_ENGINE" calls and
the host library's azk_host_engine), the base and client builds
assemble the same build invocation twice, the operator confirmation is
written three times, and the test harness repeats its result-capture tail
ten times. This change gives each of them one home and keeps the behavior
callers and tests see identical.

What changed

  • Engine calls: the five direct "$AZK_HOST_ENGINE" … invocations in
    install.sh now go through azk_host_engine from lib/azk-host.sh,
    which resolves the engine and runs it with the host environment plus
    LC_ALL=C — the way every other engine call already ran. The recorded
    engine argv stays byte-identical; the pins of the first commit prove
    it, including the --version probe line and environment inheritance.
  • Builds: one _azk_install_build_image LABEL TARGET IMAGE EXTRA…
    in install.sh assembles the build invocation shared by the base and
    the client builds; each caller keeps only its own build-args.
  • Confirmations: _azk_confirm "PROMPT" y|n in bin/azkaban owns
    the prompt read and the yes-parse; the workspace, custom-image
    approval, and shared-image update prompts call it. Prompt texts, the
    per-prompt defaults, and today's treatment of an empty line and a
    closed terminal as no are unchanged; each caller still owns its own
    outcome path.
  • Test harness: _launch_captured and _capture_result in
    tests/helpers.sh hold the EXIT_CODE/STDOUT/STDERR tail that ten
    runners copied; each runner keeps only its own part — the launcher
    symlink, the env wrapper, the stdin file, the pty status file.

How to verify

From a fresh checkout, on the base (01e9109) and on this branch:

  • Engine argv unchanged: make test TESTS='install_pulls install_builds install_engine' asserts the exact recorded argv of the pull, tag,
    version-probe, and build calls, including the full macOS container
    sequence. Same results on both revisions.
  • Engine calls inherit the installer environment:
    make test TESTS=install_engine runs
    test_engine_calls_inherit_the_installer_environment, which reads the
    stub's per-call environment record. Passes on both revisions.
  • Confirmations behave as before:
    make test TESTS='arg_parsing custom_image_approval custom_image_shared auto_pull' runs the accept, decline, empty-line,
    and closed-stdin matrices of all three prompts. Same results on both
    revisions.
  • Harness contract: the full make test covers every runner through the
    suites that use it.

All scenarios were run on the branch tip: the engine suites pass, the
confirmation suites pass (43 tests), and the pins — added before any
code change — passed on the base's code and pass on the tip. The
networked release gate, make test-e2e, was not run: it needs real
rootless Podman and stays outside the project's Verify.

Checks run: the Verify command make lint && .agents/hooks/shellcheck.sh repo && make test passes on 6b5e210 (331 tests, 0 failures).
Change and security reviews ran on the tip with no findings to fix.

Considerations

  • Installer engine calls now receive forced LC_ALL=C, as launcher
    engine calls already did: version and message parsing becomes
    deterministic, with diagnostics text the only thing it can affect.
  • Four duplications are deliberately left: the identical Bash 4.4 gates
    in bin/azkaban and install.sh are bootstrap code that must run
    before any Bash-only syntax and is tested at each entry point
    separately; the podman_args mount-scan loops already share their
    reading in _azk_split_mount; sharing the client build between the
    installer and lib/azk-image.sh would cross a process and a trust
    boundary; and the harness's workspace_key keeps
    azk_host_sha256's logic independent of production code on purpose.
## Why The same maintainers keep the dispatcher, the installer, and the test suite, and today four pieces of their logic exist in several copies, so changing one means remembering the others: the installer reaches the container engine through two paths (direct `"$AZK_HOST_ENGINE"` calls and the host library's `azk_host_engine`), the base and client builds assemble the same `build` invocation twice, the operator confirmation is written three times, and the test harness repeats its result-capture tail ten times. This change gives each of them one home and keeps the behavior callers and tests see identical. ## What changed - **Engine calls**: the five direct `"$AZK_HOST_ENGINE" …` invocations in `install.sh` now go through `azk_host_engine` from `lib/azk-host.sh`, which resolves the engine and runs it with the host environment plus `LC_ALL=C` — the way every other engine call already ran. The recorded engine argv stays byte-identical; the pins of the first commit prove it, including the `--version` probe line and environment inheritance. - **Builds**: one `_azk_install_build_image LABEL TARGET IMAGE EXTRA…` in `install.sh` assembles the `build` invocation shared by the base and the client builds; each caller keeps only its own build-args. - **Confirmations**: `_azk_confirm "PROMPT" y|n` in `bin/azkaban` owns the prompt read and the yes-parse; the workspace, custom-image approval, and shared-image update prompts call it. Prompt texts, the per-prompt defaults, and today's treatment of an empty line and a closed terminal as no are unchanged; each caller still owns its own outcome path. - **Test harness**: `_launch_captured` and `_capture_result` in `tests/helpers.sh` hold the `EXIT_CODE`/`STDOUT`/`STDERR` tail that ten runners copied; each runner keeps only its own part — the launcher symlink, the `env` wrapper, the stdin file, the pty status file. ## How to verify From a fresh checkout, on the base (`01e9109`) and on this branch: - Engine argv unchanged: `make test TESTS='install_pulls install_builds install_engine'` asserts the exact recorded argv of the pull, tag, version-probe, and build calls, including the full macOS `container` sequence. Same results on both revisions. - Engine calls inherit the installer environment: `make test TESTS=install_engine` runs `test_engine_calls_inherit_the_installer_environment`, which reads the stub's per-call environment record. Passes on both revisions. - Confirmations behave as before: `make test TESTS='arg_parsing custom_image_approval custom_image_shared auto_pull'` runs the accept, decline, empty-line, and closed-stdin matrices of all three prompts. Same results on both revisions. - Harness contract: the full `make test` covers every runner through the suites that use it. All scenarios were run on the branch tip: the engine suites pass, the confirmation suites pass (43 tests), and the pins — added before any code change — passed on the base's code and pass on the tip. The networked release gate, `make test-e2e`, was not run: it needs real rootless Podman and stays outside the project's Verify. Checks run: the Verify command `make lint && .agents/hooks/shellcheck.sh repo && make test` passes on `6b5e210` (331 tests, 0 failures). Change and security reviews ran on the tip with no findings to fix. ## Considerations - Installer engine calls now receive forced `LC_ALL=C`, as launcher engine calls already did: version and message parsing becomes deterministic, with diagnostics text the only thing it can affect. - Four duplications are deliberately left: the identical Bash 4.4 gates in `bin/azkaban` and `install.sh` are bootstrap code that must run before any Bash-only syntax and is tested at each entry point separately; the `podman_args` mount-scan loops already share their reading in `_azk_split_mount`; sharing the client build between the installer and `lib/azk-image.sh` would cross a process and a trust boundary; and the harness's `workspace_key` keeps `azk_host_sha256`'s logic independent of production code on purpose.
Record, before reshaping the launcher and installer, what callers see
today on the paths the refactor rewrites: the Linux engine --version
probe call, engine calls inheriting the installer environment, and both
interactive prompts declining on closed stdin with the workspace prompt
answering [Y/n]. All pins pass on the main branch's code.
Route the five direct calls through azk_host_engine, which resolves the
engine command and runs it with the host environment plus LC_ALL=C as
every other engine call does, and assemble the base and client builds in
one _azk_install_build_image so their shared option shape is written
once. The recorded engine argv stays byte-identical.
The workspace, approval, and update prompts shared the same read plus
yes-parse in three copies; the helper owns it now, keeping the exact
prompt texts, the per-prompt defaults, and today's treatment of an empty
line and a closed terminal as no.
The ten copies of the EXIT_CODE/STDOUT/STDERR tail collapse into
_launch_captured for plain runners and _capture_result for subshell
runners of their own; each runner keeps only its own part: the launcher
symlink, the env wrapper, the stdin file, and the pty status file.
claudiomaradonna deleted branch refactor-dedup 2026-11-21 19:05:54 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/azkaban!81
No description provided.