@christang/keel 5.206.0 → 5.208.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/.claude-plugin/plugin.json +1 -1
- package/README.md +4 -0
- package/README.zh-CN.md +3 -0
- package/assets/bootstrap/AGENTS.md +1 -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/scripts/validation/common.py +2 -2
- package/scripts/validation/contract.py +73 -0
- package/scripts/validation/registry.py +3 -0
- package/scripts/validation/shift.py +89 -0
- package/src/core/branches.js +5 -5
- package/src/core/chat/cli.js +5 -4
- package/src/core/chat/store.js +37 -1
- package/src/core/gates.js +16 -6
- package/src/core/patrol.js +8 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.208.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",
|
package/README.md
CHANGED
|
@@ -883,6 +883,10 @@ fetches nothing, schedules nothing, calls no model, and writes nothing when noth
|
|
|
883
883
|
0 then, 2 when the coordinator has something to act on — a risk, or its own wait met — 3 when it only
|
|
884
884
|
recorded something or told other roles, and 1 on an error, so a cheap scheduler — cron, `/loop`, CI —
|
|
885
885
|
can wake the model only on 2 (#350). `keel chat waits` lists what is still awaited.
|
|
886
|
+
A commit wait can name its branch, `--branch main`, and then holds only once that remote branch
|
|
887
|
+
contains the commit (#477). Without `--branch`, a repository whose `branches:` declares a `trunk:`
|
|
888
|
+
waits for the remote's default branch or any declared trunk. One that declares none waits for any
|
|
889
|
+
branch of the remote, and the echo and `keel chat waits` say `any branch of origin`.
|
|
886
890
|
|
|
887
891
|
A patrol on an hourly schedule should report change, not state, or it wakes the coordinator every
|
|
888
892
|
hour for a note deliberately left parked (#295). `keel patrol --since-last` keeps a snapshot per role
|
package/README.zh-CN.md
CHANGED
|
@@ -735,6 +735,9 @@ keel patrol --issues /tmp/issues.json # 以协调者的角色运行
|
|
|
735
735
|
角色。它不 fetch、不调度、不调用模型,没有新情况时什么都不写;这时它以 0 退出,当协调者有事要处理——一个风险,
|
|
736
736
|
或它自己的等待已满足——时以 2 退出,只记录了东西或通知了其他角色时以 3 退出,出错时以 1 退出,所以一个廉价的
|
|
737
737
|
调度器——cron、`/loop`、CI——可以只在 2 时唤醒模型(#350)。`keel chat waits` 列出仍在等待的事项。
|
|
738
|
+
提交类等待可以用 `--branch main` 指定分支,这时只有那个远端分支包含该提交才算满足(#477)。不带 `--branch` 时,
|
|
739
|
+
`branches:` 声明了 `trunk:` 的仓库等的是远端默认分支或任一声明的主干;没有声明的仓库等的是远端的任一分支,
|
|
740
|
+
登记回显和 `keel chat waits` 会写明 `any branch of origin`。
|
|
738
741
|
|
|
739
742
|
按小时运行的巡查应该报告变化而不是状态,否则它每小时都会为一张故意搁置的便条唤醒协调者(#295)。
|
|
740
743
|
`keel patrol --since-last` 为每个角色保存一份快照——换班状态、远端默认分支的末端、主 checkout 的未提交路径、
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.208.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.208.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.208.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.208.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",
|
|
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
|
|
|
35
35
|
os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
PACKAGE_VERSION = "5.
|
|
38
|
+
PACKAGE_VERSION = "5.208.0"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.
|
|
41
|
+
PROTOCOL_VERSION = "5.208.0"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
@@ -10537,6 +10537,79 @@ def problem_codes(payload: dict) -> list[str]:
|
|
|
10537
10537
|
# passed, one where the fixture contained no wording the checker would refuse.
|
|
10538
10538
|
# The declaration is what a gate can hold: written into the check, so it is in
|
|
10539
10539
|
# the fingerprint, and therefore written before the run rather than after it.
|
|
10540
|
+
def validate_declared_literal_whitespace_scenario() -> int:
|
|
10541
|
+
"""Issue #479 D1, D2: declared literals match recorded Evidence with whitespace runs as one space.
|
|
10542
|
+
|
|
10543
|
+
Tool output aligns with runs of spaces; a literal copied from it must
|
|
10544
|
+
match the raw output it was copied from, while different characters are
|
|
10545
|
+
still refused and the refusal rules spacing out.
|
|
10546
|
+
"""
|
|
10547
|
+
label = "declared-literal-whitespace"
|
|
10548
|
+
with tempfile.TemporaryDirectory(prefix="keel-literal-479-") as raw:
|
|
10549
|
+
repo = Path(raw) / "repo"
|
|
10550
|
+
|
|
10551
|
+
def complete(check: str, evidence: list[str]) -> dict:
|
|
10552
|
+
task = "\n".join([
|
|
10553
|
+
"- [x] 1.1 Literal probe",
|
|
10554
|
+
" - Owner: claude",
|
|
10555
|
+
" - Mode: implementation",
|
|
10556
|
+
" - Covers:",
|
|
10557
|
+
" - E1: the task proves its own behavior",
|
|
10558
|
+
" - Read:",
|
|
10559
|
+
" - README.md",
|
|
10560
|
+
" - Touch:",
|
|
10561
|
+
" - src/example.js",
|
|
10562
|
+
" - Verify:",
|
|
10563
|
+
" - Strategy: vertical-tdd",
|
|
10564
|
+
f" - M1: node test.js asserts the public behavior. {check}",
|
|
10565
|
+
" - Evidence:",
|
|
10566
|
+
*evidence,
|
|
10567
|
+
" - Review:",
|
|
10568
|
+
" - Status: pass",
|
|
10569
|
+
" - Acceptance check: the behavior is proven.",
|
|
10570
|
+
" - Scope check: only Touch changed.",
|
|
10571
|
+
" - Findings: none.",
|
|
10572
|
+
" - Blocker: none",
|
|
10573
|
+
" - Reauthorizations: none",
|
|
10574
|
+
])
|
|
10575
|
+
write_gate_fixture(repo, tasks=task)
|
|
10576
|
+
started = run_keel(repo, "gate", "task-start", "--change", "demo", "--task", "1.1", "--record", "--json")
|
|
10577
|
+
try:
|
|
10578
|
+
json.loads(started.stdout)
|
|
10579
|
+
except json.JSONDecodeError:
|
|
10580
|
+
return {"status": "unstarted", "problems": [{"message": started.stdout[:300]}]}
|
|
10581
|
+
done = run_keel(repo, "gate", "task-complete", "--change", "demo", "--task", "1.1", "--json")
|
|
10582
|
+
try:
|
|
10583
|
+
return json.loads(done.stdout)
|
|
10584
|
+
except json.JSONDecodeError:
|
|
10585
|
+
return {"status": "unparsed", "problems": [{"message": done.stdout[:400]}]}
|
|
10586
|
+
|
|
10587
|
+
cases = (
|
|
10588
|
+
("an aligned failure signature", "Fails with: `FAIL record reachable`",
|
|
10589
|
+
[" - M1: pass.", " - M1.red: fail. `FAIL record reachable` (exit 1).", " - M1.green: pass."]),
|
|
10590
|
+
("an aligned injection failure", "Fails with: `boom` Detects: `drop the guard` -> `FAIL guard missing`",
|
|
10591
|
+
[" - M1: pass.", " - M1.red: fail. `boom`.", " - M1.green: pass.",
|
|
10592
|
+
" - M1.detects: fail. `FAIL guard missing`."]),
|
|
10593
|
+
("a spaced measurement", "Fails with: `boom` Measured: `took 12 s`",
|
|
10594
|
+
[" - M1: pass. the run took 12 s.", " - M1.red: fail. `boom`.", " - M1.green: pass."]),
|
|
10595
|
+
)
|
|
10596
|
+
for name, check, evidence in cases:
|
|
10597
|
+
result = complete(check, evidence)
|
|
10598
|
+
if result.get("status") != "pass":
|
|
10599
|
+
report(f"{label}: {name} copied from the raw output was refused; {problem_codes(result)!r} {problem_text(result)!r}.")
|
|
10600
|
+
return 1
|
|
10601
|
+
wrong = complete("Fails with: `FAIL record reachable`",
|
|
10602
|
+
[" - M1: pass.", " - M1.red: fail. `FAIL record unreachable` (exit 1).", " - M1.green: pass."])
|
|
10603
|
+
if "red-missing-declared-failure" not in problem_codes(wrong):
|
|
10604
|
+
report(f"{label}: a red with different characters was not refused as red-missing-declared-failure; {problem_codes(wrong)!r}.")
|
|
10605
|
+
return 1
|
|
10606
|
+
if "as one space" not in problem_text(wrong):
|
|
10607
|
+
report(f"{label}: the refusal does not say runs of whitespace are compared as one space; {problem_text(wrong)!r}.")
|
|
10608
|
+
return 1
|
|
10609
|
+
report(f"{label} scenario passed.")
|
|
10610
|
+
return 0
|
|
10611
|
+
|
|
10612
|
+
|
|
10540
10613
|
def validate_red_declares_what_it_proves_scenario() -> int:
|
|
10541
10614
|
label = "a-red-declares-what-it-proves"
|
|
10542
10615
|
signature = "openspec: not found"
|
|
@@ -199,6 +199,7 @@ SCENARIOS: tuple = (
|
|
|
199
199
|
("output-survives-the-pipe", selfcheck.validate_output_survives_the_pipe_scenario),
|
|
200
200
|
("a-strategy-is-declared", contract.validate_strategy_is_declared_scenario),
|
|
201
201
|
("a-red-declares-what-it-proves", contract.validate_red_declares_what_it_proves_scenario),
|
|
202
|
+
("declared-literal-whitespace", contract.validate_declared_literal_whitespace_scenario),
|
|
202
203
|
("the-weakest-strategy-states-its-reason", contract.validate_weakest_strategy_states_its_reason_scenario),
|
|
203
204
|
("a-quoted-marker-is-not-a-disposition", contract.validate_quoted_marker_is_not_a_disposition_scenario),
|
|
204
205
|
("drift-names-where-to-look", contract.validate_drift_names_where_to_look_scenario),
|
|
@@ -469,6 +470,8 @@ SCENARIOS: tuple = (
|
|
|
469
470
|
("chat-ack", chat.validate_chat_ack_scenario),
|
|
470
471
|
("chat-reply-addresses-author", chat.validate_chat_reply_addresses_author_scenario),
|
|
471
472
|
("coordinator-patrol", shift.validate_coordinator_patrol_scenario),
|
|
473
|
+
("chat-wait-commit-branch", shift.validate_chat_wait_commit_branch_scenario),
|
|
474
|
+
("chat-wait-commit-trunks", shift.validate_chat_wait_commit_trunks_scenario),
|
|
472
475
|
("patrol-since-last", shift.validate_patrol_since_last_scenario),
|
|
473
476
|
("patrol-next", shift.validate_patrol_next_scenario),
|
|
474
477
|
("tick-runs-due-patrol", shift.validate_tick_runs_due_patrol_scenario),
|
|
@@ -1397,6 +1397,95 @@ def validate_patrol_quota_scenario() -> int:
|
|
|
1397
1397
|
return 0
|
|
1398
1398
|
|
|
1399
1399
|
|
|
1400
|
+
def wait_branch_scratch(base: Path, config: str = "") -> tuple[Path, Path, dict, str]:
|
|
1401
|
+
"""rtl and verify in group soc, a bare origin with `main`, and a commit pushed only to `origin/feature` (#477)."""
|
|
1402
|
+
rtl, verify, env = chat_scratch_group(base)
|
|
1403
|
+
if config:
|
|
1404
|
+
write_authorize_config(rtl, config)
|
|
1405
|
+
write_authorize_config(verify, config)
|
|
1406
|
+
subprocess.run(["git", "add", "-A"], cwd=rtl, check=True, capture_output=True)
|
|
1407
|
+
subprocess.run(["git", "commit", "-q", "-m", "config"], cwd=rtl, check=True, capture_output=True)
|
|
1408
|
+
origin = base / "origin.git"
|
|
1409
|
+
subprocess.run(["git", "init", "-q", "--bare", str(origin)], check=True, capture_output=True)
|
|
1410
|
+
for args in (["remote", "add", "origin", str(origin)], ["push", "-q", "origin", "main", "main:integ"],
|
|
1411
|
+
["switch", "-q", "-c", "feature"], ["commit", "-q", "--allow-empty", "-m", "fix"],
|
|
1412
|
+
["push", "-q", "origin", "feature"], ["fetch", "-q", "origin"]):
|
|
1413
|
+
subprocess.run(["git", *args], cwd=rtl, check=True, capture_output=True)
|
|
1414
|
+
sha = subprocess.run(["git", "rev-parse", "HEAD"], cwd=rtl, check=True, capture_output=True, text=True).stdout.strip()
|
|
1415
|
+
return rtl, verify, env, sha
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
def push_to(rtl: Path, sha: str, branch: str) -> None:
|
|
1419
|
+
for args in (["push", "-q", "origin", f"{sha}:refs/heads/{branch}"], ["fetch", "-q", "origin"]):
|
|
1420
|
+
subprocess.run(["git", *args], cwd=rtl, check=True, capture_output=True)
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
def validate_chat_wait_commit_branch_scenario() -> int:
|
|
1424
|
+
"""Issue #477 D1: a commit wait with `--branch` holds only when that branch contains the commit."""
|
|
1425
|
+
label = "chat-wait-commit-branch:"
|
|
1426
|
+
with tempfile.TemporaryDirectory(prefix="keel-wait-branch-") as raw:
|
|
1427
|
+
rtl, verify, env, sha = wait_branch_scratch(Path(raw))
|
|
1428
|
+
waited = run_keel(verify, "chat", "wait", "soc", "--commit", sha, "--branch", "main", env=env)
|
|
1429
|
+
if waited.returncode != 0:
|
|
1430
|
+
report(f"{label} keel chat wait --branch main exited {waited.returncode}: {waited.stderr!r}")
|
|
1431
|
+
return 1
|
|
1432
|
+
|
|
1433
|
+
def told() -> int:
|
|
1434
|
+
return len(chat_records_with(rtl, "dm-rtl--verify", sha[:7]))
|
|
1435
|
+
|
|
1436
|
+
run_keel(rtl, "patrol", env=env)
|
|
1437
|
+
waits = chat_json(run_keel(rtl, "chat", "waits", "--json", env=env)).get("waits", [])
|
|
1438
|
+
if [w.get("condition") for w in waits] != [f"commit {sha} on origin/main"]:
|
|
1439
|
+
report(f"{label} with the commit only on origin/feature, waits lists {waits!r}, not the open wait on origin/main.")
|
|
1440
|
+
return 1
|
|
1441
|
+
if told():
|
|
1442
|
+
report(f"{label} verify was told of the commit while it was only on origin/feature.")
|
|
1443
|
+
return 1
|
|
1444
|
+
push_to(rtl, sha, "main")
|
|
1445
|
+
run_keel(rtl, "patrol", env=env)
|
|
1446
|
+
if len(chat_records_with(rtl, "dm-rtl--verify", "origin/main")) != 1:
|
|
1447
|
+
report(f"{label} after the push to main verify has {told()} messages naming the commit, not one naming origin/main.")
|
|
1448
|
+
return 1
|
|
1449
|
+
if chat_json(run_keel(rtl, "chat", "waits", "--json", env=env)).get("waits"):
|
|
1450
|
+
report(f"{label} the met wait is still listed.")
|
|
1451
|
+
return 1
|
|
1452
|
+
report("chat-wait-commit-branch scenario passed.")
|
|
1453
|
+
return 0
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
def validate_chat_wait_commit_trunks_scenario() -> int:
|
|
1457
|
+
"""Issue #477 D2, D3: declared trunks are a commit wait's default; an undeclared one says any branch."""
|
|
1458
|
+
label = "chat-wait-commit-trunks:"
|
|
1459
|
+
with tempfile.TemporaryDirectory(prefix="keel-wait-trunks-") as raw:
|
|
1460
|
+
base = Path(raw)
|
|
1461
|
+
rtl, verify, env, sha = wait_branch_scratch(base / "declared", "branches:\n trunk:\n - integ\n")
|
|
1462
|
+
waited = run_keel(verify, "chat", "wait", "soc", "--commit", sha, env=env)
|
|
1463
|
+
if "origin/main or origin/integ" not in waited.stdout:
|
|
1464
|
+
report(f"{label} with trunk integ declared the wait does not name origin/main or origin/integ: {waited.stdout!r} {waited.stderr!r}")
|
|
1465
|
+
return 1
|
|
1466
|
+
run_keel(rtl, "patrol", env=env)
|
|
1467
|
+
if not chat_json(run_keel(rtl, "chat", "waits", "--json", env=env)).get("waits"):
|
|
1468
|
+
report(f"{label} the trunk wait was met while the commit was only on origin/feature.")
|
|
1469
|
+
return 1
|
|
1470
|
+
push_to(rtl, sha, "integ")
|
|
1471
|
+
run_keel(rtl, "patrol", env=env)
|
|
1472
|
+
if chat_json(run_keel(rtl, "chat", "waits", "--json", env=env)).get("waits"):
|
|
1473
|
+
report(f"{label} the trunk wait is still open after the commit reached origin/integ.")
|
|
1474
|
+
return 1
|
|
1475
|
+
|
|
1476
|
+
_rtl, verify, env, sha = wait_branch_scratch(base / "undeclared")
|
|
1477
|
+
echo = run_keel(verify, "chat", "wait", "soc", "--commit", sha, env=env)
|
|
1478
|
+
if "any branch of origin" not in echo.stdout:
|
|
1479
|
+
report(f"{label} with no trunk declared the wait's echo does not say any branch of origin: {echo.stdout!r}")
|
|
1480
|
+
return 1
|
|
1481
|
+
listed = run_keel(verify, "chat", "waits", env=env)
|
|
1482
|
+
if "any branch of origin" not in listed.stdout:
|
|
1483
|
+
report(f"{label} keel chat waits does not say any branch of origin: {listed.stdout!r}")
|
|
1484
|
+
return 1
|
|
1485
|
+
report("chat-wait-commit-trunks scenario passed.")
|
|
1486
|
+
return 0
|
|
1487
|
+
|
|
1488
|
+
|
|
1400
1489
|
def validate_coordinator_patrol_scenario() -> int:
|
|
1401
1490
|
"""Issue #260: declared waits, and a patrol that notifies once.
|
|
1402
1491
|
|
package/src/core/branches.js
CHANGED
|
@@ -49,11 +49,11 @@ function globRegExp(glob) {
|
|
|
49
49
|
|
|
50
50
|
const { readBranchesDeclaration } = require("./config");
|
|
51
51
|
|
|
52
|
-
function remoteDefault(cwd) {
|
|
53
|
-
const head = git(cwd, ["symbolic-ref", "--quiet", "--short", `refs/remotes/${
|
|
54
|
-
if (head.ok && head.out) return head.out.slice(
|
|
52
|
+
function remoteDefault(cwd, remote = REMOTE) {
|
|
53
|
+
const head = git(cwd, ["symbolic-ref", "--quiet", "--short", `refs/remotes/${remote}/HEAD`]);
|
|
54
|
+
if (head.ok && head.out) return head.out.slice(remote.length + 1);
|
|
55
55
|
for (const name of ["main", "master"]) {
|
|
56
|
-
if (git(cwd, ["rev-parse", "--verify", "--quiet", `refs/remotes/${
|
|
56
|
+
if (git(cwd, ["rev-parse", "--verify", "--quiet", `refs/remotes/${remote}/${name}`]).ok) return name;
|
|
57
57
|
}
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
@@ -255,4 +255,4 @@ function runBranches(argv) {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
module.exports = { BranchesError, readBranchesDeclaration, merged, describe, prune, runBranches, globRegExp, REMOTE, USAGE };
|
|
258
|
+
module.exports = { BranchesError, readBranchesDeclaration, remoteDefault, merged, describe, prune, runBranches, globRegExp, REMOTE, USAGE };
|
package/src/core/chat/cli.js
CHANGED
|
@@ -26,7 +26,7 @@ const USAGE = [
|
|
|
26
26
|
"keel chat ack <id> acknowledge a record that asks (a reply also counts)",
|
|
27
27
|
"keel chat acks [--mine] [--json] records still waiting on an acknowledgement",
|
|
28
28
|
"keel chat summary --since <90s|15m|2h|3d|date> [--group <group>] [--json] (what changed, per group and sender; reads without marking read)",
|
|
29
|
-
"keel chat wait <group> --commit <sha> [--remote <name>] [note...] (or --issue <n> --closed: what this role waits for; keel patrol tells it when it holds)",
|
|
29
|
+
"keel chat wait <group> --commit <sha> [--branch <name>] [--remote <name>] [note...] (or --issue <n> --closed: what this role waits for; keel patrol tells it when it holds)",
|
|
30
30
|
"keel chat waits [--json] waits not yet met",
|
|
31
31
|
"keel chat dm <role> <text...> [--no-stamp] [--not-a-loop <why>] [--json]",
|
|
32
32
|
"keel chat <group> [--since <90s|15m|2h|3d|date>] [--follow] [--peek] [--json] (view; advances your read position unless --peek)",
|
|
@@ -74,6 +74,7 @@ const VALUED = {
|
|
|
74
74
|
"--since": "since",
|
|
75
75
|
"--commit": "commit",
|
|
76
76
|
"--remote": "remote",
|
|
77
|
+
"--branch": "branch",
|
|
77
78
|
"--worktree": "worktree",
|
|
78
79
|
"--thread": "thread",
|
|
79
80
|
"--host": "host",
|
|
@@ -442,16 +443,16 @@ function dispatch(where, options) {
|
|
|
442
443
|
const [group, ...words] = rest;
|
|
443
444
|
if (!group) throw new ChatError("keel chat wait needs a group.");
|
|
444
445
|
const record = store.wait(where, {
|
|
445
|
-
group, commit: options.commit, remote: options.remote, issue: options.issue,
|
|
446
|
+
group, commit: options.commit, branch: options.branch, remote: options.remote, issue: options.issue,
|
|
446
447
|
closed: options.closed, text: words.join(" "),
|
|
447
448
|
});
|
|
448
|
-
out(options.json ? JSON.stringify({ id: record.id, condition: record.condition }) : `Waiting: ${record.condition} (${record.id}).`);
|
|
449
|
+
out(options.json ? JSON.stringify({ id: record.id, condition: record.condition }) : `Waiting: ${store.describeCondition(record.condition)} (${record.id}).`);
|
|
449
450
|
return 0;
|
|
450
451
|
}
|
|
451
452
|
case "waits": {
|
|
452
453
|
const waits = store.openWaits(where);
|
|
453
454
|
if (options.json) out(JSON.stringify({ waits: waits.map((w) => ({ id: w.id, group: w.group, from: w.from, condition: w.condition, text: w.text, created: w.created })) }));
|
|
454
|
-
else out(waits.length ? waits.map((w) => `${w.group} ${w.id} ${w.from} waits for ${w.condition}${w.text ? `: ${w.text}` : ""}`).join("\n") : "keel chat: nobody is waiting.");
|
|
455
|
+
else out(waits.length ? waits.map((w) => `${w.group} ${w.id} ${w.from} waits for ${store.describeCondition(w.condition)}${w.text ? `: ${w.text}` : ""}`).join("\n") : "keel chat: nobody is waiting.");
|
|
455
456
|
return 0;
|
|
456
457
|
}
|
|
457
458
|
case "dm": {
|
package/src/core/chat/store.js
CHANGED
|
@@ -893,7 +893,25 @@ function directPost(where, target, text, extra = {}) {
|
|
|
893
893
|
|
|
894
894
|
// --- waits (#260) ---------------------------------------------------------------
|
|
895
895
|
|
|
896
|
-
const WAIT_FORMS = "`--commit <sha> [--remote <name>]` or `--issue <n> --closed`";
|
|
896
|
+
const WAIT_FORMS = "`--commit <sha> [--branch <name>] [--remote <name>]` or `--issue <n> --closed`";
|
|
897
|
+
|
|
898
|
+
// `commit <sha> on <remote>` holds on any of the remote's branches; `on
|
|
899
|
+
// <remote>/<branch>`, joined by ` or `, only on those branches (#477 D1, D3).
|
|
900
|
+
function parseCommitCondition(condition) {
|
|
901
|
+
const match = String(condition).match(/^commit ([0-9a-f]+) on (.+)$/);
|
|
902
|
+
if (!match) return null;
|
|
903
|
+
const targets = match[2].split(" or ");
|
|
904
|
+
if (targets.length === 1 && !targets[0].includes("/")) return { sha: match[1], remote: targets[0], branches: null };
|
|
905
|
+
const refs = targets.map((target) => target.match(/^([^/\s]+)\/(\S+)$/));
|
|
906
|
+
if (refs.some((ref) => !ref)) return null;
|
|
907
|
+
return { sha: match[1], remote: refs[0][1], refs: refs.map((ref) => ({ remote: ref[1], branch: ref[2] })) };
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// A condition as people read it: an any-branch commit wait says so (#477 D2).
|
|
911
|
+
function describeCondition(condition) {
|
|
912
|
+
const commit = parseCommitCondition(condition);
|
|
913
|
+
return commit && !commit.refs ? `commit ${commit.sha} on any branch of ${commit.remote}` : String(condition);
|
|
914
|
+
}
|
|
897
915
|
|
|
898
916
|
// What a role is waiting for, as a record every session can read. A wait is
|
|
899
917
|
// not readable (D1): it wakes nobody and is unread for nobody.
|
|
@@ -914,8 +932,24 @@ function wait(where, options) {
|
|
|
914
932
|
const remote = options.remote || "origin";
|
|
915
933
|
checkName(remote.toLowerCase(), "Remote");
|
|
916
934
|
condition = `commit ${String(options.commit).toLowerCase()} on ${remote}`;
|
|
935
|
+
if (options.branch !== null && options.branch !== undefined) {
|
|
936
|
+
if (!/^[A-Za-z0-9._][A-Za-z0-9._/-]*$/.test(String(options.branch)) || String(options.branch).includes("..")) {
|
|
937
|
+
throw new ChatError(`--branch ${JSON.stringify(options.branch)} is not a branch name.`);
|
|
938
|
+
}
|
|
939
|
+
condition += `/${options.branch}`;
|
|
940
|
+
} else {
|
|
941
|
+
// Declared trunks are the default (#477 D3), resolved now so a later
|
|
942
|
+
// change to `branches:` does not move an open wait.
|
|
943
|
+
const branches = require("../branches");
|
|
944
|
+
const declared = branches.readBranchesDeclaration(where.worktree).trunk;
|
|
945
|
+
if (declared.length) {
|
|
946
|
+
const names = [...new Set([branches.remoteDefault(where.worktree, remote), ...declared].filter(Boolean))];
|
|
947
|
+
condition = `commit ${String(options.commit).toLowerCase()} on ${names.map((name) => `${remote}/${name}`).join(" or ")}`;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
917
950
|
} else {
|
|
918
951
|
if (!options.closed) throw new ChatError(`keel chat wait --issue needs --closed; use ${WAIT_FORMS}.`);
|
|
952
|
+
if (options.branch !== null && options.branch !== undefined) throw new ChatError(`--branch goes with --commit; use ${WAIT_FORMS}.`);
|
|
919
953
|
condition = `issue ${normalizeIssue(options.issue)} closed`;
|
|
920
954
|
}
|
|
921
955
|
const { state } = loadGroup(where, group);
|
|
@@ -1073,6 +1107,8 @@ module.exports = {
|
|
|
1073
1107
|
wait,
|
|
1074
1108
|
mentionText,
|
|
1075
1109
|
openWaits,
|
|
1110
|
+
parseCommitCondition,
|
|
1111
|
+
describeCondition,
|
|
1076
1112
|
markMet,
|
|
1077
1113
|
canAct,
|
|
1078
1114
|
ack,
|
package/src/core/gates.js
CHANGED
|
@@ -1444,7 +1444,7 @@ function completionChecks(repo, task, contract = null, changeVerify = null, chan
|
|
|
1444
1444
|
if (!entry.measured || !entry.label) continue;
|
|
1445
1445
|
const recorded = evidenceValue(task, entry.label);
|
|
1446
1446
|
if (!isConcrete(recorded)) continue;
|
|
1447
|
-
if (!
|
|
1447
|
+
if (!containsDeclared(recorded, entry.measured)) {
|
|
1448
1448
|
problems.push(
|
|
1449
1449
|
problem(
|
|
1450
1450
|
"measurement-missing-from-evidence",
|
|
@@ -1453,7 +1453,7 @@ function completionChecks(repo, task, contract = null, changeVerify = null, chan
|
|
|
1453
1453
|
+ "string. Paste the output the number came from, or correct the "
|
|
1454
1454
|
+ "declaration — which moves the contract fingerprint, because a "
|
|
1455
1455
|
+ "number reconciled to the output after the run is a transcription "
|
|
1456
|
-
+
|
|
1456
|
+
+ `of it.${WHITESPACE_NOTE}`,
|
|
1457
1457
|
)
|
|
1458
1458
|
);
|
|
1459
1459
|
}
|
|
@@ -1484,7 +1484,7 @@ function completionChecks(repo, task, contract = null, changeVerify = null, chan
|
|
|
1484
1484
|
);
|
|
1485
1485
|
continue;
|
|
1486
1486
|
}
|
|
1487
|
-
if (!
|
|
1487
|
+
if (!containsDeclared(recorded, entry.detects.failure)) {
|
|
1488
1488
|
problems.push(
|
|
1489
1489
|
problem(
|
|
1490
1490
|
"injection-missing-declared-failure",
|
|
@@ -1493,7 +1493,7 @@ function completionChecks(repo, task, contract = null, changeVerify = null, chan
|
|
|
1493
1493
|
+ `${entry.label}.detects Evidence does not contain that string. `
|
|
1494
1494
|
+ "Record what the mutation actually printed, or correct the "
|
|
1495
1495
|
+ "declaration — which moves the contract fingerprint, because an "
|
|
1496
|
-
+
|
|
1496
|
+
+ `injection edited after the run is a transcription of it.${WHITESPACE_NOTE}`,
|
|
1497
1497
|
)
|
|
1498
1498
|
);
|
|
1499
1499
|
}
|
|
@@ -1525,7 +1525,7 @@ function completionChecks(repo, task, contract = null, changeVerify = null, chan
|
|
|
1525
1525
|
if (exempt.has(label)) continue;
|
|
1526
1526
|
const expected = declaredFailure.get(label);
|
|
1527
1527
|
const recorded = evidenceValue(task, `${label}.red`);
|
|
1528
|
-
if (expected && isConcrete(recorded) && !
|
|
1528
|
+
if (expected && isConcrete(recorded) && !containsDeclared(recorded, expected)) {
|
|
1529
1529
|
problems.push(
|
|
1530
1530
|
problem(
|
|
1531
1531
|
"red-missing-declared-failure",
|
|
@@ -1534,7 +1534,7 @@ function completionChecks(repo, task, contract = null, changeVerify = null, chan
|
|
|
1534
1534
|
+ "string. Record the failure output the red actually printed, "
|
|
1535
1535
|
+ "or correct the declaration — which moves the contract "
|
|
1536
1536
|
+ "fingerprint, because a signature edited after the red was "
|
|
1537
|
-
+
|
|
1537
|
+
+ `observed is a transcription of it.${WHITESPACE_NOTE}`,
|
|
1538
1538
|
)
|
|
1539
1539
|
);
|
|
1540
1540
|
}
|
|
@@ -1860,6 +1860,16 @@ function changeEvidenceValue(content, tasks, label) {
|
|
|
1860
1860
|
return match ? match[1].trim() : "";
|
|
1861
1861
|
}
|
|
1862
1862
|
|
|
1863
|
+
// A declared literal is compiled from whitespace-collapsed check text, so the
|
|
1864
|
+
// recorded Evidence is collapsed the same way before it is searched; nothing
|
|
1865
|
+
// else is folded (#479 D1).
|
|
1866
|
+
function containsDeclared(recorded, literal) {
|
|
1867
|
+
const collapse = (value) => String(value).replace(/\s+/g, " ");
|
|
1868
|
+
return collapse(recorded).includes(collapse(literal));
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
const WHITESPACE_NOTE = " Runs of whitespace are compared as one space, so spacing is not the cause.";
|
|
1872
|
+
|
|
1863
1873
|
// `change-close`-only: `## Change Verify`'s own shape, and completeness of
|
|
1864
1874
|
// `## Change Evidence` for every check it declares — whether or not any task
|
|
1865
1875
|
// actually defers to it, because a declared check still owes its own result.
|
package/src/core/patrol.js
CHANGED
|
@@ -48,10 +48,14 @@ function readIssues(file) {
|
|
|
48
48
|
|
|
49
49
|
// D3: a commit condition holds when a `refs/remotes/<remote>/` ref contains it.
|
|
50
50
|
function conditionHolds(where, condition, issues) {
|
|
51
|
-
const commit =
|
|
51
|
+
const commit = store.parseCommitCondition(condition);
|
|
52
52
|
if (commit) {
|
|
53
|
-
if (git(where.worktree, ["cat-file", "-e", `${commit
|
|
54
|
-
|
|
53
|
+
if (git(where.worktree, ["cat-file", "-e", `${commit.sha}^{commit}`]) === null) return { holds: false };
|
|
54
|
+
// A named branch holds only when it contains the commit (#477 D1, D3).
|
|
55
|
+
if (commit.refs) {
|
|
56
|
+
return { holds: commit.refs.some((ref) => git(where.worktree, ["merge-base", "--is-ancestor", commit.sha, `refs/remotes/${ref.remote}/${ref.branch}`]) !== null) };
|
|
57
|
+
}
|
|
58
|
+
const refs = git(where.worktree, ["for-each-ref", "--contains", commit.sha, "--format=%(refname)", `refs/remotes/${commit.remote}/`]);
|
|
55
59
|
return { holds: Boolean(refs) };
|
|
56
60
|
}
|
|
57
61
|
const issue = condition.match(/^issue #(\d+) closed$/);
|
|
@@ -101,7 +105,7 @@ function patrol(where, role, options) {
|
|
|
101
105
|
store.markMet(where, waitRecord, role);
|
|
102
106
|
result.held.push({ id: waitRecord.id, from: waitRecord.from, condition: waitRecord.condition });
|
|
103
107
|
if (waitRecord.from !== role) {
|
|
104
|
-
const text = `Condition met: ${waitRecord.condition} (wait ${waitRecord.id}${waitRecord.text ? `: ${waitRecord.text}` : ""}).`;
|
|
108
|
+
const text = `Condition met: ${store.describeCondition(waitRecord.condition)} (wait ${waitRecord.id}${waitRecord.text ? `: ${waitRecord.text}` : ""}).`;
|
|
105
109
|
const posted = store.directPost(where, waitRecord.from, text, { refs: [`wait:${waitRecord.id}`] });
|
|
106
110
|
result.notices.push({ to: waitRecord.from, id: posted.id, text });
|
|
107
111
|
}
|