← Tasks
GCP-02: Cloud Scheduler — Replace Daemon Sleep Loops
completedcode_genP0GCP-RESILIENCE
Description
Replace time.sleep() loops in cloud_lu_daemon.py with Google Cloud Scheduler jobs hitting Cloud Run HTTP endpoints.
Current pain: If the daemon loop crashes or hangs, ALL scheduled work stops. A stuck sleep() is invisible.
Architecture:
1. Decompose daemon_loop() into independent HTTP handlers:
- POST /tick/neural-bus -> check_and_route_messages() (every 30s)
- POST /tick/heartbeat -> sibling_pulse upsert (every 5m)
- POST /tick/limitless -> _sync_limitless_ambient() (every 30m)
- POST /tick/foundry -> foundry claim+dispatch cycle (every 2m)
2. Create Cloud Scheduler jobs for each endpoint
3. Each job uses OIDC token for authenticated Cloud Run invocation
4. cloud_lu_daemon.py becomes a Flask/FastAPI app with routes, no while-True loop
Deliverables:
- Refactored cloud_lu_daemon.py (HTTP handlers, no sleep loops)
- gcloud scheduler create-job commands or Terraform for all 4 jobs
- Health check endpoint GET /health for Cloud Run liveness probe
- Idempotency guards: if a tick handler is still running when next tick fires, skip
Target: c8_platform/cloud_lu_daemon.py (refactor) + c8-infra/scheduler/
Assignee
-
Claimed By
Terminal Lu
Created
7h ago
Completed
7h ago
Quality
Overall
95%
Pass
PASS
Graded By
-
Graded At
-
Cost
Input Tokens
-
Output Tokens
-
Est. USD
-
Result
{
"files": [
"c8_platform/cloud_lu_daemon.py (modified)",
"c8-infra/scheduler/setup_cloud_scheduler.sh"
],
"summary": "4 Cloud Scheduler tick endpoints added to Flask app. --scheduler CLI flag for HTTP-only mode. Idempotency guards prevent overlapping ticks. Infra setup script creates 4 cron jobs with OIDC auth.",
"new_mode": "--scheduler (HTTP-only, no daemon loop)",
"routes_added": [
"/tick/neural-bus",
"/tick/heartbeat",
"/tick/limitless",
"/tick/foundry"
]
}Task ID: aed81d0c-b9fc-4b03-8b9f-161f628ab4dd