Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/app/migrations/0001_app_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ CREATE TABLE app.connections (tenant_id uuid NOT NULL REFERENCES app.tenants(id)
CREATE TABLE app.github_installations (installation_id bigint PRIMARY KEY, tenant_id uuid NOT NULL REFERENCES app.tenants(id) ON DELETE CASCADE, account_login text NOT NULL, account_type text NOT NULL, state text NOT NULL CHECK (state IN ('active','suspended')), updated_at timestamptz NOT NULL DEFAULT now(), UNIQUE (tenant_id,installation_id));
CREATE TABLE app.github_setup_states (tenant_id uuid NOT NULL REFERENCES app.tenants(id) ON DELETE CASCADE, nonce text NOT NULL, expires_at timestamptz NOT NULL, used_at timestamptz, PRIMARY KEY (tenant_id,nonce));

CREATE TABLE app.jobs (tenant_id uuid NOT NULL REFERENCES app.tenants(id) ON DELETE CASCADE, id uuid NOT NULL, name text NOT NULL, slug text NOT NULL, encrypted_prompt_template text NOT NULL, encrypted_run_name_template text NOT NULL DEFAULT '', execution_target jsonb NOT NULL, concurrency_limit integer NOT NULL CHECK (concurrency_limit >= 1), enabled boolean NOT NULL DEFAULT true, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,slug));
CREATE TABLE app.jobs (tenant_id uuid NOT NULL REFERENCES app.tenants(id) ON DELETE CASCADE, id uuid NOT NULL, name text NOT NULL, slug text NOT NULL, encrypted_prompt_template text NOT NULL, encrypted_run_name_template text NOT NULL DEFAULT '', execution_target jsonb NOT NULL, model text NOT NULL DEFAULT '', effort text NOT NULL DEFAULT '', concurrency_limit integer NOT NULL CHECK (concurrency_limit >= 1), enabled boolean NOT NULL DEFAULT true, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,slug));
CREATE TABLE app.triggers (tenant_id uuid NOT NULL, id uuid NOT NULL, job_id uuid NOT NULL, kind text NOT NULL CHECK (kind IN ('manual','schedule','webhook','jobLifecycle')), slug text NOT NULL, enabled boolean NOT NULL DEFAULT true, config jsonb NOT NULL DEFAULT '{}', position integer NOT NULL DEFAULT 0, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,job_id,slug), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE);
CREATE TABLE app.invocations (tenant_id uuid NOT NULL, id uuid NOT NULL, job_id uuid NOT NULL, source text NOT NULL CHECK (source IN ('manual','schedule','webhook','jobLifecycle')), claim_key text NOT NULL, trigger_id uuid NOT NULL, context jsonb NOT NULL, occurrence jsonb, created_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,job_id,claim_key), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE, FOREIGN KEY (tenant_id,trigger_id) REFERENCES app.triggers(tenant_id,id));
CREATE TABLE app.job_runs (tenant_id uuid NOT NULL, id uuid NOT NULL, job_id uuid NOT NULL, invocation_id uuid NOT NULL, state text NOT NULL CHECK (state IN ('queued','starting','running','blocked','stopping','succeeded','failed','stopped')), encrypted_prompt text NOT NULL, run_name text NOT NULL DEFAULT '', launch_lease_expires_at timestamptz, next_poll_at timestamptz, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), started_at timestamptz, PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,invocation_id), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE, FOREIGN KEY (tenant_id,invocation_id) REFERENCES app.invocations(tenant_id,id) ON DELETE CASCADE);
CREATE INDEX job_runs_queue ON app.job_runs (state,created_at) WHERE state='queued';
CREATE INDEX job_runs_poll_due ON app.job_runs (next_poll_at) WHERE state IN ('running','blocked','stopping');
CREATE INDEX job_runs_launch_lease ON app.job_runs (launch_lease_expires_at) WHERE state='starting';

