@caddis/cli 0.4.106 → 0.4.107
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/bundles/antigravity-plugin/plugin.json +1 -1
- package/bundles/antigravity-plugin/repo_hygiene.py +37 -30
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_status.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/caddis_guide.json +2 -2
- package/bundles/manifest.json +2 -2
- package/package.json +1 -1
|
@@ -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(
|
|
586
|
-
"""
|
|
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
|
-
|
|
589
|
-
|
|
590
|
-
|
|
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
|
|
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
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
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
|
-
|
|
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
|
-
|
|
633
|
-
|
|
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)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc
CHANGED
|
Binary file
|
package/bundles/manifest.json
CHANGED
package/package.json
CHANGED