Overview
Stewards are automated maintenance agents that handle system tasks like code review, documentation upkeep, and error recovery. Stoneforge provides four built-in steward focuses, each specialized for a specific type of maintenance work.Built-in Steward Focuses
Merge Steward
Reviews and merges completed work branches. Runs tests, resolves conflicts, and auto-merges to main.
Docs Steward
Scans documentation for outdated content, broken links, and missing API docs. Auto-merges documentation fixes.
Recovery Steward
Monitors system health. Detects stuck tasks, orphaned processes, and stale worktrees. Creates recovery tasks.
Custom Steward
Executes user-defined workflow playbooks for specialized maintenance (dependency updates, code quality scans, etc.).
Merge Steward
Purpose
Automate code review and merge process for completed tasks.How It Works
Task Completion Trigger
When a worker completes a task (
sf task complete <task-id>), the task enters REVIEW status with mergeStatus: pending.Branch Sync
Daemon syncs the task’s branch with the target branch (usually
main) before spawning the steward.Review and Test
Steward:
- Resolves any merge conflicts
- Reviews changes against acceptance criteria
- Runs test suite (if configured)
- Checks for documentation updates
Configuration
Service Configuration
Customize merge behavior:Responsibilities
- Conflict Resolution: Resolve ALL merge conflicts, including complex logic conflicts
- Test Execution: Run test suite before merging (configurable)
- Acceptance Criteria Verification: Ensure all task acceptance criteria are met
- Documentation Check: Verify relevant docs were updated
- Fix Task Creation: Create detailed fix tasks when tests fail or conflicts can’t be resolved
- Branch Cleanup: Delete merged branches and clean up worktrees
Docs Steward
Purpose
Maintain documentation quality by detecting and fixing common issues.How It Works
Issue Detection
Scans for:
- Broken external links (HTTP 404, timeout)
- Broken internal links (missing files)
- Outdated API references (compare with code)
- Missing documentation for new APIs
- Inconsistent formatting
Configuration
Service Configuration
Responsibilities
- Link Validation: Check all markdown links (internal and external)
- API Documentation Coverage: Ensure all public APIs are documented
- Consistency Checks: Verify formatting, heading hierarchy, code block syntax
- Auto-Fix: Merge simple fixes automatically (broken links, formatting)
- Task Creation: Create documentation tasks for complex issues
Example Scan Output
Recovery Steward
Purpose
Monitor system health and recover from failures automatically.How It Works
Issue Detection
Detects:
- Stuck tasks (in
IN_PROGRESSfor >2 hours with no updates) - Orphaned agent sessions (agent crashed, session still active)
- Stale worktrees (directory exists but task is closed)
- Merge conflicts stuck in
testingstatus for >1 hour
Configuration
Responsibilities
- Stuck Task Detection: Find tasks with no progress updates
- Session Health: Detect crashed agent sessions
- Worktree Cleanup: Remove abandoned worktrees
- Merge Recovery: Restart stuck merge reviews
- Resource Monitoring: Track disk space, memory usage (optional)
- Alert Generation: Notify operators of critical issues
Detection Criteria
| Issue | Detection Rule | Recovery Action |
|---|---|---|
| Stuck task | IN_PROGRESS status, no updates for 2+ hours | Reset to OPEN, increment resumeCount |
| Orphaned session | Session marked running, agent process not found | Terminate session, cleanup worktree |
| Stale worktree | Worktree exists, task is CLOSED, branch merged | Remove worktree, delete local branch |
| Stuck merge | mergeStatus: testing, no updates for 1+ hour | Reset to pending, re-dispatch |
Example Recovery Report
Custom Steward
Purpose
Execute user-defined workflow playbooks for specialized maintenance tasks.How It Works
Custom stewards reference a Playbook (Workflow element) that defines step-by-step procedures:Playbook Structure
See the Playbooks Guide for detailed playbook creation.Use Cases
Dependency Management
Dependency Management
- Check for outdated npm/pip/cargo dependencies
- Create update tasks for major version bumps
- Auto-update patch versions
Code Quality
Code Quality
- Run linters and type checkers
- Detect code smells with static analysis
- Create fix tasks for violations
Security Scanning
Security Scanning
- Run
npm auditorsnyk test - Check for hardcoded secrets
- Validate SSL certificates
Repository Cleanup
Repository Cleanup
- Delete stale branches
- Archive old issues/PRs
- Clean up temporary files
Metrics Collection
Metrics Collection
- Gather code coverage stats
- Track bundle size over time
- Generate performance reports
Steward Lifecycle
Registration and Startup
Trigger and Dispatch
Deactivation
Best Practices
Start with Merge Steward
Merge steward provides the most immediate value by automating code review and merging.
Add Docs Steward for Large Codebases
If you have >50 documentation files, a docs steward prevents documentation drift.
Recovery Steward for Production
Essential for long-running systems to detect and recover from stuck tasks and orphaned sessions.
Custom Stewards for Specialized Needs
Use playbooks for project-specific maintenance (dependency updates, security scans, etc.).
Steward Concurrency
Multiple Stewards of Same Focus
You can register multiple stewards with the same focus:Monitoring Stewards
List Active Stewards
Query Steward Activity
Troubleshooting
Steward not triggering on events
Steward not triggering on events
Symptom: Tasks complete but merge steward never triggersPossible causes:
- Steward has
maxConcurrentTasks: 0(disabled) - Trigger event doesn’t match (e.g.,
task_createdinstead oftask_completed) - Dispatch daemon not running
Steward stuck in infinite loop
Steward stuck in infinite loop
Symptom: Steward keeps processing the same task repeatedlyCause: Task status not updating correctly after steward completesSolution: Ensure steward properly closes or updates task status:
Custom steward playbook errors
Custom steward playbook errors
Symptom: Custom steward spawns but doesn’t execute playbookCause: Playbook has syntax errors or bash commands failSolution: Test playbook commands manually:
Related Resources
Merge Review Guide
Detailed merge steward workflow
Playbooks
Create custom steward playbooks
Custom Agents
Customize steward prompts and behaviors