Improve UMS candidate scoring and snapshot materialization for sparse data.
Lower term threshold, tune promotion scores, project candidate fallback in snapshot, and add rebuild-ums-snapshot script for production backfill. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Rebuild UMS candidates + snapshot from existing signals (no new evidence ingest).
|
||||
*
|
||||
* UMS_DATABASE_URL=... node scripts/rebuild-ums-snapshot.mjs [user_id]
|
||||
*/
|
||||
import { createUmsPool, isUmsDatabaseConfigured } from '../user-model-service/db.mjs';
|
||||
import { mergeCandidatesFromSignals } from '../user-model-service/candidates.mjs';
|
||||
import { materializeProfileAndSnapshot } from '../user-model-service/snapshot.mjs';
|
||||
import { resolveCanonicalUserId } from '../user-model-service/canonical-user.mjs';
|
||||
|
||||
async function main() {
|
||||
if (!isUmsDatabaseConfigured()) {
|
||||
console.error('Set UMS_DATABASE_URL');
|
||||
process.exit(1);
|
||||
}
|
||||
const userId = resolveCanonicalUserId(
|
||||
process.argv[2] ?? process.env.UMS_REBUILD_USER_ID ?? 'a70ff537-8908-486e-9b6c-042e07cc25db',
|
||||
);
|
||||
const pool = createUmsPool();
|
||||
try {
|
||||
const candidates = await mergeCandidatesFromSignals(pool, userId);
|
||||
const snapshot = await materializeProfileAndSnapshot(pool, userId, { reason: 'rebuild_script' });
|
||||
console.log('rebuild OK:', {
|
||||
user_id: userId,
|
||||
candidates_touched: candidates,
|
||||
profile_version: snapshot.profile_version,
|
||||
byte_size: snapshot.byte_size,
|
||||
});
|
||||
} finally {
|
||||
await pool.end();
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user