CREATE TABLE app.runs (tenant_id uuid NOT NULL, id uuid NOT NULL, job_id uuid NOT NULL, invocation_id uuid NOT NULL, provider text NOT NULL, issue_id text NOT NULL, issue_url text, issue_title text NOT NULL DEFAULT '', run_name text NOT NULL DEFAULT '', agent_name text NOT NULL, workspace_name text NOT NULL DEFAULT '', agent_kind text NOT NULL DEFAULT '', state text NOT NULL, execution_backend_kind text NOT NULL DEFAULT '', execution_handle jsonb, execution_capabilities jsonb NOT NULL DEFAULT '[]', destination_url text, result text, output_captured boolean NOT NULL DEFAULT false, claim_released boolean NOT NULL DEFAULT false, vm_cleanup_attempt integer NOT NULL DEFAULT 0, cleanup_next_at timestamptz, vm_cleanup_complete boolean NOT NULL DEFAULT false, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,invocation_id), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE, FOREIGN KEY (tenant_id,invocation_id) REFERENCES app.invocations(tenant_id,id) ON DELETE CASCADE);
CREATE TABLE app.runs (tenant_id uuid NOT NULL, id uuid NOT NULL, job_id uuid NOT NULL, invocation_id uuid NOT NULL, provider text NOT NULL, issue_id text NOT NULL, issue_url text, issue_title text NOT NULL DEFAULT '', run_name text NOT NULL DEFAULT '', agent_name text NOT NULL, workspace_name text NOT NULL DEFAULT '', agent_kind text NOT NULL DEFAULT '', state text NOT NULL, execution_backend_kind text NOT NULL DEFAULT '', execution_handle jsonb, execution_capabilities jsonb NOT NULL DEFAULT '[]', destination_url text, artifact_state text NOT NULL DEFAULT 'pending' CHECK (artifact_state IN ('pending','collecting','stored','partial','failed')), artifact_error text, claim_released boolean NOT NULL DEFAULT false, vm_cleanup_attempt integer NOT NULL DEFAULT 0, cleanup_next_at timestamptz, vm_cleanup_complete boolean NOT NULL DEFAULT false, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,invocation_id), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE, FOREIGN KEY (tenant_id,invocation_id) REFERENCES app.invocations(tenant_id,id) ON DELETE CASCADE);
CREATE INDEX runs_order ON app.runs (tenant_id,created_at DESC,id DESC);
CREATE INDEX runs_state_order ON app.runs (tenant_id,state,created_at DESC,id DESC);
CREATE INDEX runs_cleanup_due ON app.runs (cleanup_next_at) WHERE NOT vm_cleanup_complete;
CREATE INDEX runs_issue_trgm ON app.runs USING gin (issue_id gin_trgm_ops);
CREATE INDEX runs_name_trgm ON app.runs USING gin (run_name gin_trgm_ops);
CREATE TABLE app.run_transcripts (tenant_id uuid NOT NULL, run_id uuid NOT NULL, transcript text NOT NULL, byte_size integer NOT NULL CHECK (byte_size >= 0), search_vector tsvector GENERATED ALWAYS AS (to_tsvector('english',transcript)) STORED, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,run_id), FOREIGN KEY (tenant_id,run_id) REFERENCES app.runs(tenant_id,id) ON DELETE CASCADE);
CREATE INDEX run_transcripts_search ON app.run_transcripts USING gin (search_vector);
CREATE TABLE app.run_artifacts (tenant_id uuid NOT NULL, run_id uuid NOT NULL, id uuid NOT NULL, kind text NOT NULL CHECK (kind IN ('native_session','related_session','terminal_log','manifest')), object_key text NOT NULL, provider text NOT NULL, format text NOT NULL, format_version text, cli_version text, native_session_id text, byte_size bigint NOT NULL CHECK (byte_size >= 0), sha256 text NOT NULL CHECK (sha256 ~ '^[0-9a-f]{64}$'), state text NOT NULL CHECK (state IN ('pending','collecting','stored','partial','failed')), created_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,object_key), FOREIGN KEY (tenant_id,run_id) REFERENCES app.runs(tenant_id,id) ON DELETE CASCADE);
CREATE INDEX run_artifacts_by_run ON app.run_artifacts (tenant_id,run_id,created_at,id);
CREATE TABLE app.run_trace_events (tenant_id uuid NOT NULL, run_id uuid NOT NULL, sequence bigint NOT NULL CHECK (sequence > 0), id text NOT NULL, parent_id text, event_type text NOT NULL CHECK (event_type IN ('user_message','assistant_message','reasoning','tool_call','tool_result','command','file_change','compaction','branch','usage','warning','error','metadata')), role text, title text NOT NULL, preview_text text NOT NULL, display_data jsonb NOT NULL DEFAULT '{}', occurred_at timestamptz, created_at timestamptz NOT NULL DEFAULT now(), search_vector tsvector GENERATED ALWAYS AS (to_tsvector('english',title || ' ' || preview_text)) STORED, PRIMARY KEY (tenant_id,run_id,sequence), FOREIGN KEY (tenant_id,run_id) REFERENCES app.runs(tenant_id,id) ON DELETE CASCADE);
CREATE INDEX run_trace_events_search ON app.run_trace_events USING gin (search_vector);
CREATE INDEX run_trace_events_by_type ON app.run_trace_events (tenant_id,run_id,event_type,sequence);
CREATE TABLE app.run_activity (tenant_id uuid NOT NULL, id uuid NOT NULL, run_id uuid NOT NULL, action text NOT NULL, detail text NOT NULL, created_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), FOREIGN KEY (tenant_id,run_id) REFERENCES app.runs(tenant_id,id) ON DELETE CASCADE);
CREATE TABLE app.active_claims (tenant_id uuid NOT NULL, job_id uuid NOT NULL, claim_key text NOT NULL, run_id uuid NOT NULL, expires_at timestamptz, PRIMARY KEY (tenant_id,job_id,claim_key), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE, FOREIGN KEY (tenant_id,run_id) REFERENCES app.runs(tenant_id,id) ON DELETE CASCADE);

