-
Notifications
You must be signed in to change notification settings - Fork 184
Harden worker delivery contracts and add durable worker event journal #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
vsumner
wants to merge
9
commits into
spacedriveapp:main
from
vsumner:feat/worker-contract-events-delivery-outcome
+5,372
−411
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f2f2d45
feat(worker): add durable terminal delivery, checkpoints, and resilience
vsumner 072212b
chore(api): trim worker progress interface surface
vsumner d2b612b
Harden worker delivery contracts and persist worker events
vsumner 3cf1d67
Fix clippy -Dwarnings violations in worker contract paths
vsumner 63d44f5
Fix worker delivery contract edge cases and align docs
vsumner 685bfde
Harden worker contract semantics and deterministic status hashing
vsumner fb59dd4
Address follow-up reliability and docs findings
vsumner 84a019d
Harden outbound delivery paths and simplify routing flow
vsumner 5ab67b4
Merge branch 'main' into feat/worker-contract-events-delivery-outcome
jamiepine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| -- Durable delivery receipts for terminal worker notifications. | ||
| -- | ||
| -- Tracks whether a terminal worker completion notice has been delivered to the | ||
| -- user-facing channel, with bounded retry metadata for transient adapter | ||
| -- failures. | ||
|
|
||
| CREATE TABLE IF NOT EXISTS worker_delivery_receipts ( | ||
| id TEXT PRIMARY KEY, | ||
| worker_id TEXT NOT NULL, | ||
| channel_id TEXT NOT NULL, | ||
| kind TEXT NOT NULL, | ||
| status TEXT NOT NULL DEFAULT 'pending', | ||
| terminal_state TEXT NOT NULL, | ||
| payload_text TEXT NOT NULL, | ||
| attempt_count INTEGER NOT NULL DEFAULT 0, | ||
| last_error TEXT, | ||
| next_attempt_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| acked_at TIMESTAMP, | ||
| created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| UNIQUE(worker_id, kind) | ||
| ); | ||
|
|
||
| CREATE INDEX idx_worker_delivery_receipts_due | ||
| ON worker_delivery_receipts(status, next_attempt_at); | ||
|
|
||
| CREATE INDEX idx_worker_delivery_receipts_channel | ||
| ON worker_delivery_receipts(channel_id, created_at); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| -- Deterministic worker task contracts. | ||
| -- | ||
| -- Tracks acknowledgement/progress/terminal guarantees for worker executions so | ||
| -- long-running tasks always provide bounded feedback and reach terminal states. | ||
|
|
||
| CREATE TABLE IF NOT EXISTS worker_task_contracts ( | ||
| id TEXT PRIMARY KEY, | ||
| agent_id TEXT NOT NULL, | ||
| channel_id TEXT NOT NULL, | ||
| worker_id TEXT NOT NULL UNIQUE, | ||
| task_summary TEXT NOT NULL, | ||
| state TEXT NOT NULL DEFAULT 'created', | ||
| ack_deadline_at TIMESTAMP NOT NULL, | ||
| progress_deadline_at TIMESTAMP NOT NULL, | ||
| terminal_deadline_at TIMESTAMP NOT NULL, | ||
| last_progress_at TIMESTAMP, | ||
| last_status_hash TEXT, | ||
| attempt_count INTEGER NOT NULL DEFAULT 0, | ||
| sla_nudge_sent INTEGER NOT NULL DEFAULT 0, | ||
| terminal_state TEXT, | ||
| created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
| ); | ||
|
|
||
| CREATE INDEX idx_worker_task_contracts_channel_state | ||
| ON worker_task_contracts(channel_id, state); | ||
|
|
||
| CREATE INDEX idx_worker_task_contracts_ack_due | ||
| ON worker_task_contracts(state, ack_deadline_at); | ||
|
|
||
| CREATE INDEX idx_worker_task_contracts_progress_due | ||
| ON worker_task_contracts(state, progress_deadline_at); | ||
|
|
||
| CREATE INDEX idx_worker_task_contracts_terminal_due | ||
| ON worker_task_contracts(state, terminal_deadline_at); |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| -- Durable worker event journal for debugging and UX timeline recovery. | ||
| -- | ||
| -- Captures lifecycle checkpoints (started/progress/tool activity/completed) as | ||
| -- append-only records tied to worker_runs. | ||
|
|
||
| CREATE TABLE IF NOT EXISTS worker_events ( | ||
| id TEXT PRIMARY KEY, | ||
| worker_id TEXT NOT NULL, | ||
| channel_id TEXT, | ||
| agent_id TEXT, | ||
| event_type TEXT NOT NULL, | ||
| payload_json TEXT, | ||
| created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| FOREIGN KEY (worker_id) REFERENCES worker_runs(id) ON DELETE CASCADE | ||
| ); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_worker_events_worker | ||
| ON worker_events(worker_id, created_at); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_worker_events_channel | ||
| ON worker_events(channel_id, created_at); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_worker_events_agent | ||
| ON worker_events(agent_id, created_at); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.