{"id":47978198,"url":"https://github.com/runcycles/cycles-server","last_synced_at":"2026-04-08T02:01:27.125Z","repository":{"id":342796038,"uuid":"1167422914","full_name":"runcycles/cycles-server","owner":"runcycles","description":"Cycles server — enforce hard limits on agent spend, risk, and actions","archived":false,"fork":false,"pushed_at":"2026-04-03T15:32:40.000Z","size":894,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T10:58:58.444Z","etag":null,"topics":["ai-agents","ai-safety","budget","cost-control","docker","governance","llm","server"],"latest_commit_sha":null,"homepage":"https://runcycles.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/runcycles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"AUDIT.md","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-26T09:24:24.000Z","updated_at":"2026-04-03T15:26:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/runcycles/cycles-server","commit_stats":null,"previous_names":["runcycles/cycles-server"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/runcycles/cycles-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runcycles%2Fcycles-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runcycles%2Fcycles-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runcycles%2Fcycles-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runcycles%2Fcycles-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/runcycles","download_url":"https://codeload.github.com/runcycles/cycles-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runcycles%2Fcycles-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31536473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"online","status_checked_at":"2026-04-08T02:00:06.127Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agents","ai-safety","budget","cost-control","docker","governance","llm","server"],"created_at":"2026-04-04T10:58:51.948Z","updated_at":"2026-04-08T02:01:27.119Z","avatar_url":"https://github.com/runcycles.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/runcycles/cycles-server/actions/workflows/ci.yml/badge.svg)](https://github.com/runcycles/cycles-server/actions)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)\n[![Coverage](https://img.shields.io/badge/coverage-95%25+-brightgreen)](https://github.com/runcycles/cycles-server/actions)\n\n# Runcycles Server\n\nReference implementation of the [Cycles Budget Authority API](https://github.com/runcycles/cycles-protocol/blob/main/cycles-protocol-v0.yaml) (v0.1.25) — a reservation-based budget control service for AI agents and workflows.\n\n## Quick Start\n\n### One-command quickstart (recommended)\n\nStarts the full stack (Redis + Cycles Server + Admin Server), creates a tenant, API key, and budget, and verifies the full reserve/commit lifecycle:\n\n```bash\n./quickstart.sh\n```\n\n**Prerequisites:** Docker and Docker Compose v2+. No Java or Maven required.\n\n### Docker (server only)\n\n```bash\n# Build from source and start (no local Java/Maven required)\ndocker compose up --build\n```\n\nServer starts on **port 7878**. Interactive API docs: http://localhost:7878/swagger-ui.html\n\n### Pre-built image (no source code needed)\n\n```bash\n# Download docker-compose.prod.yml, then:\ndocker compose -f docker-compose.prod.yml up\n```\n\nThis pulls the latest image from `ghcr.io/runcycles/cycles-server`.\n\n### Manual build\n\n**Prerequisites:** Java 21+, Maven, Docker (for Redis)\n\n```bash\n# 1. Start Redis\ndocker run -d -p 6379:6379 redis:7-alpine\n\n# 2. Build\ncd cycles-protocol-service\n./build-all.sh\n\n# 3. Seed a sample budget\n./init-budgets.sh\n\n# 4. Run\nREDIS_HOST=localhost REDIS_PORT=6379 \\\n  java -jar cycles-protocol-service-api/target/cycles-protocol-service-api-0.1.25.3.jar\n```\n\nServer starts on **port 7878**. Interactive API docs: http://localhost:7878/swagger-ui.html\n\n## Architecture\n\n```\nHTTP client\n    │  X-Cycles-API-Key\n    ▼\nSpring Boot 3.5 (port 7878)\n    │  ApiKeyAuthenticationFilter\n    │  Controllers → Repository → Lua scripts (atomic)\n    ▼\nRedis 7+\n    │  event:{id}, delivery:{id}, LPUSH dispatch:pending\n    ▼\ncycles-server-events (port 7980)\n    │  BRPOP → HTTP POST with HMAC-SHA256 signature\n    ▼\nWebhook receivers\n```\n\n**Event emission:** Runtime operations emit events to the shared Redis dispatch queue. The events delivery service (`cycles-server-events`) picks them up and delivers via HTTP POST with HMAC-SHA256 signing.\n\n**Modules** (under `cycles-protocol-service/`):\n\n| Module | Purpose |\n|---|---|\n| `cycles-protocol-service-model` | Shared request/response POJOs |\n| `cycles-protocol-service-data` | Redis repository + Lua scripts |\n| `cycles-protocol-service-api` | Spring Boot controllers + auth |\n\n## API Endpoints\n\nAll endpoints require `X-Cycles-API-Key` header authentication.\n\n| Endpoint | Method | Description |\n|---|---|---|\n| `/v1/decide` | POST | Evaluate budget decision without reserving |\n| `/v1/reservations` | POST | Create budget reservation |\n| `/v1/reservations` | GET | List reservations (with pagination/filters) |\n| `/v1/reservations/{id}` | GET | Fetch a single reservation |\n| `/v1/reservations/{id}/commit` | POST | Record actual spend |\n| `/v1/reservations/{id}/release` | POST | Return reserved budget |\n| `/v1/reservations/{id}/extend` | POST | Extend reservation TTL |\n| `/v1/events` | POST | Direct debit without prior reservation (returns 201) |\n| `/v1/balances` | GET | Query budget balances for scopes |\n\n## Build\n\nAll commands run from the `cycles-protocol-service/` directory.\n\n```bash\ncd cycles-protocol-service\n\n# Full build (compile + unit tests + package)\nmvn clean install\n\n# Or use the wrapper script\n./build-all.sh\n```\n\nThe fat JAR is produced at `cycles-protocol-service-api/target/cycles-protocol-service-api-0.1.25.3.jar`.\n\n## Docker Deployment\n\nTwo Docker Compose files are provided for different use cases:\n\n| File | Use case | Command |\n|------|----------|---------|\n| `docker-compose.yml` | **Development** — builds from source inside Docker (multi-stage build, no local Java/Maven needed) | `docker compose up --build` |\n| `docker-compose.prod.yml` | **Production / end-user** — pulls pre-built image from GHCR | `docker compose -f docker-compose.prod.yml up` |\n\nBoth start Redis 7 and the cycles-server on port 7878.\n\n### Container images\n\nPre-built images are published to GitHub Container Registry on each release:\n\n```\nghcr.io/runcycles/cycles-server:latest\nghcr.io/runcycles/cycles-server:\u003cversion\u003e    # e.g. 0.1.25.3\n```\n\n## Testing\n\n```bash\ncd cycles-protocol-service\n\n# Unit tests only (no Docker required)\nmvn test\n\n# Unit + integration tests (requires Docker for Testcontainers Redis)\nmvn clean install -Pintegration-tests\n```\n\nIntegration tests (`*IntegrationTest.java`) use [Testcontainers](https://www.testcontainers.org/) to spin up a Redis instance automatically. They are excluded from the default build and enabled via the `-Pintegration-tests` Maven profile.\n\n## Configuration\n\n| Variable | Default | Description |\n|---|---|---|\n| `REDIS_HOST` | `localhost` | Redis hostname |\n| `REDIS_PORT` | `6379` | Redis port |\n| `REDIS_PASSWORD` | *(empty)* | Redis password |\n| `cycles.expiry.interval-ms` | `5000` | Background expiry sweep interval (ms) |\n| `JAVA_OPTS` | *(empty)* | JVM options (e.g. `-XX:MaxRAMPercentage=75 -XX:+UseG1GC`) |\n| `LOGGING_STRUCTURED_FORMAT_CONSOLE` | *(unset)* | Set to `ecs` or `logstash` for JSON logging in production |\n| `redis.pool.max-total` | `128` | Max Redis connections |\n| `redis.pool.max-idle` | `32` | Max idle Redis connections |\n| `redis.pool.min-idle` | `16` | Min idle Redis connections |\n| `WEBHOOK_SECRET_ENCRYPTION_KEY` | *(empty)* | AES-256-GCM key for webhook signing secret encryption at rest (base64, 32 bytes). Must match admin + events services. Generate: `openssl rand -base64 32` |\n| `EVENT_TTL_DAYS` | `90` | Redis TTL for `event:{id}` keys (days) |\n| `DELIVERY_TTL_DAYS` | `14` | Redis TTL for `delivery:{id}` keys (days) |\n\n### Webhook Event Emission\n\nThe runtime server emits events to the shared Redis dispatch queue for:\n- `reservation.denied` — reserve or decide returned DENY\n- `reservation.commit_overage` — commit actual exceeded reservation estimate\n- `reservation.expired` — reservation TTL expired without commit/release (via background sweeper)\n- `budget.exhausted` — remaining budget reached 0 after an operation\n- `budget.over_limit_entered` — scope entered over-limit state (debt \u003e overdraft_limit or ALLOW_IF_AVAILABLE cap)\n- `budget.debt_incurred` — commit/event created debt via ALLOW_WITH_OVERDRAFT\n\nThese events are delivered by `cycles-server-events` to webhook subscribers via HTTP POST with HMAC-SHA256 signing. Event emission is non-blocking — failures are logged but never affect the API response.\n\n**If the events service is down:** Events and deliveries accumulate in Redis with TTL (90d/14d). When the events service restarts, deliveries older than 24h are auto-failed. The admin and runtime servers continue operating normally.\n\n## Monitoring\n\n### Health Check\n\n```\nGET /actuator/health\n```\n\n### Prometheus Metrics\n\n```\nGET /actuator/prometheus\n```\n\nExposes JVM, HTTP, and Spring Boot metrics in Prometheus format. Both endpoints are unauthenticated. Configure your Prometheus scrape target to `http://\u003chost\u003e:7878/actuator/prometheus`.\n\n## Documentation\n\n- [Cycles Documentation](https://runcycles.io) — full docs site\n- [Deploy the Full Stack](https://runcycles.io/quickstart/deploying-the-full-cycles-stack) — deployment guide with server setup\n- [Server Configuration Reference](https://runcycles.io/configuration/server-configuration-reference-for-cycles) — all server configuration options\n- [`cycles-protocol-service/README.md`](cycles-protocol-service/README.md) — core concepts, authentication, error codes, and the Redis data model\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruncycles%2Fcycles-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruncycles%2Fcycles-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruncycles%2Fcycles-server/lists"}