Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
chore(clawpatch): track hand-authored threat models under .config/clawpatch (#2822)
Maximilian Roosac958c232683
diff --git a/.config/clawpatch/config.json b/.config/clawpatch/config.jsonnew file mode 100644index 000000000..4b3e18e5f--- /dev/null+++ b/.config/clawpatch/config.json@@ -0,0 +1,38 @@+{+ "schemaVersion": 1,+ "stateDir": ".config/clawpatch",+ "include": [+ "**/*"+ ],+ "exclude": [+ "node_modules/**",+ "dist/**",+ "build/**",+ "target/**",+ ".build/**",+ ".git/**",+ ".clawpatch/**",+ ".config/clawpatch/**"+ ],+ "provider": {+ "name": "codex",+ "model": null+ },+ "commands": {+ "typecheck": "cargo check --workspace --all-targets",+ "lint": null,+ "format": "cargo fmt --all --check",+ "test": "cargo test --workspace"+ },+ "review": {+ "maxContextFiles": 24,+ "maxOwnedFiles": 12,+ "maxFindingsPerFeature": 10,+ "minConfidenceToFix": "medium"+ },+ "git": {+ "requireCleanWorktreeForFix": true,+ "commit": false,+ "openPr": false+ }+}diff --git a/.config/clawpatch/features/feat_custom_approval_gate.json b/.config/clawpatch/features/feat_custom_approval_gate.jsonnew file mode 100644index 000000000..b98c71dc3--- /dev/null+++ b/.config/clawpatch/features/feat_custom_approval_gate.json@@ -0,0 +1,111 @@+{+ "schemaVersion": 1,+ "featureId": "feat_custom_approval_gate",+ "title": "Project-command approval gate and command execution",+ "summary": "Worktrunk runs arbitrary project-defined hook commands, alias steps, and --execute bodies. These must only run after the approval gate (`Approvals` + `approve_command_batch` / `approve_or_skip`) clears them. Bypassing the gate = remote code execution on `wt switch`. Also handles signal-derived child exits (Ctrl-C must abort, not get swallowed by `FailureStrategy::Warn`). See CLAUDE.md > Project Commands Run Only After Approval and Signal Handling.",+ "kind": "library",+ "source": "manual",+ "confidence": "high",+ "entrypoints": [+ {+ "path": "src/commands/command_executor.rs",+ "symbol": "handle_command_error",+ "route": null,+ "command": null+ }+ ],+ "ownedFiles": [+ {+ "path": "src/commands/command_approval.rs",+ "reason": "approval gate logic"+ },+ {+ "path": "src/commands/command_executor.rs",+ "reason": "hook/alias/pipeline execution and signal forwarding"+ },+ {+ "path": "src/commands/for_each.rs",+ "reason": "per-worktree loop signal handling"+ },+ {+ "path": "src/commands/hooks.rs",+ "reason": "hook dispatch"+ },+ {+ "path": "src/commands/hook_commands.rs",+ "reason": "hook command resolution"+ },+ {+ "path": "src/commands/hook_filter.rs",+ "reason": "hook filtering"+ }+ ],+ "contextFiles": [+ {+ "path": "src/config/approvals.rs",+ "reason": "approvals storage"+ },+ {+ "path": "src/git/error.rs",+ "reason": "ChildProcessExited signal channel"+ },+ {+ "path": "src/shell_exec.rs",+ "reason": "child process spawning"+ },+ {+ "path": "CLAUDE.md",+ "reason": "approval gate and signal handling invariants"+ }+ ],+ "tests": [+ {+ "path": "tests/integration_tests/user_hooks.rs",+ "command": "cargo test --test integration user_hooks"+ },+ {+ "path": "tests/integration_tests/custom.rs",+ "command": "cargo test --test integration custom"+ }+ ],+ "tags": [+ "rust",+ "security",+ "approval-gate",+ "rce",+ "signal-handling"+ ],+ "trustBoundaries": [+ "user-input",+ "process-exec",+ "filesystem"+ ],+ "status": "needs-fix",+ "lock": null,+ "findingIds": [+ "fnd_sig-feat-custom-approval-gate-20_4591965160",+ "fnd_sig-feat-custom-approval-gate-45_1b36e46567",+ "fnd_sig-feat-custom-approval-gate-74_863f528652"+ ],+ "patchAttemptIds": [],+ "analysisHistory": [+ {+ "runId": "20260516T210804-353f93",+ "kind": "review",+ "summary": "2 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-16T21:14:12.355Z"+ },+ {+ "runId": "20260517T050139-b247d5",+ "kind": "review",+ "summary": "1 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-17T05:09:05.683Z"+ }+ ],+ "createdAt": "2026-05-16T21:00:00.000Z",+ "updatedAt": "2026-05-17T05:09:05.683Z"+}diff --git a/.config/clawpatch/features/feat_custom_config_deprecation.json b/.config/clawpatch/features/feat_custom_config_deprecation.jsonnew file mode 100644index 000000000..34816c56d--- /dev/null+++ b/.config/clawpatch/features/feat_custom_config_deprecation.json@@ -0,0 +1,103 @@+{+ "schemaVersion": 1,+ "featureId": "feat_custom_config_deprecation",+ "title": "Config loading, deprecation, and migration",+ "summary": "Pre-deserialization TOML migration rewrites deprecated patterns into canonical form. A silent migration bug here changes user-facing behavior without warning. Must: emit warnings exactly once per process, never drop unknown keys silently, and produce a stable .new file. Config format is an external interface (CLAUDE.md > Project Status). See CLAUDE.md > Config Deprecation.",+ "kind": "library",+ "source": "manual",+ "confidence": "high",+ "entrypoints": [+ {+ "path": "src/config/deprecation.rs",+ "symbol": "check_and_migrate",+ "route": null,+ "command": null+ }+ ],+ "ownedFiles": [+ {+ "path": "src/config/deprecation.rs",+ "reason": "deprecation detection + migration"+ },+ {+ "path": "src/config/mod.rs",+ "reason": "config loading orchestration"+ },+ {+ "path": "src/config/unknown_tree.rs",+ "reason": "unknown-field tracking"+ },+ {+ "path": "src/config/expansion.rs",+ "reason": "config field expansion"+ }+ ],+ "contextFiles": [+ {+ "path": "src/config/hooks.rs",+ "reason": "hook config schema"+ },+ {+ "path": "src/config/commands.rs",+ "reason": "command/alias config schema"+ },+ {+ "path": "src/config/project.rs",+ "reason": "project config schema"+ },+ {+ "path": "src/config/approvals.rs",+ "reason": "approvals config schema"+ },+ {+ "path": "CLAUDE.md",+ "reason": "config compatibility policy and deprecation recipe"+ }+ ],+ "tests": [+ {+ "path": "tests/integration_tests/config_show.rs",+ "command": "cargo test --test integration config_"+ }+ ],+ "tags": [+ "rust",+ "config",+ "deprecation",+ "external-interface"+ ],+ "trustBoundaries": [+ "filesystem"+ ],+ "status": "needs-fix",+ "lock": null,+ "findingIds": [+ "fnd_sig-feat-custom-config-deprecati_9d0e822819",+ "fnd_sig-feat-custom-config-deprecati_79b2b12026",+ "fnd_sig-feat-custom-config-deprecati_2cdc3ec70a",+ "fnd_sig-feat-custom-config-deprecati_0e8e3b1526",+ "fnd_sig-feat-custom-config-deprecati_bba4ffd8ac",+ "fnd_sig-feat-custom-config-deprecati_b5b81b84e7"+ ],+ "patchAttemptIds": [],+ "analysisHistory": [+ {+ "runId": "20260516T210804-353f93",+ "kind": "review",+ "summary": "3 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-16T21:12:52.547Z"+ },+ {+ "runId": "20260517T050139-b247d5",+ "kind": "review",+ "summary": "3 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-17T05:07:43.153Z"+ }+ ],+ "createdAt": "2026-05-16T21:00:00.000Z",+ "updatedAt": "2026-05-17T05:07:43.153Z"+}diff --git a/.config/clawpatch/features/feat_custom_merge_safety.json b/.config/clawpatch/features/feat_custom_merge_safety.jsonnew file mode 100644index 000000000..1ebffd703--- /dev/null+++ b/.config/clawpatch/features/feat_custom_merge_safety.json@@ -0,0 +1,101 @@+{+ "schemaVersion": 1,+ "featureId": "feat_custom_merge_safety",+ "title": "wt merge: data safety, rebase, and worktree cleanup",+ "summary": "The `wt merge` command lands a feature branch onto the target, runs the rebase, performs cleanup of the merged worktree, and runs pre-/post-merge hooks. Critical data-safety surface: a failed merge must not silently discard uncommitted work, and cleanup must not run before approval. See CLAUDE.md > Data Safety and Project Commands Run Only After Approval.",+ "kind": "library",+ "source": "manual",+ "confidence": "high",+ "entrypoints": [+ {+ "path": "src/commands/merge.rs",+ "symbol": "handle_merge",+ "route": null,+ "command": "wt merge"+ }+ ],+ "ownedFiles": [+ {+ "path": "src/commands/merge.rs",+ "reason": "entrypoint - merge command top-level"+ },+ {+ "path": "src/commands/worktree/finish.rs",+ "reason": "post-merge worktree finish/cleanup"+ },+ {+ "path": "src/commands/worktree/hooks.rs",+ "reason": "pre/post-merge hook invocation"+ },+ {+ "path": "src/commands/worktree/push.rs",+ "reason": "merge-time push handling"+ }+ ],+ "contextFiles": [+ {+ "path": "src/commands/command_approval.rs",+ "reason": "approval gate for pre/post-merge hooks"+ },+ {+ "path": "src/commands/command_executor.rs",+ "reason": "hook execution"+ },+ {+ "path": "src/git/repository/mod.rs",+ "reason": "git repository operations"+ },+ {+ "path": "src/git/repository/working_tree.rs",+ "reason": "dirty/clean detection"+ },+ {+ "path": "CLAUDE.md",+ "reason": "data safety + approval gate invariants"+ }+ ],+ "tests": [+ {+ "path": "tests/integration_tests/merge.rs",+ "command": "cargo test --test integration merge"+ }+ ],+ "tags": [+ "rust",+ "merge",+ "data-safety",+ "approval-gate"+ ],+ "trustBoundaries": [+ "filesystem",+ "process-exec"+ ],+ "status": "needs-fix",+ "lock": null,+ "findingIds": [+ "fnd_sig-feat-custom-merge-safety-77c_e1b74c5a3b",+ "fnd_sig-feat-custom-merge-safety-95c_56f1f1e6f0",+ "fnd_sig-feat-custom-merge-safety-b33_40d5e5a595"+ ],+ "patchAttemptIds": [],+ "analysisHistory": [+ {+ "runId": "20260516T210804-353f93",+ "kind": "review",+ "summary": "2 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-16T21:13:35.385Z"+ },+ {+ "runId": "20260517T050139-b247d5",+ "kind": "review",+ "summary": "1 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-17T05:07:50.805Z"+ }+ ],+ "createdAt": "2026-05-16T21:00:00.000Z",+ "updatedAt": "2026-05-17T05:07:50.805Z"+}diff --git a/.config/clawpatch/features/feat_custom_remove.json b/.config/clawpatch/features/feat_custom_remove.jsonnew file mode 100644index 000000000..8202f6954--- /dev/null+++ b/.config/clawpatch/features/feat_custom_remove.json@@ -0,0 +1,105 @@+{+ "schemaVersion": 1,+ "featureId": "feat_custom_remove",+ "title": "wt remove and picker-driven removal: data-loss surface",+ "summary": "Worktree removal is the highest-stakes destructive operation. Force-remove must require explicit user consent; cleanup must not silently discard uncommitted changes or untracked files. Race conditions between safety checks and the actual delete must fail closed (retain data). The picker also routes alt-r through handle_remove_output - must consult approvals read-only and skip rather than prompt mid-render. See CLAUDE.md > Data Safety, Time-of-check vs time-of-use.",+ "kind": "library",+ "source": "manual",+ "confidence": "high",+ "entrypoints": [+ {+ "path": "src/commands/picker/mod.rs",+ "symbol": "do_removal",+ "route": null,+ "command": "wt remove (interactive)"+ }+ ],+ "ownedFiles": [+ {+ "path": "src/commands/picker/mod.rs",+ "reason": "interactive removal entry"+ },+ {+ "path": "src/git/repository/worktrees.rs",+ "reason": "worktree list/remove primitives"+ },+ {+ "path": "src/remove_dir.rs",+ "reason": "filesystem removal logic"+ },+ {+ "path": "src/commands/relocate.rs",+ "reason": "relocate/move worktree (also destructive)"+ }+ ],+ "contextFiles": [+ {+ "path": "src/commands/command_approval.rs",+ "reason": "approval system for pre-remove hooks"+ },+ {+ "path": "src/commands/hooks.rs",+ "reason": "pre/post-remove hook execution"+ },+ {+ "path": "src/git/repository/working_tree.rs",+ "reason": "dirty detection"+ },+ {+ "path": "docs/content/faq.md",+ "reason": "documented destructive surface"+ },+ {+ "path": "CLAUDE.md",+ "reason": "data safety invariants"+ }+ ],+ "tests": [+ {+ "path": "tests/integration_tests/remove.rs",+ "command": "cargo test --test integration remove"+ }+ ],+ "tags": [+ "rust",+ "data-safety",+ "destructive"+ ],+ "trustBoundaries": [+ "filesystem",+ "user-input"+ ],+ "status": "needs-fix",+ "lock": null,+ "findingIds": [+ "fnd_sig-feat-custom-remove-3fc85fbc9_2fb36531bc",+ "fnd_sig-feat-custom-remove-d1e281e8e_f4081924e6",+ "fnd_sig-feat-custom-remove-54cc3614f_9edd442ab5",+ "fnd_sig-feat-custom-remove-1dbe5d2d1_10faa93f43",+ "fnd_sig-feat-custom-remove-7e79725d5_26a2834e00",+ "fnd_sig-feat-custom-remove-3f4296191_028f92e016",+ "fnd_sig-feat-custom-remove-34d4e5259_2210c7a66b",+ "fnd_sig-feat-custom-remove-087a0b4bb_5c82e2c2a5"+ ],+ "patchAttemptIds": [],+ "analysisHistory": [+ {+ "runId": "20260516T210804-353f93",+ "kind": "review",+ "summary": "4 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-16T21:13:20.172Z"+ },+ {+ "runId": "20260517T050139-b247d5",+ "kind": "review",+ "summary": "4 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-17T05:10:23.387Z"+ }+ ],+ "createdAt": "2026-05-16T21:00:00.000Z",+ "updatedAt": "2026-05-17T05:10:23.387Z"+}diff --git a/.config/clawpatch/features/feat_custom_repo_cache.json b/.config/clawpatch/features/feat_custom_repo_cache.jsonnew file mode 100644index 000000000..9eb39d4bb--- /dev/null+++ b/.config/clawpatch/features/feat_custom_repo_cache.json@@ -0,0 +1,105 @@+{+ "schemaVersion": 1,+ "featureId": "feat_custom_repo_cache",+ "title": "Repository caching invariants and worktree list mutation",+ "summary": "Repository<Arc<RepoCache>> caches read-only values to avoid re-querying git. Mutating paths (switch --create / remove) must NOT read list_worktrees() through the same Repository after their own mutation - cache is now stale. Per CLAUDE.md, dirty/HEAD must NOT be cached. Stale cache reads here surface as missing worktrees or wrong commit in hook template vars.",+ "kind": "library",+ "source": "manual",+ "confidence": "high",+ "entrypoints": [+ {+ "path": "src/git/repository/mod.rs",+ "symbol": "Repository",+ "route": null,+ "command": null+ }+ ],+ "ownedFiles": [+ {+ "path": "src/git/repository/mod.rs",+ "reason": "Repository + RepoCache definitions"+ },+ {+ "path": "src/git/repository/worktrees.rs",+ "reason": "list_worktrees caching path"+ },+ {+ "path": "src/git/repository/branches.rs",+ "reason": "branch cache"+ },+ {+ "path": "src/git/repository/working_tree.rs",+ "reason": "dirty / HEAD — explicitly NOT cached"+ },+ {+ "path": "src/git/repository/sha_cache.rs",+ "reason": "SHA cache"+ },+ {+ "path": "src/git/repository/ref_snapshot.rs",+ "reason": "ref snapshot"+ }+ ],+ "contextFiles": [+ {+ "path": "src/git/repository/remotes.rs",+ "reason": "remote URL cache"+ },+ {+ "path": "src/git/repository/config.rs",+ "reason": "repo config cache"+ },+ {+ "path": "src/commands/worktree/switch.rs",+ "reason": "mutating caller"+ },+ {+ "path": "src/commands/picker/mod.rs",+ "reason": "mutating caller (remove)"+ },+ {+ "path": "CLAUDE.md",+ "reason": "caching contract"+ }+ ],+ "tests": [+ {+ "path": "tests/integration_tests/list.rs",+ "command": "cargo test --test integration list"+ }+ ],+ "tags": [+ "rust",+ "caching",+ "concurrency",+ "invariants"+ ],+ "trustBoundaries": [],+ "status": "reviewed",+ "lock": null,+ "findingIds": [+ "fnd_sig-feat-custom-repo-cache-fa107_0b8ee04f50",+ "fnd_sig-feat-custom-repo-cache-4a612_c50420c545"+ ],+ "patchAttemptIds": [],+ "analysisHistory": [+ {+ "runId": "20260516T210804-353f93",+ "kind": "review",+ "summary": "2 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-16T21:13:53.940Z"+ },+ {+ "runId": "20260517T050139-b247d5",+ "kind": "review",+ "summary": "0 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-17T05:06:19.386Z"+ }+ ],+ "createdAt": "2026-05-16T21:00:00.000Z",+ "updatedAt": "2026-05-17T05:06:19.386Z"+}diff --git a/.config/clawpatch/features/feat_custom_switch_resolve.json b/.config/clawpatch/features/feat_custom_switch_resolve.jsonnew file mode 100644index 000000000..1b9a134ad--- /dev/null+++ b/.config/clawpatch/features/feat_custom_switch_resolve.json@@ -0,0 +1,105 @@+{+ "schemaVersion": 1,+ "featureId": "feat_custom_switch_resolve",+ "title": "wt switch + branch resolution: ref-injection, PR fetching, network policy",+ "summary": "`wt switch` resolves user-supplied references (branch names, pr:N, mr:N, gh URLs) and may create worktrees. Branch names can contain hyphens, slashes, special chars — must be passed to git without interpretation as flags. PR/MR fetch is the one place where shelling out to `gh`/`glab` is allowed and must not happen on background paths. See CLAUDE.md > Network Access policy and Worktree Model.",+ "kind": "library",+ "source": "manual",+ "confidence": "high",+ "entrypoints": [+ {+ "path": "src/commands/worktree/switch.rs",+ "symbol": "handle_switch",+ "route": null,+ "command": "wt switch"+ }+ ],+ "ownedFiles": [+ {+ "path": "src/commands/worktree/switch.rs",+ "reason": "switch command top-level"+ },+ {+ "path": "src/commands/worktree/resolve.rs",+ "reason": "PR/MR/branch resolution"+ },+ {+ "path": "src/commands/worktree/types.rs",+ "reason": "switch types/options"+ },+ {+ "path": "src/git/remote_ref/mod.rs",+ "reason": "remote ref parsing (PR/MR URLs)"+ },+ {+ "path": "src/git/repository/branch.rs",+ "reason": "branch name handling"+ }+ ],+ "contextFiles": [+ {+ "path": "src/git/repository/mod.rs",+ "reason": "repository operations"+ },+ {+ "path": "src/commands/worktree/mod.rs",+ "reason": "worktree module"+ },+ {+ "path": "src/commands/hooks.rs",+ "reason": "post-switch hook invocation"+ },+ {+ "path": "CLAUDE.md",+ "reason": "network policy, branch name handling"+ }+ ],+ "tests": [+ {+ "path": "tests/integration_tests/switch.rs",+ "command": "cargo test --test integration switch"+ }+ ],+ "tags": [+ "rust",+ "network-policy",+ "ref-injection",+ "user-input"+ ],+ "trustBoundaries": [+ "user-input",+ "network",+ "process-exec"+ ],+ "status": "needs-fix",+ "lock": null,+ "findingIds": [+ "fnd_sig-feat-custom-switch-resolve-d_5219fbb9db",+ "fnd_sig-feat-custom-switch-resolve-2_faf6ce371c",+ "fnd_sig-feat-custom-switch-resolve-d_db7a89a910",+ "fnd_sig-feat-custom-switch-resolve-b_d9afa10eef",+ "fnd_sig-feat-custom-switch-resolve-d_2ef4bb00aa",+ "fnd_sig-feat-custom-switch-resolve-c_24711332c6"+ ],+ "patchAttemptIds": [],+ "analysisHistory": [+ {+ "runId": "20260516T210804-353f93",+ "kind": "review",+ "summary": "3 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-16T21:14:00.797Z"+ },+ {+ "runId": "20260517T050139-b247d5",+ "kind": "review",+ "summary": "3 finding(s)",+ "provider": "codex",+ "model": null,+ "createdAt": "2026-05-17T05:12:27.656Z"+ }+ ],+ "createdAt": "2026-05-16T21:00:00.000Z",+ "updatedAt": "2026-05-17T05:12:27.656Z"+}diff --git a/.gitignore b/.gitignoreindex d0b9f14d1..bf6d9744f 100644--- a/.gitignore+++ b/.gitignore@@ -16,3 +16,14 @@ test-results//result/result-*.fonts++# clawpatch state lives in .config/clawpatch/ (run with --state-dir+# .config/clawpatch or CLAWPATCH_STATE_DIR=.config/clawpatch). Track only the+# hand-authored threat models and tuned config; findings, the auto-mapped+# feature, project.json, and per-run state are derived/transient and not.+/.clawpatch/+/.config/clawpatch/*+!/.config/clawpatch/config.json+!/.config/clawpatch/features+/.config/clawpatch/features/*+!/.config/clawpatch/features/feat_custom_*.json