Learning cycle hardened: nothing from a cycle file runs at check, replay in an exported tree with the learning's own commits, typed approval and a hook that refuses agent-issued approval, backlog and pending statuses so a cycle is not due for ever, rule additions, a brief a small model can act on

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-23 15:27:03 -07:00
commit 9f1f9411fd
16 files changed
+2282 -351

No files matched your search

+45
View File
@@ -56,6 +56,12 @@ class SisiCase(unittest.TestCase):
for k in ("SISI_TOOL", "SISI_SESSION_ID"):
os.environ.pop(k, None)
# no test may talk to the terminal it is run from: `sisi approve` finds none unless the test says so
from unittest import mock as _mock
_no_tty = _mock.patch("sisi.cycle._open_terminal", return_value=None)
_no_tty.start()
self.addCleanup(_no_tty.stop)
def restore():
for k, v in saved.items():
if v is None:
@@ -143,3 +149,42 @@ def skip_timing_if_busy(case):
return
if load > cpus:
case.skipTest("machine overloaded (load %.0f on %d processors): speed not measured" % (load, cpus))
class FakeTerminal:
"""What `sisi approve` reads its decision from. Writes are kept; the line it answers with is the
word the prompt asked for (or `typed`, to type something else, or None to type nothing)."""
def __init__(self, typed="the word"):
self.out, self.typed = [], typed
def write(self, text):
self.out.append(text)
def flush(self):
pass
def readline(self):
if self.typed is None:
return ""
if self.typed != "the word":
return self.typed + "\n"
import re
m = re.search(r"Type the word (\w+)", "".join(self.out))
return (m.group(1) if m else "") + "\n"
def close(self):
pass
@property
def text(self):
return "".join(self.out)
def terminal(typed="the word"):
"""Patch: the process has a controlling terminal, and the owner types `typed` at it."""
from unittest import mock
t = FakeTerminal(typed)
p = mock.patch("sisi.cycle._open_terminal", return_value=t)
p.fake = t
return p