karajan-code 4.49.0 → 4.49.1
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/package.json +1 -1
- package/src/commands/review-gate.js +10 -3
- package/src/config/defaults.js +4 -2
- package/src/environment/playbook.js +2 -2
- package/src/git/hu-automation.js +11 -1
- package/src/harden/advisory.js +20 -1
- package/src/harden/sentinel-hooks.js +5 -2
- package/src/orchestrator/drivers/init-context.js +12 -1
- package/src/planning-game/client.js +25 -11
- package/src/planning-game/pipeline-adapter.js +8 -5
- package/src/policy/exceptions.js +7 -3
- package/src/review/card-first.js +3 -1
- package/src/spec-review/run-spec-review.js +7 -0
- package/templates/roles/coder.md +1 -1
package/package.json
CHANGED
|
@@ -246,7 +246,11 @@ export async function reviewGateCommand({ config, logger = null, flags = {} }) {
|
|
|
246
246
|
const locInv = pol.errors.length === 0
|
|
247
247
|
? (pol.policy.invariants || []).find((i) => i.kind === "diff-threshold" && i.metric === "net_lines_added")
|
|
248
248
|
: null;
|
|
249
|
-
|
|
249
|
+
// KJC-BUG-0326 (#2085): two tiers. ~150 is the ideal (method_gates.pr_size_warn);
|
|
250
|
+
// up to the limit (the policy's net_lines_added max, else method_gates.pr_size_max,
|
|
251
|
+
// 200) is allowed without asking; above the limit, partition.
|
|
252
|
+
const sizeIdeal = config?.method_gates?.pr_size_warn ?? 150;
|
|
253
|
+
const sizeWarn = locInv?.max ?? config?.method_gates?.pr_size_max ?? 200;
|
|
250
254
|
const sizeSource = locInv ? `policy [${locInv.id}]` : "method_gates";
|
|
251
255
|
if (sizeWarn > 0) {
|
|
252
256
|
const numstat = await rawDiff(flags.range, ["--numstat"]);
|
|
@@ -258,6 +262,9 @@ export async function reviewGateCommand({ config, logger = null, flags = {} }) {
|
|
|
258
262
|
// Said out loud: an exemption nobody sees is indistinguishable from a gate
|
|
259
263
|
// that is not looking.
|
|
260
264
|
if (exempt > 0) console.log(`ℓ pr-size: ${exempt} line(s) exempt from the budget (generated output and human docs; AI-rule files always count)`);
|
|
265
|
+
if (added > sizeIdeal && added <= sizeWarn) {
|
|
266
|
+
console.log(`ℓ pr-size: ${added} lines added, over the ~${sizeIdeal} ideal, within the ${sizeWarn} limit: allowed, nothing to ask`);
|
|
267
|
+
}
|
|
261
268
|
if (added > sizeWarn) {
|
|
262
269
|
// KJC-TSK-0795 AC5: say how much of the weight is the module's OWN tests —
|
|
263
270
|
// partitioning is a decision, and it must never split code from its tests.
|
|
@@ -265,12 +272,12 @@ export async function reviewGateCommand({ config, logger = null, flags = {} }) {
|
|
|
265
272
|
const sizePolicy = config?.method_gates?.pr_size || "warn";
|
|
266
273
|
// ADR 0015: no env escape — an exception is the user's label on the PR, judged in CI.
|
|
267
274
|
if (sizePolicy === "block") {
|
|
268
|
-
const reason = `${added} lines added${split}
|
|
275
|
+
const reason = `${added} lines added${split} is over the ${sizeWarn}-line limit (${sizeSource}; method_gates.pr_size: block) — partition the work; an exception is your user's large-pr-justified label on the PR`;
|
|
269
276
|
console.log(`✗ pr-size gate: ${reason}`);
|
|
270
277
|
process.exitCode = 1;
|
|
271
278
|
return { verdict: "rejected", reviewer: "pr-size", issues: [{ severity: "high", description: reason }] };
|
|
272
279
|
} else {
|
|
273
|
-
console.log(`⚠ pr-size: ${added} lines added${split} (
|
|
280
|
+
console.log(`⚠ pr-size: ${added} lines added${split}, over the ${sizeWarn}-line limit (ideal ~${sizeIdeal}, source: ${sizeSource}) — partition the work before committing (method_gates.pr_size: block to harden)`);
|
|
274
281
|
}
|
|
275
282
|
}
|
|
276
283
|
}
|
package/src/config/defaults.js
CHANGED
|
@@ -81,9 +81,11 @@ const DEFAULTS = {
|
|
|
81
81
|
card_first_exempt_branches: ["chore/release-"],
|
|
82
82
|
// MG-B: source changes without a test change — "warn" | "block".
|
|
83
83
|
tests_with_code: "warn",
|
|
84
|
-
// MG-C:
|
|
85
|
-
//
|
|
84
|
+
// MG-C + KJC-BUG-0326: ~pr_size_warn added lines is the ideal; up to
|
|
85
|
+
// pr_size_max is allowed without asking; above it, partition (warn, or
|
|
86
|
+
// block with pr_size: "block"). A policy net_lines_added max wins over pr_size_max.
|
|
86
87
|
pr_size_warn: 150,
|
|
88
|
+
pr_size_max: 200,
|
|
87
89
|
// CLM-B (claims-with-evidence ADR): the Stop gate crosses the hard data of
|
|
88
90
|
// the turn's final message against that turn's tool outputs. "off" (adoption
|
|
89
91
|
// is explicit) | "warn" (report only) | "block" (a datum DENIED by its own
|
|
@@ -76,8 +76,8 @@ ${panel ? `${panel}\n` : ""}- Security findings are never overridable — not ev
|
|
|
76
76
|
\`kj audit --security\` (zero tokens) and remediate BEFORE the review.
|
|
77
77
|
- A design decision the card's AC don't cover belongs to the USER: record
|
|
78
78
|
it as a proposed ADR (\`kj adr add\`) and ask — never bury it in a PR
|
|
79
|
-
bullet.
|
|
80
|
-
|
|
79
|
+
bullet. Diff size: ~150 net lines of code is the ideal, up to 200 is
|
|
80
|
+
allowed without asking, above 200 partition, always.
|
|
81
81
|
- A non-trivial plan names at least two approaches — one as if the
|
|
82
82
|
codebase didn't exist — and says why the winner won. Following the
|
|
83
83
|
legacy line is a choice, never a default.
|
package/src/git/hu-automation.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { commitAll, pushBranch, createPullRequest, hasChanges } from "../utils/git.js";
|
|
6
6
|
import { runCommand } from "../utils/process.js";
|
|
7
|
+
import { stampStagedVerdict } from "../review/verdict-store.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Build a git-safe branch name for an HU story.
|
|
@@ -184,7 +185,16 @@ export async function finalizeHuCommit({ story, branchName, config, logger, cwd
|
|
|
184
185
|
const title = story.title || story.id;
|
|
185
186
|
const commitMsg = `feat(${story.id}): ${title}`;
|
|
186
187
|
if (config.git?.auto_commit) {
|
|
187
|
-
|
|
188
|
+
// KJC-BUG-0323: this commit runs after the HU's reviewer approved, so it
|
|
189
|
+
// records that verdict for the staged diff, as the other post-review commits do.
|
|
190
|
+
const commitRes = await commitAll(commitMsg, cwd, {
|
|
191
|
+
beforeCommit: ({ paths } = {}) => stampStagedVerdict({
|
|
192
|
+
projectDir: cwd || config.projectDir || process.cwd(),
|
|
193
|
+
paths,
|
|
194
|
+
reviewer: config.reviewer || "pipeline-reviewer",
|
|
195
|
+
summary: `kj run HU ${story.id}: reviewer approved`,
|
|
196
|
+
}),
|
|
197
|
+
});
|
|
188
198
|
if (commitRes) {
|
|
189
199
|
result.committed = true;
|
|
190
200
|
logger.info(`HU ${story.id}: committed on '${branchName}'`);
|
package/src/harden/advisory.js
CHANGED
|
@@ -166,9 +166,28 @@ export function classifyArtifact(searchDir, artifact, altDirs = [searchDir]) {
|
|
|
166
166
|
* own root (monorepo-aware, mirroring installConfigsForRoots). `minimal`
|
|
167
167
|
* profile ships no config, so there is nothing to compare.
|
|
168
168
|
*/
|
|
169
|
+
// KJC-BUG-0335 (#2094): the method's own pieces, not only the configs. Without
|
|
170
|
+
// them the report said "0 missing" while the review gate demanded the Sentinel.
|
|
171
|
+
const METHOD_PIECES = [
|
|
172
|
+
{ id: "sentinel", what: "the Sentinel (it records the session, the RAG queries the review gate needs among them)",
|
|
173
|
+
files: [".karajan/harness/pretooluse-sentinel.mjs", ".karajan/harness/posttooluse.mjs", ".karajan/harness/stop.mjs"] },
|
|
174
|
+
{ id: "git-hooks", what: "the git hooks", files: [".karajan/hooks/pre-commit", ".karajan/hooks/commit-msg", ".karajan/hooks/pre-push"] },
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
function methodPiece(projectDir, { id, what, files }) {
|
|
178
|
+
const head = { dir: ".", id, file: files[0], currentVersion: null, managedVersion: null, upToDate: null, improvements: [], mergeable: false };
|
|
179
|
+
const missing = files.filter((f) => !existsSync(join(projectDir, f)));
|
|
180
|
+
return missing.length === 0
|
|
181
|
+
? { ...head, status: "KJ_MANAGED", foundAt: files[0], recommendation: "keep", rationale: `${what}: installed` }
|
|
182
|
+
: { ...head, status: "MISSING", foundAt: null, missing, recommendation: "install", rationale: `kj harden (without --report) installs ${what}; missing: ${missing.join(", ")}` };
|
|
183
|
+
}
|
|
184
|
+
|
|
169
185
|
export function compareHarden({ projectDir = process.cwd(), profile = "standard", only = [], exclude = [] } = {}) {
|
|
170
186
|
if (profile === "minimal") return { artifacts: [] };
|
|
171
|
-
const artifacts =
|
|
187
|
+
const artifacts = [
|
|
188
|
+
...METHOD_PIECES.map((piece) => methodPiece(projectDir, piece)),
|
|
189
|
+
...UNIVERSAL_CONFIGS.map((cfg) => ({ dir: ".", ...classifyArtifact(projectDir, toArtifact(cfg)) })),
|
|
190
|
+
];
|
|
172
191
|
for (const { dir, language } of detectStackRoots(projectDir, { only, exclude })) {
|
|
173
192
|
const searchDir = dir === "." ? projectDir : join(projectDir, dir);
|
|
174
193
|
for (const cfg of CONFIGS_BY_LANGUAGE[language] ?? []) {
|
|
@@ -1423,8 +1423,11 @@ export function installSentinelHooks({ projectDir = process.cwd(), logger = cons
|
|
|
1423
1423
|
};
|
|
1424
1424
|
const [lib, post, stop, pre] = Object.entries(SCRIPT_BODIES).map(([name, body]) => {
|
|
1425
1425
|
if (keepsItsSeal(name)) {
|
|
1426
|
-
|
|
1427
|
-
|
|
1426
|
+
const abs = join(projectDir, ".karajan", "harness", name);
|
|
1427
|
+
// KJC-BUG-0325: only a sealed guard the current template would change is
|
|
1428
|
+
// waiting for the human; one identical to it has nothing to advance.
|
|
1429
|
+
if (readFileSync(abs, "utf8") !== body) deferred.push(name);
|
|
1430
|
+
return abs;
|
|
1428
1431
|
}
|
|
1429
1432
|
return writeHarnessScript(projectDir, name, body);
|
|
1430
1433
|
});
|
|
@@ -36,6 +36,17 @@ import { getIntegration } from "../integrations.js";
|
|
|
36
36
|
import { tryAutoStartBoard } from "./post-loop.js";
|
|
37
37
|
import { runPreLoopStages } from "./pre-loop.js";
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* KJC-BUG-0324: the coder is built before the pre-loop, with the run's first
|
|
41
|
+
* config, so what the pre-loop resolves (the Domain Curator's domainContext,
|
|
42
|
+
* the methodology) never reached its prompt. The run and the coder both take
|
|
43
|
+
* the resolved config; the coder is initialized after this.
|
|
44
|
+
*/
|
|
45
|
+
export function adoptPreLoopConfig(ctx, updatedConfig) {
|
|
46
|
+
ctx.config = updatedConfig;
|
|
47
|
+
ctx.coderRoleInstance.config = updatedConfig;
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
export async function initFlowContext({ task, config, logger, emitter, askQuestion, pgTaskId, pgProject, flags }) {
|
|
40
51
|
// Auto-init .karajan/ if missing (copies coder-rules, review-rules, role templates)
|
|
41
52
|
const initProjectDir = config.projectDir || process.cwd();
|
|
@@ -182,7 +193,7 @@ export async function initFlowContext({ task, config, logger, emitter, askQuesti
|
|
|
182
193
|
|
|
183
194
|
const preLoopResult = await runPreLoopStages({ config, logger, emitter, eventBase: ctx.eventBase, session: ctx.session, flags, pipelineFlags: ctx.pipelineFlags, coderRole: ctx.coderRole, trackBudget: ctx.trackBudget, task, askQuestion, pgTaskId, pgProject, stageResults: ctx.stageResults, brainCtx: ctx.brainCtx });
|
|
184
195
|
ctx.plannedTask = preLoopResult.plannedTask;
|
|
185
|
-
ctx
|
|
196
|
+
adoptPreLoopConfig(ctx, preLoopResult.updatedConfig);
|
|
186
197
|
|
|
187
198
|
// --- Session Journal: persist pre-loop outputs + display plan summary ---
|
|
188
199
|
const reportDir = ctx.config.output?.report_dir || ".reviews";
|
|
@@ -14,8 +14,22 @@ import { withRetry } from "../utils/retry.js";
|
|
|
14
14
|
const DEFAULT_API_URL = "http://localhost:3000/api";
|
|
15
15
|
const DEFAULT_TIMEOUT_MS = 10000;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// KJC-BUG-0322: PG_API_URL > planning_game.api_url (passed by the caller) > localhost.
|
|
18
|
+
function getApiUrl(apiUrl) {
|
|
19
|
+
const fromEnv = process.env.PG_API_URL?.trim();
|
|
20
|
+
if (fromEnv) return fromEnv;
|
|
21
|
+
const fromConfig = typeof apiUrl === "string" ? apiUrl.trim() : "";
|
|
22
|
+
return fromConfig ? fromConfig : DEFAULT_API_URL;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Origin and path only: credentials or a query token in a configured URL never reach a log.
|
|
26
|
+
function urlForMessage(url) {
|
|
27
|
+
try {
|
|
28
|
+
const u = new URL(url);
|
|
29
|
+
return `${u.origin}${u.pathname}`;
|
|
30
|
+
} catch {
|
|
31
|
+
return "(invalid Planning Game URL)";
|
|
32
|
+
}
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
async function fetchWithTimeout(url, options = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
@@ -37,7 +51,7 @@ async function fetchWithTimeout(url, options = {}, timeoutMs = DEFAULT_TIMEOUT_M
|
|
|
37
51
|
err.httpStatus = 408;
|
|
38
52
|
throw err;
|
|
39
53
|
}
|
|
40
|
-
throw new Error(`Planning Game network error: ${error?.message
|
|
54
|
+
throw new Error(`Planning Game network error at ${urlForMessage(url)}: ${error?.message ?? "unknown error"}`, { cause: error });
|
|
41
55
|
} finally {
|
|
42
56
|
clearTimeout(timeoutId);
|
|
43
57
|
}
|
|
@@ -58,15 +72,15 @@ async function parseJsonResponse(response) {
|
|
|
58
72
|
}
|
|
59
73
|
}
|
|
60
74
|
|
|
61
|
-
export async function fetchCard({ projectId, cardId, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
62
|
-
const url = `${getApiUrl()}/projects/${encodeURIComponent(projectId)}/cards/${encodeURIComponent(cardId)}`;
|
|
75
|
+
export async function fetchCard({ projectId, cardId, apiUrl, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
76
|
+
const url = `${getApiUrl(apiUrl)}/projects/${encodeURIComponent(projectId)}/cards/${encodeURIComponent(cardId)}`;
|
|
63
77
|
const response = await fetchWithRetry(url, {}, timeoutMs);
|
|
64
78
|
const data = await parseJsonResponse(response);
|
|
65
79
|
return data?.card || data;
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
export async function updateCard({ projectId, cardId: _cardId, firebaseId, updates, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
69
|
-
const url = `${getApiUrl()}/projects/${encodeURIComponent(projectId)}/cards/${encodeURIComponent(firebaseId)}`;
|
|
82
|
+
export async function updateCard({ projectId, cardId: _cardId, firebaseId, updates, apiUrl, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
83
|
+
const url = `${getApiUrl(apiUrl)}/projects/${encodeURIComponent(projectId)}/cards/${encodeURIComponent(firebaseId)}`;
|
|
70
84
|
const response = await fetchWithRetry(
|
|
71
85
|
url,
|
|
72
86
|
{
|
|
@@ -79,8 +93,8 @@ export async function updateCard({ projectId, cardId: _cardId, firebaseId, updat
|
|
|
79
93
|
return parseJsonResponse(response);
|
|
80
94
|
}
|
|
81
95
|
|
|
82
|
-
export async function createCard({ projectId, card, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
83
|
-
const url = `${getApiUrl()}/projects/${encodeURIComponent(projectId)}/cards`;
|
|
96
|
+
export async function createCard({ projectId, card, apiUrl, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
97
|
+
const url = `${getApiUrl(apiUrl)}/projects/${encodeURIComponent(projectId)}/cards`;
|
|
84
98
|
const response = await fetchWithRetry(
|
|
85
99
|
url,
|
|
86
100
|
{
|
|
@@ -93,8 +107,8 @@ export async function createCard({ projectId, card, timeoutMs = DEFAULT_TIMEOUT_
|
|
|
93
107
|
return parseJsonResponse(response);
|
|
94
108
|
}
|
|
95
109
|
|
|
96
|
-
export async function relateCards({ projectId, sourceCardId, targetCardId, relationType, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
97
|
-
const url = `${getApiUrl()}/projects/${encodeURIComponent(projectId)}/cards/relate`;
|
|
110
|
+
export async function relateCards({ projectId, sourceCardId, targetCardId, relationType, apiUrl, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
111
|
+
const url = `${getApiUrl(apiUrl)}/projects/${encodeURIComponent(projectId)}/cards/relate`;
|
|
98
112
|
const response = await fetchWithRetry(
|
|
99
113
|
url,
|
|
100
114
|
{
|
|
@@ -63,9 +63,10 @@ async function handlePgDecomposition({ triageResult, pgTaskId, pgProject, config
|
|
|
63
63
|
const normalizedAnswer = (answer || "").trim().toLowerCase();
|
|
64
64
|
const isAccept = normalizedAnswer === "1" || normalizedAnswer === "yes" || normalizedAnswer === "sí" || normalizedAnswer === "si";
|
|
65
65
|
if (isAccept) {
|
|
66
|
-
const
|
|
66
|
+
const apiUrl = config.planning_game?.api_url;
|
|
67
|
+
const parentCard = await fetchCard({ projectId: pgProject, cardId: pgTaskId, apiUrl }).catch(() => null);
|
|
67
68
|
const createdSubtasks = await createDecompositionSubtasks({
|
|
68
|
-
client: { createCard, relateCards },
|
|
69
|
+
client: { createCard: (args) => createCard({ ...args, apiUrl }), relateCards: (args) => relateCards({ ...args, apiUrl }) },
|
|
69
70
|
projectId: pgProject,
|
|
70
71
|
parentCardId: pgTaskId,
|
|
71
72
|
parentFirebaseId: parentCard?.firebaseId || null,
|
|
@@ -129,7 +130,8 @@ export async function markPgCardToValidate({ pgCard, pgProject, config, session,
|
|
|
129
130
|
projectId: pgProject,
|
|
130
131
|
cardId: session.pg_task_id,
|
|
131
132
|
firebaseId: pgCard.firebaseId,
|
|
132
|
-
updates: pgUpdates
|
|
133
|
+
updates: pgUpdates,
|
|
134
|
+
apiUrl: config.planning_game?.api_url
|
|
133
135
|
});
|
|
134
136
|
logger.info(`Planning Game: ${session.pg_task_id} → To Validate`);
|
|
135
137
|
} catch (err) {
|
|
@@ -201,9 +203,9 @@ async function markPgCardInProgress({ pgTaskId, pgProject, config, logger }) {
|
|
|
201
203
|
// its own HUs and said approved. With a card named, no card is a loud stop.
|
|
202
204
|
let pgCard;
|
|
203
205
|
try {
|
|
204
|
-
pgCard = await fetchCard({ projectId: pgProject, cardId: pgTaskId });
|
|
206
|
+
pgCard = await fetchCard({ projectId: pgProject, cardId: pgTaskId, apiUrl: config.planning_game?.api_url });
|
|
205
207
|
} catch (err) {
|
|
206
|
-
throw new Error(`Planning Game: card ${pgTaskId} could not be read (${err.message}): the run would implement without the card's acceptance criteria. Check PG_API_URL, or run without pgTask.`, { cause: err });
|
|
208
|
+
throw new Error(`Planning Game: card ${pgTaskId} could not be read (${err.message}): the run would implement without the card's acceptance criteria. Check planning_game.api_url in the config (PG_API_URL overrides it), or run without pgTask.`, { cause: err });
|
|
207
209
|
}
|
|
208
210
|
if (!pgCard) throw new Error(`Planning Game: card ${pgTaskId} not found in project ${pgProject}: the run would implement without the card's acceptance criteria. Check the id, or run without pgTask.`);
|
|
209
211
|
try {
|
|
@@ -212,6 +214,7 @@ async function markPgCardInProgress({ pgTaskId, pgProject, config, logger }) {
|
|
|
212
214
|
projectId: pgProject,
|
|
213
215
|
cardId: pgTaskId,
|
|
214
216
|
firebaseId: pgCard.firebaseId,
|
|
217
|
+
apiUrl: config.planning_game?.api_url,
|
|
215
218
|
updates: {
|
|
216
219
|
status: "In Progress",
|
|
217
220
|
startDate: new Date().toISOString(),
|
package/src/policy/exceptions.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { appendFileSync, mkdirSync, readFileSync } from "node:fs";
|
|
8
8
|
import { join } from "node:path";
|
|
9
|
-
import {
|
|
9
|
+
import { userInfo } from "node:os";
|
|
10
|
+
import { getKarajanHome } from "../utils/paths.js";
|
|
10
11
|
import { spawnSync } from "node:child_process";
|
|
11
12
|
import { recordPolicyException as kernelRecord } from "@karajan-family/governance";
|
|
12
13
|
|
|
@@ -36,7 +37,10 @@ export function loadStandingExceptions(projectDir, { home } = {}) {
|
|
|
36
37
|
* Ruta del almacén GLOBAL (~/.karajan): excepciones de la máquina, no de un
|
|
37
38
|
* proyecto. `home` es inyectable SOLO para tests.
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
// KJC-BUG-0337: with no injected home it is the Karajan home (honours KARAJAN_HOME,
|
|
41
|
+
// and the suite's temp home), not homedir(): the tests read the machine's real grants.
|
|
42
|
+
const globalDir = (home) => (home ? join(home, ".karajan") : getKarajanHome());
|
|
43
|
+
export const globalExceptionsFile = ({ home } = {}) => join(globalDir(home), "policy-exceptions.jsonl");
|
|
40
44
|
|
|
41
45
|
function readRecordsAt(file, origin) {
|
|
42
46
|
let raw;
|
|
@@ -85,7 +89,7 @@ function defaultAppend(projectDir, line) {
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
const globalAppend = (home) => (_projectDir, line) => {
|
|
88
|
-
const dir =
|
|
92
|
+
const dir = globalDir(home);
|
|
89
93
|
mkdirSync(dir, { recursive: true });
|
|
90
94
|
appendFileSync(join(dir, "policy-exceptions.jsonl"), line, "utf8");
|
|
91
95
|
};
|
package/src/review/card-first.js
CHANGED
|
@@ -11,7 +11,9 @@ import { listPlans, loadPlan } from "../plan/plan-store.js";
|
|
|
11
11
|
import { escapeRegExp } from "../utils/escape-regexp.js";
|
|
12
12
|
import { verifyCardAlive } from "./card-verify.js";
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// KJC-BUG-0323: coding/reviewing are the run working the HU, certified is ready
|
|
15
|
+
// to run; the gate blocked the pipeline's own commit on its own HU.
|
|
16
|
+
const LIVE_STATUSES = new Set(["pending", "running", "failed", "certified", "coding", "reviewing"]);
|
|
15
17
|
// Card-shaped reference: LIN-123, bb-002 and multi-segment ids like
|
|
16
18
|
// KJC-TSK-0684 (optional middle segments) — tight enough to skip slugs.
|
|
17
19
|
// Shared with the method report (MG-D): one pattern, one truth.
|
|
@@ -51,6 +51,13 @@ export async function runSpecReview({ spec, config, logger, askQuestion, flags =
|
|
|
51
51
|
return { proceed: true, skipped: true };
|
|
52
52
|
}
|
|
53
53
|
if (!spec || !String(spec).trim()) return { proceed: true, skipped: true };
|
|
54
|
+
// KJC-BUG-0321 (#2074): with --plan the spec is the plan's original task, which
|
|
55
|
+
// `kj plan` reviewed when it generated the plan, and the HUs were certified since.
|
|
56
|
+
// Reviewing it again flags the plan, not the HUs being run.
|
|
57
|
+
if (flags.plan) {
|
|
58
|
+
logger?.info?.(`Spec review skipped: plan ${flags.plan} was reviewed when it was generated and its HUs certified.`);
|
|
59
|
+
return { proceed: true, skipped: true };
|
|
60
|
+
}
|
|
54
61
|
|
|
55
62
|
const role = new SpecReviewerRole({ config, logger });
|
|
56
63
|
await role.init({ task: spec });
|
package/templates/roles/coder.md
CHANGED
|
@@ -52,7 +52,7 @@ Karajan projects MAY enforce a CI gate that fails any PR whose net delta exceeds
|
|
|
52
52
|
|
|
53
53
|
- Stay under **~150 LOC per iteration** (safety margin against the 200 hard limit).
|
|
54
54
|
- The gate counts the SUM of every changed file, not per-file. Tests count too. 5 files × 40 LOC = 200 = on the limit.
|
|
55
|
-
- If the task clearly requires >
|
|
55
|
+
- Up to 200 LOC is allowed without asking. If the task clearly requires >200 LOC, STOP and report the partition needed. Don't ship a 500-LOC PR — the gate rejects it and the work is redone, burning tokens twice.
|
|
56
56
|
- Excluded from the count: lockfiles, snapshots, `dist/`, `node_modules/`, generated `tests/_diet/`, `public/docs/`. Source + tests count.
|
|
57
57
|
|
|
58
58
|
## Task completeness
|