|
| 1 | +-- A bug report a person sent from a Thread. The message and the redacted |
| 2 | +-- diagnostics they chose live in DX_STORAGE under `bug-reports/<id>/`; this |
| 3 | +-- row lists the report under Your Reports and records where Core filed it: |
| 4 | +-- a new issue (`filed`), a comment on an open issue it duplicates |
| 5 | +-- (`commented`), nowhere because the deployment names no repository |
| 6 | +-- (`saved`), or not at all (`failed`). |
| 7 | +CREATE TABLE bug_report ( |
| 8 | + id TEXT PRIMARY KEY CHECK (id GLOB 'bug_*' AND length(id) = 36), |
| 9 | + reporter_user_id TEXT NOT NULL, |
| 10 | + thread_id TEXT NOT NULL, |
| 11 | + message TEXT NOT NULL CHECK (length(message) BETWEEN 1 AND 10000), |
| 12 | + status TEXT NOT NULL |
| 13 | + CHECK (status IN ('filing', 'filed', 'commented', 'saved', 'failed')), |
| 14 | + issue_number INTEGER CHECK (issue_number IS NULL OR issue_number > 0), |
| 15 | + issue_url TEXT CHECK (issue_url IS NULL OR length(issue_url) <= 2048), |
| 16 | + image_count INTEGER NOT NULL CHECK (image_count BETWEEN 0 AND 5), |
| 17 | + diagnostics TEXT NOT NULL, |
| 18 | + created_at TEXT NOT NULL, |
| 19 | + updated_at TEXT NOT NULL |
| 20 | +) WITHOUT ROWID; |
| 21 | + |
| 22 | +CREATE INDEX bug_report_reporter_created |
| 23 | + ON bug_report (reporter_user_id, created_at DESC); |
| 24 | + |
| 25 | +-- Thread families (issue #1100). `parent_thread_id` stays the family's root, |
| 26 | +-- which sharing, archive, and delete act on. `started_by_thread_id` records |
| 27 | +-- the family member whose agent started the Thread, so clients can show the |
| 28 | +-- family as a tree. NULL for a root, and for a Thread started before this |
| 29 | +-- column existed or whose starter was deleted: those list under the root. |
| 30 | +ALTER TABLE threads ADD COLUMN started_by_thread_id TEXT |
| 31 | + REFERENCES threads (id) ON DELETE SET NULL; |
| 32 | + |
| 33 | +CREATE INDEX threads_started_by_idx ON threads (started_by_thread_id) |
| 34 | + WHERE started_by_thread_id IS NOT NULL; |
| 35 | + |
| 36 | +-- Scripts saved in a Project's Orb settings, so a repository works in Orbs |
| 37 | +-- without committing setup files. Pre-clone runs before dx clones the |
| 38 | +-- repository and pre-setup runs before `.agents/setup`; desktop-resume is |
| 39 | +-- reserved for the Desktop. An empty script is deleted, not stored. |
| 40 | +CREATE TABLE project_orb_script ( |
| 41 | + project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE, |
| 42 | + kind TEXT NOT NULL CHECK (kind IN ('pre-clone', 'pre-setup', 'desktop-resume')), |
| 43 | + body TEXT NOT NULL CHECK (length(CAST(body AS BLOB)) BETWEEN 1 AND 32768), |
| 44 | + updated_by_user_id TEXT NOT NULL CHECK (length(updated_by_user_id) BETWEEN 1 AND 128), |
| 45 | + updated_at TEXT NOT NULL CHECK (length(updated_at) BETWEEN 20 AND 40), |
| 46 | + PRIMARY KEY (project_id, kind) |
| 47 | +); |
| 48 | + |
| 49 | +-- Every change to a script, kept after the Project is gone. Scripts run in |
| 50 | +-- every member's Orbs, so the audit names who changed which script and the |
| 51 | +-- digest of what it became. |
| 52 | +CREATE TABLE project_orb_script_audit ( |
| 53 | + id TEXT PRIMARY KEY NOT NULL, |
| 54 | + project_id TEXT NOT NULL CHECK (length(project_id) BETWEEN 1 AND 128), |
| 55 | + kind TEXT NOT NULL CHECK (kind IN ('pre-clone', 'pre-setup', 'desktop-resume')), |
| 56 | + action TEXT NOT NULL CHECK (action IN ('set', 'clear')), |
| 57 | + body_sha256 TEXT CHECK ( |
| 58 | + (action = 'set' AND length(body_sha256) = 64) |
| 59 | + OR (action = 'clear' AND body_sha256 IS NULL) |
| 60 | + ), |
| 61 | + actor_user_id TEXT NOT NULL CHECK (length(actor_user_id) BETWEEN 1 AND 128), |
| 62 | + request_id TEXT NOT NULL CHECK (length(request_id) BETWEEN 1 AND 128), |
| 63 | + occurred_at TEXT NOT NULL |
| 64 | +); |
| 65 | + |
| 66 | +CREATE INDEX project_orb_script_audit_project_time_idx |
| 67 | +ON project_orb_script_audit(project_id, occurred_at DESC, id DESC); |
| 68 | + |
| 69 | +CREATE TRIGGER project_orb_script_audit_immutable_update |
| 70 | +BEFORE UPDATE ON project_orb_script_audit |
| 71 | +BEGIN |
| 72 | + SELECT RAISE(ABORT, 'project orb script audit is immutable'); |
| 73 | +END; |
| 74 | + |
| 75 | +CREATE TRIGGER project_orb_script_audit_immutable_delete |
| 76 | +BEFORE DELETE ON project_orb_script_audit |
| 77 | +BEGIN |
| 78 | + SELECT RAISE(ABORT, 'project orb script audit is immutable'); |
| 79 | +END; |
| 80 | + |
| 81 | +-- A plugin row is either a code plugin or a bundle in Claude Code's format. |
| 82 | +-- A bundle's skills and MCP servers live in their own stores and point back |
| 83 | +-- at the plugin that installed them; a disabled or removed bundle hides them |
| 84 | +-- from new Threads. |
| 85 | +ALTER TABLE trusted_plugin ADD COLUMN kind TEXT NOT NULL DEFAULT 'code' |
| 86 | + CHECK (kind IN ('code', 'bundle')); |
| 87 | + |
| 88 | +ALTER TABLE skill ADD COLUMN plugin_id TEXT |
| 89 | + REFERENCES trusted_plugin (id) ON DELETE RESTRICT; |
| 90 | + |
| 91 | +ALTER TABLE mcp_server ADD COLUMN plugin_id TEXT |
| 92 | + REFERENCES trusted_plugin (id) ON DELETE RESTRICT; |
| 93 | + |
| 94 | +CREATE INDEX skill_plugin_idx ON skill (plugin_id) WHERE plugin_id IS NOT NULL; |
| 95 | + |
| 96 | +CREATE INDEX mcp_server_plugin_idx ON mcp_server (plugin_id) |
| 97 | + WHERE plugin_id IS NOT NULL; |
0 commit comments