carson 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f56a11a84e2d19363137153a34302874e8ad0941e4fb330012a1ec92a124eb6a
4
+ data.tar.gz: 060f8f8c2fbe673321255c32d6b064c674358908b4171a71cf778ab2215cf3aa
5
+ SHA512:
6
+ metadata.gz: 39c24b390c66d13428e7bede056a0465481759ec3abf64a380118c954c84705242645d772a3ecd9f52e85a9b61a33f27e345b641a7b8af63757d7fd8383904e4
7
+ data.tar.gz: 25612172dd0f5649f8fc54af37cba2a43727d3848caac284805ee0e3c7ba6b40da4ce9fedab8fd7cd780e05ff370862e2b03d0d259572f741b064df442af952d
@@ -0,0 +1,12 @@
1
+ ## Shared Governance Baseline
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).
@@ -0,0 +1,14 @@
1
+ ## Shared Scope and Validation
2
+
3
+ - [ ] `single_business_intent`: this PR is one coherent domain or feature intent.
4
+ - [ ] `single_scope_group`: non-doc files stay within one scope group.
5
+ - [ ] `cross-boundary_changes_justified`: any cross-boundary change has explicit rationale.
6
+ - [ ] `carson audit` before commit.
7
+ - [ ] `carson audit` before push.
8
+ - [ ] `gh pr list --state open --limit 50` checked at session start (capture competing active PRs).
9
+ - [ ] `gh pr list --state open --limit 50` re-checked immediately before merge decision.
10
+ - [ ] Required CI checks are passing.
11
+ - [ ] At least 60 seconds passed since the last push to allow AI reviewers to post.
12
+ - [ ] No unresolved required conversation threads at merge time.
13
+ - [ ] `carson review gate` passes with converged snapshots.
14
+ - [ ] Every actionable top-level review item has a `Disposition:` disposition (`accepted`, `rejected`, `deferred`) with the target review URL.
@@ -0,0 +1,90 @@
1
+ name: Carson policy reusable
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ carson_ref:
7
+ description: Carson repository ref to check out
8
+ required: false
9
+ type: string
10
+ default: main
11
+ carson_version:
12
+ description: Exact Carson gem version expected in VERSION
13
+ required: true
14
+ type: string
15
+ rubocop_version:
16
+ description: Exact RuboCop gem version installed before Carson audit.
17
+ required: false
18
+ type: string
19
+ default: "1.81.0"
20
+ secrets:
21
+ CARSON_READ_TOKEN:
22
+ description: Read token for private lint-policy source repository.
23
+ required: false
24
+
25
+ jobs:
26
+ governance:
27
+ name: Carson policy
28
+ runs-on: ubuntu-latest
29
+ permissions:
30
+ contents: read
31
+ pull-requests: read
32
+
33
+ steps:
34
+ - name: Checkout host repository
35
+ uses: actions/checkout@v4
36
+ with:
37
+ path: host
38
+ fetch-depth: 0
39
+
40
+ - name: Checkout Carson runtime
41
+ uses: actions/checkout@v4
42
+ with:
43
+ repository: wanghailei/carson
44
+ ref: ${{ inputs.carson_ref }}
45
+ path: carson
46
+
47
+ - name: Setup Ruby
48
+ uses: ruby/setup-ruby@v1
49
+ with:
50
+ ruby-version: "4.0"
51
+
52
+ - name: Validate expected version
53
+ run: |
54
+ actual="$(cat carson/VERSION)"
55
+ if [[ "$actual" != "${{ inputs.carson_version }}" ]]; then
56
+ echo "Expected Carson version ${{ inputs.carson_version }} but got ${actual}" >&2
57
+ exit 1
58
+ fi
59
+
60
+ - name: Install Carson gem from source checkout
61
+ run: |
62
+ cd carson
63
+ gem build carson.gemspec
64
+ gem install --local "carson-${{ inputs.carson_version }}.gem"
65
+
66
+ - name: Install pinned RuboCop
67
+ run: gem install rubocop -v "${{ inputs.rubocop_version }}" --no-document
68
+
69
+ - name: Align remote name for Carson
70
+ working-directory: host
71
+ run: |
72
+ if ! git remote get-url github >/dev/null 2>&1; then
73
+ git remote rename origin github
74
+ fi
75
+
76
+ - name: Carson audit
77
+ working-directory: host
78
+ env:
79
+ CARSON_READ_TOKEN: ${{ secrets.CARSON_READ_TOKEN }}
80
+ run: |
81
+ carson lint setup --source https://github.com/wanghailei/ai.git --ref main --force
82
+ carson hook
83
+ carson audit
84
+
85
+ - name: Carson review gate
86
+ working-directory: host
87
+ env:
88
+ GH_TOKEN: ${{ github.token }}
89
+ CARSON_PR_NUMBER: ${{ github.event.pull_request.number }}
90
+ run: carson review gate
data/API.md ADDED
@@ -0,0 +1,114 @@
1
+ # Carson API
2
+
3
+ This document defines Carson's user-facing interface contract for CLI commands, configuration inputs, and exit behaviour.
4
+
5
+ ## Command interface
6
+
7
+ Command form:
8
+
9
+ ```bash
10
+ carson <command> [subcommand] [arguments]
11
+ ```
12
+
13
+ Supported commands:
14
+
15
+ | Command | Purpose |
16
+ |---|---|
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
+ | `carson audit` | Evaluate governance status and generate report output. |
21
+ | `carson hook` | Install or refresh Carson-managed global hooks. |
22
+ | `carson check` | Run governance checks against current repository state. |
23
+ | `carson prune` | Remove stale local branches whose upstream refs no longer exist. |
24
+ | `carson template check` | Detect drift between managed templates and host `.github/*` files. |
25
+ | `carson template apply` | Write canonical managed template content into host `.github/*` files. |
26
+ | `carson lint setup --source <path-or-git-url> [--ref <git-ref>] [--force]` | Seed or refresh `~/AI/CODING` policy files from an explicit source. |
27
+ | `carson review gate` | Block until actionable review findings are resolved or convergence timeout is reached. |
28
+ | `carson review sweep` | Scan recent PR activity and update a rolling tracking issue for late actionable feedback. |
29
+ | `carson offboard [repo_path]` | Remove Carson-managed host artefacts and detach Carson hooks path where applicable. |
30
+
31
+ ## Exit status contract
32
+ - `0`: success
33
+ - `1`: runtime/configuration/command error
34
+ - `2`: policy blocked (hard stop)
35
+
36
+ Automation and CI integrations should treat exit `2` as an expected policy failure signal.
37
+
38
+ ## Repository boundary contract
39
+ Blocked Carson artefacts in host repositories:
40
+ - `.carson.yml`
41
+ - `bin/carson`
42
+ - `.tools/carson/*`
43
+
44
+ Allowed Carson-managed persistence in host repositories:
45
+ - selected GitHub-native files under `.github/*`
46
+
47
+ ## Configuration interface
48
+ Default global configuration path:
49
+ - `~/.carson/config.json`
50
+
51
+ Override path:
52
+ - `CARSON_CONFIG_FILE=/absolute/path/to/config.json`
53
+
54
+ Environment overrides:
55
+ - `CARSON_HOOKS_BASE_PATH`
56
+ - `CARSON_REVIEW_WAIT_SECONDS`
57
+ - `CARSON_REVIEW_POLL_SECONDS`
58
+ - `CARSON_REVIEW_MAX_POLLS`
59
+ - `CARSON_REVIEW_DISPOSITION_PREFIX`
60
+ - `CARSON_REVIEW_SWEEP_WINDOW_DAYS`
61
+ - `CARSON_REVIEW_SWEEP_STATES`
62
+ - `CARSON_RUBY_INDENTATION`
63
+
64
+ `lint.languages` schema:
65
+
66
+ ```json
67
+ {
68
+ "lint": {
69
+ "languages": {
70
+ "ruby": {
71
+ "enabled": true,
72
+ "globs": ["**/*.rb"],
73
+ "command": ["ruby", "/absolute/path/to/carson/lib/carson/policy/ruby/lint.rb", "{files}"],
74
+ "config_files": ["~/AI/CODING/rubocop.yml"]
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ `lint.languages` semantics:
82
+ - `enabled`: boolean toggle per language.
83
+ - `globs`: file-match patterns applied to the selected audit target set.
84
+ - `command`: argv array executed without shell interpolation.
85
+ - `config_files`: required files that must exist before lint runs.
86
+ - `{files}` token: replaced with matched files; if omitted, matched files are appended at the end of argv.
87
+ - Default Ruby policy source is `~/AI/CODING/rubocop.yml`; Ruby execution logic is Carson-owned.
88
+ - Client repositories containing repo-local `.rubocop.yml` are hard-blocked by `carson audit` in outsider mode.
89
+ - Non-Ruby language entries (`javascript`, `css`, `html`, `erb`) are present but disabled by default.
90
+
91
+ Lint target file source precedence in `carson audit`:
92
+ - staged files for local commit-time execution.
93
+ - PR changed files in GitHub `pull_request` events.
94
+ - full repository tracked files in GitHub non-PR events.
95
+ - local working-tree changes as fallback.
96
+
97
+ Private-source clone token for `carson lint setup`:
98
+ - `CARSON_READ_TOKEN` (used when `--source` points to a private GitHub repository).
99
+
100
+ Ruby source requirement for `carson lint setup` (when Ruby lint is enabled):
101
+ - `CODING/rubocop.yml` must exist in the source tree.
102
+
103
+ Policy layout requirement:
104
+ - Language policy files are stored directly under `CODING/` and copied to `~/AI/CODING/` without language subdirectories.
105
+
106
+ ## Output interface
107
+ Report output directory precedence:
108
+ - `~/.cache/carson`
109
+ - `TMPDIR/carson` (used when `HOME` is invalid and `TMPDIR` is absolute)
110
+ - `/tmp/carson` (fallback)
111
+
112
+ ## Versioning and compatibility
113
+ - Pin Carson in automation by explicit release and version pair (`carson_ref`, `carson_version`).
114
+ - Review upgrade actions in `RELEASE.md` before moving to a newer minor or major version.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hailei Wang (WHL) <wanghailei@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/MANUAL.md ADDED
@@ -0,0 +1,170 @@
1
+ # Carson Manual
2
+
3
+ This manual is for users who need to install Carson, configure repository governance, and run a stable daily operating cadence.
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)
10
+
11
+ ## Install Carson
12
+
13
+ Recommended installation path:
14
+
15
+ ```bash
16
+ gem install --user-install carson -v 1.0.0
17
+ ```
18
+
19
+ If `carson` is not found after installation:
20
+
21
+ ```bash
22
+ export PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
23
+ ```
24
+
25
+ Verify installation:
26
+
27
+ ```bash
28
+ carson version
29
+ ```
30
+
31
+ Expected result:
32
+ - Carson version is printed.
33
+ - The `carson` command is available in your shell.
34
+
35
+ ## Configure your first repository
36
+ Assume your repository path is `/local/path/of/repo`.
37
+
38
+ Prepare your global lint policy baseline first:
39
+
40
+ ```bash
41
+ carson lint setup --source /path/to/ai-policy-repo
42
+ ```
43
+
44
+ `lint setup` expects the source to contain `CODING/` and writes policy files to `~/AI/CODING/`.
45
+ For Ruby, the required policy file is `CODING/rubocop.yml`.
46
+ Language policy files are expected directly under `CODING/` (flat layout, no language subfolders).
47
+ Use `--ref <git-ref>` when `--source` is a git URL.
48
+ Use `--force` to overwrite existing `~/AI/CODING` files.
49
+
50
+ Audit policy notes:
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.
54
+
55
+ Run baseline initialisation:
56
+
57
+ ```bash
58
+ carson init /local/path/of/repo
59
+ ```
60
+
61
+ `init` performs:
62
+ - remote alignment using configured `git.remote` (default `github`)
63
+ - hook installation under `~/.carson/hooks/<version>/`
64
+ - repository `core.hooksPath` alignment to Carson global hooks
65
+ - commit-time governance gate via managed `pre-commit` hook
66
+ - managed `.github/*` template synchronisation
67
+ - initial governance audit
68
+
69
+ After `init`, commit generated `.github/*` changes in your repository.
70
+
71
+ ## Pin Carson in CI
72
+ Use the reusable workflow with explicit release pins:
73
+
74
+ ```yaml
75
+ name: Carson policy
76
+
77
+ on:
78
+ pull_request:
79
+
80
+ jobs:
81
+ governance:
82
+ uses: wanghailei/carson/.github/workflows/carson_policy.yml.8.1
83
+ secrets:
84
+ CARSON_READ_TOKEN: ${{ secrets.CARSON_READ_TOKEN }}
85
+ with:
86
+ carson_ref: "v1.0.0"
87
+ carson_version: "1.0.0"
88
+ rubocop_version: "1.81.0"
89
+ ```
90
+
91
+ When upgrading Carson, update both `carson_ref` and `carson_version` together.
92
+ `CARSON_READ_TOKEN` must have read access to `wanghailei/ai` so CI can run `carson lint setup`.
93
+ The reusable workflow installs a pinned RuboCop gem before `carson audit`; mirror the same pin in host governance workflows (including BOS) for deterministic checks.
94
+
95
+ ## Daily operations
96
+ Start of work:
97
+
98
+ ```bash
99
+ carson sync
100
+ carson lint setup --source /path/to/ai-policy-repo
101
+ carson audit
102
+ ```
103
+
104
+ Before push or PR update:
105
+
106
+ ```bash
107
+ carson audit
108
+ carson template check
109
+ ```
110
+
111
+ If template drift is detected:
112
+
113
+ ```bash
114
+ carson template apply
115
+ ```
116
+
117
+ Before merge recommendation:
118
+
119
+ ```bash
120
+ gh pr list --state open --limit 50
121
+ carson review gate
122
+ ```
123
+
124
+ Scheduled late-review monitoring:
125
+
126
+ ```bash
127
+ carson review sweep
128
+ ```
129
+
130
+ Local branch clean-up:
131
+
132
+ ```bash
133
+ carson prune
134
+ ```
135
+
136
+ ## Exit contract
137
+ - `0`: success
138
+ - `1`: runtime or configuration error
139
+ - `2`: policy blocked (hard stop)
140
+
141
+ Treat exit `2` as a mandatory stop until the policy violation is resolved.
142
+
143
+ ## Troubleshooting
144
+ `carson: command not found`
145
+ - Confirm Ruby and gem installation.
146
+ - Confirm `$(ruby -e 'print Gem.user_dir')/bin` is in `PATH`.
147
+
148
+ `review gate` fails on actionable comments
149
+ - Respond with a valid disposition comment using the required prefix.
150
+ - Re-run `carson review gate`.
151
+
152
+ Template drift blocks
153
+
154
+ ```bash
155
+ carson template apply
156
+ carson template check
157
+ ```
158
+
159
+ ## Offboard from a repository
160
+ To retire Carson from a repository:
161
+
162
+ ```bash
163
+ carson offboard /local/path/of/repo
164
+ ```
165
+
166
+ This removes Carson-managed host artefacts and unsets `core.hooksPath` when it points to Carson-managed global hooks.
167
+
168
+ ## Related documents
169
+ - Interface reference: `API.md`
170
+ - Release notes: `RELEASE.md`
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Carson
2
+
3
+ Carson is an outsider governance runtime for teams that need predictable GitHub policy controls without placing Carson-owned tooling inside client repositories.
4
+
5
+ ## Introduction
6
+ Repository governance often drifts over time: local protections weaken, review actions are missed, and policy checks become inconsistent between contributors.
7
+ Carson solves this by running from your workstation or CI, applying a deterministic governance baseline, and managing only selected GitHub-native policy files where necessary.
8
+ This model is effective because ownership stays explicit: Carson runtime assets remain outside host repositories, while merge authority remains with GitHub branch protection and human review.
9
+
10
+ ## Quickstart
11
+ Prerequisites:
12
+ - Ruby `>= 4.0`
13
+ - `gem` and `git` available in `PATH`
14
+ - `gh` available in `PATH` for PR/check reporting (recommended, not required for core local commands)
15
+
16
+ ```bash
17
+ gem install --user-install carson -v 1.0.0
18
+ carson version
19
+ carson lint setup --source /path/to/ai-policy-repo
20
+ carson init /local/path/of/repo
21
+ ```
22
+
23
+ Expected result:
24
+ - `carson version` prints `1.0.0` (or newer).
25
+ - `carson lint setup` seeds `~/AI/CODING` from your explicit source.
26
+ - Ruby lint policy data is sourced from `~/AI/CODING/rubocop.yml`; Ruby lint execution stays Carson-owned.
27
+ - Policy files live directly under `~/AI/CODING/` (no per-language subdirectories).
28
+ - `carson init` aligns remote naming, installs Carson-managed hooks, synchronises managed `.github/*` files, and runs an initial audit.
29
+ - Your repository is ready for daily governance commands.
30
+
31
+ ## Where to Read Next
32
+ - User manual: `MANUAL.md`
33
+ - API reference: `API.md`
34
+ - Release notes: `RELEASE.md`
35
+
36
+ ## Core Capabilities
37
+ - Outsider boundary enforcement that blocks Carson-owned host artefacts (`.carson.yml`, `bin/carson`, `.tools/carson/*`).
38
+ - Deterministic governance checks with stable exit codes for local and CI automation.
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`).
45
+
46
+ ## Support
47
+ - Open or track issues: <https://github.com/wanghailei/carson/issues>
48
+ - Review version-specific upgrade actions: `RELEASE.md`