Skip to content

Add tenant-discriminated claims for a shared queue - #1

Open
phernandez wants to merge 3 commits into
mainfrom
codex-tenant-discriminator
Open

Add tenant-discriminated claims for a shared queue#1
phernandez wants to merge 3 commits into
mainfrom
codex-tenant-discriminator

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

Basic Memory Cloud needs one shared agent queue while PGQ retains tenant admission and fairness. A PGQ worker must execute one ready Absurd batch for its selected tenant without creating a queue/table set per tenant.

What Changed

  • Optional task discriminator at spawn, with a (discriminator, task_id) index.
  • Optional fifth claim_task argument, applied before ordering, limiting, and locking. Cancellation and expired-lease maintenance use the same discriminator.
  • Idempotency-key collisions across discriminators raise instead of returning a task from another tenant.
  • ready_discriminators discovers ready work and due maintenance without claiming it.
  • Python synchronous and asynchronous spawn, claim, work_batch, and ready-discriminator methods.

Implementation Details

The discriminator belongs to the logical task, so retries and resumed runs preserve it without changing run/checkpoint logic. Omitting the claim discriminator retains queue-wide behavior. This is an admission aid, not an authorization or fairness system; PGQ owns those decisions and holds its slot while awaiting work_batch.

Testing

  • uv run --directory tests pytest -q --ignore=test_cron_pgcron_e2e.py --ignore=test_build_absurdctl.py: 172 passed.
  • uv run --directory sdks/python pytest -q: 95 passed.
  • Removed the SQL claim filter temporarily: both partitioned and unpartitioned regression cases failed by claiming the other tenant. Restored afterward.

Risks / Follow-ups

This fork targets fresh installations; an upgrade migration for existing Absurd queues is not included. SQL and Python SDK must be installed together. Other SDKs retain their existing unfiltered behavior. Full pg_cron container and CLI build tests were not run. Cloud integration and development runtime acceptance remain in basicmachines-co/basic-memory-cloud#1980.

AI Assistance

Implemented, tested, and described with Codex. This PR is against the Basic Machines fork, not an upstream contribution.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T00:10:27.584250Z de81f76 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22f3a41a83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sql/absurd.sql

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71c1b5997c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/discriminator.md
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.

1 participant