Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .github/workflows/j5-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
- name: Typecheck
run: pnpm exec vp run -r --concurrency-limit 2 --log grouped typecheck

- name: Check unused code
run: pnpm exec vp run knip:check

# These gitlinks belong to vendored manifests, not this repository.
# Remove them only from the disposable index before checkout's cleanup.
- name: Exclude vendored gitlinks from checkout cleanup
Expand Down
5 changes: 4 additions & 1 deletion FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ These files exist upstream, but J5 owns its copy outright and they are not integ
Against upstream pin `d2c440312e5f39d59827ed466838a623516454d6`, the inventory has 95 entries: 1–94 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` exports `ALL_MCP_CAPABILITIES` and adds the `artifacts` capability that case 33's tools check; nothing imports the export at pin `d2c440312e`.
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.

Every tool J5 owns is named with a `j5_` prefix, so none reads as a harness's native tool ([#508](https://github.com/Jacksondr5/j5code/issues/508)); upstream's names stay as upstream's, including the ones J5 re-declares (`delegate_task`, `orchestrator_capabilities`, `t3_thread_transfer`, `t3_thread_organize`, `t3_queue`, `t3_attachment_prepare_upload`). The rule for which name a tool carries: a J5 name when J5 changes what it takes, returns or means, and upstream's name when J5 only adds a refusal, an error message or a corrected description (Jackson, 2026-10-11, [#519](https://github.com/Jacksondr5/j5code/issues/519)). The pre-prefix names are not registered; `apps/web/src/j5/a2a/ThreadA2ARenderer.tsx` still reads them in recorded history, and the ledger command ids for a send and a clear keep their original `send_message` and `clear_own_ask` segments (`commandIdForRequest`).

Expand Down Expand Up @@ -502,6 +502,8 @@ migrations after upstream migrations.

94. Cmd+K names who wrote a person's message it found ([#809](https://github.com/Jacksondr5/j5code/issues/809)). Upstream labels every user-role hit "You:", which is wrong for anyone else's words in a shared conversation. Upstream's `OrchestrationThreadSearchMatch` (`packages/contracts/src/threadSearch.ts`) gains an optional `author`, J5's `ThreadSearchAuthor` (`you`, or `person` with the name they wrote under). The server fills it in J5-owned code: `connectionView` (case 69) labels each search's matches through `apps/server/src/j5/sharing/searchAuthors.ts`, by the message's `j5_a2a_message_author` record (case 80), or as the first owner's when a person typed it before the thread was shared. ws.ts is unchanged. On the web, `ThreadSearchMatchExcerpt` (`apps/web/src/components/ThreadSearchMatch.tsx`) draws `threadSearchMatchLabel` (`apps/web/src/j5/sharing/searchAuthorLabel.ts`) in place of its "You"/"Agent" choice, and the author is passed through `CommandPaletteThreadContentMatch` (`CommandPalette.logic.ts`), `CommandPaletteThreadItems.tsx` and the sidebar's `SidebarThreadRow.tsx`. A match without `author`, from an older server or any message no person typed, keeps upstream's label. Mobile's palette still says "You". On every rebase, keep the field on the match and the one-line label call.

95. Knip checks J5's code with upstream's settings ([#812](https://github.com/Jacksondr5/j5code/issues/812)). J5 CI runs `vp run knip:check`, as upstream's CI does, and `knip.jsonc` carries J5's additions, each marked `J5:`. The `scripts` and `apps/server` workspaces list the J5 scripts that run by path. The top-level `ignoreFiles` and `ignoreIssues` cover upstream code whose only callers J5 removed or replaced: the T3 wordmarks (rebrand), the `thread` CLI command (case 82), `configuredHostedAppUrl` (case 76), `useNpmReleasePublished` (case 40) and `buildT3ProjectFileJsonSchema` (J5's marketing site dropped upstream's schema page). That code is left as upstream wrote it, so advances merge cleanly. Drop an entry when upstream deletes its code or J5 calls it again; knip runs with `--no-config-hints`, so it won't flag a stale one.

## 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 @@ -770,6 +772,7 @@ explicitly marked.
| `apps/web/src/components/settings/settingsSearch.ts` | N | 42–44, 72, 77, 87, 92 |
| `apps/web/src/components/settings/SettingsSidebarNav.tsx` | N | 42, 72, 73 |
| `docs/README.md` | N | 42, 45, 48 |
| `knip.jsonc` | N | 95 |
| `packages/client-runtime/src/state/runtime.test.ts` | N | 42 |
| `packages/contracts/src/auth.ts` | N | 35 |
| `packages/contracts/src/environmentHttp.ts` | N | 70 |
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/scripts/electron-launcher.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const repoRoot = NodePath.resolve(desktopDir, "..", "..");
const devBundleIdSuffix = NodePath.basename(repoRoot)
.toLowerCase()
.replaceAll(/[^a-z0-9]+/g, "");
export const APP_DISPLAY_NAME = isDevelopment
const APP_DISPLAY_NAME = isDevelopment
? J5_BRANDING.desktop.developmentName
: J5_BRANDING.desktop.baseName;
export const APP_BUNDLE_ID = isDevelopment
const APP_BUNDLE_ID = isDevelopment
? `${J5_BRANDING.desktop.developmentAppId}.${devBundleIdSuffix || "local"}`
: J5_BRANDING.desktop.appId;
const APP_PROTOCOL_SCHEMES = isDevelopment
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/electron/ElectronProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { J5_BRANDING } from "../../../../scripts/lib/j5-branding.ts";
import * as Electron from "electron";

export const DESKTOP_HOST = "app";
export const DESKTOP_PRODUCTION_SCHEME = J5_BRANDING.desktop.productionScheme;
export const DESKTOP_DEVELOPMENT_SCHEME = J5_BRANDING.desktop.developmentScheme;
const DESKTOP_PRODUCTION_SCHEME = J5_BRANDING.desktop.productionScheme;
const DESKTOP_DEVELOPMENT_SCHEME = J5_BRANDING.desktop.developmentScheme;

export function getDesktopScheme(isDevelopment: boolean): string {
return isDevelopment ? DESKTOP_DEVELOPMENT_SCHEME : DESKTOP_PRODUCTION_SCHEME;
Expand Down
9 changes: 3 additions & 6 deletions apps/server/src/cloud/j5/legacyBootService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type { BootServiceStep } from "../bootService.ts";
* T3 Code. `j5 service install` retires such a unit only when it is provably J5's: it names
* `J5CODE_HOME` and never `T3CODE_HOME`. A T3 Code unit is never touched.
*/
export const LEGACY_J5_SYSTEMD_UNIT_FILE = "t3code.service";
export const LEGACY_J5_LAUNCHD_LABEL = "com.t3tools.t3code.service";
const LEGACY_J5_SYSTEMD_UNIT_FILE = "t3code.service";
const LEGACY_J5_LAUNCHD_LABEL = "com.t3tools.t3code.service";

/** Whether a unit or plist at a legacy path was written by a J5 CLI. */
export function isLegacyJ5BootServiceUnit(contents: string): boolean {
Expand All @@ -37,10 +37,7 @@ export function isRenderedJ5BootServiceUnit(contents: string): boolean {
* denied, bus unreachable, a timeout) is a real failure: the old server may still be running, so
* the handover must stop before a second writer starts on the same home.
*/
export function legacyStopMeansNotRunning(
kind: "systemd" | "launchd",
result: ProcessRunOutput,
): boolean {
function legacyStopMeansNotRunning(kind: "systemd" | "launchd", result: ProcessRunOutput): boolean {
if (result.timedOut) return false;
const output = `${result.stdout}\n${result.stderr}`;
if (kind === "systemd") {
Expand Down
6 changes: 1 addition & 5 deletions apps/server/src/j5/a2a/AgentCrewProposalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ export type CrewProposalKind = "roster" | "addition";
*/
export type CrewProposalStatus = "open" | "approved" | "declined";
export type CrewProposalDecision = "approve" | "decline";
export const CREW_PROPOSAL_STATUSES: ReadonlyArray<CrewProposalStatus> = [
"open",
"approved",
"declined",
];
const CREW_PROPOSAL_STATUSES: ReadonlyArray<CrewProposalStatus> = ["open", "approved", "declined"];
const finalStatus = (decision: CrewProposalDecision) =>
decision === "approve" ? ("approved" as const) : ("declined" as const);

Expand Down
6 changes: 2 additions & 4 deletions apps/server/src/j5/a2a/ArchiveCrewService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ export class ArchiveCrewNotCaptainError extends Data.TaggedError("ArchiveCrewNot
}
}

export class ArchiveCrewProjectMismatchError extends Data.TaggedError(
"ArchiveCrewProjectMismatchError",
)<{
class ArchiveCrewProjectMismatchError extends Data.TaggedError("ArchiveCrewProjectMismatchError")<{
readonly crewInstanceId: string;
readonly projectId: LedgerProjectId;
readonly expected: LedgerProjectId;
Expand Down Expand Up @@ -133,7 +131,7 @@ export class ArchiveCrewConfirmationStaleError extends Data.TaggedError(
}
}

export class ArchiveCrewConfirmationTokenError extends Data.TaggedError(
class ArchiveCrewConfirmationTokenError extends Data.TaggedError(
"ArchiveCrewConfirmationTokenError",
)<{ readonly reason: "malformed" | "unsupported-version" }> {
override get message(): string {
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/j5/a2a/ClientReadsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const participantIdentityRows = (
`;

