carson 3.22.0 → 3.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/API.md +19 -20
  3. data/MANUAL.md +76 -65
  4. data/README.md +42 -50
  5. data/RELEASE.md +24 -1
  6. data/SKILL.md +1 -1
  7. data/VERSION +1 -1
  8. data/carson.gemspec +3 -4
  9. data/hooks/command-guard +1 -1
  10. data/hooks/pre-push +17 -20
  11. data/lib/carson/adapters/agent.rb +2 -2
  12. data/lib/carson/branch.rb +38 -0
  13. data/lib/carson/cli.rb +45 -30
  14. data/lib/carson/config.rb +80 -29
  15. data/lib/carson/delivery.rb +64 -0
  16. data/lib/carson/ledger.rb +305 -0
  17. data/lib/carson/repository.rb +47 -0
  18. data/lib/carson/revision.rb +30 -0
  19. data/lib/carson/runtime/audit.rb +43 -17
  20. data/lib/carson/runtime/deliver.rb +163 -149
  21. data/lib/carson/runtime/govern.rb +233 -357
  22. data/lib/carson/runtime/housekeep.rb +233 -27
  23. data/lib/carson/runtime/local/onboard.rb +29 -29
  24. data/lib/carson/runtime/local/prune.rb +120 -35
  25. data/lib/carson/runtime/local/sync.rb +29 -7
  26. data/lib/carson/runtime/local/template.rb +30 -12
  27. data/lib/carson/runtime/local/worktree.rb +37 -442
  28. data/lib/carson/runtime/review/gate_support.rb +144 -12
  29. data/lib/carson/runtime/review/sweep_support.rb +2 -2
  30. data/lib/carson/runtime/review/utility.rb +1 -1
  31. data/lib/carson/runtime/review.rb +21 -77
  32. data/lib/carson/runtime/setup.rb +25 -33
  33. data/lib/carson/runtime/status.rb +96 -212
  34. data/lib/carson/runtime.rb +39 -4
  35. data/lib/carson/worktree.rb +497 -0
  36. data/lib/carson.rb +6 -0
  37. metadata +37 -17
  38. data/.github/copilot-instructions.md +0 -1
  39. data/.github/pull_request_template.md +0 -12
  40. data/templates/.github/AGENTS.md +0 -1
  41. data/templates/.github/CLAUDE.md +0 -1
  42. data/templates/.github/carson.md +0 -47
  43. data/templates/.github/copilot-instructions.md +0 -1
  44. data/templates/.github/pull_request_template.md +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e75b6729cf0c977beb1ace5da390f41ae20d80208d7470c97b145b76e44cb3ad
4
- data.tar.gz: 24d85c37e66498731b9d980b39017a4d73c06c93acd1dd8018e74b33e951d4df
3
+ metadata.gz: 3b09da719cacfca1da3e00f8c542719283e0f1e0d73554371449fa01d3d1b331
4
+ data.tar.gz: 33d2ab2f5881e8f96934037f715893492b495354eda5c77c64b47ded8d1ee710
5
5
  SHA512:
6
- metadata.gz: df4ff4c103415e7ff448ee5c8d7bbd60b4259afa15f522d840519b420e0202dc8cb7e86af7d27df0174c8df963eb57cf13fd578678e3c960b669f94e81089d6b
7
- data.tar.gz: fcc758b8416931f303dbd72bcabac9f703b844c79b1dd37eec4572b43abe455bca81ca0f8f9871c09a2ee27f086f70c3e977b78b5c078d6820d8f8d770fb74c2
6
+ metadata.gz: d5c0dbbae4f9424054cbed42c0d6ed6430643a7f974252bf532f98c8aeeafb5e0962c9204e3e9d806752ac5ee063c98d005b4693d570c2b3d9699b2ac1808bef
7
+ data.tar.gz: d49e6eef6854bf55eb3fe788e6f549585806a03d9266ef5aefdd42b960b3ed9e9f8750d48c3d893d94415e43a56df685701989724d1ff8af439375218f5af743
data/API.md CHANGED
@@ -15,7 +15,7 @@ carson <command> [subcommand] [arguments]
15
15
 
16
16
  | Command | Purpose |
17
17
  |---|---|
18
- | `carson setup` | Interactive quiz to configure remote, main branch, workflow, and merge method. Writes `~/.carson/config.json`. |
18
+ | `carson setup` | Interactive quiz to configure remote, main branch, workflow, and canonical lint-policy path. Writes `~/.carson/config.json`. |
19
19
  | `carson onboard [repo_path]` | Apply one-command baseline setup for a target git repository. Auto-triggers `setup` on first run. Installs or refreshes Carson-managed global hooks. |
20
20
  | `carson refresh [repo_path]` | Re-apply hooks, templates, and audit after upgrading Carson. Auto-propagates template updates to the remote via worktree (branch workflow: PR on `carson/template-sync`; trunk workflow: push to main). |
21
21
  | `carson offboard [repo_path]` | Remove Carson-managed host artefacts, detach Carson hooks path, and deregister from `govern.repos`. |
@@ -25,11 +25,14 @@ carson <command> [subcommand] [arguments]
25
25
  | Command | Purpose |
26
26
  |---|---|
27
27
  | `carson audit` | Evaluate governance status and generate report output. |
28
+ | `carson deliver` | Start autonomous branch delivery for the current checkout: push, create or refresh PR, record delivery state, and return immediately. |
28
29
  | `carson sync` | Fast-forward local `main` from configured remote when tree is clean. |
29
30
  | `carson prune` | Remove stale local branches whose upstream refs no longer exist. |
30
31
  | `carson template check` | Detect drift between managed templates and host `.github/*` files. |
