Repository navigation
FEAT: Complete backend — Issues #5, #6, #7, #8 - #13
Merged
Merged
Conversation
Issue #5 — Redis Pub/Sub Integration - internal/ws/pubsub.go: Redis client, Subscribe/Publish/PublishLeaderboardUpdate - internal/ws/hub.go: leaderboard channel key, RegisterLeaderboard, BroadcastLeaderboard - All state changes (proposal, winner, settlement) now publish to Redis pub/sub alongside local WebSocket broadcast — enables horizontal scaling Issue #6 — Scoring Engine - internal/scoring/engine.go: deterministic 4-criterion weighted scorer Weights: execution efficiency (35%), win rate (25%), slippage (25%), reputation (15%) - New agents seeded with neutral 0.5 on slippage + reputation — can compete from day one - Tie-break: earlier proposal wins — fully deterministic, no randomness - handlers/executions.go SelectWinner(): replaced stub with real engine Fetches agent_reputations, runs engine, persists individual scores back to proposals table Issue #7 — Execution Validation Service - internal/validation/service.go: 6-constraint validation — token pair, slippage, deadline, approved venue, intent ownership, agent ID presence - All checks run on every call — caller always gets the full failure list - handlers/executions.go ValidateExecution(): replaced stub with real service Failed proposals get score zeroed (penalises agent in future scoring) HTTP 422 Unprocessable Entity on failure (semantically correct) - handlers/executions.go SettleExecution(): validation added as hard gate Cannot settle without passing — runs independently of /validate endpoint Issue #8 — Circle Integration - internal/circle/client.go: isolated Circle API client CreateWallet (deterministic idempotency via SHA1 UUID from wallet address) GetWallet / GetBalance (USDC balance reads) SendUSDC (micropayment settlement — agent execution fee) SimulateCCTPTransfer (cross-chain routing demo) Sandbox/production toggled from ENV — never hits prod from dev - internal/handlers/circle.go: 4 new endpoints POST /api/v1/wallets, GET /api/v1/wallets/{id}/balance POST /api/v1/wallets/transfer, POST /api/v1/wallets/cctp - handlers/executions.go SettleExecution(): Circle.SendUSDC() called after settlement Idempotency key tied to execution ID — retries never double-pay Agent total_intents_won + consecutive_successes incremented atomically (gorm.Expr) CI/CD fixes - golangci-lint-action upgraded v3 → v6 - Linter now installed via go install (compiled with Go 1.26, no version mismatch) - actions/upload-artifact, actions/cache, codecov/codecov-action all bumped to v4 - errcheck fix: json.Encode return value checked in respondJSON README - Full rewrite reflecting complete backend scope - Added Circle badge, scoring weights table, validation constraints table - Full API reference table (13 endpoints) - WebSocket events table with message shape example - Updated project structure with all new packages - All 7 issues marked ✅ Done Verified end-to-end: Intent → proposal → scoring engine (0.841) → validation passed → settlement confirmed → leaderboard updated ✅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes Issue #5 — Redis Pub/Sub Integration
closes Issue #6 — Scoring Engine
closes Issue #7 — Execution Validation Service
closes Issue #8 — Circle Integration
CI/CD fixes
README
Verified end-to-end:
Intent → proposal → scoring engine (0.841) → validation passed → settlement confirmed → leaderboard updated ✅