From 1b57d00e60c265c9ca6c6c54f42c123b53e8dbd0 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 23 Nov 2026 12:29:33 -0700 Subject: [PATCH] Item 6: sisi learn prints the stored text, id, scope and the withdraw command. done 6 / next 7 (brief template) --- sisi/scope.py | 6 ++++-- tests/test_learning_loop.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/sisi/scope.py b/sisi/scope.py index 9b1f26e..649c52b 100644 --- a/sisi/scope.py +++ b/sisi/scope.py @@ -65,6 +65,8 @@ def cmd_learn(argv): os.getcwd(), L.unit_id(), change=statement, mechanism="knowledge", scope=scope, expect="the agent acts on this statement", owner_statement=True, entered_via="learn", origin=origin) - print("recorded owner statement %s (%s; printed by `sisi oracle`; withdraw a mistake with " - "`sisi learn --withdraw %s --reason ...`)" % (rec["id"], origin, rec["id"])) + print("recorded owner statement %s (%s)" % (rec["id"], origin)) + print(" stored: %s" % rec["observation"]["evidence"]) + print(" scope: %s; it takes effect at once and `sisi oracle` prints it" % rec["proposed"]["scope"]) + print(" to take it back: sisi learn --withdraw %s --reason \"\"" % rec["id"]) return 0 diff --git a/tests/test_learning_loop.py b/tests/test_learning_loop.py index 7412127..ce03f3a 100644 --- a/tests/test_learning_loop.py +++ b/tests/test_learning_loop.py @@ -936,6 +936,21 @@ class Store(Base): self.assertIn("prefer short plain reports", r.stdout) self.assertEqual(len(L.owner_statements()), 1) + def test_learn_says_what_it_stored_and_how_to_take_it_back(self): + """R-12-1: the receipt shows the stored text (secrets scrubbed), id, scope and a withdraw command that works.""" + out = self.sisi("learn", "--scope", "project", "prefer short plain reports, password=hunter2hunter2").stdout + row = self.rows()[0] + self.assertIn(row["id"], out) + self.assertIn("scope: project", out) + self.assertIn(row["observation"]["evidence"], out) + self.assertNotIn("hunter2", out) + cmd = [l for l in out.splitlines() if "sisi learn --withdraw" in l][0].split("sisi learn ", 1)[1] + self.assertIn("--withdraw %s " % row["id"], cmd) + import shlex + r = self.sisi("learn", *shlex.split(cmd.replace("", "test"))) + self.assertEqual(r.returncode, 0, r.stderr) + self.assertEqual(L.owner_statements(), []) + def test_learn_records_whether_the_owner_typed_it(self): """A statement quoted from a human-typed message of the session transcript is `typed by the owner`; a relayed one, or none to check, is `relayed by an agent`. Never blocked."""