@christang/keel 5.104.0 → 5.105.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/README.md CHANGED
@@ -30,7 +30,8 @@ What Keel adds:
30
30
  check that the task contract and evidence are present; they do not judge whether the design
31
31
  is correct.
32
32
  - **A write guard (Claude).** After `task-start`, a `PreToolUse` hook rejects any edit
33
- outside the files the task declared it would touch.
33
+ outside the files the task declared it would touch. Where `push:<branch glob>` is declared, it
34
+ also refuses a `git push` to any other branch, with or without a task.
34
35
  - **Expectation alignment.** Before specs and tasks are finalized, Keel surfaces hidden
35
36
  assumptions and asks about the ones that actually change behavior.
36
37
 
@@ -181,7 +182,7 @@ because a permission granted in conversation does not survive a context reset. D
181
182
  `keel/config.yaml` instead:
182
183
 
183
184
  ```yaml
184
- authorize: # accepted names: commit, push, release, archive, continuation, issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>
185
+ authorize: # accepted names: commit, push, push:<branch glob>, release, archive, continuation, issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>, issue-close:<owner>/<repo>, cleanup:scratch
185
186
  - commit
186
187
  - push
187
188
  ```
@@ -201,14 +202,30 @@ whose vocabulary predates the word, the entry is unrecognized and the whole decl
201
202
  nothing until corrected — fail-closed, never a silent grant.
202
203
 
203
204
  `issue:<owner>/<repo>`, the sixth name, names the resource it reaches, and it is refused without
204
- one; `chat-reply:<group>`, the eighth, is the only other name that does. The other names act on the
205
- checkout the declaration sits in, so each is already bounded by the repository you declared it in. The credentials that open an issue are not:
205
+ one; `chat-reply:<group>`, the eighth, and `issue-close:<owner>/<repo>` and `cleanup:scratch`, the ninth
206
+ and tenth, are the others that do. The other names act on the checkout the declaration sits in, so each is already bounded by the repository you declared it in. The credentials that open an issue are not:
206
207
  `gh` is account-wide, so a bare `issue` would reach every repository your account can touch —
207
208
  silently the widest entry in the file, and wider than `push`. Naming the repository keeps the
208
209
  grant the size of what it says. Keel carries that scope to `keel --doctor` and to the compiled
209
210
  capsule and **does not enforce it**: it invokes no tracker client and cannot observe one, exactly
