Skip to content
Workbench
Esc
↑↓navigate↵open⌘Jpreview
On this page

Business private runtime

Private conversation initialization, authorized native execution, and recoverable canonical replies.

The main application’s personal agent now has a separate user-and-organization namespace. This page describes the preserved business-private runtime, not that personal conversation.

Initialize an explicitly selected conversation

Create the client business and select an existing business-bound space before initializing private Wes. The first slice requires that space; it does not create a hidden Finance space or choose one from a list. The private conversation remains separate from shared Finance conversations and workspaces.

POST /businesses/:businessOrganizationId/private-conversations accepts only spaceId and a stable conversationId. The server verifies the selected space’s business binding and the original actor’s current internal access, creates a private conversation through the existing conversation domain, and initializes its native Pi SQLite history and owner. Retry the same identifiers after an unavailable response. agent.status: initialized means that native private identity/history exists; it does not mean a Computer filesystem, provider account, Finance workspace or greeting was provisioned. No human instruction is fabricated.

All private-runtime endpoints require both x-workbench-expected-user-id and x-workbench-expected-organization-id. These are rendered-context preconditions, not credentials: the existing Authentication middleware compares them with the actual session and returns 409 when the context changed. Missing headers are invalid requests. The server derives identity from CurrentUser and live database authority.

Execute a saved human instruction

Append the user’s message through the existing conversation API. The private reply paths are:

Method and path Behavior
POST /conversations/:conversationId/private-replies/:initiatingMessageId/start Admit that immutable human instruction; retry the same identifiers to reconcile interrupted admission
POST /conversations/:conversationId/private-replies/:initiatingMessageId/status Read native state and idempotently reconcile a completed reply into canonical messages
POST /conversations/:conversationId/private-replies/:initiatingMessageId/stop Cancel the saved original operation under current authority

Each body contains only businessOrganizationId. Browser-supplied actor, model text and runtime receipts are not authority. The shared Effect contract owns these methods and paths; http/private-replies.ts is thin composition over the domain. The status operation is POST because it can save a canonical reply. GET does not start or settle work.

Each native object has separate SQLite state addressed by firm, selected business, human and conversation in a new personal-v3 namespace. Legacy pilot histories are preserved. Admission persists immutable input and stable output identifiers before native submission. One active operation is admitted at a time. A queue acceptance receipt is not a reply.

Request authority

Pi’s generation hooks report extension failures and continue. A throwing hook alone cannot enforce authorization. The hook binds the exact native input operation to a one-use request check; the provider credential resolver consumes that check and revalidates original authority before releasing model credentials. Missing or malformed input leaves the request denied. This uses the pinned provider’s native request authentication path.

The registry has no provider tools, computer access or shared publication capability. Status, resume and stop also revalidate the saved original actor.

Automatic and recoverable canonical delivery

The same native Lifecycle instance hosts PiHarness and a small reply-delivery capability. After the immutable invocation is persisted, its stable native Lifecycle job is durably queued before Pi submission. The job observes Pi state; it does not submit a competing model task or automatically replay prepared input. Pending generation defers for two seconds, bounded by the job’s two-minute window.

A completed native result is saved through a server-only loopback RPC. Its unforgeable execution-context property must match the exact Durable Object ID derived from the principal. The server re-resolves the canonical instruction and compares the complete actor, principal and immutable input with the native result. Only a matching completed result supplies the verified context to the argument-free conversation writer. The writer rechecks current authority at insertion and retry reads. Its canonical message ID must match the persisted native output ID before the runtime records delivery.

The native job allows three SDK attempts per dispatch and at most two deferred recovery dispatches within its window. The SDK’s single-flight lease covers the bounded save callback. Unknown save outcomes retain the immutable invocation and native outcome as undelivered; they are not reported as done. Status reconciliation or retrying start can recover after the bounded automatic attempts. A duplicate save response returns the same canonical message. Revoked authority blocks delivery and retry; it does not trigger automatic deletion of private state.

Public messages expose the safe agent author and exact saved text, without runtime receipts. Saving a private reply never publishes a Client message or attachment.

Worker composition and verification

worker.ts binds BusinessPrivateAgentSession and provides BusinessPrivateRuntime at the HTTP request boundary. Its trusted native callbacks verify the caller’s object scope and current database authority. There is no public HTTP callback or administrative control route. infra/server.ts owns deployment properties and environment bindings; the Durable Object keeps its existing logical identity. The model is explicitly configured with BUSINESS_PRIVATE_AGENT_MODEL; the credential uses the existing stage-owned AI_GATEWAY_API_KEY source. Missing configuration returns 503. Neither value is accepted from a browser or model.

The native workerd test replaces the external model and canonical-writer boundaries. It exercises actual Pi, SQLite and Lifecycle delivery without a status request, restart recovery with a lost save response, controlled native single-flight expiry and alarm dispatch, and revoked publication. Core tests own immutable-operation conflicts, cancellation and interrupted admission. The HTTP suite owns actual routing, rendered scope, selected-space initialization and real database authorization/canonical insertion.

This is a local composition candidate. A read-only Alchemy plan, chosen migration ordering, independent review and hosted acceptance remain required before publication/deployment. The Computer filesystem/file handoff and provider tools are separate work; this registry has no computer or provider tools and does not initialize a shared Finance workspace.

Actual Worker loopback acceptance gap