31
32
  | `carson template apply` | Write canonical managed template content into host `.github/*` files. |
32
- | `carson status` | Show repository state (branch, worktrees, PRs, governance). |
33
+ | `carson status [--json]` | Show repository delivery state. Default output is Markdown/text; `--json` is the explicit machine contract. |
34
+ | `carson worktree create <name>` | Create an isolated worktree and branch for a new stream of work. |
35
+ | `carson worktree remove <path_or_name>` | Remove a worktree safely and clean up its branch when allowed. |
33
36
 
34
37
  ### Batch commands (Layer 2)
35
38
 
@@ -41,7 +44,7 @@ All batch commands operate across every governed repository registered in `gover
41
44
  | `carson audit --all` | Run governance audit across all governed repos. Reports pass/block/fail per repo. |
42
45
  | `carson sync --all` | Sync main branch across all governed repos. |
43
46
  | `carson prune --all` | Remove stale branches across all governed repos. |
44
- | `carson status --all [--json]` | Portfolio-wide status overview with branch, worktrees, and governance state per repo. |
47
+ | `carson status --all [--json]` | Portfolio-wide delivery overview per governed repository. |
45
48
  | `carson template check --all` | Read-only template drift detection across all governed repos. |
46
49
  | `carson housekeep --all` | Sync, reap dead worktrees, and prune across all governed repos. |
47
50
 
@@ -49,11 +52,11 @@ All batch commands operate across every governed repository registered in `gover
49
52
 
50
53
  | Command | Purpose |
51
54
  |---|---|
52
- | `carson govern [--dry-run] [--json] [--loop SECONDS]` | Portfolio-level PR triage: classify, merge, dispatch agents, escalate. |
55
+ | `carson govern [--dry-run] [--json] [--loop SECONDS]` | Portfolio-level delivery oversight: assess active deliveries, integrate ready branches, dispatch revisions, and escalate blocked work. |
53
56
 
54
57
  `--loop SECONDS` runs the govern cycle continuously, sleeping SECONDS between cycles. The loop isolates errors per cycle — a single failing cycle does not stop the daemon. `Ctrl-C` cleanly exits with a cycle count summary. SECONDS must be a positive integer.
55
58
 
56
- `govern.merge.method` accepts `squash`, `merge`, or `rebase` (default: `squash`). Squash keeps main linear — one PR, one commit. When the target repository enforces linear history via branch protection, both `squash` and `rebase` are accepted by GitHub — only `merge` is rejected.
59
+ Governed integration is fixed to `squash`. Non-squash `govern.merge.method` values are rejected by config validation.
57
60
 
58
61
  ### Review commands
59
62
 
@@ -84,12 +87,7 @@ Blocked Carson artefacts in host repositories:
84
87
  - `.tools/carson/*`
85
88
 
86
89
  Allowed Carson-managed persistence in host repositories:
87
- - `.github/carson.md` — governance baseline (source of truth)
88
- - `.github/copilot-instructions.md` — agent discovery pointer for Copilot
89
- - `.github/CLAUDE.md` — agent discovery pointer for Claude Code
90
- - `.github/AGENTS.md` — agent discovery pointer for Codex
91
- - `.github/pull_request_template.md` — PR template
92
- - Any file discovered from `template.canonical` — user's canonical `.github/` files
90
+ - Any file discovered from `lint.canonical` — user's canonical GitHub and lint-policy files
93
91
 
94
92
  ## Configuration interface
95
93
 
@@ -109,8 +107,7 @@ Environment overrides:
109
107
  - `CARSON_REVIEW_SWEEP_STATES`
110
108
  - `CARSON_WORKFLOW_STYLE`
111
109
  - `CARSON_GOVERN_REPOS`
112
- - `CARSON_GOVERN_AUTO_MERGE`
113
- - `CARSON_GOVERN_MERGE_METHOD`
110
+ - `CARSON_GOVERN_AUTHORITY`
114
111
  - `CARSON_GOVERN_AGENT_PROVIDER`
115
112
  - `CARSON_GOVERN_CHECK_WAIT`
116
113
 
@@ -120,40 +117,42 @@ Environment overrides:
120
117
  {
121
118
  "govern": {
122
119
  "repos": ["~/Dev/project-a", "~/Dev/project-b"],
120
+ "authority": "remote",
123
121
  "agent": {
124
122
  "provider": "auto",
125
123
  "codex": {},
126
124
  "claude": {}
127
125
  },
128
126
  "check_wait": 30,
129
- "auto_merge": true,
130
127
  "merge": {
131
128
  "method": "squash"
132
- }
129
+ },
130
+ "state_path": "~/.carson/state.sqlite3"
133
131
  }
134
132
  }
135
133
  ```
136
134
 
137
135
  `govern` semantics:
138
136
  - `repos`: list of local repo paths to govern (empty = current repo only).
137
+ - `authority`: `"remote"` (default) or `"local"`.
139
138
  - `agent.provider`: `"auto"`, `"codex"`, or `"claude"`.
140
139
  - `agent.codex` / `agent.claude`: provider-specific options (reserved).
141
140
  - `check_wait`: seconds to wait for CI checks before classifying (default: `30`).
142
- - `auto_merge`: `true` (default) — Carson may merge autonomously. Set to `false` to require explicit enablement.
143
- - `merge.method`: `"squash"` (default), `"merge"`, or `"rebase"`.
141
+ - `merge.method`: `"squash"` only in governed mode.
142
+ - `state_path`: SQLite ledger path for active deliveries and revisions.
144
143
 
145
144
  `template` schema:
146
145
 
147
146
  ```json
