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-hostSource, 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.
See where this package fits.
Follow a declared connection, inspect an import, then open the source guide when you need the detail.
Arrows point from a package to its direct dependency. Each count is derived from the captured manifests.
@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
- Couche:
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 atapp/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.
- REST —
- 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(useOpaBookingplus the typed./availabilityprojections): anonymous visitors load the availability quote, pick a slot and create a booking intent bound to itsavailabilityRef/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:
Session projection (
src/session-context.ts,createOpaHostSessionContext). AnAuthorization: Bearertoken is checked against AuthOS (/api/auth/get-session, throughcreateBetterAuthBearerSessionReader) 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 }, wheretenantId/workspaceIduse the OPA ref grammar (tenant:<segment>,workspace:<segment>) androlesis 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'srequireWorkspaceModule(session, 'opa'), the host requiresopain the authority read'senabledModules. When the list is missing or lacksopa, the user ctx gets adecidethat answers 403 on every non-public operation, whatever the persona; public operations stay reachable as for an anonymous caller. A malformedenabledModulesis treated as no authority (401).RBAC binding (
src/opa-host-rbac.ts,createOpaHostRbac). Identity RBAC'sRBACPolicyEngineplus one user-bound, tenant-tagged binding per CompanyOS persona.opa.loop.execute(admin, founder approver, operations manager) andopa.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 throughOpaBuildDeps(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_revieweropa.meeting_workspace.get,opa.meeting_artifact.list/get,opa.meeting_artifact.review_decideauditoropa.meeting_workspace.get,opa.meeting_artifact.list/get(read-only)frontline_staffopa.meeting_workspace.getai_operatornone (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 insrc/opa-host-rbac.ts.Policy decision point (
src/opa-host-policy.ts). WhencreateOpaRestHandler(ctxFactory, { rbac })is given an RBAC port, every request context gets adecidethat 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 contextdecidecan only narrow the result. Bindings are tenant-scoped like the runtime'sauthorizeOpaOperation(src/opa-host-tenant-scope.ts): grants tagged, scoped or targeted to another tenant are dropped, and own-tenanttenantIdortenant-scope grants are honored. The runtime authority port still rejects a resource from another workspace (403). Without an RBAC port,createOpaRestHandleris default-deny: a non-anonymous ctx that brings nodecideof its own (such as the onecreateOpaHostSessionContextprojects) 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 | Objectif |
|---|---|
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 testsbun run typecheck— TypeScript checkbun 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 entriesThese 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
- @lssm-tech/integration.authos-better-auth
- workspace:*
- @lssm-tech/lib.contracts-runtime-server-mcp
- workspace:*
- @lssm-tech/lib.contracts-runtime-server-rest
- workspace:*
- @lssm-tech/lib.contracts-spec
- workspace:*
- @lssm-tech/lib.design-system
- workspace:*
- @lssm-tech/lib.identity-rbac
- workspace:*
- @lssm-tech/lib.logger
- workspace:*
- @lssm-tech/lib.organization-planning-runtime
- workspace:*
- @lssm-tech/lib.organization-planning-spec
- workspace:*
- @lssm-tech/lib.translation-runtime
- workspace:*
- @lssm-tech/module.organization-planning
- workspace:*
- @lssm-tech/opa-booking-react
- workspace:*
- @modelcontextprotocol/sdk
- catalog:ai
- @pothos/core
- catalog:graphql
- lucide-react
- catalog:ui
- next
- catalog:
- react
- catalog:
- react-dom
- catalog:
- zod
- catalog:
Development dependencies 5
- @lssm-tech/tool.bun
- workspace:*
- @lssm-tech/tool.typescript
- workspace:*
- @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.
rimraf dist .turbobun lint:fixnode ../../../scripts/biome.cjs check --write .node ../../../scripts/biome.cjs check .bun testtsgo --noEmit