appsWorkspace onlyv0.1.6

app.organization-planning-host

Thin OPA host: mounts the organization-planning operation registry on REST, GraphQL, and MCP surfaces via the shared contracts-runtime adapters.

@lssm-tech/app.organization-planning-host
Source, release and verification context

Source snapshot bcc79fcc · Declared package version 0.1.6. This page combines the checked-in package guide and manifest; commands and runtime behavior were not executed in this review.

Package source ↗ Manifest ↗
EXPLORE THE PACKAGE

See where this package fits.

Follow a declared connection, inspect an import, then open the source guide when you need the detail.

THIS PACKAGEapp.organization-planning-hostapps

Arrows point from a package to its direct dependency. Each count is derived from the captured manifests.

20 declarations · first 6 shownSELECT TO INSPECT

@lssm-tech/app.organization-planning-host

Website: https://contractspec.io

Thin OPA host — mounts the organization-planning operation registry on REST, GraphQL, and MCP.

What It Provides

  • Layer: app. (thin deployable host; transport wiring only).
  • Exposes buildOpaOps() (from @lssm-tech/lib.organization-planning-runtime) identically on three surfaces via existing contracts-runtime adapters:
    • REST — createOpaRestHandler(ctxFactory), served by the Next App Router catch-all at app/api/ops/[...route]/route.ts.
    • GraphQL — createOpaGraphqlBuilder() returns a Pothos builder with the OPA query/mutation fields.
    • MCP — mountOpaMcp(server, ctxFactories) registers the OPA tools.
  • Serves the public booking page at app/book/[link]/page.tsx. The page speaks the OPA v2 public booking protocol through @lssm-tech/opa-booking-react (useOpaBooking plus the typed ./availability projections): anonymous visitors load the availability quote, pick a slot and create a booking intent bound to its availabilityRef/slotRef. The booking link must allowlist this host's origin; only name, email, timezone and locale are sent.

Auth

Fail-closed at every step. The REST route (app/api/ops/[...route]/route.ts) composes three pieces:

  1. Session projection (src/session-context.ts, createOpaHostSessionContext). An Authorization: Bearer token is checked against AuthOS (/api/auth/get-session, through createBetterAuthBearerSessionReader) and then against the caller's own CompanyOS authority (GET /api/companyos/auth/authority, same bearer, no cookies or redirects, 1.5 s budget, answer at most 5 s old). The session and active organization must match, and the identity is read again after the authority read. The result is { actor: 'user', userId, organizationId, tenantId, workspaceId, roles }, where tenantId/workspaceId use the OPA ref grammar (tenant:<segment>, workspace:<segment>) and roles is the CompanyOS persona (grantRole). Anything else is { actor: 'anonymous' }, which the REST adapter rejects with 401 on every non-public operation. Module entitlement (src/opa-workspace-module.ts). Like the monolith's requireWorkspaceModule(session, 'opa'), the host requires opa in the authority read's enabledModules. When the list is missing or lacks opa, the user ctx gets a decide that answers 403 on every non-public operation, whatever the persona; public operations stay reachable as for an anonymous caller. A malformed enabledModules is treated as no authority (401).

  2. RBAC binding (src/opa-host-rbac.ts, createOpaHostRbac). Identity RBAC's RBACPolicyEngine plus one user-bound, tenant-tagged binding per CompanyOS persona. opa.loop.execute (admin, founder approver, operations manager) and opa.booking.approve (admin, founder approver) follow the api-application-monolith bindings. The profile capabilities (opa.profile.read/manage/publish) and every capability of the meeting-workspace operations a deployment can install through OpaBuildDeps (opa.meeting_policy.*, opa.meeting_workspace.*, opa.meeting_context.*, opa.meeting_artifact.*, opa.meeting_work_session.*, opa.meeting_outcome.*, opa.meeting_dispatch.*, opa.meeting_share.*, opa.recording.source_bind) go to the OPA personas of the managed-companyos coverage manifest (founder approver, operations manager) and the admin. The manifest gives the other personas no OPA coverage, so they get only the meeting capabilities of their AuthOS built-in role template:

    Persona Meeting operations allowed
    expert_reviewer opa.meeting_workspace.get, opa.meeting_artifact.list/get, opa.meeting_artifact.review_decide
    auditor opa.meeting_workspace.get, opa.meeting_artifact.list/get (read-only)
    frontline_staff opa.meeting_workspace.get
    ai_operator none (not an assignable AuthOS role)

    Every other operation answers 403 for these personas, including opa.meeting_work_session.*, policy, context, dispatch and sharing, and unknown roles get no binding at all. The runtime authority port still checks the actor's own grant on each meeting resource. An operation group whose capabilities have no persona grant answers 403 for every persona until its capabilities are mapped in src/opa-host-rbac.ts.

  3. Policy decision point (src/opa-host-policy.ts). When createOpaRestHandler(ctxFactory, { rbac }) is given an RBAC port, every request context gets a decide that requires the operation's declared capability for a resolved tenant and workspace actor. Public (policy.auth: 'anonymous') operations pass, unknown operations and missing grants are 403, and a context decide can only narrow the result. Bindings are tenant-scoped like the runtime's authorizeOpaOperation (src/opa-host-tenant-scope.ts): grants tagged, scoped or targeted to another tenant are dropped, and own-tenant tenantId or tenant-scope grants are honored. The runtime authority port still rejects a resource from another workspace (403). Without an RBAC port, createOpaRestHandler is default-deny: a non-anonymous ctx that brings no decide of its own (such as the one createOpaHostSessionContext projects) gets one that answers 403 on every non-public operation. Pair the session projection with { rbac }.

