Compare commits
21
Commits
f849609afb
...
a63134ee6e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a63134ee6e | ||
|
|
60e7dea44f | ||
|
|
2485fbf352 | ||
|
|
4810a03fde | ||
|
|
ed189976f8 | ||
|
|
8f679dbba0 | ||
|
|
9f442c4ddc | ||
|
|
0ed7df1155 | ||
|
|
6f5b1aa3ca | ||
|
|
73434306c8 | ||
|
|
6d77c91b5b | ||
|
|
d7c0b40197 | ||
|
|
055810f20f | ||
|
|
acdfa210cb | ||
|
|
6b0602ad17 | ||
|
|
54d122961f | ||
|
|
54312e6154 | ||
|
|
5b28ba1a8c | ||
|
|
72262a83d7 | ||
|
|
848560a975 | ||
|
|
bf6f67f0ff |
No files matched your search
+43
-38
@@ -56,35 +56,37 @@ something that did not run read as passed.
|
||||
|
||||
## 4. Deliver fast
|
||||
|
||||
Time to a first useful result and time to a verified finish are both part of success. Work in
|
||||
parallel, run the quickest check first and slow ones in the background, and hand over a useful
|
||||
part as soon as it stands on its own. Release each piece the moment its checks pass, with a way
|
||||
back; reviews and later builds run beside or after a release, never in front of it. Make the smallest piece that can be released on its own the first check in `sisi done`, and release it before any other build or review starts. Do not chain
|
||||
single workers one after another. Long builds running at once each get their own checkout and
|
||||
branch, merged as each passes. When something has taken out of proportion to its
|
||||
progress, stop and change approach: narrow it, use another worker, or ask. Never buy speed with
|
||||
a weaker check.
|
||||
Time to a first useful result and time to a verified finish are both part of success. Work in parallel,
|
||||
run the quickest check first and slow ones in the background, and hand over a useful part as soon as it
|
||||
stands on its own. Release each piece the moment its checks pass, with a way back; reviews and later
|
||||
builds run beside or after a release, never in front of it. Make the smallest piece that can be released
|
||||
on its own the first check in `sisi done`, and release it before any other build or review starts. Do
|
||||
not chain single workers one after another; merge each branch as it passes. When something has taken out
|
||||
of proportion to its progress, stop and change approach: narrow it, use another worker, or ask. Never
|
||||
buy speed with a weaker check.
|
||||
|
||||
## 5. Delegate everything (lead only)
|
||||
|
||||
You own the outcome; workers do the work. Delegate reading, searching, building, testing,
|
||||
research and first reviews, and keep your own context for intent, design, judgement and the
|
||||
final call. Do something yourself only when briefing it would cost more than doing it.
|
||||
`sisi models` lists the workers you have. Decide the class of the task (routine, ordinary, hard),
|
||||
counting rework as cost, then `sisi pick CLASS` spins the wheel over the workers of that class and
|
||||
gives you one: use it. A class holds models of like strength from different makers; the wheel never mixes classes. A review always goes to a different maker than the author:
|
||||
`sisi pick CLASS --review-of WORKER`. Start the worker with the host's own delegation tool; do not
|
||||
shell out to a worker's command line. Run
|
||||
independent work in parallel. Brief a worker as a peer who starts cold: the outcome, what is
|
||||
known and ruled out, what done looks like, the files it may change, what it may create. Decide
|
||||
the central mechanism in the brief, set against the person's standing rules on its subject, and say what a failed or
|
||||
gamed job does to each number it optimizes. For a reported fault, the report's exact inputs are an acceptance test. For a
|
||||
replacement, list each behaviour of the old thing as keep, change or drop, with a check for every
|
||||
keep. Always use the newest version of a model within its maker and class. Its report is evidence for
|
||||
you to judge, not a fact to pass on; record how it went with `sisi judge`. When a worker fails
|
||||
for a limit, a login or a connection, give the same brief to the next one at once: do not ask
|
||||
the person and do not report it. When session start says the models table is old, start a
|
||||
research worker in the background to rebuild it.
|
||||
You own the outcome; workers do the work. Delegate reading, searching, building, testing, research and
|
||||
first reviews, and keep your own context for intent, design, judgement and the final call. Do something
|
||||
yourself only when briefing it would cost more than doing it. `sisi models` lists the workers you have.
|
||||
Decide the class of the task (routine, ordinary, hard), counting rework as cost, then `sisi pick CLASS`
|
||||
spins the wheel over the workers of that class and gives you one: use it. A class holds models of like
|
||||
strength from different makers; the wheel never mixes classes. A review always goes to a different maker
|
||||
than the author: `sisi pick CLASS --review-of WORKER`. Start the worker with the host's own delegation
|
||||
tool; do not shell out to a worker's command line. Run independent work in parallel. Brief a worker as a
|
||||
peer who starts cold: the outcome, what is known and ruled out, what done looks like, the files it may
|
||||
change, what it may create, and a time limit (`sisi pick CLASS --limit MINUTES [--branch NAME]`). At the
|
||||
limit it stops and reports as it stands: what is proven, what failed, what did not run. Extending is the
|
||||
lead's call, made once, with a reason (`sisi judge WORKER extend MINUTES "<reason>"`). Decide the
|
||||
central mechanism in the brief, set against the person's standing rules on its subject, and say what a
|
||||
failed or gamed job does to each number it optimizes. For a reported fault, the report's exact inputs
|
||||
are an acceptance test. For a replacement, list each behaviour of the old thing as keep, change or drop,
|
||||
with a check for every keep. Always use the newest version of a model within its maker and class. Its
|
||||
report is evidence for you to judge, not a fact to pass on; record how it went with `sisi judge`. When a
|
||||
worker fails for a limit, a login or a connection, give the same brief to the next one at once: do not
|
||||
ask the person and do not report it. When session start says the models table is old, start a research
|
||||
worker in the background to rebuild it.
|
||||
|
||||
## 6. Report plainly
|
||||
|
||||
@@ -117,15 +119,18 @@ rules need organizing, have a cheap worker do it in the background.
|
||||
|
||||
## 9. Fix what you see
|
||||
|
||||
A fault you see is yours, whether or not the request covers it: a crash, a failed run, a full
|
||||
disk, a slow build, a wrong result, a mess. In the turn you see it, start its fix, or name what
|
||||
blocks the fix and what would unblock it. Noting it, reporting it or working around it is not a
|
||||
fix. Fix the cause, not the symptom: ask why it happened, what else the same cause breaks, and
|
||||
whether your own work fed it. What your work makes is yours to clear once no running job uses
|
||||
it: copies, checkouts, branches, build output, background jobs. Before work that makes copies,
|
||||
checkouts or builds, know how much room they take, share one build folder between checkouts where
|
||||
the tool allows, and never start more than the machine has room for. A brief names what its
|
||||
worker may create; remove it when the piece merges, without asking. Record it with `sisi fault
|
||||
"<what is wrong>"`. Where the tool has hooks, sisi shows open faults at every request and sends
|
||||
you back twice before a turn ends on one with no fix started and no blocker named. A worker fixes
|
||||
what its brief covers and reports the rest. Never wait to be told.
|
||||
A fault you see is yours, whether or not the request covers it: a crash, a failed run, a full disk, a
|
||||
slow build, a wrong result, a mess. In the turn you see it, start its fix, or name what blocks the fix
|
||||
and what would unblock it. Noting it, reporting it or working around it is not a fix. Fix the cause, not
|
||||
the symptom: ask why it happened, what else the same cause breaks, and whether your own work fed it.
|
||||
What your work makes is yours to clear once no running job uses it: copies, checkouts, branches, build
|
||||
output, background jobs. Each worker that builds gets its own checkout and build folder, and workers
|
||||
build at the same time: never make them take turns on one lock or share a build folder unless the build
|
||||
tool is known to be safe with that. Measure what each piece needs and what the machine has free (CPU,
|
||||
memory, disk per checkout and build folder) and set how many build at once from that: never one unless a
|
||||
measurement says so. A brief names what its worker may create; remove it when the piece merges or is
|
||||
dropped, without asking. Cleaning up is the answer to disk use, not fewer workers. Record a fault with
|
||||
`sisi fault "<what is wrong>"`; for a resource fault name the measured cause there first, and never cut
|
||||
parallelism unless a measurement shows parallelism caused it. Where the tool has hooks, sisi shows open
|
||||
faults at every request and sends you back twice before a turn ends on one with no fix started and no
|
||||
blocker named. A worker fixes what its brief covers and reports the rest. Never wait to be told.
|
||||
+3
-2
@@ -27,9 +27,10 @@ Delegation
|
||||
sisi models the workers you have: what each is good at and what it costs
|
||||
sisi models research [--record FILE]
|
||||
the brief for a research worker to rebuild that table; record its answer
|
||||
sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...]
|
||||
sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...] [--limit MINUTES] [--branch NAME]
|
||||
the wheel gives you one worker of that class; one pick, one delegation
|
||||
sisi judge WORKER good|bad WHY how a delegation went
|
||||
sisi judge WORKER good|bad WHY | extend MINUTES WHY [--newest]
|
||||
how a delegation went, or give a running job more time
|
||||
sisi direct REASON allow yourself more direct tool calls this turn, with the reason
|
||||
|
||||
Setting up
|
||||
|
||||
@@ -44,6 +44,8 @@ def add(cwd, text, kind="", flag="", fid=0):
|
||||
hit = next((f for f in doc["items"] if f["id"] == fid), None)
|
||||
if not hit:
|
||||
return None
|
||||
if hit.get("kind", "").startswith("late:"):
|
||||
raise OSError('sisi fault: #%d is a late worker fault; run `sisi judge WORKER good|bad "<why>"` or `sisi judge WORKER extend MINUTES "<reason>"`.' % fid)
|
||||
doc["items"] = [f for f in doc["items"] if f["id"] != fid] if flag == "--fixed" else doc["items"]
|
||||
hit.update(state=flag[2:], note=text)
|
||||
elif kind and any(f.get("kind") == kind for f in doc["items"]):
|
||||
@@ -58,6 +60,13 @@ def add(cwd, text, kind="", flag="", fid=0):
|
||||
store.write(p, out)
|
||||
return hit
|
||||
|
||||
def clear(cwd, prefix, keep=()):
|
||||
if os.path.lexists(p := _path(cwd)):
|
||||
with store.lock(p):
|
||||
doc, err = _load(p)
|
||||
if not err and len(items := [f for f in doc["items"] if not (f.get("kind", "").startswith(prefix) and f.get("kind") not in keep)]) != len(doc["items"]):
|
||||
store.write(p, json.dumps({"next": doc["next"], "items": items}))
|
||||
|
||||
def _checkouts(cwd):
|
||||
try:
|
||||
cur = os.path.abspath(cwd)
|
||||
|
||||
+14
-3
@@ -124,20 +124,30 @@ def tick(p):
|
||||
return 0
|
||||
|
||||
|
||||
def _late_lines(late1, cwd):
|
||||
now, cfg_m = time.time(), store.config()["worker_minutes"]
|
||||
def prog(branch, ext):
|
||||
rc, out = store.git(["log", "-1", "--format=%ct", branch], cwd, timeout=2) if branch else (1, "")
|
||||
return "commit %dm ago on %s" % (max(0, int((now - int(out.strip())) / 60)), branch) if rc == 0 and out.strip().isdigit() else "extended %dm ago" % max(0, int((now - ext) / 60)) if ext is not None else "no report since it started"
|
||||
return ["sisi: worker %s has run %dm (limit %gm); last progress: %s" % (w, int((now - t) / 60), lim if lim is not None else cfg_m, prog(b, e)) for w, t, lim, b, e in late1]
|
||||
|
||||
|
||||
def prompt(p):
|
||||
"""Each request: a new turn begins. The first request tells a delegated worker from a lead."""
|
||||
sid, cwd, worker, free = p["session_id"], p["cwd"] or os.getcwd(), p["subagent"], None
|
||||
sid, cwd, worker, free, late1 = p["session_id"], p["cwd"] or os.getcwd(), p["subagent"], None, []
|
||||
if sid:
|
||||
with store.session(sid) as s:
|
||||
_begin(s, cwd)
|
||||
if not s.get("prompts") and WORKER.search(p["prompt"][:2000]):
|
||||
s["worker"] = True
|
||||
worker, free = worker or bool(s.get("worker")), s.get("free_bytes")
|
||||
worker or not p["prompt"].strip() or s.update(said=(s.get("said", []) + [" ".join(p["prompt"].split())[:8000]])[-20:]) # the person's own words
|
||||
s["prompts"] = s.get("prompts", 0) + 1
|
||||
s.get("prompts_since") or s.update(began=time.time()) # the first request of a piece of work
|
||||
s["prompts_since"] = s.get("prompts_since", 0) + 1
|
||||
s["direct"], s["extra"], s["blocks"] = 0, 0, 0
|
||||
not worker and (text := _faults(cwd, False, free)) and print(text)
|
||||
not worker and (models.sync_late(s, cwd, sid), late1 := models.late(s, 1))
|
||||
not worker and (text := "\n".join(x for x in [_faults(cwd, False, free)] + _late_lines(late1, cwd) if x)) and print(text)
|
||||
return 0
|
||||
|
||||
|
||||
@@ -207,10 +217,11 @@ def gate(p, for_subagent=False):
|
||||
_begin(s, cwd)
|
||||
if s.get("worker"):
|
||||
return 0
|
||||
models.sync_late(s, cwd, sid)
|
||||
open_f, starts = _faults(cwd, True), s["starts"] if isinstance(s.get("starts"), dict) else {}
|
||||
seen = [x for x in (s["reminded"] if isinstance(s.get("reminded"), list) else [])
|
||||
if isinstance(x, list) and len(x) == 2 and x[1] in (starts.get(x[0]) if isinstance(starts.get(x[0]), list) else ())]
|
||||
late = models.overdue({"starts": {w: [t for t in v if [w, t] not in seen] for w, v in starts.items() if isinstance(v, list)}})
|
||||
late = models.overdue({"starts": {w: [t for t in v if [w, t] not in seen] for w, v in starts.items() if isinstance(v, list)}, "meta": s.get("meta")})
|
||||
reason, demand = " ".join("sisi: " + LATE % (w, time.strftime("%H:%M", time.localtime(t))) for w, t in late), False
|
||||
if not reason and not s.get("paused"):
|
||||
checks = (s.get("done") or {}).get("checks") or []
|
||||
|
||||
+65
-28
@@ -162,19 +162,36 @@ def claim(s, text, segment=False):
|
||||
if any(re.search(r"(?<![a-z0-9.-])%s(?![a-z0-9.-])" % re.escape(n), text.lower()) for n in (name, name.rsplit("/", 1)[-1])) or (
|
||||
segment and re.search("[a-z]", text.lower()) and text.lower() in name.rsplit("/", 1)[-1].split("-")):
|
||||
s["picked"].remove(name)
|
||||
starts = s["starts"] if isinstance(s.get("starts"), dict) else {}
|
||||
starts[name] = (starts[name] if isinstance(starts.get(name), list) else []) + [time.time()]
|
||||
t, starts = time.time(), (s["starts"] if isinstance(s.get("starts"), dict) else {})
|
||||
starts[name] = (starts[name] if isinstance(starts.get(name), list) else []) + [t]
|
||||
s["starts"] = starts # `sisi judge` times the job from here
|
||||
if isinstance(s.get("pending"), dict) and isinstance(meta := s["pending"].pop(name, None), dict):
|
||||
s["meta"] = {**(s["meta"] if isinstance(s.get("meta"), dict) else {}), "%s %r" % (name, t): meta}
|
||||
s.setdefault("workers_since", []).append(name)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def late(s, factor=1):
|
||||
"""Open jobs whose age >= factor * threshold: [(worker, start, limit, branch, extended)]."""
|
||||
now, default_m, starts, meta, out = time.time(), store.config()["worker_minutes"], s.get("starts"), s.get("meta"), []
|
||||
num = lambda x: type(x) in (int, float) and math.isfinite(x)
|
||||
for w, v in (starts.items() if isinstance(starts, dict) else ()):
|
||||
for t in (v if isinstance(v, list) else ()):
|
||||
m = meta.get("%s %r" % (w, t)) if num(t) and t <= now and isinstance(meta, dict) else {}
|
||||
m = m if isinstance(m, dict) else {}
|
||||
lim = m.get("limit") if num(m.get("limit")) and m["limit"] > 0 else None
|
||||
th = lim if lim is not None else default_m
|
||||
if num(t) and t <= now and num(th) and now - t >= 60 * factor * th:
|
||||
out.append((w, t, lim, m.get("branch") if isinstance(m.get("branch"), str) and m["branch"] else None, m.get("extended") if num(m.get("extended")) else None))
|
||||
return out
|
||||
|
||||
|
||||
def overdue(s):
|
||||
"""Open delegations older than `worker_minutes`: [(worker, its oldest such start)]. A bad or future start is none."""
|
||||
mins, starts = store.config()["worker_minutes"], s.get("starts")
|
||||
old = lambda v: [t for t in v if type(t) in (int, float) and math.isfinite(t) and t <= time.time() - 60 * mins] if isinstance(v, list) else []
|
||||
return [(w, min(old(v))) for w, v in (starts.items() if isinstance(starts, dict) and type(mins) in (int, float) else []) if old(v)]
|
||||
"""Open delegations older than their threshold: [(worker, its oldest such start)]."""
|
||||
by_w, l = {}, late(s, 1)
|
||||
[by_w.setdefault(w, min(t for w2, t, *_ in l if w2 == w)) for w, *_ in l]
|
||||
return list(by_w.items())
|
||||
|
||||
|
||||
def waiting(s):
|
||||
@@ -226,18 +243,17 @@ def choose(text, cls, skip=(), review=None, rand=None, today=None, speed=None):
|
||||
|
||||
|
||||
def pick(args, cwd=None, rand=None):
|
||||
"""`sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...]`: the wheel gives one worker."""
|
||||
cls, skip, review, i = (args[0] if args and args[0] in ("routine", "ordinary", "hard") else None), set(), None, 1
|
||||
"""`sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...] [--limit MINUTES] [--branch NAME]`: the wheel gives one worker."""
|
||||
cls, skip, review, limit, branch, i = (args[0] if args and args[0] in ("routine", "ordinary", "hard") else None), set(), None, None, None, 1
|
||||
while cls and i < len(args):
|
||||
if args[i] == "--not" and i + 1 < len(args):
|
||||
skip.add(short(args[i + 1]))
|
||||
elif args[i] == "--review-of" and i + 1 < len(args):
|
||||
review = args[i + 1]
|
||||
else:
|
||||
cls = None
|
||||
if args[i] == "--not" and i + 1 < len(args): skip.add(short(args[i + 1]))
|
||||
elif args[i] == "--review-of" and i + 1 < len(args): review = args[i + 1]
|
||||
elif args[i] == "--limit" and i + 1 < len(args) and re.fullmatch(r"[1-9]\d{0,3}|10000", args[i + 1]): limit = int(args[i + 1])
|
||||
elif args[i] == "--branch" and i + 1 < len(args) and re.fullmatch(r"[A-Za-z0-9._/-]{1,100}", args[i + 1]) and not args[i + 1].startswith("-"): branch = args[i + 1]
|
||||
else: cls = None
|
||||
i += 2
|
||||
if not cls:
|
||||
print("usage: sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...]")
|
||||
print("usage: sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...] [--limit MINUTES] [--branch NAME]")
|
||||
return 1
|
||||
text = store.read(table())
|
||||
mine = [r for r in rows(text) if r[2].strip().lower() == cls]
|
||||
@@ -259,7 +275,8 @@ def pick(args, cwd=None, rand=None):
|
||||
sid = store.current_session(cwd)
|
||||
if sid:
|
||||
with store.session(sid) as s:
|
||||
s.setdefault("picked", []).append(short(r[0]))
|
||||
s.setdefault("picked", []).append(w := short(r[0]))
|
||||
if limit is not None or branch is not None: s["pending"] = {**(s["pending"] if isinstance(s.get("pending"), dict) else {}), w: {"limit": limit, "branch": branch}}
|
||||
print("worker: %s (model id: %s)\nstart it with the host's delegation tool; one pick buys one delegation" % (r[0], short(r[0])))
|
||||
if store.config()["shell_workers"] or not command(r):
|
||||
print("how to call it: " + r[1])
|
||||
@@ -315,31 +332,51 @@ def research_record(answer_file):
|
||||
return None
|
||||
|
||||
|
||||
def sync_late(s, cwd, sid, add=True):
|
||||
if not (late2 := late(s, 2)) and not os.path.lexists(os.path.join(store.STATE, "core-faults", store.project_key(cwd) + ".json")): return
|
||||
from . import faults
|
||||
prefix, now, cfg_m = "late:%s:" % sid[:8], time.time(), store.config()["worker_minutes"]
|
||||
want = {"%s%s@%d" % (prefix, w, int(t)): 'worker %s has run %dm (past 2x %gm limit). Judge it (`sisi judge %s good|bad "<why>"`) or extend (`sisi judge %s extend MINUTES "<reason>"`).' % (
|
||||
w, int((now - t) / 60), lim if lim is not None else cfg_m, w, w) for w, t, lim, *_ in late2}
|
||||
try:
|
||||
faults.clear(cwd, prefix, set(want)); add and [faults.add(cwd, text, kind=k) for k, text in want.items()]
|
||||
except OSError: pass
|
||||
|
||||
|
||||
def judge(args, cwd=None):
|
||||
"""`sisi judge WORKER good|bad "<why>" [--minutes N] [--newest]`: how a delegation went, and how long the job took:
|
||||
from the oldest start of this worker's open jobs (the newest with --newest) unless --minutes says."""
|
||||
"""`sisi judge WORKER good|bad "<why>" [--minutes N] [--newest] | extend MINUTES "<why>" [--newest]`."""
|
||||
from . import retro # not at the top: hooks import this module and must stay quick
|
||||
args, newest, minutes, note = [a for a in args if a != "--newest"], "--newest" in args, None, ""
|
||||
if "--minutes" in args:
|
||||
i = args.index("--minutes")
|
||||
v, args = (args[i + 1:i + 2] or [""])[0], args[:i] + args[i + 2:]
|
||||
minutes = int(v) if re.fullmatch(r"[1-9]\d{0,3}|10000", v) else 0
|
||||
if len(args) != 3 or not args[0].strip() or args[1] not in ("good", "bad") or len(args[2].split()) < 3 or minutes == 0:
|
||||
print('usage: sisi judge WORKER good|bad "<what it did well or badly, in a sentence>" [--minutes N] [--newest]')
|
||||
ext = len(args) == 4 and args[1] == "extend" and minutes is None and re.fullmatch(r"[1-9]\d{0,3}|10000", args[2])
|
||||
if not args or not args[0].strip() or not (ext or (len(args) == 3 and args[1] in ("good", "bad") and minutes != 0)) or len(args[-1].split()) < 3:
|
||||
print('usage: sisi judge WORKER good|bad "<what it did well or badly, in a sentence>" [--minutes N] [--newest] | extend MINUTES "<reason, 3+ words>" [--newest]')
|
||||
return 1
|
||||
trows = rows(store.read(table()))
|
||||
hits = [r for r in trows if short(r[0]) == short(args[0])] or [r for r in trows if claim({"picked": [short(r[0])]}, args[0], True)]
|
||||
model = (hits[0][0].split() or [""])[0] if len(hits) == 1 else args[0]
|
||||
sid, now, began = store.current_session(cwd), time.time(), None
|
||||
wkey, sid, now, began = short(model), store.current_session(cwd), time.time(), None
|
||||
if sid:
|
||||
with store.session(sid) as s:
|
||||
starts = s["starts"].get(short(model)) if isinstance(s.get("starts"), dict) else None
|
||||
if isinstance(starts, list) and starts:
|
||||
cand = starts.pop(-1 if newest else 0) # one start per open job, oldest first
|
||||
if type(cand) in (int, float) and math.isfinite(cand) and cand <= now: # else dropped, times nothing
|
||||
began = cand
|
||||
minutes = minutes or max(1, int((now - began) / 60))
|
||||
note = " (job started %s, %d more open for this worker)" % (time.strftime("%H:%M", time.localtime(began)), len(starts))
|
||||
starts = s["starts"].get(wkey) if isinstance(s.get("starts"), dict) else None
|
||||
cand = (starts.pop(-1 if newest else 0) if not ext else starts[-1 if newest else 0]) if isinstance(starts, list) and starts else None
|
||||
ok_t = type(cand) in (int, float) and math.isfinite(cand) and cand <= now
|
||||
if ext:
|
||||
if not ok_t: return print("sisi judge: no open job for %s." % args[0]) or 1
|
||||
lim, m, k = max(0, int((now - cand) / 60)) + int(args[2]), (s["meta"] if isinstance(s.get("meta"), dict) else {}), "%s %r" % (wkey, cand)
|
||||
m[k], s["meta"] = {**(m[k] if isinstance(m.get(k), dict) else {}), "limit": lim, "extended": now, "reason": retro.clean(args[3])}, m
|
||||
isinstance(s.get("reminded"), list) and s.__setitem__("reminded", [x for x in s["reminded"] if x != [wkey, cand]])
|
||||
return sync_late(s, cwd, sid, False) or print("extended %s limit to %d min." % (wkey, lim)) or 0
|
||||
isinstance(s.get("meta"), dict) and s["meta"].pop("%s %r" % (wkey, cand), None)
|
||||
if ok_t:
|
||||
began = cand
|
||||
minutes = minutes or max(1, int((now - began) / 60))
|
||||
note = " (job started %s, %d more open for this worker)" % (time.strftime("%H:%M", time.localtime(began)), len(starts))
|
||||
sync_late(s, cwd, sid, False)
|
||||
elif ext: return print("sisi judge: no open job for %s." % args[0]) or 1
|
||||
iso = lambda t: time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(t))
|
||||
rec = {"ts": iso(now), "ended": iso(now), "worker": args[0], "model": model, "verdict": args[1],
|
||||
"why": retro.clean(args[2]), "project": os.path.basename(store.project_root(cwd)),
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ def record(s, cwd, opt, sid=None):
|
||||
print("sisi: retro saved, but store git commit failed.")
|
||||
s["snapshot"], s["changed"], s["retro_at"] = store.snapshot(cwd), False, now
|
||||
for key in ("prompts_since", "direct_since", "delegations_since", "reasons_since", "workers_since", "done", "paused",
|
||||
"fails_since", "picked", "starts", "retro_demanded", "began"):
|
||||
"fails_since", "picked", "starts", "pending", "meta", "reminded", "retro_demanded", "began"):
|
||||
s.pop(key, None)
|
||||
|
||||
|
||||
|
||||
+42
-8
@@ -10,8 +10,10 @@ USER, PROJECT = "user", "project"
|
||||
OWNER = re.compile(r"\[owner\b[^\]]*\]")
|
||||
_owner, _retro = lambda l: bool(OWNER.search(l)), lambda ls: [l for l in ls if not _owner(l)]
|
||||
_snap = lambda u, p: hashlib.sha1(("\n".join(u) + "\0" + "\n".join(p)).encode()).hexdigest()[:16]
|
||||
HEAD_USER = "## Learned here\n\nAdded by retros and by the person. These add to the rules above and never relax them.\n"
|
||||
HEAD_PROJECT = "sisi: learned in this project (these add to the rules and never relax them):"
|
||||
_TAGS = " [owner] lines are the person's words; [agent ...] lines are an agent's reading, which a later owner statement or a measurement overrides."
|
||||
HEAD_USER = "## Learned here\n\nAdded by retros and by the person. These add to the rules above and never relax them." + _TAGS + "\n"
|
||||
HEAD_PROJECT = "sisi: learned in this project (these add to the rules and never relax them)." + _TAGS
|
||||
SMELL = re.compile(r"(?i)\bone (?:build|test|run|worker|job)\b.{0,60}\bat a time|\bflock\b|\b(?:shared?|one)\b.{0,30}\bbuild (?:folder|dir)")
|
||||
|
||||
ORGANIZE = """You are a worker. Do this task yourself; do not delegate it further.
|
||||
|
||||
@@ -28,7 +30,11 @@ Rewrite both lists so they serve that objective best:
|
||||
- A rule seen in more than one project, or about how the person wants to be worked with, belongs in the
|
||||
first list. A rule about this project's own code belongs in the second.
|
||||
- Lines marked [owner ...] are the person's own words: copy every one of them verbatim, unchanged by even
|
||||
one character (you may reorder them). Only [retro ...] lines may be merged, reworded or dropped.
|
||||
one character (you may reorder them). Only the other lines ([retro ...], [agent ...]) may be merged, reworded or dropped.
|
||||
- Flag, but do not change, any [owner ...] line whose text does not read as the person's own words (a paraphrase, an
|
||||
agent's conclusion, third person), and any rule that limits builds, tests or workers to one at a time or tells
|
||||
checkouts to share one build folder. List each under a final `## flags` section with its proposed corrected or
|
||||
retagged form, for the person to accept.
|
||||
- Keep the [source date] mark at the end of every line.
|
||||
- A `better` that recurs across retros has earned a rule: add it, worded as an instruction, marked [retro <date>].
|
||||
- Non-owner ([retro ...]) lines in each list: at most %(lines)d lines and %(chars)d characters. Fewer is better.
|
||||
@@ -38,6 +44,8 @@ Answer with exactly this shape and nothing else:
|
||||
- ...
|
||||
## project
|
||||
- ...
|
||||
## flags
|
||||
- ... (only if there are any)
|
||||
|
||||
=== The first list now (all projects) ===
|
||||
%(user)s
|
||||
@@ -45,6 +53,9 @@ Answer with exactly this shape and nothing else:
|
||||
=== The second list now (project "%(name)s") ===
|
||||
%(project)s
|
||||
|
||||
=== Flagged for the person (likely wrong; propose a fix) ===
|
||||
%(flagged)s
|
||||
|
||||
=== What recent retros found, newest last (context only) ===
|
||||
%(retros)s
|
||||
"""
|
||||
@@ -286,6 +297,7 @@ def organize_brief(cwd):
|
||||
return ORGANIZE % {
|
||||
"name": os.path.basename(store.project_root(cwd)), "objective": objective(),
|
||||
"lines": cfg["rules_lines"], "chars": cfg["rules_chars"],
|
||||
"flagged": "\n".join(l for l in u + p if SMELL.search(l)) or "(none)",
|
||||
"user": "\n".join(u) or "(none)", "project": "\n".join(p) or "(none)",
|
||||
"retros": "\n".join(store.read(store.data("retro.jsonl")).splitlines()[-40:]) or "(none)"}
|
||||
|
||||
@@ -293,7 +305,9 @@ def organize_brief(cwd):
|
||||
def organize_record(answer_file, cwd):
|
||||
"""Replace both lists with the worker's answer. Returns why not, or None when it is done."""
|
||||
cfg = store.config()
|
||||
parts = re.split(r"(?m)^## (user|project)[ \t]*$", store.read(answer_file))
|
||||
body, *flags = re.split(r"(?m)^## flags[ \t]*$", store.read(answer_file), 1) # the flags are for the person, not rules
|
||||
flags = "".join(flags)
|
||||
parts = re.split(r"(?m)^## (user|project)[ \t]*$", body)
|
||||
got = {parts[i]: [l.rstrip() for l in parts[i + 1].splitlines() if l.startswith("- ")]
|
||||
for i in range(1, len(parts) - 1, 2)}
|
||||
if set(got) != {USER, PROJECT}:
|
||||
@@ -350,6 +364,7 @@ def organize_record(answer_file, cwd):
|
||||
build_rulebook()
|
||||
for scope in (USER, PROJECT):
|
||||
print("%s rules: %d lines (were %d)" % (scope, len(got[scope]), len(had[scope])))
|
||||
flags.strip() and print("Flagged for you (not changed):" + flags.rstrip())
|
||||
return None
|
||||
|
||||
|
||||
@@ -425,18 +440,37 @@ def run(args, cwd=None):
|
||||
return 1 if why else 0
|
||||
|
||||
|
||||
_norm = lambda t: " ".join(re.sub(r"[\W_]+", " ", t.lower()).split())
|
||||
|
||||
|
||||
def _said(words, cwd):
|
||||
"""True when the words are a quotation of one of the person's recent messages in this session."""
|
||||
try:
|
||||
sid = store.current_session(cwd)
|
||||
said = json.loads(store.read(store._session_path(sid)) or "{}").get("said") if sid else None
|
||||
except (OSError, ValueError, AttributeError):
|
||||
return False
|
||||
return isinstance(said, list) and any(" %s " % _norm(words) in " %s " % _norm(m) for m in said if isinstance(m, str))
|
||||
|
||||
|
||||
def learn(args, cwd=None):
|
||||
"""`sisi learn [--project] TEXT`: the person's own words become a rule at once."""
|
||||
"""`sisi learn [--project] "<the person's exact words>" [--means "<how I will apply it>"]`: a rule at once; the
|
||||
owner tag only when the words are found in the person's recent messages, else the agent's own tag."""
|
||||
i = args.index("--means") if "--means" in args else len(args)
|
||||
args, means = list(args[:i]), " ".join(args[i + 1:])
|
||||
scope = PROJECT if "--project" in args else USER
|
||||
text = " ".join(a for a in args if a != "--project").strip()
|
||||
if len(text.split()) < 3:
|
||||
print('usage: sisi learn [--project] "<what the person said, in their words>"')
|
||||
if len(text.split()) < 3 or (means and len(means.split()) < 3):
|
||||
print('usage: sisi learn [--project] "<what the person said, in their words>" [--means "<how I will apply it>"]')
|
||||
return 1
|
||||
heard = _said(text, cwd)
|
||||
log = os.path.join(store.DATA, "rules", "owner.log") # their exact words are kept, whatever organizing later does to the rule
|
||||
try:
|
||||
line, warn = add(text, scope, "owner", cwd, (log, "%s %s %s" % (time.strftime("%Y-%m-%d"), scope, " ".join(text.split()))))
|
||||
line, warn = add(text, scope, "owner" if heard else "agent, attributed to owner", cwd, (log, "%s %s %s" % (time.strftime("%Y-%m-%d"), scope, " ".join(text.split()))))
|
||||
means and add(means, scope, "agent reading", cwd)
|
||||
except OSError as e:
|
||||
print("sisi learn: could not write %s (%s). Nothing was changed, and your words were not kept." % (path(scope, cwd) or cwd or os.getcwd(), e))
|
||||
return 1
|
||||
heard or print("sisi learn: these words were not found in the person's recent messages, so the rule carries the weaker tag [agent, attributed to owner]; a later owner statement or a measurement overrides it.")
|
||||
print(warn or "in force from the next session: %s" % line)
|
||||
return 0
|
||||
+4
-2
@@ -24,7 +24,7 @@ LIB = os.environ.get("SISI_LIB") or os.path.join(HOME, ".local", "lib", "sisi")
|
||||
# Every setting there is. The person overrides one under "core" in config.json in their store.
|
||||
DEFAULTS = {"gate": True, "meter": True, "direct_calls": 8, "direct_extension": 8,
|
||||
"rules_lines": 30, "rules_chars": 4000, "organize_after": 8, "research_days": 7, "shell_workers": False,
|
||||
"worker_minutes": 15, "retro_minutes": 5, "disk_free_percent": 20, "disk_drop_percent": 5, "checkouts": 8}
|
||||
"worker_minutes": 90, "retro_minutes": 5, "disk_free_percent": 20, "disk_drop_percent": 5, "checkouts": 8}
|
||||
|
||||
def config():
|
||||
cfg = dict(DEFAULTS)
|
||||
@@ -87,8 +87,10 @@ def append(path, line, once=False):
|
||||
|
||||
|
||||
def git(args, cwd, timeout=15):
|
||||
# A repository named by the caller's environment (a git hook sets GIT_DIR) must not decide which project this folder is.
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR")}
|
||||
try:
|
||||
r = subprocess.run(["git"] + args, cwd=cwd, capture_output=True, text=True, timeout=timeout)
|
||||
r = subprocess.run(["git"] + args, cwd=cwd, capture_output=True, text=True, timeout=timeout, env=env)
|
||||
return r.returncode, r.stdout
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
return 1, ""
|
||||
|
||||
+125
-7
@@ -973,7 +973,7 @@ class Core(unittest.TestCase):
|
||||
self.assertFalse(os.path.exists(old_b))
|
||||
rc2, out2, _ = self.sisi("rules", "revert")
|
||||
self.assertEqual(rc2, 0, out2)
|
||||
self.assertIn("undone: rule added (user, owner)", out2)
|
||||
self.assertIn("undone: rule added (user,", out2)
|
||||
self.assertFalse(os.path.exists(old_b))
|
||||
self.assertEqual(self.read(beta, ".sisi", "rules.md"), rows)
|
||||
self.assertFalse(os.path.exists(os.path.join(self.data, "rules", "user.md")))
|
||||
@@ -1348,7 +1348,7 @@ cli.main(["tick"])
|
||||
rc, out, err = self.sisi("learn", "--project", "Rule saved even when store rules dir is read only")
|
||||
self.assertEqual((rc, err), (0, ""), out)
|
||||
self.assertIn("Rule saved even when store rules dir is read only", self.read(self.proj, ".sisi", "rules.md"))
|
||||
self.assertEqual(len(out.strip().splitlines()), 1, out)
|
||||
self.assertEqual(len(out.strip().splitlines()), 2, out)
|
||||
self.assertIn("the rule is in", out)
|
||||
self.assertIn("could not be recorded for undo", out)
|
||||
self.assertNotIn("Nothing was changed", out)
|
||||
@@ -1359,7 +1359,7 @@ cli.main(["tick"])
|
||||
rc, out, err = self.sisi("learn", "--project", "Project rule while index lock blocks commit")
|
||||
self.assertEqual((rc, err), (0, ""), out)
|
||||
self.assertIn("Project rule while index lock blocks commit", self.read(self.proj, ".sisi", "rules.md"))
|
||||
self.assertEqual(len(out.strip().splitlines()), 1, out)
|
||||
self.assertEqual(len(out.strip().splitlines()), 2, out)
|
||||
self.assertIn("could not be recorded for undo", out)
|
||||
os.remove(lock)
|
||||
rc_rev, out_rev, _ = self.sisi("rules", "revert")
|
||||
@@ -1526,7 +1526,8 @@ cli.main(["tick"])
|
||||
|
||||
def test_the_models_table_is_researched_recorded_and_goes_stale(self):
|
||||
self.assertIn("no models table yet", self.hook("tick")[1])
|
||||
self.sisi("learn", "Only the cheapest models on the shared plan")
|
||||
self.hook("prompt", prompt="Only the cheapest models on the shared plan")
|
||||
self.sisi("learn", "Only the cheapest models on the shared plan", sid="s1")
|
||||
brief = self.sisi("models", "research")[1]
|
||||
self.assertIn("Fallback order:", brief)
|
||||
self.assertIn("Only the cheapest models on the shared plan", brief) # the person's words bind the researcher
|
||||
@@ -2787,6 +2788,7 @@ cli.main(["tick"])
|
||||
|
||||
def test_the_gate_blocks_on_a_worker_that_was_started_and_never_reported(self):
|
||||
self.table(WORKERS)
|
||||
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"worker_minutes": 15}}))
|
||||
self.hook("tick")
|
||||
self.hook("prompt", prompt="go")
|
||||
self.done()
|
||||
@@ -2850,6 +2852,7 @@ cli.main(["tick"])
|
||||
|
||||
def test_retro_row_records_session_id_and_demand_to_record_seconds(self):
|
||||
self.table(WORKERS)
|
||||
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"worker_minutes": 15}}))
|
||||
self.hook("tick")
|
||||
self.hook("prompt", prompt="go")
|
||||
self.done()
|
||||
@@ -2947,6 +2950,7 @@ cli.main(["tick"])
|
||||
|
||||
def test_a_lead_waiting_on_a_worker_that_is_not_late_is_not_stopped_for_open_checks(self):
|
||||
self.table(WORKERS)
|
||||
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"worker_minutes": 15}}))
|
||||
self.hook("tick")
|
||||
self.hook("prompt", prompt="go")
|
||||
self.done()
|
||||
@@ -3451,6 +3455,120 @@ cli.main(["tick"])
|
||||
self.assertIn("organize", out.lower())
|
||||
self.assertIn("New rule added while organizer was working", self.read(p_race, ".sisi", "rules.md"))
|
||||
|
||||
def test_owner_tag_means_the_persons_own_words(self):
|
||||
said = "Please, ALWAYS name the check that failed first!"
|
||||
rc, out, _ = self.sisi("learn", "always name the check that failed first", sid="o1") # no message of the person yet
|
||||
rules_u = lambda: self.read(self.data, "rules", "user.md")
|
||||
self.assertEqual(rc, 0, out)
|
||||
self.assertIn("[agent, attributed to owner", rules_u())
|
||||
self.assertNotIn("[owner ", rules_u())
|
||||
self.assertIn("not found in the person's recent messages", out)
|
||||
self.hook("prompt", sid="o1", prompt=said)
|
||||
self.hook("prompt", sid="w1", prompt="You are a worker. Do this task yourself.\nnever use tabs anywhere")
|
||||
self.assertEqual(self.sisi("learn", "ALWAYS name the check -- that failed first", sid="o1")[0], 0)
|
||||
self.assertRegex(rules_u().splitlines()[-1], r"first \[owner \d{4}-\d\d-\d\d\]$")
|
||||
self.assertEqual(self.sisi("learn", "never use tabs anywhere", sid="w1")[0], 0) # a worker records nothing
|
||||
self.assertIn("never use tabs anywhere [agent, attributed", rules_u())
|
||||
rc, out, _ = self.sisi("learn", "ALWAYS name the check that failed first", "--means", "name the failing check in every report", sid="o1")
|
||||
last = rules_u().splitlines()[-2:]
|
||||
self.assertRegex(last[0], r"failed first \[owner \d{4}-\d\d-\d\d\]$")
|
||||
self.assertRegex(last[1], r"^- name the failing check in every report \[agent reading \d{4}-\d\d-\d\d\]$")
|
||||
from sisi import rules
|
||||
self.assertFalse(rules.OWNER.search("- x [agent, attributed to owner 2026-11-25]") or rules.OWNER.search(last[1]))
|
||||
self.write(os.path.join(self.mkdir(self.proj, ".sisi"), "rules.md"), "- Old plain rule [owner 2026-11-20]\n") # before this change
|
||||
self.assertIn("- Old plain rule [owner 2026-11-20]", self.sisi("rules")[1])
|
||||
|
||||
def test_organize_brief_flags_build_limits_for_the_person(self):
|
||||
bad = "- Only one build or test run on the laptop at a time: every cargo command starts as flock [owner 2026-11-25]"
|
||||
self.write(os.path.join(self.mkdir(self.data, "rules"), "user.md"), bad + "\n- Keep it simple [owner 2026-11-24]\n")
|
||||
brief = self.sisi("rules", "organize")[1]
|
||||
flagged = brief.split("=== Flagged for the person (likely wrong; propose a fix) ===")[1].split("===")[0]
|
||||
self.assertIn(bad, flagged)
|
||||
self.assertNotIn("Keep it simple", flagged)
|
||||
ans = self.write(os.path.join(self.tmp, "flags.md"), "## user\n%s\n- Keep it simple [owner 2026-11-24]\n## project\n## flags\n- %s: reword it\n" % (bad, bad[2:]))
|
||||
rc, out, err = self.sisi("rules", "organize", "--record", ans)
|
||||
self.assertEqual(rc, 0, out + err)
|
||||
self.assertIn("reword it", out)
|
||||
self.assertNotIn("reword it", self.read(self.data, "rules", "user.md"))
|
||||
|
||||
def test_prompt_reports_late_workers_with_limit_branch_and_extension(self):
|
||||
self.table(WORKERS)
|
||||
self.hook("tick")
|
||||
self.hook("prompt", prompt="go")
|
||||
self.done()
|
||||
def set_start(w, mins_ago, limit=None, branch=None, ext_ago=None):
|
||||
with open(os.path.join(self.tmp, "state", "core-sessions", "s1.json"), "r+") as f:
|
||||
st = json.load(f)
|
||||
old_t = st["starts"][w][0]
|
||||
t = time.time() - mins_ago * 60 - 5
|
||||
st["starts"][w] = [t]
|
||||
m = st.get("meta", {}).pop("%s %r" % (w, old_t), {})
|
||||
if limit is not None:
|
||||
m["limit"] = limit
|
||||
if branch is not None:
|
||||
m["branch"] = branch
|
||||
if ext_ago is not None:
|
||||
m["extended"] = time.time() - ext_ago * 60 - 5
|
||||
if m:
|
||||
st.setdefault("meta", {})["%s %r" % (w, t)] = m
|
||||
f.seek(0), f.truncate(), json.dump(st, f)
|
||||
self.assertEqual((self.sisi("pick", "hard", sid="s1")[0], self.tool("Agent", tool_input={"model": "sonnet"})[0]), (0, 0))
|
||||
set_start("sonnet", 10)
|
||||
self.assertNotIn("has run", self.hook("prompt", prompt="check 10m")[1])
|
||||
set_start("sonnet", 91)
|
||||
out91 = self.hook("prompt", prompt="check 91m")[1]
|
||||
self.assertIn("sisi: worker sonnet has run 91m (limit 90m); last progress: no report since it started", out91)
|
||||
self.assertEqual(self.sisi("judge", "sonnet", "good", "finished first job cleanly", sid="s1")[0], 0)
|
||||
subprocess.run(["git", "checkout", "-q", "-b", "fix/prog"], cwd=self.proj, check=True, capture_output=True)
|
||||
subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", "commit", "-q", "--allow-empty", "-m", "wip"], cwd=self.proj, check=True, capture_output=True)
|
||||
self.assertEqual((self.sisi("pick", "hard", "--limit", "30", "--branch", "fix/prog", sid="s1")[0], self.tool("Agent", tool_input={"model": "sonnet"})[0]), (0, 0))
|
||||
set_start("sonnet", 29)
|
||||
self.assertNotIn("has run", self.hook("prompt", prompt="check 29m")[1])
|
||||
set_start("sonnet", 31)
|
||||
out31 = self.hook("prompt", prompt="check 31m")[1]
|
||||
self.assertIn("sisi: worker sonnet has run 31m (limit 30m); last progress: commit 0m ago on fix/prog", out31)
|
||||
before_out = len(self.read(self.data, "outcomes.jsonl").splitlines())
|
||||
rc, ext_out, _ = self.sisi("judge", "sonnet", "extend", "20", "waiting on remaining integration checks", sid="s1")
|
||||
self.assertEqual((rc, "51" in ext_out, len(self.read(self.data, "outcomes.jsonl").splitlines())), (0, True, before_out))
|
||||
self.assertNotIn("has run", self.hook("prompt", prompt="after extend")[1])
|
||||
set_start("sonnet", 52, branch="", ext_ago=5)
|
||||
self.assertIn("extended 5m ago", self.hook("prompt", prompt="after ext expired")[1])
|
||||
for bad in (("pick", "hard", "--limit", "0"), ("pick", "hard", "--branch", "bad ref"), ("judge", "sonnet", "extend", "10", "too short")):
|
||||
self.assertEqual(self.sisi(*bad, sid="s1")[0], 1, bad)
|
||||
|
||||
def test_gate_blocks_at_2x_limit_and_refuses_bare_liveness_fault_note(self):
|
||||
self.table(WORKERS)
|
||||
self.hook("tick")
|
||||
self.hook("prompt", prompt="go")
|
||||
self.done()
|
||||
def start_2x(mins_ago=61):
|
||||
self.assertEqual((self.sisi("pick", "hard", "--limit", "30", sid="s1")[0], self.tool("Agent", tool_input={"model": "sonnet"})[0]), (0, 0))
|
||||
with open(os.path.join(self.tmp, "state", "core-sessions", "s1.json"), "r+") as f:
|
||||
st = json.load(f)
|
||||
old_t = st["starts"]["sonnet"][0]
|
||||
t = time.time() - mins_ago * 60 - 5
|
||||
st["starts"]["sonnet"] = [t]
|
||||
st.setdefault("meta", {})["sonnet %r" % t] = st.get("meta", {}).pop("sonnet %r" % old_t, {"limit": 30})
|
||||
f.seek(0), f.truncate(), json.dump(st, f)
|
||||
start_2x()
|
||||
rc, out, _ = self.hook("gate")
|
||||
self.assertEqual((rc, '"block"' in out, "sonnet" in out, "61m" in out, "30m" in out), (0, True, True, True, True), out)
|
||||
self.assertIn("sisi judge", out)
|
||||
self.assertIn("extend", out)
|
||||
rc_f, out_f, _ = self.sisi("fault", "--blocked", "1", "it is still alive")
|
||||
self.assertEqual((rc_f, len(out_f.strip().splitlines()), "sisi judge" in out_f), (1, 1, True), out_f)
|
||||
self.hook("prompt", prompt="next")
|
||||
self.assertIn('"block"', self.hook("gate")[1])
|
||||
self.assertEqual(self.sisi("judge", "sonnet", "extend", "30", "still building the test suite", sid="s1")[0], 0)
|
||||
self.assertNotIn("has run", self.hook("gate")[1])
|
||||
self.assertEqual(self.sisi("judge", "sonnet", "good", "finished the build cleanly", sid="s1")[0], 0)
|
||||
for verdict, why in (("good", "reported cleanly and passed checks"), ("bad", "stopped: worker hung on build")):
|
||||
self.hook("prompt", prompt="next turn")
|
||||
start_2x()
|
||||
self.assertIn('"block"', self.hook("gate")[1])
|
||||
self.assertEqual(self.sisi("judge", "sonnet", verdict, why, sid="s1")[0], 0)
|
||||
self.assertNotIn("has run", self.hook("gate")[1])
|
||||
|
||||
def test_the_spec_is_unchanged(self):
|
||||
for line in self.read(REPO, "docs", "spec", "SHA256SUMS").splitlines():
|
||||
digest, rel = line.split()
|
||||
@@ -3459,10 +3577,10 @@ cli.main(["tick"])
|
||||
|
||||
def test_the_product_stays_small(self):
|
||||
code = sum(len(self.read(p).splitlines()) for p in glob.glob(os.path.join(REPO, "sisi", "*.py")))
|
||||
self.assertLessEqual(code, 1997, "sisi is two loops. If it needs more than this, find the simpler shape.")
|
||||
self.assertLessEqual(code, 2092, "sisi is two loops. If it needs more than this, find the simpler shape.")
|
||||
rulebook = self.read(REPO, "canon", "core.md")
|
||||
self.assertLess(len(rulebook.splitlines()), 135)
|
||||
self.assertLessEqual(len(rulebook), 9872)
|
||||
self.assertLess(len(rulebook.splitlines()), 137)
|
||||
self.assertLessEqual(len(rulebook), 10530)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user