210
- as it never commits on your behalf either. Closing an issue is not in scope and does not need to
211
- be — a pull request body carrying `Closes #<n>` does that when it lands.
211
+ as it never commits on your behalf either. Closing an issue is a separate name,
212
+ `issue-close:<owner>/<repo>` (#257): a merge made by an automation token does not fire
213
+ `Closes #<n>`, so a session that finished the work closes the issue itself, with a comment naming
214
+ the pull request that resolved it. Keel carries that scope the same way and does not enforce it.
215
+
216
+ `push:<branch glob>` narrows `push` to the branches a session may push (#257) — for example
217
+ `push:claude/*` and `push:worktree-*` in a repository where only the coordinator pushes `main`.
218
+ Declare one entry per glob; `*` matches within one `/` segment and `**` across them. Unlike every
219
+ other scope, this one is enforced: while any `push:` glob is declared, the Claude write guard checks
220
+ every `git push` a `Bash` call runs, with or without a task, and refuses one to any other branch, or
221
+ one whose target it cannot tell — `--all`, `--mirror`, `--tags`, a shell variable, no configured
222
+ push destination — naming `git push origin <branch>` instead. A bare `push` keeps its old meaning,
223
+ and declaring it beside a `push:` glob is refused, because it would silently widen the glob. Codex
224
+ has no such hook, so there the scope is carried, not enforced.
225
+
226
+ `cleanup:scratch` covers removing temporary worktrees and run output under the session's own
227
+ scratchpad, after checking that they are merged and that no process is using them. It never covers
228
+ a branch or another session's files, and like the tracker scopes it is carried, not enforced.
212
229
 
213
230
  `protocol-refresh`, the seventh name, covers the one piece of a release that a plugin update cannot
214
231
  carry: the managed protocol block in this repository's `AGENTS.md`, which moves only when
@@ -234,7 +251,7 @@ Three things the declaration is not:
234
251
  anything.
235
252
  - **Not a trigger.** It removes a confirmation, not the step that reaches the action. Nothing
236
253
  schedules itself, and no next task is selected for you.
237
- - **Not open-ended.** The eight names above are the whole vocabulary. An unrecognized entry is
254
+ - **Not open-ended.** The ten names above are the whole vocabulary. An unrecognized entry is
238
255
  reported with the accepted names and the declaration authorizes nothing until you fix it — a
239
256
  typo never becomes a silent grant.
240
257
 
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.104.0 -->
1
+ <!-- keel:start version=5.105.1 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
package/bin/keel.js CHANGED
@@ -2254,13 +2254,25 @@ function printStandingAuthorizationSurface(repo) {
2254
2254
  // observes none that an agent runs, so the scope is a declaration carried to
2255
2255
  // the people who read it rather than a boundary anything holds. A reader who
2256
2256
  // took it for a sandbox would be relying on nothing.
2257
- if ([...scopes.values()].some((scope) => scope !== null)) {
2257
+ if ([...scopes.entries()].some(([action, scope]) => scope !== null && action !== "push")) {
2258
2258
  printDoctorLine(
2259
2259
  "scope",
2260
2260
  "carried",
2261
- "Keel records a scope and does not enforce it — it invokes no tracker "
2262
- + "client and cannot observe one, so the boundary is kept by whoever "
2263
- + "acts, not by this check"
2261
+ "Keel records a tracker, chat, or scratchpad scope and does not enforce "
2262
+ + "it — it invokes no tracker client and cannot observe one, so the "
2263
+ + "boundary is kept by whoever acts, not by this check"
2264
+ );
2265
+ }
2266
+ // The one scope something holds (#257): the Claude write guard reads the
2267
+ // `push:` globs and refuses a `git push` to any other branch, with or
2268
+ // without a task. Codex has no such hook, so there it is a declaration too.
2269
+ if (scopes.get("push")) {
2270
+ printDoctorLine(
2271
+ "push scope",
2272
+ "enforced",
2273
+ "the Claude write guard enforces these globs: it refuses a `git push` "
2274
+ + "to any other branch, or one whose target it cannot determine, with "
2275
+ + "or without a task; on Codex the scope is carried, not enforced"
2264
2276
  );
2265
2277
  }
2266
2278
  return true;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.104.0",
3
+ "version": "5.105.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.104.0",
9
+ "version": "5.105.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.104.0",
5
+ "version": "5.105.1",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.104.0",
3
+ "version": "5.105.1",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.104.0",
3
+ "version": "5.105.1",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Keel plugin hooks: non-blocking SessionStart projection and the manifest-gated PreToolUse write guard, both backed by the shared keel CLI contract.",
2
+ "description": "Keel plugin hooks: non-blocking SessionStart projection, the manifest-gated PreToolUse write guard, and its push-branch check on Bash, all backed by the shared keel CLI contract.",
3
3
  "hooks": {
4
4
  "SessionStart": [
5
5
  {
@@ -7,7 +7,9 @@
7
7
  {
8
8
  "type": "command",
9
9
  "command": "node",
10
- "args": ["${CLAUDE_PLUGIN_ROOT}/scripts/session-start.js"],
10
+ "args": [
11
+ "${CLAUDE_PLUGIN_ROOT}/scripts/session-start.js"
12
+ ],
11
13
  "timeout": 15
12
14
  }
13
15
  ]
@@ -20,7 +22,22 @@
20
22
  {
21
23
  "type": "command",
22
24
  "command": "node",
23
- "args": ["${CLAUDE_PLUGIN_ROOT}/scripts/pretooluse-guard.js"],
25
+ "args": [
26
+ "${CLAUDE_PLUGIN_ROOT}/scripts/pretooluse-guard.js"
27
+ ],
28
+ "timeout": 10
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "matcher": "Bash",
34
+ "hooks": [
35
+ {
36
+ "type": "command",
37
+ "command": "node",
38
+ "args": [
39
+ "${CLAUDE_PLUGIN_ROOT}/scripts/pretooluse-guard.js"
40
+ ],
24
41
  "timeout": 10
25
42
  }
26
43
  ]
@@ -16,6 +16,7 @@
16
16
  const crypto = require("crypto");
17
17
  const fs = require("fs");
18
18
  const path = require("path");
19
+ const { spawnSync } = require("child_process");
19
20
 
20
21
  // A newer installed copy of this script runs in its place when the host has
21
22
  // installed one (forward.js, #204). A copy of this script without forward.js
@@ -157,6 +158,302 @@ function repoRelative(repo, target) {
157
158
  );
158
159
  }
159
160
 
161
+ // --- push-branch check (#257) -------------------------------------------------
162
+ //
163
+ // While keel/config.yaml declares `push:<branch glob>`, every `git push` a Bash
164
+ // call runs must target a matching branch, with or without a task manifest.
165
+ // The globs are read here rather than through the declaration's validator, so
166
+ // a typo elsewhere in `authorize:` — which voids the declaration — leaves the
167
+ // check standing: a broken declaration fails toward more checking (D3).
168
+
169
+ const EXPLICIT_FORM = "`git push origin <branch>`";
170
+
171
+ function gitOut(cwd, args) {
172
+ const result = spawnSync("git", ["-C", cwd, ...args], { encoding: "utf8", timeout: 3000 });
173
+ return result.status === 0 ? String(result.stdout || "").trim() : null;
174
+ }
175
+
176
+ function readPushGlobs(top) {
177
+ let text = "";
178
+ try {
179
+ text = fs.readFileSync(path.join(top, "keel", "config.yaml"), "utf8");
180
+ } catch {
181
+ return [];
182
+ }
183
+ const globs = [];
184
+ let inBlock = false;
185
+ for (const line of text.split(/\r?\n/)) {
186
+ if (/^\s*#/.test(line) || line.trim() === "") continue;
187
+ if (/^authorize\s*:\s*$/.test(line)) {
188
+ inBlock = true;
189
+ continue;
190
+ }
191
+ if (!inBlock) continue;
192
+ if (!/^\s/.test(line)) break;
193
+ const entry = line.replace(/\s+#.*$/, "").match(/^\s+-\s*push:(\S+)\s*$/);
194
+ if (entry) globs.push(entry[1]);
195
+ }
196
+ return globs;
197
+ }
198
+
199
+ // Shell words and the separators between commands. Quotes are honoured, and a
200
+ // word that the shell would expand (`$`, a backtick) is marked, because its
201
+ // value is not knowable here.
202
+ function shellSegments(command) {
203
+ const segments = [];
204
+ let words = [];
205
+ let word = null;
206
+ let expands = false;
207
+ const finishWord = () => {
208
+ if (word !== null) words.push({ text: word, expands });
209
+ word = null;
210
+ expands = false;
211
+ };
212
+ const finishSegment = () => {
213
+ finishWord();
214
+ if (words.length) segments.push(words);
215
+ words = [];
216
+ };
217
+ // Heredoc bodies are data, not commands: `<<'EOF'` … `EOF` is skipped from
218
+ // the end of its line to the terminator, so a body line reading like a push
219
+ // is not taken for one.
220
+ const pendingHeredocs = [];
221
+ for (let i = 0; i < command.length; i += 1) {
222
+ const c = command[i];
223
+ if (c === "<" && command[i + 1] === "<" && command[i + 2] !== "<") {
224
+ const marker = command.slice(i + 2).match(/^-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/);
225
+ if (marker) {
226
+ pendingHeredocs.push(marker[2]);
227
+ finishWord();
228
+ i += 1 + marker[0].length;
229
+ continue;
230
+ }
231
+ }
232
+ if (c === "\n" && pendingHeredocs.length) {
233
+ finishSegment();
234
+ let rest = i + 1;
235
+ while (pendingHeredocs.length) {
236
+ const terminator = pendingHeredocs.shift();
237
+ const lines = command.slice(rest).split("\n");
238
+ let consumed = 0;
239
+ for (const line of lines) {
240
+ consumed += line.length + 1;
241
+ if (line.replace(/^\t+/, "") === terminator) break;
242
+ }
243
+ rest += consumed;
244
+ }
245
+ i = rest - 1;
246
+ continue;
247
+ }
248
+ if (c === "'") {
249
+ const end = command.indexOf("'", i + 1);
250
+ word = (word || "") + command.slice(i + 1, end === -1 ? command.length : end);
251
+ i = end === -1 ? command.length : end;
252
+ } else if (c === '"') {
253
+ let j = i + 1;
254
+ let text = "";
255
+ while (j < command.length && command[j] !== '"') {
256
+ if (command[j] === "\\" && j + 1 < command.length) {
257
+ text += command[j + 1];
258
+ j += 2;
259
+ continue;
260
+ }
261
+ if (command[j] === "$" || command[j] === "`") expands = true;
262
+ text += command[j];
263
+ j += 1;
264
+ }
265
+ word = (word || "") + text;
266
+ i = j;
267
+ } else if (c === "\\" && i + 1 < command.length) {
268
+ word = (word || "") + command[i + 1];
269
+ i += 1;
270
+ } else if (c === "$" || c === "`") {
271
+ expands = true;
272
+ word = (word || "") + c;
273
+ } else if (c === ";" || c === "\n" || c === "&" || c === "|" || c === "(" || c === ")") {
274
+ finishSegment();
275
+ } else if (/\s/.test(c)) {
276
+ finishWord();
277
+ } else {
278
+ word = (word || "") + c;
279
+ }
280
+ }
281
+ finishSegment();
282
+ return segments;
283
+ }
284
+
285
+ const PREFIX_COMMANDS = new Set(["env", "command", "exec", "nohup", "time", "sudo"]);
286
+ const SHELLS = new Set(["bash", "sh", "zsh", "eval"]);
287
+ const PUSH_FLAGS = new Set([
288
+ "-u", "--set-upstream", "-f", "--force", "--force-if-includes", "--no-force-if-includes",
289
+ "-n", "--dry-run", "--no-verify", "--verify", "-q", "--quiet", "-v", "--verbose",
290
+ "--porcelain", "--progress", "--no-progress", "--atomic", "--no-atomic", "--no-signed",
291
+ "--thin", "--no-thin", "--follow-tags", "--no-follow-tags", "-4", "--ipv4", "-6", "--ipv6",
292
+ "--prune", "--no-recurse-submodules", "--force-with-lease", "--signed", "-d", "--delete",
293
+ ]);
294
+ const PUSH_VALUED = new Set(["-o", "--push-option", "--repo", "--receive-pack", "--exec"]);
295
+ const PUSH_UNDETERMINED = new Set(["--all", "--branches", "--mirror", "--tags"]);
296
+
297
+ // The pushes a command runs, each as { dir, cdBefore, args } or { undetermined }.
298
+ function findPushes(command, cwd) {
299
+ const pushes = [];
300
+ let cdBefore = false;
301
+ for (const words of shellSegments(command)) {
302
+ let i = 0;
303
+ while (i < words.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(words[i].text)) i += 1;
304
+ while (i < words.length && PREFIX_COMMANDS.has(words[i].text)) i += 1;
305
+ const head = words[i] ? words[i].text : "";
306
+ if (head === "cd" || head === "pushd") {
307
+ cdBefore = true;
308
+ continue;
309
+ }
310
+ if (SHELLS.has(head)) {
311
+ if (/\bgit\b[\s\S]*\bpush\b/.test(words.slice(i + 1).map((w) => w.text).join(" "))) {
312
+ pushes.push({ undetermined: `it runs \`git push\` inside \`${head}\`` });
313
+ }
314
+ continue;
315
+ }
316
+ if (head !== "git") continue;
317
+ let dir = cwd;
318
+ i += 1;
319
+ let unknownGlobal = null;
320
+ while (i < words.length && words[i].text.startsWith("-")) {
321
+ const option = words[i].text;
322
+ if (option === "-C" && words[i + 1]) {
323
+ dir = path.resolve(dir, words[i + 1].text);
324
+ i += 2;
325
+ } else if (option === "-c" && words[i + 1]) {
326
+ i += 2;
327
+ } else if (option === "--no-pager" || option === "-P") {
328
+ i += 1;
329
+ } else {
330
+ unknownGlobal = option;
331
+ i += 1;
332
+ }
333
+ }
334
+ if (!words[i] || words[i].text !== "push") continue;
335
+ if (unknownGlobal) {
336
+ pushes.push({ undetermined: `the git option \`${unknownGlobal}\` is not one the guard reads` });
337
+ continue;
338
+ }
339
+ pushes.push({ dir, cdBefore, args: words.slice(i + 1) });
340
+ }
341
+ return pushes;
342
+ }
343
+
344
+ function currentBranch(dir) {
345
+ return gitOut(dir, ["symbolic-ref", "--short", "-q", "HEAD"]);
346
+ }
347
+
348
+ // The branch a push with no refspec goes to: its configured push destination.
349
+ function pushDestination(dir) {
350
+ const ref = gitOut(dir, ["rev-parse", "--symbolic-full-name", "@{push}"]);
351
+ if (!ref || !ref.startsWith("refs/remotes/")) return null;
352
+ const rest = ref.slice("refs/remotes/".length);
353
+ const remotes = (gitOut(dir, ["remote"]) || "").split(/\s+/).filter(Boolean)
354
+ .sort((a, b) => b.length - a.length);
355
+ const remote = remotes.find((name) => rest.startsWith(`${name}/`));
356
+ return remote ? rest.slice(remote.length + 1) : null;
357
+ }
358
+
359
+ // Target branches of one push, or { undetermined: reason }.
360
+ function pushTargets(push) {
361
+ if (push.undetermined) return push;
362
+ const positionals = [];
363
+ let deleting = false;
364
+ for (let i = 0; i < push.args.length; i += 1) {
365
+ const word = push.args[i];
366
+ if (word.expands) return { undetermined: `\`${word.text}\` is expanded by the shell` };
367
+ const text = word.text;
368
+ if (text === "--") {
369
+ positionals.push(...push.args.slice(i + 1).map((w) => w.text));
370
+ break;
371
+ }
372
+ if (!text.startsWith("-") || text === "-") {
373
+ positionals.push(text);
374
+ continue;
375
+ }
376
+ const name = text.includes("=") ? text.slice(0, text.indexOf("=")) : text;
377
+ if (PUSH_UNDETERMINED.has(name)) return { undetermined: `\`${name}\` pushes refs the guard cannot list` };
378
+ if (name === "-d" || name === "--delete") deleting = true;
379
+ if (PUSH_VALUED.has(name)) {
380
+ if (!text.includes("=")) i += 1;
381
+ continue;
382
+ }
383
+ if (PUSH_FLAGS.has(name) || name.startsWith("--force-with-lease") || name.startsWith("--signed")
384
+ || name.startsWith("--recurse-submodules")) {
385
+ continue;
386
+ }
387
+ if (/^-[a-zA-Z0-9]{2,}$/.test(text) && [...text.slice(1)].every((c) => PUSH_FLAGS.has(`-${c}`))) {
388
+ if (text.includes("d")) deleting = true;
389
+ continue;
390
+ }
391
+ return { undetermined: `the push option \`${text}\` is not one the guard reads` };
392
+ }
393
+ const refspecs = positionals.slice(1);
394
+ const needsCurrent = () => {
395
+ if (push.cdBefore) return { undetermined: "the directory changes before it, so its branch is unknown here" };
396
+ return null;
397
+ };
398
+ if (!refspecs.length) {
399
+ const unknown = needsCurrent();
400
+ if (unknown) return unknown;
401
+ const branch = pushDestination(push.dir);
402
+ return branch ? { targets: [branch] } : { undetermined: "the branch has no configured push destination" };
403
+ }
404
+ const targets = [];
405
+ for (const raw of refspecs) {
406
+ const spec = raw.replace(/^\+/, "");
407
+ let dst = spec;
408
+ if (!deleting && spec.includes(":")) dst = spec.slice(spec.indexOf(":") + 1);
409
+ else if (spec.startsWith(":")) dst = spec.slice(1);
410
+ if (!dst) return { undetermined: `\`${raw}\` names no destination` };
411
+ if (dst === "HEAD" || dst === "@") {
412
+ const unknown = needsCurrent();
413
+ if (unknown) return unknown;
414
+ dst = currentBranch(push.dir);
415
+ if (!dst) return { undetermined: "HEAD is detached" };
416
+ }
417
+ if (dst.startsWith("refs/heads/")) dst = dst.slice("refs/heads/".length);
418
+ else if (dst.startsWith("refs/")) return { undetermined: `\`${raw}\` is not a branch` };
419
+ targets.push(dst);
420
+ }
421
+ return { targets };
422
+ }
423
+
424
+ function checkPushes(event) {
425
+ const command = event.tool_input && typeof event.tool_input.command === "string"
426
+ ? event.tool_input.command : "";
427
+ if (!/\bgit\b/.test(command) || !/\bpush\b/.test(command)) return 0;
428
+ const cwd = typeof event.cwd === "string" && event.cwd ? event.cwd : process.cwd();
429
+ for (const push of findPushes(command, cwd)) {
430
+ const top = gitOut(push.dir || cwd, ["rev-parse", "--show-toplevel"]);
431
+ if (!top) continue;
432
+ const globs = readPushGlobs(top);
433
+ if (!globs.length) continue;
434
+ const declared = globs.map((glob) => `\`push:${glob}\``).join(", ");
435
+ const result = pushTargets(push);
436
+ if (result.undetermined) {
437
+ deny(
438
+ `Keel push guard: keel/config.yaml limits push to ${declared}, and the `
439
+ + `guard cannot tell which branch this push targets: ${result.undetermined}. `
440
+ + `Name the branch, as ${EXPLICIT_FORM}.`
441
+ );
442
+ return 0;
443
+ }
444
+ const outside = result.targets.filter((branch) => !globs.some((glob) => globPattern(glob).test(branch)));
445
+ if (outside.length) {
446
+ deny(
447
+ `Keel push guard: this command pushes to ${outside.map((b) => `\`${b}\``).join(", ")}, `
448
+ + `and keel/config.yaml limits push to ${declared}. Push a matching branch, `
449
+ + "or ask the owner; the declaration is theirs to widen."
450
+ );
451
+ return 0;
452
+ }
453
+ }
454
+ return 0;
455
+ }
456
+
160
457
  function main() {
161
458
  const input = readStdin();
162
459
  let event = {};
@@ -176,6 +473,8 @@ function main() {
176
473
  if (handed !== null) return handed;
177
474
  }
178
475
 
476
+ if (event.tool_name === "Bash") return checkPushes(event);
477
+
179
478
  const pathField = FILE_EDIT_TOOLS.get(event.tool_name);
180
479
  if (!pathField) return 0;
181
480
 
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
47
47
  "scripts/validate_plugin.py",
48
48
  ]
49
49
 
50
- PACKAGE_VERSION = "5.104.0"
51
- PROTOCOL_VERSION = "5.104.0"
50
+ PACKAGE_VERSION = "5.105.1"
51
+ PROTOCOL_VERSION = "5.105.1"
52
52
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
53
53
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
54
54
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -24084,6 +24084,118 @@ def write_authorize_config(repo: Path, body: str) -> None:
24084
24084
  (repo / "keel" / "config.yaml").write_text(body, encoding="utf-8")
24085
24085
 
24086
24086
 
24087
+ def validate_authorize_block_reads_every_line_scenario() -> int:
24088
+ """Issue #275: no line of `authorize:` is dropped silently.
24089
+
24090
+ An item with a space used to end the block, dropping it and every later
24091
+ entry while doctor said ok; a trailing comment dropped its item too.
24092
+ """
24093
+ label = "authorize-block-reads-every-line:"
24094
+ with tempfile.TemporaryDirectory(prefix="keel-authorize-275-") as raw_tmp:
24095
+ root = Path(raw_tmp)
24096
+ spaced = root / "spaced"
24097
+ spaced.mkdir()
24098
+ write_authorize_config(spaced, "authorize:\n - commit\n - push:main branch\n - release\n")
24099
+ doctor = run_keel(spaced, "--doctor")
24100
+ if doctor.returncode == 0:
24101
+ report(f"{label} an item with a space was not refused: {doctor.stdout}")
24102
+ return 1
24103
+ if "push:main branch" not in doctor.stdout + doctor.stderr:
24104
+ report(f"{label} the refusal does not name `push:main branch`: {doctor.stdout}")
24105
+ return 1
24106
+ if "commit: authorized" in doctor.stdout:
24107
+ report(f"{label} the entries beside the refused one stayed authorized.")
24108
+ return 1
24109
+
24110
+ commented = root / "commented"
24111
+ subprocess.run(["git", "init", "-q", "-b", "main", str(commented)], check=True, capture_output=True)
24112
+ write_authorize_config(
24113
+ commented,
24114
+ "authorize:\n - commit # owner, 2026-10-11\n - push:claude/* # sessions push their own branches\n",
24115
+ )
24116
+ out = run_keel(commented, "--doctor").stdout
24117
+ if "commit: authorized" not in out:
24118
+ report(f"{label} a trailing comment dropped `commit`: {out}")
24119
+ return 1
24120
+ push_line = next((l for l in out.splitlines() if l.strip().startswith("push:")), "")
24121
+ if "claude/*" not in push_line or "#" in push_line:
24122
+ report(f"{label} the push line does not read the glob without its comment: {push_line!r}")
24123
+ return 1
24124
+ event = {"tool_name": "Bash", "tool_input": {"command": "git push origin HEAD:main"}, "cwd": str(commented)}
24125
+ decision = pretooluse_decision(run_pretooluse_guard_hook(commented, event))
24126
+ if not decision or decision.get("permissionDecision") != "deny":
24127
+ report(f"{label} the push guard did not read a commented glob: {decision!r}")
24128
+ return 1
24129
+ report("authorize-block-reads-every-line scenario passed.")
24130
+ return 0
24131
+
24132
+
24133
+ def validate_authorize_push_close_cleanup_scenario() -> int:
24134
+ """Issue #257: `push:<glob>`, `issue-close:<owner>/<repo>`, `cleanup:scratch`.
24135
+
24136
+ Each is reported with its scope, a task with no boundary inherits all of
24137
+ them, and each wrong form is refused naming the form it needs.
24138
+ """
24139
+ label = "authorize-push-close-cleanup:"
24140
+ with tempfile.TemporaryDirectory(prefix="keel-authorize-257-") as raw_tmp:
24141
+ root = Path(raw_tmp)
24142
+
24143
+ def fixture(name: str, entries: list[str]) -> Path:
24144
+ repo = root / name
24145
+ repo.mkdir()
24146
+ write_authorize_config(repo, "authorize:\n" + "".join(f" - {e}\n" for e in entries))
24147
+ return repo
24148
+
24149
+ good = fixture("good", ["push:claude/*", "push:worktree-*", "issue-close:acme/widgets", "cleanup:scratch"])
24150
+ doctor = run_keel(good, "--doctor")
24151
+ lines = doctor.stdout.splitlines()
24152
+
24153
+ def line_for(action: str) -> str:
24154
+ return next((l for l in lines if l.strip().startswith(f"{action}:")), "")
24155
+
24156
+ for action, needles in (
24157
+ ("push", ("authorized", "claude/*", "worktree-*")),
24158
+ ("issue-close", ("authorized", "acme/widgets")),
24159
+ ("cleanup", ("authorized", "scratch")),
24160
+ ):
24161
+ line = line_for(action)
24162
+ missing = [n for n in needles if n not in line]
24163
+ if missing:
24164
+ report(f"{label} doctor's {action} line lacks {missing!r}: {line!r}")
24165
+ report(doctor.stdout)
24166
+ return 1
24167
+ if "write guard enforces" not in doctor.stdout:
24168
+ report(f"{label} doctor does not say the write guard enforces the push globs.")
24169
+ report(doctor.stdout)
24170
+ return 1
24171
+
24172
+ write_text(good / "openspec/changes/inherit/tasks.md", task_capsule_compact_fixture().replace(
24173
+ " - Autonomy boundary:\n - Default: hard-stop\n - Pre-authorized fallback: none\n", ""))
24174
+ started = run_keel(good, "gate", "task-start", "--change", "inherit", "--task", "1.1", "--json")
24175
+ text = started.stdout
24176
+ inherited = "push:claude/*, push:worktree-*, issue-close:acme/widgets, cleanup:scratch"
24177
+ if inherited not in text:
24178
+ report(f"{label} the inherited autonomy entry does not name all four: {text[:1500]}")
24179
+ return 1
24180
+
24181
+ for name, entries, needles in (
24182
+ ("mixed", ["push", "push:claude/*"], ("push", "push:claude/*")),
24183
+ ("bare-close", ["issue-close"], ("issue-close:<owner>/<repo>",)),
24184
+ ("cleanup-runs", ["cleanup:runs"], ("cleanup:scratch",)),
24185
+ ("bad-glob", ["push:main?"], ("push:main?", "push:<branch glob>")),
24186
+ ):
24187
+ refused = run_keel(fixture(name, entries), "--doctor")
24188
+ if refused.returncode == 0:
24189
+ report(f"{label} {entries!r} was accepted.")
24190
+ return 1
24191
+ missing = [n for n in needles if n not in refused.stdout + refused.stderr]
24192
+ if missing:
24193
+ report(f"{label} {entries!r} was refused without naming {missing!r}: {refused.stdout}")
24194
+ return 1
24195
+ report("authorize-push-close-cleanup scenario passed.")
24196
+ return 0
24197
+
24198
+
24087
24199
  def validate_standing_authorization_declaration_scenario() -> int:
24088
24200
  with tempfile.TemporaryDirectory(prefix="keel-authorize-") as raw_tmp:
24089
24201
  root = Path(raw_tmp)
@@ -27009,6 +27121,13 @@ def validate_continuation_authorization_scenario() -> int:
27009
27121
  return 0
27010
27122
 
27011
27123
 
27124
+ ACCEPTED_AUTHORIZE_NAMES = (
27125
+ "commit, push, push:<branch glob>, release, archive, continuation, "
27126
+ "issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>, "
27127
+ "issue-close:<owner>/<repo>, cleanup:scratch"
27128
+ )
27129
+
27130
+
27012
27131
  def validate_continuation_docs_scenario() -> int:
27013
27132
  """Every text an agent reads at the between-task boundary names the word (#94).
27014
27133
 
@@ -27058,9 +27177,8 @@ def validate_continuation_docs_scenario() -> int:
27058
27177
  # The seventh name (#164). Each surface that spells the vocabulary out has
27059
27178
  # to spell all of it: a reader copies from the list they are shown.
27060
27179
  for needle in (
27061
- "accepted names: commit, push, release, archive, continuation, "
27062
- "issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>",
27063
- "The eight names above are the whole vocabulary.",
27180
+ f"accepted names: {ACCEPTED_AUTHORIZE_NAMES}",
27181
+ "The ten names above are the whole vocabulary.",
27064
27182
  "`protocol-refresh`, the seventh name",
27065
27183
  ):
27066
27184
  if needle not in readme:
@@ -27068,7 +27186,7 @@ def validate_continuation_docs_scenario() -> int:
27068
27186
  return 1
27069
27187
 
27070
27188
  config_text = (ROOT / "keel/config.yaml").read_text(encoding="utf-8")
27071
- if "commit, push, release, archive,\n# continuation, issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>" not in config_text:
27189
+ if "commit, push, push:<branch glob>,\n# release, archive, continuation, issue:<owner>/<repo>, protocol-refresh,\n# chat-reply:<group>, issue-close:<owner>/<repo>, cleanup:scratch" not in config_text:
27072
27190
  report(
27073
27191
  f"{label}: keel/config.yaml's comment lacks: protocol-refresh in the "
27074
27192
  "seven-name vocabulary."
@@ -29455,6 +29573,84 @@ def validate_touch_guard_record_layer_scenario() -> int:
29455
29573
  return 0
29456
29574
 
29457
29575
 
29576
+ def validate_push_branch_guard_scenario() -> int:
29577
+ """Issue #257: with `push:<glob>` declared, the hook refuses other pushes.
29578
+
29579
+ The real hook script receives `Bash` events with no task manifest. A push
29580
+ to a declared branch passes, one to `main` is refused by name, a bare
29581
+ `git push` resolves the branch's push destination, an undetermined target
29582
+ is refused naming the explicit form, a typo elsewhere does not lift the
29583
+ check, and a bare `push` declaration intercepts nothing.
29584
+ """
29585
+ label = "push-branch-guard:"
29586
+ hooks = json.loads((ROOT / PLUGIN_ROOT / "hooks/hooks.json").read_text(encoding="utf-8"))
29587
+ matchers = [entry.get("matcher", "") for entry in hooks.get("hooks", {}).get("PreToolUse", [])]
29588
+ if not any("Bash" in matcher.split("|") for matcher in matchers):
29589
+ report(f"{label} hooks.json does not register the guard for Bash: {matchers!r}")
29590
+ return 1
29591
+ with tempfile.TemporaryDirectory(prefix="keel-push-guard-") as raw:
29592
+ base = Path(raw)
29593
+ remote = base / "remote.git"
29594
+ repo = base / "repo"
29595
+
29596
+ def git(*args: str, cwd: Path = repo) -> None:
29597
+ subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True, text=True)
29598
+
29599
+ git("init", "-q", "--bare", str(remote), cwd=base)
29600
+ git("init", "-q", "-b", "main", str(repo), cwd=base)
29601
+ git("-c", "user.name=t", "-c", "user.email=t@t", "commit", "-q", "--allow-empty", "-m", "init")
29602
+ git("remote", "add", "origin", str(remote))
29603
+ git("push", "-q", "-u", "origin", "main")
29604
+ git("switch", "-q", "-c", "claude/fix")
29605
+ git("push", "-q", "-u", "origin", "claude/fix")
29606
+
29607
+ def decide(command: str) -> dict | None:
29608
+ event = {"tool_name": "Bash", "tool_input": {"command": command}, "cwd": str(repo)}
29609
+ return pretooluse_decision(run_pretooluse_guard_hook(repo, event))
29610
+
29611
+ def denied(decision: dict | None) -> bool:
29612
+ return bool(decision) and decision.get("permissionDecision") == "deny"
29613
+
29614
+ write_authorize_config(repo, "authorize:\n - commit\n - push:claude/*\n")
29615
+ checks = [
29616
+ ("a push to the declared branch", "git add -A && git push -u origin claude/fix", False, None),
29617
+ ("a push to main", "git push origin HEAD:main", True, "main"),
29618
+ ("a bare push on a branch pushing to claude/fix", "git push", False, None),
29619
+ ("--all", "git push --all origin", True, "git push origin <branch>"),
29620
+ ("a shell variable", 'git push origin "$BRANCH"', True, "git push origin <branch>"),
29621
+ ]
29622
+ for what, command, want_deny, needle in checks:
29623
+ decision = decide(command)
29624
+ if decision and "error" in decision:
29625
+ report(f"{label} the hook failed on {what}: {decision['error']}")
29626
+ return 1
29627
+ if denied(decision) != want_deny:
29628
+ report(f"{label} {what} ({command!r}) was {'allowed' if want_deny else 'denied'}: {decision!r}")
29629
+ return 1
29630
+ if needle and needle not in decision.get("permissionDecisionReason", ""):
29631
+ report(f"{label} {what} was denied without naming {needle!r}: {decision!r}")
29632
+ return 1
29633
+ git("switch", "-q", "main")
29634
+ decision = decide("git push")
29635
+ if not denied(decision):
29636
+ report(f"{label} a bare push on a branch pushing to origin/main was allowed: {decision!r}")
29637
+ return 1
29638
+ if "main" not in decision.get("permissionDecisionReason", ""):
29639
+ report(f"{label} the bare push to main was denied without naming main: {decision!r}")
29640
+ return 1
29641
+
29642
+ write_authorize_config(repo, "authorize:\n - push:claude/*\n - deploy\n")
29643
+ if not denied(decide("git push origin HEAD:main")):
29644
+ report(f"{label} a typo elsewhere in authorize: lifted the push check.")
29645
+ return 1
29646
+ write_authorize_config(repo, "authorize:\n - push\n")
29647
+ if decide("git push origin HEAD:main") is not None:
29648
+ report(f"{label} a bare push declaration intercepted a push.")
29649
+ return 1
29650
+ report("push-branch-guard scenario passed.")
29651
+ return 0
29652
+
29653
+
29458
29654
  def validate_touch_write_guard_scenario() -> int:
29459
29655
  with tempfile.TemporaryDirectory(
29460
29656
  prefix="keel-touch-guard-", ignore_cleanup_errors=True
@@ -37996,6 +38192,8 @@ SCENARIOS: tuple = (
37996
38192
  "standing-authorization-declaration",
37997
38193
  validate_standing_authorization_declaration_scenario,
37998
38194
  ),
38195
+ ("authorize-push-close-cleanup", validate_authorize_push_close_cleanup_scenario),
38196
+ ("authorize-block-reads-every-line", validate_authorize_block_reads_every_line_scenario),
37999
38197
  (
38000
38198
  "standing-authorization-sync-confusion",
38001
38199
  validate_standing_authorization_sync_confusion_scenario,
@@ -38199,6 +38397,7 @@ SCENARIOS: tuple = (
38199
38397
  ("native-helper-targets", validate_native_helper_targets_scenario),
38200
38398
  ("native-single-task-matrix", validate_native_single_task_matrix_scenario),
38201
38399
  ("touch-write-guard", validate_touch_write_guard_scenario),
38400
+ ("push-branch-guard", validate_push_branch_guard_scenario),
38202
38401
  ("touch-guard-record-layer", validate_touch_guard_record_layer_scenario),
38203
38402
  ("repo-action-mode", validate_repo_action_mode_scenario),
38204
38403
  ("runner-skip-accounting", validate_runner_skip_accounting_scenario),
@@ -230,9 +230,10 @@ function guardDiagnostics(repo, target) {
230
230
  boundary: {
231
231
  level: "advisory",
232
232
  evidence:
233
- "The guard covers file-edit tools only (Edit, Write, NotebookEdit); "
234
- + "Bash and other indirect writes stay disciplinary, and paths outside "
235
- + "the repository are not product writes.",
233
+ "The guard covers file-edit tools (Edit, Write, NotebookEdit), and on "
234
+ + "Bash only `git push` while keel/config.yaml declares `push:<branch "
235
+ + "glob>`; every other Bash command and indirect write stays "
236
+ + "disciplinary, and paths outside the repository are not product writes.",
236
237
  },
237
238
  };
238
239
  }
@@ -21,6 +21,13 @@ const STANDING_AUTHORIZATION_ACTIONS = [
21
21
  // Answering, in the named chat group, a record addressed to the session's
22
22
  // role (#195). Scoped: in a Slack-enabled group a reply leaves the machine.
23
23
  "chat-reply",
24
+ // Closing an issue on the named repository with a comment naming the work
25
+ // that resolved it (#257). Scoped for the reason `issue` is.
26
+ "issue-close",
27
+ // Removing temporary worktrees and run output under the session's own
28
+ // scratchpad once merged and unused, never a branch or another session's
29
+ // files (#257). Its one scope, `scratch`, says which tree it reaches.
30
+ "cleanup",
24
31
  ];
25
32
 
26
33
  // The actions whose credential reaches further than the checkout the
@@ -30,7 +37,12 @@ const STANDING_AUTHORIZATION_ACTIONS = [
30
37
  // actions are declared with the resource they may reach and refused bare —
31
38
  // accepting the bare form as a convenience would make the narrow form optional
32
39
  // and the wide one the default, which is the decision inverted.
33
- const SCOPED_AUTHORIZATION_ACTIONS = new Set(["issue", "chat-reply"]);
40
+ const SCOPED_AUTHORIZATION_ACTIONS = new Set(["issue", "chat-reply", "issue-close", "cleanup"]);
41
+
42
+ // Actions whose scope narrows them but is not required (#257). A bare `push`
43
+ // keeps the meaning it always had; `push:<branch glob>` limits it to matching
44
+ // branches, and the Claude write guard enforces that limit.
45
+ const OPTIONALLY_SCOPED_AUTHORIZATION_ACTIONS = new Set(["push"]);
34
46
 
35
47
  // `<owner>/<repo>`: two non-empty segments and nothing else. The shape is
36
48
  // checked and the existence is not, for the reason `triage` never fetches an
@@ -43,14 +55,24 @@ const AUTHORIZATION_SCOPE_PATTERN = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
43
55
  const AUTHORIZATION_SCOPES = {
44
56
  issue: { form: "<owner>/<repo>", pattern: AUTHORIZATION_SCOPE_PATTERN },
45
57
  "chat-reply": { form: "<group>", pattern: /^[a-z0-9][a-z0-9-]{0,31}$/ },
58
+ "issue-close": { form: "<owner>/<repo>", pattern: AUTHORIZATION_SCOPE_PATTERN },
59
+ cleanup: { form: "scratch", pattern: /^scratch$/ },
60
+ // Branch-name characters and `*`; `*` matches within one `/` segment and
61
+ // `**` across them, as Touch globs do.
62
+ push: { form: "<branch glob>", pattern: /^[A-Za-z0-9._/*-]+$/ },
46
63
  };
47
64
 
48
65
  // How the accepted names are spelled back to an author: the scoped ones carry
49
66
  // their form, so the list is copyable rather than a name the next message
50
67
  // refuses.
51
- const STANDING_AUTHORIZATION_ACCEPTED_FORMS = STANDING_AUTHORIZATION_ACTIONS.map(
52
- (action) =>
53
- SCOPED_AUTHORIZATION_ACTIONS.has(action) ? `${action}:${AUTHORIZATION_SCOPES[action].form}` : action
68
+ const STANDING_AUTHORIZATION_ACCEPTED_FORMS = STANDING_AUTHORIZATION_ACTIONS.flatMap(
69
+ (action) => {
70
+ if (SCOPED_AUTHORIZATION_ACTIONS.has(action)) return [`${action}:${AUTHORIZATION_SCOPES[action].form}`];
71
+ if (OPTIONALLY_SCOPED_AUTHORIZATION_ACTIONS.has(action)) {
72
+ return [action, `${action}:${AUTHORIZATION_SCOPES[action].form}`];
73
+ }
74
+ return [action];
75
+ }
54
76
  );
55
77
 
56
78
  // One declared entry, split into the action and the resource it names. Returns
@@ -63,7 +85,10 @@ function classifyAuthorizationEntry(entry) {
63
85
  if (!STANDING_AUTHORIZATION_ACTIONS.includes(action)) {
64
86
  return { ok: false, entry, reason: "unknown-action" };
65
87
  }
66
- if (!SCOPED_AUTHORIZATION_ACTIONS.has(action)) {
88
+ if (OPTIONALLY_SCOPED_AUTHORIZATION_ACTIONS.has(action) && scope === null) {
89
+ return { ok: true, entry, action, scope: null };
90
+ }
91
+ if (!SCOPED_AUTHORIZATION_ACTIONS.has(action) && !OPTIONALLY_SCOPED_AUTHORIZATION_ACTIONS.has(action)) {
67
92
  if (scope !== null) return { ok: false, entry, action, reason: "unexpected-scope" };
68
93
  return { ok: true, entry, action, scope: null };
69
94
  }
@@ -119,11 +144,14 @@ function configList(repo, key) {
119
144
  }
120
145
  if (!inBlock) continue;
121
146
  if (line.trim() === "") continue;
122
- const entry = line.match(/^\s+-\s*(\S+)\s*$/);
123
- // Anything that is not a list item closes the block; the next top-level
124
- // key belongs to the rest of the file.
125
- if (!entry) break;
126
- entries.push(entry[1]);
147
+ // Only a line at column zero closes the block: the next top-level key
148
+ // belongs to the rest of the file. Every indented line is an entry, read
149
+ // whole, so one Keel cannot use is refused by name rather than ending the
150
+ // block and dropping itself and everything after it unseen (#275).
151
+ if (!/^\s/.test(line)) break;
152
+ const text = line.replace(/\s+#.*$/, "").trim();
153
+ const entry = text.replace(/^-\s*/, "");
154
+ if (entry) entries.push(entry);
127
155
  }
128
156
  return entries;
129
157
  }
@@ -257,6 +285,28 @@ function standingAuthorizationUnknownMessage(unknown, problems = []) {
257
285
  // names are ... issue" beside "unrecognized action: issue" would contradict
258
286
  // itself. Name what is missing instead, and why this one name carries it.
259
287
  for (const problem of problems) {
288
+ if (problem.reason === "mixed-push") {
289
+ notes.push(
290
+ `\`push\` and ${problem.scoped.map((entry) => `\`${entry}\``).join(", ")} are `
291
+ + "declared together; the bare form would silently widen the scoped "
292
+ + "one. Keep `push` alone, or only the `push:<branch glob>` entries."
293
+ );
294
+ continue;
295
+ }
296
+ if (problem.action === "push") {
297
+ notes.push(
298
+ `\`${problem.entry}\` does not name a branch glob as \`push:<branch glob>\` — `
299
+ + "letters, digits, `.`, `_`, `-`, `/`, and `*`."
300
+ );
301
+ continue;
302
+ }
303
+ if (problem.action === "cleanup") {
304
+ notes.push(
305
+ `\`${problem.entry}\` is not \`cleanup:scratch\`, the one form this name `
306
+ + "takes: it covers the session's own scratchpad and nothing else."
307
+ );
308
+ continue;
309
+ }
260
310
  if (problem.reason === "missing-scope" && problem.action === "chat-reply") {
261
311
  notes.push(
262
312
  "`chat-reply` names no chat group; write it as `chat-reply:<group>`, "
@@ -271,7 +321,7 @@ function standingAuthorizationUnknownMessage(unknown, problems = []) {
271
321
  } else if (problem.reason === "missing-scope") {
272
322
  notes.push(
273
323
  `\`${problem.action}\` names no repository; write it as `
274
- + `\`${problem.action}:<owner>/<repo>\`. The credentials that open an `
324
+ + `\`${problem.action}:<owner>/<repo>\`. The credentials that open or close an `
275
325
  + "issue are account-wide, so an unscoped grant would reach every "
276
326
  + "repository the account can touch — wider than commit or push, "
277
327
  + "which this checkout bounds."
@@ -318,17 +368,30 @@ function readStandingAuthorization(repo) {
318
368
  // Fail closed. A declaration Keel cannot fully read authorizes nothing,
319
369
  // because the alternative is granting the entries beside a typo while the
320
370
  // author believes they granted the typo too.
371
+ const pushGlobs = [];
372
+ for (const entry of declared) {
373
+ const classified = classifyAuthorizationEntry(entry);
374
+ if (classified.action === "push" && classified.scope !== null && !pushGlobs.includes(classified.scope)) {
375
+ pushGlobs.push(classified.scope);
376
+ }
377
+ }
378
+ if (pushGlobs.length && declared.includes("push")) {
379
+ unknown.push("push");
380
+ problems.push({ reason: "mixed-push", entry: "push", action: "push", scoped: pushGlobs.map((glob) => `push:${glob}`) });
381
+ }
321
382
  if (unknown.length > 0) {
322
383
  return {
323
384
  declared: [],
324
385
  scopes: new Map(),
325
386
  chatReplyGroups: [],
387
+ pushGlobs: [],
326
388
  unknown,
327
389
  message: standingAuthorizationUnknownMessage(unknown, problems),
328
390
  };
329
391
  }
330
392
  if (chatReplyGroups.length) scopes.set("chat-reply", chatReplyGroups.join(", "));
331
- return { declared, scopes, chatReplyGroups, unknown, message: null };
393
+ if (pushGlobs.length) scopes.set("push", pushGlobs.join(", "));
394
+ return { declared, scopes, chatReplyGroups, pushGlobs, unknown, message: null };
332
395
  }
333
396
 
334
397
  // `full_mode_paths:` — the paths whose change always routes Full, whatever the