Skip to content

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 08 Aug 07:56
· 97 commits to main since this release
v0.3.0
92d1983

This release closes a gap an agent could not see from inside: when the harness, not the agent, decides to use a git worktree, jj silently answers for the wrong repository.

Harness-created git worktrees (worktree-shadowed)

The skill assumed the agent chooses whether to use a git worktree. It does not. Claude Code's EnterWorktree, --worktree, isolation: "worktree" on a subagent, and background sessions all create a plain git worktree at .claude/worktrees/<name> inside the repo, before the agent has any say. That worktree has no .jj/, so jj walks up, finds the parent repo's .jj/, and answers for the parent workspace.

Reported by @plttn in #18 — including the discard_changes: true trap below, which is what makes the state destructive rather than merely confusing — and fixed in #19 by @CybotTM.

What it costs, all reproduced on jj 0.43.0:

  • Reads lie. jj status prints The working copy has no changes. over a modified and an untracked file.
  • Writes hit the wrong repo. jj describe -m from the worktree committed the parent checkout's unrelated in-progress edit under the agent's message, and jj new advanced the parent's working copy. The worktree's own edits were never touched.
  • The detector endorsed it. detect_jj_state.sh reported mode: colocated with a working-copy state read from the wrong workspace. It computed both roots and never compared them.

Neither conversion repairs the directory in place: jj git init --colocate refuses inside a git worktree, and jj workspace add refuses a non-empty destination.

What changed

  • detect_jj_state.sh gains a worktree-shadowed mode and exits 3. Detection is structural — git's own gitdir differs from the common dir and jj root is not the worktree root — not a .claude/worktrees/* path glob, so it holds for harnesses that use other directories. Working-copy state comes from git in that mode, and the jj status probe is skipped because it answers for the parent.
  • agent-safety.md §7: run no jj command in this state, reads included.
  • git-interop.md: the full failure mode, and the discard_changes: true trap named explicitly. ExitWorktree refuses to remove a worktree with uncommitted files; that check is at the git level and is correct. The failure sequence is jj reporting clean → the agent believing jj over the tool → passing discard_changes: true → the work gone, with no operation log to recover from because jj never recorded it.
  • recovery-playbook.md: recovering the parent repo after jj already ran from a shadowed worktree, and what is not recoverable at all.

A data-loss recipe removed

git-interop.md previously offered jj git init --git-repo=… as the fallback for the worktree case. In a dirty worktree that command succeeds, prints Added 0 files, modified 1 files, removed 1 files, and silently reverts the modified file and deletes the untracked one — no prompt, no operation-log entry to undo from. It is now marked as destructive, with a git status --short precondition. This affected anyone in a bare-repo + worktree layout, independent of the harness topic.

Also fixed: detect_jj_state.sh --json emitted string fields unescaped, so a repo path containing a double quote produced unparseable output — which would have broken the very guard this release adds.

Distribution and CI

  • Portable Agent Plugins 1.0.0 manifest (plugin.json) in #17 by @CybotTM, alongside the existing .claude-plugin/plugin.json.
  • Adopted the shared Netresearch skill-repo template in #16; validate.yml dropped in favour of the template's lint.yml.
  • Secret and workflow scanning added to security.yml in #15; jj evals now run via the shared script-check reusable in #14.

Upgrading

No breaking changes. Agents in a normal colocated repo, a jj workspace, or a bare-repo worktree layout see no behaviour change — all three were verified not to trigger the new mode. The one contract change: detect_jj_state.sh now exits 3 in the shadowed state, so a caller running it under set -e will abort there. That is the intent.

Full Changelog: v0.2.0...v0.3.0