architecture-harness 0.29.0 → 0.29.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architecture-harness",
3
- "version": "0.29.0",
3
+ "version": "0.29.1",
4
4
  "type": "module",
5
5
  "description": "Architecture gates, lint rules and scaffolding for the bounded-vertical-slice architecture",
6
6
  "license": "MIT",
package/src/cli/check.mjs CHANGED
@@ -994,7 +994,7 @@ export async function runCheck(config, only = [], { lister = repoFiles } = {}) {
994
994
  lines.push("OK floor every check the kit ships on is in force, or names the decision that switched it off");
995
995
  const hooks = hookDrift(config.root, requiredHooks(config));
996
996
  problems.push(...hooks.problems);
997
- lines.push("OK hooks each git hook makes the calls hooks.required names");
997
+ lines.push(config.hooks?.required === null ? "OK hooks off: hooks.required is null" : "OK hooks each git hook makes the calls hooks.required names");
998
998
  for (const note of hooks.notes) lines.push(`NOTE hooks ${note}`);
999
999
  }
1000
1000
 
@@ -129,7 +129,7 @@ function reportHooks(config) {
129
129
  const { problems, notes } = hookDrift(config.root, requiredHooks(config));
130
130
  for (const problem of problems) console.error(`FAIL hooks ${problem.path}: ${problem.detail}`);
131
131
  for (const note of notes) console.log(`NOTE hooks ${note}`);
132
- if (problems.length === 0) console.log("OK hooks each git hook makes the calls hooks.required names");
132
+ if (problems.length === 0) console.log(config.hooks?.required === null ? "OK hooks off: hooks.required is null" : "OK hooks each git hook makes the calls hooks.required names");
133
133
  return problems.length > 0;
134
134
  }
135
135
 
@@ -93,6 +93,17 @@ test("drift alone never blocks: the stop passes with a note that names the setup
93
93
  assert.match(message, /FAIL {2}doctor from installed/);
94
94
  });
95
95
 
96
+ test("a drift note shows once per session, so a repeat stop with the same drift is silent", (t) => {
97
+ const ws = workspace(t, { codes: { doctor: 1 }, withDoctor: true });
98
+ const first = ws.run({ session_id: "session-drift" });
99
+ assert.match(JSON.parse(first.stdout).systemMessage, /kit setup drifts/);
100
+ const repeat = ws.run({ session_id: "session-drift" });
101
+ assert.equal(repeat.status, 0, repeat.stderr);
102
+ assert.equal(repeat.stdout, "");
103
+ const other = ws.run({ session_id: "session-other" });
104
+ assert.match(JSON.parse(other.stdout).systemMessage, /kit setup drifts/);
105
+ });
106
+
96
107
  test("a red check beside drift blocks, and the block text carries the code failure, not the drift", (t) => {
97
108
  const ws = workspace(t, { codes: { doctor: 1, check: 1 }, withDoctor: true });
98
109
  const result = ws.run();
package/src/config.mjs CHANGED
@@ -340,6 +340,7 @@ export const defaults = {
340
340
  // A null `pattern` switches the rule off.
341
341
  branches: { pattern: "^[a-z]+/[0-9]+-", allow: ["main", "master", "release/**"] },
342
342
 
343
+ // A null `required` switches the git hook rule off. An empty object keeps the defaults, because merge combines objects.
343
344
  hooks: {
344
345
  required: { "pre-commit": ["qc work-order-check"], "commit-msg": ["qc commit-msg"], "pre-push": ["qc check"] },
345
346
  },
@@ -17,8 +17,10 @@ export function switchedOff(shipped, configured) {
17
17
 
18
18
  /** @returns each hook whose required calls lack one the kit ships. */
19
19
  export function weakenedHooks(shipped = {}, configured = {}) {
20
+ // `hooks.required: null` switches every shipped hook off.
21
+ const kept = configured ?? {};
20
22
  return Object.keys(shipped)
21
- .filter((name) => shipped[name].some((call) => !(configured[name] ?? []).includes(call)))
23
+ .filter((name) => shipped[name].some((call) => !(kept[name] ?? []).includes(call)))
22
24
  .sort();
23
25
  }
24
26
 
@@ -130,3 +130,13 @@ test("the dropped-default-helper detail says a default in either list counts as
130
130
  const [problem] = checkConfigFloor(shippedHelpers, withHelpers([insert]));
131
131
  assert.match(problem.detail, /neither exemptHelpers nor extraExemptHelpers/);
132
132
  });
133
+
134
+ test("a null hooks.required switches every shipped hook off and needs an exemption, not a crash", () => {
135
+ const withHooks = { ...shipped, hooks: { required: { "pre-commit": ["qc work-order-check"] } } };
136
+ const findings = checkConfigFloor(withHooks, { ...allOn, hooks: { required: null } });
137
+ assert.equal(findings.length, 1);
138
+ assert.match(JSON.stringify(findings), /hooks\.pre-commit/);
139
+ const exempt = checkConfigFloor(withHooks, { ...allOn, hooks: { required: null } },
140
+ { exemptions: { "hooks.pre-commit": "QC-001" }, pattern: /^QC-\d{3}$/ });
141
+ assert.deepEqual(exempt, []);
142
+ });