@christang/keel 5.109.0 → 5.110.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/README.md +10 -2
- package/assets/bootstrap/AGENTS.md +1 -1
- package/bin/keel.js +10 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/plugins/keel/scripts/pretooluse-guard.js +86 -7
- package/scripts/validate_plugin.py +120 -5
- package/src/core/config.js +25 -4
package/README.md
CHANGED
|
@@ -182,7 +182,7 @@ because a permission granted in conversation does not survive a context reset. D
|
|
|
182
182
|
`keel/config.yaml` instead:
|
|
183
183
|
|
|
184
184
|
```yaml
|
|
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
|
+
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, push-protected:<branch glob>[@<role>]
|
|
186
186
|
- commit
|
|
187
187
|
- push
|
|
188
188
|
```
|
|
@@ -223,6 +223,14 @@ push destination — naming `git push origin <branch>` instead. A bare `push` ke
|
|
|
223
223
|
and declaring it beside a `push:` glob is refused, because it would silently widen the glob. Codex
|
|
224
224
|
has no such hook, so there the scope is carried, not enforced.
|
|
225
225
|
|
|
226
|
+
`push-protected:<branch glob>`, optionally `@<role>`, names a branch that is neither allowed nor
|
|
227
|
+
refused but asked about (#280): a push to it makes the Claude write guard return `ask`, so Claude
|
|
228
|
+
Code asks you to confirm that one command, and the next push asks again — Keel stores no approval.
|
|
229
|
+
`push-protected:main@iecc-pm` lets only the session bound to `iecc-pm` ask; any other session is
|
|
230
|
+
refused. A permission mode that cannot be relied on to ask, `bypassPermissions` or `dontAsk`, is
|
|
231
|
+
refused too. Declaring it turns the push check on by itself, and a bare `push` beside it is
|
|
232
|
+
refused.
|
|
233
|
+
|
|
226
234
|
`cleanup:scratch` covers removing temporary worktrees and run output under the session's own
|
|
227
235
|
scratchpad, after checking that they are merged and that no process is using them. It never covers
|
|
228
236
|
a branch or another session's files, and like the tracker scopes it is carried, not enforced.
|
|
@@ -251,7 +259,7 @@ Three things the declaration is not:
|
|
|
251
259
|
anything.
|
|
252
260
|
- **Not a trigger.** It removes a confirmation, not the step that reaches the action. Nothing
|
|
253
261
|
schedules itself, and no next task is selected for you.
|
|
254
|
-
- **Not open-ended.** The
|
|
262
|
+
- **Not open-ended.** The eleven names above are the whole vocabulary. An unrecognized entry is
|
|
255
263
|
reported with the accepted names and the declaration authorizes nothing until you fix it — a
|
|
256
264
|
typo never becomes a silent grant.
|
|
257
265
|
|
package/bin/keel.js
CHANGED
|
@@ -2254,7 +2254,7 @@ 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.entries()].some(([action, scope]) => scope !== null && action !== "push")) {
|
|
2257
|
+
if ([...scopes.entries()].some(([action, scope]) => scope !== null && action !== "push" && action !== "push-protected")) {
|
|
2258
2258
|
printDoctorLine(
|
|
2259
2259
|
"scope",
|
|
2260
2260
|
"carried",
|
|
@@ -2266,6 +2266,15 @@ function printStandingAuthorizationSurface(repo) {
|
|
|
2266
2266
|
// The one scope something holds (#257): the Claude write guard reads the
|
|
2267
2267
|
// `push:` globs and refuses a `git push` to any other branch, with or
|
|
2268
2268
|
// without a task. Codex has no such hook, so there it is a declaration too.
|
|
2269
|
+
if (scopes.get("push-protected")) {
|
|
2270
|
+
printDoctorLine(
|
|
2271
|
+
"protected push",
|
|
2272
|
+
"asked",
|
|
2273
|
+
"the Claude write guard asks the user to confirm each push to these "
|
|
2274
|
+
+ "branches, one command at a time; a role after `@` limits who may be "
|
|
2275
|
+
+ "asked, and a mode that cannot ask (bypassPermissions, dontAsk) is refused"
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2269
2278
|
if (scopes.get("push")) {
|
|
2270
2279
|
printDoctorLine(
|
|
2271
2280
|
"push scope",
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.110.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.110.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.110.0",
|
|
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.
|
|
3
|
+
"version": "5.110.0",
|
|
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",
|
|
@@ -55,6 +55,20 @@ function deny(reason) {
|
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
// Hand the decision to the user for this one call (#280): the host asks, and
|
|
59
|
+
// nothing is stored, so the next call is asked again.
|
|
60
|
+
function ask(reason) {
|
|
61
|
+
process.stdout.write(
|
|
62
|
+
`${JSON.stringify({
|
|
63
|
+
hookSpecificOutput: {
|
|
64
|
+
hookEventName: "PreToolUse",
|
|
65
|
+
permissionDecision: "ask",
|
|
66
|
+
permissionDecisionReason: reason,
|
|
67
|
+
},
|
|
68
|
+
})}\n`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
function sha256(buffer) {
|
|
59
73
|
return crypto.createHash("sha256").update(buffer).digest("hex");
|
|
60
74
|
}
|
|
@@ -173,14 +187,16 @@ function gitOut(cwd, args) {
|
|
|
173
187
|
return result.status === 0 ? String(result.stdout || "").trim() : null;
|
|
174
188
|
}
|
|
175
189
|
|
|
190
|
+
// `push:` globs and `push-protected:` entries ({ glob, role }) of `authorize:`.
|
|
176
191
|
function readPushGlobs(top) {
|
|
177
192
|
let text = "";
|
|
178
193
|
try {
|
|
179
194
|
text = fs.readFileSync(path.join(top, "keel", "config.yaml"), "utf8");
|
|
180
195
|
} catch {
|
|
181
|
-
return [];
|
|
196
|
+
return { globs: [], protectedEntries: [] };
|
|
182
197
|
}
|
|
183
198
|
const globs = [];
|
|
199
|
+
const protectedEntries = [];
|
|
184
200
|
let inBlock = false;
|
|
185
201
|
for (const line of text.split(/\r?\n/)) {
|
|
186
202
|
if (/^\s*#/.test(line) || line.trim() === "") continue;
|
|
@@ -190,12 +206,35 @@ function readPushGlobs(top) {
|
|
|
190
206
|
}
|
|
191
207
|
if (!inBlock) continue;
|
|
192
208
|
if (!/^\s/.test(line)) break;
|
|
193
|
-
const
|
|
209
|
+
const bare = line.replace(/\s+#.*$/, "");
|
|
210
|
+
const entry = bare.match(/^\s+-\s*push:(\S+)\s*$/);
|
|
194
211
|
if (entry) globs.push(entry[1]);
|
|
212
|
+
const guarded = bare.match(/^\s+-\s*push-protected:([^@\s]+)(?:@(\S+))?\s*$/);
|
|
213
|
+
if (guarded) protectedEntries.push({ glob: guarded[1], role: guarded[2] || null });
|
|
195
214
|
}
|
|
196
|
-
return globs;
|
|
215
|
+
return { globs, protectedEntries };
|
|
197
216
|
}
|
|
198
217
|
|
|
218
|
+
// The chat role bound to the worktree at `top` (#245), for a role-limited
|
|
219
|
+
// protected branch (#280 D3). Read directly: this hook never spawns the CLI.
|
|
220
|
+
function sessionRole(top) {
|
|
221
|
+
for (const variable of ["KEEL_CHAT_ROLE", "KEEL_MAIL_ROLE"]) {
|
|
222
|
+
const value = (process.env[variable] || "").trim();
|
|
223
|
+
if (value) return value;
|
|
224
|
+
}
|
|
225
|
+
const common = gitOut(top, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
226
|
+
if (!common) return null;
|
|
227
|
+
try {
|
|
228
|
+
const roles = JSON.parse(fs.readFileSync(path.join(fs.realpathSync(common), "keel-chat", "roles.json"), "utf8"));
|
|
229
|
+
return roles[fs.realpathSync(top)] || null;
|
|
230
|
+
} catch {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Modes in which the host cannot be relied on to ask (#280 D3, F2).
|
|
236
|
+
const MODES_THAT_CANNOT_ASK = new Set(["bypassPermissions", "dontAsk"]);
|
|
237
|
+
|
|
199
238
|
// Shell words and the separators between commands. Quotes are honoured, and a
|
|
200
239
|
// word that the shell would expand (`$`, a backtick) is marked, because its
|
|
201
240
|
// value is not knowable here.
|
|
@@ -426,12 +465,16 @@ function checkPushes(event) {
|
|
|
426
465
|
? event.tool_input.command : "";
|
|
427
466
|
if (!/\bgit\b/.test(command) || !/\bpush\b/.test(command)) return 0;
|
|
428
467
|
const cwd = typeof event.cwd === "string" && event.cwd ? event.cwd : process.cwd();
|
|
468
|
+
const asks = [];
|
|
429
469
|
for (const push of findPushes(command, cwd)) {
|
|
430
470
|
const top = gitOut(push.dir || cwd, ["rev-parse", "--show-toplevel"]);
|
|
431
471
|
if (!top) continue;
|
|
432
|
-
const globs = readPushGlobs(top);
|
|
433
|
-
if (!globs.length) continue;
|
|
434
|
-
const declared =
|
|
472
|
+
const { globs, protectedEntries } = readPushGlobs(top);
|
|
473
|
+
if (!globs.length && !protectedEntries.length) continue;
|
|
474
|
+
const declared = [
|
|
475
|
+
...globs.map((glob) => `\`push:${glob}\``),
|
|
476
|
+
...protectedEntries.map((e) => `\`push-protected:${e.glob}${e.role ? `@${e.role}` : ""}\``),
|
|
477
|
+
].join(", ");
|
|
435
478
|
const result = pushTargets(push);
|
|
436
479
|
if (result.undetermined) {
|
|
437
480
|
deny(
|
|
@@ -441,7 +484,27 @@ function checkPushes(event) {
|
|
|
441
484
|
);
|
|
442
485
|
return 0;
|
|
443
486
|
}
|
|
444
|
-
const
|
|
487
|
+
const unlisted = result.targets.filter((branch) => !globs.some((glob) => globPattern(glob).test(branch)));
|
|
488
|
+
const outside = [];
|
|
489
|
+
for (const branch of unlisted) {
|
|
490
|
+
const entry = protectedEntries.find((e) => globPattern(e.glob).test(branch));
|
|
491
|
+
if (!entry) {
|
|
492
|
+
outside.push(branch);
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (entry.role) {
|
|
496
|
+
const role = sessionRole(top);
|
|
497
|
+
if (role !== entry.role) {
|
|
498
|
+
deny(
|
|
499
|
+
`Keel push guard: \`${branch}\` is protected for role ${entry.role}, and this `
|
|
500
|
+
+ `session is ${role ? `role ${role}` : "bound to no chat role"}; only an ${entry.role} `
|
|
501
|
+
+ "session may ask to push it."
|
|
502
|
+
);
|
|
503
|
+
return 0;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
asks.push(branch);
|
|
507
|
+
}
|
|
445
508
|
if (outside.length) {
|
|
446
509
|
deny(
|
|
447
510
|
`Keel push guard: this command pushes to ${outside.map((b) => `\`${b}\``).join(", ")}, `
|
|
@@ -451,6 +514,22 @@ function checkPushes(event) {
|
|
|
451
514
|
return 0;
|
|
452
515
|
}
|
|
453
516
|
}
|
|
517
|
+
if (asks.length) {
|
|
518
|
+
const mode = typeof event.permission_mode === "string" ? event.permission_mode : "";
|
|
519
|
+
const branches = asks.map((b) => `\`${b}\``).join(", ");
|
|
520
|
+
if (MODES_THAT_CANNOT_ASK.has(mode)) {
|
|
521
|
+
deny(
|
|
522
|
+
`Keel push guard: ${branches} is protected, so each push needs the user's `
|
|
523
|
+
+ `confirmation, and permission mode ${mode} cannot be relied on to ask. `
|
|
524
|
+
+ "Switch to a mode that asks, or let the user push it."
|
|
525
|
+
);
|
|
526
|
+
return 0;
|
|
527
|
+
}
|
|
528
|
+
ask(
|
|
529
|
+
`Keel push guard: ${branches} is a protected branch (keel/config.yaml `
|
|
530
|
+
+ "push-protected). Confirm only if the user approves this one push; the next push asks again."
|
|
531
|
+
);
|
|
532
|
+
}
|
|
454
533
|
return 0;
|
|
455
534
|
}
|
|
456
535
|
|
|
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
|
|
|
47
47
|
"scripts/validate_plugin.py",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
PACKAGE_VERSION = "5.
|
|
51
|
-
PROTOCOL_VERSION = "5.
|
|
50
|
+
PACKAGE_VERSION = "5.110.0"
|
|
51
|
+
PROTOCOL_VERSION = "5.110.0"
|
|
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
|
|
@@ -24545,6 +24545,42 @@ def validate_authorize_block_reads_every_line_scenario() -> int:
|
|
|
24545
24545
|
return 0
|
|
24546
24546
|
|
|
24547
24547
|
|
|
24548
|
+
def validate_push_protected_declaration_scenario() -> int:
|
|
24549
|
+
"""Issue #280: `push-protected:<glob>[@<role>]` is accepted and reported."""
|
|
24550
|
+
label = "push-protected-declaration:"
|
|
24551
|
+
with tempfile.TemporaryDirectory(prefix="keel-push-protected-") as raw_tmp:
|
|
24552
|
+
root = Path(raw_tmp)
|
|
24553
|
+
|
|
24554
|
+
def fixture(name: str, entries: list[str]) -> Path:
|
|
24555
|
+
repo = root / name
|
|
24556
|
+
repo.mkdir()
|
|
24557
|
+
write_authorize_config(repo, "authorize:\n" + "".join(f" - {e}\n" for e in entries))
|
|
24558
|
+
return repo
|
|
24559
|
+
|
|
24560
|
+
doctor = run_keel(fixture("good", ["push:claude/*", "push-protected:main@iecc-pm"]), "--doctor")
|
|
24561
|
+
line = next((l for l in doctor.stdout.splitlines() if l.strip().startswith("push-protected:")), "")
|
|
24562
|
+
if "authorized" not in line or "main@iecc-pm" not in line:
|
|
24563
|
+
report(f"{label} doctor's push-protected line is {line!r}.")
|
|
24564
|
+
report(doctor.stdout)
|
|
24565
|
+
return 1
|
|
24566
|
+
if "asks the user" not in doctor.stdout:
|
|
24567
|
+
report(f"{label} doctor does not say each protected push is asked: {doctor.stdout}")
|
|
24568
|
+
return 1
|
|
24569
|
+
for name, entries, needle in (
|
|
24570
|
+
("bad-role", ["push-protected:main@Not"], "push-protected:main@Not"),
|
|
24571
|
+
("mixed", ["push", "push-protected:main"], "push-protected:main"),
|
|
24572
|
+
):
|
|
24573
|
+
refused = run_keel(fixture(name, entries), "--doctor")
|
|
24574
|
+
if refused.returncode == 0:
|
|
24575
|
+
report(f"{label} {entries!r} was accepted.")
|
|
24576
|
+
return 1
|
|
24577
|
+
if needle not in refused.stdout + refused.stderr:
|
|
24578
|
+
report(f"{label} {entries!r} was refused without naming {needle!r}: {refused.stdout}")
|
|
24579
|
+
return 1
|
|
24580
|
+
report("push-protected-declaration scenario passed.")
|
|
24581
|
+
return 0
|
|
24582
|
+
|
|
24583
|
+
|
|
24548
24584
|
def validate_authorize_push_close_cleanup_scenario() -> int:
|
|
24549
24585
|
"""Issue #257: `push:<glob>`, `issue-close:<owner>/<repo>`, `cleanup:scratch`.
|
|
24550
24586
|
|
|
@@ -27539,7 +27575,7 @@ def validate_continuation_authorization_scenario() -> int:
|
|
|
27539
27575
|
ACCEPTED_AUTHORIZE_NAMES = (
|
|
27540
27576
|
"commit, push, push:<branch glob>, release, archive, continuation, "
|
|
27541
27577
|
"issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>, "
|
|
27542
|
-
"issue-close:<owner>/<repo>, cleanup:scratch"
|
|
27578
|
+
"issue-close:<owner>/<repo>, cleanup:scratch, push-protected:<branch glob>[@<role>]"
|
|
27543
27579
|
)
|
|
27544
27580
|
|
|
27545
27581
|
|
|
@@ -27593,7 +27629,7 @@ def validate_continuation_docs_scenario() -> int:
|
|
|
27593
27629
|
# to spell all of it: a reader copies from the list they are shown.
|
|
27594
27630
|
for needle in (
|
|
27595
27631
|
f"accepted names: {ACCEPTED_AUTHORIZE_NAMES}",
|
|
27596
|
-
"The
|
|
27632
|
+
"The eleven names above are the whole vocabulary.",
|
|
27597
27633
|
"`protocol-refresh`, the seventh name",
|
|
27598
27634
|
):
|
|
27599
27635
|
if needle not in readme:
|
|
@@ -27601,7 +27637,7 @@ def validate_continuation_docs_scenario() -> int:
|
|
|
27601
27637
|
return 1
|
|
27602
27638
|
|
|
27603
27639
|
config_text = (ROOT / "keel/config.yaml").read_text(encoding="utf-8")
|
|
27604
|
-
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:
|
|
27640
|
+
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,\n# push-protected:<branch glob>[@<role>]" not in config_text:
|
|
27605
27641
|
report(
|
|
27606
27642
|
f"{label}: keel/config.yaml's comment lacks: protocol-refresh in the "
|
|
27607
27643
|
"seven-name vocabulary."
|
|
@@ -30066,6 +30102,83 @@ def validate_push_branch_guard_scenario() -> int:
|
|
|
30066
30102
|
return 0
|
|
30067
30103
|
|
|
30068
30104
|
|
|
30105
|
+
def validate_push_protected_guard_scenario() -> int:
|
|
30106
|
+
"""Issue #280: a protected push is asked, never stored, and role-limited.
|
|
30107
|
+
|
|
30108
|
+
The real hook returns `ask` for the bound role in a mode that can ask,
|
|
30109
|
+
denies another role and a mode that cannot ask, and leaves `push:` and
|
|
30110
|
+
unlisted branches as they were.
|
|
30111
|
+
"""
|
|
30112
|
+
label = "push-protected-guard:"
|
|
30113
|
+
with tempfile.TemporaryDirectory(prefix="keel-push-protected-guard-") as raw:
|
|
30114
|
+
base = Path(raw)
|
|
30115
|
+
repo = mailbox_repository(base / "repo")
|
|
30116
|
+
pm = chat_worktree(repo, base / "pm")
|
|
30117
|
+
rtl = chat_worktree(repo, base / "rtl")
|
|
30118
|
+
env = chat_environment()
|
|
30119
|
+
run_keel(pm, "chat", "role", "--set", "iecc-pm", env=env)
|
|
30120
|
+
run_keel(rtl, "chat", "role", "--set", "rtl", env=env)
|
|
30121
|
+
hook_env = {k: v for k, v in os.environ.items() if k not in ("KEEL_CHAT_ROLE", "KEEL_MAIL_ROLE")}
|
|
30122
|
+
hook_env["CLAUDE_PLUGIN_ROOT"] = str(ROOT / PLUGIN_ROOT)
|
|
30123
|
+
|
|
30124
|
+
def declare(entries: list[str]) -> None:
|
|
30125
|
+
for cwd in (pm, rtl):
|
|
30126
|
+
write_authorize_config(cwd, "authorize:\n" + "".join(f" - {e}\n" for e in entries))
|
|
30127
|
+
|
|
30128
|
+
def decide(cwd: Path, command: str, mode: str = "default") -> dict:
|
|
30129
|
+
event = {"tool_name": "Bash", "tool_input": {"command": command}, "cwd": str(cwd), "permission_mode": mode}
|
|
30130
|
+
result = subprocess.run(
|
|
30131
|
+
["node", str(ROOT / PLUGIN_ROOT / "scripts/pretooluse-guard.js")],
|
|
30132
|
+
cwd=cwd, env=hook_env, input=json.dumps(event), text=True, capture_output=True, check=False,
|
|
30133
|
+
)
|
|
30134
|
+
return pretooluse_decision(result) or {"permissionDecision": "pass"}
|
|
30135
|
+
|
|
30136
|
+
declare(["push:claude/*", "push-protected:main@iecc-pm"])
|
|
30137
|
+
store_before = chat_logs_snapshot(repo)
|
|
30138
|
+
for attempt in (1, 2):
|
|
30139
|
+
asked = decide(pm, "git push origin HEAD:main")
|
|
30140
|
+
if asked.get("permissionDecision") != "ask":
|
|
30141
|
+
report(f"{label} the coordinator's push to main (attempt {attempt}) was {asked!r}, not ask.")
|
|
30142
|
+
return 1
|
|
30143
|
+
if "main" not in asked.get("permissionDecisionReason", ""):
|
|
30144
|
+
report(f"{label} the ask does not name main: {asked!r}")
|
|
30145
|
+
return 1
|
|
30146
|
+
if chat_logs_snapshot(repo) != store_before:
|
|
30147
|
+
report(f"{label} asking wrote to the chat store.")
|
|
30148
|
+
return 1
|
|
30149
|
+
other = decide(rtl, "git push origin HEAD:main")
|
|
30150
|
+
if other.get("permissionDecision") != "deny":
|
|
30151
|
+
report(f"{label} another role's push to main was {other!r}, not deny.")
|
|
30152
|
+
return 1
|
|
30153
|
+
if "iecc-pm" not in other.get("permissionDecisionReason", ""):
|
|
30154
|
+
report(f"{label} the refusal does not name iecc-pm: {other!r}")
|
|
30155
|
+
return 1
|
|
30156
|
+
for mode in ("bypassPermissions", "dontAsk"):
|
|
30157
|
+
refused = decide(pm, "git push origin HEAD:main", mode)
|
|
30158
|
+
if refused.get("permissionDecision") != "deny":
|
|
30159
|
+
report(f"{label} the protected push in {mode} was {refused!r}, not deny.")
|
|
30160
|
+
return 1
|
|
30161
|
+
if mode not in refused.get("permissionDecisionReason", ""):
|
|
30162
|
+
report(f"{label} the {mode} refusal does not name the mode: {refused!r}")
|
|
30163
|
+
return 1
|
|
30164
|
+
if decide(rtl, "git push origin claude/fix").get("permissionDecision") != "pass":
|
|
30165
|
+
report(f"{label} a declared push: branch was intercepted.")
|
|
30166
|
+
return 1
|
|
30167
|
+
if decide(rtl, "git push origin release").get("permissionDecision") != "deny":
|
|
30168
|
+
report(f"{label} an unlisted branch was not denied.")
|
|
30169
|
+
return 1
|
|
30170
|
+
|
|
30171
|
+
declare(["push-protected:main"])
|
|
30172
|
+
if decide(rtl, "git push origin release").get("permissionDecision") != "deny":
|
|
30173
|
+
report(f"{label} with only push-protected declared, an unlisted branch was not denied.")
|
|
30174
|
+
return 1
|
|
30175
|
+
if decide(rtl, "git push origin HEAD:main").get("permissionDecision") != "ask":
|
|
30176
|
+
report(f"{label} with no role limit, a push to main was not asked.")
|
|
30177
|
+
return 1
|
|
30178
|
+
report("push-protected-guard scenario passed.")
|
|
30179
|
+
return 0
|
|
30180
|
+
|
|
30181
|
+
|
|
30069
30182
|
def validate_touch_write_guard_scenario() -> int:
|
|
30070
30183
|
with tempfile.TemporaryDirectory(
|
|
30071
30184
|
prefix="keel-touch-guard-", ignore_cleanup_errors=True
|
|
@@ -38611,6 +38724,7 @@ SCENARIOS: tuple = (
|
|
|
38611
38724
|
validate_standing_authorization_declaration_scenario,
|
|
38612
38725
|
),
|
|
38613
38726
|
("authorize-push-close-cleanup", validate_authorize_push_close_cleanup_scenario),
|
|
38727
|
+
("push-protected-declaration", validate_push_protected_declaration_scenario),
|
|
38614
38728
|
("authorize-block-reads-every-line", validate_authorize_block_reads_every_line_scenario),
|
|
38615
38729
|
(
|
|
38616
38730
|
"standing-authorization-sync-confusion",
|
|
@@ -38819,6 +38933,7 @@ SCENARIOS: tuple = (
|
|
|
38819
38933
|
("native-single-task-matrix", validate_native_single_task_matrix_scenario),
|
|
38820
38934
|
("touch-write-guard", validate_touch_write_guard_scenario),
|
|
38821
38935
|
("push-branch-guard", validate_push_branch_guard_scenario),
|
|
38936
|
+
("push-protected-guard", validate_push_protected_guard_scenario),
|
|
38822
38937
|
("touch-guard-record-layer", validate_touch_guard_record_layer_scenario),
|
|
38823
38938
|
("repo-action-mode", validate_repo_action_mode_scenario),
|
|
38824
38939
|
("runner-skip-accounting", validate_runner_skip_accounting_scenario),
|
package/src/core/config.js
CHANGED
|
@@ -28,6 +28,9 @@ const STANDING_AUTHORIZATION_ACTIONS = [
|
|
|
28
28
|
// scratchpad once merged and unused, never a branch or another session's
|
|
29
29
|
// files (#257). Its one scope, `scratch`, says which tree it reaches.
|
|
30
30
|
"cleanup",
|
|
31
|
+
// A branch the Claude write guard asks the user about, one push at a time,
|
|
32
|
+
// instead of refusing (#280); `@<role>` limits who may be asked.
|
|
33
|
+
"push-protected",
|
|
31
34
|
];
|
|
32
35
|
|
|
33
36
|
// The actions whose credential reaches further than the checkout the
|
|
@@ -37,7 +40,7 @@ const STANDING_AUTHORIZATION_ACTIONS = [
|
|
|
37
40
|
// actions are declared with the resource they may reach and refused bare —
|
|
38
41
|
// accepting the bare form as a convenience would make the narrow form optional
|
|
39
42
|
// and the wide one the default, which is the decision inverted.
|
|
40
|
-
const SCOPED_AUTHORIZATION_ACTIONS = new Set(["issue", "chat-reply", "issue-close", "cleanup"]);
|
|
43
|
+
const SCOPED_AUTHORIZATION_ACTIONS = new Set(["issue", "chat-reply", "issue-close", "cleanup", "push-protected"]);
|
|
41
44
|
|
|
42
45
|
// Actions whose scope narrows them but is not required (#257). A bare `push`
|
|
43
46
|
// keeps the meaning it always had; `push:<branch glob>` limits it to matching
|
|
@@ -60,6 +63,7 @@ const AUTHORIZATION_SCOPES = {
|
|
|
60
63
|
// Branch-name characters and `*`; `*` matches within one `/` segment and
|
|
61
64
|
// `**` across them, as Touch globs do.
|
|
62
65
|
push: { form: "<branch glob>", pattern: /^[A-Za-z0-9._/*-]+$/ },
|
|
66
|
+
"push-protected": { form: "<branch glob>[@<role>]", pattern: /^[A-Za-z0-9._/*-]+(?:@[a-z0-9][a-z0-9-]{0,31})?$/ },
|
|
63
67
|
};
|
|
64
68
|
|
|
65
69
|
// How the accepted names are spelled back to an author: the scoped ones carry
|
|
@@ -295,6 +299,14 @@ function standingAuthorizationUnknownMessage(unknown, problems = []) {
|
|
|
295
299
|
);
|
|
296
300
|
continue;
|
|
297
301
|
}
|
|
302
|
+
if (problem.action === "push-protected") {
|
|
303
|
+
notes.push(
|
|
304
|
+
`\`${problem.entry}\` is not \`push-protected:<branch glob>\` or `
|
|
305
|
+
+ "`push-protected:<branch glob>@<role>` — a glob of letters, digits, `.`, `_`, `-`, `/`, and `*`, "
|
|
306
|
+
+ "and a chat role of lowercase letters, digits, and hyphens."
|
|
307
|
+
);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
298
310
|
if (problem.action === "push") {
|
|
299
311
|
notes.push(
|
|
300
312
|
`\`${problem.entry}\` does not name a branch glob as \`push:<branch glob>\` — `
|
|
@@ -371,15 +383,22 @@ function readStandingAuthorization(repo) {
|
|
|
371
383
|
// because the alternative is granting the entries beside a typo while the
|
|
372
384
|
// author believes they granted the typo too.
|
|
373
385
|
const pushGlobs = [];
|
|
386
|
+
const protectedPushes = [];
|
|
374
387
|
for (const entry of declared) {
|
|
375
388
|
const classified = classifyAuthorizationEntry(entry);
|
|
376
389
|
if (classified.action === "push" && classified.scope !== null && !pushGlobs.includes(classified.scope)) {
|
|
377
390
|
pushGlobs.push(classified.scope);
|
|
378
391
|
}
|
|
392
|
+
if (classified.action === "push-protected" && !protectedPushes.includes(classified.scope)) {
|
|
393
|
+
protectedPushes.push(classified.scope);
|
|
394
|
+
}
|
|
379
395
|
}
|
|
380
|
-
if (pushGlobs.length && declared.includes("push")) {
|
|
396
|
+
if ((pushGlobs.length || protectedPushes.length) && declared.includes("push")) {
|
|
381
397
|
unknown.push("push");
|
|
382
|
-
problems.push({
|
|
398
|
+
problems.push({
|
|
399
|
+
reason: "mixed-push", entry: "push", action: "push",
|
|
400
|
+
scoped: [...pushGlobs.map((glob) => `push:${glob}`), ...protectedPushes.map((scope) => `push-protected:${scope}`)],
|
|
401
|
+
});
|
|
383
402
|
}
|
|
384
403
|
if (unknown.length > 0) {
|
|
385
404
|
return {
|
|
@@ -387,13 +406,15 @@ function readStandingAuthorization(repo) {
|
|
|
387
406
|
scopes: new Map(),
|
|
388
407
|
chatReplyGroups: [],
|
|
389
408
|
pushGlobs: [],
|
|
409
|
+
protectedPushes: [],
|
|
390
410
|
unknown,
|
|
391
411
|
message: standingAuthorizationUnknownMessage(unknown, problems),
|
|
392
412
|
};
|
|
393
413
|
}
|
|
394
414
|
if (chatReplyGroups.length) scopes.set("chat-reply", chatReplyGroups.join(", "));
|
|
395
415
|
if (pushGlobs.length) scopes.set("push", pushGlobs.join(", "));
|
|
396
|
-
|
|
416
|
+
if (protectedPushes.length) scopes.set("push-protected", protectedPushes.join(", "));
|
|
417
|
+
return { declared, scopes, chatReplyGroups, pushGlobs, protectedPushes, unknown, message: null };
|
|
397
418
|
}
|
|
398
419
|
|
|
399
420
|
// `full_mode_paths:` — the paths whose change always routes Full, whatever the
|