Skip to content

feat(messaging): packaging-mode knobs for self-host integrators (PR-5d)#25

Merged
govindkavaturi-art merged 4 commits intomainfrom
feat/dock-readiness-5d-packaging-knobs
May 2, 2026
Merged

feat(messaging): packaging-mode knobs for self-host integrators (PR-5d)#25
govindkavaturi-art merged 4 commits intomainfrom
feat/dock-readiness-5d-packaging-knobs

Conversation

@govindkavaturi-art
Copy link
Copy Markdown
Member

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.

Flag Effect
`DISABLE_CUE_PRIMITIVE` Strips cues / executions / workers routers at startup
`DISABLE_DEVICE_CODE` Strips email-magic-link signup flow
`DISABLE_QUOTA_ENFORCEMENT` Bypasses cue + message quota checks at the service layer

All default to `False` — default behavior unchanged.

Wire-up

  • `app/config.py` — three new `BaseSettings` fields
  • `app/main.py` — conditional `include_router` calls (gated on `not `)
  • `app/services/cue_service.py` — `active_cue_limit` check skipped when quotas disabled
  • `app/services/message_service.py` — per-minute rate-limit + priority anti-abuse + monthly quota all skipped when quotas disabled

Tests

`tests/test_dock_readiness_packaging_knobs.py` — 4 test classes, 6 cases:

  • `TestDisableCuePrimitive` — flag default-off keeps cue routes; flag-on strips them; messaging stays live
  • `TestDisableDeviceCode` — flag default-off keeps signup; flag-on strips it
  • `TestDockMessagingOnlyMode` — pin Dock's expected combo (both flags ON, messaging-only)
  • `TestDisableQuotaEnforcement` — exercise cue create path with user at cap; flag-off returns `cue_limit_exceeded` (regression-pin); flag-on succeeds

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

  • CI `test` + `sdk-integration` + `parity-check` green
  • Local `pytest tests/test_dock_readiness_packaging_knobs.py -v` passes 6/6
  • Existing tests still pass (no regressions)
  • After merge: hosted cueapi prod still mounts everything (defaults preserved)

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

Parity check

This PR modifies files tracked in parity-manifest.json:

  • app/config.py
  • app/main.py
  • app/services/cue_service.py
  • app/services/message_service.py

Please confirm one of the following in a reply or PR description update:

  1. The equivalent change has been applied to the private cueapi monorepo. Link the PR.
  2. This change is OSS-only and does not need porting. Briefly explain why (e.g. "fixes a bug that only exists in the OSS build").
  3. A follow-up issue has been filed to port the reverse direction. Link the issue.

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.

Gk and others added 2 commits May 2, 2026 01:35
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>
@govindkavaturi-art govindkavaturi-art force-pushed the feat/dock-readiness-5d-packaging-knobs branch from 85dce23 to f648c3d Compare May 2, 2026 08:35
@govindkavaturi-art govindkavaturi-art enabled auto-merge (squash) May 2, 2026 08:49
@govindkavaturi-art govindkavaturi-art merged commit d042c5d into main May 2, 2026
5 checks passed
@govindkavaturi-art govindkavaturi-art deleted the feat/dock-readiness-5d-packaging-knobs branch May 2, 2026 08:49
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