Skip to content

fix: harden queue recovery semantics#2

Open
mikehostetler wants to merge 5 commits into
bedrock-kv:mainfrom
mikehostetler:intent-ledger/recovery-semantics
Open

fix: harden queue recovery semantics#2
mikehostetler wants to merge 5 commits into
bedrock-kv:mainfrom
mikehostetler:intent-ledger/recovery-semantics

Conversation

@mikehostetler

@mikehostetler mikehostetler commented May 15, 2026

Copy link
Copy Markdown

Summary

Stacked on #1. This branch is based on intent-ledger/action-hooks; review after or with #1. GitHub could not use #1 as the upstream base because that branch only exists on the fork, and I do not have permission to create the base branch in bedrock-kv/job_queue.

  • rollback queue transactions when action hooks fail
  • make expired item leases visible/re-leaseable for recovery
  • allow supervisors to use a precomputed root keyspace for integration tests
  • forward scanner, lease, backoff, and GC options from the supervisor into the consumer runtime
  • accept the current Store.extend_lease/5 return shape in the lease extender
  • scan raw item ranges for real Bedrock repos while keeping mock/keyspace tests compatible
  • add regression coverage for hook rollback, hook action metadata for complete/requeue/snooze/discard outcomes, expired lease visibility, precomputed roots, option forwarding, direct lease-extension return values, and real Bedrock raw range scans

Tests

  • mix test


# Initialize the directory and cache the keyspace before starting supervisor
{:ok, root} = Internal.init_root(config.repo, job_queue_module)
root = Keyword.get_lazy(opts, :root, fn -> init_root!(config.repo, job_queue_module) end)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

blocking: If callers pass a precomputed root, the consumer starts against that root, but the public JobQueue.enqueue/4 path still resolves its root via Internal.root_keyspace/1. Because this path skips Internal.init_root/2, nothing writes the supplied root into :persistent_term, so enqueue can fall back to Keyspace.new("job_queue/<module>/") while the consumer scans the supplied root. Either cache the provided root here or make the public enqueue/stats path read the same configured root.

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