/** This exact statement is executed for count reads and compiled by the plan proof below. */
export const openInboxCountStatement = (sql: SqlClient.SqlClient, personId: ParticipantId) =>
const openInboxCountStatement = (sql: SqlClient.SqlClient, personId: ParticipantId) =>
sql<OpenInboxCountRow>`
SELECT COUNT(*) AS count
FROM j5_a2a_human_inbox AS inbox
Expand All @@ -164,7 +164,7 @@ const decodeLatestPeerDelivery = Schema.decodeUnknownSync(
Schema.fromJsonString(Schema.Struct({ label: Schema.String, environmentId: Schema.String })),
);

export const peerSenderLabelStatement = (
const peerSenderLabelStatement = (
sql: SqlClient.SqlClient,
participantIds: ReadonlyArray<string>,
) =>
Expand Down
12 changes: 7 additions & 5 deletions apps/server/src/j5/a2a/CrewLaunchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,18 @@ export interface CrewLaunchResult {
readonly seats: ReadonlyArray<CrewSeatLaunchOutcome>;
}

export class CrewLaunchSeatUnavailableError extends Data.TaggedError(
"CrewLaunchSeatUnavailableError",
)<{ readonly seatName: string; readonly agentId: string; readonly detail: string }> {
class CrewLaunchSeatUnavailableError extends Data.TaggedError("CrewLaunchSeatUnavailableError")<{
readonly seatName: string;
readonly agentId: string;
readonly detail: string;
}> {
override get message(): string {
return `Seat ${this.seatName} (agent ${this.agentId}) is unavailable: ${this.detail} Nothing was spawned.`;
}
}

/** The Crew is full; the seats it holds already reach the cap once the request is counted. */
export class CrewLaunchCapError extends Data.TaggedError("CrewLaunchCapError")<{
class CrewLaunchCapError extends Data.TaggedError("CrewLaunchCapError")<{
readonly crewInstanceId: string;
readonly held: number;
readonly adding: number;
Expand All @@ -190,7 +192,7 @@ export class CrewLaunchCapError extends Data.TaggedError("CrewLaunchCapError")<{
}

/** A seat name the reservation could not take: another participant already holds it. */
export class CrewLaunchSeatConflictError extends Data.TaggedError("CrewLaunchSeatConflictError")<{
class CrewLaunchSeatConflictError extends Data.TaggedError("CrewLaunchSeatConflictError")<{
readonly crewInstanceId: string;
readonly seatNames: ReadonlyArray<string>;
}> {
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/j5/a2a/CrewProposalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const launchSeatOf = (seat: CrewProposalSeat): CrewLaunchSeat => {
};
};

export class CrewProposalRequestError extends Data.TaggedError("CrewProposalRequestError")<{
class CrewProposalRequestError extends Data.TaggedError("CrewProposalRequestError")<{
readonly detail: string;
readonly nextStep: string;
}> {
Expand All @@ -89,15 +89,15 @@ export class CrewProposalNotOpenError extends Data.TaggedError("CrewProposalNotO
}
}

export class CrewProposalNotFoundError extends Data.TaggedError("CrewProposalNotFoundError")<{
class CrewProposalNotFoundError extends Data.TaggedError("CrewProposalNotFoundError")<{
readonly proposalId: string;
}> {
override get message(): string {
return `Proposal ${this.proposalId} does not exist in this environment.`;
}
}

export class CrewProposalOperationError extends Data.TaggedError("CrewProposalOperationError")<{
class CrewProposalOperationError extends Data.TaggedError("CrewProposalOperationError")<{
readonly phase: string;
readonly cause: unknown;
}> {
Expand Down
13 changes: 7 additions & 6 deletions apps/server/src/j5/a2a/CrewRuntimeRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ interface CrewSeatThread {

export { inboxAnswerableApprovals } from "@t3tools/shared/j5/crewRuntimeRequests";

export class CrewRuntimeRequestNotFoundError extends Data.TaggedError(
"CrewRuntimeRequestNotFoundError",
)<{ readonly threadId: ThreadId; readonly requestId: RuntimeRequestId }> {
class CrewRuntimeRequestNotFoundError extends Data.TaggedError("CrewRuntimeRequestNotFoundError")<{
readonly threadId: ThreadId;
readonly requestId: RuntimeRequestId;
}> {
override get message() {
return `No pending approval ${this.requestId} on a live Crew seat's thread ${this.threadId}.`;
}
Expand All @@ -48,9 +49,9 @@ export class CrewRuntimeRequestConflictError extends Data.TaggedError(
}

