Skip to content

feat: gate cloud agents behind entitlement + default workspace pod (open-registration staging) - #529

Merged
samxu01 merged 2 commits into
mainfrom
feat/cloud-agent-entitlement-gate
Jun 29, 2026
Merged

samxu01 merged 2 commits into
mainfrom
feat/cloud-agent-entitlement-gate

Conversation

@samxu01

@samxu01 samxu01 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Prerequisites to safely open registration later (you chose stage it). registrationInviteOnly is unchanged — this only builds the gate so open signup won't hand every new user free hosted compute. The BYO/local-agent path stays open to all authenticated users.

  • Taxonomy (agentIdentityService.isCloudRuntime + CLOUD_RUNTIME_TYPES): single source of truth. host:'byo' always wins → non-cloud; webhook/claude-code are BYO; moltbot/internal/native/managed-agents + codex(non-byo) are cloud; unknown → non-cloud (open).
  • Entitlement: User.entitlements.cloudAgents (default false); admins implicitly allowed.
  • Gates (install.ts + provision.ts): cloud runtime ⇒ require admin OR entitlement, else 403 { code: 'cloud_agents_not_entitled' }. install resolves effective runtimeType from config.runtime then falls back to AGENT_TYPES[name].runtime so built-in cloud agents are caught. BYO/webhook/claude-code/host:byo never gated.
  • Default pod on signup: every new user gets a private 'My Workspace' pod so BYO onboarding has a target (best-effort; never fails registration).
  • 4 test files (taxonomy, install-gate, provision-gate, default-pod) — 599 lines.

Follow-up: frontend marketplace cloud-vs-BYO visual distinction + 403 handling (#525-adjacent).

🤖 Generated with Claude Code

samxu01 added 2 commits June 29, 2026 06:45
Prerequisite for opening registration safely (raft.build model). Adds a
single-source runtime taxonomy (CLOUD_RUNTIME_TYPES + isCloudRuntime) and a
User.entitlements.cloudAgents gate on the install + provision routes: a cloud
(Commonly-hosted) runtime now requires admin OR the entitlement; BYO/self-serve
(webhook, claude-code, host:'byo') stays open to all authenticated users.
registrationInviteOnly is unchanged. New signups get a default private
'My Workspace' pod as a BYO onboarding target (best-effort, never fails
registration). Frontend 403 'cloud_agents_not_entitled' surfacing is a followup.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Claude-Session: https://claude.ai/code/session_019vuFLFHnmJKmMxosHSWA4P
…miting)

The entitlement-gate DB lookup surfaced CodeQL's missing-rate-limiting alert on the provision route (it had no limiter, unlike install.ts). Add provisionRateLimit mirroring installRateLimit, skipped under NODE_ENV=test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Claude-Session: https://claude.ai/code/session_019vuFLFHnmJKmMxosHSWA4P
@samxu01
samxu01 merged commit 712f597 into main Jun 29, 2026
11 checks passed
samxu01 added a commit that referenced this pull request Jun 29, 2026
…a test (#532)

Add IP-keyed express-rate-limit middlewares to /register (10/hr), /login (20/15min), and /waitlist (5/hr) before open registration — the #1 pre-flip abuse guard. Mirrors the install/uploads limiter shape (skip under NODE_ENV=test, ipKeyGenerator key, 429 {code:'rate_limited'} handler). Adds a service-tier regression test asserting the hosted-agent entitlement gate: non-admin/non-entitled users 403 on cloud installs and succeed on BYO/webhook; admins and cloudAgents-entitled users pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Claude-Session: https://claude.ai/code/session_019vuFLFHnmJKmMxosHSWA4P
samxu01 pushed a commit that referenced this pull request Sep 18, 2026
…loud gate"

Decision card 69363 ruled option 1 — keep the gate (Sam 69366). The first-party
native exemption this reverts was implemented on Wren's 69359/69361 key and Sam's
69364 confirmation; Sam then overrode both, and the reason is checkable in the
repo: the first-teammate path never meets this gate. Scout is installed at
registration by the server (authController.ts:215, buildInstallationConfig) and
the hire path writes the model directly (personaHireService.ts:79-93), neither of
which goes through routes/registry/install.ts — the gate is route-level only. Its
actual subject is a non-admin adding further native apps from the Hub, and #529
deliberately routes that 403 to the BYO flow; exempting it would widen who can
consume platform compute without a pricing sentence behind it.

Content is byte-identical to 4b58841 (git diff 4b58841 HEAD is empty), so
re-gating is a zero-diff re-clear. The exemption itself is preserved in history
at ef8d8ff should a product row for it land. Non-admin tests kept: a community
row declaring native 403s, and an explicit caller runtimeType beats the manifest.

This reverts commit ef8d8ff.
lilyshen0722 added a commit that referenced this pull request Sep 18, 2026
)

* fix(registry): make a manifest's declared driver identity persist

