carson 2.13.0 → 2.13.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbc67303ff1efe52235731586e0fb13830d943764edfb67119ff3b8cd5605102
4
- data.tar.gz: 6facbe0d10eebe0ef1f89d491799fa65d2993221574b1d3e7e898d82e3c0fc32
3
+ metadata.gz: 8d19271a17424021f6b4ef1ceabe73275feb47c54965175fbd5fbd1a2b6f869b
4
+ data.tar.gz: 8011d1e680ba9331e99bd8254b0b07605f64ed1856baa6a62b53ec1f6eb98c7c
5
5
  SHA512:
6
- metadata.gz: c606ed005e274ab872ccf9b50da945edcc8bffcf2a7e146679e0f6f9673c572d826a679e9575d9866a4c91ffe71ca648a89b415237cb63e97f7d023ffa05a453
7
- data.tar.gz: fc3e7c8ba85a437aafc643f498c381bb8f617ee71c5527b08462af993f1b94cbcf51dbfc9298dd45b3dee92dbfad45c611513e449114051878e4c8239e4b7c23
6
+ metadata.gz: 51be2370d394a2b83169b5ca543339a8949ec0a8cb969430e934d7a22977e3e085997c7d6f89006a7d128abb9a8f426c5f22327555a6d26f85c89c186eb25dc9
7
+ data.tar.gz: 9bc89f7a0f84f70d21c0a38ec5cca6b84d961ebab815bfb826f86a1316139915093f378fbbf8d52f9696d9445bacbe3d5677b3c78e14e6a9542b334128adfbb3
data/API.md CHANGED
@@ -98,38 +98,57 @@ Environment overrides:
98
98
  - `CARSON_REVIEW_SWEEP_STATES`
99
99
  - `CARSON_WORKFLOW_STYLE`
100
100
  - `CARSON_RUBY_INDENTATION`
101
- - `CARSON_LINT_COMMAND`
102
- - `CARSON_LINT_ENFORCEMENT`
103
101
  - `CARSON_LINT_POLICY_SOURCE`
102
+ - `CARSON_GOVERN_REPOS`
103
+ - `CARSON_GOVERN_MERGE_AUTHORITY`
104
+ - `CARSON_GOVERN_MERGE_METHOD`
105
+ - `CARSON_GOVERN_AGENT_PROVIDER`
106
+ - `CARSON_GOVERN_CHECK_WAIT`
107
+
108
+ `govern` schema:
109
+
110
+ ```json
111
+ {
112
+ "govern": {
113
+ "repos": ["~/Dev/project-a", "~/Dev/project-b"],
114
+ "agent": {
115
+ "provider": "auto",
116
+ "codex": {},
117
+ "claude": {}
118
+ },
119
+ "check_wait": 30,
120
+ "merge": {
121
+ "authority": false,
122
+ "method": "squash"
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ `govern` semantics:
129
+ - `repos`: list of local repo paths to govern (empty = current repo only).
130
+ - `agent.provider`: `"auto"`, `"codex"`, or `"claude"`.
131
+ - `agent.codex` / `agent.claude`: provider-specific options (reserved).
132
+ - `check_wait`: seconds to wait for CI checks before classifying (default: `30`).
133
+ - `merge.authority`: `false` (default) — Carson does not merge until explicitly enabled.
134
+ - `merge.method`: `"squash"` (default), `"merge"`, or `"rebase"`.
104
135
 
105
136
  `lint` schema:
106
137
 
107
138
  ```json
108
139
  {
109
140
  "lint": {
110
- "command": "make lint",
111
- "enforcement": "strict",
112
141
  "policy_source": "wanghailei/lint.git"
113
142
  }
114
143
  }
115
144
  ```
116
145
 
117
146
  `lint` semantics:
118
- - `command`: string or array — local lint command executed during `carson audit`. If `null` (default), local lint is skipped.
119
- - `enforcement`: `"strict"` (default) blocks on lint failure; `"advisory"` warns but does not block.
120
147
  - `policy_source`: default source for `carson lint policy` when `--source` is not specified.
121
148
 
122
149
  Environment overrides:
123
- - `CARSON_LINT_COMMAND` — overrides `lint.command`.
124
- - `CARSON_LINT_ENFORCEMENT` — overrides `lint.enforcement`.
125
150
  - `CARSON_LINT_POLICY_SOURCE` — overrides `lint.policy_source`.
126
151
 
127
- Lint target file source precedence in `carson audit`:
128
- - staged files for local commit-time execution.
129
- - PR changed files in GitHub `pull_request` events.
130
- - full repository tracked files in GitHub non-PR events.
131
- - local working-tree changes as fallback.
132
-
133
152
  Private-source clone token for `carson lint policy`:
134
153
  - `CARSON_READ_TOKEN` (used when `--source` points to a private GitHub repository).
135
154
 
data/MANUAL.md CHANGED
@@ -27,7 +27,7 @@ carson version
27
27
 
28
28
  ### Step 1: Prepare your lint policy
29
29
 
30
- Carson distributes lint configuration files from a central policy source — a directory or git repository you control — into each governed repo's `.github/linters/` directory, where MegaLinter auto-discovers them.
30
+ Carson distributes lint configuration files from a central policy source — a directory or git repository you control — into each governed repo's `.github/linters/` directory, where MegaLinter auto-discovers them in CI.
31
31
 
32
32
  ```bash
33
33
  carson lint policy --source /path/to/your-policy-repo
@@ -35,6 +35,8 @@ carson lint policy --source /path/to/your-policy-repo
35
35
 
