Implement initial scan logic and council formation for WHOOSH project kickoffs

- Replace incremental sync with full scan for new repositories
- Add initial_scan status to bypass Since parameter filtering
- Implement council formation detection for Design Brief issues
- Add version display to WHOOSH UI header for debugging
- Fix Docker token authentication with trailing newline removal
- Add comprehensive council orchestration with Docker Swarm integration
- Include BACKBEAT prototype integration for distributed timing
- Support council-specific agent roles and deployment strategies
- Transition repositories to active status after content discovery

Key architectural improvements:
- Full scan approach for new project detection vs incremental sync
- Council formation triggered by chorus-entrypoint labeled Design Briefs
- Proper token handling and authentication for Gitea API calls
- Support for both initial discovery and ongoing task monitoring

This enables autonomous project kickoff workflows where Design Brief issues
automatically trigger formation of specialized agent councils for new projects.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude Code
2025-09-12 09:49:36 +10:00
parent b5c0deb6bc
commit 56ea52b743
74 changed files with 17778 additions and 236 deletions

View File

@@ -0,0 +1,25 @@
-- Rollback task-team integration enhancements
-- Drop task executions table
DROP TABLE IF EXISTS task_executions;
-- Drop triggers and functions
DROP TRIGGER IF EXISTS update_task_executions_updated_at ON task_executions;
DROP FUNCTION IF EXISTS update_updated_at_column();
-- Remove agent performance columns
ALTER TABLE agents DROP COLUMN IF EXISTS workload_capacity;
ALTER TABLE agents DROP COLUMN IF EXISTS current_tasks;
ALTER TABLE agents DROP COLUMN IF EXISTS success_rate;
-- Remove team composition data column
ALTER TABLE teams DROP COLUMN IF EXISTS composition_data;
ALTER TABLE teams DROP COLUMN IF EXISTS task_id;
-- Remove repository_id from tasks if it was added by this migration
-- (Leave it if it existed before since other migrations might depend on it)
-- Drop indexes
DROP INDEX IF EXISTS idx_agents_workload;
DROP INDEX IF EXISTS idx_agents_performance;
DROP INDEX IF EXISTS idx_teams_task_id;

View File

@@ -0,0 +1,97 @@
-- Enhance task-team integration for WHOOSH Phase 2
-- Add missing columns and relationships for team composition workflow
-- Add repository_id column to tasks table if not exists
-- (some tasks might not have this from the original migration)
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS repository_id UUID REFERENCES repositories(id) ON DELETE SET NULL;
-- Create index for repository_id if not exists
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_indexes WHERE indexname = 'idx_tasks_repository_id') THEN
CREATE INDEX idx_tasks_repository_id ON tasks(repository_id);
END IF;
END$$;
-- Update teams table to have better task linkage
-- Add task_id reference for current active task
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'teams' AND column_name = 'task_id') THEN
ALTER TABLE teams ADD COLUMN task_id UUID REFERENCES tasks(id) ON DELETE SET NULL;
CREATE INDEX idx_teams_task_id ON teams(task_id);
END IF;
END$$;
-- Add team status tracking for better workflow management
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'teams' AND column_name = 'composition_data') THEN
ALTER TABLE teams ADD COLUMN composition_data JSONB DEFAULT '{}';
END IF;
END$$;
-- Add performance metrics to agents table for better team matching
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'agents' AND column_name = 'workload_capacity') THEN
ALTER TABLE agents ADD COLUMN workload_capacity INTEGER DEFAULT 1;
ALTER TABLE agents ADD COLUMN current_tasks INTEGER DEFAULT 0;
ALTER TABLE agents ADD COLUMN success_rate FLOAT DEFAULT 0.0;
CREATE INDEX idx_agents_workload ON agents(workload_capacity, current_tasks);
CREATE INDEX idx_agents_performance ON agents(success_rate);
END IF;
END$$;
-- Create task execution tracking for better monitoring
CREATE TABLE IF NOT EXISTS task_executions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
task_id UUID NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
team_id UUID NOT NULL REFERENCES teams(id) ON DELETE CASCADE,
agent_id UUID REFERENCES agents(id) ON DELETE SET NULL,
-- Execution details
stage VARCHAR(50) NOT NULL DEFAULT 'analysis', -- analysis, planning, execution, review, complete
status VARCHAR(50) NOT NULL DEFAULT 'pending', -- pending, in_progress, completed, failed
-- Output and results
output_data JSONB DEFAULT '{}',
error_message TEXT,
-- Timing
started_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
completed_at TIMESTAMP WITH TIME ZONE,
duration_seconds INTEGER,
-- Metadata
metadata JSONB DEFAULT '{}',
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Indexes for task executions
CREATE INDEX IF NOT EXISTS idx_task_executions_task_id ON task_executions(task_id);
CREATE INDEX IF NOT EXISTS idx_task_executions_team_id ON task_executions(team_id);
CREATE INDEX IF NOT EXISTS idx_task_executions_agent_id ON task_executions(agent_id);
CREATE INDEX IF NOT EXISTS idx_task_executions_status ON task_executions(status);
CREATE INDEX IF NOT EXISTS idx_task_executions_stage ON task_executions(stage);
-- Add updated_at trigger for task_executions
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ language 'plpgsql';
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_trigger WHERE tgname = 'update_task_executions_updated_at') THEN
CREATE TRIGGER update_task_executions_updated_at
BEFORE UPDATE ON task_executions
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
END IF;
END$$;

