Decisions, trade-offs, limitations, and an honest roadmap
T3 Code's architecture is a set of bounded choices: server authority, transactional events, hot reactors, cursored projections, adapters, scoped reconnect, durable mobile intent, exact-version updates, and demand-driven background work each make one failure mode tractable while deliberately leaving another visible.
What this chapter resolves
- Read the major architectural choices as pressure, choice, benefit, cost, alternative, and reversal trigger rather than as universal patterns.
- Separate shipped behavior, documented intent, source-bounded inference, latent capability, and explicit future work.
- Identify the persistence and delivery seams, including the conditions under which each choice should be reconsidered.
- Leave a precise inventory of platform asymmetries and repository discrepancies without inventing roadmap commitments.
This is a ledger, not a claim that T3 Code found the one right architecture. At the locked revision, its choices consistently put one environment server in charge of product authority, preserve accepted intent in SQLite, and make provider-native execution, filesystem work, and client presentation explicitly separate. That produces a comprehensible control surface across many harnesses. It also produces real seams: a committed event can miss a hot reactor, an external harness can cross an ambiguous crash boundary, and not every client or retained artifact has equal capabilities.
Use the six columns throughout this chapter precisely:
| Lens | Question it answers |
|---|---|
| Pressure | What failure or product constraint is being controlled? |
| Choice | What is actually implemented at the pinned revision? |
| Benefit | Which guarantee becomes easier to state or test? |
| Cost | What complexity, boundary, or weaker guarantee remains? |
| Alternative | What a different design could optimize instead—not a promise about T3. |
| Reversal trigger | The product pressure that would justify revisiting this choice. |
1. Authority and durable intent: make the environment server the product boundary
Server authority
The pressure is remote control without pretending that a browser, desktop shell, or phone owns a provider process, Git worktree, terminal, or filesystem. T3 puts those operations behind the environment server. Clients authenticate, use typed RPC, and hold projections and presentation state; a provider still owns its native reasoning and context engine. This makes one environment the place where authorization, orchestration, workspace effects, and product history meet.
The benefit is a clear remote model: adding another device adds another client of an environment rather than another competing owner of a workspace. The cost is that availability, upgrades, and recovery concentrate around that server; clients must reconnect and reconcile instead of making local state authoritative. A peer-to-peer or client-owned model could improve disconnected autonomy, but would need a conflict, credential, and workspace-execution story that this implementation deliberately does not carry. Revisit the choice if concurrent offline editing or multi-writer workspace authority becomes a primary product requirement.
Transactional event core
The pressure is accepting a user command exactly enough to answer a retry without claiming provider completion. The choice is a serialized engine that decides a command, appends its event batch, applies projections, and records the command receipt inside one SQLite transaction. The benefit is a sharp acceptance boundary: retrying the same command id can recover the stored result, and a failed transaction leaves no accepted receipt. The cost is that normalization-time files, provider calls, and later reactor work are outside that transaction.
const committedCommand = yield* sql
.withTransaction(
Effect.gen(function* () {
const committedEvents: OrchestrationEvent[] = [];
let nextCommandReadModel = commandReadModel;
for (const nextEvent of eventBases) {
const savedEvent = yield* eventStore.append(nextEvent);
nextCommandReadModel = yield* projectEvent(nextCommandReadModel, savedEvent);
yield* projectionPipeline.projectEvent(savedEvent);
committedEvents.push(savedEvent);
}
const lastSavedEvent = committedEvents.at(-1) ?? null;
if (lastSavedEvent === null) {
return yield* new OrchestrationCommandInvariantError({
commandType: envelope.command.type,
detail: "Command produced no events.",
});
}
yield* commandReceiptRepository.upsert({
commandId: envelope.command.commandId,
aggregateKind: lastSavedEvent.aggregateKind,
aggregateId: lastSavedEvent.aggregateId,
acceptedAt: lastSavedEvent.occurredAt,
resultSequence: lastSavedEvent.sequence,
status: "accepted",
error: null,
});
return {
committedEvents,
lastSequence: lastSavedEvent.sequence,
nextCommandReadModel,
} as const;
}),
)
.pipe(
Effect.catchTag("SqlError", (sqlError) =>
Effect.fail(
toPersistenceSqlError("OrchestrationEngine.processEnvelope:transaction")(sqlError),
),
),
);
commandReadModel = committedCommand.nextCommandReadModel;
for (const [index, event] of committedCommand.committedEvents.entries()) {
yield* PubSub.publish(eventPubSub, event);
if (index === 0) {
yield* Metric.update(
Metric.withAttributes(
orchestrationCommandAckDuration,
metricAttributes({
...baseMetricAttributes,
ackEventType: event.type,
}),
),
Duration.millis(Math.max(0, (yield* Clock.currentTimeMillis) - envelope.startedAtMs)),
);
}
}
return { sequence: committedCommand.lastSequence };An append-only log is not free: commands and deciders must retain invariants, read models must be maintained, and a receipt is not an end-to-end idempotence proof for a multi-step bootstrap saga. A direct CRUD model could lower local complexity when there is no need to replay or compose state. Revisit the event core when the product no longer benefits from immutable command history, independently shaped projections, or receipt-based retry semantics.
Zoom with the controls, +/−, or Ctrl/⌘ + trackpad scroll. Enable Pan to drag, use two-finger scrolling, or use the arrow keys. 0 fits the diagram; Esc leaves Pan or expanded view.
Text equivalent
An authenticated client sends a command to an environment server. The server transaction writes an event, projections, and receipt. A hot reactor may start provider work through an adapter. Provider-native state, Git/filesystem effects, and client cache presentation remain separate. Projection cursors rebuild read models; mobile has an intent outbox; updater staging is version-pinned; background work is retained only while demanded. Each measure controls one boundary rather than making all arrows atomic.
apps/server/src/server.ts:353–416 ↗apps/server/src/orchestration/Layers/OrchestrationEngine.ts:197–259 ↗apps/server/src/orchestration/Layers/ProviderCommandReactor.ts:1405–1409 ↗apps/server/src/orchestration/Layers/ProjectionPipeline.ts:1609–1678 ↗apps/server/src/provider/Services/ProviderAdapter.ts:47–71 ↗apps/mobile/src/state/thread-outbox-manager.ts:91–124 ↗apps/server/src/cloud/selfUpdate.ts:64–169 ↗apps/mobile/src/connection/background-activity.ts:44–115 ↗2. Delivery and read state: choose explicit eventual boundaries
Hot, best-effort post-commit reactors
The pressure is to avoid calling a harness while a domain transaction is still open. T3 publishes only after commit, then runs provider, runtime-ingestion, checkpoint, deletion, and awareness consumers as hot scoped workers. The benefit is simple: rollback cannot have caused a provider turn, and one reactor failure is handled without rolling back accepted domain history. The cost is the reactor crash window. A process can die after the receipt/event commit and before a reactor observes it; the source contains no durable outbox row, per-reactor delivery cursor, or startup replay of pending hot work.
That is a reasonable trade where an external operation can be ambiguous to repeat: a durable outbox still needs idempotency keys, attempt records, and a policy for a harness that accepted work just before a crash. It would be the alternative when the product requires guaranteed post-commit execution. The reversal trigger is explicit: if “accepted turn” must eventually imply “provider send attempted” across server crashes, add a durable delivery protocol rather than describing the current reactor as exactly once.
Snapshot plus cursor
The pressure is a fast UI that can restart, replay, and subscribe without claiming that one monolithic snapshot is globally current. Each projector has a durable cursor; normal command acceptance advances its projector SQL and cursor together. A composed snapshot uses the minimum cursor among its required projectors, while live clients attach before their replay/snapshot read and use global event sequence for gap repair.
The benefit is independently shaped and rebuildable read state. The cost is more than one watermark, a bounded bootstrap path, ordering-sensitive projectors, and careful client race guards. A single authoritative document per thread could simplify some reads but makes fan-out and independently evolved views harder. Revisit cursor architecture if projection lag, cross-projector joins, or operational replay needs outgrow the current SQLite/replay ceiling.
3. Harness and client continuity: normalize the boundary, not the world
Provider adapters
The pressure is five harnesses with different session, approval, stream, context,
and process semantics. T3 chooses a narrow adapter lifecycle and canonical runtime
event grammar; ProviderService owns routing, bindings, correlation, credentials,
and cross-provider policy. The benefit is one product domain that can preserve native
provenance without forcing all harnesses into a fictional universal feature set.
The cost is an adapter matrix, capability gaps, and no repository-wide proof that all providers have semantic parity. A generic “agent protocol only” design could reduce some integrations but would either lose native features or push product policy into each provider driver. Revisit this boundary when the normalized contract can no longer represent an important native lifecycle without pervasive escape hatches.
One reconnect owner per environment
The pressure is multiple pages, caches, notifications, and devices observing one remote environment without creating retry storms or merging unrelated authorities. The choice is one environment registry entry with one supervisor generation and at most one active RPC lease; shell and thread synchronizers retain separate cache and cursor responsibilities. The benefit is one place to own transport lifecycle while each projection remains honest about its own authoritative refresh.
The cost is a sophisticated supervisor, generations, leases, and surface-specific resynchronization. A global connection manager is attractive but would blur separate environment authority and corrupt cache ownership. Revisit this model if the product adds genuine cross-environment aggregation or a shared write model—not merely a UI that displays several environment summaries.
Durable mobile intent outbox
The pressure is a phone losing foreground time or connectivity after the user has pressed send. Mobile uses an optimistic enqueue with durable persistence, serializes its manager, and asks the user for a delivery decision when a queued turn collides with a changed thread state. The benefit is preserving user intent locally before it can be delivered to an environment. The cost is another state machine: existence guards, capped backoff, confirmations, and explicit replay semantics instead of an assumption that a compose action immediately became a server turn.
An always-online client could omit this machinery, but it would trade away the recovery behavior that matters on a mobile lifecycle. Revisit the outbox when mobile intent becomes multi-device collaborative work requiring server-issued identities or when all clients need an equivalent durable intent queue.
// The queued atom drives the composer's immediate "queued" feedback, so it
// is published synchronously; the durable write happens behind it and rolls
// the message back out if it fails (durability only matters for crash
// recovery, not for the in-session queue).
const enqueue = (message: QueuedThreadMessage): Promise<void> => {
setMessages([
...currentMessages().filter((candidate) => candidate.messageId !== message.messageId),
message,
]);
return serialize(async () => {
try {
await options.storage.write(message);
} catch (cause) {
// Roll back by reference, not messageId: a retry enqueue with the same
// id may have optimistically replaced this attempt while the write was
// in flight, and its entry must survive this attempt's failure.
setMessages(currentMessages().filter((candidate) => candidate !== message));
throw new ThreadOutboxManagerError({
operation: "enqueue",
environmentId: message.environmentId,
threadId: message.threadId,
messageId: message.messageId,
cause,
});
}
});
};
// Resolves once all pending mutations (including any in-flight enqueue
// write) have settled, reporting whether the message is still queued. The
// drain awaits this before dispatching so a message whose durable write
// later fails can never have been delivered first.
const confirmQueued = (message: QueuedThreadMessage): Promise<boolean> =>
serialize(async () => currentMessages().some((candidate) => candidate === message));Exact-version updates
The pressure is a newly visible client asking a connected server to run an incompatible runtime. T3 publishes the exact CLI package before a release exposes the clients that can request it; a boot-service server rejects non-exact targets, stages and preflights that runtime, then hands activation to a stable launcher. The benefit is a precise compatibility target and a reversible SQLite-bound trial. The cost is release ordering, launcher protocol compatibility, and platform-specific update machinery.
A floating channel update can reduce operations friction but makes an update request less reproducible. Revisit the invariant if a compatibility protocol—not matching versions—becomes sufficient to prove safe server/client combinations.
Scope-driven background work
The pressure is staying useful while mobile is backgrounded without keeping every environment permanently active. Mobile background activity reports retained demand through reference-counted environment scopes. The benefit is a bounded reason for work to continue: a caller declares interest and releases it. The cost is that subscription ownership and lifecycle cleanup must be correct; background liveness is not a durable scheduler, and platform APIs constrain what actually runs.
An always-on global worker would simplify call sites but waste resources and make ownership leaks more damaging. Revisit scopes when the product needs a durable background-job contract with OS-managed scheduling and completion receipts.
Trace the trade-off, then test its reversal trigger
Filter the ledger, select a decision, and move through its six-step path. No animation advances on its own.
Shipped domain
Server authority
- 1Pressure
Remote clients must control one workspace without becoming competing owners of provider processes, Git, terminals, or files.
- 2Choice
One environment server owns product authority; clients use authenticated RPC and projections.
- 3Benefit
Authorization, orchestration, workspace effects, and durable product history meet at one address.
- 4Cost
Availability and recovery depend on that environment; clients reconcile rather than write authoritatively.
- 5Alternative
Client-owned or peer-to-peer workspaces with a separate conflict and credential model.
- 6Reversal trigger
Concurrent offline editing or multi-writer workspace authority becomes a core requirement.
1 of 6 · Pressure
Server authority selected. Step 1 of 6: Pressure.
Complete static ledger
| Decision | Pressure | Choice | Benefit | Cost | Alternative | Reversal trigger |
|---|---|---|---|---|---|---|
| ShippedServer authority | Remote clients must control one workspace without becoming competing owners of provider processes, Git, terminals, or files. | One environment server owns product authority; clients use authenticated RPC and projections. | Authorization, orchestration, workspace effects, and durable product history meet at one address. | Availability and recovery depend on that environment; clients reconcile rather than write authoritatively. | Client-owned or peer-to-peer workspaces with a separate conflict and credential model. | Concurrent offline editing or multi-writer workspace authority becomes a core requirement. |
| ShippedTransactional event core | A command needs a durable acceptance boundary and a retry answer before external work completes. | Decide, append events, fold projections, and write a receipt in one SQLite transaction. | Accepted intent and its receipt survive together; failed transactions leave no acceptance result. | Files, provider calls, and later delivery remain outside the transaction; projections require maintenance. | Direct CRUD where replayable history and independently shaped read models are not valuable. | Immutable command history and projection diversity stop paying for their operational complexity. |
| ShippedHot post-commit reactors | Do not call a harness while the domain transaction could still roll back. | Publish committed events to scoped, hot reactor workers; keep failures isolated from acceptance. | Rollback cannot have caused provider work, and one consumer failure does not undo durable history. | A crash after commit can lose pending observation; sends and runtime ingestion are not a durable outbox. | Durable outbox with attempts, idempotency keys, and a policy for ambiguous external acceptance. | An accepted turn must eventually imply an attempted provider send across process loss. |
| ShippedSnapshot + cursor | Clients need rebuildable read state and bounded resume without calling every page one global snapshot. | Each projection advances its own cursor; composed snapshots use a safe watermark and subscriptions repair gaps. | Read models evolve independently and can rebuild from committed events. | Several watermarks, order-sensitive projectors, replay limits, and client race guards must remain intelligible. | One authoritative document per thread with fewer projections and less independent fan-out. | Projection lag, cross-view joins, or replay operations exceed the current cursor model's operating envelope. |
| ShippedProvider adapters | Harnesses disagree about sessions, approvals, streams, context, and process ownership. | A narrow adapter contract emits canonical runtime facts while ProviderService owns product policy and routing. | One product model preserves native provenance without inventing false provider parity. | Adapter maintenance and capability differences remain explicit; no universal conformance proof exists. | A stricter generic protocol that may discard native features or push product policy into every driver. | Important native lifecycles require pervasive escape hatches that the canonical contract cannot express. |
| ShippedOne reconnect owner | Several views and devices can observe an environment without independent retry loops or merged authorities. | An environment-scoped supervisor owns generations and one active lease; caches synchronize separately. | Transport lifecycle has one owner while shell and thread views keep precise refresh boundaries. | Leases, generations, and surface-specific reconciliation add client-runtime complexity. | A global connection manager that would need another way to preserve environment ownership. | The product adds a real cross-environment write model, not just combined presentation. |
| ShippedDurable mobile intent outbox | A user can send while the phone loses connectivity or foreground time. | Optimistically enqueue, persist durably, then confirm and deliver through a serialized mobile outbox. | User intent can survive locally before the environment can accept it. | Backoff, existence guards, confirmation, and delivery choices become a separate lifecycle. | Always-online direct send, sacrificing the local recovery contract. | Intent becomes multi-device collaborative work needing server-issued identities or all clients need the same queue. |
| ShippedExact-version updates | A visible client must not request a server runtime that is unavailable or incompatible. | Publish the exact CLI first; stage and preflight the exact server runtime before launcher activation. | An update target is reproducible and the managed-server trial has a defined rollback boundary. | Release order, launcher compatibility, and platform-specific update state machines remain necessary. | Floating channel updates paired with a stronger compatibility negotiation protocol. | Compatibility proof becomes sufficient without requiring equal client and server versions. |
| ShippedScope-driven background work | Mobile should remain useful in the background without keeping every environment permanently active. | Reference-counted scopes retain declared per-environment background demand. | Continuation has an owner and can end when that owner releases its interest. | Scope cleanup and platform scheduling constraints remain part of correctness; it is not a durable job queue. | An always-on global worker with higher resource use and leak risk. | The product needs OS-managed durable jobs with explicit completion receipts. |
4. Limitations are part of the architecture contract
The ledger above describes choices. This section records the places where their edges must stay visible in a design review.
Shipped asymmetries and discrepancies
| Classification | What the pinned source establishes | Consequence for a reader or successor |
|---|---|---|
| Shipped platform asymmetry | Desktop, boot-service server, and Expo mobile update through three different state machines; mobile’s OTA is fingerprint-gated and its safe reload waits for persistence and lifecycle conditions. | “Update” cannot be one shared abstraction without losing its owner and rollback boundary. |
| Latent artifact | Root build scripts support more target names than the inspected release matrix actually publishes; Windows ARM64 is present as a latent/commented target rather than a distributed artifact at this lock. | Builder support is not evidence that a user can download a release. |
| Transition / compatibility path | The web hides OpenCode’s plan agent when legacy plan mode is off and heals old stored selections after settings hydrate; mobile retains a device-local legacy plan-mode preference. |
The plan UI is transitional compatibility code, not proof of a new universal planning model. |
| Shipped model boundary | Provider resume state is an opaque binding; thread plans, checkpoints, drafts, and native harness history remain distinct records. | There is no universal memory layer or provider-independent continuation guarantee. |
Retention and cleanup are selected operations, not one erase button
Tombstoning a project or thread changes its projected visibility; it does not erase the append-only event history or command receipts. Thread revert removes selected derived messages, plans, activities, turns, attachment files, and later checkpoint refs, but retains event history and records the revert itself. The thread-deletion reactor performs best-effort provider and terminal cleanup; the web separately offers an orphan-worktree removal path. Provider binding deletion exists as a repository operation, yet no caller appeared in the inspected production sources. Hidden checkpoint refs likewise do not gain a repository-wide lifecycle reconciler simply because a thread is tombstoned.
Attachment cleanup has the opposite shape: normalizers write image bytes before command dispatch, while projectors perform later filesystem deletion after their SQL and cursor step. That reduces database/file coupling but makes cross-store atomicity unavailable. A rejected or retried command can leave an early file; a failed cleanup is logged, and a crash after cursor advancement can prevent that event from selecting the same cleanup again. This is shipped behavior, not a future garbage collection protocol.
DPoP replay defense records a replay marker under a hashed proof-derived key through exclusive secret creation. The source path establishes rejection of a duplicate marker. Inference: the inspected source does not show a corresponding marker-expiry or retention sweep, so this book cannot claim a bounded replay-marker store merely because proof timestamps are recorded. That is a retention inference, not a security weakness claim.
The only roadmap claims here are explicit upstream future work
The internal remote document labels three items unbuilt: additional third-party
tunnel endpoint providers, a relay-hosted OAuth callback broker, and richer
multi-environment UI beyond the current connections list. They are future work, not
dates, milestones, or a promise that their current design will ship. The pinned code
and connect documentation do implement a hosted static /connect/callback handoff
page. That is not evidence of a relay-hosted backend broker: only the broad claim
that there is no callback path is stale, while the literal broker item remains
future work.
5. A decision review is more useful than a pattern checklist
When evaluating T3 Code’s choices, the useful question is not “should every system copy this?” It is: which pressure does this choice address, which boundary is durable, and which cost does it impose? T3’s strongest recurring lesson is truthful separation: accepted intent is not provider completion; a projection is not a universal snapshot; a remote notification is not authority; a bounded local record is not a retention policy; and a compatibility branch is not a roadmap.