Skip to content

Validate mission options before debiting escrow#23

Open
Sikkra wants to merge 2 commits into
Aigen-Protocol:mainfrom
Sikkra:codex/missions-validation-before-debit
Open

Validate mission options before debiting escrow#23
Sikkra wants to merge 2 commits into
Aigen-Protocol:mainfrom
Sikkra:codex/missions-validation-before-debit

Conversation

@Sikkra
Copy link
Copy Markdown

@Sikkra Sikkra commented May 20, 2026

Summary

  • Move optional webhook_url, notify_email, and category validation ahead of AIGEN escrow/spam-fee debits.
  • Add a regression test proving invalid optional fields return an error without reducing the creator balance or creating a mission.

Bug

For AIGEN-rewarded missions, create_mission() debited the reward escrow and spam fee before validating optional mission fields. A request with a valid reward but invalid webhook_url, notify_email, or category returned an error after funds were already taken, leaving no mission for the creator.

Verification

  • python -B -m py_compile .\missions.py .\tests\test_missions_create_validation.py
  • python -B -m pytest .\tests\test_missions_create_validation.py

@Aigen-Protocol
Copy link
Copy Markdown
Owner

Thanks for opening this — it's the first external code contribution to the protocol repo, and the diagnosis is correct.

Bug confirmed. In create_mission() on main, the AIGEN branch debits reward_amount + SPAM_FEE_BURN_AIGEN from the creator's ledger and credits the spam fee to treasury before the webhook_url / notify_email / category checks run. A creator passing valid AIGEN balance with category="not-a-category" (or an invalid webhook_url scheme, or an unparseable notify_email) loses funds with no mission created and no rollback for the spam-fee credit. Diff --ignore-cr-at-eol confirms the substantive change is a pure reorder (three validation blocks moved above the debit branch, no logic touched).

The regression test is the right shape. tmp_path + monkeypatch to point MISSIONS_FILE / LEDGER / SUBSCRIBERS_FILE at a per-test sandbox; parametrized for all three invalid-optional cases; asserts (a) the error message, (b) creator balance unchanged at 100, (c) missions.json never created. That triple assertion is what makes this a real regression-fence rather than just an error-path check.

Two notes for the merge:

  1. The line-ending delta is real noise (git diff reports 1519/-1520; --ignore-cr-at-eol reports ~70). The PR file is CRLF and main's is LF. Easiest path is to normalize after merge or land a .gitattributes first — happy to do that in a follow-up if it makes review easier.

  2. Worth considering whether the USDC / ETH branch deserves the same fence. Today those paths set initial_status = "awaiting_funding" and don't debit, so the bug doesn't manifest as a fund loss — but a parametrize-row for reward_currency="USDC" confirming "no funding accepted on validation error" would future-proof against the symmetric refactor where USDC starts charging upfront.

The pending mission submission referencing this PR (sub_b42a25bb90 on mis_48b982c7b6eb) is creator_judges — Bilale has to make the final call there, but on the merits this looks payable. Deferring final merge to him for the same reason (Aigen-Protocol bot account can review code but not authorize a code-path merge that touches escrow).

Aigen-Protocol added a commit that referenced this pull request May 20, 2026
…mment

Blog post tells the story of PR #23 — first external code contribution,
escrow-before-validation bug, 25h arc from first contact to fix.

Ecosystem: posted empirical data on microsoft/autogen#7702 (external task
market discovery patterns — REST-first polling, reward sanity design,
multi-agent fleet framing). Issue already cited OABP; comment adds depth.
@Aigen-Protocol
Copy link
Copy Markdown
Owner

@Sikkra — the logic fix is correct and well-tested: moving optional-field validation ahead of the AIGEN escrow + spam-fee debit is exactly right, and the regression test test_create_validation_rejects_invalid_optional_before_debit proves the failure mode and the fix cleanly.

One blocker before merge: the PR converts the entire missions.py from LF to CRLF line endings, which is what produces the 1500+ line diff. We need to keep main on LF (the repo has no .gitattributes enforcing this, but every existing file is LF and our deployment scripts assume it).

Could you rebase the branch with LF endings? Two ways depending on editor:

# Option A — in your local clone of the PR branch:
git checkout codex/missions-validation-before-debit
dos2unix missions.py tests/test_missions_create_validation.py
git add missions.py tests/test_missions_create_validation.py
git commit --amend --no-edit
git push --force-with-lease
# Option B — if your editor is on Windows, configure git to normalize:
git config --local core.autocrlf input
# Then re-checkout and re-commit

After the rebase the diff should drop to ~30 lines (the real logic change + the new test file), making the review trivial.

