Skip to main content

Goals and Background Execution

Norns supports long-term goal planning with autonomous background execution. This allows the supervisor to define goals with a definition of done, create granular execution plans, and run them autonomously while keeping users informed.

Architecture

┌─────────────────────────────────────────────────────────────┐
│ NornsSupervisor │
│ (Domain.GOAL routing) │
└─────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────┐
│ GoalDomainSupervisor │
│ Routes to specialized workers │
└─────────────────────────────────────────────────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Planning │ │ Execution │ │ Monitor │ │Communication│
│ Worker │ │ Worker │ │ Worker │ │ Worker │
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘


┌─────────────────────────────────────────────────────────────┐
│ norns-executor │
│ (Background execution service) │
└─────────────────────────────────────────────────────────────┘

Database Tables

goals

Core goal definitions with status tracking.

ColumnTypeDescription
goal_idUUIDPrimary key
user_idUUIDOwner
titleVARCHAR(500)Goal title
descriptionTEXTDetailed description
definition_of_doneTEXTSuccess criteria
statusVARCHAR(30)draft, planning, ready, active, paused, completed, failed, cancelled
priorityVARCHAR(5)P1-P5
deadlineTIMESTAMPTZOptional deadline
schedule_cronVARCHAR(100)Recurring schedule
progress_pctINTEGER0-100

plan_items

Individual steps in a goal's execution plan.

ColumnTypeDescription
plan_item_idUUIDPrimary key
goal_idUUIDParent goal
titleVARCHAR(500)Step title
action_typeVARCHAR(50)tool_call, synthesis, decision_point, user_approval, external_wait
tool_nameVARCHAR(100)Tool to execute
tool_paramsJSONBTool parameters
depends_onUUID[]Prerequisite steps
statusVARCHAR(30)pending, in_progress, completed, failed, skipped
execution_resultJSONBStep output

background_goals

Goals queued for autonomous execution.

ColumnTypeDescription
goal_idUUIDPrimary key
user_idUUIDOwner
titleVARCHAR(500)Goal title
plan_stepsJSONBSerialized plan
statusVARCHAR(50)pending, claimed, running, completed, failed
executor_idUUIDClaiming executor
context_snapshotJSONBUser context at creation time
current_stepINTEGERProgress tracking
percent_completeNUMERIC(5,2)0-100

Goal State Machine

draft → planning → ready → active ⟷ paused

completed | failed | cancelled

Workers

GoalPlanningWorker

Creates execution plans from goal definitions using LLM reasoning.

Capabilities:

  • Breaks down goals into actionable steps
  • Identifies tool calls needed
  • Sets up step dependencies
  • Estimates complexity

GoalExecutionWorker

Executes plan items step by step.

Action Types:

  • tool_call - Execute a Norns tool
  • synthesis - LLM reasoning/summarization
  • decision_point - Make an autonomous decision
  • user_approval - Pause and request user input
  • external_wait - Wait for external event

GoalMonitorWorker

Tracks goal progress and handles state changes.

Capabilities:

  • List active goals
  • Check progress
  • Pause/resume goals
  • Cancel goals
  • Detect blocked goals

GoalCommunicationWorker

Manages user communication.

Capabilities:

  • Send Slack status updates
  • Request approvals via Slack
  • Update goal thread with progress
  • Handle user replies

Available Tools

ToolDescription
create_goalCreate a new goal with title, description, and definition of done
query_goalsList goals by status, priority, or search
update_goalModify goal status, priority, or schedule
add_plan_stepAdd a step to a goal's plan
get_goal_statusGet detailed goal progress
execute_goal_stepManually trigger step execution
retry_plan_itemRetry a failed step

Background Executor Service

The norns-executor service runs as a separate container for crash isolation and scalability.

Components

ClaimManager

  • Redis-based distributed locking
  • 5-minute lease with 60-second heartbeat renewal
  • Prevents duplicate execution across replicas

GoalConsumer

  • Polls for pending goals
  • Claims and executes goals
  • Manages concurrency (default: 3 concurrent goals)

GoalRunner

  • Executes plan steps sequentially
  • Handles timeouts and failures
  • Reports progress to database

Configuration

Environment VariableDefaultDescription
EXECUTOR_CONCURRENCY3Max concurrent goals per instance
POLL_INTERVAL5Seconds between polling
EXECUTOR_MODELgpt-4oLLM for reasoning steps

Endpoints

EndpointDescription
GET /healthHealth check with active goal count
GET /metricsPrometheus-compatible metrics
GET /statusDetailed executor status

Usage Examples

Create a goal via Slack

@norns Create a goal to review all open PRs in the ravenhelm project.
Definition of done: All PRs have been reviewed and commented on.

Check goal progress

@norns What's the status of my active goals?

Pause a running goal

@norns Pause the PR review goal

Event Topics (Redpanda)

TopicDescription
norns.goals.createdNew goal queued
norns.goals.executionGoal claimed by executor
norns.goals.progressProgress updates
norns.goals.completedCompletion events
norns.executor.heartbeatExecutor liveness

Approval Workflow

Certain actions require user approval before execution:

  • File deletions
  • Git push operations
  • External API mutations
  • Steps marked with requires_approval: true

When approval is needed:

  1. Goal pauses at the approval step
  2. Slack message sent to user with approve/reject buttons
  3. User responds via Slack reaction or reply
  4. Goal resumes or cancels based on response