Overlay rule changes cannot stack on a waiting one; an empty brief is one line; a brief never exceeds its limit. done / next: repeat runs, report

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-23 14:55:28 -07:00
1 parent a11491c985
commit 4180df8544
3 files changed
+41 -1

No files matched your search

+6 -1
View File
@@ -339,6 +339,11 @@ def brief_text():
base = L.store_base(rows)
flagged = {r["id"] for r in L.flagged(rows)}
todo = _rank([r for r in proposed(rows) if r["id"] not in flagged] + L.flagged(rows))
if not todo:
backlog = sum(1 for r in rows if r.get("status") == "backlog")
waiting = sum(1 for r in rows if r.get("status") == "pending-approval")
return ("Learning cycle brief: no learning a cycle can act on (%d on the backlog for sisi itself, %d waiting "
"for the owner). Nothing to write.\n" % (backlog, waiting))
text = "Learning cycle brief.\n" + format_text(base)
blocks, left = [], 0
for r in todo[:BRIEF_MAX_LEARNINGS]:
@@ -347,7 +352,7 @@ def brief_text():
r["id"], r.get("recurrences_after_promotion", 0))
else:
blk = _learning_block(r)
if len(text) + sum(len(b) + 1 for b in blocks) + len(blk) + 120 > BRIEF_MAX_CHARS and r["id"] not in flagged:
if len(text) + sum(len(b) + 1 for b in blocks) + len(blk) + 120 > BRIEF_MAX_CHARS:
left += 1
continue
blocks.append(blk)
+4
View File
@@ -796,6 +796,10 @@ def _rule_change_waits(action):
ok, msg = documents.check_budgets(render_with({rid: parse_rule_file(action["rule_text"], rid)}))
if not ok:
raise OverlayError(msg)
waiting = cycle._waiting()[1].get(rid)
if waiting:
raise OverlayError("rule %s already has a change waiting for the owner (%s); a second one waits until that "
"is decided" % (rid, waiting))
pid = cycle.park_rule_change(action, ["%s %s: changing or disabling an existing rule needs the owner" % (action["action"], rid)])
print("%s %s waits for the owner: nothing changed. The owner decides in a terminal: `sisi approve %s --yes`"
% (action["action"], rid, pid))
+31
View File
@@ -918,3 +918,34 @@ class DueCounter(Base):
with open(p, "w") as f:
json.dump(rec, f)
self.assertIn("cycle is due (6 proposed", cycle.due_notice())
class Odds(Base):
"""R-11.5-11, R-11.1-14 (items 5 and 8): the edges."""
def test_the_overlay_command_cannot_stack_a_second_change_on_a_rule_that_has_one_waiting(self):
_contract(self)
text = "## Deliver {#deliver-fast}\n\nShip it.\n\nWhy: speed.\n"
with open(os.path.join(self.tmp, "r.md"), "w") as f:
f.write(text)
r = self.sisi("overlay", "replace-rule", "deliver-fast", os.path.join(self.tmp, "r.md"))
self.assertEqual(r.returncode, 0, r.stderr)
r = self.sisi("overlay", "replace-rule", "deliver-fast", os.path.join(self.tmp, "r.md"))
self.assertEqual(r.returncode, 1)
self.assertIn("already has a change waiting", r.stderr)
self.assertEqual(len(self.pending()), 1)
def test_an_empty_brief_says_so_in_one_line_and_flagged_learnings_never_break_the_limit(self):
_contract(self)
out = self.sisi("cycle").stdout
self.assertEqual(len(out.splitlines()), 1)
self.assertIn("Nothing to write", out)
for n in range(8):
self.another(n)
rows = self.rows()
for r in rows:
r["flagged_not_working"] = True
L.save_learnings(rows, "t", touched=rows, via="test")
text = self.sisi("cycle").stdout
self.assertLessEqual(len(text), 6000)
self.assertEqual(text.count("FLAGGED NOT WORKING"), 8)