@caddis/cli 0.4.106 → 0.4.108

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "caddis",
3
- "version": "1.3.190",
3
+ "version": "1.3.192",
4
4
  "description": "caddis — agent-agnostic dev harness as an Antigravity (agy) plugin: TDD skills + commands, single-sourced with the Claude Code plugin."
5
5
  }
@@ -17,6 +17,7 @@ through a `subprocess.run`-shaped seam and orca through a `Popen`-shaped one; ne
17
17
  """
18
18
  from __future__ import annotations
19
19
 
20
+ import contextlib
20
21
  import json
21
22
  import os
22
23
  import shutil
@@ -582,36 +583,39 @@ def _start_sweep(argv: list[str], log: Path) -> None:
582
583
  start_new_session=os.name != "nt", close_fds=True)
583
584
 
584
585
 
585
- def _claim_stamp(stamp: Path, now: float) -> bool:
586
- """True when this process won the sweep for this window. Two sessions that start at once: exactly one wins.
586
+ def _claim_stamp(folder: Path, now: float) -> Path | None:
587
+ """The claim file when this process won the sweep for this window, else None. Two sessions at once: one wins.
587
588
 
588
- The stamp is created with O_EXCL. An existing stamp inside the window means no. An expired one is moved aside
589
- with one rename (only one racer's rename succeeds), then created again with O_EXCL. An empty stamp (a racer
590
- has not written the time yet, or was killed before it did) dates from its modified time, so it expires too.
589
+ Each claim is a numbered file in `folder` that holds the claim time. The newest claim inside the window means
590
+ no. When it has expired, the next number is created with O_EXCL: only one racer can create it. No step moves or
591
+ deletes a claim that another racer may still be reading, so a racer that read an expired claim cannot remove a
592
+ fresh one. An empty claim (a racer has not written the time yet, or was killed before it did) dates from its
593
+ modified time, so it expires too. Claims older than the previous one are deleted; the previous one stays, so a
594
+ slow racer that read it fails its O_EXCL on ours.
591
595
  """
592
- for _ in range(2):
596
+ numbers = sorted((int(p.name) for p in folder.iterdir() if p.name.isascii() and p.name.isdigit()), reverse=True)
597
+ newest = numbers[0] if numbers else 0
598
+ if numbers:
593
599
  try:
594
- fd = os.open(stamp, os.O_CREAT | os.O_EXCL | os.O_WRONLY)
595
- except FileExistsError:
596
- try:
597
- text = stamp.read_text(encoding="utf-8").strip()
598
- last = float(text) if text else stamp.stat().st_mtime
599
- except ValueError:
600
- last = 0.0 # unreadable: treat as expired
601
- except OSError:
602
- return False
603
- if 0 <= now - last < ORCA_SWEEP_EVERY_S:
604
- return False
605
- try:
606
- stamp.rename(stamp.with_name(f"{stamp.name}.{os.getpid()}.old"))
607
- except OSError:
608
- return False # another racer moved it first
609
- stamp.with_name(f"{stamp.name}.{os.getpid()}.old").unlink(missing_ok=True)
610
- continue
611
- with os.fdopen(fd, "w", encoding="utf-8") as fh:
612
- fh.write(str(int(now)))
613
- return True
614
- return False
600
+ text = (folder / str(newest)).read_text(encoding="utf-8").strip()
601
+ last = float(text) if text else (folder / str(newest)).stat().st_mtime
602
+ except ValueError:
603
+ last = 0.0 # unreadable: treat as expired
604
+ except OSError:
605
+ return None
606
+ if 0 <= now - last < ORCA_SWEEP_EVERY_S:
607
+ return None
608
+ claim = folder / str(newest + 1)
609
+ try:
610
+ fd = os.open(claim, os.O_CREAT | os.O_EXCL | os.O_WRONLY)
611
+ except OSError:
612
+ return None # another racer created this claim first
613
+ with os.fdopen(fd, "w", encoding="utf-8") as fh:
614
+ fh.write(str(int(now)))
615
+ for old in numbers[1:]:
616
+ with contextlib.suppress(OSError):
617
+ (folder / str(old)).unlink(missing_ok=True)
618
+ return claim
615
619
 
616
620
 
617
621
  def orca_sweep(main: Path, orca_linked: int, env: Mapping[str, str], home: Path, now: float,
@@ -627,10 +631,13 @@ def orca_sweep(main: Path, orca_linked: int, env: Mapping[str, str], home: Path,
627
631
  if not tidy.is_file():
628
632
  return None
629
633
  stamps = home / ".caddis" / "orca-sweep"
630
- stamp = stamps / (_key(main).replace(":", "").replace("\\", "-").replace("/", "-").strip("-") + ".stamp")
634
+ folder = stamps / _key(main).replace(":", "").replace("\\", "-").replace("/", "-").strip("-")
635
+ with contextlib.suppress(OSError):
636
+ folder.with_name(folder.name + ".stamp").unlink(missing_ok=True) # the one-file stamp of caddis <= 1.3.190
631
637
  try:
632
- stamps.mkdir(parents=True, exist_ok=True)
633
- if not _claim_stamp(stamp, now):
638
+ folder.mkdir(parents=True, exist_ok=True)
639
+ stamp = _claim_stamp(folder, now)
640
+ if stamp is None:
634
641
  return None
635
642
  log = home / ".caddis" / "logs" / "orca-sweep.log"
636
643
  log.parent.mkdir(parents=True, exist_ok=True)
@@ -506,9 +506,10 @@ def remove_finished(path: Path | None, facts: dict, remover: Callable | None = N
506
506
  landed = {pr_head, head.lower()} - {""} # only tips this proof showed landed
507
507
  if path is not None and branches_first:
508
508
  if branch: # update-ref detaches without running a post-checkout hook (git switch would run it)
509
- detach = _git(path, "update-ref", "--no-deref", "HEAD", head)
509
+ # The old value makes it compare-and-swap: a HEAD that moved after the proof is left as it is.
510
+ detach = _git(path, "update-ref", "--no-deref", "HEAD", head, head)
510
511
  if detach.returncode != 0:
511
- return "FAILED", f"git update-ref --no-deref HEAD failed: {_err(detach)}"
512
+ return "FAILED", f"HEAD moved after the proof, or git update-ref failed: {_err(detach)}"
512
513
  notes = _delete_branches(repo, branch, landed)
513
514
  problem = safety.safe_remove_worktree(repo, path, force=False, env=_env(), remover=remover)
514
515
  if problem:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
- "version": "1.3.189",
4
- "generated": "2026-11-11 23:11 UTC",
3
+ "version": "1.3.191",
4
+ "generated": "2026-11-12 01:33 UTC",
5
5
  "commands": [
6
6
  {
7
7
  "name": "add-rules",
@@ -1,7 +1,7 @@
1
1
  {
2
- "poolVersion": "1.3.190",
2
+ "poolVersion": "1.3.192",
3
3
  "bundles": {
4
- "antigravity-plugin": "1.3.190",
4
+ "antigravity-plugin": "1.3.192",
5
5
  "antigravity-plugin-extras": "1.3.52",
6
6
  "codex": "unknown"
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caddis/cli",
3
- "version": "0.4.106",
3
+ "version": "0.4.108",
4
4
  "description": "Install, update and diagnose the caddis dev harness across every coding agent you use (Claude Code, agy/Antigravity, and more).",
5
5
  "keywords": [
6
6
  "caddis",