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';
const FIELDS = ['resource_id','name','upstream_url','version','format','sync_source','local_path','body_text','embedding','last_synced','metadata'];
@@ -14,6 +15,7 @@ export async function create(input, actor) {
vals
);
await recordAudit(actor, 'create', 'source_doc', r.id, null, r);
await triggerEmbed('source_doc', r.id);
return r;
}
@@ -43,6 +45,7 @@ export async function update(id, patch, actor) {
vals
);
await recordAudit(actor, 'update', 'source_doc', id, before, r);
if (patch.embedding === undefined) await triggerEmbed('source_doc', id);
return r;
}