A change made while score runs gets one follow-up score, and the page waits on it

score is solo, so a request during a run was deduped into the running job,
which had already read the old state. _score_after_change returns a queued
score when one has not started, else enqueues a plain score and, if that
dedupes to a running job, one follow-up with depends_on it, after="done" and
dedup_key score:after:<id>. POST /api/score answers with that job and
agents.js waits on it; the affinity route answers with score_job.

The flaky affinity test was pipeline's race, not the app's: Jobs.enqueue
re-raises the UNIQUE IntegrityError when the live job it collided with
finishes before the SELECT that should hand it back. The app retries.

Co-Authored-By: Claude Opus <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus committed 2026-09-29 15:16:23 +02:00
1 parent 3abb44e10a
commit 91d15fcc7d
4 files changed
+110 -12

No files matched your search

+5 -3
View File
@@ -289,14 +289,16 @@
render();
}
// Start the `score` job and wait for it, so "scored" means the Roles tab
// already orders by what was saved. `said` is what happened first.
// Ask for a `score` and wait for the job the server answers with, so
// "scored" means the Roles tab already orders by what was saved. While a
// score is running that is a follow-up queued after it, since the running
// one read the agent before the save. `said` is what happened first.
async function rescore(status, agent, said) {
const runs = () => link("/settings/sources#runs", "follow it under Runs");
status.replaceChildren(`${said}. Scoring every open role; `, runs(), ".");
let job;
try {
job = await api("/api/jobs", { method: "POST", body: { kind: "score", payload: {} } });
job = await api("/api/score", { method: "POST" });
} catch (err) {
status.textContent = `${said}, but scoring did not start.`;
return;