Known scope: the CompanyOS authority read does not return the selected team or sub-workspace, so the host scopes OPA to the active organization's workspace (workspace:<segment(activeOrganizationId)>). The route binds no profile or meeting persistence, so it serves only the operation groups a deployment configures through OpaBuildDeps.

Variable Purpose
OPA_HOST_AUTHOS_BASE_URL Origin (no path) of the CompanyOS API, which serves AuthOS and the authority read. Unset → every caller is anonymous. HTTPS only, except http://localhost. A value that is not an exact origin (trailing slash, path, credentials, HTTP on another host) is logged once as opa_host.invalid_authos_base_url when the route loads, and every caller is then anonymous; public operations keep working.
OPA_HOST_INSECURE_DEV 1 enables the LOCAL-ONLY x-opa-dev-user/-tenant/-workspace/-roles headers when no bearer is sent. Ignored when NODE_ENV=production; the dev subject still needs a persona in x-opa-dev-roles.

The MCP mount (mountOpaMcp) still takes the caller's toolCtx; it does not use this session projection yet.

Local Commands

  • bun run test — smoke tests (3 surface mounts + REST round-trip), session projection, REST default-deny and RBAC tests
  • bun run typecheck — TypeScript check
  • bun run lint:check — Biome check

Declared capabilities.

This manifest does not declare a capability catalogue. Use the guide, import map and source to assess the package.

Imports and export paths.

0 entries

These are package-manifest entry points. Named symbols listed above come from the capability catalogue; this is not an exhaustive TypeScript symbol reference.

This workspace does not declare package export paths.

Dependencies and related packages.

Runtime dependencies 20
@modelcontextprotocol/sdk
catalog:ai
@pothos/core
catalog:graphql
lucide-react
catalog:ui
next
catalog:
react
catalog:
react-dom
catalog:
zod
catalog:
Development dependencies 5
@types/react
catalog:types
@types/react-dom
catalog:types
typescript
catalog:

Package scripts.

Commands declared by this package. Review its setup requirements before running them; no command here was executed by this review.

cleanrimraf dist .turbo
lintbun lint:fix
lint:fixnode ../../../scripts/biome.cjs check --write .
lint:checknode ../../../scripts/biome.cjs check .
testbun test
typechecktsgo --noEmit
Your view

Make room for your context.

Shape the presentation around this moment. You can change it whenever you need.

Your context

The different parts of you

Choose a starting point

A useful mix of context, visuals and gentle guidance.

Tune each dimension
Each dimension can change independently. Product permissions and available actions stay unchanged.

Support the way you begin and return

Tune your support

Reading comfort

Choose your language

Interface language changes text only. Markets, prices and workflows keep their own settings.

Translation coverage

Original source

Navigation151
Graph616
Categories378
Portfolio833
Examples2,035
Source preview1,542

More translations will be added as content is reviewed.

This preference is saved on this browser.

Search the website

Useful starting points

No results. Try a shorter phrase, an operation name or another search area.

A LITTLE ROOM TO EXPLORE

Find something to explore.

Open a closer look on this page, try a different perspective, or follow the detail into its own page.

How previews and controls work
01

Look before you leave

Hover a link or focus it with Tab to see a preview. Clicking the original link or pressing Enter always opens its destination.

02

Stay with the context

Move into the preview to explore its sections. Use Alt + ↓ from a focused link to enter it with the keyboard. Escape closes it.

03

Open the possibilities

Disclosure rows, perspective choices and highlighted controls reveal more. Your view changes reading comfort and the context you explore.

A separate button for a closer look

Show small preview buttons beside links where there is room. Tap the eye to inspect, or tap the link to go straight there. This choice stays in this tab.

No browsing history is collected. Reduced motion follows your device and Your view.