148
147
  {
149
- "template": {
148
+ "lint": {
150
149
  "canonical": "~/AI/CODING/LINT"
151
150
  }
152
151
  }
153
152
  ```
154
153
 
155
- `template` semantics:
156
- - `canonical`: path to a directory of canonical `.github/` files. Carson discovers files in this directory and syncs them to governed repos alongside its own governance files. The directory mirrors `.github/` structure — `workflows/lint.yml` deploys to `.github/workflows/lint.yml`. Default: `nil` (no canonical files).
154
+ `lint` semantics:
155
+ - `canonical`: path to a directory of canonical GitHub and lint-policy files. Carson discovers files in this directory and syncs them to governed repos. Explicit GitHub paths stay under `.github/` (`workflows/lint.yml` `.github/workflows/lint.yml`, `.github/labeler.yml` → `.github/labeler.yml`); flat policy files default to `.github/linters/` (`rubocop.yml` → `.github/linters/rubocop.yml`). Legacy root lint configs become stale and are removed on apply. Default: `nil` (no canonical files). The deprecated alias `template.canonical` is still accepted when loading config.
157
156
 
158
157
  ## Output interface
159
158
 
data/MANUAL.md CHANGED
@@ -39,7 +39,7 @@ On first run (no `~/.carson/config.json` exists), `onboard` launches `carson set
39
39
  - Hook installation under `~/.carson/hooks/<version>/`.
40
40
  - Repository `core.hooksPath` alignment to Carson global hooks.
41
41
  - Commit-time governance gate via managed `pre-commit` hook.
42
- - Managed `.github/*` template synchronisation.
42
+ - Canonical `.github/*` template synchronisation (when `lint.canonical` is configured).
43
43
  - Initial governance audit.
44
44
 
45
45
  ### Reconfigure later
@@ -48,11 +48,11 @@ On first run (no `~/.carson/config.json` exists), `onboard` launches `carson set
48
48
  carson setup
49
49
  ```
50
50
 
51
- Re-run the interactive setup quiz to change your remote, main branch, workflow style, or merge method. Choices are saved to `~/.carson/config.json`.
51
+ Re-run the interactive setup quiz to change your remote, main branch, workflow style, or canonical lint-policy path. Choices are saved to `~/.carson/config.json`.
52
52
 
53
53
  ### Commit generated files
54
54
 
55
- After `onboard`, commit the generated `.github/*` changes in your repository. From this point the repository is governed.
55
+ After `onboard`, commit any `.github/*` changes in your repository. From this point the repository is governed.
56
56
 
57
57
  ## CI Setup
58
58
 
@@ -82,37 +82,70 @@ Notes:
82
82
 
83
83
  ### Canonical Templates
84
84
 
85
- Carson manages 5 governance files (carson.md, CLAUDE.md, AGENTS.md, copilot-instructions.md, pull_request_template.md). Beyond those, you can tell Carson about your own canonical `.github/` files CI workflows, linter configs, labeller rules, anything that belongs in `.github/`.
85
+ Carson has no built-in template files. Instead, you tell Carson about your own canonical GitHub and lint-policy files via `lint.canonical`.
86
86
 
87
- Set `template.canonical` in `~/.carson/config.json`:
87
+ Set `lint.canonical` in `~/.carson/config.json`:
88
88
 
89
89
  ```json
90
90
  {
91
- "template": {
91
+ "lint": {
92
92
  "canonical": "~/AI/CODING/LINT"
93
93
  }
94
94
  }
95
95
  ```
96
96
 
97
- That directory mirrors the `.github/` structure:
97
+ Flat lint-policy directories default to `.github/linters/`, while explicit GitHub paths stay under `.github/`:
98
98
 
99
99
  ```
100
100
  ~/AI/CODING/LINT/
101
+ ├── rubocop.yml → deployed to .github/linters/rubocop.yml
102
+ ├── ruff.toml → deployed to .github/linters/ruff.toml
101
103
  ├── workflows/
102
104
  │ └── lint.yml → deployed to .github/workflows/lint.yml
103
- ├── .mega-linter.yml → deployed to .github/.mega-linter.yml
104
- └── labeler.yml → deployed to .github/labeler.yml
105
+ └── .github/
106
+ └── labeler.yml → deployed to .github/labeler.yml
105
107
  ```
106
108
 
107
- Carson discovers files in this directory and syncs them to governed repos alongside its own governance files. `carson template check` detects drift, `carson template apply` writes them, and `carson refresh` propagates them to the remote.
109
+ Carson discovers files in this directory and syncs them to governed repos. Root files that are not recognised GitHub artefacts are treated as lint policy and written under `.github/linters/`; legacy root lint configs become stale and are removed on apply. `carson template check` detects drift, `carson template apply` writes them, and `carson refresh` propagates them to the remote. Carson still reads the deprecated `template.canonical` key for backwards compatibility, but new setup writes `lint.canonical`.
108
110
 
109
111
  **Why this design.** Lint, CI, and tooling config are personal decisions — not governance decisions. Carson's job is to deliver your canonical files reliably, not to decide what they should contain.
110
112
 
113
+ ## Operating Strategies
114
+
115
+ These strategies are the audit lens for Carson. If behaviour departs from them, either the product model or the implementation needs attention.
116
+
117
+ ### Git Strategist
118
+
119
+ - **Worktree-first discipline** — substantive work happens in worktrees, never on the main working tree. This keeps concurrent agent work isolated and makes cleanup explicit.
120
+ - **Deterministic base selection** — new work starts from the repo's chosen integration authority, not from whatever branch state happens to be lying around.
121
+ - **Single landing path per authority** — in `remote`, completed work rejoins through remote `main`; in `local`, completed work rejoins through local `main` and then pushes `main` as backup.
122
+ - **Content-aware merge detection** — Carson proves whether a branch's content is already on `main` without relying on commit SHAs, so squash and rebase merges are handled correctly.
123
+ - **Worktree-aware delivery** — Carson lands work without assuming `main` can be checked out in the active worktree, and cleanup is deferred to the correct context.
124
+ - **Exact post-merge guidance** — after a successful landing, Carson tells the caller the next clean-up command instead of leaving the lifecycle half-finished.
125
+
126
+ ### Repo Governor
127
+
128
+ - **Outsider boundary** — Carson governs repositories without writing Carson-specific config, scripts, or runtime payloads into them.
129
+ - **Command ownership** — in governed repositories, Carson owns worktree and delivery operations so agents do not mix raw git flows with governed ones.
130
+ - **Authority enforcement** — every governed repo has one integration authority at a time. That authority determines how work starts and how it returns to shared truth.
131
+ - **Active review gating** — when the repo uses PR-based delivery, review findings must be acknowledged before merge. Feedback is never silently buried.
132
+ - **Portfolio triage** — `carson govern` applies the same discipline across multiple repositories: classify, merge, dispatch, or escalate.
133
+ - **Template propagation** — Carson treats canonical policy files as managed infrastructure and keeps them consistent across repos.
134
+
135
+ ### Safety Strategies
136
+
137
+ - **Process-aware worktree removal** — Carson checks whether the current shell or another process has its CWD inside a worktree before attempting removal.
138
+ - **Stale worktree sweep** — Carson removes worktrees whose content has already been absorbed into `main` so dead state does not block later maintenance.
139
+ - **Protected branch preservation** — Carson never deletes protected branches and does not prune branches that are still held by active worktrees.
140
+ - **Hook bypass only for managed operations** — Carson uses controlled bypasses such as `--no-verify` only for its own managed flows, not as a general escape hatch.
141
+ - **Self-diagnosing errors** — blocks and failures must explain the condition and prescribe the exact recovery command.
142
+ - **Self-configuring guardrails** — running Carson should install and refresh its own safeguards rather than expecting manual post-install housekeeping.
143
+
111
144
  ## Agent Worktree Workflow
112
145
 
113
146
  The core workflow for coding agents using Carson. One command per step, full lifecycle.
114
147
 
115
- **1. Create a worktree** — Carson auto-syncs main before branching (3.13.0+), so the worktree always starts from the latest code:
148
+ **1. Create a worktree** — Carson starts new work from the repo's chosen integration authority rather than from the caller's current HEAD. When that authority requires sync, Carson checks it before branching:
116
149
 
117
150
  ```bash
118
151
  carson worktree create my-feature
@@ -121,18 +154,26 @@ cd /path/to/.claude/worktrees/my-feature
121
154
 
122
155
  **2. Work** — make changes, commit, iterate.
123
156
 
124
- **3. Deliver and merge** — push, create PR, merge when CI passes. After merge, Carson prints the exact next command (3.13.0+):
157
+ **3. Hand the branch to Carson** — `deliver` is the asynchronous branch handoff. In remote authority Carson pushes the branch, creates or refreshes the PR, records delivery state, and returns immediately. Managed template drift is corrected and committed automatically before push (3.23.0+).
158
+
159
+ ```bash
160
+ carson deliver
161
+ # Output: PR #N, Delivery: queued|gated
162
+ # Next: carson status
163
+ ```
164
+
165
+ **4. Monitor and advance** — `status` is the delivery surface. It shows the current branch plus active deliveries for the repository. Keep `govern` running to advance queued deliveries and revisions across governed repositories:
125
166
 
126
167
  ```bash
127
- carson deliver --merge
128
- # Output: Merged PR #N via squash.
129
- # Next: cd /path/to/repo && carson worktree remove my-feature
168
+ carson status
169
+ carson govern --loop 300
130
170
  ```
131
171
 
132
- **4. Clean up** — follow the printed next step. After squash merge, Carson detects the content is on main and allows removal without `--force` (3.13.1+):
172
+ **5. Clean up landed work** — once the delivery is integrated, use Carson cleanup commands from the main worktree:
133
173
 
134
174
  ```bash
135
- cd /path/to/repo && carson worktree remove my-feature
175
+ cd /path/to/repo
176
+ carson worktree remove my-feature
136
177
  carson prune
137
178
  ```
138
179
 
@@ -142,7 +183,7 @@ carson prune
142
183
 
143
184
  After squash or rebase merge, the content matches main — removal proceeds without `--force`.
144
185
 
145
- **Stale worktree recovery** — if a worktree directory is destroyed externally (e.g. by running `gh pr merge --delete-branch` from inside it), `worktree remove` and `prune` handle the stale entry gracefully: they clean up the git registration and delete the branch without error. Use `carson deliver --merge` instead of raw `gh pr merge --delete-branch` to avoid this situation — `deliver` deliberately omits `--delete-branch` so the worktree directory stays intact for orderly cleanup.
186
+ **Stale worktree recovery** — if a worktree directory is destroyed externally (for example by a raw GitHub merge/delete flow), `worktree remove` and `prune` handle the stale entry gracefully: they clean up the git registration and delete the branch without error. Use Carson's `deliver` + `govern` flow instead of raw `gh pr merge --delete-branch` so the worktree directory stays intact for orderly cleanup.
146
187
 
147
188
  ### Carson vs Claude Code EnterWorktree
148
189
 
@@ -152,7 +193,7 @@ Claude Code has a built-in `EnterWorktree` tool. Both create a git worktree unde
152
193
 
153
194
  | Concern | EnterWorktree | Carson |
154
195
  |---|---|---|
155
- | Auto-sync main before branching | No — branches from current HEAD, which may be stale | Yes — `git pull --ff-only` before branch creation |
196
+ | Governed baseline before branching | No — branches from current HEAD, which may be stale | Yes — branches from the repo's governed baseline rather than the caller's current HEAD |
156
197
  | CWD guard on removal | No | Yes — blocks if shell is inside the worktree |
157
198
  | Unpushed-commits guard | No | Yes — blocks if work hasn't been pushed |
158
199
  | Content-aware squash/rebase detection | No | Yes — compares tree content, not SHAs |
@@ -238,7 +279,7 @@ Use `--loop SECONDS` to run `carson govern` as a persistent daemon that cycles o
238
279
 
239
280
  ```bash
240
281
  carson govern --loop 300 # cycle every 5 minutes
241
- carson govern --loop 300 --dry-run # observe mode, no merges or dispatches
282
+ carson govern --loop 300 --dry-run # observe mode, no integration or revision dispatch
242
283
  ```
243
284
 
244
285
  The loop is built-in and cross-platform — no cron, launchd, or Task Scheduler required. Run it in a terminal, tmux, screen, or as a system service.
@@ -247,25 +288,15 @@ Each cycle runs independently: if one cycle fails (network error, GitHub API tim
247
288
 
248
289
  ### Govern and Coding Agents
249
290
 
250
- `carson govern` dispatches coding agents (Codex or Claude) when a PR has failing CI checks. The agent receives the failure context and attempts to fix the issues in a follow-up commit. If the agent succeeds, the PR re-enters the governance pipeline. If it fails or times out, the PR is escalated for human attention.
291
+ `carson govern` dispatches coding agents (Codex or Claude) when an active delivery is blocked by CI, review, or policy feedback. The agent receives the failure context and attempts a revision. If the agent succeeds, the delivery re-enters the governance pipeline. If it fails repeatedly or times out, the delivery is escalated for human attention.
251
292
 
252
293
  The agent provider is configurable via `govern.agent.provider` (`auto`, `codex`, or `claude`). In `auto` mode, Carson selects the first available provider.
253
294
 
254
- ## Merge Method and Linear History
255
-
256
- Carson's `govern.merge.method` controls how `carson govern` merges ready PRs. The options are `squash`, `merge`, and `rebase` (default: `squash`). Set this in `~/.carson/config.json`:
295
+ ## Governed Integration Policy
257
296
 
258
- ```json
259
- {
260
- "govern": {
261
- "merge": {
262
- "method": "squash"
263
- }
264
- }
265
- }
266
- ```
297
+ Governed integration is fixed to `squash`. Carson no longer exposes merge-method choice for governed delivery, and config validation rejects non-squash values.
267
298
 
268
- **Why squash is the default.** Squash-to-main keeps history linear: one PR = one commit on main. Every commit on main corresponds to a reviewed, CI-passing unit of work. The benefits:
299
+ **Why squash is fixed.** Squash-to-main keeps history linear: one delivered branch = one commit on main. Every commit on main corresponds to a reviewed, CI-passing unit of work. The benefits:
269
300
 
270
301
  - `git log --oneline` on main tells the full story without merge noise or work-in-progress commits.
271
302
  - Every commit is individually revertable — `git revert <sha>` undoes exactly one PR.
@@ -274,10 +305,7 @@ Carson's `govern.merge.method` controls how `carson govern` merges ready PRs. Th
274
305
 
275
306
  **When to use other methods:**
276
307
 
277
- - `rebase` if you want to preserve individual commits from the branch on main. Both `squash` and `rebase` are compatible with GitHub's "Require linear history" branch protection — only `merge` is rejected.
278
- - `merge` — if you want explicit merge commits. This creates a non-linear graph but preserves branch topology.
279
-
280
- **Important:** Carson's merge method must match your GitHub repository's allowed merge types. If your repo only allows squash merges and Carson is set to `merge`, govern will fail when it tries to auto-merge. Check your repository settings under Settings > General > Pull Requests.
308
+ There is no governed manual-final-merge mode. Repositories that require a human to perform the final merge are outside Carson's governed delivery contract.
281
309
 
282
310
  ## Defaults and Why
283
311
 
@@ -304,15 +332,13 @@ How code reaches main.
304
332
 
305
333
  Change: `carson setup` or `CARSON_WORKFLOW_STYLE`.
306
334
 
307
- #### Merge method
335
+ #### Governed integration
308
336
 
309
- How `carson govern` merges ready PRs.
337
+ How Carson lands ready deliveries.
310
338
 
311
- - **`squash`** (default) — one PR = one commit on main. Linear, bisectable history. Every commit is individually revertable. Branch commits are preserved in the PR on GitHub.
312
- - **`rebase`** — preserves individual branch commits on main. Linear history. Use when commit-level attribution matters.
313
- - **`merge`** — creates merge commits. Non-linear graph but preserves branch topology. Use when branch structure is meaningful.
339
+ - **`squash`** (fixed) — one delivered branch = one commit on main. Linear, bisectable history. Branch commits remain visible in the PR on GitHub.
314
340
 
315
- Must match your GitHub repo's allowed merge types. Change: `carson setup` or `govern.merge.method` in config.
341
+ This is part of Carson's governed contract, not a setup preference.
316
342
 
317
343
  #### Git remote
318
344
 
@@ -347,13 +373,14 @@ Whether reviewer findings require acknowledgement.
347
373
 
348
374
  Change: `CARSON_REVIEW_DISPOSITION`.
349
375
 
350
- #### Merge authority
376
+ #### Delivery authority
351
377
 
352
- Whether `carson govern` can merge PRs autonomously.
378
+ Where completed work rejoins shared truth.
353
379
 
354
- - Default: **enabled**. Carson merges PRs that pass all gates (CI green, review clean, audit clean). PRs that need human judgement are escalated, never silently merged.
380
+ - **`remote`** (default) the PR lands on remote `main`.
381
+ - **`local`** — Carson integrates through local `main`, then pushes `main` as backup.
355
382
 
356
- Disable: `govern.auto_merge: false` in config or `CARSON_GOVERN_AUTO_MERGE=false`.
383
+ Change: `govern.authority` in config.
357
384
 
358
385
  #### Output verbosity
359
386
 
@@ -362,22 +389,6 @@ How much Carson prints.
362
389
  - Default: **concise**. A healthy audit prints one line. Problems print actionable summaries with cause and fix.
363
390
  - `--verbose` restores full diagnostic key-value output for debugging.
364
391
 
365
- ## Agent Discovery
366
-
367
- Carson writes managed files that help interactive agents (Claude Code, Codex, Copilot) discover the governance system when they work in a governed repository.
368
-
369
- **How it works:**
370
-
371
- - `.github/AGENTS.md` — full governance baseline; read by Codex and other agents. Points to `carson.md`.
372
- - `.github/CLAUDE.md` — read by Claude Code at session start. Points to `AGENTS.md`.
373
- - `.github/copilot-instructions.md` — read by GitHub Copilot. Points to `AGENTS.md`.
374
-
375
- Each agent reads its own expected filename and follows the reference to the shared baseline. One file to maintain, zero drift across agents.
376
-
377
- All four files are managed templates — `carson template check` detects drift, `carson template apply` writes them, and `carson offboard` removes them.
378
-
379
- **Why this matters:** without discovery, agents working in governed repos hit Carson's hooks blindly and don't understand the governance contract. With discovery, agents know to run `carson audit` before committing, `carson review gate` before recommending a merge, and to respect protected refs.
380
-
381
392
  ## Configuration
382
393
 
383
394
  Default global config path: `~/.carson/config.json`.
@@ -398,7 +409,7 @@ Common environment overrides:
398
409
  | `CARSON_REVIEW_SWEEP_WINDOW_DAYS` | Lookback window for review sweep. |
399
410
  | `CARSON_REVIEW_SWEEP_STATES` | PR states to include in sweep. |
400
411
  | `CARSON_REVIEW_BOT_USERNAMES` | Comma-separated bot usernames to ignore in review gate and sweep. |
401
- | `CARSON_GOVERN_AUTO_MERGE` | Enable or disable autonomous PR merging. |
412
+ | `CARSON_GOVERN_AUTHORITY` | Override delivery authority (`remote` or `local`). |
402
413
  | `CARSON_WORKFLOW_STYLE` | Workflow style override (`branch` or `trunk`). |
403
414
  | `CARSON_RUBY_INDENTATION` | Ruby indentation policy (`tabs`, `spaces`, or `either`). |
404
415
 
data/README.md CHANGED
@@ -2,97 +2,89 @@
2
2
 
3
3
  # ⧓ Carson
4
4
 
5
- *Carson at your service.*
5
+ Named after the butler of Downton Abbey, Carson is a strategic governor for multiple agents working in one repo.
6
6
 
7
- Named after the head of household in Downton Abbey, Carson is your repositories' autonomous governance runtime — you write the code, Carson manages everything else. From commit-time checks through PR triage, agent dispatch, merge, and cleanup, Carson runs the household with discipline and professional standards. Carson itself has no intelligence it follows a deterministic decision tree. The intelligence comes from the coding agents it dispatches (Codex, Claude) to fix problems.
7
+ Carson is deterministic infrastructure for concurrent agent work. It governs how work starts, how it rejoins shared truth, and how the repo is cleaned up afterwards so agents can code without trampling each other. The agents provide the intelligence; Carson provides the discipline.
8
+
9
+ Carson was built in real work. Its strategies come from scars: more than ten agents running across multiple projects at once, with each repeated failure turned into a rule, guardrail, or recovery path.
8
10
 
9
11
  ## The Problem
10
12
 
11
- Managing a growing portfolio of repositories is rewarding work but the operational overhead scales faster than the code itself. PR templates go stale, reviewer feedback gets quietly buried, and what passes on a developer's laptop fails in CI. When coding agents start producing PRs across multiple projects, the coordination load multiplies: checking results, dispatching fixes, clicking merge, cleaning up branches.
13
+ When several agents work on one repository, plain Git leaves too much to habit. Branches start from different bases, work lands back on `main` through inconsistent paths, old worktrees linger, and one clean-up step can disrupt another session.
12
14
 
13
- Carson exists so you can focus on what matters building while governance runs itself.
15
+ Carson solves that single-repo concurrency problem first, then extends the same discipline across multiple repositories.
14
16
 
15
17
  ## What Carson Does
16
18
 
17
- Carson is an autonomous governance runtime that lives on your workstation and in CI, never inside the repositories it governs. It operates at two levels:
19
+ Carson lives on your workstation and in CI, never inside the repositories it governs. Two roles, one tool:
18
20
 
19
- **Per-commit governance** — Carson gates merges on unresolved review comments, synchronises templates, and keeps your local branches clean. Every commit triggers `carson audit` through managed hooks; the same checks run in GitHub Actions.
21
+ **Git strategist** — Carson decides how new work begins, which base it uses, how it returns to shared truth, and how cleanup happens safely.
20
22
 
21
- **Portfolio-level autonomy** — `carson govern` is a triage loop that scans your registered repositories, classifies every open PR, and acts: merge what's ready, dispatch coding agents (Codex or Claude) to fix what's failing, and escalate what needs human judgement. One command, all your projects, unmanned.
23
+ **Repo governor** — Carson enforces the repo's operating contract: worktree-first flow, Carson-owned delivery operations, policy checks, and exact recovery guidance when work cannot proceed.
22
24
 
23
25
  ```
24
26
  ~/.carson/ ← Carson lives here, never inside your repos
25
27
 
26
- ├─ hooks ──────────────► commit gates (every governed repo)
27
- └─ govern ─────────────► PR triage merge | dispatch agent | escalate
28
+ ├─ hooks ──────────────► commit gates and command guards
29
+ ├─ worktree flow ──────► creatework deliver clean up
30
+ └─ portfolio layer ────► status --all | refresh --all | govern
28
31
  ```
29
32
 
30
- This separation is Carson's defining trait — the **outsider boundary**: no Carson scripts, config files, or governance payloads are ever placed inside a governed repository.
31
-
32
- **Agent workspace management** — `carson worktree create` and `carson worktree remove` give coding agents safe, isolated workspaces. Unlike Claude Code's built-in `EnterWorktree`, Carson auto-syncs main before branching, guards against removing worktrees with unpushed work or an active shell inside, detects squash/rebase merges so removal doesn't falsely block, and cleans up the local and remote branch in one step. The two tools are complementary — see `MANUAL.md § Carson vs Claude Code EnterWorktree` for the full comparison.
33
-
34
- ### The Governance Loop
35
-
36
- Carson orchestrates a closed governance loop across two layers:
37
-
38
- 1. **CI enforcement** — Carson's `audit` gates on CI check status reported by GitHub. The actual CI runs are delegated to GitHub Actions.
39
- 2. **Autonomous triage** — `carson govern` reads CI status, review disposition, and audit health for every open PR. Ready PRs are merged. Failing PRs get a coding agent (Codex or Claude) dispatched to fix them. Stuck PRs are escalated.
33
+ The outsider boundary still matters: Carson governs repositories without becoming a runtime dependency inside them.
40
34
 
41
- Carson's role is governance orchestration — gating on results and dispatching action. The actual CI runs and code fixes are delegated to specialised tools: GitHub Actions for CI and coding agents for remediation.
35
+ ## Two Authorities
42
36
 
43
- ### Principles
37
+ Each governed repo chooses one integration authority.
44
38
 
45
- Carson is opinionated about governance. These are non-negotiable principles, not configurable defaults:
39
+ **Remote** — remote `main` is the integration authority. Agents still work in local worktrees, but completed work rejoins through remote `main`.
46
40
 
47
- - **Outsider boundary** — Carson lives outside your repo, never inside. No Carson-owned artefacts in your repository. Offboarding leaves no trace.
48
- - **Active review** — undisposed reviewer findings block merge. Feedback must be acknowledged, not buried.
49
- - **Self-diagnosing output** — every warning and error names what went wrong, why, and what to do next. If you have to read source code to understand a message, that message is a bug.
50
- - **Transparent governance** — Carson prepares everything for merge but never oversteps. It does not make decisions for you without telling you.
41
+ **Local** — local `main` is the integration authority. Agents still work in local worktrees, but completed work rejoins through local `main`, then `main` is pushed to the remote as backup.
51
42
 
52
- Everything else bends to your preference. Which branch is main, how PRs are merged, which repositories to govern, which coding agent to dispatch Carson asks during setup and remembers. Sensible defaults are provided; you only change what matters to you. See `MANUAL.md` for the full list.
43
+ This is about where completed work rejoins shared truth, not about team size. Both authorities use worktrees. The authority changes how work lands, not whether Carson is needed.
53
44
 
54
- ## When to Use Carson
45
+ ## Principles
55
46
 
56
- - **You run coding agents across multiple repositories** and need a single command that triages every open PR, merges what's ready, dispatches agents to fix what's broken, and reports what needs your attention.
57
- - **Your PR feedback gets buried.** Carson blocks merge until every reviewer comment is explicitly acknowledged accepted, rejected, or deferred so nothing is silently ignored.
58
- - **CI breaks and nobody notices.** `carson audit` runs on every commit via managed hooks, and `carson govern` watches CI status across your portfolio continuously.
59
- - **You onboard new repositories often** and want consistent hooks, templates, and governance from the first commit without manual setup.
60
- - **You want agent-safe worktree management.** `carson worktree create` auto-syncs, branches, and isolates; `carson worktree remove` guards against unpushed work and active shells before cleanup.
47
+ - **Worktree-first** substantive work happens in worktrees, not on `main`.
48
+ - **Carson-owned operations**Carson owns worktree and delivery operations in governed repositories.
49
+ - **Self-diagnosing output** every block should say what happened and the exact next command.
50
+ - **Outsider boundary** Carson governs repositories without becoming a host-repository runtime dependency.
61
51
 
62
52
  ## Quickstart
63
53
 
64
- Prerequisites: Ruby `>= 3.4`, `git`, and `gem` in your PATH. `gh` (GitHub CLI) is recommended for full review governance features.
54
+ Prerequisites: Ruby `>= 3.4`, `git`, and `gem` in your `PATH`. `gh` (GitHub CLI) is recommended for review governance features.
65
55
 
66
56
  ```bash
67
57
  gem install carson
68
- ```
58
+ carson onboard your/repo/path
69
59
 
70
- **Onboard a repository:**
60
+ carson worktree create your-worktree
61
+ cd your/repo/path/.claude/worktrees/your-worktree
71
62
 
72
- ```bash
73
- carson onboard /path/to/your-repo
74
- ```
63
+ # work, test, commit
64
+ carson deliver
65
+ carson status
75
66
 
76
- On first run, Carson walks you through setup — remote, main branch, workflow style, merge method — then installs hooks, syncs templates, and runs an initial audit.
67
+ # keep govern running to advance queued deliveries
68
+ carson govern --loop 300
69
+ ```
77
70
 
78
- After `carson onboard`, your repository has:
79
- - Git hooks that run `carson audit` on every commit.
80
- - Managed `.github/*` templates synchronised from Carson.
81
- - An initial governance audit report.
71
+ By default, repositories onboard as `remote`. `carson deliver` is the branch handoff: it pushes the branch, creates or refreshes the PR, records delivery state, and returns immediately. `carson status` shows the active branch deliveries, and `carson govern` advances queued work across the governed portfolio.
82
72
 
83
- Commit the generated `.github/*` changes, and the repository is governed.
73
+ ## Portfolio Layer
84
74
 
85
- **Govern your portfolio.** Once repositories are onboarded, `carson govern` is your recurring command. Run it whenever you want Carson to triage open PRs, enforce review policy, and dispatch coding agents across all governed repos:
75
+ Single-repo depth comes first. Once multiple repositories are onboarded, the same discipline scales out across them:
86
76
 
87
77
  ```bash
88
- carson govern --dry-run # preview what Carson would do, change nothing
89
- carson govern # triage PRs, merge ready ones, dispatch agents
90
- carson govern --loop 300 # run continuously, cycling every 5 minutes
78
+ carson status --all
79
+ carson refresh --all
80
+ carson govern --dry-run
91
81
  ```
92
82
 
83
+ `carson govern` is the portfolio layer. It advances queued deliveries, dispatches revision work for blocked branches, and surfaces what needs human judgement. Governed integration is squash-only and happens one repository at a time.
84
+
93
85
  ## Where to Read Next
94
86
 
95
- - **MANUAL.md** — installation, first-time setup, CI configuration, daily operations, full command reference, troubleshooting.
87
+ - **MANUAL.md** — installation, setup, operating strategies, daily workflows, command reference, troubleshooting.
96
88
  - **API.md** — formal interface contract: commands, exit codes, configuration schema.
97
89
 
98
90
  ## Support
data/RELEASE.md CHANGED
@@ -5,6 +5,29 @@ Release-note scope rule:
5
5
  - `RELEASE.md` records only version deltas, breaking changes, and migration actions.
6
6
  - Operational usage guides live in `MANUAL.md` and `API.md`.
7
7
 
8
+ ## 3.23.0
9
+
10
+ ### What changed
11
+
12
+ - **Single-actor branch delivery redesign** — Carson is now the sole actor. Repository and branch state are recorded in a SQLite delivery ledger, `carson deliver` becomes the asynchronous branch handoff, and `carson govern` advances queued deliveries and revision cycles without blocking the caller process.
13
+ - **Status redesigned around deliveries** — `carson status` now reports repository authority, the current branch, active deliveries, and stale-branch counts. `--json` exposes the same delivery-centred model explicitly for software consumers.
14
+ - **Governed integration is squash-only** — Carson now enforces a single governed integration policy. Repository settings must allow squash merge, and Carson rejects governed configs that specify any other merge method.
15
+ - **Setup and help contract simplified** — `carson setup` no longer offers merge-method choice for governed repositories, and `carson deliver --merge` is removed in favour of the single autonomous `carson deliver` path.
16
+
17
+ ### Migration required
18
+
19
+ - Set governed repositories to allow squash merge before using Carson-governed integration.
20
+ - Update Carson config so `govern.merge.method` is `squash`.
21
+ - Stop using `carson deliver --merge`; use `carson deliver`.
22
+
23
+ ## 3.22.1
24
+
25
+ ### What changed
26
+
27
+ - **Template sync moved into deliver** — `deliver!` now runs `template_apply!` before push, restoring template drift detection that was lost when 3.21.0 added `--no-verify` to `push_branch!`. The pre-push hook's `template apply --push-prep` block was silently skipped; managed files with drifted content could reach the remote undetected. Canonical content is now written and committed automatically before the push.
28
+
29
+ ### No migration required
30
+
8
31
  ## 3.22.0
9
32
 
10
33
  ### What changed
@@ -31,7 +54,7 @@ Release-note scope rule:
31
54
  ### What changed
32
55
 
33
56
  - **Command guard for governed repositories** — Carson now detects and blocks raw `git push` and `gh pr create/merge` commands in governed repos, redirecting agents to `carson deliver` instead. Three enforcement layers:
34
- - **Pre-push hook** — blocks raw `git push` in governed repos. Carson sets `CARSON_PUSH=1` internally so its own pushes pass through.
57
+ - **Pre-push hook** — blocks raw `git push` unconditionally in governed repos. Carson uses `--no-verify` internally to skip its own hook. *(Side effect: `--no-verify` also skips the hook's `template apply --push-prep` block — template sync moved into `deliver!` in a later release to restore coverage.)*
35
58
  - **Command guard script** — a Claude Code `PreToolUse` hook that intercepts `gh pr create` and `gh pr merge` Bash commands in governed repos.
36
59
  - **Existing pre-push guard** — the main/master branch push block now uses the same `BLOCKED` message format with explicit recovery guidance.
37
60
  - **`with_env_var` helper** — new Runtime utility for temporarily setting environment variables with guaranteed cleanup.
data/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Carson Skill
2
2
 
3
- You are working in a repository governed by Carson — a deterministic governance runtime. Carson handles git hooks, PR triage, agent dispatch, merge, and cleanup. You provide the intelligence; Carson provides the infrastructure.
3
+ You are working in a repository governed by Carson — an autonomous git strategist and repositories governor. Carson handles git hooks, PR triage, agent dispatch, merge, and cleanup. You provide the intelligence; Carson provides the infrastructure.
4
4
 
5
5
  ## When to use Carson commands
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.22.0
1
+ 3.23.0