Pin NO REPO CODE at native run seam

Task 7447 · Done · Coder · created · updated

Child C2 of epic 7433 (plan). Architecture (task 7432 `architecture.md`) §2.6 and §4 C2; PRD (task 7431 `prd.md`) AC-4. ## Original requirement (verbatim, epic body) Goal: no git operation that holds a credential, and no git operation run as the daemon, can be steered by a config, hook or include in a runner-writable tree. Achieve this structurally, so the growing denylist (`NO_REPO_CODE`, `BROKER_ONLY`, `DECLARED_OP`, Task 7284's pins) can be retired. Consolidates draft epic 7354 (with its children 7355–7357), 7353 and 7322. 2. Until (1) covers a path, close the known holes there. A repo-local `http.*` key, including URL-scoped `http.<url>.*`, an `url.*`, `include*`, `credential.*` or `remote.*.(proxy|vcs|uploadpack|receivepack)` key, can no longer redirect or MITM a declared op. Every daemon-uid git call carries `NO_REPO_CODE`: `worktree_ops._sync_develop_body`, `microvm_session._git`, and the `commands._native_run` seam. Out of scope: credential formats; the broker destination check and askPass pin (Task 7339). Required checks: ./dc check full ## This child's scope - `apps/jaahd/commands.py` `_native_run` (:169-235): for `argv[0] == "git"`, BOTH branches run `["git", *git_env.NO_REPO_CODE, *argv[1:]]` — the session-user branch (`run_as_session_user`, ~:200-203) and the daemon-uid `clone_identity.run_own` branch (~:221-224). The seam owns it; no caller has to remember. - Remove the now-duplicate caller prefix `git_env.NO_REPO_CODE` from `worktree_ops._sync_develop_body`'s `git` tuple (`worktree_ops.py:284`) in the same change. `worktree_mechanics._run_git`, `microvm_session._git`, `microvm_images._git` and preflight's `_NO_REPO_CODE` local calls keep theirs. - Audit every `_native_run` git caller for hook reliance (`reconcile.py:3689`, `slot_destroy.py:79,116`, `stack_ops`, `worktree_ops`). None is expected to rely on hooks (the daemon must never run repo hooks). If one does, stop, record it in the PR body and keep that caller working without running repo code. ## Acceptance criteria (verbatim, PRD AC-4) **AC-4. Every daemon-uid git call carries `NO_REPO_CODE`, or its structural equivalent once D3 retires it.** - The `commands._native_run` seam itself guarantees it for every argv whose `argv[0] == "git"`, on both the session-user branch and the daemon-uid branch. Today each caller has to remember; after this change no caller has to. `_sync_develop_body` and `microvm_session._git` keep it. - **verify:** - A unit test calls `commands._native_run("git", "status")` with each branch forced (switch needed / not needed). Asserting on the argv handed to `run_as_session_user` and to `clone_identity.run_own`, observe that the hooks/fsmonitor pins (or their successor) are present. - A behavioural test plants `core.fsmonitor=<marker program>` and a `post-checkout` hook in a tree, runs a `_native_run` git status/checkout, and observes the marker absent. Credentials & reach: PRD unit tests — Nothing beyond the worktree (local git 2.53.0) — **verified**. AC-9 `./dc check full` — worktree-local — **verified**. Watching the PR's Jaah Deploy — `jaah-forge` — **verified**. Out of scope: Do NOT touch credential formats, `cred_broker`'s `check_destination` or `core.askPass` handling (Task 7339). No UI, API route, DB migration, setting or flag. Do NOT touch the credentialed fetch paths, `git_env` transport pins or the mirror (child C1), `microvm_images` error text (child C3), or `git_credential_helper.py`/`fleet_dispatch.py` (child C4). No unrelated refactor of `commands.py` or `worktree_ops.py`. Done means: - AC-4 argv — `cd apps/jaahd && python3 -m pytest tests/ -k native_run -v`: with `session_user.switch_needed` patched True and False, the argv handed to `run_as_session_user` / `clone_identity.run_own` both start `git` + every `NO_REPO_CODE` element; a non-git argv is unchanged. - AC-4 behaviour — the planted `core.fsmonitor=<marker program>` + `post-checkout` hook test runs `_native_run("git", "-C", tree, "status")` and a checkout; the marker file is absent. Removing the seam pin makes it fail (mutation check recorded in the PR body). - `worktree_ops.py:284` no longer prefixes `NO_REPO_CODE`; existing `test_worktree_ops.py` sync tests updated and green; the caller audit result is stated in the PR body. - AC-9 — the merge lane's `./dc check full` reports pass (locally: `env -u JAAH_PROJECT_MEMORY ./dc check full`). Required checks: ./dc check full

Outcome

_native_run now pins NO_REPO_CODE on every git argv (both branches); sync_develop's duplicate prefix removed; argv + planted fsmonitor/hook tests with mutation check. Quick gate green; PR #6012 queued to merge lane.

Pull request

Artifacts

Activity

  • Draft
  • Ready
  • Runner started
  • Runner ended (done)