779ba6db59
Brings the §1 bot wrapper, the §4 cache (webhook + reconciler), the §5 schema (six numbered migrations), Gitea OAuth + §6 user provisioning, the §7 catalog left pane, and the propose-to-merge vertical: propose modal opens an idea PR against the meta repo, an owner merges from the pending-idea view, the cache picks it up via webhook or reconciler sweep, and the catalog renders the new super-draft. Per §1 the bot is the only Git writer; every commit, branch creation, and PR merge carries the §6.5 On-behalf-of: trailer and an `actions` audit row. Per §4 the cache is never written from a user action — it's webhook+reconciler only. Covered by `backend/tests/test_propose_vertical.py` against an in-process Gitea simulator. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
2.2 KiB
SQL
46 lines
2.2 KiB
SQL
-- §5 / §10.3 / §15.6 / §15.7: the freshness cursors and the watch model.
|
|
--
|
|
-- Two cursor families per §15.7: per-event read state lives on notifications
|
|
-- (added in 006); per-scope freshness lives on pr_seen and branch_chat_seen.
|
|
-- They serve different jobs and are reconciled by the visit-advances-cursor
|
|
-- reconciler in §15.7.
|
|
|
|
CREATE TABLE pr_seen (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
rfc_slug TEXT NOT NULL,
|
|
pr_number INTEGER NOT NULL,
|
|
last_seen_commit_sha TEXT,
|
|
last_seen_message_id INTEGER REFERENCES thread_messages(id) ON DELETE SET NULL,
|
|
seen_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
UNIQUE (user_id, rfc_slug, pr_number)
|
|
);
|
|
|
|
CREATE TABLE branch_chat_seen (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
rfc_slug TEXT NOT NULL,
|
|
branch_name TEXT NOT NULL,
|
|
last_seen_message_id INTEGER REFERENCES thread_messages(id) ON DELETE SET NULL,
|
|
seen_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
UNIQUE (user_id, rfc_slug, branch_name)
|
|
);
|
|
|
|
-- §15.6: the watch model. Three states; auto-rules upgrade but never
|
|
-- downgrade; explicit settings exempt from the 90-day decay. Per-RFC
|
|
-- mute lives here as state='muted'.
|
|
CREATE TABLE watches (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
rfc_slug TEXT NOT NULL,
|
|
state TEXT NOT NULL CHECK (state IN ('watching', 'following', 'muted')),
|
|
set_by TEXT NOT NULL CHECK (set_by IN ('auto', 'explicit')),
|
|
set_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
last_participation_at TEXT, -- 90-day decay key per §15.6
|
|
UNIQUE (user_id, rfc_slug)
|
|
);
|
|
|
|
CREATE INDEX idx_watches_user ON watches (user_id);
|
|
CREATE INDEX idx_watches_rfc ON watches (rfc_slug);
|
|
CREATE INDEX idx_watches_decay ON watches (state, last_participation_at);
|