Skip to content

fix(build): n8 build always builds the nemesis8 container#98

Merged
kordless merged 2 commits into
mainfrom
fix/build-resolve-and-fetch
Jul 21, 2026
Merged

fix(build): n8 build always builds the nemesis8 container#98
kordless merged 2 commits into
mainfrom
fix/build-resolve-and-fetch

Conversation

@kordless

Copy link
Copy Markdown
Contributor

Problem

Two failure modes let n8 build build the wrong thing — or nothing:

  1. cwd hijack. project_dir_fn() treated any Dockerfile in the current directory as the nemesis8 source. Running n8 build (or triggering an auto-build) from a sibling repo that ships a Dockerfile (e.g. skiff) compiled that project and stamped it nemesis8:latest (DEFAULT_IMAGE is fixed), silently clobbering the real agent image.

  2. Installed users have no repo/Dockerfile. The fetch path (~/.nemesis8/project) shallow-cloned main via git, which (a) requires git on the user's machine and (b) floats to main instead of the tag matching the installed binary — so the built container could drift out of sync with the binary.

Fix

  • cwd guard (is_nemesis8_dockerfile): the cwd Dockerfile is trusted only if it carries a nemesis8 build marker (nemesis8-base / nemesis8-entry). A foreign Dockerfile is ignored with a warning, and resolution falls through to the real nemesis8 source.
  • Versioned, git-free fetch: download_build_files now downloads the GitHub source tarball for this binary's version (v{CARGO_PKG_VERSION}) over HTTPS (reqwest::blocking, already used in entry.rs) and unpacks it with flate2 + tar — no git required. A shallow git clone of the tag remains a fallback. The context is cached under ~/.nemesis8/project with a .nemesis8-version stamp and re-fetched only on version mismatch.

Net: n8 build always builds the nemesis8 container matching the binary — never a foreign project, never a floating main.

Verification

Compiled locally with cargo build (stable 1.97.1, x86_64-pc-windows-msvc) — Finished with no errors. flate2 + transitive deps locked in Cargo.lock.

🤖 Generated with Claude Code

kordless and others added 2 commits July 20, 2026 14:55
Two failure modes let `n8 build` build the wrong thing — or nothing:

1. cwd hijack: project_dir_fn() treated ANY Dockerfile in the current
   directory as the nemesis8 source, so running `n8 build` from a sibling
   repo (e.g. skiff) compiled THAT project and stamped it nemesis8:latest,
   silently clobbering the real agent image. Now the cwd Dockerfile is
   accepted only if it carries a nemesis8 build marker (nemesis8-base /
   nemesis8-entry); a foreign Dockerfile is ignored with a warning and
   resolution falls through to the real nemesis8 source.

2. Installed users have only the binary — no repo, no Dockerfile. The
   fetch path now downloads the GitHub source tarball for THIS binary's
   version (v{CARGO_PKG_VERSION}) over HTTPS (reqwest::blocking, already
   used in entry.rs) and unpacks it with flate2 + tar — no git required.
   git clone of the tag remains a fallback. The context is cached under
   ~/.nemesis8/project with a .nemesis8-version stamp and re-fetched only
   on version mismatch, so the built container always matches the binary
   instead of chasing a floating main.

Cargo.lock will gain flate2 on the next build (no main-binary path uses
--locked). No new commands or behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kordless
kordless merged commit 3ce7ad9 into main Jul 21, 2026
4 checks passed
kordless added a commit that referenced this pull request Jul 22, 2026
Podman/Docker runtime detection on Windows (#100), n8 build project-dir resolution + versioned tarball fetch (#98), single-key resume workspace prompt (#99).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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