Skip to content

feat(schema): agent-observability tables (obs_messages/obs_contacts) — provenance record - #66

Merged
BIBOYANG425 merged 1 commit into
mainfrom
feat/agent-observability-schema
Jul 13, 2026
Merged

feat(schema): agent-observability tables (obs_messages/obs_contacts) — provenance record#66
BIBOYANG425 merged 1 commit into
mainfrom
feat/agent-observability-schema

Conversation

@BIBOYANG425

@BIBOYANG425 BIBOYANG425 commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Provenance record for the message-observability schema consumed by george's obs wiring (companion PR in the george repo).

  • Two RLS-sealed tables (obs_messages, obs_contacts) + four read RPCs (stats/series/conversation-count/inbox).
  • Already applied to the live project (ujkaregrwrppaehvbahf) via the Supabase MCP on 2026-07-13; idempotent (IF NOT EXISTS / CREATE OR REPLACE), so re-applying is a no-op.
  • Deny-all RLS + anon/authenticated grants revoked, matching this project's internal-table pattern (service-role only).
  • Source: the imessage-agent-observability boilerplate's packages/core/schema.sql. bia-admin owns the schema; george ships none (its schema-ownership guard stays green).

Security advisors after apply: no new ERROR/WARN; the obs tables show only the expected INFO rls_enabled_no_policy (intended for service-role-only deny-all).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added message observability for tracking inbound and outbound conversations across channels.
    • Added conversation history with contact details, latest-message previews, timestamps, and search support.
    • Added reporting capabilities for message totals, inbound/outbound activity, conversation counts, and time-based trends.
    • Added support for message metadata, media references, and opt-out status.
    • Applied access controls to protect observability data.

…tacts)

Provenance record for the message-observability tables + read RPCs consumed by
george's obs wiring. Already applied to the live project via Supabase MCP on
2026-07-13; idempotent, so re-applying is a no-op. bia-admin owns the schema;
george ships none.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bia-admin-bia-admin Ready Ready Preview, Comment Jul 13, 2026 10:09pm

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a Supabase migration with agent-scoped message and contact tables, indexes, service-role-only access, and SQL functions for message statistics, time-series aggregation, conversation counts, and searchable conversation listings.

Changes

Agent observability

Layer / File(s) Summary
Observability tables and indexes
supabase/migrations/20260713000000_agent_observability_schema.sql
Creates obs_messages and obs_contacts with metadata, timestamps, constraints, agent-scoped keys, and supporting indexes.
Service-role access controls
supabase/migrations/20260713000000_agent_observability_schema.sql
Enables RLS and restricts table and sequence access to service_role.
Reporting and conversation functions
supabase/migrations/20260713000000_agent_observability_schema.sql
Adds functions for channel statistics, conversation counts, time-series message totals, and searchable latest-message conversation results.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the new agent-observability schema and mentions the added tables, which are the main change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-observability-schema

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@BIBOYANG425
BIBOYANG425 merged commit 4f6bed1 into main Jul 13, 2026
4 of 5 checks passed

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 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 `@supabase/migrations/20260713000000_agent_observability_schema.sql`:
- Around line 52-56: Add explicit, idempotently guarded deny-all FOR ALL RLS
policies for the anon and authenticated API roles on both obs_messages and
obs_contacts. Each policy must use USING (false) and WITH CHECK (false), while
preserving service-role access and the existing RLS enablement.
- Around line 63-65: Restrict the observability RPC functions, including
obs_message_stats and the other functions defined in this migration, to
service_role execution only. After each function definition, revoke EXECUTE from
PUBLIC, anon, and authenticated, then grant EXECUTE explicitly to service_role;
do not rely on table privilege revocations for this boundary.
🪄 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

Run ID: 151cba05-23bc-4f12-8d4d-d5bf1a0ad80b

📥 Commits

Reviewing files that changed from the base of the PR and between 50de988 and 46921b7.

📒 Files selected for processing (1)
  • supabase/migrations/20260713000000_agent_observability_schema.sql

Comment on lines +52 to +56
-- RLS deny-all + revoke Data API grants: matches this project's internal-table
-- pattern (service-role bypasses RLS and keeps full access; anon/authenticated
-- get neither rows nor privilege).
alter table obs_messages enable row level security;
alter table obs_contacts enable row level security;

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Add explicit deny-all RLS policies.

RLS is enabled, but this migration defines no policies. Add idempotently guarded FOR ALL policies with USING (false) and WITH CHECK (false) for the API roles on both tables. As per coding guidelines, files matching supabase/migrations/**/*.sql must add RLS policies in the same migration and default to deny.

🤖 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 `@supabase/migrations/20260713000000_agent_observability_schema.sql` around
lines 52 - 56, Add explicit, idempotently guarded deny-all FOR ALL RLS policies
for the anon and authenticated API roles on both obs_messages and obs_contacts.
Each policy must use USING (false) and WITH CHECK (false), while preserving
service-role access and the existing RLS enablement.

Source: Coding guidelines

Comment on lines +63 to +65
create or replace function obs_message_stats(since timestamptz, agent text default 'default')
returns table (channel text, inbound bigint, outbound bigint, total bigint, conversations bigint)
language sql stable as $$

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Restrict RPC execution to service_role.

These functions inherit PUBLIC EXECUTE access. Revoke EXECUTE from PUBLIC, anon, and authenticated, then grant it explicitly to service_role; revoking table privileges alone does not enforce the stated RPC access boundary.

Suggested ACL hardening
+revoke all on function public.obs_message_stats(timestamptz, text) from public, anon, authenticated;
+grant execute on function public.obs_message_stats(timestamptz, text) to service_role;
+revoke all on function public.obs_conversation_count(timestamptz, text) from public, anon, authenticated;
+grant execute on function public.obs_conversation_count(timestamptz, text) to service_role;
+revoke all on function public.obs_message_series(timestamptz, text, text) from public, anon, authenticated;
+grant execute on function public.obs_message_series(timestamptz, text, text) to service_role;
+revoke all on function public.obs_conversations(text, integer, text) from public, anon, authenticated;
+grant execute on function public.obs_conversations(text, integer, text) to service_role;

Also applies to: 78-80, 86-88, 100-110

🤖 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 `@supabase/migrations/20260713000000_agent_observability_schema.sql` around
lines 63 - 65, Restrict the observability RPC functions, including
obs_message_stats and the other functions defined in this migration, to
service_role execution only. After each function definition, revoke EXECUTE from
PUBLIC, anon, and authenticated, then grant EXECUTE explicitly to service_role;
do not rely on table privilege revocations for this boundary.

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.

1 participant