Expand description
Transaction sentinel detection for the dispatch path.
Every state-changing CLI verb should consult active_transactions
before executing. When the answer is non-empty, the verb is running
against a repo with one or more open transactions; the verb should
either (a) refuse to mutate (the conservative shipping shape), or
(b) append itself to the sentinel’s buffered_ops and defer.
This module ships only the detection primitive — recording each
verb into the sentinel’s buffered_ops list (and replaying them at
commit) is the larger follow-on the local transaction service
already flags with TODO(transaction-replay).
Sentinel files live at <heddle_dir>/state/transactions/<id>.toml
(the same path the local TransactionService uses), so the
detection here is consistent with the gRPC view.
Structs§
- Active
Transaction - One open transaction, hydrated from its on-disk sentinel. Field
names match the writer in
crates/daemon/src/grpc_local_impl/transaction.rs::TransactionSentinel— keep this struct in sync if the writer’s shape changes. TheSerializeimpl is used byappend_op_to_active_for_threadto rewrite the sentinel after appending a buffered op.
Functions§
- active_
for_ thread - Return the active transaction whose
threadmatchesthread_name, if any. Used by state-changing verbs that target a specific thread: the verb should either route into that transaction’s buffer (full wiring is follow-on work) or refuse to proceed (today’s shape). - active_
transactions - Walk the sentinel directory and return every transaction whose
state is still
"active". Returns an empty vec when the directory is missing (no transactions ever started in this repo). - append_
op_ to_ active_ for_ thread - Append
verb_nameto thebuffered_opslist of every active transaction whosethreadmatchesthread_name. Returns the transaction ids that were updated. Errors are tracing-warned and swallowed — buffering is best-effort metadata; the verb still executes regardless. - buffered_
for_ thread - Convenience wrapper for the common “did this verb get buffered?”
question. Calls
append_op_to_active_for_threadand returnstruewhen at least one open transaction onthread_namerecorded the verb. Useful for the dispatch path: when buffering occurs, the surrounding verb can short-circuit the actual mutation (the strict “buffer-instead-of-execute” mode the transaction contract calls for).