36
36
  After this command, `.github/linters/` contains your lint configs (`.rubocop.yml`, `biome.json`, `ruff.toml`, etc.). MegaLinter uses these in CI. Every governed repository gets the same rules — this is how Carson keeps lint consistent across languages.
37
37
 
38
+ Carson distributes policy; MegaLinter enforces it. Carson does not run linters itself — that responsibility belongs to MegaLinter in CI and to the developer's own local tooling.
39
+
38
40
  Options:
39
41
  - `--source <path-or-git-url>` — where to read policy files from (required).
40
42
  - `--ref <git-ref>` — branch or tag when `--source` is a git URL.
@@ -97,6 +99,17 @@ Notes:
97
99
  - `CARSON_READ_TOKEN` must have read access to your policy source repository so CI can run `carson lint policy`.
98
100
  - The reusable workflow installs a pinned RuboCop gem before `carson audit`; mirror the same pin in host governance workflows for deterministic checks.
99
101
 
102
+ ### MegaLinter in CI
103
+
104
+ Carson manages a MegaLinter workflow template (`carson-lint.yml`) that is applied to governed repositories via `carson template apply`. MegaLinter auto-discovers lint configs from `.github/linters/` — the same directory populated by `carson lint policy`. This means:
105
+
106
+ - **Policy source** (your central lint repo) defines the rules.
107
+ - **`carson lint policy`** distributes the rules into each repo.
108
+ - **MegaLinter** (in GitHub Actions) enforces the rules.
109
+ - **`carson govern`** reads CI check status (including MegaLinter results) and acts on it.
110
+
111
+ Carson's `audit` gates on CI check status reported by GitHub — it does not duplicate MegaLinter's work locally. If MegaLinter fails in CI, `carson govern` classifies the PR accordingly and can dispatch a coding agent to fix the issues.
112
+
100
113
  ## Daily Operations
101
114
 
102
115
  **Start of work:**
@@ -146,6 +159,12 @@ The loop is built-in and cross-platform — no cron, launchd, or Task Scheduler
146
159
 
147
160
  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.
148
161
 
162
+ ### Govern and Coding Agents
163
+
164
+ `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.
165
+
166
+ The agent provider is configurable via `govern.agent.provider` (`auto`, `codex`, or `claude`). In `auto` mode, Carson selects the first available provider.
167
+
149
168
  ## Merge Method and Linear History
150
169
 
151
170
  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`:
@@ -181,7 +200,7 @@ Carson's `govern.merge.method` controls how `carson govern` merges ready PRs. Th
181
200
  These define what Carson *is*. They are not configurable.
182
201
 
183
202
  - **Outsider boundary** — Carson never places its own artefacts inside a governed repository.
184
- - **Centralised lint** — one policy source distributed into each repo's `.github/linters/`, zero per-repo drift.
203
+ - **Centralised lint** — one policy source distributed into each repo's `.github/linters/`, zero per-repo drift. MegaLinter enforces it in CI.
185
204
  - **Active review** — undisposed reviewer findings block merge; feedback must be acknowledged.
186
205
  - **Self-diagnosing output** — every message names the cause and the fix.
187
206
  - **Transparent governance** — Carson prepares everything for merge but never makes decisions without telling you.
@@ -332,9 +351,6 @@ carson template apply
332
351
  carson template check
333
352
  ```
334
353
 
335
- **Audit blocks on lint failure**
336
- - If `lint.command` is configured and fails, audit blocks (in `strict` mode) or warns (in `advisory` mode). Fix the lint issues and re-run `carson audit`.
337
-
338
354
  **Hook version mismatch after upgrade**
339
355
  - Run `carson refresh` to re-apply hooks and templates for the new Carson version.
340
356
  - Run `carson refresh --all` to refresh all governed repositories at once.
data/README.md CHANGED
@@ -2,22 +2,26 @@
2
2
 
3
3
  # ⧓ Carson
4
4
 
5
+ *Carson at your service.*
6
+
5
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.
6
8
 
7
- ## The Problem
9
+ ## The Problem to Solve
10
+
11
+ Managing a growing portfolio of repositories is rewarding work — but the operational overhead scales faster than the code itself. Lint configs drift between repos, 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.
8
12
 
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.
13
+ Carson exists so you can focus on what matters buildingwhile governance runs itself.
10
14
 
11
15
  ## How Carson Works
12
16
 
13
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:
14
18
 
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.
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. Lint execution is handled entirely by MegaLinter in CI and by the developer's own local tooling — Carson distributes the shared lint configuration but does not run linters itself.
16
20
 
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.
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.
18
22
 
19
23
  ```
20
- ┌──────────────────────────────────────────────�┐
24
+ ┌──────────────────────────────────────────────┐
21
25
  │ Your workstation │
22
26
  │ │
23
27
  │ ~/.carson/ Carson config │
@@ -39,71 +43,27 @@ Carson is an autonomous governance runtime that lives on your workstation and in
39
43
 
40
44
  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.
41
45
 
46
+ ### The Governance Loop
47
+
48
+ Carson orchestrates a closed governance loop across three layers:
49
+
50
+ 1. **Policy distribution** — `carson lint policy` distributes shared lint configs from a central source into each repo's `.github/linters/`. This is the single source of truth for lint rules across all governed repositories.
51
+ 2. **CI enforcement** — MegaLinter runs in GitHub Actions (via the managed `carson-lint.yml` workflow) and auto-discovers configs from `.github/linters/`. Carson does not run linters — MegaLinter does. Carson's `audit` gates on CI check status reported by GitHub.
52
+ 3. **Autonomous triage** — `carson govern` reads CI status (including MegaLinter results), 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.
53
+
54
+ Carson's role is governance orchestration — distributing policy, gating on results, and dispatching action. The actual lint execution, CI runs, and code fixes are delegated to specialised tools: MegaLinter for linting, GitHub Actions for CI, and coding agents for remediation.
55
+
42
56
  ## Opinions