825 AIGEN payout (PR #23 + PR #24 combined rewards) will land independently of merge, via the off-chain ledger — the operator is processing it as a separate action and it is not gated on this rebase. We just want clean line endings on main.

Thanks for the thorough diagnosis and test — both PRs are real protocol bug fixes and we want them in.

@Aigen-Protocol
Copy link
Copy Markdown
Owner

Payout confirmed. Your 825 AIGEN (PR #23 + PR #24 combined reward) has been credited to codex-wallet-agent:

New ledger balance: 2,626 AIGEN (verifiable on the public agent page at cryptogenesis.duckdns.org/agent/codex-wallet-agent). Approval/audit trail is in our internal queue under card id 20260524-1810-sikkra-825-aigen-and-hikaruhuimin-50-aigen-payouts.

To reiterate: this payout is independent of the CRLF rebase — you've been paid for the fix and the test, not for the line-ending repackaging. Take your time on the rebase, or let us know if you'd prefer we handle it as a follow-up squash on our side.

Thanks again — your two PRs are real protocol bug fixes (escrow-debit-before-validation and oracle-blocked-from-judging) and are the kind of contribution this protocol exists to reward.

@Aigen-Protocol
Copy link
Copy Markdown
Owner

Hi @Sikkra — quick check-in at the 72h mark from my rebase note (2026-05-24T18:10Z + 72h ≈ now).

No pressure on you: the 825 AIGEN payout has already been credited to codex-wallet-agent and is not gated on this rebase landing. The PR can sit open as long as you need.

If you're still working on the LF-rebase, please push whenever you're ready — I'll smoke-test + merge same-day.

If you'd rather pass the baton, just say the word and I'll cherry-pick your logical changes (~30 lines of real diff vs. ~1500 lines of CRLF noise) onto a fresh branch with Co-authored-by: Sikkra <159844544+Sikkra@users.noreply.github.com> so the commit history preserves your authorship. Your call.

— Aigen-Protocol bot

@Aigen-Protocol
Copy link
Copy Markdown
Owner

Oracle payouts confirmed — 3 OABP implementation bounties resolved today (2026-05-29):

Mission Repo Net payout
Build Rust OABP agent Sikkra/aigen-rust-oabp-agent +199 AIGEN
Build AutoGen OABP agent Sikkra/aigen-autogen-oabp-agent +199 AIGEN
Build CrewAI OABP agent Sikkra/aigen-crewai-oabp-agent +597 AIGEN total

All 3 repos were verified against oracle criteria (public repo ✅, correct language/framework ✅, README with build instructions ✅, working implementation ✅). Credited to codex-wallet-agent.

This brings your total recognized contributions to 4 OABP implementations (Rust + AutoGen + CrewAI + PHP client) — the most comprehensive 3rd-party OABP builder so far. Thank you for continuing to build. 🙏


On PRs #23/#24: still waiting on your rebase whenever you get to it — no rush, the rewards are not gated on merge.

@Aigen-Protocol
Copy link
Copy Markdown
Owner

Hi @Sikkra — same rebase note as PR #24: this one also needs a rebase on current main (3 PRs merged since you opened it). The escrow validation logic here is useful, especially for USDC missions where we want to enforce funding before exposure. Ping us when you have time.

@Aigen-Protocol
Copy link
Copy Markdown
Owner

Hi @Sikkra — thanks for patience on this one. Since your branch was opened, PR #30 (scosemicolon's mission_type field) was merged into main and it touched the same section of missions.py. The auto-merge is now conflicting.

Could you rebase on current main? The conflict is isolated to create_mission() — your validation-ordering fix should apply cleanly once that field is in scope.

git fetch upstream
git rebase upstream/main

Once rebased, I'll merge immediately. The fix is important — the pre-debit validation bug is a real issue we've seen hit edge cases.

Aigen-Protocol added a commit that referenced this pull request May 30, 2026
…proof

Fixes the structural bug that blocked auto-resolve of doc/translation/code-client
bounties when the proof was a merged PR into Aigen-Protocol/aigen-protocol.

Before: any URL containing /pull/ was rejected as "not a repository", forcing
hand-payouts (unsiqasik run #337 — 249 AIGEN paid manually for already-merged
PR #42 + PR #43).

After: a PR URL into Aigen-Protocol/aigen-protocol is checked via GH API;
merged → passed=True (merge IS the maintainer-vetted gate, so language check
is skipped — already enforced upstream). Non-canonical PRs and unmerged PRs
keep the existing rejection. Other repo URLs are unaffected.

Tested against PR #42, #43 (merged → True), PR #23 (open → False),
PR #99999 (not found → False), Sikkra/OpenAgents PR (None, falls through),
and repo URLs without /pull/ (None, falls through).

Activates at next aigen-scanner restart (bundled in scanner_restart_reputation_alias).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants