Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 0 additions & 4 deletions apps/server/src/pullRequest/GitHubPullRequestCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ import {
type GitHubReviewThreadPage,
type GitHubViewerAccess,
} from "./gitHubPullRequestJson.ts";
import { makeGitHubNativeStackRead } from "./gitHubNativeStack.ts";
import type { ProviderChangeRequestSummary, ProviderListCursor } from "./PullRequestProvider.ts";

/**
Expand Down Expand Up @@ -423,8 +422,6 @@ export interface GitHubPullRequestDiffSlice {
export class GitHubPullRequestCli extends Context.Service<
GitHubPullRequestCli,
{
readonly getNativeDependencyMembership: ReturnType<typeof makeGitHubNativeStackRead>;

readonly getViewerLogin: (input: {
readonly cwd: string;
}) => Effect.Effect<string, GitHubPullRequestCliError>;
Expand Down Expand Up @@ -1543,7 +1540,6 @@ export const make = Effect.gen(function* () {
),
fail: (detail) => new GitHubCiError({ detail }),
}),
getNativeDependencyMembership: makeGitHubNativeStackRead(github.execute),
getViewerLogin: (input) =>
github.execute({ cwd: input.cwd, args: ["api", "user", "--jq", ".login"] }).pipe(
Effect.flatMap((result) => {
Expand Down
2 changes: 0 additions & 2 deletions apps/server/src/pullRequest/GitHubPullRequestProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ export const make = Effect.gen(function* () {
getCiJobs: (input) => cli.getCiJobs(input).pipe(Effect.mapError(fail("getCiJobs"))),
rerunCi: (input) => cli.rerunCi(input).pipe(Effect.mapError(fail("rerunCi"))),

getNativeDependencyMembership: (input) => cli.getNativeDependencyMembership(input),

getViewer: (input) =>
cli.getViewerLogin({ cwd: input.cwd }).pipe(Effect.mapError(fail("getViewer"))),

Expand Down
31 changes: 0 additions & 31 deletions apps/server/src/pullRequest/PullRequestProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,29 +165,6 @@ export interface ProviderChangeRequestPage {
readonly continues: boolean;
}

/** Optional host-native stack membership, independent from ordinary branch relationships. */
export type ProviderNativeDependencyMembership =
| {
readonly status: "present";
readonly id: string;
/** Host-defined order. Every member carries enough data to render a lightweight node. */
readonly members: ReadonlyArray<
Pick<
ProviderChangeRequest,
| "number"
| "title"
| "url"
| "state"
| "isDraft"
| "headBranch"
| "baseBranch"
| "headRepositoryNameWithOwner"
>
>;
readonly coverage: "complete" | "partial";
}
| { readonly status: "none" };

/**
* Where a repository's next slice starts, as the provider that has to ask for it needs it. Built
* by the service out of the slice it just handed over, so the boundary that decides whether a row
Expand Down Expand Up @@ -410,14 +387,6 @@ export interface PullRequestProviderApi extends Partial<ProviderCiApi<PullReques
input: ProviderRepositoryRef & { readonly number: number },
) => Effect.Effect<ProviderChangeRequestDetail, PullRequestProviderError>;

/**
* Explicit stack membership reported by the host. Optional and independent from branch-chain
* discovery: an absent implementation or failed read must not disable ordinary relationships.
*/
readonly getNativeDependencyMembership?: (
input: ProviderRepositoryRef & { readonly number: number; readonly limit: number },
) => Effect.Effect<ProviderNativeDependencyMembership, PullRequestProviderError>;

