feat(store): record agent instances and query results by checker

Refs #82

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 12:54:56 +01:00
1 parent db8bdb3a62
commit 53ff2a628d
7 files changed
+289 -2

No files matched your search

@@ -0,0 +1,24 @@
-- +goose Up
-- Processes running with an agent token. Several may share a token; check
-- results name the instance that ran them.
CREATE TABLE agent_instances (
id uuid PRIMARY KEY,
agent_id uuid NOT NULL REFERENCES agents (id) ON DELETE CASCADE,
org_id uuid REFERENCES orgs (id) ON DELETE CASCADE,
release text NOT NULL DEFAULT '',
started_at timestamptz NOT NULL DEFAULT now(),
last_seen_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX agent_instances_agent_idx ON agent_instances (agent_id, last_seen_at DESC);
ALTER TABLE agent_instances ENABLE ROW LEVEL SECURITY;
ALTER TABLE agent_instances FORCE ROW LEVEL SECURITY;
-- Platform instances serve every organization and are visible to all, like
-- platform regions.
CREATE POLICY agent_instances_read ON agent_instances FOR SELECT
USING (app_scope_system() OR org_id IS NULL OR org_id = app_org_id());
CREATE POLICY agent_instances_write ON agent_instances FOR ALL
USING (app_scope_system()) WITH CHECK (app_scope_system());
-- +goose Down
DROP TABLE agent_instances;