43
57
 
44
58
  Carson is opinionated about governance. These are non-negotiable principles, not configurable defaults:
45
59
 
46
60
  - **Outsider boundary** — Carson lives outside your repo, never inside. No Carson-owned artefacts in your repository. Offboarding leaves no trace.
47
- - **Centralised lint** — lint policy distributed from a central source into each repo's `.github/linters/`. One source of truth, zero drift.
61
+ - **Centralised lint** — lint policy distributed from a central source into each repo's `.github/linters/`. One source of truth, zero drift. MegaLinter enforces it in CI.
48
62
  - **Active review** — undisposed reviewer findings block merge. Feedback must be acknowledged, not buried.
49
63
  - **Self-diagnosing output** — every message names the cause and the fix. If you need to debug Carson's output, the output failed.
50
64
  - **Transparent governance** — Carson prepares everything for merge but never oversteps. It does not make decisions for you without telling you.
51
65
 
52
- Everything else workflow style, merge method, remote name, main branch is a configurable default chosen during `carson setup`. See `MANUAL.md` for the full list of defaults and why each was chosen.
53
-
54
- The data flow:
55
-
56
- 1. You maintain a **policy source** — a directory or git repository containing your lint config files (e.g. `.rubocop.yml`, `biome.json`, `ruff.toml`). `carson lint policy --source <repo>` copies these into each governed repo's `.github/linters/`, where MegaLinter auto-discovers them.
57
- 2. `carson onboard` installs git hooks, synchronises `.github/*` templates (including a MegaLinter CI workflow), and runs a first governance audit on a host repository.
58
- 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.
59
- 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**.
60
- 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.
61
-
62
- ## Commands at a Glance
63
-
64
- **Govern** — autonomous portfolio management:
65
-
66
- | Command | What it does |
67
- |---|---|
68
- | `carson govern` | Triage all open PRs: merge ready ones, dispatch agents for failures, escalate the rest. |
69
- | `carson govern --dry-run` | Show what Carson would do without taking action. |
70
- | `carson govern --loop SECONDS` | Run the govern cycle continuously, sleeping SECONDS between cycles. |
71
- | `carson housekeep` | Sync main + prune stale branches (also runs automatically after govern merges). |
72
-
73
- **Setup** — run once per machine or per repository:
74
-
75
- | Command | What it does |
76
- |---|---|
77
- | `carson lint policy --source <repo>` | Distribute lint configs from policy source into `.github/linters/`. |
78
- | `carson onboard` | One-command baseline: hooks + templates + first audit. |
79
- | `carson prepare` | Install or refresh Carson-managed global hooks. |
80
- | `carson refresh` | Re-apply hooks, templates, and audit after upgrading Carson. |
81
- | `carson refresh --all` | Refresh all governed repositories at once. |
82
- | `carson offboard` | Remove Carson from a repository. |
83
-
84
- **Daily** — regular development workflow:
85
-
86
- | Command | What it does |
87
- |---|---|
88
- | `carson audit` | Full governance check (also runs automatically on every commit). |
89
- | `carson sync` | Fast-forward local `main` from remote. |
90
- | `carson prune` | Remove stale local branches whose upstream is gone. |
91
- | `carson template check` | Detect drift between managed and host `.github/*` files. |
92
- | `carson template apply` | Repair drifted `.github/*` files. |
93
-
94
- **Review** — PR merge readiness:
95
-
96
- | Command | What it does |
97
- |---|---|
98
- | `carson review gate` | Block or approve merge based on unresolved review comments. |
99
- | `carson review sweep` | Scan recent PRs and update a tracking issue for late feedback. |
100
-
101
- **Info**:
102
-
103
- | Command | What it does |
104
- |---|---|
105
- | `carson version` | Print installed version. |
106
- | `carson inspect` | Verify Carson-managed hook installation and repository setup. |
66
+ Everything else bends to your preference. Which branch is main, how PRs are merged, which repositories to govern, which coding agent to dispatch, where your lint policy lives — Carson asks during setup and remembers. Sensible defaults are provided; you only change what matters to you. See `MANUAL.md` for the full list.
107
67
 
108
68
  ## Quickstart
109
69
 
@@ -111,7 +71,6 @@ Prerequisites: Ruby `>= 3.4`, `git`, and `gem` in your PATH.
111
71
  `gh` (GitHub CLI) is recommended for full review governance features.
112
72
 
113
73
  ```bash
114
- # Install
115
74
  gem install --user-install carson
116
75
  carson version
117
76
  ```
@@ -135,7 +94,7 @@ After `carson onboard`, your repository has:
135
94
 
136
95
  Commit the generated `.github/*` changes, and the repository is governed.
137
96
 
138
- **Daily workflow:**
97
+ **Run governance across your portfolio:**
139
98
 
140
99
  ```bash
141
100
  carson govern --dry-run # see what Carson would do across all repos
@@ -143,18 +102,9 @@ carson govern # triage PRs, merge ready ones, dispatch agents, hou
143
102
  carson govern --loop 300 # run continuously, cycling every 5 minutes
144
103
  ```
145
104
 
