feat(messaging): packaging-mode knobs for self-host integrators (PR-5d)#25
Merged
govindkavaturi-art merged 4 commits intomainfrom May 2, 2026
Merged
Conversation
Parity checkThis PR modifies files tracked in
Please confirm one of the following in a reply or PR description update:
This is a soft check — it does not block merge. The goal is visibility, not friction. See HOSTED_ONLY.md for the open-core policy. |
3 tasks
Adds three env-var flags so self-host integrators (Dock Connect first; future others) can ship cueapi-core as a SUBSET of the full surface without forking the codebase. Per the Dock-readiness PRD §"PR-5d Operational packaging knobs" (https://trydock.ai/dock/prd/cueapi-port). Flags ----- * DISABLE_CUE_PRIMITIVE — strips cues / executions / workers routers at startup. Use when running cueapi-core as a messaging-only substrate (Dock's case). * DISABLE_DEVICE_CODE — strips the email-magic-link signup flow. Use when the integrator has its own user identity system and writes to the users table directly (or via the internal endpoint added in PR-5c). * DISABLE_QUOTA_ENFORCEMENT — bypasses cue + message quota checks at the service layer. Use when the integrator's billing/plan layer already gates these one level up (Dock enforces per-tier limits in src/lib/plan.ts). All three default to ``False`` so default cueapi-core behavior is unchanged. Self-hosters override via env var. Implementation -------------- * app/config.py — three new ``BaseSettings`` fields with detailed docstrings explaining when to flip each. * app/main.py — conditional ``include_router`` calls. Health, auth, agents, messages, alerts, webhook_secret, usage, echo always mount. Cue surface mounts only when ``not DISABLE_CUE_PRIMITIVE``; device-code mounts only when ``not DISABLE_DEVICE_CODE``. * app/services/cue_service.py — quota check (active_cue_limit) wrapped in ``if not DISABLE_QUOTA_ENFORCEMENT``. * app/services/message_service.py — three quota checks wrapped: per-minute rate limit, priority-high anti-abuse, monthly quota. ``priority_downgraded`` defaulted to False when checks skipped so the return shape is stable. Tests ----- tests/test_dock_readiness_packaging_knobs.py (3 test classes, 6 cases): * TestDisableCuePrimitive — pins router presence/absence based on flag, covers the messaging-still-live invariant. * TestDisableDeviceCode — same shape for the signup flow. * TestDockMessagingOnlyMode — pins the both-flags-on combo Dock will ship with (a regression here would silently break Dock's deploy). * TestDisableQuotaEnforcement — exercises the cue create path with a user already at their cap. Default-off path returns cue_limit_exceeded (regression-pin); flag-on path succeeds. Tests use a context-manager helper (_patch_settings) that mutates the global settings object + reloads app.main so router registration re-evaluates. Settings restored on exit; no test pollutes the next. What's NOT in this PR --------------------- * PR-5a Multi-shell same-agent claims (separate PR — schema change) * PR-5b Pluggable cross-user authz (separate PR — pluggable backend) * PR-5c External auth backend + INTERNAL_AUTH_TOKEN (separate PR — auth middleware change) These three are independent — landing this PR doesn't block any of them. Each ships as its own focused review surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI surfaced two issues in the PR-5d test file: 1. ImportError: 'ScheduleConfig' doesn't exist in cueapi-core/app/schemas/cue.py The actual class is named ScheduleCreate (matches the existing CueCreate / CallbackCreate naming convention). I had assumed the private monorepo's name without verifying — fixed. 2. AuthenticatedUser doesn't have an 'api_key_id' field in cueapi-core (multi-key scoping is HOSTED_ONLY). Stripped the api_key_id=None kwarg from both AuthenticatedUser instantiations. Pure test-fixture mismatch — service-layer + flag-wiring code is untouched. CI green expected after this lands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
85dce23 to
f648c3d
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
tl;dr
Adds 3 env-var flags so self-host integrators ship cueapi-core as a SUBSET of the full surface without forking. PR-5d of the Dock-readiness PRD.
All default to `False` — default behavior unchanged.
Wire-up
Tests
`tests/test_dock_readiness_packaging_knobs.py` — 4 test classes, 6 cases:
Dock's expected config
Once this PR + PR-5c land, Dock's deploy config will be:
```
DISABLE_CUE_PRIMITIVE=true
DISABLE_DEVICE_CODE=true
DISABLE_QUOTA_ENFORCEMENT=true
EXTERNAL_AUTH_BACKEND=true # PR-5c
INTERNAL_AUTH_TOKEN=... # PR-5c
```
Test plan
🤖 Generated with Claude Code