View File

@@ -0,0 +1,32 @@
-- Rollback council-related tables
-- Drop triggers first
DROP TRIGGER IF EXISTS update_councils_updated_at ON councils;
DROP TRIGGER IF EXISTS update_council_agents_updated_at ON council_agents;
-- Drop function
DROP FUNCTION IF EXISTS update_updated_at_column();
-- Drop indexes
DROP INDEX IF EXISTS idx_councils_status;
DROP INDEX IF EXISTS idx_councils_created_at;
DROP INDEX IF EXISTS idx_councils_task_id;
DROP INDEX IF EXISTS idx_councils_repository;
DROP INDEX IF EXISTS idx_council_agents_council_id;
DROP INDEX IF EXISTS idx_council_agents_status;
DROP INDEX IF EXISTS idx_council_agents_role_name;
DROP INDEX IF EXISTS idx_council_agents_deployed;
DROP INDEX IF EXISTS idx_council_artifacts_council_id;
DROP INDEX IF EXISTS idx_council_artifacts_type;
DROP INDEX IF EXISTS idx_council_artifacts_status;
DROP INDEX IF EXISTS idx_council_decisions_council_id;
DROP INDEX IF EXISTS idx_council_decisions_type;
-- Drop tables in reverse dependency order
DROP TABLE IF EXISTS council_decisions;
DROP TABLE IF EXISTS council_artifacts;
DROP TABLE IF EXISTS council_agents;
DROP TABLE IF EXISTS councils;

View File