146
- Or the individual commands if you prefer manual control:
147
-
148
- ```bash
149
- carson audit # full governance check
150
- carson review gate # block or approve merge based on review status
151
- carson sync # fast-forward local main
152
- carson prune # clean up stale local branches
153
- ```
154
-
155
105
  ## Where to Read Next
156
106
 
157
- - **MANUAL.md** — installation, first-time setup, CI configuration, daily operations, troubleshooting.
107
+ - **MANUAL.md** — installation, first-time setup, CI configuration, daily operations, full command reference, troubleshooting.
158
108
  - **API.md** — formal interface contract: commands, exit codes, configuration schema.
159
109
  - **RELEASE.md** — version history and upgrade actions.
160
110
  - **docs/define.md** — product definition and scope.
data/RELEASE.md CHANGED
@@ -5,11 +5,35 @@ 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
- ## 2.13.0 — Refresh All Governed Repositories
8
+ ## 2.13.2Docs Refresh
9
+
10
+ ### What changed
11
+
12
+ - Updated `docs/define.md`: added missing in-scope commands (`govern`, `housekeep`, `refresh --all`, `lint policy`); corrected out-of-scope merge authority statement.
13
+ - Updated `docs/plan.md`: corrected test counts, added `prompt.rb` and `runtime_refresh_all_test.rb` to file structure, added `--loop SECONDS` and `refresh --all` to CLI section, updated delivery status.
14
+ - Updated `API.md`: added `govern` config schema and environment overrides.
15
+
16
+ ## 2.13.1 — Guided Governance Registration
17
+
18
+ ### What changed
19
+
20
+ - After `carson onboard`, Carson now prompts to register the repo for portfolio governance (`govern.repos`). Accept to include it in `carson refresh --all` and `carson govern`; decline to skip.
21
+ - Improved `refresh --all` guidance when no repos are configured — now directs users to `carson onboard`.
22
+
23
+ ## 2.13.0 — Refresh All + Strip Local Lint Execution
9
24
 
10
25
  ### What changed
11
26
 
12
27
  - **`carson refresh --all`** refreshes every governed repository in a single command. Iterates `govern.repos`, runs hooks + templates + audit on each, prints a per-repo summary line, and returns non-zero if any repo fails. Verbose mode streams full diagnostics per repo.
28
+ - **Removed `lint.command` and `lint.enforcement` config keys.** Local lint execution during `carson audit` has been removed. MegaLinter runs in CI and `carson govern` gates on CI check status — local lint execution was redundant. Carson now focuses on what makes it unique: **policy distribution** via `carson lint policy`. The `lint.policy_source` config key and `carson lint policy --source` command are unchanged.
29
+ - **Removed `CARSON_LINT_COMMAND` and `CARSON_LINT_ENFORCEMENT` environment overrides.**
30
+ - **Removed lint command and enforcement prompts from `carson setup`.**
31
+
32
+ ### Migration
33
+
34
+ 1. Remove `lint.command` and `lint.enforcement` from `~/.carson/config.json` if present — they are now ignored.
35
+ 2. Remove `CARSON_LINT_COMMAND` and `CARSON_LINT_ENFORCEMENT` from any CI or shell configuration.
36
+ 3. If you relied on local lint during audit, run your lint tool directly (e.g. `make lint`, `trunk check`) or let MegaLinter handle it in CI.
13
37
 
14
38
  ## 2.12.0 — Language-Agnostic Lint Policy Distribution + MegaLinter
15
39
 
data/SKILL.md CHANGED
@@ -33,7 +33,6 @@ When you see exit 2, do NOT bypass it. Read the output, fix the root cause, and
33
33
  Carson audit output is structured as labelled key-value lines prefixed with ⧓. Key sections:
34
34
 
35
35
  - **Working Tree** — staged/unstaged status.
36
- - **Local Lint Quality** — lint command result. `lint_command_status: ok` means clean.
37
36
  - **Main Sync Status** — whether local main matches remote. If ahead, reset drift before committing.
38
37
  - **Scope Integrity Guard** — checks that commits stay within a single business intent and scope group.
39
38
  - **Audit Result** — final verdict: `status: ok` (clean), `status: attention` (advisory, not blocking), `status: block` (must fix).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.13.0
1
+ 2.13.2
data/carson.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Carson::VERSION
8
8
  spec.authors = [ "Hailei Wang" ]
9
9
  spec.email = [ "wanghailei@users.noreply.github.com" ]
10
- spec.summary = "Autonomous governance runtime lint, review gates, PR triage, and merge across repositories."
11
- spec.description = "Carson lives outside the repositories it governs. On every commit it enforces centralised lint policy and scope checks. On PRs it gates merge on unresolved reviewer feedback, dispatches coding agents to fix CI failures, merges passing PRs, and housekeeps branches. Runs locally and in GitHub Actions."
10
+ spec.summary = "Autonomous repository governance — you write the code, Carson manages everything else."
11
+ spec.description = "Carson is a governance runtime that lives outside the repositories it governs — no Carson-owned artefacts in your repo. On every commit, managed hooks enforce centralised lint policy and review gates. At portfolio level, carson govern triages every open PR across your registered repositories: merge what's ready, dispatch coding agents to fix what's failing, escalate what needs human judgement. One command, all your projects, unmanned."
12
12
  spec.homepage = "https://github.com/wanghailei/carson"
13
13
  spec.license = "MIT"
14
14
  spec.required_ruby_version = ">= 3.4"
data/lib/carson/config.rb CHANGED
@@ -9,7 +9,7 @@ module Carson
9
9
  attr_accessor :git_remote
10
10
  attr_reader :main_branch, :protected_branches, :hooks_base_path, :required_hooks,
