feat(jobs): repo-level embed triggers (pages/refs/source_docs)

create/update on embeddable repos enqueue embed.text with a singleton
key that coalesces rapid edits. No-op when the queue is not running
(server tests construct createApp without booting pg-boss).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 03:48:03 +10:00
parent 37b7753360
commit e558be49a9
5 changed files with 88 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { pool } from '../pool.js';
import { recordAudit } from './audit_stub.js';
import { triggerEmbed } from '../../jobs/triggers.js';
async function snapshot(client, page_id, body_md, edited_by) {
await client.query(
@@ -21,6 +22,7 @@ export async function create({ space_id, slug, title, body_md = '', parent_id },
await snapshot(client, r.id, body_md, actor?.kind);
await client.query('COMMIT');
await recordAudit(actor, 'create', 'page', r.id, null, r);
await triggerEmbed('page', r.id);
return r;
} catch (e) {
await client.query('ROLLBACK'); throw e;
@@ -79,6 +81,7 @@ export async function update(id, patch, actor) {
}
await client.query('COMMIT');
await recordAudit(actor, 'update', 'page', id, before, r);
if (patch.embedding === undefined) await triggerEmbed('page', id);
return r;
} catch (e) {
await client.query('ROLLBACK'); throw e;