Expand All @@ -42,7 +45,7 @@ CREATE INDEX job_events_by_job ON app.job_events (tenant_id,job_id,received_at D

CREATE TABLE app.webhook_deliveries (tenant_id uuid NOT NULL REFERENCES app.tenants(id) ON DELETE CASCADE, id uuid NOT NULL, provider text NOT NULL, delivery_id text NOT NULL, event_type text NOT NULL DEFAULT 'unknown', event_action text NOT NULL DEFAULT 'unknown', outcome text NOT NULL, detail text NOT NULL, received_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,provider,delivery_id));
CREATE TABLE app.webhook_delivery_events (tenant_id uuid NOT NULL, id uuid NOT NULL, delivery_id uuid NOT NULL, job_id uuid, outcome text NOT NULL, detail text NOT NULL, created_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), FOREIGN KEY (tenant_id,delivery_id) REFERENCES app.webhook_deliveries(tenant_id,id) ON DELETE CASCADE, FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE SET NULL);
CREATE TABLE app.pending_verifications (tenant_id uuid NOT NULL REFERENCES app.tenants(id) ON DELETE CASCADE, id uuid NOT NULL, job_id uuid, delivery_id text NOT NULL, installation_id bigint NOT NULL, repository_id bigint NOT NULL, repository_owner text NOT NULL, repository_name text NOT NULL, pull_number integer NOT NULL, attempt integer NOT NULL DEFAULT 0, next_attempt_at timestamptz NOT NULL, payload jsonb NOT NULL, PRIMARY KEY (tenant_id,id), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE);
CREATE TABLE app.pending_verifications (tenant_id uuid NOT NULL REFERENCES app.tenants(id) ON DELETE CASCADE, id uuid NOT NULL, job_id uuid NOT NULL, trigger_id uuid NOT NULL, delivery_id text NOT NULL, installation_id bigint NOT NULL, repository_id bigint NOT NULL, repository_owner text NOT NULL, repository_name text NOT NULL, pull_number integer NOT NULL, attempt integer NOT NULL DEFAULT 0, next_attempt_at timestamptz NOT NULL, payload jsonb NOT NULL, PRIMARY KEY (tenant_id,id), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE, FOREIGN KEY (tenant_id,trigger_id) REFERENCES app.triggers(tenant_id,id) ON DELETE CASCADE);
CREATE INDEX pending_verifications_due ON app.pending_verifications (next_attempt_at);
CREATE TABLE app.tail_fingerprints (tenant_id uuid NOT NULL REFERENCES app.tenants(id) ON DELETE CASCADE, job_id uuid NOT NULL, fingerprint text NOT NULL, window_started_at timestamptz NOT NULL, count integer NOT NULL CHECK (count >= 0), PRIMARY KEY (tenant_id,job_id,fingerprint), FOREIGN KEY (tenant_id,job_id) REFERENCES app.jobs(tenant_id,id) ON DELETE CASCADE);
CREATE TABLE app.wake_hints (key text PRIMARY KEY DEFAULT 'global' CHECK (key='global'), not_before timestamptz NOT NULL, updated_at timestamptz NOT NULL DEFAULT now());
Expand Down
21 changes: 21 additions & 0 deletions packages/app/migrations/0002_native_run_artifacts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Destructive cutover: terminal transcripts are intentionally not migrated.
DROP TABLE IF EXISTS app.run_transcripts;
ALTER TABLE app.runs DROP COLUMN IF EXISTS result;
ALTER TABLE app.runs DROP COLUMN IF EXISTS output_captured;
ALTER TABLE app.runs ADD COLUMN IF NOT EXISTS artifact_state text NOT NULL DEFAULT 'pending';
ALTER TABLE app.runs ADD COLUMN IF NOT EXISTS artifact_error text;
ALTER TABLE app.jobs ADD COLUMN IF NOT EXISTS model text NOT NULL DEFAULT '';
ALTER TABLE app.jobs ADD COLUMN IF NOT EXISTS effort text NOT NULL DEFAULT '';
ALTER TABLE app.runs DROP CONSTRAINT IF EXISTS runs_artifact_state_check;
ALTER TABLE app.runs ADD CONSTRAINT runs_artifact_state_check CHECK (artifact_state IN ('pending','collecting','stored','partial','failed'));

