diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b153e0c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,17 @@ +name: tests + +on: + push: + branches: [main] + pull_request: + +jobs: + pytest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - run: pip install pytest + - run: python -m pytest -v diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6c56ff1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +.pytest_cache/ diff --git a/README.md b/README.md index 6fc5c2f..a63838a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,28 @@ -# evoforge-demo +# evoforge-target -Demo target repository for EvoForge (verifiable AI engineering collective). -`calc.add` has a deliberate bug for the Builder/Critic loop to fix. +Demo target repository for [EvoForge](https://evoforge-web-230852112787.asia-northeast3.run.app/), a verifiable AI engineering collective. + +EvoForge takes a mission written in plain language, has a Builder write the change and a Critic check it, runs the visible tests plus a sealed held-out suite, and opens a pull request here only when every gate passes. Each PR carries an evidence id and an Ed25519-signed proof certificate that anyone can check on the EvoForge verify page. + +## The demo mission + +`stats.median` has a deliberate bug: for a list of even length it returns the upper middle element instead of the average of the two middle elements. The visible test only covers an odd-length list, so a change that merely passes the visible tests is not enough; the held-out suite decides. + +Example mission: + +> In stats.py, fix median(xs) so that for an even number of items it returns the average of the two middle items. Keep mean unchanged. + +`calc.py` (add, sub, mul) is the history of earlier missions: each of those bugs was fixed by a merged EvoForge PR. + +## Checking a PR + +1. Open the `Verify:` link in the PR body and confirm the verdict is VERIFIED. +2. Compare the certificate id, public key fingerprint and signature shown there with the ones in the PR body. +3. The `tests` workflow runs `pytest` on every PR independently of EvoForge. + +## Running the tests + +``` +pip install pytest +python -m pytest -v +``` diff --git a/stats.py b/stats.py new file mode 100644 index 0000000..e8407d0 --- /dev/null +++ b/stats.py @@ -0,0 +1,6 @@ +def mean(xs): + return sum(xs) / len(xs) + +def median(xs): + ordered = sorted(xs) + return ordered[len(xs) // 2] diff --git a/tests/evoforge_gen/test_7a0ab91b_1.py b/tests/evoforge_gen/test_7a0ab91b_1.py index 959f4d8..16c6ff6 100644 --- a/tests/evoforge_gen/test_7a0ab91b_1.py +++ b/tests/evoforge_gen/test_7a0ab91b_1.py @@ -1,3 +1,3 @@ def test_mul_returns_product(): from calc import mul - assert mul(2, 3) == 6 \ No newline at end of file + assert mul(2, 3) == 6 diff --git a/tests/evoforge_gen/test_7a0ab91b_2.py b/tests/evoforge_gen/test_7a0ab91b_2.py index d96ac77..71c4239 100644 --- a/tests/evoforge_gen/test_7a0ab91b_2.py +++ b/tests/evoforge_gen/test_7a0ab91b_2.py @@ -1,3 +1,3 @@ def test_add_unchanged(): from calc import add - assert add(2, 3) == 5 \ No newline at end of file + assert add(2, 3) == 5 diff --git a/tests/evoforge_gen/test_7a0ab91b_3.py b/tests/evoforge_gen/test_7a0ab91b_3.py index 02f0c2d..5961c7e 100644 --- a/tests/evoforge_gen/test_7a0ab91b_3.py +++ b/tests/evoforge_gen/test_7a0ab91b_3.py @@ -1,3 +1,3 @@ def test_sub_unchanged(): from calc import sub - assert sub(5, 3) == 2 \ No newline at end of file + assert sub(5, 3) == 2 diff --git a/tests/evoforge_gen/test_813100b8_1.py b/tests/evoforge_gen/test_813100b8_1.py index 8e82fdf..9c76854 100644 --- a/tests/evoforge_gen/test_813100b8_1.py +++ b/tests/evoforge_gen/test_813100b8_1.py @@ -1,3 +1,3 @@ def test_sub_basic(): from calc import sub - assert sub(5, 3) == 2 \ No newline at end of file + assert sub(5, 3) == 2 diff --git a/tests/evoforge_gen/test_813100b8_2.py b/tests/evoforge_gen/test_813100b8_2.py index 3c0b5d3..1b43905 100644 --- a/tests/evoforge_gen/test_813100b8_2.py +++ b/tests/evoforge_gen/test_813100b8_2.py @@ -1,3 +1,3 @@ def test_sub_negative_result(): from calc import sub - assert sub(2, 5) == -3 \ No newline at end of file + assert sub(2, 5) == -3 diff --git a/tests/evoforge_gen/test_813100b8_3.py b/tests/evoforge_gen/test_813100b8_3.py index 7755345..cf61f76 100644 --- a/tests/evoforge_gen/test_813100b8_3.py +++ b/tests/evoforge_gen/test_813100b8_3.py @@ -1,3 +1,3 @@ def test_sub_zero(): from calc import sub - assert sub(0, 0) == 0 \ No newline at end of file + assert sub(0, 0) == 0 diff --git a/tests/evoforge_gen/test_gen_1.py b/tests/evoforge_gen/test_gen_1.py index b58ea21..054f6c5 100644 --- a/tests/evoforge_gen/test_gen_1.py +++ b/tests/evoforge_gen/test_gen_1.py @@ -1,3 +1,3 @@ def test_add_positive(): from calc import add - assert add(2, 3) == 5 \ No newline at end of file + assert add(2, 3) == 5 diff --git a/tests/evoforge_gen/test_gen_2.py b/tests/evoforge_gen/test_gen_2.py index 6a63892..cb7c787 100644 --- a/tests/evoforge_gen/test_gen_2.py +++ b/tests/evoforge_gen/test_gen_2.py @@ -1,3 +1,3 @@ def test_add_negative(): from calc import add - assert add(-2, -3) == -5 \ No newline at end of file + assert add(-2, -3) == -5 diff --git a/tests/evoforge_gen/test_gen_3.py b/tests/evoforge_gen/test_gen_3.py index 31f4be0..9ef6be3 100644 --- a/tests/evoforge_gen/test_gen_3.py +++ b/tests/evoforge_gen/test_gen_3.py @@ -1,3 +1,3 @@ def test_add_zero(): from calc import add - assert add(0, 5) == 5 \ No newline at end of file + assert add(0, 5) == 5 diff --git a/tests/test_stats.py b/tests/test_stats.py new file mode 100644 index 0000000..0930c15 --- /dev/null +++ b/tests/test_stats.py @@ -0,0 +1,7 @@ +def test_mean_basic(): + from stats import mean + assert mean([1, 2, 3, 4]) == 2.5 + +def test_median_odd_length(): + from stats import median + assert median([3, 1, 2]) == 2