11
11
  :path_groups, :template_managed_files,
12
- :lint_command, :lint_enforcement, :lint_policy_source,
12
+ :lint_policy_source,
13
13
  :review_wait_seconds, :review_poll_seconds, :review_max_polls, :review_sweep_window_days,
14
14
  :review_sweep_states, :review_disposition_prefix, :review_risk_keywords,
15
15
  :review_tracking_issue_title, :review_tracking_issue_label, :review_bot_usernames,
@@ -51,8 +51,6 @@ module Carson
51
51
  "managed_files" => [ ".github/carson-instructions.md", ".github/copilot-instructions.md", ".github/CLAUDE.md", ".github/AGENTS.md", ".github/pull_request_template.md", ".github/workflows/carson-lint.yml" ]
52
52
  },
53
53
  "lint" => {
54
- "command" => nil,
55
- "enforcement" => "strict",
56
54
  "policy_source" => "wanghailei/lint.git"
57
55
  },
58
56
  "workflow" => {
@@ -168,10 +166,6 @@ module Carson
168
166
  advisory_names = env_string_array( key: "CARSON_AUDIT_ADVISORY_CHECK_NAMES" )
169
167
  audit[ "advisory_check_names" ] = advisory_names unless advisory_names.empty?
170
168
  lint = fetch_hash_section( data: copy, key: "lint" )
171
- lint_command_env = ENV.fetch( "CARSON_LINT_COMMAND", "" ).to_s.strip
172
- lint[ "command" ] = lint_command_env unless lint_command_env.empty?
173
- lint_enforcement_env = ENV.fetch( "CARSON_LINT_ENFORCEMENT", "" ).to_s.strip
174
- lint[ "enforcement" ] = lint_enforcement_env unless lint_enforcement_env.empty?
175
169
  lint_policy_source_env = ENV.fetch( "CARSON_LINT_POLICY_SOURCE", "" ).to_s.strip
176
170
  lint[ "policy_source" ] = lint_policy_source_env unless lint_policy_source_env.empty?
177
171
  style = fetch_hash_section( data: copy, key: "style" )
@@ -223,8 +217,6 @@ module Carson
223
217
 
224
218
  @template_managed_files = fetch_string_array( hash: fetch_hash( hash: data, key: "template" ), key: "managed_files" )
225
219
  lint_hash = fetch_hash( hash: data, key: "lint" )
226
- @lint_command = normalize_lint_command_setting( value: lint_hash[ "command" ] )
227
- @lint_enforcement = normalize_lint_enforcement( value: lint_hash.fetch( "enforcement", "strict" ) )
228
220
  @lint_policy_source = lint_hash.fetch( "policy_source", "" ).to_s.strip
229
221
 
230
222
  workflow_hash = fetch_hash( hash: data, key: "workflow" )
@@ -338,23 +330,6 @@ module Carson
338
330
  patterns
339
331
  end
340
332
 
341
- def normalize_lint_command_setting( value: )
342
- return nil if value.nil?
343
- return value.to_s.strip if value.is_a?( String )
344
- if value.is_a?( Array )
345
- parts = value.map { |entry| entry.to_s.strip }.reject( &:empty? )
346
- raise ConfigError, "lint.command array must contain at least one argument" if parts.empty?
347
- return parts
348
- end
349
- raise ConfigError, "lint.command must be a string, array, or null"
350
- end
351
-
352
- def normalize_lint_enforcement( value: )
353
- text = value.to_s.strip.downcase
354
- raise ConfigError, "lint.enforcement must be one of strict, advisory" unless [ "strict", "advisory" ].include?( text )
355
- text
356
- end
357
-
358
333
  def fetch_optional_boolean( hash:, key:, default:, key_path: nil )
359
334
  value = hash.fetch( key, default )
360
335
  return true if value == true
@@ -1,5 +1,4 @@
1
1
  require "cgi"
2
- require "open3"
3
2
 
4
3
  module Carson
5
4
  class Runtime
@@ -24,17 +23,6 @@ module Carson
24
23
  audit_concise_problems << "Hooks: mismatch — run carson prepare."
25
24
  end
26
25
  puts_verbose ""
27
- puts_verbose "[Local Lint Quality]"
28
- local_lint_quality = local_lint_quality_report
29
- if local_lint_quality.fetch( :status ) == "block"
30
- audit_state = "block"
31
- blocking_langs = local_lint_quality.fetch( :languages ).select { |l| l.fetch( :status ) == "block" }
32
- blocking_langs.each do |lang|
33
- exit_code = lang.fetch( :exit_code, 1 )
34
- audit_concise_problems << "Lint: #{lang.fetch( :language )} failed (exit #{exit_code})."
35
- end
36
- end
37
- puts_verbose ""
38
26
  puts_verbose "[Main Sync Status]"
39
27
  ahead_count, behind_count, main_error = main_sync_counts
40
28
  if main_error
@@ -71,7 +59,6 @@ module Carson
71
59
  audit_state = "attention" if audit_state == "ok" && scope_guard.fetch( :status ) == "attention"
72
60
  write_and_print_pr_monitor_report(
73
61
  report: monitor_report.merge(
74
- local_lint_quality: local_lint_quality,
75
62
  default_branch_baseline: default_branch_baseline,
76
63
  audit_status: audit_state
77
64
  )
@@ -162,217 +149,6 @@ module Carson
162
149
  report
163
150
  end
164
151
 
165
- # Enforces configured lint policy before governance passes.
166
- # Runs lint.command and gates on exit code. Skips when lint.command is not set.
167
- def local_lint_quality_report
168
- unless config.lint_command
169
- report = {
170
- status: "ok",
171
- skip_reason: "lint.command not configured",
172
- target_source: "none",
173
- target_files_count: 0,
174
- blocking_languages: 0,
175
- languages: []
176
- }
177
- puts_verbose "lint: SKIP (lint.command not configured)"
178
- return report
179
- end
180
-
181
- lint_command_report
182
- rescue StandardError => e
183
- report = {
184
- status: "block",
185
- skip_reason: e.message,
186
- target_source: "unknown",
187
- target_files_count: 0,
188
- blocking_languages: 0,
189
- languages: []
190
- }
191
- puts_line "BLOCK: local lint quality check failed (#{e.message})."
192
- report
193
- end
194
-
195
- # Runs the lint.command and returns a structured report.
196
- def lint_command_report
197
- target_files, target_source = lint_target_files
198
- advisory = config.lint_enforcement == "advisory"
199
- command_value = config.lint_command
200
- command_string = command_value.is_a?( Array ) ? command_value.join( " " ) : command_value.to_s
201
-
202
- report = {
203
- status: "ok",
204
- skip_reason: nil,
205
- target_source: target_source,
206
- target_files_count: target_files.count,
207
- blocking_languages: 0,
208
- languages: []
209
- }
210
- puts_verbose "lint_target_source: #{target_source}"
211
- puts_verbose "lint_target_files_total: #{target_files.count}"
212
- puts_verbose "lint_command: #{command_string}"
213
- puts_verbose "lint_enforcement: #{config.lint_enforcement}"
214
-
215
- args = command_string.split( /\s+/ )
216
- command_name = args.first.to_s.strip
217
- unless command_available_for_lint?( command_name: command_name )
218
- language_report = {
219
- language: "lint.command",
220
- enabled: true,
221
- status: "block",
222
- reason: "command not available: #{command_name}",
223
- file_count: target_files.count,
224
- files: target_files,
225
- command: args,
226
- config_files: [],
227
- exit_code: EXIT_BLOCK
228
- }
229
- report[ :languages ] << language_report
230
- report[ :status ] = advisory ? "ok" : "block"
231
- report[ :blocking_languages ] = advisory ? 0 : 1
232
- puts_verbose "lint_command_status: #{language_report.fetch( :status )}"
233
- puts_line "WARN: lint command not available: #{command_name}" if advisory
234
- return report
235
- end
236
-
237
- stdout_text, stderr_text, success, exit_code = local_command( *args )
238
- language_report = {
239
- language: "lint.command",
240
- enabled: true,
241
- status: success ? "ok" : "block",
242
- reason: success ? nil : summarise_command_output(
243
- stdout_text: stdout_text,
244
- stderr_text: stderr_text,
245
- fallback: "lint command failed"
246
- ),
247
- file_count: target_files.count,
248
- files: target_files,
249
- command: args,
250
- config_files: [],
251
- exit_code: exit_code
252
- }
253
- report[ :languages ] << language_report
254
-
255
- unless success
256
- if advisory
257
- report[ :status ] = "ok"
258
- puts_verbose "lint_command_status: advisory_warn (exit #{exit_code})"
259
- puts_line "WARN: lint command failed (exit #{exit_code}) — advisory mode, not blocking."
260
- else
261
- report[ :status ] = "block"
262
- report[ :blocking_languages ] = 1
263
- puts_verbose "lint_command_status: block (exit #{exit_code})"
264
- end
265
- else
266
- puts_verbose "lint_command_status: ok"
267
- end
268
-
269
- report
270
- end
271
-
272
- # File selection precedence:
273
- # 1) staged files for local commit-time execution
274
- # 2) PR changed files in GitHub pull_request events
275
- # 3) full repository tracked files in GitHub non-PR events
276
- # 4) local working-tree changed files as fallback
277
- def lint_target_files
278
- staged = existing_repo_files( paths: staged_files )
279
- return [ staged, "staged" ] unless staged.empty?
280
-
281
- if github_pull_request_event?
282
- files = lint_target_files_for_pull_request
283
- return [ files, "github_pull_request" ] unless files.nil?
284
- puts_verbose "WARN: unable to resolve pull request changed files; falling back to full repository files."
285
- end
286
-
287
- if github_actions_environment?
288
- return [ lint_target_files_for_non_pr_ci, "github_full_repository" ]
289
- end
290
-
291
- [ existing_repo_files( paths: changed_files ), "working_tree" ]
292
- end
293
-
294
- def lint_target_files_for_pull_request
295
- base_ref = ENV.fetch( "GITHUB_BASE_REF", "" ).to_s.strip
296
- return nil if base_ref.empty?
297
-
298
- remote_name = config.git_remote
299
- unless git_remote_exists?( remote_name: remote_name )
300
- remote_name = "origin" if git_remote_exists?( remote_name: "origin" )
301
- end
302
-
303
- _, _, fetch_success, = git_run( "fetch", "--no-tags", "--depth", "1", remote_name, base_ref )
304
- return nil unless fetch_success
305
-
306
- base = "#{remote_name}/#{base_ref}"
307
- stdout_text, _, success, = git_run(
308
- "diff", "--name-only", "--diff-filter=ACMRTUXB", "#{base}...HEAD"
309
- )
310
- return nil unless success
311
-
312
- paths = stdout_text.lines.map { |line| line.to_s.strip }.reject( &:empty? )
313
- existing_repo_files( paths: paths )
314
- end
315
-
316
- def lint_target_files_for_non_pr_ci
317
- stdout_text = git_capture!( "ls-files" )
318
- paths = stdout_text.lines.map { |line| line.to_s.strip }.reject( &:empty? )
319
- existing_repo_files( paths: paths )
320
- end
321
-
322
- def github_actions_environment?
323
- ENV.fetch( "GITHUB_ACTIONS", "" ).to_s.strip.casecmp( "true" ).zero?
324
- end
325
-
326
- def github_pull_request_event?
327
- return false unless github_actions_environment?
328
-
329
- event_name = ENV.fetch( "GITHUB_EVENT_NAME", "" ).to_s.strip
330
- [ "pull_request", "pull_request_target" ].include?( event_name )
331
- end
332
-
333
- def existing_repo_files( paths: )
334
- Array( paths ).map do |relative|
335
- next if relative.to_s.strip.empty?
336
- absolute = resolve_repo_path!( relative_path: relative, label: "lint target file #{relative}" )
337
- next unless File.file?( absolute )
338
- relative
339
- end.compact.uniq
340
- end
341
-
342
- def command_available_for_lint?( command_name: )
343
- return false if command_name.to_s.strip.empty?
344
-
345
- if command_name.include?( "/" )
346
- path = if command_name.start_with?( "~" )
347
- File.expand_path( command_name )
348
- elsif command_name.start_with?( "/" )
349
- command_name
350
- else
351
- File.expand_path( command_name, repo_root )
352
- end
353
- return File.executable?( path )
354
- end
355
- path_entries = ENV.fetch( "PATH", "" ).split( File::PATH_SEPARATOR )
356
- path_entries.any? do |entry|
357
- next false if entry.to_s.strip.empty?
358
- File.executable?( File.join( entry, command_name ) )
359
- end
360
- end
361
-
362
- # Local command runner for repository-context tools used by audit lint checks.
363
- def local_command( *args )
364
- stdout_text, stderr_text, status = Open3.capture3( *args, chdir: repo_root )
365
- [ stdout_text, stderr_text, status.success?, status.exitstatus ]
366
- end
367
-
368
- # Compacts command output to one-line diagnostics for audit logs and JSON report payloads.
369
- def summarise_command_output( stdout_text:, stderr_text:, fallback: )
370
- combined = [ stderr_text.to_s, stdout_text.to_s ].join( "\n" )
371
- lines = combined.lines.map { |line| line.to_s.strip }.reject( &:empty? )
372
- return fallback if lines.empty?
373
- lines.first( 12 ).join( " | " )
374
- end
375
-
376
152
  # Evaluates default-branch CI health so stale workflow drift blocks before merge.
377
153
  def default_branch_ci_baseline_report
378
154
  report = {
@@ -630,28 +406,6 @@ module Carson
630
406
  checks.fetch( :pending ).each { |entry| lines << "- #{entry.fetch( :workflow )} / #{entry.fetch( :name )} (#{entry.fetch( :state )}) #{entry.fetch( :link )}".strip }
631
407
  end
632
408
  lines << ""
633
- lines << "## Local Lint Quality"
634
- lint_quality = report[ :local_lint_quality ]
635
- if lint_quality.nil?
636
- lines << "- not available"
637
- else
638
- lines << "- Status: #{lint_quality.fetch( :status )}"
639
- lines << "- Skip reason: #{lint_quality.fetch( :skip_reason )}" unless lint_quality.fetch( :skip_reason ).nil?
640
- lines << "- Target source: #{lint_quality.fetch( :target_source )}"
641
- lines << "- Target files: #{lint_quality.fetch( :target_files_count )}"
642
- lines << "- Blocking languages: #{lint_quality.fetch( :blocking_languages )}"
643
- lines << ""
644
- lines << "### Language Results"
645
- if lint_quality.fetch( :languages ).empty?
646
- lines << "- none"
647
- else
648
- lint_quality.fetch( :languages ).each do |entry|
649
- lines << "- #{entry.fetch( :language )}: status=#{entry.fetch( :status )} files=#{entry.fetch( :file_count )} exit=#{entry.fetch( :exit_code )}"
650
- lines << " reason: #{entry.fetch( :reason )}" unless entry.fetch( :reason ).nil?
651
- end
652
- end
653
- end
654
- lines << ""
655
409
  lines << "## Default Branch CI Baseline"
656
410
  baseline = report[ :default_branch_baseline ]
657
411
  if baseline.nil?
@@ -188,7 +188,7 @@ module Carson
188
188
  puts_line ""
189
189
  puts_line "Onboarding #{repo_name}..."
190
190
 
191
- unless global_config_exists?
191
+ if !global_config_exists? || !git_remote_exists?( remote_name: config.git_remote )
192
192
  if self.in.respond_to?( :tty? ) && self.in.tty?
193
193
  setup_status = setup!
194
194
  return setup_status unless setup_status == EXIT_OK
@@ -251,7 +251,8 @@ module Carson
251
251
  def refresh_all!
252
252
  repos = config.govern_repos
253
253
  if repos.empty?
254
- puts_line "ERROR: no governed repositories configured. Add repos via carson setup or govern.repos in ~/.carson/config.json."
254
+ puts_line "No governed repositories configured."
255
+ puts_line " Run carson onboard in each repo to register."
255
256
  return EXIT_ERROR
256
257
  end
257
258
 
@@ -813,6 +814,9 @@ module Carson
813
814
  puts_line ""
814
815
  puts_line "Carson is ready. Workflow: #{config.workflow_style}"
815
816
  puts_line "Reconfigure anytime: carson setup"
817
+
818
+ prompt_govern_registration! if self.in.respond_to?( :tty? ) && self.in.tty?
819
+
816
820
  audit_status
817
821
  end
818
822
 
@@ -39,11 +39,6 @@ module Carson
39
39
  merge_choice = prompt_merge_method
40
40
  choices[ "govern.merge.method" ] = merge_choice unless merge_choice.nil?
41
41
 
42
- lint_command_choice = prompt_lint_command
43
- choices[ "lint.command" ] = lint_command_choice unless lint_command_choice.nil?
44
-
45
- lint_enforcement_choice = prompt_lint_enforcement
46
- choices[ "lint.enforcement" ] = lint_enforcement_choice unless lint_enforcement_choice.nil?
47
42
 
48
43
  write_setup_config( choices: choices )
49
44
  end
@@ -148,34 +143,6 @@ module Carson
148
143
  prompt_choice( options: options, default: 0 )
149
144
  end
150
145
 
151
- def prompt_lint_command
152
- puts_line ""
153
- puts_line "Lint command"
154
- options = [
155
- { label: "make lint", value: "make lint" },
156
- { label: "trunk check (Recommended)", value: "trunk check" },
157
- { label: "Other (enter command)", value: :other },
158
- { label: "Skip (no local lint)", value: nil }
159
- ]
160
- choice = prompt_choice( options: options, default: 1 )
161
-
162
- if choice == :other
163
- prompt_custom_value( label: "Lint command" )
164
- else
165
- choice
166
- end
167
- end
168
-
169
- def prompt_lint_enforcement
170
- puts_line ""
171
- puts_line "Lint enforcement"
172
- options = [
173
- { label: "strict — block on lint failure (default)", value: "strict" },
174
- { label: "advisory — warn but don't block", value: "advisory" }
175
- ]
176
- prompt_choice( options: options, default: 0 )
177
- end
178
-
179
146
  def prompt_choice( options:, default: )
180
147
  options.each_with_index do |option, index|
181
148
  puts_line " #{index + 1}) #{option.fetch( :label )}"
@@ -374,6 +341,56 @@ module Carson
374
341
  path = Config.global_config_path( repo_root: repo_root )
375
342
  !path.empty? && File.file?( path )
376
343
  end
344
+
345
+ # After onboard succeeds, offer to register the repo for portfolio governance.
346
+ def prompt_govern_registration!
347
+ expanded = File.expand_path( repo_root )
348
+ if config.govern_repos.include?( expanded )
349
+ puts_verbose "govern_registration: already registered #{expanded}"
350
+ return
351
+ end
352
+
353
+ puts_line ""
354
+ puts_line "Portfolio governance"
355
+ puts_line " Register this repo so carson refresh --all and carson govern include it?"
356
+ accepted = prompt_yes_no( default: true )
357
+ if accepted
358
+ append_govern_repo!( repo_path: expanded )
359
+ puts_line "Registered. Run carson refresh --all to keep all repos in sync."
360
+ else
361
+ puts_line "Skipped. Run carson onboard here again to register later."
362
+ end
363
+ end
364
+
365
+ # Reusable Y/n prompt following existing prompt_choice conventions.
366
+ def prompt_yes_no( default: true )
367
+ hint = default ? "Y/n" : "y/N"
368
+ out.print "#{BADGE} [#{hint}]: "
369
+ out.flush
370
+ raw = self.in.gets
371
+ return default if raw.nil?
372
+
373
+ input = raw.to_s.strip.downcase
374
+ return default if input.empty?
375
+
376
+ input.start_with?( "y" )
377
+ end
378
+
379
+ # Appends a repo path to govern.repos without replacing the array via deep_merge.
380
+ def append_govern_repo!( repo_path: )
381
+ config_path = Config.global_config_path( repo_root: repo_root )
382
+ return if config_path.empty?
383
+
384
+ existing_data = load_existing_config( path: config_path )
385
+ existing_data[ "govern" ] ||= {}
386
+ repos = Array( existing_data[ "govern" ][ "repos" ] )
387
+ repos << repo_path
388
+ existing_data[ "govern" ][ "repos" ] = repos.uniq
389
+
390
+ FileUtils.mkdir_p( File.dirname( config_path ) )
391
+ File.write( config_path, JSON.pretty_generate( existing_data ) )
392
+ reload_config_after_setup!
393
+ end
377
394
  end
378
395
 
379
396
  include Setup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carson
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.0
4
+ version: 2.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hailei Wang
@@ -9,10 +9,12 @@ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
- description: Carson lives outside the repositories it governs. On every commit it
13
- enforces centralised lint policy and scope checks. On PRs it gates merge on unresolved
14
- reviewer feedback, dispatches coding agents to fix CI failures, merges passing PRs,
15
- and housekeeps branches. Runs locally and in GitHub Actions.
12
+ description: 'Carson is a governance runtime that lives outside the repositories it
13
+ governs no Carson-owned artefacts in your repo. On every commit, managed hooks
14
+ enforce centralised lint policy and review gates. At portfolio level, carson govern
15
+ triages every open PR across your registered repositories: merge what''s ready,
16
+ dispatch coding agents to fix what''s failing, escalate what needs human judgement.
17
+ One command, all your projects, unmanned.'
16
18
  email:
17
19
  - wanghailei@users.noreply.github.com
18
20
  executables:
@@ -93,6 +95,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
95
  requirements: []
94
96
  rubygems_version: 4.0.3
95
97
  specification_version: 4
96
- summary: Autonomous governance runtime lint, review gates, PR triage, and merge
97
- across repositories.
98
+ summary: Autonomous repository governance — you write the code, Carson manages everything
99
+ else.
98
100
  test_files: []