CREATE TABLE IF NOT EXISTS app.run_artifacts (tenant_id uuid NOT NULL, run_id uuid NOT NULL, id uuid NOT NULL, kind text NOT NULL CHECK (kind IN ('native_session','related_session','terminal_log','manifest')), object_key text NOT NULL, provider text NOT NULL, format text NOT NULL, format_version text, cli_version text, native_session_id text, byte_size bigint NOT NULL CHECK (byte_size >= 0), sha256 text NOT NULL CHECK (sha256 ~ '^[0-9a-f]{64}$'), state text NOT NULL CHECK (state IN ('pending','collecting','stored','partial','failed')), created_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tenant_id,id), UNIQUE (tenant_id,object_key), FOREIGN KEY (tenant_id,run_id) REFERENCES app.runs(tenant_id,id) ON DELETE CASCADE);
CREATE INDEX IF NOT EXISTS run_artifacts_by_run ON app.run_artifacts (tenant_id,run_id,created_at,id);
CREATE TABLE IF NOT EXISTS app.run_trace_events (tenant_id uuid NOT NULL, run_id uuid NOT NULL, sequence bigint NOT NULL CHECK (sequence > 0), id text NOT NULL, parent_id text, event_type text NOT NULL CHECK (event_type IN ('user_message','assistant_message','reasoning','tool_call','tool_result','command','file_change','compaction','branch','usage','warning','error','metadata')), role text, title text NOT NULL, preview_text text NOT NULL, display_data jsonb NOT NULL DEFAULT '{}', occurred_at timestamptz, created_at timestamptz NOT NULL DEFAULT now(), search_vector tsvector GENERATED ALWAYS AS (to_tsvector('english',title || ' ' || preview_text)) STORED, PRIMARY KEY (tenant_id,run_id,sequence), FOREIGN KEY (tenant_id,run_id) REFERENCES app.runs(tenant_id,id) ON DELETE CASCADE);
CREATE INDEX IF NOT EXISTS run_trace_events_search ON app.run_trace_events USING gin (search_vector);
CREATE INDEX IF NOT EXISTS run_trace_events_by_type ON app.run_trace_events (tenant_id,run_id,event_type,sequence);

-- The product decision is to discard all pre-artifact run history.
TRUNCATE app.run_trace_events, app.run_artifacts, app.active_claims, app.lifecycle_deliveries, app.run_activity, app.runs, app.job_runs, app.invocations CASCADE;

INSERT INTO app.schema_migrations(version) VALUES ('0002_native_run_artifacts') ON CONFLICT DO NOTHING;
9 changes: 9 additions & 0 deletions packages/app/migrations/0003_postgres_runtime_completion.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Runtime completion after the initial PostgreSQL cutover.
ALTER TABLE app.pending_verifications ADD COLUMN IF NOT EXISTS trigger_id uuid;
DELETE FROM app.pending_verifications WHERE trigger_id IS NULL;
ALTER TABLE app.pending_verifications ALTER COLUMN job_id SET NOT NULL;
ALTER TABLE app.pending_verifications ALTER COLUMN trigger_id SET NOT NULL;
ALTER TABLE app.pending_verifications DROP CONSTRAINT IF EXISTS pending_verifications_trigger_id_fkey;
ALTER TABLE app.pending_verifications ADD CONSTRAINT pending_verifications_trigger_id_fkey FOREIGN KEY (tenant_id,trigger_id) REFERENCES app.triggers(tenant_id,id) ON DELETE CASCADE;

INSERT INTO app.schema_migrations(version) VALUES ('0003_postgres_runtime_completion') ON CONFLICT DO NOTHING;
8 changes: 6 additions & 2 deletions packages/app/migrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ connection string or expose it as a Worker variable.
The initial schema deliberately excludes the inert legacy `pipes`,
`deliveries`, and `flow_events` tables. Every application-owned relationship
uses a tenant-qualified key so a child row cannot reference another tenant's
record. `run_transcripts` stores only scrubbed plaintext and provides the GIN
full-text index used by PostgreSQL search.
record. Native sessions live in object storage. `run_artifacts` records exact
keys and checksums, while `run_trace_events` is the bounded projection used by
the cursor-paginated UI and PostgreSQL search.

