feat(database,service,features): a task's and an agent's write answers the transaction it committed in

Draft
CH
9d ago
+425-122

Stack 2 · Task list and automations, piece 3 of 10. Stacked on #3269 (luke/neon-realtime-plan-list-service), which sits on #3265 → luke/live-tx-wait (P).

Each write whose result the desktop shows through the live task list now returns the id of the transaction it committed in, as Neon's mutations guide says:

  • task: start, rename, standing, pin, archive, move, set repository, delete;
  • agent: start, rename, archive, pin.

How it works:

  • The txid comes from the RETURNING pg_current_xact_id()::text of the write that changed a row: the row itself, or the reader's pin.
  • A write that changed nothing returns no txid. A pin asked again is one example.
  • Agent Stop and message are left out. Their visible effect comes later, from eve, in another transaction.

Interfaces:

  • Wire: taskAnswerSchema, taskStartAnswerSchema, taskDeleteAnswerSchema and codingAgentAnswerSchema gain an optional txid.
  • Task client: returns the txid beside the task (TaskWritten).
  • Store: …Committed variants return the txid. The existing functions map onto them, so no other caller changes.

The host waits for the txid on the followed list in a later piece of this stack.

Tests: a PGlite store test checks that a rename and a pin return a txid, and that a pin asked again returns none. Web and service delete assertions now read the answer through taskDeleteAnswerSchema.

Made with Luke