/**
* The cheap live fields used by linked threads. Optional because a provider without a narrow
* endpoint can fall back to its full detail read at the service boundary.
Expand Down
133 changes: 55 additions & 78 deletions apps/server/src/pullRequest/PullRequestService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3297,7 +3297,7 @@ it.effect(
}),
);

it.effect("coalesces bounded dependency reads and invalidates them by repository", () =>
it.effect("caches inferred reads by repository without fetching native stacks", () =>
Effect.gen(function* () {
let relationshipReads = 0;
let nativeReads = 0;
Expand Down Expand Up @@ -3327,9 +3327,9 @@ it.effect("coalesces bounded dependency reads and invalidates them by repository
assert.strictEqual(input.relationshipOnly, true);
return Effect.succeed({ items: [parent, child], truncated: false, continues: false });
},
getNativeDependencyMembership: () => {
getChangeRequestStack: () => {
nativeReads += 1;
return Effect.succeed({ status: "none" });
return Effect.succeed(null);
},
}),
],
Expand All @@ -3341,23 +3341,25 @@ it.effect("coalesces bounded dependency reads and invalidates them by repository
);
assert.deepStrictEqual(first, second);
assert.deepStrictEqual(first.edges, [{ child: 2, parent: 1, certainty: "confirmed" }]);
assert.deepStrictEqual(first.native, { status: "none" });
assert.strictEqual(relationshipReads, 1);
assert.strictEqual(nativeReads, 1);
assert.strictEqual(nativeReads, 0);

yield* service.dependencyContext({ ...reference, number: 1 });
assert.strictEqual(relationshipReads, 1);
assert.strictEqual(nativeReads, 2);
assert.strictEqual(nativeReads, 0);

yield* service.invalidate({ reference });
yield* service.dependencyContext(reference);
assert.strictEqual(relationshipReads, 2);
assert.strictEqual(nativeReads, 3);
assert.strictEqual(nativeReads, 0);

yield* service.update({ ...reference, title: "Renamed" });
yield* service.dependencyContext(reference);
assert.strictEqual(relationshipReads, 3);
assert.strictEqual(nativeReads, 4);
assert.strictEqual(nativeReads, 0);
yield* service.stack(reference);
yield* service.stack(reference);
assert.strictEqual(nativeReads, 1);
assert.isAbove(
Option.getOrThrow(yield* Stream.runHead(service.subscribeRefreshes)).revision,
0,
Expand Down Expand Up @@ -3458,55 +3460,26 @@ it.effect("retries a failed focus summary and caches the recovered context", ()
}),
);

it.effect("retries unavailable native membership and caches the recovered context", () =>
it.effect("retries failed native stack reads and caches a successful absence", () =>
Effect.gen(function* () {
let relationshipReads = 0;
let nativeReads = 0;
let reads = 0;
const reference = { projectId: "p1" as ProjectId, repository: "acme/web", number: 2 };
const service = yield* makeService({
projects: [project({ id: "p1", title: "web", workspaceRoot: "/a", repository: "acme/web" })],
providers: [
fakeProvider("github", {
listChangeRequests: () => {
relationshipReads += 1;
return Effect.succeed({
items: [
{
...changeRequest(1, "2026-07-02T00:00:00Z"),
headBranch: "migration",
headRepositoryNameWithOwner: "acme/web",
},
{
...changeRequest(2, "2026-07-03T00:00:00Z"),
headBranch: "api",
headRepositoryNameWithOwner: "acme/web",
baseBranch: "migration",
},
],
truncated: false,
continues: false,
});
},
getNativeDependencyMembership: () => {
nativeReads += 1;
return nativeReads === 1
? Effect.fail(requestFailed)
: Effect.succeed({ status: "none" });
getChangeRequestStack: () => {
reads += 1;
return reads === 1 ? Effect.fail(requestFailed) : Effect.succeed(null);
},
}),
],
});

const degraded = yield* service.dependencyContext(reference);
assert.deepStrictEqual(degraded.edges, [{ child: 2, parent: 1, certainty: "confirmed" }]);
assert.strictEqual(degraded.coverage, "complete");
assert.deepStrictEqual(degraded.native, { status: "unavailable" });
const recovered = yield* service.dependencyContext(reference);
assert.deepStrictEqual(recovered.native, { status: "none" });
assert.strictEqual(relationshipReads, 1);
assert.strictEqual(nativeReads, 2);
assert.deepStrictEqual(yield* service.dependencyContext(reference), recovered);
assert.strictEqual(nativeReads, 2);
const failure = yield* Effect.flip(service.stack(reference));
assert.strictEqual(failure._tag, "PullRequestOperationError");
assert.isNull(yield* service.stack(reference));
assert.isNull(yield* service.stack(reference));
assert.strictEqual(reads, 2);
}),
);

Expand Down Expand Up @@ -3628,53 +3601,58 @@ it.effect("keeps a merged focus visible without linking it to a reused live bran
}),
);

it.effect("appends ordered native members as nodes without fabricating branch edges", () =>
it.effect("keeps native stack members out of inferred branch relationships", () =>
Effect.gen(function* () {
const reference = { projectId: "p1" as ProjectId, repository: "acme/web", number: 2 };
const focus = {
...changeRequest(2, "2026-07-03T00:00:00Z"),
headBranch: "api",
headRepositoryNameWithOwner: "acme/web",
baseBranch: "migration",
};
const service = yield* makeService({
projects: [project({ id: "p1", title: "web", workspaceRoot: "/a", repository: "acme/web" })],
providers: [
fakeProvider("github", {
getChangeRequest: () => Effect.succeed(hostedChangeRequest("body")),
listChangeRequests: () =>
Effect.succeed({ items: [focus], truncated: false, continues: false }),
getNativeDependencyMembership: () =>
Effect.succeed({
status: "present",
id: "STACK_1",
coverage: "complete",
members: [
items: [
{
number: 1,
title: "Migration",
url: "https://github.com/acme/web/pull/1",
state: "merged",
isDraft: false,
headBranch: "migration",
...changeRequest(2, "2026-07-03T00:00:00Z"),
headBranch: "api",
headRepositoryNameWithOwner: "acme/web",
baseBranch: "main",
baseBranch: "migration",
},
focus,
],
truncated: false,
continues: false,
}),
getChangeRequestStack: () =>
Effect.succeed({
id: "STACK_1",
number: 1,
url: "https://github.com/acme/web/stacks/1",
base: "main",
layers: [
{ number: 1, headBranch: "migration", state: "merged" },
{ number: 2, headBranch: "api", state: "open" },
],
}),
}),
],
});

const result = yield* service.dependencyContext(reference);
assert.deepStrictEqual(result.native, {
status: "present",
id: "STACK_1",
members: [1, 2],
coverage: "complete",
const stack = yield* service.stack(reference);
assert.deepStrictEqual(
stack?.layers.map((layer) => layer.number),
[1, 2],
);
const context = yield* service.dependencyContext(reference);
assert.deepStrictEqual(
context.nodes.map((node) => node.ref.number),
[2],
);
assert.deepStrictEqual(context.edges, []);
assert.notProperty(context, "native");
const detail = yield* service.detail(reference);
assert.deepStrictEqual(detail.capabilities.dependencies, {
branchRelationships: true,
nativeMembership: false,
});
assert.deepStrictEqual(result.nodes.map((node) => node.ref.number).sort(), [1, 2]);
assert.deepStrictEqual(result.edges, []);
}),
);

Expand Down Expand Up @@ -5537,7 +5515,6 @@ it.effect(
continues: false,
};
}),
getNativeDependencyMembership: () => Effect.succeed({ status: "none" }),
getChangeRequestStack: () =>
Effect.sync(() => {
stacks++;
Expand Down
Loading
Loading