@@ -0,0 +1,119 @@
-- Add council-related tables for project kickoff management
-- Councils table: tracks project kickoff councils
CREATE TABLE IF NOT EXISTS councils (
id UUID PRIMARY KEY,
project_name VARCHAR(255) NOT NULL,
repository VARCHAR(500) NOT NULL,
project_brief TEXT NOT NULL,
constraints TEXT,
tech_limits TEXT,
compliance_notes TEXT,
targets TEXT,
status VARCHAR(50) NOT NULL DEFAULT 'forming',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
completed_at TIMESTAMPTZ,
-- Link to original task/issue
task_id UUID REFERENCES tasks(id) ON DELETE SET NULL,
issue_id BIGINT,
external_url TEXT,
-- Additional metadata
metadata JSONB,
-- Indexes
CONSTRAINT councils_status_check CHECK (status IN ('forming', 'active', 'completed', 'failed'))
);
-- Council agents table: tracks individual agents in each council
CREATE TABLE IF NOT EXISTS council_agents (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
council_id UUID NOT NULL REFERENCES councils(id) ON DELETE CASCADE,
agent_id VARCHAR(255) NOT NULL,
role_name VARCHAR(100) NOT NULL,
agent_name VARCHAR(255) NOT NULL,
required BOOLEAN NOT NULL DEFAULT true,
deployed BOOLEAN NOT NULL DEFAULT false,
status VARCHAR(50) NOT NULL DEFAULT 'pending',
service_id VARCHAR(255), -- Docker Swarm service ID
deployed_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
-- Unique constraint to prevent duplicate agents in the same council
UNIQUE(council_id, role_name),
-- Status constraint
CONSTRAINT council_agents_status_check CHECK (status IN ('pending', 'deploying', 'active', 'failed', 'removed'))
);
-- Council artifacts table: tracks outputs produced by councils
CREATE TABLE IF NOT EXISTS council_artifacts (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
council_id UUID NOT NULL REFERENCES councils(id) ON DELETE CASCADE,
artifact_type VARCHAR(50) NOT NULL,
artifact_name VARCHAR(255) NOT NULL,
content TEXT,
content_json JSONB,
produced_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
produced_by VARCHAR(255), -- Which agent/role produced this
status VARCHAR(50) NOT NULL DEFAULT 'draft',
-- Artifact types: kickoff_manifest, seminal_dr, scaffold_plan, gate_tests, etc.
CONSTRAINT council_artifacts_type_check CHECK (artifact_type IN ('kickoff_manifest', 'seminal_dr', 'scaffold_plan', 'gate_tests', 'hmmm_thread', 'slurp_sources', 'shhh_policy', 'ucxl_root')),
CONSTRAINT council_artifacts_status_check CHECK (status IN ('draft', 'review', 'approved', 'rejected'))
);
-- Council decisions table: tracks decision-making process
CREATE TABLE IF NOT EXISTS council_decisions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
council_id UUID NOT NULL REFERENCES councils(id) ON DELETE CASCADE,
decision_type VARCHAR(50) NOT NULL,
decision_title VARCHAR(255) NOT NULL,
context TEXT,
options JSONB, -- Array of decision options with pros/cons
chosen_option JSONB,
rationale TEXT,
consequences TEXT,
reversibility VARCHAR(20),
votes JSONB, -- Voting record by role
dissent JSONB, -- Dissenting opinions
decided_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT council_decisions_reversibility_check CHECK (reversibility IN ('high', 'medium', 'low', 'irreversible'))
);
-- Indexes for performance
CREATE INDEX IF NOT EXISTS idx_councils_status ON councils(status);
CREATE INDEX IF NOT EXISTS idx_councils_created_at ON councils(created_at);
CREATE INDEX IF NOT EXISTS idx_councils_task_id ON councils(task_id);
CREATE INDEX IF NOT EXISTS idx_councils_repository ON councils(repository);
CREATE INDEX IF NOT EXISTS idx_council_agents_council_id ON council_agents(council_id);
CREATE INDEX IF NOT EXISTS idx_council_agents_status ON council_agents(status);
CREATE INDEX IF NOT EXISTS idx_council_agents_role_name ON council_agents(role_name);
CREATE INDEX IF NOT EXISTS idx_council_agents_deployed ON council_agents(deployed);
CREATE INDEX IF NOT EXISTS idx_council_artifacts_council_id ON council_artifacts(council_id);
CREATE INDEX IF NOT EXISTS idx_council_artifacts_type ON council_artifacts(artifact_type);
CREATE INDEX IF NOT EXISTS idx_council_artifacts_status ON council_artifacts(status);
CREATE INDEX IF NOT EXISTS idx_council_decisions_council_id ON council_decisions(council_id);
CREATE INDEX IF NOT EXISTS idx_council_decisions_type ON council_decisions(decision_type);
-- Update timestamp triggers
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ language 'plpgsql';
CREATE TRIGGER update_councils_updated_at BEFORE UPDATE ON councils
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
CREATE TRIGGER update_council_agents_updated_at BEFORE UPDATE ON council_agents
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();