Skip to content
Open
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
170 changes: 157 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ jobs:
# Lint, typecheck, and the desktop build each get a runner so they run side by
# side instead of one after another. The `Check` job at the end of this file
# passes only when every other job does.
# Forks use GitHub-hosted runners without requiring the upstream runner app.
lint:
name: Lint
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-8vcpu-ubuntu-2404' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -57,7 +58,7 @@ jobs:

typecheck:
name: Typecheck
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-8vcpu-ubuntu-2404' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand All @@ -83,8 +84,8 @@ jobs:

build:
name: Build
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 10
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-8vcpu-ubuntu-2404' }}
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
Expand Down Expand Up @@ -129,6 +130,38 @@ jobs:
- name: Verify preload bundle output
run: node apps/desktop/scripts/verify-preload-bundle.mjs

- name: Build unsigned desktop archive without publishing
env:
T3CODE_DESKTOP_SIGNED: "false"
run: |
sudo apt-get install -y imagemagick
node scripts/build-desktop-artifact.ts --platform linux --target tar.gz --arch x64 --skip-build --output-dir "$RUNNER_TEMP/t3-desktop-archive"

- name: Verify Riftri in the complete desktop archive
run: |
mkdir "$RUNNER_TEMP/t3-desktop-extracted"
tar -xzf "$RUNNER_TEMP"/t3-desktop-archive/*.tar.gz -C "$RUNNER_TEMP/t3-desktop-extracted"
T3CODE_TEST_DESKTOP_ASAR=$(find "$RUNNER_TEMP/t3-desktop-extracted" -name app.asar -type f)
test -f "$T3CODE_TEST_DESKTOP_ASAR"
export T3CODE_TEST_DESKTOP_ASAR
export T3CODE_TEST_ELECTRON_BINARY=$(node -e "console.log(require(require.resolve('electron', { paths: ['./apps/desktop'] })))")
unset RIFTRI_BINARY
vp test run scripts/lib/riftri-packaging.test.ts -t 'complete desktop archive'

- name: Build CLI single-executable
env:
# Match the release build and SEA_NODE_VERSION in the server config.
VP_NODE_VERSION: "26.8.2"
run: node apps/server/scripts/cli.ts build-exe --verbose

- name: Package and start the standalone CLI in a temporary home
run: |
t3_artifact_version=$(node -p "require('./apps/server/package.json').version")
mkdir -p "$RUNNER_TEMP/t3-cli-resource-monitor/linux-x64"
cp native/resource-monitor/target/x86_64-unknown-linux-gnu/release/t3-resource-monitor "$RUNNER_TEMP/t3-cli-resource-monitor/linux-x64/"
node scripts/build-cli-archive.ts --platform linux --arch x64 --version "$t3_artifact_version" --resource-monitor-dir "$RUNNER_TEMP/t3-cli-resource-monitor" --output-dir "$RUNNER_TEMP/t3-cli-archive"
node scripts/smoke-cli-archive.ts --archive "$RUNNER_TEMP"/t3-cli-archive/*.tar.gz --expect-version "$t3_artifact_version"

# Everything except `t3` (apps/server) and the web app, which has its own job
# below. `--parallel` drops the package dependency ordering that `vp run`
# applies by default: these `test` tasks declare no `dependsOn` and resolve
Expand All @@ -137,7 +170,7 @@ jobs:
# per runner is unchanged.
test:
name: Test
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-8vcpu-ubuntu-2404' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -201,7 +234,7 @@ jobs:
# started last and ran alone for about 40s after everything else finished.
test_web:
name: Test Web
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-8vcpu-ubuntu-2404' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -230,7 +263,7 @@ jobs:
# split files by recorded duration (apps/server/src/testUtils/weightedShardSequencer.ts).
test_server:
name: Test Server ${{ matrix.shard }}
runs-on: blacksmith-4vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }}
timeout-minutes: 10
strategy:
fail-fast: false
Expand Down Expand Up @@ -302,7 +335,7 @@ jobs:
# On Blacksmith like every other job here: the GitHub-hosted queue is shared
# with the PR bots and can leave this job waiting until it is abandoned,
# which fails `Check` on an otherwise green run.
runs-on: blacksmith-2vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-2vcpu-ubuntu-2404' }}
timeout-minutes: 5
steps:
- name: Require transfer measurements
Expand All @@ -315,7 +348,7 @@ jobs:
# for checks that take under 3s, on the critical path of every PR.
rust:
name: Rust
runs-on: blacksmith-4vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-4vcpu-ubuntu-2404' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -349,7 +382,7 @@ jobs:
# the diff cannot be resolved, the lint runs.
mobile_native_changes:
name: Mobile Native Changes
runs-on: blacksmith-2vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-2vcpu-ubuntu-2404' }}
timeout-minutes: 5
permissions:
contents: read
Expand Down Expand Up @@ -427,7 +460,7 @@ jobs:
# Skip only on an explicit "no": a gate job that failed or errored leaves the
# output empty, and that must run the lint rather than silently skip it.
if: ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
runs-on: blacksmith-6vcpu-macos-26
runs-on: ${{ github.event.repository.fork && 'macos-15' || 'blacksmith-6vcpu-macos-26' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -455,7 +488,7 @@ jobs:

release_smoke:
name: Release Smoke
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-8vcpu-ubuntu-2404' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand All @@ -478,6 +511,116 @@ jobs:
- name: Exercise release-only workflow steps
run: node scripts/release-smoke.ts

riftri_storage:
name: Riftri storage (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [macos-15, ubuntu-24.04]
steps:
- name: Checkout
uses: actions/checkout@v6
with:
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false

- name: Setup Vite+
uses: voidzero-dev/setup-vp@v1
with:
node-version-file: package.json
cache: true
run-install: true

- name: Ensure Electron runtime is installed
run: vp run --filter @t3tools/desktop ensure:electron

- name: Resolve published native runtimes
run: |
node --input-type=module <<'NODE' >> "$GITHUB_ENV"
import { createRequire } from 'node:module';
const server = createRequire(`${process.cwd()}/apps/server/package.json`);
const desktop = createRequire(`${process.cwd()}/apps/desktop/package.json`);
console.log(`T3CODE_TEST_RIFTRI_BINARY=${server('riftri').resolveBinary()}`);
console.log(`T3CODE_TEST_ELECTRON_BINARY=${desktop('electron')}`);
NODE
echo 'T3CODE_TEST_RIFTRI_PACKAGE=1' >> "$GITHUB_ENV"
echo 'RIFTRI_BYPASS=1' >> "$GITHUB_ENV"

- name: Prepare disposable Linux OverlayFS volume
if: runner.os == 'Linux'
run: |
# Only this disposable runner's mount namespace is used by the tests.
if test -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns; then
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
fi
truncate -s 2G "$RUNNER_TEMP/t3-riftri-overlay.img"
mkdir "$RUNNER_TEMP/t3-riftri-overlay"
mkfs.ext4 -F "$RUNNER_TEMP/t3-riftri-overlay.img"
sudo mount -o loop "$RUNNER_TEMP/t3-riftri-overlay.img" "$RUNNER_TEMP/t3-riftri-overlay"
sudo chown "$(id -u):$(id -g)" "$RUNNER_TEMP/t3-riftri-overlay"

- name: Prepare disposable macOS APFS volume
if: runner.os == 'macOS'
run: |
hdiutil create -size 1g -fs APFS -volname T3RiftriProof -type SPARSEBUNDLE "$RUNNER_TEMP/t3-riftri-apfs.sparsebundle"
mkdir "$RUNNER_TEMP/t3-riftri-apfs"
hdiutil attach -nobrowse -mountpoint "$RUNNER_TEMP/t3-riftri-apfs" "$RUNNER_TEMP/t3-riftri-apfs.sparsebundle"
touch "$RUNNER_TEMP/t3-riftri-apfs/.metadata_never_index"

- name: Test native Git lifecycle and packaged runtime
shell: bash
run: |
unset RIFTRI_BINARY
command=(vp test run --fileParallelism=false
apps/server/src/vcs/RiftriWorktrees.test.ts
apps/server/src/vcs/GitVcsDriverCore.riftri.test.ts
apps/server/src/vcs/GitVcsDriverCore.riftri.performance.test.ts
apps/server/src/git/GitManager.test.ts
apps/server/src/orchestration-v2/ProjectionStore.worktreeRoots.test.ts
apps/server/src/serverRuntimeStartup.test.ts
apps/server/src/serverRuntimeStartup.autoPull.test.ts
apps/server/src/workspace/WorkspaceStorage.test.ts
scripts/lib/riftri-packaging.test.ts)
export T3CODE_TEST_RIFTRI_REPORT="$RUNNER_TEMP/t3-riftri-performance.json"
if test "$RUNNER_OS" = Linux; then
export T3CODE_TEST_RIFTRI_BACKEND=overlay-fs
export TMPDIR="$RUNNER_TEMP/t3-riftri-overlay"
export T3CODE_TEST_RIFTRI_VOLUME="$TMPDIR"
unshare --user --map-root-user --mount --propagation private -- "${command[@]}"
else
export T3CODE_TEST_RIFTRI_BACKEND=apfs-clone
export TMPDIR="$RUNNER_TEMP/t3-riftri-apfs"
export T3CODE_TEST_RIFTRI_VOLUME="$TMPDIR"
"${command[@]}"
fi

- name: Upload physical storage and latency measurements
if: always()
uses: actions/upload-artifact@v7
with:
name: riftri-performance-${{ matrix.os }}
path: ${{ runner.temp }}/t3-riftri-performance.json
if-no-files-found: error
retention-days: 30

- name: Unmount disposable macOS volume
if: always() && runner.os == 'macOS'
run: |
if mount | grep -Fq " on $RUNNER_TEMP/t3-riftri-apfs "; then
hdiutil detach "$RUNNER_TEMP/t3-riftri-apfs"
fi

- name: Unmount disposable Linux volume
if: always() && runner.os == 'Linux'
run: |
if mountpoint -q "$RUNNER_TEMP/t3-riftri-overlay"; then
sudo umount "$RUNNER_TEMP/t3-riftri-overlay"
fi

# Branch protection requires this job by its name, `Check`. It fails when any
# other job fails, is cancelled, or is skipped without a reason, so splitting
# or resharding jobs needs no ruleset change. Add every new job to `needs`.
Expand All @@ -499,8 +642,9 @@ jobs:
mobile_native_changes,
mobile_native_static_analysis,
release_smoke,
riftri_storage,
]
runs-on: blacksmith-2vcpu-ubuntu-2404
runs-on: ${{ github.event.repository.fork && 'ubuntu-24.04' || 'blacksmith-2vcpu-ubuntu-2404' }}
timeout-minutes: 5
steps:
- name: Require every job to pass
Expand Down
1 change: 1 addition & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"node-pty": "^1.2.0-beta.15",
"playwright-core": "1.60.0",
"proper-lockfile": "4.1.2",
"riftri": "0.6.3",
"stream-chain": "^4.2.5",
"stream-json": "3.6.0",
"yaml": "catalog:",
Expand Down
8 changes: 8 additions & 0 deletions apps/server/src/git/GitManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ import * as ProjectSetupScriptRunner from "../project/ProjectSetupScriptRunner.t
import * as ProviderRegistry from "../provider/ProviderRegistry.ts";
import * as ServerSettings from "../serverSettings.ts";
import * as GitManager from "./GitManager.ts";
import * as WorkspaceStorage from "../workspace/WorkspaceStorage.ts";
import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";

const encodeCliJson = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
const decodeForgejoPullRequest = Schema.decodeEffect(ForgejoPullRequestSchema);
Expand Down Expand Up @@ -732,6 +734,7 @@ function makeManager(input?: {
),
),
).pipe(
Layer.provide(WorkspaceStorage.layer),
Layer.provideMerge(VcsProcess.layer),
Layer.provideMerge(NodeServices.layer),
Layer.provideMerge(layerServerConfig),
Expand Down Expand Up @@ -794,6 +797,11 @@ const layerGitManagerTest = GitVcsDriver.layer.pipe(
Layer.provide(ServerConfig.layerTest(process.cwd(), { prefix: "t3-git-manager-test-" })),
Layer.provideMerge(VcsProcess.layer),
Layer.provideMerge(NodeServices.layer),
// These fixtures remove their temporary directories directly. Native bases
// need journaled cleanup, covered by GitVcsDriverCore.riftri.test.ts instead.
Layer.provideMerge(
Layer.succeed(HostProcessEnvironment, { ...process.env, T3CODE_WORKTREE_STORAGE: "git" }),
),
);

it.layer(layerGitManagerTest)("GitManager", (it) => {
Expand Down
36 changes: 36 additions & 0 deletions apps/server/src/orchestration-v2/ProjectionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
ThreadId,
TurnItemId,
NodeId,
ProjectId,
} from "@t3tools/contracts";
import {
createOrchestrationV2TurnItemVisibility,
Expand All @@ -78,6 +79,8 @@ import {
THREAD_HISTORY_MAX_RAW_TURNS,
} from "./threadHistoryPaging.ts";

const WorktreeRoot = Schema.Struct({ projectId: ProjectId, worktreePath: Schema.String });

export class ProjectionStoreApplyEventError extends Schema.TaggedError<ProjectionStoreApplyEventError>()(
"ProjectionStoreApplyEventError",
{
Expand Down Expand Up @@ -342,6 +345,11 @@ export interface ProjectionStoreV2Shape {
readonly location?: "active" | "archive";
readonly unsettledOnly?: boolean;
}) => Effect.Effect<OrchestrationV2ThreadShellSnapshot, ProjectionStoreV2Error>;
/** Storage startup needs roots, not run/session/message enrichment. Includes archives. */
readonly getWorktreeRoots: () => Effect.Effect<
ReadonlyArray<typeof WorktreeRoot.Type>,
ProjectionStoreV2Error
>;
readonly getThreadShell: (
threadId: ThreadId,
) => Effect.Effect<OrchestrationV2ThreadShell | null, ProjectionStoreV2Error>;
Expand Down Expand Up @@ -5348,6 +5356,19 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
)
.pipe(Effect.mapError((cause) => new ProjectionStoreSetupError({ cause })));

const getWorktreeRoots: ProjectionStoreV2Shape["getWorktreeRoots"] = () =>
sql`
SELECT DISTINCT
json_extract(payload_json, '$.projectId') AS projectId,
json_extract(payload_json, '$.worktreePath') AS worktreePath
FROM orchestration_v2_projection_threads
WHERE deleted_at IS NULL
AND json_extract(payload_json, '$.worktreePath') IS NOT NULL
`.pipe(
Effect.flatMap(Schema.decodeUnknownEffect(Schema.Array(WorktreeRoot))),
Effect.mapError((cause) => new ProjectionStoreSetupError({ cause })),
);

const getThreadsWithPullRequests: ProjectionStoreV2Shape["getThreadsWithPullRequests"] = (
threadId,
) =>
Expand Down Expand Up @@ -5687,6 +5708,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
return {
apply,
getShellSnapshot,
getWorktreeRoots,
getThreadShell,
getThread,
getSettlementCandidates,
Expand Down Expand Up @@ -5729,6 +5751,20 @@ export const layerMemory: Layer.Layer<ProjectionStoreV2> = Layer.effect(
const sequence = yield* Ref.make(0);

const service: ProjectionStoreV2Shape = {
getWorktreeRoots: () =>
Ref.get(replayState).pipe(
Effect.map(({ projections }) => {
const roots = new Map<string, typeof WorktreeRoot.Type>();
for (const { thread } of projections.values()) {
if (thread.deletedAt !== null || thread.worktreePath === null) continue;
roots.set(JSON.stringify([thread.projectId, thread.worktreePath]), {
projectId: thread.projectId,
worktreePath: thread.worktreePath,
});
}
return [...roots.values()];
}),
),
apply: (event) =>
Effect.gen(function* () {
const result = yield* Ref.modify(replayState, (existing) => {
Expand Down
Loading
Loading