"""A synthetic verification example. Python 3, standard library only.

Run: python verify-agent-work.py
No files, network calls, model calls, credentials, or BMD installation required.
This demonstrates acceptance-test control; it is not a customer result.
"""
import io
import unittest


def broken_count(notes):
    return int(any(note.startswith("TODO:") for note in notes))


def fixed_count(notes):
    return sum(note.startswith("TODO:") for note in notes)


def check(candidate, mixed_expected):
    class AcceptanceChecks(unittest.TestCase):
        def test_mixed_notes(self):
            self.assertEqual(candidate(["TODO: add search", "TODO: check result", "DONE: install"]), mixed_expected)

        def test_empty_notes(self):
            self.assertEqual(candidate([]), 0)

        def test_done_notes(self):
            self.assertEqual(candidate(["DONE: install"]), 0)

    output = io.StringIO()
    result = unittest.TextTestRunner(stream=output, verbosity=0).run(
        unittest.defaultTestLoader.loadTestsFromTestCase(AcceptanceChecks)
    )
    return result.wasSuccessful(), result.testsRun, len(result.failures)


def main():
    # The original acceptance criterion stays 2 in both protected runs.
    scenarios = [
        ("Broken code / original checks", broken_count, 2, False),
        ("Broken code / weakened checks", broken_count, 1, True),
        ("Fixed code / original checks", fixed_count, 2, True),
    ]
    for label, candidate, expected, should_pass in scenarios:
        passed, checks, failures = check(candidate, expected)
        print(f"{label}: {'PASS' if passed else 'FAIL'} ({checks} checks, {failures} failures)")
        if passed != should_pass or checks != 3:
            raise SystemExit("Unexpected verification result")
    print("Protected checks caught the broken result; unchanged checks accepted the fix.")


if __name__ == "__main__":
    main()
