Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
04e260b
feat(j5): start Crew members on their first assignment
bryantderosier Oct 27, 2026
7d6017d
fix(j5): deliver Crew context when the assignment starts
bryantderosier Oct 27, 2026
3b53dc9
fix(j5): Crew context follows what the provider actually received (#745)
bryantderosier Oct 28, 2026
c5f8b54
fix(web): a seat whose first start failed reads as failed, not Not st…
bryantderosier Oct 28, 2026
c3bb58e
refactor(j5): stop unwrapping context-wrapped Crew envelopes (#745)
bryantderosier Oct 28, 2026
aa9cd84
docs(j5): Crew delivery, steering, introduction and Not started as th…
bryantderosier Oct 28, 2026
9f04c46
fix(web): carry the Not started seat label onto the Fleet fact cells …
bryantderosier Oct 29, 2026
613e9cf
merge: bring the updated Agent Setup layer into the deferred-assignme…
bryantderosier Nov 2, 2026
9b368df
fix(j5): drop the static-markup seat label tests; crewState covers th…
bryantderosier Nov 2, 2026
cc57ff9
fix(j5): Crew seat context writes and announces only when it changes;…
bryantderosier Nov 2, 2026
fc6452b
merge: pick up the lint fixes from the Agent Setup layer
bryantderosier Nov 2, 2026
b01e62c
merge: Crew seat context fixes from review
bryantderosier Nov 2, 2026
20ecc6c
merge: pick up the settings seam test fix
bryantderosier Nov 2, 2026
0f5140e
feat(j5): a Crew member's thread keeps what it was told
bryantderosier Nov 2, 2026
b0ea47e
feat(j5): show what a Crew member was told as a card in its thread
bryantderosier Nov 2, 2026
5a98a5e
fix(web): SpawnedChildGroupRows is no longer exported now that no tes…
bryantderosier Nov 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ These files exist upstream, but J5 owns its copy outright and they are not integ

### Sanctioned appended integration cases

Against upstream pin `d2c440312e5f39d59827ed466838a623516454d6`, the inventory has 106 entries: 1–105 plus 15b. Seventeen are retired and keep their numbers (10–14, 15b, 16–18, 20, 27–29, 54, 55, 61, 66), and 19 and 39 are retired except for a remainder. Existing numbers never change; a new case takes the next number. Line coordinates and landing SHAs below describe historical integrations; use named symbols and tests after upstream movement. Branding has its own inventory in `BRANDING.md`; temporary defect patches are listed separately below.
Against upstream pin `d2c440312e5f39d59827ed466838a623516454d6`, the inventory has 107 entries: 1–106 plus 15b. Seventeen are retired and keep their numbers (10–14, 15b, 16–18, 20, 27–29, 54, 55, 61, 66), and 19 and 39 are retired except for a remainder. Existing numbers never change; a new case takes the next number. Line coordinates and landing SHAs below describe historical integrations; use named symbols and tests after upstream movement. Branding has its own inventory in `BRANDING.md`; temporary defect patches are listed separately below.

1. A1's independent communication-ledger migration lane: in `apps/server/src/persistence/Sqlite.ts`, `layerSetup` runs `runJ5CompatibleUpstreamMigrations` and then `runJ5A2AMigrations` where upstream calls `runMigrations()`. Upstream's `layerConfig` has already run `initializeV2Database`, which copies `state.sqlite` to `statev2.sqlite`, so both run only against `statev2.sqlite`. J5 adopts that copy-on-first-start unchanged (Jackson's 2026-09-24 decision #2): an existing `statev2.sqlite` wins and `state.sqlite` is never recopied or written again, so the cutover is one-way: writes after the first V2 boot are invisible to an older binary. Snapshot before the upgrade, and roll back across it by stopping writers and moving `statev2.sqlite` aside (`docs/j5/runbooks/dogfood-runtime.md`); never run old and new binaries against the two files. `layerFromPath` calls one J5 step, `snapshotBeforeMigrations` (`apps/server/src/j5/persistence/MigrationSnapshot.ts`), before it builds the SQL layer, so every file-backed open is covered. When the database has migration history and either lane has a migration pending (upstream's `effect_sql_migrations` against upstream's manifest, or `j5_a2a_migrations` against J5's ledger list), it is first copied with `VACUUM INTO`, through a read-only connection, to `statev2.pre-migration-u<upstream id>-j<J5 id>.sqlite` beside it, named for the newest migration each lane had recorded. The copy is synchronous and does not use `node:sqlite`'s `backup()`: on the Node 26 that release executables embed, `backup()` rejects the one-step rate Node 24 accepts and its promise settles only when another event wakes the loop, which stopped the first nightly from starting. The snapshot is a compacted copy in rollback-journal mode; the server sets WAL again when it opens a restored one. A database with no history, or with nothing pending, is not copied. The newest three snapshots are kept (`MIGRATION_SNAPSHOTS_KEPT`) and older ones deleted. This is the roll-forward policy's emergency exit (issue #507): J5 adds no refusal to start on a database newer than the build, as upstream adds none for that case. Upstream refuses only a history that would skip one of V2's own migrations (`assertV2MigrationsCanRun` in `Migrations.ts`), and a second server on the same home (`apps/server/src/serverOwnership.ts`, exit 78), whose lock `layerMakeServer` takes before anything opens the database, so before the snapshot. A failed copy dies there, so the server does not start and nothing migrates. It dies rather than fails so the layer's error type, which upstream's tests name, stays upstream's. `MigrationSnapshot.test.ts` covers it. The `j5_run_observability_migrations` lane (one index) is not consulted. J5 tooling (`fleet-load.ts`, `devDeliverySeed.ts`, `dogfood-snapshot.sh`, `dogfood-local.sh`) targets `statev2.sqlite`; `apps/server/src/j5/persistence/StateV2Cutover.test.ts` covers the copy, no-recopy and failed-first-boot retry. Case 31 defines the compatibility wrapper; J5's own migration IDs remain in separate tracking tables and run after upstream migration completion.
2. The authenticated J5 MCP registration seam: the `layer` of `apps/server/src/mcp/McpHttpServer.ts` calls `layerJ5Toolkits(toolkitRegistration)` (`apps/server/src/j5/a2a/mcp/registration.ts`) in place of upstream's orchestrator, thread, attachment, project and environment registrations. Upstream's preview, preview-controls, worktree, pull-request, device and html toolkits are registered whole, as upstream registers them. Upstream's lint rule `no-raw-mcp-registration` allows MCP registration only in `McpHttpServer.ts`, so J5 registers through the `toolkitRegistration` function that file passes in. `layerJ5Toolkits` registers J5's own tools and the admitted part of those five upstream toolkits. `upstreamCatalog.ts` selects the admitted tools one by one and runs them on upstream's own handlers through `handlersFor`, which is one documented cast. Upstream's `McpServer.toolkit` asks for every tool's declared dependencies at registration, so J5's environment toolkit registration (`registration.ts`) provides `ThreadCommandExecutor.layer`, as upstream's own does. `apps/server/src/mcp/McpInvocationContext.ts` adds the `artifacts` capability that case 33's tools check.
Expand Down Expand Up @@ -527,6 +527,8 @@ migrations after upstream migrations.

105. Agent Setup and Crew approval settings ([#743](https://github.com/Jacksondr5/j5code/issues/743)): `packages/contracts/src/settings.ts` registers J5's `crewAutoApprove` boolean (default off) in server settings, patches, and project overrides. `apps/web/src/components/settings/settingsSearch.ts` renames the existing `/settings/personas` destination to Agent Setup and adds search terms and the scoped Crew setting target. `apps/mobile/src/features/settings/SettingsRouteScreen.tsx` and `apps/mobile/src/Stack.tsx` rename the existing Personas navigation entry and title to Agent Setup. Runtime behavior and the web sections stay in J5-owned files; mobile still exposes only the persona library.

106. Deferred Crew assignments ([#745](https://github.com/Jacksondr5/j5code/issues/745)): `orchestration-v2/runtimeLayer.ts` wraps the shared orchestrator with J5-owned `CrewDeliveryContext.ts` for first-assignment workspace preparation and guards, and supplies J5-owned `CrewTurnContext.ts` to provider turn start and provider turn control. `orchestration-v2/ProviderTurnStartService.ts` asks that service whether the thread is a Crew seat (one indexed read) and delegates only a seat's selected assignment text to it immediately around provider delivery; every other thread keeps upstream's fast path and delivery unchanged, and `CrewDeliveryContext.ts` likewise passes any non-seat thread's dispatch straight through. `orchestration-v2/ProviderTurnControlService.ts` wraps the live session with the service's `steering`, one hook beside upstream's `steerTurn` call, so a message steered into a busy seat carries the current context too. The service builds the approved introduction or net roster changes from the current roster, sends the full introduction again when the provider conversation it reached is replaced (a model or provider switch, or a missing native session rebuilt from history), and records what it sent only after the provider accepts the prompt; a send that never happens (the run was stopped or superseded before `startTurn`) leaves it owed. Editable messages and shared author prefixes stay unchanged, so queued edits, cancellations and reordering cannot consume context. Waiting seats whose Crew is retired fail visibly; a retained worktree guard applies even after retirement. J5 migration 49 owns the context, and `CrewSeatPreparation.ts` uses upstream's persisted preparation path. `orchestration-v2/ProviderTurnStartService.test.ts` and `ProviderTurnControlService.test.ts` exercise the hooks against the real seat context, including a retained and a replaced native conversation and a Stop before the provider send. A seat's thread also keeps what it was told (register D43): after the provider accepts a prompt that carried the introduction or a roster change, `CrewTurnContext.ts` dispatches the server-only `platform-message.record` command with that text, ids derived from the conversation and the text so a retry records once, and a failure to post is logged without failing the turn. `packages/contracts/src/orchestrationV2.ts` appends the command to the internal command union; `orchestration-v2/Orchestrator.ts` adds one `commandThreadId` case, one `dispatch` case and `dispatchPlatformMessageRecord`, which emits the existing `message.updated` and `turn-item.updated` events for the named run with no run created or queued; `ProviderTurnStartService.ts` adds `runId: run.id` to the delivery it already hands the seat service; and `runtimeLayer.ts` builds the orchestrator layers above the two turn services so `CrewTurnContext.layer` can depend on the orchestrator. The client side is J5-owned: `presentCrewContext` in `packages/client-runtime/src/j5/crewNotices.ts`, `CrewNoticeRenderer.tsx` on web and `timeline.tsx` on mobile. `Orchestrator.platform-message.test.ts` proves the command, and `CrewDeliveryContext.test.ts` and its integration test prove the posting. On an advance, retain the hooks at actual delivery and steering after queue selection, shared by every provider and transport, and the internal command with its one decision function.

## Pin and upstream advance runbook

Current pin: `d2c440312e5f39d59827ed466838a623516454d6`, upstream's stable release tag `v0.1.3` on `main` (frozen 2026-10-27). The previous pin was `70d60e03a7a35c6fa131825bbfa05ec893e69912`, upstream's nightly tag `v0.1.1-nightly.20261017.3238`.
Expand Down Expand Up @@ -834,15 +836,17 @@ explicitly marked.
| `packages/provider-core/src/server/ProviderAdapter.ts` | R | 47, 60, N, Role library |
| `packages/provider-core/src/server/orchestrationInstructions.ts` | N | 8, B |
| `packages/provider-pi/src/server/mcpExtensionSource.test.ts` | N | 8 |
| `apps/server/src/orchestration-v2/ProviderTurnControlService.ts` | R | 26 |
| `apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts` | A | N |
| `apps/server/src/orchestration-v2/ProviderTurnStartService.ts` | A | 30, N |
| `apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts` | N | 106 |
| `apps/server/src/orchestration-v2/ProviderTurnControlService.ts` | R | 26, 106 |
| `apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts` | A | N, 106 |
| `apps/server/src/orchestration-v2/ProviderTurnStartService.ts` | A | 30, N, 106 |
| `packages/contracts/src/orchestrationV2.ts` | N | 106 |
| `apps/server/src/orchestration-v2/RunFinalizationService.ts` | R | 30 |
| `apps/server/src/orchestration-v2/ThreadLaunchService.ts` | R | Saved-agent launch |
| `apps/server/src/orchestration-v2/runtimeLayer.test.ts` | R | 3 |
| `apps/server/src/orchestration-v2/ThreadSearch.ts` | N | 69, 91 |
| `apps/server/src/orchestration-v2/ThreadSearch.test.ts` | N | 69 |
| `apps/server/src/orchestration-v2/runtimeLayer.ts` | R | 5, 21, 26, 30, 38, 91 |
| `apps/server/src/orchestration-v2/runtimeLayer.ts` | R | 5, 21, 26, 30, 38, 91, 106 |
| `apps/server/src/os-jank.ts` | R | H |
| `apps/server/src/persistence/Sqlite.ts` | A | 1, 31 |
| `apps/server/src/project/RepositoryIdentityResolver.test.ts` | N | gh default repository patch |
Expand Down Expand Up @@ -994,7 +998,7 @@ explicitly marked.
| `packages/provider-cursor/src/server/adapter.ts` | N | B |
| `packages/provider-opencode/src/server/v2/adapter.ts` | N | B |
| `packages/provider-opencode/src/server/adapter.ts` | N | N |
| `apps/server/src/orchestration-v2/Orchestrator.ts` | N | Role library, Saved-agent mentions |
| `apps/server/src/orchestration-v2/Orchestrator.ts` | N | Role library, Saved-agent mentions, 106 |
| `apps/server/src/orchestration-v2/ProjectionStore.ts` | N | Role library |
| `apps/server/src/orchestration-v2/RuntimePolicy.ts` | N | 47, Role library |
| `apps/server/src/orchestration-v2/ThreadManagementService.ts` | N | 26 |
Expand Down
28 changes: 27 additions & 1 deletion apps/mobile/src/j5/a2a/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
J5UserMessagePresentation,
} from "@t3tools/client-runtime/j5/user-message";
import { isSharedNote } from "@t3tools/client-runtime/j5/shared-conversation";
import type { ReactNode } from "react";
import { useState, type ReactNode } from "react";
import { Pressable, View } from "react-native";

import { AppText as Text } from "../../components/ui/AppText";
Expand Down Expand Up @@ -44,6 +44,9 @@ export function renderJ5TimelineNotice(input: {
</View>
);
}
if (notice.kind === "context") {
return <CrewContextNotice title={notice.title} text={notice.text} />;
}
return (
<View className="mb-5 gap-1.5 rounded-xl border border-border bg-card p-3">
<Text className="font-t3-medium text-xs text-foreground-muted">{notice.label}</Text>
Expand All @@ -54,6 +57,29 @@ export function renderJ5TimelineNotice(input: {
);
}

/** What the platform told a Crew member: its title, and the model's own reading once opened. */
function CrewContextNotice(props: { readonly title: string; readonly text: string }) {
const [open, setOpen] = useState(false);
return (
<View className="mb-5 gap-1.5 rounded-xl border border-border bg-card p-3">
<Pressable
accessibilityRole="button"
accessibilityState={{ expanded: open }}
onPress={() => setOpen((value) => !value)}
>
<Text className="font-t3-medium text-xs text-foreground-muted">
{open ? "▾" : "▸"} {props.title} from J5
</Text>
</Pressable>
{open ? (
<Text selectable className="font-mono text-xs leading-relaxed text-foreground">
{props.text}
</Text>
) : null}
</View>
);
}

function Tag(props: { readonly label: string; readonly tone?: "warning" | "success" }) {
return (
<View
Expand Down
15 changes: 15 additions & 0 deletions apps/mobile/src/j5/a2a/timelinePresentation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ describe("presentJ5TimelineNotice", () => {
).toEqual({ kind: "raw", label: "Crew notice" });
});

it("shows what a Crew member was told as a card of its own, not as the reader's message", () => {
expect(
presentJ5TimelineNotice({
id: "message:j5:crew-context:abc",
role: "user",
createdBy: "system",
text: "<j5_crew_delivery_context>\n<j5_crew_roster_changed>\njoined: security\n</j5_crew_roster_changed>\n</j5_crew_delivery_context>",
}),
).toEqual({
kind: "context",
title: "Roster changed",
text: "<j5_crew_roster_changed>\njoined: security\n</j5_crew_roster_changed>",
});
});

it("leaves letters and upstream's own messages to their rows", () => {
expect(presentJ5TimelineNotice(delivery("agent", askRaw))).toBeNull();
expect(
Expand Down
9 changes: 7 additions & 2 deletions apps/mobile/src/j5/a2a/timelinePresentation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { presentCrewContext } from "@t3tools/client-runtime/j5/crew-notices";
import type { ParticipantIdentities } from "@t3tools/client-runtime/j5/participant-identity";
import {
isJ5DeliveryMessage,
Expand Down Expand Up @@ -45,16 +46,20 @@ export type J5FeedMessagePresentation = ReturnType<typeof resolveJ5FeedMessage>;

/**
* J5's platform notices that upstream's row would draw as the reader's own message: a silence,
* which has a plain summary, and a Crew notice or a delivery notice this client cannot read yet,
* which keep their raw text until the notices are redrawn. Null for every other message.
* which has a plain summary, what a Crew member was told (a card that opens to the text), and a
* Crew notice or a delivery notice this client cannot read yet, which keep their raw text until
* the notices are redrawn. Null for every other message.
*/
export function presentJ5TimelineNotice(
message: J5UserMessageInput,
):
| { readonly kind: "silence"; readonly summary: string | null }
| { readonly kind: "raw"; readonly label: string }
| { readonly kind: "context"; readonly title: string; readonly text: string }
| null {
if (message.role !== "user" || message.createdBy !== "system") return null;
const context = presentCrewContext(message);
if (context !== null) return { kind: "context", title: context.title, text: context.text };
const presentation = presentJ5UserMessage(message);
if (presentation?.group !== "notice") {
return isJ5DeliveryMessage(message) ? { kind: "raw", label: "Raw A2A delivery" } : null;
Expand Down
9 changes: 8 additions & 1 deletion apps/server/src/j5/a2a/AgentCrewInstanceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ParticipantId, type LedgerProjectId } from "./contracts.ts";
import { ReadChanges } from "./ReadChanges.ts";

export interface AgentCrewMember {
readonly notStarted?: boolean;
readonly seatName: string;
/** The saved agent the seat runs as; null for a custom seat that runs as the Captain. */
readonly agentId: string | null;
Expand Down Expand Up @@ -68,6 +69,7 @@ export interface RecordAgentCrewInput {

export interface AgentCrewMembership {
readonly crewInstanceId: string;
readonly notStarted?: boolean;
readonly seatName: string;
}

Expand Down Expand Up @@ -181,6 +183,7 @@ interface InstanceRow {

interface MemberRow {
readonly crew_instance_id: string;
readonly not_started: number | null;
readonly seat_name: string;
readonly agent_id: string | null;
readonly participant_id: string;
Expand Down Expand Up @@ -226,6 +229,7 @@ const stepOwnershipConflict = (
};

const memberFromRow = (row: MemberRow): AgentCrewMember => ({
...(row.not_started == null ? {} : { notStarted: row.not_started === 1 }),
seatName: row.seat_name,
agentId: row.agent_id,
participantId: ParticipantId.make(row.participant_id),
Expand Down Expand Up @@ -269,7 +273,10 @@ export const layer: Layer.Layer<AgentCrewInstanceService, never, SqlClient.SqlCl
) {
if (rows.length === 0) return [];
const members = yield* sql<MemberRow>`
SELECT * FROM j5_agent_crew_member
SELECT member.*, CASE WHEN context.thread_id IS NULL THEN NULL
WHEN context.delivered_roster IS NULL THEN 1 ELSE 0 END AS not_started
FROM j5_agent_crew_member AS member
LEFT JOIN j5_crew_seat_context AS context ON context.thread_id = member.thread_id
WHERE crew_instance_id IN ${sql.in(rows.map(({ id }) => id))}
`;
return rows.map((row) => instanceFromRows(row, members));
Expand Down
Loading
Loading