Skip to content

feat(autopilot-svm) PR09: settlement observation - #4754

Open
squadgazzz wants to merge 10 commits into
mainfrom
ilya/be-185-pr09-settlement-observation
Open

feat(autopilot-svm) PR09: settlement observation#4754
squadgazzz wants to merge 10 commits into
mainfrom
ilya/be-185-pr09-settlement-observation

Conversation

@squadgazzz

@squadgazzz squadgazzz commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Description

The loop currently dispatches a settlement and forgets it. Nothing checks whether the transaction ever landed.

Now every dispatch opens a window in solana.settlement_executions. When the indexer records the settlement, a NOTIFY closes the window as landed with the signature. If the submission deadline passes first, the window closes as timeout and logs an error. A settlement observed late still flips the window to landed: chain truth wins, and the lateness stays visible in the slot columns.

Windows live in the database and the listener re-checks all open ones on every (re)connect, so restarts and missed notifies lose nothing.

The indexer drives this because there is no blocking /settle response to learn the outcome from, the driver answers at submission and landing is asynchronous.

Temporary solutions: solution_uid is the winner's driver-local id until competition persistence, and the timeout check runs per competition cycle, so on an idle chain a miss surfaces with the next auction.

Changes

  • solana.settlements gains an AFTER INSERT trigger notifying with the auction id (V2 edited in place, the series is deployed nowhere)
  • infra/observation.rs opens, lands, and times out the windows, and resolves notifies plus reconnect re-reads
  • The executor registers each dispatch, the observer drives the deadline check

How to test

New DB-backed tests: the trigger fires and the listener closes the window as landed, deadlines expire, and the mock-cycle test asserts a dispatch opens a window.

@linear-code

linear-code Bot commented Aug 18, 2026

Copy link
Copy Markdown

BE-185

@squadgazzz
squadgazzz marked this pull request as ready for review August 19, 2026 08:25
@squadgazzz
squadgazzz requested a review from a team as a code owner August 19, 2026 08:25
@claude

claude Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Claude finished @squadgazzz's task in 2m 50s —— View job


PR Review: settlement observation

The design is clean — windows persisted in the DB, NOTIFY + reconnect re-seed for convergence, and timeouts upgraded to landed when a settlement lands late. The ListenSession reuse and the best-effort window-open in the executor are nicely reasoned. Two points I'd like addressed, posted inline:

  • observer.rs:45flag_expired(*tip).await? propagates through persist_competition_ranking, which run_loop::single_run gates dispatch on. A transient DB error in the (unrelated) timeout bookkeeping would abort dispatch of the current winner. This contradicts the executor's own "window open must not block the settlement" principle; make it best-effort (log & continue).
  • observation.rs:157-175resolve/landed collapse all of an auction's windows onto a single settlement's signature and don't key on solver. Correct for one winner, but max_winners is configurable and the executor opens one window per winner, so multi-winner silently mis-attributes. Worth keying by solver or at least logging a count mismatch.

Nothing blocking beyond the first item; the second is a heads-up for when multi-winner arrives.

  • Read the PR diff and changed files
  • Analyze observation.rs, executor.rs, observer.rs
  • Review DB migration / trigger
  • Post inline findings and summary

Comment thread crates/autopilot-svm/src/infra/observer.rs Outdated
Comment thread crates/autopilot-svm/src/infra/observation.rs
@squadgazzz
squadgazzz force-pushed the ilya/be-184-pr08-seam-implementations-single-auction-cycle branch from 8f29d7e to 5c1b874 Compare August 19, 2026 11:14
@squadgazzz
squadgazzz force-pushed the ilya/be-185-pr09-settlement-observation branch from 03436e2 to 760fcae Compare August 19, 2026 11:15
Base automatically changed from ilya/be-184-pr08-seam-implementations-single-auction-cycle to main August 20, 2026 10:39
…lement-observation

# Conflicts:
#	crates/autopilot-svm/src/infra/executor.rs
#	crates/autopilot-svm/src/infra/mod.rs
#	crates/autopilot-svm/src/infra/observer.rs
#	crates/autopilot-svm/src/tests.rs

@jmg-duarte jmg-duarte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description reads very AI-generated

Comment thread crates/autopilot-svm/src/infra/executor.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing an existing migration sounds sus, im guessing it wasn't fully submitted before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solana migrations are currently used only in the tests.

Comment thread crates/autopilot-svm/src/infra/observation.rs
Comment thread crates/autopilot-svm/src/infra/observation.rs Outdated
Comment thread crates/autopilot-svm/src/infra/observation.rs Outdated
Comment thread crates/autopilot-svm/src/infra/observation.rs Outdated
Comment thread crates/autopilot-svm/src/infra/observation.rs Outdated
Comment thread crates/autopilot-svm/src/infra/observation.rs Outdated
Comment on lines +197 to +199
for auction_id in self.tracker.open_windows().await? {
self.resolve(auction_id).await?;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

join_all/try_join_all maybe? or it doesn't matter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code runs only when the listener connects/reconnects, and usually finds zero or a few open windows. IMO, try_join_all would only add noise.

@squadgazzz
squadgazzz requested a review from jmg-duarte August 20, 2026 14:37
@squadgazzz

Copy link
Copy Markdown
Contributor Author

Description reads very AI-generated

Updated as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants