Decisions and trade-offs

The choices that shaped Pipal, why each was made, and what each one costs.

9 min read

You close a tab on a half-written answer and later open the same chat. The reply and the tab have different lifetimes because the Pipal host owns the work. Start there when you want to understand why Pipal keeps some things on disk, some in memory, and some on a different machine.

Durability

One Pi Durable harness on local SQLite. Pipal uses Pi’s published Node SQLite adapter, task scheduler and model interface. Pipal’s own conversation document lives beside Pi’s records, so accepting a prompt can save the input, task and deadline together. The checkout pins the Pi packages. When an upgrade changes these interfaces, the recovery suite checks the contract across a forced process exit. See Durable by default. index.ts adr-runtime.md pnpm-workspace.yaml recovery.test.ts

One process owns a data directory. Pipal holds an exclusive SQLite transaction on owner.sqlite. SQLite and the operating system release the lock when the connection or process dies, so a replacement can open the store without stale lock cleanup. The same choice means you need SQLite-compatible file locking and only one Pipal process can own the directory at a time. See Where everything lives and runs. store-lock.ts index.ts

One outstanding input per chat. Pipal checks the request ID and the original input inside the acceptance transaction. A client that lost the HTTP reply can ask again without writing a second user entry. An input with changed content needs a new ID, and a different input has to wait for an active run to end. See The core runtime. index.ts adr-runtime.md

Interrupted tools need an explicit replay policy. Pi can retry a model request and wake a tool with a saved checkpoint. Pi defaults to recording an error for a tool invocation cut off by process death. A tool declared replay-safe can run again. The default protects against repeating a call that may already have changed something outside SQLite. That leaves a connector responsible for recognizing or reconciling an ambiguous write, including when the model asks for the same action as a later call. A retried model request can also incur a second charge. See Durable by default. README.md recovery.test.ts adr-runtime.md

Keep prepared attachments with the input. The images and text that a model needs are part of the saved message, so a recovered run can build its context from SQLite. The uploaded originals serve display and preparation for a new send. The batch limit during preparation counts up to 12 MiB of UTF-8 text and base64 image data before the filename labels are added. Prepared parts travel in model context while in scope. History uses small pages because Pi reads model input along with each entry. See Files in, artifacts out. index.ts uploads.ts architecture.md

Derive search from saved messages. Pipal builds an in-memory SQLite full-text index from Pi’s public transcript reads. That avoids a second on-disk transcript and a dependence on Pi’s table layout. The first search of recent or archived chats after restart indexes the chats in that view, and pending searches wait their turn. Indexed rows stay in memory for the life of the runtime. See Search, context and cost. transcript-search.ts index.ts

The wire

Start every stream with a fresh view. A reconnect needs no saved cursor. The server sends the current window, then sends full snapshots by default. Clients can opt into compact updates that reuse the committed messages or deltas that carry edits. The bundled client uses deltas, so it keeps a baseline and checks the next revision on that connection. The stream reports what the host can see now, including live output that may still be awaiting a disk flush. See Live streams. app.ts watch-conversation.ts adr-runtime.md

Check shape at the door and meaning in core. Hono checks content type and body fields. Core checks what the requested operation means for the current conversation, so a tool or test calling core meets the same chat rule as an HTTP client. The browser repeats some limits for early feedback. For example, it checks the formatted message length before sending, and core enforces the limit for its callers. Hono separately checks the shape of each text-file entry. See The Hono server. request.ts app.ts index.ts App.svelte

Access

Listen on loopback and hand HTTPS to a proxy. The Node listener stays local. For remote access, a proxy on the host provides HTTPS, while Pipal still checks its own token or passkey session. Remote deployment needs that proxy to terminate TLS. When its public URL is the configured origin, writes through a tab at the local listener’s own origin are refused. See Deploying Pipal. config.ts main.ts app.ts Caddyfile architecture.md

Keep the browser API on one origin. The host’s browser API has no cross-origin opt-in through CORS. Its session cookie and exact Origin check work with a client served from the configured origin. A replacement browser client must share that origin. See The security model. app.ts architecture.md

Offer passkeys as an alternative to the default token. A passkey sign-in requires user verification on an enrolled authenticator. The host stores credential IDs, display names, public keys and signature counters, and getting a new setup or recovery code requires access to the host’s private files. The price is a hostname binding and a recovery procedure: moving to a different hostname with enrolled keys requires setting the old store aside and enrolling again. To issue a recovery code for an existing store, the operator starts the host with PIPAL_PASSKEY_RECOVERY=1. See The security model. config.ts passkeys.ts passkey-store.ts main.ts

Tools and projects

Keep host project inspection read-only. The host reader gives Code reviewer Pi’s normal read tool over a checking file environment, alongside search helpers. The operator enables the reader and the role needs its grant. Its path checks assume trusted parent directories. The host reader sees its configured root. When the review concerns a Docker project outside that root, Developer can supply the diff and relevant files. See Three ways to touch a project. coding.ts coding-environment.ts developer.md architecture.md

Give Docker project calls fresh containers. In the Docker locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project., ordinary shell and file calls use the project volume from short-lived containers with no network and dropped capabilities. Files persist on the volume while each call gets a new process environment. The trade is a trusted engine and image, one call at a time per volume and a container start for each ordinary shell or file operation. Access to a rootful Docker engine carries root-equivalent privilege. An interrupted write or command can leave effects in the volume. The separately enabled clone operation gives its fetch container network access and mounts only the staging directory from the project volume. See The Docker project. project-shell.ts project-coding.ts server.md

Save published files with the chat. publish_file captures the project file’s bytes in an immutable entry. The download keeps working after the workspace copy changes or is removed, and a revision keeps the earlier entry available. See Files in, artifacts out. project-coding.ts web-artifacts.ts

Keep public web lookups outside the project shell. Developer can consult documentation while Docker commands stay offline. With pipal.web-search, a compatible model provider can search during generation. The independent pipal.public-web grant gives Developer two keyless host tools. Exa receives the search terms when Developer needs a fallback. Jina Reader receives the URL when Developer needs a particular page. Both grants are opt-in. See Tools and extensions. developer.md public-web.ts

Let the owner choose where development runs. The owner enables locations in Settings → Workspace. A fresh store starts with every location off. An existing SQLite store without saved workspace settings imports the configured SSH or Docker location when its project tools are enabled. This machine follows a single-user setup where the chat service runs Bash directly. Setup needs no separate login, and approved commands share the service user’s access to files, including the chat database and saved model login. SSH machine preserves the separation of accounts. The operator maintains the development login and verifies its host key. See The development workspace. workspace-locations.ts development-workspace.ts adr-development-workspace.md

Either development workspace lets another chat on the same project reuse its checkout, dependencies and services. The browser remembers a project per location. When names can be created, its fallback is pipal-scratch. The host can open or create the named directory before it commits the new chat. That chat keeps its original location and project identity, so changing either or replacing the directory requires a new chat. The project directory supplies a starting point for tools. Docker or a service manager can own a service beyond the end of a shell call. index.ts workspace-choice.ts adr-development-workspace.md

Ask before workspace changes. A gated tool parks, which means it saves its waiting state and gives up its active invocation. Approval can survive restart and a waiting top-level run need not hold an admission slot. A pending request can wait until a decision or a stop, and disabling the location interrupts the work there. Reads skip this gate. Opting in to YOLO lets eligible calls proceed under the matching workspace grant and gives up per-call review. See Approvals and YOLO. index.ts runtime.test.ts architecture.md

Keep Pi’s role composition and put Pipal’s roles in Markdown. Pipal supplies the profile’s instructions and adds the permitted specialist names when the chat can delegate. Pi composes those instructions with the enabled extensions’ prompt sections. The Markdown supplies instructions for each role, and the declared grants determine which extensions it can actually use. See Profiles and models. profiles.ts index.ts adr-runtime.md

Let Chat choose a permitted specialist. The default Chat instructions tell it to route host checks, project work and reviews to specialists with their own grants. Chat’s own profile lists optional artifact and search extensions. Delegation lets it request work under the specialist’s separate grants. A foreground specialist shares the parent’s deadline and concurrency slot. Its tool rounds count toward its own limit. Chat and Developer can both use hosted web search when granted and supported by the model. See Delegation and Tools and extensions. chat.md developer.md index.ts hosted-search.ts

Run tool calls in sequence and park the foreground delegate. Sequential execution keeps call order and lets an admitted parent drive one foreground specialist at a time. Independent calls in a round wait behind a slow call. When the delegate parks, its child can finish while the parent holds no tool invocation, and settlement wakes the parent with the answer reference. Delegation stays one level deep. The result can also hand back download cards for files the specialist already published. See Delegation. index.ts delegate.ts recovery.test.ts adr-runtime.md architecture.md

Give long development jobs their own run. An independent worker has a child conversation, a saved handle, a separate budget and a transcript. It works in the parent’s named project on This machine or SSH machine. A parent can wait with a timeout and check again while the worker keeps going. That independence means stopping the parent response can leave the worker running. The worker has a separate stop operation for its current assignment. A service started under its own manager can outlive both runs. See Workers. workers.ts index.ts runtime.test.ts adr-development-workspace.md

Save hosted search metadata beside the answer. A provider-specific adapter translates search activity and citations into Pipal’s versioned metadata. That lets the transcript show what the provider searched after reopening the store. Pipal depends on the pinned Pi adapter retaining that metadata, and provider differences require separate adapters. See Tools and extensions. hosted-search-capabilities.ts search-metadata.ts view.ts adr-runtime.md

The UI

Bundle UI extensions at build time. The installer activates a snapshot of the exact commit the operator supplies, and Vite bundles its code into the client. The page can keep a same-origin script policy. Changing the installed set takes a rebuild and reload. A browser can disable an installed extension for its workspace and apply that choice on reload. See Extending the UI. ui-extension.mjs load-ui-extensions.ts extension-preferences.ts index.html

Recap

  • The host owns a durable local store. A browser connection observes it and can start again with a fresh view.
  • The operator sets up execution destinations. The signed-in owner enables locations, and a chat keeps the location and project it started with.
  • The pinned runtime and build-time extension interfaces give contributors specific seams to verify when they change Pipal.

In the source

Book contents

Search the book