fix: order command controls after dispatch
This commit is contained in:
@@ -46,10 +46,12 @@ type StdinIntent struct {
|
||||
Close bool
|
||||
}
|
||||
|
||||
// PendingStdin returns unacknowledged input intents for one client. Delivery is
|
||||
// intentionally tracked by the session dispatcher, not by this durable query:
|
||||
// a lost connection simply causes the next session to replay the same write
|
||||
// sequence, which the client acknowledges idempotently.
|
||||
// PendingStdin returns unacknowledged input intents only after the command has
|
||||
// entered DISPATCHED state. This durable gate prevents append/close controls
|
||||
// from overtaking their initial CommandDispatch on a fresh session. Delivery is
|
||||
// otherwise tracked by the session dispatcher: a lost connection simply causes
|
||||
// the next session to replay the same write sequence, which the client
|
||||
// acknowledges idempotently.
|
||||
func (store *Store) PendingStdin(ctx context.Context, clientID string) ([]StdinIntent, error) {
|
||||
if clientID == "" {
|
||||
return nil, errors.New("client ID is required")
|
||||
@@ -60,7 +62,7 @@ func (store *Store) PendingStdin(ctx context.Context, clientID string) ([]StdinI
|
||||
}
|
||||
rows, err := database.QueryContext(ctx, `SELECT w.issue_uuid, w.write_seq, w.payload, w.raw_bytes, w.stored_bytes, w.compression, w.sha256, w.append_newline, w.close_intent
|
||||
FROM stdin_writes w JOIN commands c ON c.issue_uuid = w.issue_uuid
|
||||
WHERE c.client_id = ? AND c.lifecycle BETWEEN 1 AND 4 AND w.acknowledged = 0
|
||||
WHERE c.client_id = ? AND c.lifecycle BETWEEN 2 AND 4 AND w.acknowledged = 0
|
||||
ORDER BY c.issue_time, c.issue_uuid, w.write_seq`, clientID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user