mirror of
https://github.com/block/buzz.git
synced 2026-11-15 22:02:04 +00:00
A1 of the accumulator experiment: incrementally maintained, provenance- carrying artifacts over the event stream (signal / selection / fold / artifact), shipped as a packaged experiment. - New pure-logic workspace crate buzz-accumulator: selection-to-filter compilation with deterministic materialization, budgeted transcript rendering, zero-spend estimates (unknown model => honest None), plan_run/complete_run around a FoldRunner seam (subprocess claude -p v1 impl with sentinel/exit-code/timeout hardening), output-contract validation (exact H1 sections, cited within shown ids, >=1 citation, refuse => nothing persists), and the engine splice that retains append-section history by construction. 46 unit tests port the honesty invariants: coverage never seals unread, stall-don't-seal, prior citations never satisfy a new run. - New kinds in buzz-core: 30640 fold spec (parameterized replaceable, d = fold name) and 4640 artifact version (regular/immutable), both AUTHOR_ONLY_KINDS with NIP-44 content encrypted to self. - Relay: UsersWrite scope arms + global-only (never channel-scoped). - FTS privacy: both kinds excluded from search_tsv in schema.sql and brownfield migration 0041 (same shape as 0014/0033); embedded migrator tripwire extended. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Riley Crane <rileycrane@squareup.com>
40 lines
1.6 KiB
SQL
40 lines
1.6 KiB
SQL
-- Accumulator kinds 30640 (fold spec) and 4640 (artifact version) carry
|
|
-- NIP-44 ciphertext encrypted from the author's key to itself and are
|
|
-- author-only (AUTHOR_ONLY_KINDS). Exclude them from full-text search so
|
|
-- the ciphertext is never tokenized into search_tsv, where a NIP-50 search
|
|
-- from any member could otherwise probe it.
|
|
--
|
|
-- Same shape as 0014 (kind:30350) and 0033 (kind:30179): PostgreSQL cannot
|
|
-- alter a generated expression in place, so capture the current expression,
|
|
-- drop the column, and re-add it wrapped with the new exclusion. Every other
|
|
-- kind keeps whatever policy the database had before.
|
|
--
|
|
-- Operational cost: DROP COLUMN + ADD ... GENERATED ... STORED rewrites the
|
|
-- events heap and rebuilds the GIN index under an ACCESS EXCLUSIVE lock —
|
|
-- see the note on 0033. Operators with large brownfield databases should
|
|
-- schedule a window.
|
|
DO $$
|
|
DECLARE
|
|
existing_expression TEXT;
|
|
BEGIN
|
|
SELECT pg_get_expr(d.adbin, d.adrelid)
|
|
INTO existing_expression
|
|
FROM pg_attrdef d
|
|
JOIN pg_attribute a
|
|
ON a.attrelid = d.adrelid
|
|
AND a.attnum = d.adnum
|
|
WHERE d.adrelid = 'events'::regclass
|
|
AND a.attname = 'search_tsv';
|
|
|
|
IF existing_expression IS NULL THEN
|
|
RAISE EXCEPTION 'events.search_tsv generated expression not found';
|
|
END IF;
|
|
|
|
ALTER TABLE events DROP COLUMN search_tsv;
|
|
EXECUTE format(
|
|
'ALTER TABLE events ADD COLUMN search_tsv TSVECTOR GENERATED ALWAYS AS (CASE WHEN kind IN (4640, 30640) THEN NULL::tsvector ELSE (%s) END) STORED',
|
|
existing_expression
|
|
);
|
|
CREATE INDEX idx_events_search_tsv ON events USING GIN (search_tsv);
|
|
END $$;
|