()
| 555 | # Runner (stub mode) |
| 556 | # --------------------------------------------------------------------------- |
| 557 | def run_stub(): |
| 558 | from agent.evolution.executor import run_evolution_for_session |
| 559 | from agent.evolution import backup as backup_mod |
| 560 | from config import conf |
| 561 | # Evolution is disabled by default now; enable for the test. |
| 562 | conf()["self_evolution_enabled"] = True |
| 563 | |
| 564 | passed, failed = 0, 0 |
| 565 | for make in SCENARIOS: |
| 566 | sc = make() |
| 567 | ws = _setup_workspace() |
| 568 | try: |
| 569 | _point_config_at(ws) |
| 570 | # Patch channel push to capture instead of send. |
| 571 | channel = FakeChannel() |
| 572 | import agent.evolution.executor as ex |
| 573 | orig_notify = ex._notify_user |
| 574 | ex._notify_user = lambda ct, rcv, summary: channel.send( |
| 575 | type("R", (), {"content": summary})(), |
| 576 | {"receiver": rcv}, |
| 577 | ) |
| 578 | |
| 579 | agent = FakeAgent(_make_messages(sc["turns"])) |
| 580 | bridge = FakeAgentBridge(agent, sc["scripted"], on_edit=sc["on_edit"]) |
| 581 | |
| 582 | evolved = run_evolution_for_session( |
| 583 | bridge, "session_test", channel_type="telegram", receiver="user_42" |
| 584 | ) |
| 585 | |
| 586 | ok = True |
| 587 | errs = [] |
| 588 | |
| 589 | if evolved != sc["expect_evolved"]: |
| 590 | ok = False |
| 591 | errs.append(f"evolved={evolved}, expected {sc['expect_evolved']}") |
| 592 | |
| 593 | if sc["expect_evolved"]: |
| 594 | # memory / skill content checks |
| 595 | if "expect_memory_contains" in sc: |
| 596 | # Evolution now writes to the dated daily file, not MEMORY.md. |
| 597 | from datetime import datetime |
| 598 | daily = ws / "memory" / (datetime.now().strftime("%Y-%m-%d") + ".md") |
| 599 | mem = daily.read_text() if daily.exists() else "" |
| 600 | if sc["expect_memory_contains"] not in mem: |
| 601 | ok = False |
| 602 | errs.append("daily memory missing expected content") |
| 603 | if "expect_skill_contains" in sc: |
| 604 | sk, txt = sc["expect_skill_contains"] |
| 605 | content = (ws / "skills" / sk / "SKILL.md").read_text() |
| 606 | if txt not in content: |
| 607 | ok = False |
| 608 | errs.append("skill missing expected content") |
| 609 | if sc.get("expect_new_skill") and not _new_skill_dirs(ws): |
| 610 | ok = False |
| 611 | errs.append("expected a new skill to be created") |
| 612 | # notify happened |
| 613 | if not channel.sent: |
| 614 | ok = False |
no test coverage detected