carson 1.0.0 → 2.6.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.
- checksums.yaml +4 -4
- data/.github/copilot-instructions.md +1 -12
- data/.github/workflows/carson_policy.yml +1 -1
- data/API.md +50 -13
- data/MANUAL.md +140 -65
- data/README.md +140 -33
- data/RELEASE.md +350 -6
- data/SKILL.md +102 -0
- data/VERSION +1 -1
- data/carson.gemspec +3 -1
- data/{assets/hooks → hooks}/pre-commit +1 -1
- data/{assets/hooks → hooks}/pre-merge-commit +4 -0
- data/{assets/hooks → hooks}/pre-push +4 -0
- data/{assets/hooks → hooks}/prepare-commit-msg +4 -0
- data/icon.svg +651 -0
- data/lib/carson/adapters/agent.rb +15 -0
- data/lib/carson/adapters/claude.rb +45 -0
- data/lib/carson/adapters/codex.rb +45 -0
- data/lib/carson/adapters/prompt.rb +60 -0
- data/lib/carson/cli.rb +65 -20
- data/lib/carson/config.rb +100 -14
- data/lib/carson/policy/ruby/lint.rb +1 -1
- data/lib/carson/runtime/audit.rb +33 -10
- data/lib/carson/runtime/govern.rb +641 -0
- data/lib/carson/runtime/lint.rb +3 -3
- data/lib/carson/runtime/local.rb +51 -12
- data/lib/carson/runtime/review/gate_support.rb +14 -1
- data/lib/carson/runtime/review.rb +3 -3
- data/lib/carson/runtime.rb +10 -3
- data/lib/carson.rb +9 -0
- data/templates/.github/AGENTS.md +1 -0
- data/templates/.github/CLAUDE.md +1 -0
- data/templates/.github/carson-instructions.md +12 -0
- data/templates/.github/copilot-instructions.md +1 -12
- metadata +15 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd6dd1f0f0879b5838bc8d808261e44c408b4796ca85dcdd96f6885e397fd109
|
|
4
|
+
data.tar.gz: 0313e015a232d3eb29b46c16567457ac5403d83f0bcd062f42d4a9efd374d22b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7932b95b9798bd6935e5fc1f4f21962e31ebc473863e802f3870691e1613e00eaef5daa035239f6041d45750a6fb3fd85d29a8b72aa95285edcfbf9922992707
|
|
7
|
+
data.tar.gz: 5ed203aa2b53d844cd71b2496c45de3abed272ce765d590e7695314e29c8b2affbe79cd59ee86286adaa1118696438448b0079da97107e30dd5d5d21fb0b83c2
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
- GitHub rulesets and required checks are merge authority.
|
|
4
|
-
- Carson runs as an outsider runtime for hook health, main sync, scope integrity, and gh visibility.
|
|
5
|
-
- Before commit and before push, run `carson audit`.
|
|
6
|
-
- At session start and again immediately before merge recommendation, run `gh pr list --state open --limit 50` and re-confirm active PR priorities.
|
|
7
|
-
- Before merge recommendation, run `carson review gate`; it enforces warm-up wait, unresolved-thread convergence, and `Disposition:` dispositions for actionable top-level findings.
|
|
8
|
-
- Actionable findings are unresolved review threads, any non-author `CHANGES_REQUESTED` review, or non-author comments/reviews with risk keywords (`bug`, `security`, `incorrect`, `block`, `fail`, `regression`).
|
|
9
|
-
- `Disposition:` dispositions must include one token (`accepted`, `rejected`, `deferred`) and the target review URL.
|
|
10
|
-
- Scheduled governance runs `carson review sweep` every 8 hours to track late actionable review activity on recent open/closed PRs.
|
|
11
|
-
- Do not treat green checks or `mergeStateStatus: CLEAN` as sufficient if unresolved review threads remain.
|
|
12
|
-
- Never suggest destructive operations on protected refs (`main`/`master`, local or remote).
|
|
1
|
+
Read `.github/carson-instructions.md` for repository governance rules enforced by Carson.
|
data/API.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Carson API
|
|
2
2
|
|
|
3
3
|
This document defines Carson's user-facing interface contract for CLI commands, configuration inputs, and exit behaviour.
|
|
4
|
+
For operational usage and daily workflows, see `MANUAL.md`.
|
|
4
5
|
|
|
5
6
|
## Command interface
|
|
6
7
|
|
|
@@ -10,25 +11,53 @@ Command form:
|
|
|
10
11
|
carson <command> [subcommand] [arguments]
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
### Setup commands
|
|
15
|
+
|
|
16
|
+
| Command | Purpose |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `carson lint setup --source <path-or-git-url> [--ref <git-ref>] [--force]` | Seed or refresh `~/.carson/lint` policy files from an explicit source. |
|
|
19
|
+
| `carson onboard [repo_path]` | Apply one-command baseline setup for a target git repository. |
|
|
20
|
+
| `carson prepare` | Install or refresh Carson-managed global hooks. |
|
|
21
|
+
| `carson refresh [repo_path]` | Re-apply hooks, templates, and audit after upgrading Carson. |
|
|
22
|
+
| `carson offboard [repo_path]` | Remove Carson-managed host artefacts and detach Carson hooks path where applicable. |
|
|
23
|
+
|
|
24
|
+
### Daily commands
|
|
14
25
|
|
|
15
26
|
| Command | Purpose |
|
|
16
27
|
|---|---|
|
|
17
|
-
| `carson version` | Print installed Carson version. |
|
|
18
|
-
| `carson init [repo_path]` | Apply one-command baseline setup for a target git repository. |
|
|
19
|
-
| `carson sync` | Fast-forward local `main` from configured remote when tree is clean. |
|
|
20
28
|
| `carson audit` | Evaluate governance status and generate report output. |
|
|
21
|
-
| `carson
|
|
22
|
-
| `carson check` | Run governance checks against current repository state. |
|
|
29
|
+
| `carson sync` | Fast-forward local `main` from configured remote when tree is clean. |
|
|
23
30
|
| `carson prune` | Remove stale local branches whose upstream refs no longer exist. |
|
|
24
31
|
| `carson template check` | Detect drift between managed templates and host `.github/*` files. |
|
|
25
32
|
| `carson template apply` | Write canonical managed template content into host `.github/*` files. |
|
|
26
|
-
|
|
33
|
+
|
|
34
|
+
### Govern commands
|
|
35
|
+
|
|
36
|
+
| Command | Purpose |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `carson govern [--dry-run] [--json] [--loop SECONDS]` | Portfolio-level PR triage: classify, merge, dispatch agents, escalate. |
|
|
39
|
+
| `carson housekeep` | Sync main + prune stale branches (also runs automatically after govern merges). |
|
|
40
|
+
|
|
41
|
+
`--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.
|
|
42
|
+
|
|
43
|
+
`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, only `rebase` is accepted by GitHub — set `govern.merge.method` to `rebase` to match.
|
|
44
|
+
|
|
45
|
+
### Review commands
|
|
46
|
+
|
|
47
|
+
| Command | Purpose |
|
|
48
|
+
|---|---|
|
|
27
49
|
| `carson review gate` | Block until actionable review findings are resolved or convergence timeout is reached. |
|
|
28
50
|
| `carson review sweep` | Scan recent PR activity and update a rolling tracking issue for late actionable feedback. |
|
|
29
|
-
|
|
51
|
+
|
|
52
|
+
### Info commands
|
|
53
|
+
|
|
54
|
+
| Command | Purpose |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `carson version` | Print installed Carson version. |
|
|
57
|
+
| `carson inspect` | Verify Carson-managed hook installation and repository setup. |
|
|
30
58
|
|
|
31
59
|
## Exit status contract
|
|
60
|
+
|
|
32
61
|
- `0`: success
|
|
33
62
|
- `1`: runtime/configuration/command error
|
|
34
63
|
- `2`: policy blocked (hard stop)
|
|
@@ -36,15 +65,21 @@ Supported commands:
|
|
|
36
65
|
Automation and CI integrations should treat exit `2` as an expected policy failure signal.
|
|
37
66
|
|
|
38
67
|
## Repository boundary contract
|
|
68
|
+
|
|
39
69
|
Blocked Carson artefacts in host repositories:
|
|
40
70
|
- `.carson.yml`
|
|
41
71
|
- `bin/carson`
|
|
42
72
|
- `.tools/carson/*`
|
|
43
73
|
|
|
44
74
|
Allowed Carson-managed persistence in host repositories:
|
|
45
|
-
-
|
|
75
|
+
- `.github/carson-instructions.md` — governance baseline (source of truth)
|
|
76
|
+
- `.github/copilot-instructions.md` — agent discovery pointer for Copilot
|
|
77
|
+
- `.github/CLAUDE.md` — agent discovery pointer for Claude Code
|
|
78
|
+
- `.github/AGENTS.md` — agent discovery pointer for Codex
|
|
79
|
+
- `.github/pull_request_template.md` — PR template
|
|
46
80
|
|
|
47
81
|
## Configuration interface
|
|
82
|
+
|
|
48
83
|
Default global configuration path:
|
|
49
84
|
- `~/.carson/config.json`
|
|
50
85
|
|
|
@@ -71,7 +106,7 @@ Environment overrides:
|
|
|
71
106
|
"enabled": true,
|
|
72
107
|
"globs": ["**/*.rb"],
|
|
73
108
|
"command": ["ruby", "/absolute/path/to/carson/lib/carson/policy/ruby/lint.rb", "{files}"],
|
|
74
|
-
"config_files": ["
|
|
109
|
+
"config_files": ["~/.carson/lint/rubocop.yml"]
|
|
75
110
|
}
|
|
76
111
|
}
|
|
77
112
|
}
|
|
@@ -84,7 +119,7 @@ Environment overrides:
|
|
|
84
119
|
- `command`: argv array executed without shell interpolation.
|
|
85
120
|
- `config_files`: required files that must exist before lint runs.
|
|
86
121
|
- `{files}` token: replaced with matched files; if omitted, matched files are appended at the end of argv.
|
|
87
|
-
- Default Ruby policy source is
|
|
122
|
+
- Default Ruby policy source is `~/.carson/lint/rubocop.yml`; Ruby execution logic is Carson-owned.
|
|
88
123
|
- Client repositories containing repo-local `.rubocop.yml` are hard-blocked by `carson audit` in outsider mode.
|
|
89
124
|
- Non-Ruby language entries (`javascript`, `css`, `html`, `erb`) are present but disabled by default.
|
|
90
125
|
|
|
@@ -101,14 +136,16 @@ Ruby source requirement for `carson lint setup` (when Ruby lint is enabled):
|
|
|
101
136
|
- `CODING/rubocop.yml` must exist in the source tree.
|
|
102
137
|
|
|
103
138
|
Policy layout requirement:
|
|
104
|
-
- Language policy files are stored directly under `CODING/` and copied to
|
|
139
|
+
- Language policy files are stored directly under `CODING/` and copied to `~/.carson/lint/` without language subdirectories.
|
|
105
140
|
|
|
106
141
|
## Output interface
|
|
142
|
+
|
|
107
143
|
Report output directory precedence:
|
|
108
|
-
- `~/.cache
|
|
144
|
+
- `~/.carson/cache`
|
|
109
145
|
- `TMPDIR/carson` (used when `HOME` is invalid and `TMPDIR` is absolute)
|
|
110
146
|
- `/tmp/carson` (fallback)
|
|
111
147
|
|
|
112
148
|
## Versioning and compatibility
|
|
149
|
+
|
|
113
150
|
- Pin Carson in automation by explicit release and version pair (`carson_ref`, `carson_version`).
|
|
114
151
|
- Review upgrade actions in `RELEASE.md` before moving to a newer minor or major version.
|
data/MANUAL.md
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
# Carson Manual
|
|
2
2
|
|
|
3
|
-
This manual
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
- Ruby `>= 4.0`
|
|
7
|
-
- `gem` in `PATH`
|
|
8
|
-
- `git` in `PATH`
|
|
9
|
-
- `gh` in `PATH` (recommended for full review governance features)
|
|
3
|
+
This manual covers installation, first-time setup, CI configuration, and daily operations.
|
|
4
|
+
For the mental model and command overview, see `README.md`. For formal interface definitions, see `API.md`.
|
|
10
5
|
|
|
11
6
|
## Install Carson
|
|
12
7
|
|
|
13
|
-
|
|
8
|
+
Prerequisites: Ruby `>= 4.0`, `gem` and `git` in `PATH`. `gh` (GitHub CLI) recommended for full review governance.
|
|
14
9
|
|
|
15
10
|
```bash
|
|
16
|
-
gem install --user-install carson
|
|
11
|
+
gem install --user-install carson
|
|
17
12
|
```
|
|
18
13
|
|
|
19
14
|
If `carson` is not found after installation:
|
|
@@ -22,53 +17,53 @@ If `carson` is not found after installation:
|
|
|
22
17
|
export PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
|
|
23
18
|
```
|
|
24
19
|
|
|
25
|
-
Verify
|
|
20
|
+
Verify:
|
|
26
21
|
|
|
27
22
|
```bash
|
|
28
23
|
carson version
|
|
29
24
|
```
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
## First-Time Setup
|
|
27
|
+
|
|
28
|
+
### Step 1: Prepare your lint policy
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
Assume your repository path is `/local/path/of/repo`.
|
|
30
|
+
Carson enforces lint rules from a central policy source — a directory or git repository you control that contains a `CODING/` folder. For Ruby governance, the required file is `CODING/rubocop.yml`.
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
Run `lint setup` to copy policy files into `~/.carson/lint/`:
|
|
39
33
|
|
|
40
34
|
```bash
|
|
41
|
-
carson lint setup --source /path/to/
|
|
35
|
+
carson lint setup --source /path/to/your-policy-repo
|
|
42
36
|
```
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
After this command, `~/.carson/lint/rubocop.yml` exists and is ready for Carson to use. Every governed repository will reference these same policy files — this is how Carson keeps lint consistent.
|
|
39
|
+
|
|
40
|
+
Options:
|
|
41
|
+
- `--source <path-or-git-url>` — where to read policy files from (required).
|
|
42
|
+
- `--ref <git-ref>` — branch or tag when `--source` is a git URL.
|
|
43
|
+
- `--force` — overwrite existing `~/.carson/lint` files.
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
- Ruby lint policy data lives only in `~/AI/CODING/rubocop.yml`; execution logic is Carson-owned.
|
|
52
|
-
- Client repositories must not contain repo-local `.rubocop.yml`; `carson audit` blocks when it exists.
|
|
53
|
-
- Non-Ruby language entries remain configured but disabled by default.
|
|
45
|
+
Policy layout: language config files sit directly under `CODING/` (flat layout, no language subfolders). Non-Ruby entries are present but disabled by default.
|
|
54
46
|
|
|
55
|
-
|
|
47
|
+
### Step 2: Onboard a repository
|
|
56
48
|
|
|
57
49
|
```bash
|
|
58
|
-
carson
|
|
50
|
+
carson onboard /path/to/your-repo
|
|
59
51
|
```
|
|
60
52
|
|
|
61
|
-
`
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
53
|
+
`onboard` performs:
|
|
54
|
+
- Remote alignment using configured `git.remote` (default `github`).
|
|
55
|
+
- Hook installation under `~/.carson/hooks/<version>/`.
|
|
56
|
+
- Repository `core.hooksPath` alignment to Carson global hooks.
|
|
57
|
+
- Commit-time governance gate via managed `pre-commit` hook.
|
|
58
|
+
- Managed `.github/*` template synchronisation.
|
|
59
|
+
- Initial governance audit.
|
|
60
|
+
|
|
61
|
+
### Step 3: Commit generated files
|
|
62
|
+
|
|
63
|
+
After `onboard`, commit the generated `.github/*` changes in your repository. From this point the repository is governed.
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
## CI Setup
|
|
70
66
|
|
|
71
|
-
## Pin Carson in CI
|
|
72
67
|
Use the reusable workflow with explicit release pins:
|
|
73
68
|
|
|
74
69
|
```yaml
|
|
@@ -79,7 +74,7 @@ on:
|
|
|
79
74
|
|
|
80
75
|
jobs:
|
|
81
76
|
governance:
|
|
82
|
-
uses: wanghailei/carson/.github/workflows/carson_policy.yml.
|
|
77
|
+
uses: wanghailei/carson/.github/workflows/carson_policy.yml@v1.0.0
|
|
83
78
|
secrets:
|
|
84
79
|
CARSON_READ_TOKEN: ${{ secrets.CARSON_READ_TOKEN }}
|
|
85
80
|
with:
|
|
@@ -88,20 +83,22 @@ jobs:
|
|
|
88
83
|
rubocop_version: "1.81.0"
|
|
89
84
|
```
|
|
90
85
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
Notes:
|
|
87
|
+
- When upgrading Carson, update both `carson_ref` and `carson_version` together.
|
|
88
|
+
- `CARSON_READ_TOKEN` must have read access to your policy source repository so CI can run `carson lint setup`.
|
|
89
|
+
- The reusable workflow installs a pinned RuboCop gem before `carson audit`; mirror the same pin in host governance workflows for deterministic checks.
|
|
94
90
|
|
|
95
|
-
## Daily
|
|
96
|
-
|
|
91
|
+
## Daily Operations
|
|
92
|
+
|
|
93
|
+
**Start of work:**
|
|
97
94
|
|
|
98
95
|
```bash
|
|
99
|
-
carson sync
|
|
100
|
-
carson lint setup --source /path/to/
|
|
101
|
-
carson audit
|
|
96
|
+
carson sync # fast-forward local main
|
|
97
|
+
carson lint setup --source /path/to/your-policy-repo # refresh policy if needed
|
|
98
|
+
carson audit # full governance check
|
|
102
99
|
```
|
|
103
100
|
|
|
104
|
-
Before push or PR update
|
|
101
|
+
**Before push or PR update:**
|
|
105
102
|
|
|
106
103
|
```bash
|
|
107
104
|
carson audit
|
|
@@ -114,57 +111,135 @@ If template drift is detected:
|
|
|
114
111
|
carson template apply
|
|
115
112
|
```
|
|
116
113
|
|
|
117
|
-
Before merge
|
|
114
|
+
**Before merge:**
|
|
118
115
|
|
|
119
116
|
```bash
|
|
120
|
-
gh pr list --state open --limit 50
|
|
121
117
|
carson review gate
|
|
122
118
|
```
|
|
123
119
|
|
|
124
|
-
|
|
120
|
+
**Periodic maintenance:**
|
|
125
121
|
|
|
126
122
|
```bash
|
|
127
|
-
carson review sweep
|
|
123
|
+
carson review sweep # update tracking issue for late review feedback
|
|
124
|
+
carson prune # remove stale local branches
|
|
128
125
|
```
|
|
129
126
|
|
|
130
|
-
|
|
127
|
+
## Running Carson Govern Continuously
|
|
128
|
+
|
|
129
|
+
Use `--loop SECONDS` to run `carson govern` as a persistent daemon that cycles on a schedule:
|
|
131
130
|
|
|
132
131
|
```bash
|
|
133
|
-
carson
|
|
132
|
+
carson govern --loop 300 # cycle every 5 minutes
|
|
133
|
+
carson govern --loop 300 --dry-run # observe mode, no merges or dispatches
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
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.
|
|
137
|
+
|
|
138
|
+
Each cycle runs independently: if one cycle fails (network error, GitHub API timeout), the error is logged and the next cycle proceeds normally. Press `Ctrl-C` to stop — Carson exits cleanly with a cycle count summary.
|
|
139
|
+
|
|
140
|
+
## Merge Method and Linear History
|
|
141
|
+
|
|
142
|
+
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`:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"govern": {
|
|
147
|
+
"merge": {
|
|
148
|
+
"method": "squash"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
134
152
|
```
|
|
135
153
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
- `
|
|
139
|
-
- `
|
|
154
|
+
**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:
|
|
155
|
+
|
|
156
|
+
- `git log --oneline` on main tells the full story without merge noise or work-in-progress commits.
|
|
157
|
+
- Every commit is individually revertable — `git revert <sha>` undoes exactly one PR.
|
|
158
|
+
- `git bisect` operates on meaningful boundaries, not intermediate fixup commits.
|
|
159
|
+
- Individual branch commits are still preserved in the PR on GitHub for full traceability.
|
|
160
|
+
|
|
161
|
+
**When to use other methods:**
|
|
162
|
+
|
|
163
|
+
- `rebase` — if you want to preserve individual commits from the branch on main. Requires "Require linear history" in GitHub branch protection. GitHub rejects merge commits and squash merges when this is enabled.
|
|
164
|
+
- `merge` — if you want explicit merge commits. This creates a non-linear graph but preserves branch topology.
|
|
165
|
+
|
|
166
|
+
**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.
|
|
140
167
|
|
|
141
|
-
|
|
168
|
+
## Agent Discovery
|
|
169
|
+
|
|
170
|
+
Carson writes managed files that help interactive agents (Claude Code, Codex, Copilot) discover the governance system when they work in a governed repository.
|
|
171
|
+
|
|
172
|
+
**How it works:**
|
|
173
|
+
|
|
174
|
+
- `.github/carson-instructions.md` — the single source of truth containing the full governance baseline. This file tells agents what Carson is, what commands to run, and what rules to follow.
|
|
175
|
+
- `.github/CLAUDE.md` — read by Claude Code at session start. Points to `carson-instructions.md`.
|
|
176
|
+
- `.github/AGENTS.md` — read by Codex at session start. Points to `carson-instructions.md`.
|
|
177
|
+
- `.github/copilot-instructions.md` — read by GitHub Copilot. Points to `carson-instructions.md`.
|
|
178
|
+
|
|
179
|
+
Each agent reads its own expected filename and follows the reference to the shared baseline. One file to maintain, zero drift across agents.
|
|
180
|
+
|
|
181
|
+
All four files are managed templates — `carson template check` detects drift, `carson template apply` writes them, and `carson offboard` removes them.
|
|
182
|
+
|
|
183
|
+
**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.
|
|
184
|
+
|
|
185
|
+
## Configuration
|
|
186
|
+
|
|
187
|
+
Default global config path: `~/.carson/config.json`.
|
|
188
|
+
|
|
189
|
+
Precedence (highest wins): environment variables > config file > built-in defaults.
|
|
190
|
+
|
|
191
|
+
Override the config file path with `CARSON_CONFIG_FILE=/absolute/path/to/config.json`.
|
|
192
|
+
|
|
193
|
+
Common environment overrides:
|
|
194
|
+
|
|
195
|
+
| Variable | Purpose |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `CARSON_HOOKS_BASE_PATH` | Custom hooks installation directory. |
|
|
198
|
+
| `CARSON_REVIEW_WAIT_SECONDS` | Initial wait before first review poll. |
|
|
199
|
+
| `CARSON_REVIEW_POLL_SECONDS` | Interval between review polls. |
|
|
200
|
+
| `CARSON_REVIEW_MAX_POLLS` | Maximum review poll attempts. |
|
|
201
|
+
| `CARSON_REVIEW_DISPOSITION_PREFIX` | Required prefix for disposition comments. |
|
|
202
|
+
| `CARSON_REVIEW_SWEEP_WINDOW_DAYS` | Lookback window for review sweep. |
|
|
203
|
+
| `CARSON_REVIEW_SWEEP_STATES` | PR states to include in sweep. |
|
|
204
|
+
| `CARSON_RUBY_INDENTATION` | Ruby indentation policy (`tabs`, `spaces`, or `either`). |
|
|
205
|
+
|
|
206
|
+
For the full configuration schema and `lint.languages` definition, see `API.md`.
|
|
142
207
|
|
|
143
208
|
## Troubleshooting
|
|
144
|
-
|
|
209
|
+
|
|
210
|
+
**`carson: command not found`**
|
|
145
211
|
- Confirm Ruby and gem installation.
|
|
146
212
|
- Confirm `$(ruby -e 'print Gem.user_dir')/bin` is in `PATH`.
|
|
147
213
|
|
|
148
|
-
|
|
214
|
+
**`review gate` fails on actionable comments**
|
|
149
215
|
- Respond with a valid disposition comment using the required prefix.
|
|
150
216
|
- Re-run `carson review gate`.
|
|
151
217
|
|
|
152
|
-
Template drift blocks
|
|
218
|
+
**Template drift blocks**
|
|
153
219
|
|
|
154
220
|
```bash
|
|
155
221
|
carson template apply
|
|
156
222
|
carson template check
|
|
157
223
|
```
|
|
158
224
|
|
|
159
|
-
|
|
225
|
+
**Audit blocks on repo-local `.rubocop.yml`**
|
|
226
|
+
- Carson hard-blocks governed repositories that contain their own `.rubocop.yml`. Remove the repo-local file and rely on the central policy in `~/.carson/lint/rubocop.yml`.
|
|
227
|
+
|
|
228
|
+
**Hook version mismatch after upgrade**
|
|
229
|
+
- Run `carson refresh` to re-apply hooks and templates for the new Carson version.
|
|
230
|
+
|
|
231
|
+
## Offboard a Repository
|
|
232
|
+
|
|
160
233
|
To retire Carson from a repository:
|
|
161
234
|
|
|
162
235
|
```bash
|
|
163
|
-
carson offboard /
|
|
236
|
+
carson offboard /path/to/your-repo
|
|
164
237
|
```
|
|
165
238
|
|
|
166
239
|
This removes Carson-managed host artefacts and unsets `core.hooksPath` when it points to Carson-managed global hooks.
|
|
167
240
|
|
|
168
|
-
## Related
|
|
169
|
-
|
|
241
|
+
## Related Documents
|
|
242
|
+
|
|
243
|
+
- Mental model and command overview: `README.md`
|
|
244
|
+
- Formal interface contract: `API.md`
|
|
170
245
|
- Release notes: `RELEASE.md`
|
data/README.md
CHANGED
|
@@ -1,48 +1,155 @@
|
|
|
1
|
-
|
|
1
|
+
<img src="icon.svg" width="141" alt="Carson">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ⧓ Carson
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
If you govern more than a handful of repositories, you know the pattern: lint configs drift between repos, PR templates go stale, reviewer feedback gets quietly ignored, and what passes on a developer's laptop fails in CI. Across a portfolio of projects with coding agents producing many PRs, you become the bottleneck — manually checking results, dispatching fixes, clicking merge, and cleaning up.
|
|
10
|
+
|
|
11
|
+
## How Carson Works
|
|
12
|
+
|
|
13
|
+
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:
|
|
14
|
+
|
|
15
|
+
**Per-commit governance** — Carson enforces lint policy, 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.
|
|
16
|
+
|
|
17
|
+
**Portfolio-level autonomy** — `carson govern` is a scheduled triage loop that scans all your 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.
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌──────────────────────────────────────────────�┐
|
|
21
|
+
│ Your workstation │
|
|
22
|
+
│ │
|
|
23
|
+
│ ~/.carson/ Carson config │
|
|
24
|
+
│ ~/.carson/hooks/ Git hooks │
|
|
25
|
+
│ ~/.carson/lint/ Lint policy │
|
|
26
|
+
│ ~/.carson/cache/ Reports │
|
|
27
|
+
│ ~/.carson/govern/ Dispatch state │
|
|
28
|
+
│ │
|
|
29
|
+
│ carson govern ──► for each repo: │
|
|
30
|
+
│ 1. List open PRs (gh) │
|
|
31
|
+
│ 2. Classify: CI / review / audit status │
|
|
32
|
+
│ 3. Act: merge | dispatch agent | escalate │
|
|
33
|
+
│ 4. Housekeep: sync + prune │
|
|
34
|
+
│ │
|
|
35
|
+
│ Governed repos: repo-A/ repo-B/ repo-C/ │
|
|
36
|
+
│ .github/* templates (committed) │
|
|
37
|
+
│ core.hooksPath → ~/.carson/hooks │
|
|
38
|
+
└──────────────────────────────────────────────┘
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
The data flow:
|
|
44
|
+
|
|
45
|
+
1. You maintain a **policy source** — a directory or git repository containing your lint rules (e.g. `CODING/rubocop.yml`). Carson copies these to `~/.carson/lint/` via `carson lint setup`.
|
|
46
|
+
2. `carson init` installs git hooks, synchronises `.github/*` templates, and runs a first governance audit on a host repository.
|
|
47
|
+
3. From that point, every commit triggers `carson audit` through the managed `pre-commit` hook. The same `carson audit` runs in GitHub Actions. If it passes locally, it passes in CI.
|
|
48
|
+
4. `carson review gate` enforces review accountability: it blocks merge until every actionable reviewer comment has been formally acknowledged by the PR author through a **disposition comment**.
|
|
49
|
+
5. `carson govern` triages all open PRs across your portfolio. Ready PRs are merged and housekept. Failing PRs get a coding agent dispatched to fix them. Stuck PRs are escalated for your attention.
|
|
50
|
+
|
|
51
|
+
## Commands at a Glance
|
|
52
|
+
|
|
53
|
+
**Govern** — autonomous portfolio management:
|
|
54
|
+
|
|
55
|
+
| Command | What it does |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `carson govern` | Triage all open PRs: merge ready ones, dispatch agents for failures, escalate the rest. |
|
|
58
|
+
| `carson govern --dry-run` | Show what Carson would do without taking action. |
|
|
59
|
+
| `carson govern --loop SECONDS` | Run the govern cycle continuously, sleeping SECONDS between cycles. |
|
|
60
|
+
| `carson housekeep` | Sync main + prune stale branches (also runs automatically after govern merges). |
|
|
61
|
+
|
|
62
|
+
**Setup** — run once per machine or per repository:
|
|
63
|
+
|
|
64
|
+
| Command | What it does |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `carson lint setup` | Seed `~/.carson/lint/` from your policy source. |
|
|
67
|
+
| `carson onboard` | One-command baseline: hooks + templates + first audit. |
|
|
68
|
+
| `carson prepare` | Install or refresh Carson-managed global hooks. |
|
|
69
|
+
| `carson refresh` | Re-apply hooks, templates, and audit after upgrading Carson. |
|
|
70
|
+
| `carson offboard` | Remove Carson from a repository. |
|
|
71
|
+
|
|
72
|
+
**Daily** — regular development workflow:
|
|
73
|
+
|
|
74
|
+
| Command | What it does |
|
|
75
|
+
|---|---|
|
|
76
|
+
| `carson audit` | Full governance check (also runs automatically on every commit). |
|
|
77
|
+
| `carson sync` | Fast-forward local `main` from remote. |
|
|
78
|
+
| `carson prune` | Remove stale local branches whose upstream is gone. |
|
|
79
|
+
| `carson template check` | Detect drift between managed and host `.github/*` files. |
|
|
80
|
+
| `carson template apply` | Repair drifted `.github/*` files. |
|
|
81
|
+
|
|
82
|
+
**Review** — PR merge readiness:
|
|
83
|
+
|
|
84
|
+
| Command | What it does |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `carson review gate` | Block or approve merge based on unresolved review comments. |
|
|
87
|
+
| `carson review sweep` | Scan recent PRs and update a tracking issue for late feedback. |
|
|
88
|
+
|
|
89
|
+
**Info**:
|
|
90
|
+
|
|
91
|
+
| Command | What it does |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `carson version` | Print installed version. |
|
|
94
|
+
| `carson inspect` | Verify Carson-managed hook installation and repository setup. |
|
|
9
95
|
|
|
10
96
|
## Quickstart
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `gh` available in `PATH` for PR/check reporting (recommended, not required for core local commands)
|
|
97
|
+
|
|
98
|
+
Prerequisites: Ruby `>= 4.0`, `git`, and `gem` in your PATH.
|
|
99
|
+
`gh` (GitHub CLI) is recommended for full review governance features.
|
|
15
100
|
|
|
16
101
|
```bash
|
|
17
|
-
|
|
102
|
+
# Install
|
|
103
|
+
gem install --user-install carson
|
|
18
104
|
carson version
|
|
19
|
-
carson lint setup --source /path/to/ai-policy-repo
|
|
20
|
-
carson init /local/path/of/repo
|
|
21
105
|
```
|
|
22
106
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
107
|
+
**Prepare your lint policy.** A policy source is any directory (or git URL) that contains a `CODING/` folder with your lint configuration files. For Ruby, the required file is `CODING/rubocop.yml`. Carson copies these into `~/.carson/lint/` so that every governed repository uses the same rules:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
carson lint setup --source /path/to/your-policy-repo
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Onboard a repository:**
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
carson onboard /path/to/your-repo
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
After `carson onboard`, your repository has:
|
|
120
|
+
- Git hooks that run `carson audit` on every commit.
|
|
121
|
+
- Managed `.github/*` templates synchronised from Carson.
|
|
122
|
+
- An initial governance audit report.
|
|
123
|
+
|
|
124
|
+
Commit the generated `.github/*` changes, and the repository is governed.
|
|
125
|
+
|
|
126
|
+
**Daily workflow:**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
carson govern --dry-run # see what Carson would do across all repos
|
|
130
|
+
carson govern # triage PRs, merge ready ones, dispatch agents, housekeep
|
|
131
|
+
carson govern --loop 300 # run continuously, cycling every 5 minutes
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Or the individual commands if you prefer manual control:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
carson audit # full governance check
|
|
138
|
+
carson review gate # block or approve merge based on review status
|
|
139
|
+
carson sync # fast-forward local main
|
|
140
|
+
carson prune # clean up stale local branches
|
|
141
|
+
```
|
|
30
142
|
|
|
31
143
|
## Where to Read Next
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
- Ruby lint governance from `~/AI/CODING/rubocop.yml` with Carson-owned execution and deterministic local/CI blocking.
|
|
40
|
-
- Hard policy block when a client repository contains repo-local `.rubocop.yml`.
|
|
41
|
-
- Non-Ruby lint language entries remain present but disabled by default in this phase.
|
|
42
|
-
- Managed `.github/*` template synchronisation with drift detection and repair.
|
|
43
|
-
- Review governance controls (`review gate`, `review sweep`) for actionable feedback handling.
|
|
44
|
-
- Local branch hygiene and fast-forward sync workflow (`sync`, `prune`).
|
|
144
|
+
|
|
145
|
+
- **MANUAL.md** — installation, first-time setup, CI configuration, daily operations, troubleshooting.
|
|
146
|
+
- **API.md** — formal interface contract: commands, exit codes, configuration schema.
|
|
147
|
+
- **RELEASE.md** — version history and upgrade actions.
|
|
148
|
+
- **docs/define.md** — product definition and scope.
|
|
149
|
+
- **docs/design.md** — experience and brand design.
|
|
150
|
+
- **docs/develop.md** — contributor guide: architecture, development workflow.
|
|
45
151
|
|
|
46
152
|
## Support
|
|
153
|
+
|
|
47
154
|
- Open or track issues: <https://github.com/wanghailei/carson/issues>
|
|
48
155
|
- Review version-specific upgrade actions: `RELEASE.md`
|