learning_ai_common_plat/services/platform-service/src
saravanakumardb1 33c1d8d5fa fix(platform-service): make fleet job claim truly atomic via datastore updateIfMatch
The foundation's revUpdateJob/revUpdateLease did a read -> rev-check -> write with
await points between them, so two CONCURRENT claims could both read the same rev,
both pass the check, and both write — a double-assignment the old (sequential) race
test could not catch.

Rewire revUpdateJob/revUpdateLease to delegate to the datastore's updateIfMatch,
which performs the compare and the write as one indivisible operation (Cosmos
If-Match; synchronous compare-set on memory). The coordinator's tryClaimJob keeps
identical external behavior (ok/conflict) but is now genuinely single-winner.

Upgrades the coordinator tests to prove atomicity under TRUE concurrency:
- two contenders via Promise.all -> exactly one ok, one conflict; assigned once;
  one run; one lease; leaseEpoch 1.
- N-claimer (15) stress via Promise.all -> one ok, N-1 conflicts, no double-assignment.
- N concurrent claimNextJob for one job -> exactly one non-null claim.
- N concurrent lease renewals -> exactly one wins.

Verified these concurrent tests FAIL against the old read-check-write (double-assign)
and pass after the fix.
2026-05-29 20:59:08 -07:00
..
lib feat(platform-service): fleet data model + container registration (P2 foundation) 2026-05-29 20:19:59 -07:00
migrations refactor(platform-service): migrate webhooks/routes and migrations/runner from cosmos.js to datastore 2026-03-02 02:02:47 -08:00
modules fix(platform-service): make fleet job claim truly atomic via datastore updateIfMatch 2026-05-29 20:59:08 -07:00
nodemailer.d.ts feat(platform-service): add smtp email delivery and postal setup 2026-03-14 05:52:28 +00:00
server.test.ts feat(runtime): add platform runtime projection api 2026-04-04 01:14:37 -07:00
server.ts feat(platform-service): fleet REST routes + module registration (P2 foundation) 2026-05-29 20:20:46 -07:00