ai-engineering-loop 2.8.0 → 2.9.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.
- package/.agents/skills/ael/references/loop-maker.md +1 -0
- package/.claude/agents/devil-advocate.md +1 -1
- package/.grok/agents/devil-advocate.md +1 -1
- package/CHANGELOG.md +8 -1
- package/agents/shared/devil-advocate.body.md +1 -1
- package/core/verification-loop.md +10 -0
- package/lib/comment-findings.js +106 -30
- package/lib/gates.js +2 -2
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
- Branch on mode. REPORT_ONLY: never edit repository files; write `RUN_DIR/report.json` with summary and recommendations, then the report review (`loop-report`), run `gate report`, and stop. ASSISTED: the parent (or intern) is Maker; delivery later needs human approval. UNATTENDED: `sandbox create --run <runId>`, Maker works only in the returned worktreePath, never the parent checkout, then `sandbox capture --run <runId>`.
|
|
5
5
|
- Maker intern: read `maker_intern` from workflow.md (missing or `none` = parent is Maker). Confirm it through the host model catalog; otherwise the parent is Maker and you report INVOCATION_UNAVAILABLE. The intern cannot skip later gates or spawn DA/Judge.
|
|
6
6
|
- Guardrails: Claude Code enforces them after `hooks install`. Elsewhere, before an out-of-scope edit or a destructive command (`rm -rf`, `DROP TABLE`, `git push --force`, `git reset --hard`, `git clean -fd`) run `guard check --tool edit --path <file>` or `--tool bash --command "<cmd>"`: `warn` = ask the human, `block` = do not run it.
|
|
7
|
+
- No code comments in product code (C-26): put intent in names, types, tests; rationale in the commit.
|
|
7
8
|
- Bugs: red repro first. Features: one red test per AC row, then green.
|
|
8
9
|
- After package and manifest edits are stable, run `npx ai-engineering-loop refresh` once (drift during red-green is expected; do not refresh per test cycle).
|
|
9
10
|
- `eslint --fix` and other auto-fixers run before `gate maker`, never after.
|
|
@@ -38,7 +38,7 @@ Report Spec and Standards as separate findings. Do not rerank one axis with the
|
|
|
38
38
|
|
|
39
39
|
**Standards** (`axis: "standards"`): `.ai-engineering-loop/conventions.md` plus the smell baseline below. Judgement calls: severity MEDIUM or LOW. Set `hardConvention: true` only when conventions.md states a hard rule that this hunk violates. A smell that hides an AC defect is Spec, not Standards.
|
|
40
40
|
|
|
41
|
-
Skip style nits unless they hide a defect. The CLI adds `comment-justification` findings for new suppressions and workaround comments: decide whether the root cause should be fixed instead; dismiss one only with evidence. Learnings in the pack carry `confidence`; never raise BLOCKER or HIGH only because a `tentative` (one-Run) learning was not followed.
|
|
41
|
+
Skip style nits unless they hide a defect. The CLI adds `comment-justification` findings for new suppressions and workaround comments: decide whether the root cause should be fixed instead; dismiss one only with evidence. It also adds blocking `no-comments` findings (C-26) for any other comment added in product code; never ask the Maker to add a comment. Learnings in the pack carry `confidence`; never raise BLOCKER or HIGH only because a `tentative` (one-Run) learning was not followed.
|
|
42
42
|
|
|
43
43
|
Rubric ACs: when an AC in the Goal Contract has `rubric`, add `rubricScores: [{ac, criterion, pass, evidence}]` to the ledger, one per criterion. `evidence` must be observed (screenshot path, DOM snapshot, measured value), never an impression. A criterion you cannot observe is `pass: false`.
|
|
44
44
|
|
|
@@ -39,7 +39,7 @@ Report Spec and Standards as separate findings. Do not rerank one axis with the
|
|
|
39
39
|
|
|
40
40
|
**Standards** (`axis: "standards"`): `.ai-engineering-loop/conventions.md` plus the smell baseline below. Judgement calls: severity MEDIUM or LOW. Set `hardConvention: true` only when conventions.md states a hard rule that this hunk violates. A smell that hides an AC defect is Spec, not Standards.
|
|
41
41
|
|
|
42
|
-
Skip style nits unless they hide a defect. The CLI adds `comment-justification` findings for new suppressions and workaround comments: decide whether the root cause should be fixed instead; dismiss one only with evidence. Learnings in the pack carry `confidence`; never raise BLOCKER or HIGH only because a `tentative` (one-Run) learning was not followed.
|
|
42
|
+
Skip style nits unless they hide a defect. The CLI adds `comment-justification` findings for new suppressions and workaround comments: decide whether the root cause should be fixed instead; dismiss one only with evidence. It also adds blocking `no-comments` findings (C-26) for any other comment added in product code; never ask the Maker to add a comment. Learnings in the pack carry `confidence`; never raise BLOCKER or HIGH only because a `tentative` (one-Run) learning was not followed.
|
|
43
43
|
|
|
44
44
|
Rubric ACs: when an AC in the Goal Contract has `rubric`, add `rubricScores: [{ac, criterion, pass, evidence}]` to the ledger, one per criterion. `evidence` must be observed (screenshot path, DOM snapshot, measured value), never an impression. A criterion you cannot observe is `pass: false`.
|
|
45
45
|
|
package/CHANGELOG.md
CHANGED
|
@@ -6,9 +6,16 @@ All notable changes to this project are documented here. Versions follow [Semant
|
|
|
6
6
|
|
|
7
7
|
_No changes yet._
|
|
8
8
|
|
|
9
|
+
## 2.9.0 - 2026-11-16
|
|
10
|
+
|
|
11
|
+
From "All Code Is Slop (Except Mine)" 08:06-08:46 (card C-26 in `docs/cards/slop-to-gold-2026-11-16.md`).
|
|
12
|
+
|
|
13
|
+
- **Added:** no comments in product code by default (C-26): every comment line a change adds in a non-test product file (besides suppressions and workaround comments, which stay C-18 findings) becomes one blocking `no-comments` finding per file (`hardConvention: true`, HIGH), so the Judge returns ITERATE. Comment detection follows each language's syntax and ignores strings, shebangs, license headers, `@generated` and tool directives. Opt out per project with `"comments": "allow"` in `.ai-engineering-loop/rules.json`; a reviewer may dismiss one finding only with evidence.
|
|
14
|
+
- **Changed:** C-18 suppression detection now follows each file's comment syntax and also covers `prettier-ignore`, `biome-ignore`, `stylelint-disable`, `rubocop:disable` and `pylint: disable`.
|
|
15
|
+
|
|
9
16
|
## 2.8.0 - 2026-11-16
|
|
10
17
|
|
|
11
|
-
From "All Code Is Slop (Except Mine)" (cards C-17..C-
|
|
18
|
+
From "All Code Is Slop (Except Mine)" (cards C-17..C-25 in `docs/cards/slop-to-gold-2026-11-16.md`).
|
|
12
19
|
|
|
13
20
|
- **Added:** ratchet rules: `learn promote --scope diff` judges only lines the change adds (`$AEL_ADDED_LINES_FILE`, `$AEL_CHANGED_FILES`), so a rule can be promoted on a codebase with old violations; `doctor --harness` reports each diff rule's legacy backlog (C-17).
|
|
14
21
|
- **Added:** suppressions (`eslint-disable`, `@ts-ignore`, `# noqa`, ...) and workaround comments added in product code become `comment-justification` review findings (HIGH without a reason, otherwise MEDIUM); reviewers may dismiss them only with evidence (C-18).
|
|
@@ -31,7 +31,7 @@ Report Spec and Standards as separate findings. Do not rerank one axis with the
|
|
|
31
31
|
|
|
32
32
|
**Standards** (`axis: "standards"`): `.ai-engineering-loop/conventions.md` plus the smell baseline below. Judgement calls: severity MEDIUM or LOW. Set `hardConvention: true` only when conventions.md states a hard rule that this hunk violates. A smell that hides an AC defect is Spec, not Standards.
|
|
33
33
|
|
|
34
|
-
Skip style nits unless they hide a defect. The CLI adds `comment-justification` findings for new suppressions and workaround comments: decide whether the root cause should be fixed instead; dismiss one only with evidence. Learnings in the pack carry `confidence`; never raise BLOCKER or HIGH only because a `tentative` (one-Run) learning was not followed.
|
|
34
|
+
Skip style nits unless they hide a defect. The CLI adds `comment-justification` findings for new suppressions and workaround comments: decide whether the root cause should be fixed instead; dismiss one only with evidence. It also adds blocking `no-comments` findings (C-26) for any other comment added in product code; never ask the Maker to add a comment. Learnings in the pack carry `confidence`; never raise BLOCKER or HIGH only because a `tentative` (one-Run) learning was not followed.
|
|
35
35
|
|
|
36
36
|
Rubric ACs: when an AC in the Goal Contract has `rubric`, add `rubricScores: [{ac, criterion, pass, evidence}]` to the ledger, one per criterion. `evidence` must be observed (screenshot path, DOM snapshot, measured value), never an impression. A criterion you cannot observe is `pass: false`.
|
|
37
37
|
|
|
@@ -106,6 +106,16 @@ Agents write comments to justify not doing the right thing, and comments cannot
|
|
|
106
106
|
|
|
107
107
|
Docs, changelogs, data files and tests are skipped. Unlike C-11, a reviewer may downgrade these with `dismissal: {by, evidence}` (for example generated code); dropping or downgrading one without evidence fails the review gate.
|
|
108
108
|
|
|
109
|
+
## 3d. No Comments in Product Code (C-26)
|
|
110
|
+
|
|
111
|
+
Comments go stale, humans skip them, agents use them to justify not doing the right thing, and nothing enforces them. So AEL bans new comments in product code by default. At `gate review` every other comment line added in a non-test product file (not a suppression or justification, which stay C-18 findings) becomes one `source: "no-comments"` finding per file: `axis: "standards"`, `hardConvention: true`, **HIGH**, VALID, with the line numbers as evidence. It blocks, so the Judge returns ITERATE until the comments are gone.
|
|
112
|
+
|
|
113
|
+
Where the intent goes instead: names, types, tests and lint rules (`learn promote`); rationale goes in the commit message, PR body or `docs/`.
|
|
114
|
+
|
|
115
|
+
Detection follows the file's comment syntax: `//`, `/* */` and `*` lines in C-family, JS/TS, Go, Rust, CSS and similar; `#` in Python, shell, Ruby, Terraform, Makefile and Dockerfile; `<!-- -->` in HTML, Vue, Svelte; `--` in SQL and Lua. Markers inside string literals do not count, nor does `#` glued to a name (JS `#private`). Always allowed: shebangs, `SPDX-License-Identifier`, copyright and `@license`, `@generated`, TS `/// <reference`, `//go:build`/`//go:generate`, encoding lines, `#region`. Docs, data and config files (`.md`, `.json`, `.yml`, `.toml`, ...) and tests are skipped.
|
|
116
|
+
|
|
117
|
+
A reviewer can downgrade a finding (for example public API docs that a doc generator reads) only with `dismissal: {by, evidence}`. A project that needs comments (a library shipping JSDoc, for example) opts out for every Run by having a human add `"comments": "allow"` to `.ai-engineering-loop/rules.json`; C-18 findings still apply.
|
|
118
|
+
|
|
109
119
|
## 4. The 4 Verification Gates
|
|
110
120
|
|
|
111
121
|
1. **Gate 1: Unit & Integration Tests**: All unit and edge-case tests must pass with 0 failures.
|
package/lib/comment-findings.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// C-18 ("All Code Is Slop (Except Mine)", 06:46-08:46): agents write comments
|
|
4
|
-
// to justify not doing the right thing, and comments cannot be enforced.
|
|
5
|
-
// New suppressions and justification comments in product code become
|
|
6
|
-
// standards findings, so the reviewer must decide: root cause or patch?
|
|
7
|
-
// Unlike C-11 integrity findings, a reviewer may dismiss these with evidence.
|
|
8
|
-
|
|
9
3
|
const fs = require('fs');
|
|
10
4
|
const path = require('path');
|
|
11
5
|
const { isTestFile, parseDiff } = require('./verification-integrity.js');
|
|
12
6
|
|
|
13
7
|
const SOURCE = 'comment-justification';
|
|
14
|
-
const
|
|
15
|
-
const
|
|
8
|
+
const NO_COMMENTS_SOURCE = 'no-comments';
|
|
9
|
+
const SKIP_FILE = /\.(md|mdx|txt|rst|json|jsonc|lock|ya?ml|toml|ini|cfg|conf|env|csv|svg|snap|xml|plist)$|(^|\/)(CHANGELOG|LICENSE|NOTICE|README)[^/]*$/i;
|
|
10
|
+
|
|
11
|
+
const SLASH = /\.(c|h|cc|cpp|hpp|cs|java|kt|kts|scala|swift|go|rs|js|jsx|mjs|cjs|ts|tsx|mts|cts|dart|php|css|scss|less|groovy|proto|zig|sol)$/i;
|
|
12
|
+
const HASH = /\.(py|pyi|sh|bash|zsh|fish|rb|pl|pm|r|ps1|tf|hcl|nix|cmake|mk)$|(^|\/)(Makefile|Dockerfile|Gemfile|Rakefile|BUILD|WORKSPACE)$/i;
|
|
13
|
+
const MARKUP = /\.(html?|vue|svelte|astro)$/i;
|
|
14
|
+
const DASH = /\.(sql|lua|hs|elm)$/i;
|
|
15
|
+
|
|
16
|
+
const ALLOWED = /^#!|SPDX-License-Identifier|\bcopyright\b|@license|@preserve|@generated|^\/\/\/\s*<reference|^\/\/go:(build|generate|embed)|^\/\/\s*\+build|-\*-\s*coding|^#\s*(region|endregion)\b|^\/\/\s*#(region|endregion)\b|webpackChunkName|@vite-ignore/i;
|
|
16
17
|
const SUPPRESS = [
|
|
17
18
|
{ pattern: /eslint-disable(?:-next-line|-line)?/, reason: /eslint-disable\S*(?:\s.*?)?\s--\s+(.{10,})/ },
|
|
18
19
|
{ pattern: /@ts-ignore/, reason: /@ts-ignore\s+(.{10,})/ },
|
|
@@ -21,31 +22,84 @@ const SUPPRESS = [
|
|
|
21
22
|
{ pattern: /#\s*noqa/, reason: /noqa\S*\s+#?\s*(.{10,})/ },
|
|
22
23
|
{ pattern: /\/\/\s*nolint/, reason: /nolint\S*\s+\/\/\s*(.{10,})/ },
|
|
23
24
|
{ pattern: /NOSONAR/, reason: /NOSONAR\s+(.{10,})/ },
|
|
24
|
-
{ pattern: /istanbul ignore|c8 ignore/, reason: /ignore \w+\s+(.{10,})/ }
|
|
25
|
+
{ pattern: /istanbul ignore|c8 ignore/, reason: /ignore \w+\s+(.{10,})/ },
|
|
26
|
+
{ pattern: /prettier-ignore|biome-ignore|stylelint-disable|rubocop:disable|pylint:\s*disable/, reason: /(?:prettier-ignore|biome-ignore\S*|stylelint-disable\S*|rubocop:disable\S*|pylint:\s*disable\S*)\s+.*?(?:--|:)\s*(.{10,})/ }
|
|
25
27
|
];
|
|
26
28
|
const JUSTIFICATION = /\b(work-?around|quick[- ]?fix|hack(y)?|temporary|temp fix|for now|band-?aid|kludge|until we|proper fix later|fix (this )?later)\b/i;
|
|
27
29
|
|
|
28
|
-
function
|
|
30
|
+
function commentIndex(text, marker) {
|
|
31
|
+
let quote = null;
|
|
32
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
33
|
+
const ch = text[i];
|
|
34
|
+
if (quote) {
|
|
35
|
+
if (ch === '\\') i += 1;
|
|
36
|
+
else if (ch === quote) quote = null;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
40
|
+
quote = ch;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (text.startsWith(marker, i)) {
|
|
44
|
+
if (marker === '#' && i > 0 && !/\s/.test(text[i - 1])) continue;
|
|
45
|
+
return i;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function commentOf(file, text) {
|
|
52
|
+
if (SLASH.test(file)) {
|
|
53
|
+
if (/^\s*\*(?!\*\/)/.test(text) && !/^\s*\*\s*[\w(]+\s*[=;)]/.test(text)) return text.trim();
|
|
54
|
+
for (const marker of ['//', '/*']) {
|
|
55
|
+
const at = commentIndex(text, marker);
|
|
56
|
+
if (at !== -1) return text.slice(at).trim();
|
|
57
|
+
}
|
|
58
|
+
const jsx = text.indexOf('{/*');
|
|
59
|
+
return jsx !== -1 ? text.slice(jsx).trim() : null;
|
|
60
|
+
}
|
|
61
|
+
if (HASH.test(file)) {
|
|
62
|
+
const at = commentIndex(text, '#');
|
|
63
|
+
return at !== -1 ? text.slice(at).trim() : null;
|
|
64
|
+
}
|
|
65
|
+
if (MARKUP.test(file)) {
|
|
66
|
+
const at = text.indexOf('<!--');
|
|
67
|
+
if (at !== -1) return text.slice(at).trim();
|
|
68
|
+
const slash = commentIndex(text, '//');
|
|
69
|
+
return slash !== -1 && /^\s*\/\//.test(text) ? text.slice(slash).trim() : null;
|
|
70
|
+
}
|
|
71
|
+
if (DASH.test(file)) {
|
|
72
|
+
const at = commentIndex(text, '--');
|
|
73
|
+
return at !== -1 ? text.slice(at).trim() : null;
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function loadProjectRules(rootDir) {
|
|
29
79
|
try {
|
|
30
|
-
|
|
31
|
-
return (value.justificationPatterns || []).map((text) => new RegExp(text, 'i'));
|
|
80
|
+
return JSON.parse(fs.readFileSync(path.join(rootDir, '.ai-engineering-loop', 'rules.json'), 'utf8'));
|
|
32
81
|
} catch {
|
|
33
|
-
return
|
|
82
|
+
return {};
|
|
34
83
|
}
|
|
35
84
|
}
|
|
36
85
|
|
|
37
|
-
function
|
|
86
|
+
function loadExtraPatterns(rootDir) {
|
|
87
|
+
return (loadProjectRules(rootDir).justificationPatterns || []).map((text) => new RegExp(text, 'i'));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function scanComments(diffText, { extraPatterns = [], noComments = true } = {}) {
|
|
38
91
|
const findings = [];
|
|
39
92
|
let n = 0;
|
|
40
93
|
for (const file of parseDiff(diffText)) {
|
|
41
94
|
if (file.deleted || isTestFile(file.path) || SKIP_FILE.test(file.path)) continue;
|
|
95
|
+
const plain = [];
|
|
42
96
|
for (const added of file.added) {
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
97
|
+
const comment = commentOf(file.path, added.text);
|
|
98
|
+
if (!comment) continue;
|
|
45
99
|
const location = `${file.path}:${added.line}`;
|
|
46
|
-
const suppress = SUPPRESS.find((item) => item.pattern.test(
|
|
100
|
+
const suppress = SUPPRESS.find((item) => item.pattern.test(comment));
|
|
47
101
|
if (suppress) {
|
|
48
|
-
const reasoned = suppress.reason.test(
|
|
102
|
+
const reasoned = suppress.reason.test(comment);
|
|
49
103
|
findings.push({
|
|
50
104
|
id: `COMMENT-${++n}`,
|
|
51
105
|
axis: 'standards',
|
|
@@ -53,59 +107,81 @@ function scanComments(diffText, { extraPatterns = [] } = {}) {
|
|
|
53
107
|
failureScenario: reasoned
|
|
54
108
|
? 'A lint/type/coverage suppression was added; it hides the signal instead of fixing what the check found'
|
|
55
109
|
: 'A lint/type/coverage suppression was added with no reason; the next agent will copy it as the established pattern',
|
|
56
|
-
evidence: `added line: ${text.trim().slice(0, 160)}`,
|
|
110
|
+
evidence: `added line: ${added.text.trim().slice(0, 160)}`,
|
|
57
111
|
severity: reasoned ? 'MEDIUM' : 'HIGH',
|
|
58
112
|
validity: 'VALID',
|
|
59
113
|
disposition: 'WEAK',
|
|
60
|
-
concreteAlternativeDiff: `- ${text.trim()}\n+ (remove the suppression and fix the code the check flagged)`,
|
|
114
|
+
concreteAlternativeDiff: `- ${added.text.trim()}\n+ (remove the suppression and fix the code the check flagged)`,
|
|
61
115
|
source: SOURCE
|
|
62
116
|
});
|
|
63
117
|
continue;
|
|
64
118
|
}
|
|
65
|
-
|
|
66
|
-
if (JUSTIFICATION.test(
|
|
119
|
+
if (ALLOWED.test(comment)) continue;
|
|
120
|
+
if (JUSTIFICATION.test(comment) || extraPatterns.some((pattern) => pattern.test(comment))) {
|
|
67
121
|
findings.push({
|
|
68
122
|
id: `COMMENT-${++n}`,
|
|
69
123
|
axis: 'standards',
|
|
70
124
|
location,
|
|
71
125
|
failureScenario: 'A comment justifies a workaround instead of fixing the root cause; comments cannot be enforced and the workaround spreads',
|
|
72
|
-
evidence: `added line: ${text.trim().slice(0, 160)}`,
|
|
126
|
+
evidence: `added line: ${added.text.trim().slice(0, 160)}`,
|
|
73
127
|
severity: 'MEDIUM',
|
|
74
128
|
validity: 'VALID',
|
|
75
129
|
disposition: 'WEAK',
|
|
76
130
|
source: SOURCE
|
|
77
131
|
});
|
|
132
|
+
continue;
|
|
78
133
|
}
|
|
134
|
+
plain.push(added);
|
|
135
|
+
}
|
|
136
|
+
if (noComments && plain.length) {
|
|
137
|
+
const lines = plain.map((added) => added.line);
|
|
138
|
+
findings.push({
|
|
139
|
+
id: `NOCOMMENT-${++n}`,
|
|
140
|
+
axis: 'standards',
|
|
141
|
+
hardConvention: true,
|
|
142
|
+
location: `${file.path}:${lines[0]}`,
|
|
143
|
+
failureScenario: `${plain.length} comment line(s) added in product code; comments go stale, cannot be enforced, and agents copy them as license to explain instead of fix`,
|
|
144
|
+
evidence: `comment lines ${lines.slice(0, 12).join(', ')}${lines.length > 12 ? ', ...' : ''}; first: ${plain[0].text.trim().slice(0, 120)}`,
|
|
145
|
+
severity: 'HIGH',
|
|
146
|
+
validity: 'VALID',
|
|
147
|
+
disposition: 'WEAK',
|
|
148
|
+
concreteAlternativeDiff: `- ${plain[0].text.trim()}\n+ (delete it: put intent in names, types, tests or a lint rule; put rationale in the commit message or docs/)`,
|
|
149
|
+
source: NO_COMMENTS_SOURCE
|
|
150
|
+
});
|
|
79
151
|
}
|
|
80
152
|
}
|
|
81
153
|
return findings;
|
|
82
154
|
}
|
|
83
155
|
|
|
84
156
|
function scanRunComments(rootDir, run) {
|
|
157
|
+
const rules = loadProjectRules(rootDir);
|
|
85
158
|
try {
|
|
86
|
-
return scanComments(fs.readFileSync(path.join(rootDir, run.artifacts.diff.path), 'utf8'), {
|
|
159
|
+
return scanComments(fs.readFileSync(path.join(rootDir, run.artifacts.diff.path), 'utf8'), {
|
|
160
|
+
extraPatterns: (rules.justificationPatterns || []).map((text) => new RegExp(text, 'i')),
|
|
161
|
+
noComments: rules.comments !== 'allow'
|
|
162
|
+
});
|
|
87
163
|
} catch {
|
|
88
164
|
return [];
|
|
89
165
|
}
|
|
90
166
|
}
|
|
91
167
|
|
|
92
|
-
// Reviewers may downgrade these, but only with dismissal.evidence.
|
|
93
168
|
function mergeCommentFindings(ledger, findings) {
|
|
94
169
|
const errors = [];
|
|
95
|
-
const
|
|
170
|
+
const sources = new Set([SOURCE, NO_COMMENTS_SOURCE]);
|
|
171
|
+
const existing = new Map((ledger.findings || []).filter((item) => sources.has(item.source)).map((item) => [`${item.source}|${item.location}`, item]));
|
|
96
172
|
const additions = [];
|
|
97
173
|
for (const item of findings) {
|
|
98
|
-
const present = existing.get(item.location);
|
|
174
|
+
const present = existing.get(`${item.source}|${item.location}`);
|
|
99
175
|
if (!present) {
|
|
100
176
|
additions.push(item);
|
|
101
177
|
continue;
|
|
102
178
|
}
|
|
103
|
-
const downgraded = present.validity !== 'VALID' || present.severity !== item.severity;
|
|
179
|
+
const downgraded = present.validity !== 'VALID' || present.severity !== item.severity || (item.hardConvention && present.hardConvention !== true);
|
|
104
180
|
if (downgraded && !String(present.dismissal?.evidence || '').trim()) {
|
|
105
|
-
errors.push(`${present.id} (${present.location}) was downgraded without dismissal.evidence. FIX: restore it, or add dismissal: {by, evidence} explaining why
|
|
181
|
+
errors.push(`${present.id} (${present.location}) was downgraded without dismissal.evidence. FIX: restore it, or add dismissal: {by, evidence} explaining why this comment or suppression must stay.`);
|
|
106
182
|
}
|
|
107
183
|
}
|
|
108
184
|
return { ledger: { ...ledger, findings: [...(ledger.findings || []), ...additions] }, added: additions.length, errors };
|
|
109
185
|
}
|
|
110
186
|
|
|
111
|
-
module.exports = { SOURCE, mergeCommentFindings, scanComments, scanRunComments };
|
|
187
|
+
module.exports = { NO_COMMENTS_SOURCE, SOURCE, commentOf, loadExtraPatterns, mergeCommentFindings, scanComments, scanRunComments };
|
package/lib/gates.js
CHANGED
|
@@ -532,8 +532,8 @@ function mergeCommentJustifications(rootDir, run) {
|
|
|
532
532
|
}
|
|
533
533
|
const merged = mergeCommentFindings(ledger, scanRunComments(rootDir, run));
|
|
534
534
|
if (merged.errors.length) {
|
|
535
|
-
throw gateError('Review gate failed (comment-
|
|
536
|
-
{ why: 'Comments and suppressions are how agents justify skipping the root cause; dropping the finding silently hides that decision.', fix: 'Restore the finding, or record dismissal: {by, evidence} for each one.' });
|
|
535
|
+
throw gateError('Review gate failed (comment or no-comments finding dropped)', merged.errors,
|
|
536
|
+
{ why: 'Comments and suppressions are how agents justify skipping the root cause, and new comments in product code are banned by default (C-26); dropping the finding silently hides that decision.', fix: 'Restore the finding, or record dismissal: {by, evidence} for each one.' });
|
|
537
537
|
}
|
|
538
538
|
if (merged.added) fs.writeFileSync(filePath, `${JSON.stringify(merged.ledger, null, 2)}\n`, { mode: 0o600 });
|
|
539
539
|
return merged.added;
|
package/package.json
CHANGED