architecture-harness 0.29.5 → 0.29.6

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.5",
3
+ "version": "0.29.6",
4
4
  "type": "module",
5
5
  "description": "Architecture gates, lint rules and scaffolding for the bounded-vertical-slice architecture",
6
6
  "license": "MIT",
@@ -8,6 +8,7 @@ import { checkoutRootOf } from "./checkout-root.mjs";
8
8
  import { branchAt, originOf, repoOfSpelling } from "./git-read.mjs";
9
9
  import { runGh } from "./gh-run.mjs";
10
10
  import { readyProblems } from "./legs.mjs";
11
+ import { load } from "../config.mjs";
11
12
  import { cdTarget, commandEnv, commandWords, segmentsOf } from "./shell-command.mjs";
12
13
 
13
14
  const deny = (reason) => ({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: reason } });
@@ -106,6 +107,7 @@ export function decidePr(call, { gh = runGh, problems = readyProblems } = {}) {
106
107
  const options = { ...optionsOf(words.filter((_, i) => i !== group && i !== verbAt)), verb: words[verbAt] };
107
108
  const root = checkoutRootOf(cwd);
108
109
  if (!root || !existsSync(path.join(root, "qc.config.json"))) continue;
110
+ if (!load(root).ready.enforce) continue;
109
111
  const origin = originOf(root);
110
112
  if (!origin) continue;
111
113
  const ghEnv = { ...settings(process.env), ...env, ...settings(commandEnv(segment)) };
@@ -15,7 +15,7 @@ function workspace(t) {
15
15
  git("init", "-q");
16
16
  git("checkout", "-qb", "feat/206-pr-guard");
17
17
  git("remote", "add", "origin", "https://github.com/o/r.git");
18
- writeFileSync(path.join(cwd, "qc.config.json"), "{}");
18
+ writeFileSync(path.join(cwd, "qc.config.json"), JSON.stringify({ ready: { enforce: true } }));
19
19
  return cwd;
20
20
  }
21
21
  const call = (cwd, command, extra = {}) => ({ cwd, tool_name: "Bash", hook_event_name: "PreToolUse", tool_input: { command }, ...extra });
@@ -29,6 +29,14 @@ test("create requires the controller and a draft", (t) => {
29
29
  assert.equal(decidePr(call(cwd, "gh pr create --draft"), { gh: emptyGh }), null);
30
30
  });
31
31
 
32
+ test("the guard is off unless the repository sets ready.enforce", (t) => {
33
+ const cwd = workspace(t);
34
+ writeFileSync(path.join(cwd, "qc.config.json"), "{}");
35
+ for (const command of ["gh pr create", "gh pr ready 7"]) {
36
+ assert.equal(decidePr(call(cwd, command), { gh: () => assert.fail("no gh call when the guard is off") }), null);
37
+ }
38
+ });
39
+
32
40
  test("only Bash PreToolUse in a configured origin checkout is guarded", (t) => {
33
41
  const cwd = workspace(t);
34
42
  for (const command of ["echo 'gh pr create'", "gh pr view", "gh pr create -R other/repo", "GH_REPO=other/repo gh pr create"]) {
@@ -102,13 +110,13 @@ test("ready uses the ledger for the PR head even when the checkout head differs"
102
110
  git("add", ".");
103
111
  git("commit", "-qm", "base");
104
112
  git("branch", "base");
105
- writeFileSync(path.join(cwd, "qc.config.json"), JSON.stringify({ check: { base: "base" }, ready: { platforms: ["linux", "windows"] } }));
113
+ writeFileSync(path.join(cwd, "qc.config.json"), JSON.stringify({ check: { base: "base" }, ready: { enforce: true, platforms: ["linux", "windows"] } }));
106
114
  writeFileSync(path.join(cwd, "risk.mjs"), "process.platform;\n");
107
115
  git("add", ".");
108
116
  git("commit", "-qm", "risk");
109
117
  const head = git("rev-parse", "HEAD");
110
118
  git("checkout", "-q", "base");
111
- writeFileSync(path.join(cwd, "qc.config.json"), JSON.stringify({ check: { base: "base" }, ready: { platforms: ["linux", "windows"] } }));
119
+ writeFileSync(path.join(cwd, "qc.config.json"), JSON.stringify({ check: { base: "base" }, ready: { enforce: true, platforms: ["linux", "windows"] } }));
112
120
  const gh = () => JSON.stringify({ headRefOid: head });
113
121
  assert.match(reason(decidePr(call(cwd, "gh pr ready 12"), { gh })), /linux, windows/);
114
122
  appendLeg(cwd, { head, os: "linux", source: "local" });
package/src/config.mjs CHANGED
@@ -11,7 +11,8 @@ export const CONFIG_FILE = "qc.config.json";
11
11
  export const defaults = {
12
12
  commentWatch: true,
13
13
  github: { configDirs: { shawrylk: "~/.config/gh-personal" } },
14
- ready: { platforms: ["linux"] },
14
+ // The PR guard (draft on create, platform legs before ready) runs only when a repository sets enforce.
15
+ ready: { enforce: false, platforms: ["linux"] },
15
16
  checkpoint: { maxAgeMinutes: 30 },
16
17
  post: { aiLabel: true },
17
18
  ci: { requiredChecks: [] },
@@ -801,6 +802,7 @@ export function load(root = process.cwd()) {
801
802
  config.ready.platforms.some((os) => !["linux", "windows", "darwin"].includes(os)) || new Set(config.ready.platforms).size !== config.ready.platforms.length) {
802
803
  throw new TypeError("ready.platforms must be a non-empty array of distinct linux, windows and darwin platforms");
803
804
  }
805
+ if (typeof config.ready.enforce !== "boolean") throw new TypeError("ready.enforce must be a boolean");
804
806
  if (!isPlainObject(config.check)) throw new TypeError("check must be an object");
805
807
  const { related, sincePush, e2e, commands, base } = config.check;
806
808
  const command = (value) => typeof value === "string" && value.trim().length > 0;