The destructive artifact cutover is `0002`; `0003` completes runtime queue
ownership by binding deferred GitHub verification to an exact trigger.
3 changes: 1 addition & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
"scripts": {
"dev": "npm run build:css && wrangler dev",
"build:css": "tailwindcss -i ./src/tailwind.css -o ./public/styles.css --minify",
"check": "tsc --noEmit && vitest run && npm run test:e2e && wrangler deploy --dry-run",
"check": "tsc --noEmit && vitest run && wrangler deploy --dry-run",
"test": "vitest run",
"test:e2e": "vitest run --config vitest.e2e.config.ts",
"deploy": "wrangler deploy",
"db:migrate": "node scripts/migrate.mjs",
"db:verify": "node scripts/verify-schema.mjs"
Expand Down
8 changes: 6 additions & 2 deletions packages/app/scripts/verify-schema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const ids = {
await client.connect();
try {
await client.query("BEGIN");
const authUser = "70000000-0000-4000-8000-000000000001";
await client.query("INSERT INTO app.auth_users(id,email) VALUES ($1,'schema-probe@example.invalid')", [authUser]);
await client.query("INSERT INTO app.auth_accounts(id,user_id,provider,provider_account_id,password_hash) VALUES (gen_random_uuid(),$1::uuid,'credential',$1::uuid::text,'probe')", [authUser]);
await client.query("INSERT INTO app.tenants(id) VALUES ($1),($2)", [ids.tenantA, ids.tenantB]);
await client.query("INSERT INTO app.jobs(tenant_id,id,name,slug,encrypted_prompt_template,execution_target,concurrency_limit) VALUES ($1,$2,'A','same-slug','cipher','{}',1),($3,$4,'B','same-slug','cipher','{}',1)", [ids.tenantA, ids.jobA, ids.tenantB, ids.jobB]);
await client.query("INSERT INTO app.triggers(tenant_id,id,job_id,kind,slug) VALUES ($1,$2,$3,'manual','manual')", [ids.tenantA, ids.triggerA, ids.jobA]);
Expand All @@ -21,8 +24,9 @@ try {
if (duplicate.rowCount !== 0) throw new Error("invocation deduplication constraint failed");
await client.query("INSERT INTO app.job_runs(tenant_id,id,job_id,invocation_id,state,encrypted_prompt) VALUES ($1,$2,$3,$4,'queued','cipher')", [ids.tenantA, ids.runA, ids.jobA, ids.invocationA]);
await client.query("INSERT INTO app.runs(tenant_id,id,job_id,invocation_id,provider,issue_id,agent_name,state) VALUES ($1,$2,$3,$4,'linear','GEN-2113','codex','running')", [ids.tenantA, ids.executionA, ids.jobA, ids.invocationA]);
await client.query("INSERT INTO app.run_transcripts(tenant_id,run_id,transcript,byte_size) VALUES ($1,$2,'postgres durable orchestration',30)", [ids.tenantA, ids.executionA]);
const search = await client.query("SELECT run_id FROM app.run_transcripts WHERE tenant_id=$1 AND search_vector @@ plainto_tsquery('english',$2)", [ids.tenantA, "orchestration"]);
await client.query("INSERT INTO app.run_artifacts(tenant_id,run_id,id,kind,object_key,provider,format,byte_size,sha256,state) VALUES ($1,$2,gen_random_uuid(),'native_session','tenants/a/runs/one/native/session.jsonl','codex','jsonl',10,$3,'stored')", [ids.tenantA, ids.executionA, "a".repeat(64)]);
await client.query("INSERT INTO app.run_trace_events(tenant_id,run_id,sequence,id,event_type,title,preview_text) VALUES ($1,$2,1,'event-1','assistant_message','Assistant','postgres durable orchestration')", [ids.tenantA, ids.executionA]);
const search = await client.query("SELECT run_id FROM app.run_trace_events WHERE tenant_id=$1 AND search_vector @@ plainto_tsquery('english',$2)", [ids.tenantA, "orchestration"]);
if (search.rowCount !== 1) throw new Error("tenant-scoped full-text search failed");
let isolated = false;
await client.query("SAVEPOINT cross_tenant");
Expand Down
Loading
Loading