install.ts reads manifest.runtime.runtimeType to fill a runtimeType the caller
omitted — the path a native first-party app installs through, since the Hub
sends no runtimeType of its own. No schema path existed for that field and
ManifestRuntimeSchema is strict, so every write dropped it: the fallback could
never fire and a hand-written test fixture kept it green.

- declare runtimeType on ManifestRuntimeSchema (driver identity;  stays
  the deployment shape, whose enum kept refusing 'native' — the value the
  seeder was writing into it)
- seed-native-agents: one buildRegistryManifest, identity only, no enum-invalid
  ; refreshed on every boot like the rest of the manifest
- agentManifestRegistry: carry runtimeType through publish normalization, and
  refuse a deployment shape in that field
- tests: model round-trips (constructor + upsert), the route fixture now comes
  from the real schema, seeder and validator coverage

Measured before the fix: new AgentRegistry({manifest:{runtime:{type:'native',
runtimeType:'native'}}}).toObject() == {type:'native',connection:'mcp'}.
Removing the schema path again fails 4 tests, the route fallback included.

* test(registry): pin the cloud gate against a manifest-declared runtimeType

Wren's shape read (69353) calls the entitlement consequence out as the thing to
get right: publish is plain `auth`, so with runtimeType now persisting any
owner can declare one, and install copies the manifest value BEFORE the gate
reads it. These two cases pin that shape:

- a manifest-declared 'native' install by a non-admin, non-entitled installer
  is refused with cloud_agents_not_entitled (the manifest is not a bypass)
- an explicit caller runtimeType wins over the manifest, so a manifest edit
  cannot re-shape an install the caller already typed

Both fixtures come from the real schema, so they fail if the schema path goes
away again — verified: dropping runtimeType fails the first, letting the
manifest overwrite the caller fails the second.

Open, for Vera's 69355 and Sam's ruling: whether a first-party BUILTIN native
app (scout, pod-welcomer, …) should stay entitlement-gated like every other
in-process runtime, or be exempt as the onboarding wedge. That is policy, not
code shape — this commit pins the mechanism either way.

* test(revive): the seeder writes runtimeType now; keep the `type` fallback asserted

#1733's suite pins the seeder shape it was written against — "keeps
manifest.runtime.type and drops runtimeType" — and that assertion is exactly what
TASK-043 inverts, so it fails against this branch (1 of 44 suites, on the merged
base).

The guard's intent survives the fix and stays asserted: every row the OLD seeder
wrote still carries enum-invalid type:'native' (findOneAndUpdate does not run
validators), so declaredExemptRuntime's `type` fallback is still load-bearing —
and the read-order test above it already pins runtimeType-first, which is what
makes the two PRs order-independent as Wren described.

* feat(registry): exempt first-party native installs from the cloud gate

Ruling (Wren 69359/69361, Sam 69364): first-party native apps are
entitlement-free, so the 403 the restored manifest runtimeType produced is not
intended. Scout reaches every signup ungated — authController upserts it at
workspace creation, capped by dailyRunCap — so gating the Hub copy of the same
app would gate a thing we hand out at signup. cloudAgents exists for the
operator-run tiers; the in-process native runtime is the capped one.

Exemption = effectiveRuntimeType native AND the row itself declares native AND
registry 'commonly-official' AND verified. The row, never manifest content:
publish is plain auth, so an exemption earnable by declaring 'native' would hand
any publisher in-process compute for free. Requiring the row to declare native
stops an official row's provenance being borrowed by an explicit caller
runtimeType to skip another tier's gate.

Tests (non-admin, no entitlement): official+verified native installs and
persists runtimeType; community-declared native 403s; official row that does not
declare native 403s; unverified official 403s. Mutations: dropping the exemption
fails the first, dropping the declares-native half fails the third.

* Revert "feat(registry): exempt first-party native installs from the cloud gate"

Decision card 69363 ruled option 1 — keep the gate (Sam 69366). The first-party
native exemption this reverts was implemented on Wren's 69359/69361 key and Sam's
69364 confirmation; Sam then overrode both, and the reason is checkable in the
repo: the first-teammate path never meets this gate. Scout is installed at
registration by the server (authController.ts:215, buildInstallationConfig) and
the hire path writes the model directly (personaHireService.ts:79-93), neither of
which goes through routes/registry/install.ts — the gate is route-level only. Its
actual subject is a non-admin adding further native apps from the Hub, and #529
deliberately routes that 403 to the BYO flow; exempting it would widen who can
consume platform compute without a pricing sentence behind it.

Content is byte-identical to 4b58841 (git diff 4b58841 HEAD is empty), so
re-gating is a zero-diff re-clear. The exemption itself is preserved in history
at ef8d8ff should a product row for it land. Non-admin tests kept: a community
row declaring native 403s, and an explicit caller runtimeType beats the manifest.

This reverts commit ef8d8ff.
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