2code icon indicating copy to clipboard operation
2code copied to clipboard

Task 3: Bundle the pinned Herdr sidecar

Open AkaraChen opened this issue 2 months ago • 0 comments

Summary

Make the pinned Herdr v0.9.0 executable available in development and packaged 2code builds, as required by parent plan #394. Acquisition must be reproducible and checksum-verified. This task packages and discovers the binary; it must not start a Herdr server, switch the default runtime, or own terminals or worktrees.

Reuse the Task 1 pin in docs/herdr-integration.md and src-tauri/crates/infra/tests/fixtures/herdr/pin.json. Do not introduce a second version pin or download latest.

Dependencies: Parent plan #394. Prerequisite: #395 (Task 1, accepted on issue-395-herdr-integration-contract). Checkout base: #402 (Task 2, accepted on task-2-runtime-boundary). Open contract-gap issues #396–#401 and Task 2 gap #403 do not block this task.

Work to complete

  1. Checksum-verified acquisition

    • Add a script that downloads the v0.9.0 GitHub Release assets listed in pin.json, verifies SHA-256 (GitHub asset digests; no detached GPG/cosign exists for this tag), and places executables where Tauri expects sidecars (src-tauri/binaries/, already gitignored).
    • Map Herdr asset names onto Tauri sidecar filenames for the supported triples: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, aarch64-apple-darwin, x86_64-apple-darwin, x86_64-pc-windows-msvc. The Linux binaries are static-pie ELFs; Windows is a zip whose digest is of the archive, then extract herdr.exe.
    • There is no Windows ARM64 stable asset; do not invent one. Fail closed on checksum mismatch or an unknown triple.
    • Reuse the Task 1 cache layout when present (${XDG_CACHE_HOME:-$HOME/.cache}/2code/herdr/v0.9.0) so developers and CI do not re-download blindly. Never commit binaries.
    • Wire the fetch into tauri dev / tauri build (see scripts/tauri-before.mjs) and into .github/workflows/release.yml and .github/workflows/tauri-smoke.yml so externalBin cannot break existing packaged or smoke builds.
  2. Tauri sidecar configuration and license

    • Register the pinned binary in src-tauri/tauri.conf.json bundle.externalBin. Update src-tauri/build.rs only if sidecar path/target wiring requires it.
    • Add the minimum shell/sidecar capability in src-tauri/capabilities/default.json if the chosen discovery API needs it. Do not grant a frontend-spawnable Herdr server. Do not auto-start Herdr on app launch.
    • Vendor Apache-2.0 license/NOTICE text for Herdr v0.9.0 next to the app (not the binary). Record the pin (version, tag, commit b99002ac99b09e00b4ca692436cb15a6b0d676f1, asset URLs, checksums) so packaging does not depend on the website.
    • Sidecar packaging must not tie Herdr server lifetime to the GUI process. externalBin is for locating and bundling the file. Do not spawn herdr server via Tauri's sidecar Command / process manager. --version as a short-lived child is allowed. Task 4 will spawn a detached server from the resolved path.
  3. Discovery and version reporting

    • Add a Rust helper that resolves the bundled or fetched executable for the current target (dev: src-tauri/binaries/; packaged: Tauri sidecar/resource path) and runs herdr --version, expecting herdr 0.9.0.
    • Keep this helper out of the Local PTY path and out of HerdrStubAdapter. Do not replace the stub, change RuntimeSelector default, or talk to a Herdr socket.
    • Verify discovery against a packaged layout (a real Linux tauri build bundle or an equivalent fixture). Inspecting the bundle for the sidecar and running --version is enough; do not add a new Selenium suite.
    • If an IPC command is added for version/path reporting, it must be read-only, must not start a server, and requires bun run typegen (never hand-edit src/generated/). Prefer no frontend UI.
  4. Prove packaging without changing runtime behavior

    • Tests: pin mapping and checksum failure; Windows zip extracts herdr.exe after the zip digest matches; resolved sidecar --version is herdr 0.9.0 when the binary is present; app startup still defaults to Local and does not spawn herdr server.
    • Missing binary: skip optional live checks unless an explicit required flag is set. Production/dev/package paths that declare externalBin must fetch first rather than skip.
    • Existing PTY and Task 2 routing tests keep passing.

Likely files and directories

  • New: scripts/ fetch helper (or equivalent under src-tauri/) — download, verify, rename/extract into src-tauri/binaries/.
  • New: src-tauri/crates/infra/src/herdr/ (or similar) — path discovery and --version reporting; no socket client.
  • New: Herdr Apache-2.0 license/NOTICE text for the bundled third-party binary.
  • Update: src-tauri/tauri.conf.json — bundle.externalBin.
  • Update: src-tauri/capabilities/default.json — sidecar permission only if required.
  • Update if needed: src-tauri/build.rs, scripts/tauri-before.mjs, src-tauri/crates/infra/src/lib.rs.
  • Update: .github/workflows/release.yml, .github/workflows/tauri-smoke.yml — fetch the host sidecar before packaging.
  • Reuse, do not duplicate: src-tauri/crates/infra/tests/fixtures/herdr/pin.json, docs/herdr-integration.md.
  • Do not rewrite: src-tauri/crates/service/src/pty.rs, src-tauri/crates/infra/src/pty.rs, Task 2 runtime routing, frontend terminal code.

Estimated changes: 150–300 lines total, additions plus deletions, including tests and license text; excluding generated files, lockfile churn, and downloaded binaries. Material scope growth should become a separate issue.

Acceptance criteria

  • [ ] Development and packaged builds can resolve a checksum-verified Herdr v0.9.0 sidecar for each supported triple in pin.json; acquisition never uses latest.
  • [ ] SHA-256 mismatch refuses to install the binary. Windows uses the zip digest, then herdr.exe. Windows ARM64 is explicitly unsupported.
  • [ ] Binaries stay gitignored; Apache-2.0 license/NOTICE for Herdr v0.9.0 is tracked in source.
  • [ ] Tauri externalBin (and capabilities if needed) register the sidecar without auto-starting a server and without making Herdr a child of the GUI process tree.
  • [ ] A discovery helper reports herdr 0.9.0 from the resolved executable, including a packaged-app or equivalent bundle-layout check.
  • [ ] tauri dev / tauri build / Linux smoke / release packaging fetch the sidecar so externalBin does not break existing CI.
  • [ ] Default runtime remains Local. Existing PTY/agent path still works. The Herdr stub stays fail-closed. No session or worktree is owned by both backends.
  • [ ] No herdr server is started; no JSON socket client or terminal-session attach is implemented.
  • [ ] cargo test --workspace from src-tauri (or cargo test --workspace --exclude code where GTK is unavailable). If frontend or scripts in lint scope change: bun run lint:check, bun run typecheck, bun run test. IPC changes use bun run typegen; do not edit src/generated/ by hand.

Out of scope

  • Server discovery, namespace resolution, detached startup, readiness timeouts, or GUI-exit lifetime (Task 4).
  • Socket request client, snapshot sync, DB mapping, profile adoption, terminal create/attach, xterm transport, or agent-state from Herdr (Tasks 5–13).
  • User-facing runtime health UI or making Herdr the default (Tasks 18/21).
  • Closing or implementing contract-gap issues #396–#401, line-count tracker #400, or Task 2 gap #403.
  • Removing the local PTY runtime or agent detector.
  • Changing frontend terminal rendering, restoration, or detection.
  • Remote Herdr operation.
  • Re-signing or notarizing the Herdr binary itself; app signing/notarization stays as it is in release.yml.

AkaraChen avatar Sep 15 '26 03:09 AkaraChen