@getcodesentinel/codesentinel 1.43.1 → 1.43.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.
- package/README.md +351 -293
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,81 +10,189 @@
|
|
|
10
10
|
<a href="https://getcodesentinel.github.io/codesentinel/"><img src="https://img.shields.io/badge/live%20report-GitHub%20Pages-222?logo=github" alt="Live report" /></a>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
**CODEOWNERS says who should know. This says who actually does — and what breaks when they leave.**
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
```bash
|
|
16
|
+
npx @getcodesentinel/codesentinel owners .
|
|
17
|
+
```
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
CodeSentinel reads `CODEOWNERS` and the repository's git history, and shows file by file whether the declared owner is the person who actually maintains the code: who is declared, who commits, where those two disagree, and which critical files have nobody. It runs offline on a local clone, needs no account, and is MIT licensed.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
[](https://getcodesentinel.github.io/codesentinel/#change-ownership)
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
This is this repository's own HTML report (`report --format html`). The live copy, rebuilt on every push to `main`, is at <https://getcodesentinel.github.io/codesentinel/>.
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
## What it finds
|
|
26
|
+
|
|
27
|
+
The command above, run on this repository at `0601b86` (302 tracked files, one `CODEOWNERS` entry, 90-day window, minimum two commits per file). Console output, trimmed to the summary block:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
Ownership audit — 302 tracked files, window 90d, ref HEAD
|
|
31
|
+
CODEOWNERS .github/CODEOWNERS · 1 entry · 0 invalid lines
|
|
32
|
+
|
|
33
|
+
Declared coverage: 100% (302/302)
|
|
34
|
+
Critical coverage: 100% (13/13)
|
|
35
|
+
Drift: 0.33% (1/302 declared files)
|
|
36
|
+
Owners without activity: 0 owners
|
|
37
|
+
Unowned critical: 0
|
|
38
|
+
Single-owner modules: 8
|
|
25
39
|
```
|
|
26
40
|
|
|
27
|
-
|
|
41
|
+
Four kinds of finding, one line each:
|
|
42
|
+
|
|
43
|
+
- **Ghost owner** — a declared owner with no commits in the window. Here: `0`. The single `* @aleixalonso` rule covers every file, and that account does commit.
|
|
44
|
+
- **Drift** — the declared owner is not the top author of the file. Here: `1` of 302 declared files. It is the identity case described under [Identity matching is heuristic](#identity-matching-is-heuristic), not a second maintainer.
|
|
45
|
+
- **Unowned critical file** — no `CODEOWNERS` rule matches, and the file carries structural or change pressure. Here: `0` of 13 critical files.
|
|
46
|
+
- **Single-owner module** — a module whose declared owner never varies. Here: `8`. The HTML report puts the mean bus factor at `1.0`: 334 of the 341 analysed files have a bus factor of 1.
|
|
47
|
+
|
|
48
|
+
Two of those findings are empty here because this repository has a one-line wildcard rule and a single maintainer, and the audit is supposed to say so instead of manufacturing findings. What the 100% does hide is the point of the tool: one `* @aleixalonso` line takes declared coverage to 100% while telling you nothing about whether the declared owner is the person who maintains the file. The report states it directly: _this is the metric that matters, an undeclared critical file carries the highest handoff risk, no matter how healthy the repository-wide coverage looks_.
|
|
49
|
+
|
|
50
|
+
On a repository where several teams share one tree, the same command names the files: `owner: @alice · observed dave@example.com (75%)`, `ghosted`, `unowned-critical`. The [sample output](#sample-output) below is one of those runs, and [what the statuses mean](#what-the-statuses-mean) lists every verdict. What the audit cannot see is listed under [Limitations](#limitations).
|
|
51
|
+
|
|
52
|
+
## How it compares
|
|
53
|
+
|
|
54
|
+
| Tool | What it measures | Declared vs observed ownership | Open source | Runs locally |
|
|
55
|
+
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | -------------------------------------------------------- | ------------------------------------ |
|
|
56
|
+
| **CodeSentinel** | Declared owners cross-checked against git authorship, plus structural and change-history risk | Yes | Yes, MIT | Yes, offline, `npx` |
|
|
57
|
+
| **ESLint**[^eslint] | Lint rules and code patterns in JavaScript and TypeScript | No | Yes, MIT | Yes |
|
|
58
|
+
| **SonarQube Community Build**[^sonar] | Reliability, security and maintainability issues for the 21 languages Community Build supports (more in the commercial editions); SCM blame is used to assign issues | No, blame data is used for issue assignment, not an owner audit | Yes, LGPL-3.0 | Yes, self-managed server |
|
|
59
|
+
| **CodeQL**[^codeql] | Semantic queries for vulnerabilities and coding errors, mapped to CWEs | No | No, GitHub CodeQL Terms (free for open-source codebases) | Yes, CodeQL CLI |
|
|
60
|
+
| **CodeScene**[^codescene] | Code Health, hotspots, change coupling, and knowledge distribution with bus-factor simulation | Yes, knowledge distribution and bus factor | No, proprietary | Yes, CodeScene CLI, account required |
|
|
61
|
+
|
|
62
|
+
The table compares scope, not quality: these tools answer different questions, and most teams run more than one of them.
|
|
63
|
+
|
|
64
|
+
[^eslint]: <https://eslint.org/docs/latest/> and <https://github.com/eslint/eslint/blob/main/LICENSE>.
|
|
65
|
+
|
|
66
|
+
[^sonar]: <https://www.sonarsource.com/open-source-editions/sonarqube-community-edition/> ("21 Supported Languages", checked 2026-10-23), <https://docs.sonarsource.com/sonarqube-community-build/analyzing-source-code/languages/overview> (language reference), <https://docs.sonarsource.com/sonarqube-server/10.7/analyzing-source-code/scm-integration> (SCM blame) and <https://github.com/SonarSource/sonarqube> (license).
|
|
67
|
+
|
|
68
|
+
[^codeql]: <https://codeql.github.com/docs/> and <https://github.com/github/codeql-cli-binaries/blob/main/LICENSE.md>.
|
|
69
|
+
|
|
70
|
+
[^codescene]: <https://codescene.com/product> and <https://codescene.io/docs/cli/>.
|
|
71
|
+
|
|
72
|
+
## Quickstart
|
|
73
|
+
|
|
74
|
+
### Run the audit
|
|
75
|
+
|
|
76
|
+
No install, no account, no network. Run it from the repository root:
|
|
28
77
|
|
|
29
78
|
```bash
|
|
30
|
-
|
|
79
|
+
npx @getcodesentinel/codesentinel owners .
|
|
31
80
|
```
|
|
32
81
|
|
|
33
|
-
|
|
82
|
+
It reads `CODEOWNERS` (`.github/CODEOWNERS`, `CODEOWNERS` or `docs/CODEOWNERS`, in that order) and the git history of the checked-out ref, so a local run and a CI run measure the same revision. Exit codes: `0` when the audit ran, `1` when a configured threshold is exceeded under `--fail-on error`, `2` on a configuration or parse error.
|
|
34
83
|
|
|
35
|
-
|
|
84
|
+
### Add it to a project
|
|
36
85
|
|
|
37
86
|
```bash
|
|
38
|
-
codesentinel
|
|
87
|
+
npm install --save-dev @getcodesentinel/codesentinel
|
|
88
|
+
npx codesentinel owners .
|
|
39
89
|
```
|
|
40
90
|
|
|
41
|
-
###
|
|
91
|
+
### Generate the report
|
|
42
92
|
|
|
43
93
|
```bash
|
|
44
|
-
codesentinel
|
|
94
|
+
npx codesentinel owners . --format md --output ownership.md
|
|
95
|
+
npx codesentinel owners . --format sarif --output codesentinel-ownership.sarif
|
|
96
|
+
npx codesentinel report . --format html --output codesentinel-report
|
|
45
97
|
```
|
|
46
98
|
|
|
47
|
-
|
|
99
|
+
The last command writes a self-contained `codesentinel-report/index.html` with the declared-versus-observed table, filters, hotspot and bus-factor views. The SARIF file is the one GitHub code scanning ingests.
|
|
48
100
|
|
|
49
|
-
|
|
101
|
+
### Wire it into CI
|
|
50
102
|
|
|
51
103
|
```bash
|
|
52
|
-
npx codesentinel
|
|
104
|
+
npx codesentinel init .
|
|
53
105
|
```
|
|
54
106
|
|
|
55
|
-
|
|
107
|
+
It writes `.github/workflows/codesentinel.yml` and, when a `CODEOWNERS` file exists, `.codesentinel/owners.json` with the ownership thresholds. Preview with `--dry-run`, overwrite existing files with `--force`.
|
|
108
|
+
|
|
109
|
+
A full workflow template is at `examples/github-actions/codesentinel-ci.yml`. The smallest workflow that runs the gate is:
|
|
110
|
+
|
|
111
|
+
```yaml
|
|
112
|
+
name: CodeSentinel
|
|
113
|
+
|
|
114
|
+
on: pull_request
|
|
115
|
+
|
|
116
|
+
permissions:
|
|
117
|
+
contents: read
|
|
118
|
+
|
|
119
|
+
jobs:
|
|
120
|
+
codesentinel:
|
|
121
|
+
runs-on: ubuntu-latest
|
|
122
|
+
steps:
|
|
123
|
+
- uses: actions/checkout@v4
|
|
124
|
+
with:
|
|
125
|
+
fetch-depth: 0
|
|
126
|
+
- run: npx --yes @getcodesentinel/codesentinel@latest ci --baseline-ref auto --fail-on error
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`fetch-depth: 0` is required: `--baseline-ref auto` resolves the baseline from git history.
|
|
130
|
+
|
|
131
|
+
## Reference
|
|
132
|
+
|
|
133
|
+
### Ownership audit
|
|
134
|
+
|
|
135
|
+
`codesentinel owners` cross-checks the owners declared in `CODEOWNERS` against the authors that git history proves, and reports coverage, drift, ghost owners and unowned critical files. The audit is offline by contract: it reads the `CODEOWNERS` file and the tracked tree from `--ref` (default `HEAD`), so CI and a local run measure the same revision.
|
|
136
|
+
|
|
137
|
+
#### What the statuses mean
|
|
138
|
+
|
|
139
|
+
- `aligned`: a declared owner is the top author for the file's activity horizon.
|
|
140
|
+
- `drifted`: the file has a declaration, but the top author is not one of the declared owners. A dormant file is compared against its lifetime top author.
|
|
141
|
+
- `ghosted`: no declared owner has **verified** activity inside the window, and every declared owner is verifiable. A file that is merely dormant (the owner touched it historically, nothing in the window) is not ghosted.
|
|
142
|
+
- `unowned`: no `CODEOWNERS` pattern matches the file, or the winning entry has no owners.
|
|
143
|
+
- `unowned-critical`: an unowned file is also critical (structural fan-in, hotspot, risk or churn fallback).
|
|
144
|
+
- `insufficient-evidence`: fewer lifetime commits than `--min-commits`; no verdict is emitted.
|
|
145
|
+
- `unknown`: the audit degraded (an unexpanded team, an unresolved alias). It is not a verdict on the file. An unexpanded team (`@org/team` while offline) is `unknown`, never `ghosted`: absence of evidence is not evidence of absence.
|
|
146
|
+
|
|
147
|
+
#### Ignoring bot authors
|
|
148
|
+
|
|
149
|
+
The audit excludes machine accounts from ownership evidence by default. The eight default globs are `*[bot]*`, `*-bot@*`, `*bot@users.noreply.github.com`, `semantic-release-bot@*`, `renovate@*`, `dependabot@*`, `github-actions@*` and `noreply@github.com`.
|
|
150
|
+
|
|
151
|
+
Matching is case-insensitive and anchored to the full author id or display name: `*` matches any sequence, `?` matches one character, and every other character is literal. Additional patterns extend the defaults in `.codesentinel/owners.json`:
|
|
56
152
|
|
|
57
153
|
```json
|
|
58
|
-
{
|
|
59
|
-
"scripts": {
|
|
60
|
-
"risk:ci": "codesentinel ci --baseline-ref auto --fail-on error"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
154
|
+
{ "ignoreAuthors": ["*@acme-bot.example"] }
|
|
63
155
|
```
|
|
64
156
|
|
|
65
|
-
|
|
157
|
+
Use `--ignore-author <glob>` for a per-run override; it is repeatable and additive. The defaults are always on and cannot be removed. Ignored authors are excluded from the top author, author counts, shares, ghost and drift evidence. When the activity window contains only automated commits, the audit falls back to lifetime human evidence, so a file maintained by humans is not reported as drifted or unknown just because a bot touched it. `codesentinel ci` reads the same `ignoreAuthors` configuration from `.codesentinel/owners.json`, while `--ignore-author` is the `owners` per-run override.
|
|
158
|
+
|
|
159
|
+
#### Sample output
|
|
160
|
+
|
|
161
|
+
The following is illustrative output from a small four-file repository (plus its `CODEOWNERS` file), run with `--min-commits 2`:
|
|
66
162
|
|
|
67
|
-
```yaml
|
|
68
|
-
- uses: actions/checkout@v4
|
|
69
|
-
with:
|
|
70
|
-
fetch-depth: 0
|
|
71
|
-
filter: blob:none
|
|
72
|
-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
73
|
-
- name: Ensure git history for CodeSentinel
|
|
74
|
-
run: |
|
|
75
|
-
set -euo pipefail
|
|
76
|
-
git fetch --prune --unshallow || true
|
|
77
|
-
BASE_REF="${GITHUB_BASE_REF:-main}"
|
|
78
|
-
git fetch origin "+refs/heads/${BASE_REF}:refs/remotes/origin/${BASE_REF}"
|
|
79
|
-
- name: Run CodeSentinel
|
|
80
|
-
run: npx codesentinel ci --baseline-ref auto --max-risk-score 55 --max-risk-delta 0.03 --min-health-score 65 --max-health-delta 0.03 --no-new-cycles --no-new-high-risk-deps --max-new-hotspots 2 --fail-on error
|
|
81
163
|
```
|
|
164
|
+
Ownership audit — 5 tracked files, window 90d, ref HEAD
|
|
165
|
+
CODEOWNERS CODEOWNERS · 3 entries · 0 invalid lines
|
|
82
166
|
|
|
83
|
-
|
|
167
|
+
Declared coverage: 60% (3/5)
|
|
168
|
+
Critical coverage: 0% (0/1)
|
|
169
|
+
Drift: 33.33% (1/3 declared files)
|
|
170
|
+
Owners without activity: 1 owner
|
|
171
|
+
Unowned critical: 1
|
|
172
|
+
Single-owner modules: 3
|
|
173
|
+
|
|
174
|
+
Unowned critical
|
|
175
|
+
scripts/deploy.txt fan-in n/a commits 6 authors 1
|
|
84
176
|
|
|
85
|
-
|
|
177
|
+
Drift — declared owner is not the top recent author
|
|
178
|
+
api/webhooks.txt declared @alice observed dave@example.com (75%)
|
|
86
179
|
|
|
87
|
-
|
|
180
|
+
Ghost owners — declared, no commits in the window
|
|
181
|
+
@carol docs/guide.txt
|
|
182
|
+
|
|
183
|
+
Warnings
|
|
184
|
+
- No structural analysis available: criticality falls back to hotspots and churn (p90).
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### The metric that matters
|
|
188
|
+
|
|
189
|
+
Coverage over critical files (`declaredCoverageCriticalPercent`) is the metric to watch. A single `* @someone` line takes flat coverage to 100% while the critical files that carry the risk stay orphaned.
|
|
190
|
+
|
|
191
|
+
#### SARIF output
|
|
192
|
+
|
|
193
|
+
The SARIF format is intended for GitHub code scanning: upload `codesentinel-ownership.sarif` with `github/codeql-action/upload-sarif` and `category: codesentinel-ownership`. Findings keep stable fingerprints, so code scanning updates the same alerts across runs.
|
|
194
|
+
|
|
195
|
+
### Risk and health model
|
|
88
196
|
|
|
89
197
|
CodeSentinel combines three signals into a single, explainable risk profile:
|
|
90
198
|
|
|
@@ -105,35 +213,7 @@ It also includes a deterministic `health` block (`healthScore`, dimension scores
|
|
|
105
213
|
|
|
106
214
|
The goal is a practical, engineering-grade model that supports both strategic architecture decisions and daily code review workflows.
|
|
107
215
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
- `packages/core`: shared domain types and cross-cutting services.
|
|
111
|
-
- `packages/code-graph`: source graph analysis primitives.
|
|
112
|
-
- `packages/git-analyzer`: Git history and evolutionary signals.
|
|
113
|
-
- `packages/dependency-firewall`: external dependency and supply chain signals.
|
|
114
|
-
- `packages/risk-engine`: risk aggregation and scoring model.
|
|
115
|
-
- `packages/health-engine`: health posture aggregation and scoring model.
|
|
116
|
-
- `packages/reporter`: structured report output (console, JSON, CI).
|
|
117
|
-
- `packages/governance`: CI gate evaluation and enforcement policy checks.
|
|
118
|
-
- `packages/ownership`: declared ownership signals (CODEOWNERS parsing and matching).
|
|
119
|
-
- `packages/cli`: user-facing CLI entrypoint.
|
|
120
|
-
|
|
121
|
-
Each package is standalone, ESM-only, TypeScript-first, and built with `tsup`. The CLI depends on `core`; domain packages are kept decoupled to avoid circular dependencies.
|
|
122
|
-
|
|
123
|
-
## Requirements
|
|
124
|
-
|
|
125
|
-
- Node.js 22+
|
|
126
|
-
- pnpm
|
|
127
|
-
|
|
128
|
-
## Commands
|
|
129
|
-
|
|
130
|
-
- `pnpm install`
|
|
131
|
-
- `pnpm build`
|
|
132
|
-
- `pnpm dev`
|
|
133
|
-
- `pnpm test`
|
|
134
|
-
- `pnpm release`
|
|
135
|
-
|
|
136
|
-
## CLI
|
|
216
|
+
### CLI reference
|
|
137
217
|
|
|
138
218
|
Install globally with npm:
|
|
139
219
|
|
|
@@ -291,7 +371,7 @@ pnpm dev -- check . --compare baseline.json --max-risk-delta 0.03 --no-new-cycle
|
|
|
291
371
|
pnpm dev -- ci . --baseline baseline.json --snapshot current.json --report report.md --fail-on warn
|
|
292
372
|
```
|
|
293
373
|
|
|
294
|
-
|
|
374
|
+
### Report output
|
|
295
375
|
|
|
296
376
|
`codesentinel report` produces deterministic engineering artifacts from existing analysis outputs.
|
|
297
377
|
|
|
@@ -311,7 +391,7 @@ Diff mode compares snapshots and reports:
|
|
|
311
391
|
|
|
312
392
|
The live report at <https://getcodesentinel.github.io/codesentinel/> is this project's own HTML report generated by CodeSentinel from this repository and refreshed on every push to `main`.
|
|
313
393
|
|
|
314
|
-
|
|
394
|
+
### Run output
|
|
315
395
|
|
|
316
396
|
`codesentinel run` is a convenience command that emits `analyze + explain + report` in one execution.
|
|
317
397
|
|
|
@@ -320,7 +400,7 @@ The live report at <https://getcodesentinel.github.io/codesentinel/> is this pro
|
|
|
320
400
|
- explain target selectors: `--file <path>`, `--module <name>`, `--top <n>`
|
|
321
401
|
- report diff/snapshot flags: `--compare <baseline.json>`, `--snapshot <path>`, `--no-trace`
|
|
322
402
|
|
|
323
|
-
|
|
403
|
+
### CI mode
|
|
324
404
|
|
|
325
405
|
`codesentinel check` evaluates enforcement gates against current analysis (and optional baseline diff).
|
|
326
406
|
|
|
@@ -392,102 +472,30 @@ Exit codes:
|
|
|
392
472
|
- `3`: invalid configuration
|
|
393
473
|
- `4`: internal execution error
|
|
394
474
|
|
|
395
|
-
|
|
475
|
+
### Trend
|
|
396
476
|
|
|
397
|
-
`codesentinel
|
|
477
|
+
`codesentinel trend` reads snapshot JSON artifacts written by `codesentinel ci --snapshot` and prints the series over time. Snapshots are CI artifacts, not repository files: `trend` never writes history into the repository and never changes the snapshot schema.
|
|
398
478
|
|
|
399
|
-
|
|
479
|
+
The workflow generated by `codesentinel init` runs `codesentinel ci --snapshot` and uploads the result as the `codesentinel` artifact, retrievable with `gh run download <run-id> -n codesentinel`. The ownership columns (Unowned, Ghosts, Drift) are populated from the snapshot's embedded ownership block, and the Commit column shows the short SHA. Both `codesentinel.snapshot.v2` and legacy `codesentinel.snapshot.v1` artifacts are read; v1 snapshots have no commit, so Commit shows `—`.
|
|
400
480
|
|
|
401
481
|
```bash
|
|
402
|
-
codesentinel
|
|
403
|
-
codesentinel
|
|
404
|
-
codesentinel owners . --format sarif --output codesentinel-ownership.sarif
|
|
405
|
-
codesentinel owners . --ignore-author '*@acme-bot.example'
|
|
406
|
-
codesentinel ci --max-unowned-critical 0 --max-ghost-owners 2 --max-drift 0.25 --fail-on error
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
The SARIF format is intended for GitHub code scanning: upload `codesentinel-ownership.sarif` with `github/codeql-action/upload-sarif` and `category: codesentinel-ownership`. Findings keep stable fingerprints, so code scanning updates the same alerts across runs.
|
|
410
|
-
|
|
411
|
-
### Ignoring bot authors
|
|
412
|
-
|
|
413
|
-
The audit excludes machine accounts from ownership evidence by default. The eight default globs are `*[bot]*`, `*-bot@*`, `*bot@users.noreply.github.com`, `semantic-release-bot@*`, `renovate@*`, `dependabot@*`, `github-actions@*` and `noreply@github.com`.
|
|
414
|
-
|
|
415
|
-
Matching is case-insensitive and anchored to the full author id or display name: `*` matches any sequence, `?` matches one character, and every other character is literal. Additional patterns extend the defaults in `.codesentinel/owners.json`:
|
|
416
|
-
|
|
417
|
-
```json
|
|
418
|
-
{ "ignoreAuthors": ["*@acme-bot.example"] }
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
Use `--ignore-author <glob>` for a per-run override; it is repeatable and additive. The defaults are always on and cannot be removed. Ignored authors are excluded from the top author, author counts, shares, ghost and drift evidence. When the activity window contains only automated commits, the audit falls back to lifetime human evidence, so a file maintained by humans is not reported as drifted or unknown just because a bot touched it. `codesentinel ci` reads the same `ignoreAuthors` configuration from `.codesentinel/owners.json`, while `--ignore-author` is the `owners` per-run override.
|
|
422
|
-
|
|
423
|
-
### Sample output
|
|
424
|
-
|
|
425
|
-
The following is illustrative output from a small four-file repository (plus its `CODEOWNERS` file), run with `--min-commits 2`:
|
|
426
|
-
|
|
427
|
-
```
|
|
428
|
-
Ownership audit — 5 tracked files, window 90d, ref HEAD
|
|
429
|
-
CODEOWNERS CODEOWNERS · 3 entries · 0 invalid lines
|
|
430
|
-
|
|
431
|
-
Declared coverage: 60% (3/5)
|
|
432
|
-
Critical coverage: 0% (0/1)
|
|
433
|
-
Drift: 33.33% (1/3 declared files)
|
|
434
|
-
Owners without activity: 1 owner
|
|
435
|
-
Unowned critical: 1
|
|
436
|
-
Single-owner modules: 3
|
|
437
|
-
|
|
438
|
-
Unowned critical
|
|
439
|
-
scripts/deploy.txt fan-in n/a commits 6 authors 1
|
|
440
|
-
|
|
441
|
-
Drift — declared owner is not the top recent author
|
|
442
|
-
api/webhooks.txt declared @alice observed dave@example.com (75%)
|
|
443
|
-
|
|
444
|
-
Ghost owners — declared, no commits in the window
|
|
445
|
-
@carol docs/guide.txt
|
|
446
|
-
|
|
447
|
-
Warnings
|
|
448
|
-
- No structural analysis available: criticality falls back to hotspots and churn (p90).
|
|
482
|
+
codesentinel trend --from ./snapshots
|
|
483
|
+
codesentinel trend --from './snapshots/*.json' --since 90d --last 12 --format md --output trend.md
|
|
449
484
|
```
|
|
450
485
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
- `aligned`: a declared owner is the top author for the file's activity horizon.
|
|
454
|
-
- `drifted`: the file has a declaration, but the top author is not one of the declared owners. A dormant file is compared against its lifetime top author.
|
|
455
|
-
- `ghosted`: no declared owner has **verified** activity inside the window, and every declared owner is verifiable. A file that is merely dormant (the owner touched it historically, nothing in the window) is not ghosted.
|
|
456
|
-
- `unowned`: no `CODEOWNERS` pattern matches the file, or the winning entry has no owners.
|
|
457
|
-
- `unowned-critical`: an unowned file is also critical (structural fan-in, hotspot, risk or churn fallback).
|
|
458
|
-
- `insufficient-evidence`: fewer lifetime commits than `--min-commits`; no verdict is emitted.
|
|
459
|
-
- `unknown`: the audit degraded (an unexpanded team, an unresolved alias). It is not a verdict on the file. An unexpanded team (`@org/team` while offline) is `unknown`, never `ghosted`: absence of evidence is not evidence of absence.
|
|
460
|
-
|
|
461
|
-
### The metric that matters
|
|
462
|
-
|
|
463
|
-
Coverage over critical files (`declaredCoverageCriticalPercent`) is the metric to watch. A single `* @someone` line takes flat coverage to 100% while the critical files that carry the risk stay orphaned.
|
|
464
|
-
|
|
465
|
-
### Ethics
|
|
466
|
-
|
|
467
|
-
This measures system risk, not individual performance. No owner or author ranking is emitted, drift is a coordination signal rather than a fault, and the audit must not be used to evaluate people.
|
|
468
|
-
|
|
469
|
-
### Known limitations
|
|
470
|
-
|
|
471
|
-
- No `!` negation and no `[ ]` character classes: they are literal characters, same as GitHub.
|
|
472
|
-
- Matching is case-sensitive on every platform, including macOS.
|
|
473
|
-
- A `CODEOWNERS` file above 3 MB is rejected (`codeowners_too_large`).
|
|
474
|
-
- `CODEOWNERS` is read per ref/branch, so a run measures the ref you pass, and a PR that edits `CODEOWNERS` is measured against the base ref in CI.
|
|
475
|
-
- Teams are opaque offline and stay `unknown` unless resolved; `--resolve-github` is accepted but not implemented in this iteration.
|
|
476
|
-
- The universe is tracked files only: untracked, ignored and binary-only files are out of scope.
|
|
477
|
-
- Identity matching is heuristic (noreply address, email local part, display name, alias map in `.codesentinel/owners.json`).
|
|
478
|
-
- Machine accounts are excluded by the built-in author patterns; add repository-specific patterns with `ignoreAuthors` in `.codesentinel/owners.json` or `--ignore-author <glob>`.
|
|
486
|
+
`--from` accepts a directory (non-recursive `*.json` files) or a glob pattern. Each snapshot is parsed independently: a corrupt file, an unsupported schema version or a missing score is skipped with a warning so the remaining history still renders. Series are ordered by `generatedAt`, duplicate timestamp and commit pairs are collapsed, and `--since <N>d`/`--last <N>` narrow the window. Output is available as `console` (default), `json` (stable payload) and `md`. Deltas are last minus first; ownership deltas stay `null` when either endpoint has no ownership block. Fewer than two snapshots still exits `0` and prints `not enough history for a trend`. Configuration errors exit `2`.
|
|
479
487
|
|
|
480
|
-
|
|
488
|
+
### Reading path
|
|
481
489
|
|
|
482
490
|
`codesentinel path` prints an ordered, explainable reading path for a module directory or a single file. It uses the existing CodeSentinel structural graph, git evolution history and, when present, `CODEOWNERS`. The command is offline, local and deterministic: the same repository state produces the same output.
|
|
483
491
|
|
|
484
|
-
|
|
492
|
+
#### Quickstart
|
|
485
493
|
|
|
486
494
|
```bash
|
|
487
495
|
codesentinel path packages/ownership
|
|
488
496
|
```
|
|
489
497
|
|
|
490
|
-
|
|
498
|
+
#### Sample output
|
|
491
499
|
|
|
492
500
|
The following is the real console output for `packages/ownership`:
|
|
493
501
|
|
|
@@ -535,7 +543,7 @@ Warnings
|
|
|
535
543
|
- showing 8 of 10 files (truncated)
|
|
536
544
|
```
|
|
537
545
|
|
|
538
|
-
|
|
546
|
+
#### Flags
|
|
539
547
|
|
|
540
548
|
| Flag | Description |
|
|
541
549
|
| ---------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
@@ -548,7 +556,7 @@ Warnings
|
|
|
548
556
|
| `--ref <ref>` | Git ref to read CODEOWNERS and the tracked history from. Default `HEAD`. |
|
|
549
557
|
| `--log-level <level>` | Log verbosity: `silent`, `error`, `warn`, `info` or `debug` (logs are written to stderr). Default `info`. |
|
|
550
558
|
|
|
551
|
-
|
|
559
|
+
#### Formats
|
|
552
560
|
|
|
553
561
|
`console` is the default. `md` produces the same content as a Markdown document that drops into a pull request. `json` emits a stable payload that is byte-identical across runs on the same repository state.
|
|
554
562
|
|
|
@@ -578,7 +586,7 @@ Warnings
|
|
|
578
586
|
|
|
579
587
|
The payload keys are `schemaVersion`, `target`, `targetKind`, `steps`, `people`, `commands`, `warnings`, `truncated`.
|
|
580
588
|
|
|
581
|
-
|
|
589
|
+
#### How the order is chosen
|
|
582
590
|
|
|
583
591
|
The entry step is chosen in five steps:
|
|
584
592
|
|
|
@@ -590,7 +598,7 @@ The entry step is chosen in five steps:
|
|
|
590
598
|
|
|
591
599
|
A single-file target still starts at that file. From there a greedy walk scores change coupling at 0.5, internal fan-in at 0.3 and churn at 0.2. When the walk is exhausted it jumps to the highest remaining internal fan-in. Every step carries the signal that selected it, and its role is one of `entry`, `core`, `helper` or `test`. The git-only fallback (no structural graph) orders by churn and change coupling and does not apply the package-index rule.
|
|
592
600
|
|
|
593
|
-
|
|
601
|
+
#### Degraded and edge behaviour
|
|
594
602
|
|
|
595
603
|
- No `CODEOWNERS` file: `owner` is `null`.
|
|
596
604
|
- No structural graph: ordering falls back to git history only and a warning is emitted.
|
|
@@ -598,135 +606,7 @@ A single-file target still starts at that file. From there a greedy walk scores
|
|
|
598
606
|
- More files than `--max-steps`: `truncated` is `true` and a warning records how many files were shown.
|
|
599
607
|
- A target outside the repository, a missing target or invalid flags exit `2`; success exits `0`.
|
|
600
608
|
|
|
601
|
-
###
|
|
602
|
-
|
|
603
|
-
- Commits are a biased proxy for knowledge: they measure what was committed, not what is understood.
|
|
604
|
-
- There is no tacit knowledge signal: design discussions, reviews, incidents and conversations are invisible.
|
|
605
|
-
- There is no documentation-maintenance signal: documentation pages are not tracked as knowledge carriers.
|
|
606
|
-
- There are no collaboration or team features: no multi-repository paths, no chat, no maps and no HTML view.
|
|
607
|
-
- The repository must be a git work tree with tracked files.
|
|
608
|
-
|
|
609
|
-
`--ref` pins `CODEOWNERS` and the tracked history, while the structural graph and churn come from the working tree. The suggested test command is only a suggestion: nothing is discovered and nothing is run.
|
|
610
|
-
|
|
611
|
-
## MCP server
|
|
612
|
-
|
|
613
|
-
`codesentinel mcp` serves the ownership, risk, trend and reading-path data that CodeSentinel already computes to MCP clients over stdio. It uses JSON-RPC on stdin/stdout and writes every log to stderr. All tools are read-only except `run_scan`, which analyzes the repository and writes a snapshot under `.codesentinel/snapshots`.
|
|
614
|
-
|
|
615
|
-
### Register it
|
|
616
|
-
|
|
617
|
-
Claude Code:
|
|
618
|
-
|
|
619
|
-
```bash
|
|
620
|
-
claude mcp add codesentinel --env CODESENTINEL_ROOT=/absolute/path/to/repository -- codesentinel mcp
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
Claude Desktop (`claude_desktop_config.json`):
|
|
624
|
-
|
|
625
|
-
```json
|
|
626
|
-
{
|
|
627
|
-
"mcpServers": {
|
|
628
|
-
"codesentinel": {
|
|
629
|
-
"command": "npx",
|
|
630
|
-
"args": ["-y", "@getcodesentinel/mcp"],
|
|
631
|
-
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
```
|
|
636
|
-
|
|
637
|
-
Cursor (`.cursor/mcp.json`):
|
|
638
|
-
|
|
639
|
-
```json
|
|
640
|
-
{
|
|
641
|
-
"mcpServers": {
|
|
642
|
-
"codesentinel": {
|
|
643
|
-
"command": "npx",
|
|
644
|
-
"args": ["-y", "@getcodesentinel/mcp"],
|
|
645
|
-
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
```
|
|
650
|
-
|
|
651
|
-
VS Code (`.vscode/mcp.json`):
|
|
652
|
-
|
|
653
|
-
```json
|
|
654
|
-
{
|
|
655
|
-
"servers": {
|
|
656
|
-
"codesentinel": {
|
|
657
|
-
"type": "stdio",
|
|
658
|
-
"command": "npx",
|
|
659
|
-
"args": ["-y", "@getcodesentinel/mcp"],
|
|
660
|
-
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
```
|
|
665
|
-
|
|
666
|
-
Set `CODESENTINEL_ROOT` whenever the client does not start the process from the repository root. `codesentinel mcp` and `npx -y @getcodesentinel/mcp` launch the same server; the wrapper only forwards arguments.
|
|
667
|
-
|
|
668
|
-
### Tools
|
|
669
|
-
|
|
670
|
-
| Tool | Parameters | Returns | Read-only |
|
|
671
|
-
| ------------------ | ------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------- |
|
|
672
|
-
| `get_file_owner` | `path` | Declared owners, observed authorship, criticality and warnings for one tracked file. | yes |
|
|
673
|
-
| `get_file_risk` | `path`, `ref?` (only `HEAD`) | File risk score, normalized score, factor breakdown, hotspot rank and repository score. | yes |
|
|
674
|
-
| `get_reading_path` | `target`, `maxSteps?` | Ordered reading steps with roles, reasons, owners, people and suggested commands. | yes |
|
|
675
|
-
| `get_trend` | `metric`, `path?` (unsupported), `since?`, `until?` | Repository-level metric series from snapshot artifacts, oldest to newest. | yes |
|
|
676
|
-
| `list_hotspots` | `limit?`, `cursor?` | Ranked hotspots with cursor pagination. | yes |
|
|
677
|
-
| `run_scan` | `path?`, `changedOnly?` | Fresh analysis written to a new snapshot file, plus scope and changed-file hotspots. | no |
|
|
678
|
-
| `search_findings` | `path?`, `severity?`, `rule?`, `status?`, `cursor?`, `limit?` | Ownership findings with severity, status, message and CODEOWNERS line. | yes |
|
|
679
|
-
|
|
680
|
-
A real `get_file_owner` call against this repository:
|
|
681
|
-
|
|
682
|
-
```json
|
|
683
|
-
{
|
|
684
|
-
"path": "packages/ownership/src/index.ts",
|
|
685
|
-
"ref": "HEAD",
|
|
686
|
-
"owners": [{ "kind": "user", "value": "@aleixalonso" }],
|
|
687
|
-
"teams": [],
|
|
688
|
-
"status": "aligned",
|
|
689
|
-
"matchLine": 1,
|
|
690
|
-
"topAuthor": { "id": "aleixalonso@users.noreply.github.com", "share": 1 },
|
|
691
|
-
"observed": {
|
|
692
|
-
"commits": 3,
|
|
693
|
-
"recentCommits": 3,
|
|
694
|
-
"authors": 1,
|
|
695
|
-
"dormant": false,
|
|
696
|
-
"busFactor": null,
|
|
697
|
-
"lastCommitUnix": 1792689223
|
|
698
|
-
},
|
|
699
|
-
"criticality": { "isCritical": true, "isHotspot": false, "fanIn": 5, "riskScore": null },
|
|
700
|
-
"warnings": [
|
|
701
|
-
"Ignored 183 commits attributed to 3 ignored authors matched by \"ignoreAuthors\": 29139614+renovate[bot]@users.noreply.github.com, 49699333+dependabot[bot]@users.noreply.github.com, semantic-release-bot@martynus.net."
|
|
702
|
-
]
|
|
703
|
-
}
|
|
704
|
-
```
|
|
705
|
-
|
|
706
|
-
The full request/response capture is in [`docs/mcp-transcript.md`](docs/mcp-transcript.md).
|
|
707
|
-
|
|
708
|
-
### Security
|
|
709
|
-
|
|
710
|
-
No credentials are accepted as tool arguments. Git and CI credentials come from the environment (credential helper, SSH agent or CI token), and error messages are redacted. Stdout carries only MCP messages; logs go to stderr. The server never accepts a token, password or remote URL as a tool input.
|
|
711
|
-
|
|
712
|
-
### Trend source
|
|
713
|
-
|
|
714
|
-
`get_trend` reads snapshots from `CODESENTINEL_SNAPSHOTS_DIR`, defaulting to `<root>/.codesentinel/snapshots`. Snapshots are repository-level, so `get_trend` does not support `path`; use `search_findings` or `get_file_risk` for per-file questions.
|
|
715
|
-
|
|
716
|
-
## Trend
|
|
717
|
-
|
|
718
|
-
`codesentinel trend` reads snapshot JSON artifacts written by `codesentinel ci --snapshot` and prints the series over time. Snapshots are CI artifacts, not repository files: `trend` never writes history into the repository and never changes the snapshot schema.
|
|
719
|
-
|
|
720
|
-
The workflow generated by `codesentinel init` runs `codesentinel ci --snapshot` and uploads the result as the `codesentinel` artifact, retrievable with `gh run download <run-id> -n codesentinel`. The ownership columns (Unowned, Ghosts, Drift) are populated from the snapshot's embedded ownership block, and the Commit column shows the short SHA. Both `codesentinel.snapshot.v2` and legacy `codesentinel.snapshot.v1` artifacts are read; v1 snapshots have no commit, so Commit shows `—`.
|
|
721
|
-
|
|
722
|
-
```bash
|
|
723
|
-
codesentinel trend --from ./snapshots
|
|
724
|
-
codesentinel trend --from './snapshots/*.json' --since 90d --last 12 --format md --output trend.md
|
|
725
|
-
```
|
|
726
|
-
|
|
727
|
-
`--from` accepts a directory (non-recursive `*.json` files) or a glob pattern. Each snapshot is parsed independently: a corrupt file, an unsupported schema version or a missing score is skipped with a warning so the remaining history still renders. Series are ordered by `generatedAt`, duplicate timestamp and commit pairs are collapsed, and `--since <N>d`/`--last <N>` narrow the window. Output is available as `console` (default), `json` (stable payload) and `md`. Deltas are last minus first; ownership deltas stay `null` when either endpoint has no ownership block. Fewer than two snapshots still exits `0` and prints `not enough history for a trend`. Configuration errors exit `2`.
|
|
728
|
-
|
|
729
|
-
## Explain Output
|
|
609
|
+
### Explain output
|
|
730
610
|
|
|
731
611
|
`codesentinel explain` uses the same risk-engine scoring model as `analyze` and adds structured explanation traces.
|
|
732
612
|
|
|
@@ -747,7 +627,7 @@ Filters:
|
|
|
747
627
|
- `--top <n>`: explain top `n` hotspot files (default behavior when no file/module is provided).
|
|
748
628
|
- `--format text|json|md`: render narrative text, full JSON payload, or markdown.
|
|
749
629
|
|
|
750
|
-
|
|
630
|
+
### Reading analyze output
|
|
751
631
|
|
|
752
632
|
`codesentinel analyze` returns one JSON document with five top-level blocks:
|
|
753
633
|
|
|
@@ -822,7 +702,7 @@ Interpretation notes:
|
|
|
822
702
|
- Scores are meant for within-repo prioritization and trend tracking.
|
|
823
703
|
- Full model details and limits are in `packages/risk-engine/README.md`.
|
|
824
704
|
|
|
825
|
-
|
|
705
|
+
#### Risk score guide
|
|
826
706
|
|
|
827
707
|
Use these ranges as operational guidance:
|
|
828
708
|
|
|
@@ -834,7 +714,7 @@ Use these ranges as operational guidance:
|
|
|
834
714
|
|
|
835
715
|
These ranges are heuristics for triage, not incident probability.
|
|
836
716
|
|
|
837
|
-
|
|
717
|
+
#### Health score guide
|
|
838
718
|
|
|
839
719
|
Use these ranges as operational guidance:
|
|
840
720
|
|
|
@@ -846,7 +726,7 @@ Use these ranges as operational guidance:
|
|
|
846
726
|
|
|
847
727
|
These ranges are heuristics for prioritization, not absolute quality guarantees.
|
|
848
728
|
|
|
849
|
-
|
|
729
|
+
#### What moves scores
|
|
850
730
|
|
|
851
731
|
`risk.riskScore` and `risk.fileScores[*].score` increase when:
|
|
852
732
|
|
|
@@ -862,7 +742,7 @@ They decrease when:
|
|
|
862
742
|
- dependency pressure decreases (shallower trees, fewer high-risk signals),
|
|
863
743
|
- hotspot concentration drops.
|
|
864
744
|
|
|
865
|
-
|
|
745
|
+
#### External risk signals
|
|
866
746
|
|
|
867
747
|
For `external.dependencies`, each direct dependency now exposes three signal fields:
|
|
868
748
|
|
|
@@ -906,13 +786,191 @@ Propagation policy is explicit and deterministic:
|
|
|
906
786
|
|
|
907
787
|
This keeps package-level facts local while still surfacing meaningful transitive exposure.
|
|
908
788
|
|
|
909
|
-
|
|
789
|
+
### MCP server
|
|
790
|
+
|
|
791
|
+
`codesentinel mcp` serves the ownership, risk, trend and reading-path data that CodeSentinel already computes to MCP clients over stdio. It uses JSON-RPC on stdin/stdout and writes every log to stderr. All tools are read-only except `run_scan`, which analyzes the repository and writes a snapshot under `.codesentinel/snapshots`.
|
|
792
|
+
|
|
793
|
+
#### Register it
|
|
794
|
+
|
|
795
|
+
Claude Code:
|
|
796
|
+
|
|
797
|
+
```bash
|
|
798
|
+
claude mcp add codesentinel --env CODESENTINEL_ROOT=/absolute/path/to/repository -- codesentinel mcp
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
Claude Desktop (`claude_desktop_config.json`):
|
|
802
|
+
|
|
803
|
+
```json
|
|
804
|
+
{
|
|
805
|
+
"mcpServers": {
|
|
806
|
+
"codesentinel": {
|
|
807
|
+
"command": "npx",
|
|
808
|
+
"args": ["-y", "@getcodesentinel/mcp"],
|
|
809
|
+
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
Cursor (`.cursor/mcp.json`):
|
|
816
|
+
|
|
817
|
+
```json
|
|
818
|
+
{
|
|
819
|
+
"mcpServers": {
|
|
820
|
+
"codesentinel": {
|
|
821
|
+
"command": "npx",
|
|
822
|
+
"args": ["-y", "@getcodesentinel/mcp"],
|
|
823
|
+
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
VS Code (`.vscode/mcp.json`):
|
|
830
|
+
|
|
831
|
+
```json
|
|
832
|
+
{
|
|
833
|
+
"servers": {
|
|
834
|
+
"codesentinel": {
|
|
835
|
+
"type": "stdio",
|
|
836
|
+
"command": "npx",
|
|
837
|
+
"args": ["-y", "@getcodesentinel/mcp"],
|
|
838
|
+
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
Set `CODESENTINEL_ROOT` whenever the client does not start the process from the repository root. `codesentinel mcp` and `npx -y @getcodesentinel/mcp` launch the same server; the wrapper only forwards arguments.
|
|
845
|
+
|
|
846
|
+
#### Tools
|
|
847
|
+
|
|
848
|
+
| Tool | Parameters | Returns | Read-only |
|
|
849
|
+
| ------------------ | ------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------- |
|
|
850
|
+
| `get_file_owner` | `path` | Declared owners, observed authorship, criticality and warnings for one tracked file. | yes |
|
|
851
|
+
| `get_file_risk` | `path`, `ref?` (only `HEAD`) | File risk score, normalized score, factor breakdown, hotspot rank and repository score. | yes |
|
|
852
|
+
| `get_reading_path` | `target`, `maxSteps?` | Ordered reading steps with roles, reasons, owners, people and suggested commands. | yes |
|
|
853
|
+
| `get_trend` | `metric`, `path?` (unsupported), `since?`, `until?` | Repository-level metric series from snapshot artifacts, oldest to newest. | yes |
|
|
854
|
+
| `list_hotspots` | `limit?`, `cursor?` | Ranked hotspots with cursor pagination. | yes |
|
|
855
|
+
| `run_scan` | `path?`, `changedOnly?` | Fresh analysis written to a new snapshot file, plus scope and changed-file hotspots. | no |
|
|
856
|
+
| `search_findings` | `path?`, `severity?`, `rule?`, `status?`, `cursor?`, `limit?` | Ownership findings with severity, status, message and CODEOWNERS line. | yes |
|
|
857
|
+
|
|
858
|
+
A real `get_file_owner` call against this repository:
|
|
859
|
+
|
|
860
|
+
```json
|
|
861
|
+
{
|
|
862
|
+
"path": "packages/ownership/src/index.ts",
|
|
863
|
+
"ref": "HEAD",
|
|
864
|
+
"owners": [{ "kind": "user", "value": "@aleixalonso" }],
|
|
865
|
+
"teams": [],
|
|
866
|
+
"status": "aligned",
|
|
867
|
+
"matchLine": 1,
|
|
868
|
+
"topAuthor": { "id": "aleixalonso@users.noreply.github.com", "share": 1 },
|
|
869
|
+
"observed": {
|
|
870
|
+
"commits": 3,
|
|
871
|
+
"recentCommits": 3,
|
|
872
|
+
"authors": 1,
|
|
873
|
+
"dormant": false,
|
|
874
|
+
"busFactor": null,
|
|
875
|
+
"lastCommitUnix": 1792689223
|
|
876
|
+
},
|
|
877
|
+
"criticality": { "isCritical": true, "isHotspot": false, "fanIn": 5, "riskScore": null },
|
|
878
|
+
"warnings": [
|
|
879
|
+
"Ignored 183 commits attributed to 3 ignored authors matched by \"ignoreAuthors\": 29139614+renovate[bot]@users.noreply.github.com, 49699333+dependabot[bot]@users.noreply.github.com, semantic-release-bot@martynus.net."
|
|
880
|
+
]
|
|
881
|
+
}
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
The full request/response capture is in [`docs/mcp-transcript.md`](docs/mcp-transcript.md).
|
|
885
|
+
|
|
886
|
+
#### Security
|
|
887
|
+
|
|
888
|
+
No credentials are accepted as tool arguments. Git and CI credentials come from the environment (credential helper, SSH agent or CI token), and error messages are redacted. Stdout carries only MCP messages; logs go to stderr. The server never accepts a token, password or remote URL as a tool input.
|
|
889
|
+
|
|
890
|
+
#### Trend source
|
|
891
|
+
|
|
892
|
+
`get_trend` reads snapshots from `CODESENTINEL_SNAPSHOTS_DIR`, defaulting to `<root>/.codesentinel/snapshots`. Snapshots are repository-level, so `get_trend` does not support `path`; use `search_findings` or `get_file_risk` for per-file questions.
|
|
893
|
+
|
|
894
|
+
### Monorepo layout
|
|
895
|
+
|
|
896
|
+
- `packages/core`: shared domain types and cross-cutting services.
|
|
897
|
+
- `packages/code-graph`: source graph analysis primitives.
|
|
898
|
+
- `packages/git-analyzer`: Git history and evolutionary signals.
|
|
899
|
+
- `packages/dependency-firewall`: external dependency and supply chain signals.
|
|
900
|
+
- `packages/risk-engine`: risk aggregation and scoring model.
|
|
901
|
+
- `packages/health-engine`: health posture aggregation and scoring model.
|
|
902
|
+
- `packages/reporter`: structured report output (console, JSON, CI).
|
|
903
|
+
- `packages/governance`: CI gate evaluation and enforcement policy checks.
|
|
904
|
+
- `packages/ownership`: declared ownership signals (CODEOWNERS parsing and matching).
|
|
905
|
+
- `packages/cli`: user-facing CLI entrypoint.
|
|
906
|
+
|
|
907
|
+
Each package is standalone, ESM-only, TypeScript-first, and built with `tsup`. The CLI depends on `core`; domain packages are kept decoupled to avoid circular dependencies.
|
|
908
|
+
|
|
909
|
+
### Requirements
|
|
910
|
+
|
|
911
|
+
- Node.js 22+
|
|
912
|
+
- pnpm
|
|
913
|
+
|
|
914
|
+
### Commands
|
|
915
|
+
|
|
916
|
+
- `pnpm install`
|
|
917
|
+
- `pnpm build`
|
|
918
|
+
- `pnpm dev`
|
|
919
|
+
- `pnpm test`
|
|
920
|
+
- `pnpm typecheck`
|
|
921
|
+
- `pnpm lint`
|
|
922
|
+
- `pnpm verify`
|
|
923
|
+
- `pnpm release`
|
|
924
|
+
|
|
925
|
+
`pnpm verify` runs build → typecheck → test in that order because the workspace packages resolve each other from `dist/` and the integration tests pack the CLI wrapper, so neither typecheck nor test is meaningful before a build.
|
|
926
|
+
|
|
927
|
+
### ESM import policy
|
|
910
928
|
|
|
911
929
|
- The workspace uses `TypeScript` with `moduleResolution: "NodeNext"` and ESM output.
|
|
912
930
|
- For local relative imports, use `.js` specifiers in source files (example: `import { x } from "./x.js"`).
|
|
913
931
|
- Do not use `.ts` specifiers for runtime imports in package source files.
|
|
914
932
|
- This keeps emitted code and runtime resolution aligned with Node.js ESM behavior.
|
|
915
933
|
|
|
934
|
+
## Limitations
|
|
935
|
+
|
|
936
|
+
### Commits are a biased proxy for knowledge
|
|
937
|
+
|
|
938
|
+
A commit records what was written and merged, not what is understood. Design discussions, code review, pairing, incidents and questions answered in chat leave no trace in git history, so a file whose owner only reviews it looks unowned.
|
|
939
|
+
|
|
940
|
+
### No tacit knowledge
|
|
941
|
+
|
|
942
|
+
CodeSentinel cannot see review activity, issue triage, documentation upkeep, or the person everyone asks when a module breaks. The audit is one signal about coordination risk, not a map of what a team knows. Documentation maintenance is invisible as well: documentation pages are not tracked as knowledge carriers.
|
|
943
|
+
|
|
944
|
+
### No individual rankings
|
|
945
|
+
|
|
946
|
+
The audit measures system risk, not individual performance. It emits no owner or author ranking, drift is a coordination signal rather than a fault, and the output must not be used to evaluate people.
|
|
947
|
+
|
|
948
|
+
### What `unknown` means
|
|
949
|
+
|
|
950
|
+
`unknown` means the audit degraded: an unexpanded `@org/team` while offline, or an unresolved alias. It is not a verdict on the file, and absence of evidence is not evidence of absence. A file with fewer than `--min-commits` lifetime commits is `insufficient-evidence` instead and gets no verdict at all.
|
|
951
|
+
|
|
952
|
+
### Identity matching is heuristic
|
|
953
|
+
|
|
954
|
+
Declared handles are matched to commit authors by noreply address, email local part, display name and the alias map in `.codesentinel/owners.json`. When that fails, the same person appears twice. This repository has one such case: `pnpm-workspace.yaml` is reported as drifted because the audit cannot prove that the declared `@aleixalonso` and the author `aleixalonso@hotmail.com` are the same account. A `.mailmap`, or an `aliases` entry in `.codesentinel/owners.json`, removes the ambiguity.
|
|
955
|
+
|
|
956
|
+
### Ownership parsing and scope
|
|
957
|
+
|
|
958
|
+
- No `!` negation and no `[ ]` character classes: they are literal characters, same as GitHub.
|
|
959
|
+
- Matching is case-sensitive on every platform, including macOS.
|
|
960
|
+
- A `CODEOWNERS` file above 3 MB is rejected (`codeowners_too_large`).
|
|
961
|
+
- `CODEOWNERS` is read per ref/branch, so a run measures the ref you pass, and a PR that edits `CODEOWNERS` is measured against the base ref in CI.
|
|
962
|
+
- Teams are opaque offline and stay `unknown` unless resolved; `--resolve-github` is accepted but not implemented in this iteration.
|
|
963
|
+
- The universe is tracked files only: untracked, ignored and binary-only files are out of scope.
|
|
964
|
+
- A repository without a `CODEOWNERS` file reports `available: false` and still exits `0`.
|
|
965
|
+
- The repository must be a git work tree with tracked files: the audit reads `git log` and the tracked tree.
|
|
966
|
+
|
|
967
|
+
### Reading path and history
|
|
968
|
+
|
|
969
|
+
- The reading path orders files by change coupling, fan-in and churn. It is a suggestion, not a curriculum, and its `pnpm test` line is never run.
|
|
970
|
+
- `--ref` pins `CODEOWNERS` and the tracked history, while the structural graph and churn come from the working tree.
|
|
971
|
+
- CI needs full history (`fetch-depth: 0`): a shallow clone degrades `--baseline-ref auto` and the ownership window.
|
|
972
|
+
- Scores are deterministic heuristics for within-repository prioritisation and trend tracking, not an absolute quality guarantee, and they are not meant for comparing repositories.
|
|
973
|
+
|
|
916
974
|
## License
|
|
917
975
|
|
|
918
976
|
MIT
|
package/package.json
CHANGED