Files
Codewalkers/drizzle/0013_add_proposals_table.sql
Lukas May 43e2c8b0ba fix(agent): Eliminate race condition in completion handling
PROBLEM:
- Agents completing with questions were incorrectly marked as "crashed"
- Race condition: polling handler AND crash handler both called handleCompletion()
- Caused database corruption and lost pending questions

SOLUTION:
- Add completion mutex in OutputHandler to prevent concurrent processing
- Remove duplicate completion call from crash handler
- Only one handler executes completion logic per agent

TESTING:
- Added mutex-completion.test.ts with 4 test cases
- Verified mutex prevents concurrent access
- Verified lock cleanup on exceptions
- Verified different agents can process concurrently

FIXES: residential-cuckoo and 12+ other agents stuck in crashed state
2026-02-08 15:51:32 +01:00

16 lines
488 B
SQL

CREATE TABLE `proposals` (
`id` text PRIMARY KEY NOT NULL,
`agent_id` text NOT NULL REFERENCES `agents`(`id`) ON DELETE cascade,
`initiative_id` text NOT NULL REFERENCES `initiatives`(`id`) ON DELETE cascade,
`target_type` text NOT NULL,
`target_id` text,
`title` text NOT NULL,
`summary` text,
`content` text,
`metadata` text,
`status` text NOT NULL DEFAULT 'pending',
`sort_order` integer NOT NULL DEFAULT 0,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);