workers down --until takes a date or an ISO date-time on every Python version (Z, offsets); tested at one minute either side. done / next: fix 5 (inferred age)

This commit is contained in:
swaits committed 2026-11-23 13:05:09 -07:00
1 parent e34dabfdb0
commit 8100295f98
3 files changed
+49 -4

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@ LONG = {
'status': ' sisi status [--json] [--learning] recent units with their scorecards, then trends by project, risk profile, model and policy version (median and p95; no single score)',
'verifiers': ' sisi verifiers [WORDS] [--lang L] [--kind K] [--rung N] [--section S] [--installed] [--json]\n list ways to know work is correct, by section\n sisi verifiers show ID [--trace] one entry in full, and whether its tool is installed here; --trace also prints where each folded lesson lives in it\n sisi verifiers for "<claim>" best-matching verifiers for a claim or piece of work\n sisi verifiers doctor | lint which tools are installed; validate the library',
'done': ' sisi done [ID] [--trace] recipes: which checks make a kind of work done; --trace also prints where each folded lesson lives in the recipe\n sisi done for "<work>" best-matching recipe',
'workers': ' sisi workers [--refresh] the agent tools and models found here, what is usable now and why not, allowance and price where known, delegations waiting for a judgement, and the judged record as three tables\n sisi workers fact W --price N|--score N --source S record a price (per million tokens) or benchmark standing (0-100), with its source and date\n sisi workers avoid|prefer PATTERN --why TEXT your own routing constraints, honoured by `sisi route`\n sisi workers only PROVIDER PATTERN... --why TEXT | --remove make only the matching models of that provider routable\n sisi workers note PATTERN \"TEXT\" --why SOURCE | --remove a standing fact about workers matching PATTERN, shown with route results\n sisi workers down W --reason limit|auth|missing|error [--until DATE] | up W mark a worker unavailable / available again\n sisi workers import FILE merge another ledger file into the delegation ledger (row counts printed; safe to repeat)',
'workers': ' sisi workers [--refresh] the agent tools and models found here, what is usable now and why not, allowance and price where known, delegations waiting for a judgement, and the judged record as three tables\n sisi workers fact W --price N|--score N --source S record a price (per million tokens) or benchmark standing (0-100), with its source and date\n sisi workers avoid|prefer PATTERN --why TEXT your own routing constraints, honoured by `sisi route`\n sisi workers only PROVIDER PATTERN... --why TEXT | --remove make only the matching models of that provider routable\n sisi workers note PATTERN \"TEXT\" --why SOURCE | --remove a standing fact about workers matching PATTERN, shown with route results\n sisi workers down W --reason limit|auth|missing|error [--until DATE|TIME] | up W mark a worker unavailable / available again\n sisi workers import FILE merge another ledger file into the delegation ledger (row counts printed; safe to repeat)',
'route': ' sisi route --kind K --difficulty N [--review-of W] [--explain]\n the most affordable usable worker for this kind and difficulty, and the mechanism to start it with (host subagents, host cross-provider delegation, or sisi delegate); --explain says why',
'delegate': ' sisi delegate brief | check FILE | guide the delegation-contract template (eight parts); which parts a brief lacks; the orchestration playbook\n sisi delegate --kind K --difficulty N --brief FILE [--worker W] [--review-of W] [--cwd DIR]\n run one brief on the chosen worker unattended; prints only its final report, the transcript path, and the judge command; a brief without outcome, acceptance or files it may change is refused\n sisi delegate judge ID --outcome accepted|rejected --check none|diffstat|tests|read|review [--minutes N]\n record your judgement of a delegation run, so the next choice learns from it; judge work run any other way with --worker W --type K --difficulty N instead of ID\n sisi delegate amend ID | recent [-n N] [--project P] mark a judged delegation that later proved wrong; list recent judgements to find an id',
'eval': ' sisi eval list|add|run|compare|shadow|judge|status|import\n the evaluation harness: benchmark cases from real work, isolated\n replay, policy comparison and independent judging (see docs/evaluation.md);\n `sisi eval` alone prints status; run without --tasks replays check cases only',
+9 -3
View File
@@ -383,6 +383,12 @@ def _parse_time(value):
return float(text)
except ValueError:
pass
# a trailing Z (UTC) and a +HHMM offset are accepted on every Python version; a time with no
# zone is read as local time, a bare date as the start of that day
if text[-1:] in ("Z", "z"):
text = text[:-1] + "+00:00"
elif re.search(r"[+-]\d{4}$", text) and "T" in text.upper().replace(" ", "T"):
text = text[:-2] + ":" + text[-2:]
try:
return datetime.datetime.fromisoformat(text).timestamp()
except ValueError:
@@ -1737,17 +1743,17 @@ def _cmd_brief_check(args):
def _cmd_down(args):
if not args:
print("usage: sisi workers down WORKER --reason limit|auth|missing|error [--until DATE] [--note TEXT]")
print("usage: sisi workers down WORKER --reason limit|auth|missing|error [--until DATE|DATETIME] [--note TEXT]")
return 1
worker = str(args[0]).strip().lower().rstrip("/")
reason = _opt(args, "--reason")
if reason not in REASONS:
print("usage: sisi workers down WORKER --reason limit|auth|missing|error [--until DATE] [--note TEXT]")
print("usage: sisi workers down WORKER --reason limit|auth|missing|error [--until DATE|DATETIME] [--note TEXT]")
return 1
until = _opt(args, "--until")
until_ts = _parse_time(until) if until is not None else None
if until is not None and until_ts is None:
print("sisi: --until wants a date like 2026-12-01 or 2026-12-01T09:00", file=sys.stderr)
print("sisi: --until wants a date like 2026-12-01 or a time like 2026-12-01T09:00 (add Z or an offset such as +02:00 for a zone)", file=sys.stderr)
return 1
note = _opt(args, "--note")
record_down([worker], reason, note, until_ts=until_ts)
+39
View File
@@ -78,6 +78,45 @@ class HostNativeTests(RouteCase):
self.assertNotIn("wk-", r.stdout.splitlines()[0])
class DownUntilATimeTests(RouteCase):
def stamp(self, delta_s, offset_hours=None):
import datetime
t = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(seconds=delta_s)
if offset_hours is None:
return t.strftime("%Y-%m-%dT%H:%M:%SZ")
tz = datetime.timezone(datetime.timedelta(hours=offset_hours))
return t.astimezone(tz).isoformat(timespec="seconds")
def first_line(self):
r = self.sisi("route", "--kind", "impl", "--difficulty", "2", env=self.env())
return r.stdout.splitlines()[0] if r.stdout else ""
def test_down_until_a_time_is_due_at_that_time(self):
"""A limit that resets at a known time today: a mark until a minute ago is usable, one until a
minute ahead is not (UTC `Z` or an offset), a date alone still works."""
self.seed([("wk-fast", 300, 290), ("wk-mid", 120, 100)])
for until in (self.stamp(-60), self.stamp(-60, 5), self.stamp(-60, -7)):
r = self.sisi("workers", "down", "wk-fast", "--reason", "limit", "--until", until, env=self.env())
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
self.assertEqual(self.first_line(), "wk-fast", until)
for until in (self.stamp(60), self.stamp(60, 5), self.stamp(60, -7)):
r = self.sisi("workers", "down", "wk-fast", "--reason", "limit", "--until", until, env=self.env())
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
self.assertEqual(self.first_line(), "wk-mid", until)
self.sisi("workers", "up", "wk-fast", env=self.env())
self.sisi("workers", "down", "wk-fast", "--reason", "limit", "--until", "2099-01-02", env=self.env())
self.assertEqual(self.first_line(), "wk-mid")
bad = self.sisi("workers", "down", "wk-fast", "--reason", "limit", "--until", "tomorrow-ish", env=self.env())
self.assertEqual(bad.returncode, 1)
def test_the_time_parser_does_not_depend_on_the_python_version(self):
from sisi import workers
a = workers._parse_time("2026-12-01T09:00:00Z")
self.assertEqual(a, workers._parse_time("2026-12-01T11:00:00+02:00"))
self.assertEqual(a, workers._parse_time("2026-12-01T09:00:00+00:00"))
self.assertEqual(a, workers._parse_time("2026-12-01T09:00:00z"))
class DownProvidersTests(RouteCase):
def test_host_worker_recommended_while_providers_are_down(self):
"""R-7.2-1, R-7.2-3, R-17-5: every provider down, a record exists: route still names the best