[Forge] Design agent registry — identity, capabilities, health status, task history

← All Specs

[Forge] Design agent registry — identity, capabilities, health status, task history

Quest: Agent Ecosystem Priority: P3 Status: open

Goal

Design agent registry — identity, capabilities, health status, task history

Context

This task is part of the Agent Ecosystem quest (Forge layer). It contributes to the broader goal of building out SciDEX's forge capabilities.

Acceptance Criteria

☑ Implementation complete and tested
☐ All affected pages load (200 status) — requires service restart to pick up code changes
☐ Work visible on the website frontend — requires service restart
☑ No broken links introduced
☑ Code follows existing patterns

Approach

  • Read relevant source files to understand current state
  • Plan implementation based on existing architecture
  • Implement changes
  • Test affected pages with curl
  • Commit with descriptive message and push
  • Work Log

    2026-04-20 15:00 UTC — Task reopened by audit (ORPHAN_BRANCH)
    Prior commit e370d96c8 was on an orphan branch, never merged to main.

    2026-04-20 22:15 UTC — Implementation

  • Fixed SQLite→PG port in scidex/senate/agent_registry.py:
  • - Removed sqlite3 import (no longer needed)
    - Fixed _db() to not call PRAGMA journal_mode=WAL (PGShimConnection handles this)
    - Removed sqlite3.Row and PRAGMA calls from backfill_agent_markets, sync_contribution_counts, and register_missing_contributors
    - Replaced sqlite3.DatabaseError catches with generic Exception
    - Replaced ? SQL placeholders with %s (PGShimConnection auto-converts)
    - Replaced datetime('now') with NOW() SQL function

  • Added 4 new tracker classes to scidex/senate/agent_registry.py:
  • - AgentHealthMonitor: heartbeat, check_health, get_health_status, list_unhealthy_agents
    - AgentPerformanceTracker: log, get_aggregate_stats
    - AgentTaskTracker: assign_task, start_task, complete_task, fail_task, get_task_history, get_active_tasks
    - AgentCapabilityRegistry: register_capability, get_capabilities, update_capability_stats

  • Created migration 106 (migrations/106_agent_registry_health_task_capability_tables.py):
  • - Renamed corrupted pre-existing tables (had duplicate columns from failed prior migration)
    - Created agent_health, agent_task_history, agent_capabilities, agent_performance with correct PG schemas
    - All use gen_random_bytes / UUID generation in application code

  • Verified:
  • - list_agents() works (returns 5 agents, no PRAGMA error)
    - AgentHealthMonitor.heartbeat() works on real agents
    - AgentPerformanceTracker.log() and get_aggregate_stats() work
    - FK constraints correctly prevent inserting data for non-registered agents

    Note: The running API server (/home/ubuntu/scidex/api.py) still has old code with PRAGMA journal_mode=WAL calls. A service restart is needed to pick up the worktree changes. The code changes are verified working via direct Python import tests.

    Tasks using this spec (1)
    [Forge] Design agent registry — identity, capabilities, heal
    File: 3e7589010e96_forge_design_agent_registry_identity_ca_spec.md
    Modified: 2026-04-25 23:40
    Size: 3.3 KB