/** The answer could not be sent for a reason other than the request's state; the route logs it. */
export class CrewRuntimeRequestDispatchError extends Data.TaggedError(
"CrewRuntimeRequestDispatchError",
)<{ readonly cause: OrchestratorV2Error | ThreadManagementProviderInstanceDisabledError }> {
class CrewRuntimeRequestDispatchError extends Data.TaggedError("CrewRuntimeRequestDispatchError")<{
readonly cause: OrchestratorV2Error | ThreadManagementProviderInstanceDisabledError;
}> {
override get message() {
return "The answer could not be sent.";
}
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/j5/a2a/CrewSeatFinishNotifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class CrewSeatFinishNotifier extends Context.Service<

const FINISH_SESSION = "j5-crew-seat-finish";
/** Bodies up to this size ride inline in the Captain's notice; longer ones are read on demand. */
export const INLINE_HANDOFF_MAX_CHARS = 4_000;
const INLINE_HANDOFF_MAX_CHARS = 4_000;

/**
* A seat has finished only when its run completed or failed. Interrupted, cancelled and rolled back
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/j5/a2a/CrewStopService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class CrewStopNotFoundError extends Data.TaggedError("CrewStopNotFoundErr
}
}

export class CrewStopRequestError extends Data.TaggedError("CrewStopRequestError")<{
class CrewStopRequestError extends Data.TaggedError("CrewStopRequestError")<{
readonly detail: string;
readonly nextStep: string;
}> {
Expand Down
Loading
Loading