Skip to content

revert(server): drop goals primitive — agents are the grouping concept#823

Merged
buremba merged 1 commit into
mainfrom
revert/drop-goals-primitive
May 17, 2026
Merged

revert(server): drop goals primitive — agents are the grouping concept#823
buremba merged 1 commit into
mainfrom
revert/drop-goals-primitive

Conversation

@buremba
Copy link
Copy Markdown
Member

@buremba buremba commented May 17, 2026

Summary

Goals (added in #813) had no behavior of their own — just a nullable watchers.goal_id FK pointing at a parallel goals table plus a parallel CRUD surface. Agents already encapsulate the watcher-grouping use case via watchers.agent_id, so the goals layer was redundant.

  • User feedback in-thread: "agents already encapsulate this properly" — each watcher has agent_id → grouped under an agent → that IS the grouping concept.
  • The Mac app already stopped using goals in lobu-ai/owletto#151.
  • The primitive never shipped in a release: v7.0.0 doesn't include it, and v7.1.0 (release-please PR chore(main): release lobu 7.1.0 #724) is still open. Safe to revert.

What's gone

  • db/migrations/20260517160000_drop_goals_primitive.sql — drops watchers.goal_id + the goals table. Reversible (verified with dbmate updownup).
  • Embedded-schema patch entry goals-primitive (in packages/server/src/db/embedded-schema-patches.ts) — removed entirely; dev embedded DBs that previously ran it should re-init or drop the orphan table manually.
  • packages/server/src/tools/admin/manage_goals.ts and its registration in tools/admin/index.ts + auth/tool-access.ts.
  • client.goals SDK namespace (sandbox/namespaces/goals.ts) and the goals.* entries in sandbox/method-metadata.ts.
  • goal_id from manage_watchers.ts (create/update/list projection), get_watchers.ts (SELECT + WatcherQueryRow + return shape), and WatcherMetadata in types/watchers.ts.
  • The goals-crud integration test.

Untouched

Diff size

16 files changed, 49 insertions(+), 1072 deletions(-).

Test plan

  • make typecheck clean
  • make build-packages clean
  • dbmate up (against fresh local Postgres) applies through the new revert migration cleanly
  • dbmate down then dbmate up re-applies — reversible
  • db/schema.sql regenerated via dbmate dump + scripts/normalize-schema.sh, with the schema_migrations.version varchar(128) patch reapplied
  • Integration suite (CI) — goals-crud.test.ts removed; nothing else exercises goals

Summary by CodeRabbit

  • Chores
    • Removed the goals feature from the platform, including all related management tools and functionality.
    • Removed goal associations from watchers—the goal_id field is no longer available.
    • Cleaned up database schema and removed associated tests.

Review Change Stack

Goals (added in #813) had no behavior of their own — just a nullable FK
from watchers.goal_id into a parallel `goals` table plus a parallel CRUD
surface. Agents already encapsulate the watcher-grouping use case via
watchers.agent_id; goals were the redundant layer. The Mac app stopped
using the primitive in lobu-ai/owletto#151, and the primitive never
shipped in a release (v7.0.0 doesn't include it; v7.1.0 is still open).

Removed:
- db/migrations/20260517160000_drop_goals_primitive.sql (drops the
  watchers.goal_id column and the goals table; reversible)
- packages/server/src/db/embedded-schema-patches.ts: drop the
  `goals-primitive` patch entry
- packages/server/src/tools/admin/manage_goals.ts and its registration
- packages/server/src/sandbox/namespaces/goals.ts (client.goals SDK)
  and its method-metadata entries
- goal_id from manage_watchers.ts (create/update/list), get_watchers.ts,
  and WatcherMetadata
- manage_goals from auth/tool-access scope tables
- goals-crud integration test

Untouched: the dispatcher (#814), the watcher schema additions from
#811, and packages/owletto (separate submodule).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

📝 Walkthrough

Walkthrough

This PR removes the goals feature entirely from the codebase, including the public.goals database table, watchers.goal_id foreign key relationship, SDK namespace wrappers, manage_goals tool, and all associated type definitions and access control policies.

Changes

Goals Feature Removal

Layer / File(s) Summary
Database Schema and Migration
db/migrations/20260517160000_drop_goals_primitive.sql, db/schema.sql
Migration file drops the public.goals table, public.watchers.goal_id column, and related indexes/constraints; schema is updated to reflect the removal with down-migration to recreate objects.
Type and Contract Updates
packages/server/src/types/watchers.ts, packages/server/src/sandbox/namespaces/watchers.ts
WatcherMetadata, WatcherCreateInput, and WatcherUpdateInput remove the optional goal_id field, removing the FK reference to goals.
SDK Namespace and Client Removal
packages/server/src/sandbox/namespaces/goals.ts, packages/server/src/sandbox/namespaces/index.ts, packages/server/src/sandbox/client-sdk.ts, packages/server/src/__tests__/setup/test-mcp-client.ts
Goals namespace module is deleted; buildGoalsNamespace factory and GoalsNamespace type are removed from SDK construction and test client; ClientSDK interface no longer declares goals property.
Tool Implementation Updates
packages/server/src/tools/admin/manage_goals.ts, packages/server/src/tools/admin/index.ts, packages/server/src/tools/admin/manage_watchers.ts
manage_goals tool is removed and unregistered; manage_watchers schema, creation, updates, and list queries remove goal_id handling and validation.
Query, Metadata, and Access Control Cleanup
packages/server/src/tools/get_watchers.ts, packages/server/src/sandbox/method-metadata.ts, packages/server/src/auth/tool-access.ts, packages/server/src/db/embedded-schema-patches.ts
Watcher queries drop goal_id from typing and SQL projections; goals.* method entries removed from metadata; manage_goals actions removed from access control policies; goals-primitive patch removed from embedded DB bootstrap.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • lobu-ai/lobu#813: Introduced the "goals primitive" feature that this PR removes, including the public.goals table, watchers.goal_id FK relationship, and SDK/tool surface.

Suggested labels

skip-size-check

Poem

🐰 A feature once bloomed in the goals, so grand,
But now it retreats from this database land,
With FK and indexes now cleared from sight,
The schema finds peace, the removal is right—
From table to tool, we've tidied the night! 🌙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: removing the goals primitive and explaining the rationale (agents are the grouping concept).
Description check ✅ Passed The description comprehensively covers all required sections: Summary explains the motivation and redundancy, Test plan checkbox items completed, and Notes section includes context and follow-ups.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert/drop-goals-primitive

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@db/migrations/20260517160000_drop_goals_primitive.sql`:
- Around line 8-45: The down path in this migration is misleadingly reversible
because DROP TABLE public.goals and DROP COLUMN watchers.goal_id in the up
section permanently delete data; update the migration to either (A) perform a
safe archive/backfill step before dropping (e.g., copy public.goals and
watchers.goal_id into an archive table or JSON blob and restore it in the down
path) by adding an archival step before DROP TABLE public.goals and a
corresponding restore in CREATE TABLE and ALTER TABLE in the down section, or
(B) mark the migration as irreversible by removing the CREATE/ALTER statements
from the down section and documenting/raising an irreversible migration error;
locate the relevant statements (DROP TABLE public.goals, DROP INDEX
idx_watchers_goal_id, DROP COLUMN goal_id on public.watchers, and the CREATE
TABLE/ALTER TABLE in the down path) and implement one of these two options so
the migration does not claim to be data-reversible while actually destroying
data.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4861a471-f09e-4bda-8203-42544661a673

📥 Commits

Reviewing files that changed from the base of the PR and between 175c88d and 96ba489.

📒 Files selected for processing (16)
  • db/migrations/20260517160000_drop_goals_primitive.sql
  • db/schema.sql
  • packages/server/src/__tests__/integration/watchers/goals-crud.test.ts
  • packages/server/src/__tests__/setup/test-mcp-client.ts
  • packages/server/src/auth/tool-access.ts
  • packages/server/src/db/embedded-schema-patches.ts
  • packages/server/src/sandbox/client-sdk.ts
  • packages/server/src/sandbox/method-metadata.ts
  • packages/server/src/sandbox/namespaces/goals.ts
  • packages/server/src/sandbox/namespaces/index.ts
  • packages/server/src/sandbox/namespaces/watchers.ts
  • packages/server/src/tools/admin/index.ts
  • packages/server/src/tools/admin/manage_goals.ts
  • packages/server/src/tools/admin/manage_watchers.ts
  • packages/server/src/tools/get_watchers.ts
  • packages/server/src/types/watchers.ts
💤 Files with no reviewable changes (13)
  • packages/server/src/tools/admin/manage_goals.ts
  • packages/server/src/sandbox/namespaces/index.ts
  • packages/server/src/sandbox/method-metadata.ts
  • packages/server/src/sandbox/namespaces/goals.ts
  • packages/server/src/tests/integration/watchers/goals-crud.test.ts
  • packages/server/src/sandbox/namespaces/watchers.ts
  • packages/server/src/db/embedded-schema-patches.ts
  • packages/server/src/auth/tool-access.ts
  • packages/server/src/sandbox/client-sdk.ts
  • packages/server/src/tools/admin/index.ts
  • packages/server/src/types/watchers.ts
  • packages/server/src/tools/get_watchers.ts
  • packages/server/src/tests/setup/test-mcp-client.ts

Comment on lines +8 to +45
DROP INDEX IF EXISTS idx_watchers_goal_id;

ALTER TABLE public.watchers
DROP COLUMN IF EXISTS goal_id;

DROP INDEX IF EXISTS idx_goals_organization_id;

DROP TABLE IF EXISTS public.goals;

-- migrate:down

CREATE TABLE public.goals (
id bigserial PRIMARY KEY,
organization_id text NOT NULL REFERENCES public.organization(id) ON DELETE CASCADE,
slug text NOT NULL,
name text NOT NULL,
description text,
status text NOT NULL DEFAULT 'active',
template_key text,
metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone NOT NULL DEFAULT now(),

CONSTRAINT goals_status_check
CHECK (status IN ('active', 'paused', 'archived')),
CONSTRAINT goals_org_slug_unique
UNIQUE (organization_id, slug)
);

CREATE INDEX idx_goals_organization_id
ON public.goals (organization_id);

ALTER TABLE public.watchers
ADD COLUMN goal_id bigint REFERENCES public.goals(id) ON DELETE SET NULL;

CREATE INDEX idx_watchers_goal_id
ON public.watchers (goal_id)
WHERE goal_id IS NOT NULL;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

This rollback path is schema-reversible, not data-reversible.

migrate:up permanently deletes public.goals rows and every watchers.goal_id value, but migrate:down only recreates empty structures. Any environment that applied 20260517150000 and created goal data will lose it on rollback or on an up/down/up cycle. Please either archive/backfill that data before dropping it, or explicitly treat this as an irreversible migration instead of shipping a misleading down path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@db/migrations/20260517160000_drop_goals_primitive.sql` around lines 8 - 45,
The down path in this migration is misleadingly reversible because DROP TABLE
public.goals and DROP COLUMN watchers.goal_id in the up section permanently
delete data; update the migration to either (A) perform a safe archive/backfill
step before dropping (e.g., copy public.goals and watchers.goal_id into an
archive table or JSON blob and restore it in the down path) by adding an
archival step before DROP TABLE public.goals and a corresponding restore in
CREATE TABLE and ALTER TABLE in the down section, or (B) mark the migration as
irreversible by removing the CREATE/ALTER statements from the down section and
documenting/raising an irreversible migration error; locate the relevant
statements (DROP TABLE public.goals, DROP INDEX idx_watchers_goal_id, DROP
COLUMN goal_id on public.watchers, and the CREATE TABLE/ALTER TABLE in the down
path) and implement one of these two options so the migration does not claim to
be data-reversible while actually destroying data.

@buremba buremba merged commit f5dee4e into main May 17, 2026
22 of 26 checks passed
@buremba buremba deleted the revert/drop-goals-primitive branch May 17, 2026 19:24
buremba added a commit that referenced this pull request May 17, 2026
Pulls in #823 (revert goals primitive), #824 (auto-provision default agent
+ manual trigger), #825 (owletto submodule bump to #154). Submodule
merged origin/main into our feat/chrome-debugger-executor branch
separately; bumps the parent's submodule pointer to the merge SHA so
both the executor work and main's recent owletto changes (Mac app
LobuClient + connection-settings UI rework + drop default-form-layout)
ship together.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants