Files
accounted/supabase/migrations/20260505120000_drop_agent_auto_commit.sql
T
Jakob WennbergandClaude Opus 4.7 b05f0e59b9 fix(mcp): correct fiscal_periods column ref + remove agent auto-commit (#394)
* fix(mcp): correct fiscal_periods column ref + remove agent auto-commit

The MCP `gnubok_list_fiscal_periods` tool selected a non-existent
`fiscal_periods.status` column, causing `column fiscal_periods.status
does not exist` errors when agents called it. Fixed by selecting the
real columns (`is_closed`, `locked_at`, `closed_at`,
`opening_balances_set`) and deriving `status` in code.

Also removes the agent auto-commit feature (settings card, gating logic,
DB columns, tests). In its current shape only `create_customer` was
auto-commitable, so the toggle changed nothing meaningful in practice
while implying a level of agent autonomy that wasn't actually granted.
The risk-tier infrastructure on `pending_operations` (actor model,
risk_level) is kept since it's still used by the /pending UI filters.

Migration `20260505120000_drop_agent_auto_commit.sql` drops:
  - pending_operations.auto_commit_eligible
  - pending_operations.auto_committed_at
  - company_settings.agent_auto_commit_enabled
  - company_settings.agent_auto_commit_max_amount

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(mcp): explicitly pick fields in gnubok_list_fiscal_periods response

Greptile flagged that `...p` spreads raw DB columns (`is_closed`,
`locked_at`, `closed_at`) into the tool response alongside the
derived `status`. Drop the spread for an explicit field list so the
tool contract is the derived status only — agents don't need to
reason about raw columns, and future SELECT additions won't silently
leak.

Also drops `closed_at` from the SELECT since it wasn't read.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 21:16:01 +02:00

36 lines
1.5 KiB
SQL

-- Migration: Drop agent auto-commit feature.
--
-- Removes the columns and constraints introduced by:
-- - 20260430120000_pending_operations_actor_and_risk.sql (auto_commit_*)
-- - 20260501120000_company_settings_auto_commit.sql (agent_auto_commit_*)
--
-- The actor model and risk_level are kept — those are still useful for
-- attribution and the /pending UI's "Hög risk" filter. We're only ripping
-- out the auto-commit half.
-- =============================================================================
-- 1. pending_operations: drop auto-commit columns + supporting constraint/index
-- =============================================================================
ALTER TABLE public.pending_operations
DROP CONSTRAINT IF EXISTS pending_ops_auto_commit_status;
DROP INDEX IF EXISTS public.idx_pending_ops_auto_committed;
ALTER TABLE public.pending_operations
DROP COLUMN IF EXISTS auto_commit_eligible,
DROP COLUMN IF EXISTS auto_committed_at;
-- =============================================================================
-- 2. company_settings: drop the opt-in toggle and threshold
-- =============================================================================
ALTER TABLE public.company_settings
DROP COLUMN IF EXISTS agent_auto_commit_enabled,
DROP COLUMN IF EXISTS agent_auto_commit_max_amount;
-- =============================================================================
-- 3. PostgREST schema reload
-- =============================================================================
NOTIFY pgrst, 'reload schema';