Skip to content

feat(chat): store an Admin's go-live switch and each agent's go-live permission (00443) - #1967

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-go-live-permission
Nov 2, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-go-live-permission

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

AUTONOMOUS-GO-LIVE PR 1: stores an Admin's go-live switch and each agent's go-live permission, with the ledger that holds an agent's daily limit. Migration 00443. Nothing reads it yet, so nothing changes: the precedence's exception comes in PR 5, behind CHAT_AUTO_GO_LIVE.

What changes (00443)

  • chat_settings gains the workspace switch:
    • auto_go_live_groups (the four go-live groups, distinct, as manager_execute_off);
    • auto_go_live_by, auto_go_live_at, auto_go_live_terms (the version of the responsibility text);
    • a check that a group can't be on without auto_go_live_at.
  • chat_agent_go_live: one row per allowed agent.
    • It holds the agent version it was given on, the daily limit (1–20, 5 unless set), the checksums of the agent's Library skills, and who gave it and when.
    • Read as the agent is (agent_id in chat_agents). The server writes it.
  • chat_agent_go_live_events: each step an agent takes live on its own (CMS draft, publish, webhook).
    • Status: reserved → done / failed, later taken_down.
    • It records what went live and the error.
    • A brand table: read with user_brand_ids().
  • RPCs (service role only):
    • reserve_agent_go_live takes a slot under pg_advisory_xact_lock per agent. It counts the last 24 hours' reserved, done and taken-down steps once per (draft, target). A (draft, target) already counted returns its row. It answers null when the agent is full.
    • finish_agent_go_live marks a step done or failed; a failed step frees its slot.
  • Types, schema.sql.
  • brand-access-policies: chat_agent_go_live is DEFERRED to BRAND-ACCESS PR 9 with the other agent tables.
  • Demo coverage: the events table is skipped, since no agent runs for a demo brand.

parseChatSettings reads the new columns in PR 5, with the precedence step. Reading them here would break Chat before the migration runs.

Related issue

None. AUTONOMOUS-GO-LIVE spec, PR 1.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. bash supabase/build-schema.sh: schema.sql matches.
  2. Server: brand-access-policies, brand-access-schema, demo/coverage and write-guard pass.
  3. On a dev database, select reserve_agent_go_live(...) five times for one agent with five drafts gives five ids. A sixth gives null. The same draft and target again returns its row. finish_agent_go_live(id, 'failed') frees a slot.

No visible change, no Help article.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes
  • yarn typecheck passes
  • yarn format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

CI passed on this branch (983b86a), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41355931759): schema is up to date; web format:check, lint, typecheck, all tests and yarn build pass; server lint, format:check and all tests pass.

🤖 Generated with Claude Code

…permission

AUTONOMOUS-GO-LIVE PR 1 (migration 00443), with nothing reading it yet:
chat_settings gains the workspace switch (auto_go_live_groups, who turned
it on, when, under which terms); chat_agent_go_live keeps an agent's
permission for the version it was given on, with its daily limit (1-20,
5 unless set); chat_agent_go_live_events keeps each step an agent takes
live on its own, read by brand access. reserve_agent_go_live and
finish_agent_go_live (service role) hold the daily limit under a lock per
agent, once per (draft, target); a failed step frees its slot. Types,
schema.sql, and the brand-access and demo coverage lists follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
gkhngyk previously approved these changes Nov 2, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

# Conflicts:
#	server/src/lib/brand-access-policies.test.js
#	supabase/schema.sql

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@gkhngyk
gkhngyk merged commit 246e49e into ansvisor:main Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants