Skip to content

feat(broker): add Core-only Broker Alpha - #67

Merged
jiangxt2 merged 3 commits into
masterfrom
feat/redis-stream-integration
Aug 20, 2026
Merged

feat(broker): add Core-only Broker Alpha#67
jiangxt2 merged 3 commits into
masterfrom
feat/redis-stream-integration

Conversation

@jiangxt2

@jiangxt2 jiangxt2 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Description

This PR introduces a Core-only, transport-neutral Broker Alpha API so external provider packages can integrate Redis Streams or other brokers without adding transport dependencies or production consume loops to Tributo.

The change:

  • defines Broker API v1 contracts for plugin discovery, configuration validation, runtime construction, message disposition, and credential-safe errors;
  • adds lazy, fail-open plugin discovery with diagnostics while keeping explicit provider resolution and validation fail-closed;
  • adds a workload-neutral RayJobSubmission contract, deterministic submission_id generation, ambiguous Ray Jobs submission reconciliation, and status/stop operations keyed by submission_id;
  • keeps ray_job_id optional and populates it only from a real Ray JobDetails.job_id;
  • adds identity-aware training and batch-inference submission adapters while preserving existing in-process execution and result contracts;
  • adds lazily loaded tributo broker list and tributo broker validate commands without importing broker registries or providers on normal CLI paths; and
  • documents the Alpha stability boundary and adds API, CLI-isolation, discovery, submission-reconciliation, identity, and regression tests.

This is an Alpha API change. Provider packages own transport connections, consumer groups, acknowledgements, re-delivery and recovery, cancellation watchers, external task/event schemas, production consume runtimes, and terminal-event durability. Core does not add Redis dependencies, provider runtime-environment injection, a generic consume loop, worker-side broker cancellation, or exactly-once guarantees.

Normal Tributo CLI and runtime behavior remain unchanged when no broker provider is selected. pyproject.toml and uv.lock are unchanged.

Related issues

None.

Additional information

Validation on commit f0d8e93c2af12db29575b920cd2589ae55ea72d9:

  • uv run --locked --no-sync python scripts/pr-precheck.py --skip-tests passed with the repository's existing non-blocking warnings. The command's CI-parity unit-test matrix passed on Python 3.12 and 3.13, and strict docs and spelling checks passed. The changed-test selection was also exercised once on the same final HEAD and is covered by the passing CI-parity matrix.
  • git diff --check origin/master...HEAD passed.

Redis/Ray provider Docker integration tests were not run in this repository. Those healthy-path and transport-recovery tests belong to the independently versioned provider package and are outside this Core-only PR.

…eneric runner

Tributo needs an optional control-plane integration for internal Redis
Streams tasks, lifecycle events, and cooperative cancellation. Redis and
KnoVa protocol models must stay in a separately installed provider wheel,
so Core only gains a safe, lazily loaded, versioned Broker extension
contract. The provider wheel is developed separately (independent
tributo-broker-redis repository); this branch carries only the Core side.

- Broker SPI: BrokerPlugin, BrokerRuntime, TaskConsumer, EventReporter,
  CancellationChecker, Message/JobResult identity fields, TaskDisposition,
  and JSON-safe CancellationSpec; new dataclass fields default so existing
  constructions keep working.
- Lazy discovery: tributo.brokers entry-point group, fail-open discovery
  with diagnostics, fail-closed explicit resolution, TRIBUTO_PLUGINS
  filtering, and api_version/broker_id/capabilities contract checks.
- Broker Registry and generic BrokerRunner with ACK/RETRY/REJECT, bounded
  reconnect backoff, DEGRADED/RECONNECTING lifecycle states, and graceful
  shutdown.
- Lazy CLI: broker list/validate/consume mounted through a lazy Click
  group; importing tributo.cli does not import the broker modules.
- Runtime injection: build_runtime_env extra_py_modules/runtime_pip_packages
  and submit_training_job execution_context plumbing; the default path adds
  no pip section.
- Identity mapping: submit_training_job_with_identity returns run_id,
  attempt_id, submission_id, and the Ray execution job_id; reconcile
  resolves the real execution ID when available and retains a
  compatibility fallback.
- Training bridge: worker-side cancellation checker rebuilt from JSON-safe
  specs (fail-open), _tributo_* keys stripped before strict config
  validation, cancel state surfaced in report metrics, and Ray Train
  metrics/history preserved in the lifecycle summary for provider replay.
- Docs: STABILITY.md beta entries for the three broker modules and ADR 002
  (broker plugin boundary).

- Targeted Core suite (broker SPI, discovery, runner, CLI isolation,
  runtime env, stability inventory, training lifecycle):
  `pytest -p no:cacheprovider tests/test_broker.py tests/test_broker_cli.py
  tests/test_runtime_env.py tests/test_stability_inventory.py
  tests/training/test_job_submitter.py
  tests/training/test_training_lifecycle.py -q` — 766 passed, 6 skipped.
- Full Core non-IT regression:
  `pytest -p no:cacheprovider tests --ignore=tests/integration -q` —
  2867 passed, 40 skipped, 171 deselected.
- Core Ray runtime-environment IT:
  `tests/integration/test_ray_runtime_env.py -m ray_runtime_env` —
  1 passed.
- Lint: ruff format check and ruff check on the changed files pass, plus
  pre-commit hooks; git diff --check passes.
- Real Redis Stream/Ray provider IT is intentionally excluded from this
  Core-only commit and is maintained in the independent provider
  repository.

- [x] Unit tests pass
- [x] Lint passes for changed Python files (ruff format --check, ruff check, and pre-commit)
- [x] Integration tests pass (if applicable) — Core ray-runtime IT passed; real Redis/Ray provider IT lives in the independent provider repository
- [x] No internal credentials, URLs, or tokens exposed
- [x] New external dependencies reviewed for license compatibility — no new dependencies

Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
@jiangxt2
jiangxt2 marked this pull request as ready for review August 20, 2026 05:08
@jiangxt2
jiangxt2 merged commit 4a73578 into master Aug 20, 2026
14 checks passed
@jiangxt2
jiangxt2 deleted the feat/redis-stream-integration branch August 20, 2026 05:08
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