The native fixture supplies replacement authority and canonical-writer callbacks. The HTTP fixture supplies a replacement BusinessPrivateRuntime. Neither executes the complete production path from worker.ts, through Alchemy’s actor bridge and trusted ctx.props, back to the real database and the same Durable Object. The HTTP and native tests establish their respective boundaries; they do not establish this roundtrip.

The pinned Alchemy WorkerBridge supports native ctx.exports; Miniflare supports native RPC and Hyperdrive configuration. The gap is not a missing platform feature. The production entrypoint is the Effect-native infra/server.ts: its normal build uses Alchemy’s Rolldown/runtime transforms, generated Worker/DO exports and resolved binding metadata. Its database/auth layers require the declared Hyperdrive and SQL origin. The direct Bun fixture build does not run that pipeline. An isolated probe importing the actual infrastructure entrypoint and official bridge failed while resolving the unpruned deploy-time dependency graph, including optional Vite/Astro tooling and Node imports. Adding those dependencies or replacing the Worker runtime/trust gate would not prove the production assembly. The normal pinned SDK WorkerBundle/Rolldown build has subsequently succeeded against the actual infrastructure entrypoint, emitting the real SDK Worker and Durable Object bridges. This removes the plain-Bun build limitation; it does not establish a successful database-backed roundtrip.

Additional local validation loaded that actual emitted bundle into workerd with synthetic configuration and a controlled SQL connection-failure boundary. The real default Worker RPC without trusted ctx.props returned false without opening a database connection. Calling the actual Alchemy actor’s initialization path reached the real Worker callback, passed its object-scope gate, attempted the controlled database connection and failed closed. Authority, actor, trust gate and settlement logic were not replaced. This validates bridge bootstrap and the negative authority path; it does not validate a successful canonical save or the complete same-DO publication/confirmation roundtrip.

A normal production read-only plan also succeeded: the database, runtime role, database schema resource and existing auth secret were unchanged; Server, migration and documentation/frontend updates plus the new private namespace/config bindings were planned. No resource deletion or replacement was proposed. No apply or activation occurred. The owned unshipped author migration follows the committed storage and file snapshots; its SQL stayed identical and released migrations were preserved.

After review and publication ordering, use the normal hosted PR-preview workflow for this acceptance procedure. The positive hosted procedure remains unexecuted:

  1. Inspect a read-only Alchemy plan for the selected revision and stage. Verify the new BusinessPrivateAgentSession namespace, existing Server identity, Hyperdrive binding and intended migration changes, with no unintended replacements. Obtain the actual frontend/server origins and deployed revision from the accepted preview outputs. Enable only the approved preview model and existing server-only gateway credential through normal configuration; blank configuration must still return 503. Do not read or publish credential values.
  2. Use legitimate preview memberships and business relationships: an internal original actor, a second user, and two separate client businesses with explicitly created/selected spaces. Record the test’s UUIDs privately. Initialize the first private conversation through the real endpoint with matching rendered-actor headers. Retry the same IDs and verify the same conversation and opaque agent ID. Missing/wrong space or business must fail; another user cannot read its private conversation. Initialization does not create a Computer or provider account.
  3. Append one real human message through the existing conversation endpoint. Start its native reply using only the selected business and saved conversation/message IDs. Close the initiating tab. Do not call the private status endpoint. For at most three minutes, read only the existing canonical messages endpoint as the authorized actor. Exactly one agent-authored reply must appear with the original human creator and replyToId, actual settled text and no internal receipt fields. Queue acceptance or a running model is insufficient.
  4. Correlate that operation with the actual preview Worker/DO execution and an authorized read-only database inspection. The stored operation, original actor, private principal, native provider/ref and canonical output ID must agree, and the operation must have one canonical row. This positive path exercises the real trusted loopback and same-DO status/confirmation calls; do not substitute a test service or claimed receipt.
  5. Retry start/status for the same immutable instruction and reload canonical messages: no second model admission or canonical reply may appear. A late stop on a completed reply returns stopped: false. A normal pending stop must prevent later delivery for that cancelled operation. Hosted forced-crash/lost-response recovery is not claimed by these steps; its controlled coverage remains in the native SDK fixture until separately exercised on the real deployment.
  6. Exercise stale rendered headers and tampered business/conversation/instruction IDs, then remove the original actor’s legitimate membership/permission through approved preview administration. New start, status and stop requests must fail before native work. When testing revocation after admission, compare timestamps: a reply already saved before revocation is not evidence of a failed revocation guard. An unsaved operation must not be newly delivered after revocation. Re-enabling access does not automatically authorize unrelated businesses or Client publication.
  7. Verify HTTP requests to native callback names return the shared 404; there is no browser-facing RPC bridge. The actual local emitted-bundle probe verifies a missing-ctx.props RPC denial and the trusted actor-to-database negative path. A wrong-object-property test and successful hosted canonical roundtrip remain separate acceptance checks; neither is proved by an HTTP 404. Do not add a production diagnostic endpoint to perform it.

Preserve the deployed revision, nonsecret binding names, sanitized operation correlation, canonical row counts and failures as review evidence. Keep this acceptance gap open until the actual roundtrip is observed. No preview deployment, configuration activation, membership change or infrastructure apply was performed. The observed production plan was read-only and does not authorize deployment.

Was this page helpful?