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
30 changes: 29 additions & 1 deletion .github/fork-seams.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,32 @@
"packages/provider-core/src/server/failure.ts": {
"why": "MCP profiles part 2: the refusal of a Claude turn by its MCP profile says why and how to fix it, so its message is shown.",
"added": ["case \"ClaudeMcpProfileError\":"]
},
"apps/web/src/components/settings/settingsSearch.ts": {
"why": "The fork's Settings page \"Fork\" (/settings/fork) is one more SettingsPath, so it needs its label, its place in the nav (the Agents group) and its search scope here; its rows are the fork's own search items (forkSettingsSearchItems.ts), spread in at one place. The import and the spread predate the list (they were \"pending\").",
"added": [
"import { FORK_SETTINGS_SEARCH_ITEMS } from \"./forkSettingsSearchItems\"; // Fork",
"...FORK_SETTINGS_SEARCH_ITEMS, // Fork: waits and agent slots."
],
"announced": {
"since": "2026-11-19",
"added": [
"import { FORK_SETTINGS_LABEL, FORK_SETTINGS_SEARCH_ITEMS } from \"./forkSettingsSearchItems\"; // Fork",
"| \"/settings/fork\" // Fork",
"\"/settings/fork\": FORK_SETTINGS_LABEL, // Fork",
"\"/settings/fork\", // Fork",
"\"/settings/fork\": null, // Fork",
"...FORK_SETTINGS_SEARCH_ITEMS, // Fork: the rows of the Fork page."
]
}
},
"apps/web/src/components/settings/SettingsSidebarNav.tsx": {
"why": "The fork's Settings page \"Fork\" (/settings/fork) needs its icon in the nav's icon table, which every SettingsPath must have.",
"added": [],
"announced": {
"since": "2026-11-19",
"added": ["GitForkIcon,", "\"/settings/fork\": GitForkIcon, // Fork"]
}
}
},
"//pending": "Upstream files whose fork lines predate counting every upstream file, each with its ceiling: the most fork lines it may hold against upstream (counted from upstream, as fork-follow runs the check). To move into fork files or pin as seams; lower a ceiling when lines move out and take a file off when none are left. A pull request may change them but not grow them.",
Expand Down Expand Up @@ -215,7 +241,6 @@
"apps/web/src/components/settings/SettingsPanels.tsx": 4,
"apps/web/src/components/settings/scopedSettings.test.ts": 153,
"apps/web/src/components/settings/scopedSettings.ts": 9,
"apps/web/src/components/settings/settingsSearch.ts": 2,
"apps/web/src/components/settings/useScopedSettings.ts": 27,
"apps/web/src/index.css": 2,
"apps/web/src/markdown-links.test.ts": 1,
Expand Down Expand Up @@ -281,6 +306,9 @@
"packages/shared/src/waitFor*",
"scripts/lib/release-repository.ts",
"scripts/release-repository.test.ts",
"apps/web/src/routes/_chat.settings.fork.tsx",
"apps/web/src/components/settings/ReviewRulesSettings*",
"apps/web/src/components/settings/reviewRulesSettings*",
"!scripts/scenarios/fork-title-regenerates-from-inherited-history.e2e.ts"
],
"//lost": "Seam and pending files that lost upstream lines, counted from upstream (as fork-follow runs the check): \"lines\", the upstream lines not kept in order and indentation; \"gone\", those whose text is gone. Held exactly, like a ceiling; an unlisted file counts 0. Lower a count when a line comes back, and keep each one small: a count is not a set of lines, so a line counted here may move unseen, and in a pending file a pull request can put back one gone upstream line and delete another with both counts unchanged.",
Expand Down
32 changes: 30 additions & 2 deletions .github/scripts/fork-seam-check.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ const CONFIG = ".github/fork-seams.json";
const REMOVED = ".github/fork-removed-workflows.txt";
const REMOVED_PATH = /^\.github\/workflows\/[^/,\s]+\.ya?ml$/;
const FORK_WORKFLOW = /^\.github\/workflows\/fork-[^/]*\.ya?ml$/;
// Generated upstream files: the folder each is generated from, and the fork test that proves the
// file is the generator's output (a hand edit fails it). A fork route repeats upstream's lines
// (`} as any)`), so the file is not judged line by line when its folder changes too.
const GENERATED = new Map([
[
"apps/web/src/routeTree.gen.ts",
{ source: "apps/web/src/routes/", proof: "apps/web/src/forkRouteTree.test.ts" },
],
]);

function git(args) {
return execFileSync("git", ["-c", "core.quotePath=false", ...args], {
Expand Down Expand Up @@ -271,6 +280,7 @@ function findUnlistedChanges(
changed,
atBase,
atHead,
atMain = atBase,
upstream,
isForkFile,
removed = new Set(),
Expand All @@ -297,17 +307,32 @@ function findUnlistedChanges(
if (!removed.has(file) && !FORK_WORKFLOW.test(file)) reasons.push(deleted(file));
continue;
}
const generated = GENERATED.get(file);
let unproven = "";
if (generated !== undefined && changed.some((other) => other.startsWith(generated.source))) {
const proof = atHead(generated.proof);
if (proof === undefined) {
reasons.push(
`${file}: generated from ${generated.source}, but this change has no ${generated.proof}, the test that proves it is the generator's output.`,
);
continue;
}
// On a pull request the proof must be main's: a change to it (it.skip, an always-green test)
// could pass its own hand edit. From upstream the head's own script and tests judge.
if (upstream || proof === atMain(generated.proof)) continue;
unproven = ` Judged line by line: this change's ${generated.proof} is not main's, so it proves nothing (change that test in its own pull request, or update the branch from main).`;
}
const added = total(addedLines(base, head));
const entry = upstream
? "."
: ' (if it is a fork file upstream does not have, add it to "forkFiles").';
if (added > 0) {
reasons.push(
`${file}: upstream file with ${added} fork line${added === 1 ? "" : "s"} but no entry in ${CONFIG}${entry}`,
`${file}: upstream file with ${added} fork line${added === 1 ? "" : "s"} but no entry in ${CONFIG}${entry}${unproven}`,
);
} else if (!sameLines(base, head)) {
reasons.push(
`${file}: upstream file whose lines this change deletes, moves or re-indents, but no entry in ${CONFIG}${entry}`,
`${file}: upstream file whose lines this change deletes, moves or re-indents, but no entry in ${CONFIG}${entry}${unproven}`,
);
}
}
Expand Down Expand Up @@ -1018,6 +1043,8 @@ function main(argv) {
changed,
atBase,
atHead,
// The list's commit: main on a pull request (fork-checks), the head from upstream.
atMain: (file) => textAt(configRef, file),
upstream,
isForkFile,
removed,
Expand Down Expand Up @@ -1147,6 +1174,7 @@ function main(argv) {

module.exports = {
CONFIG,
GENERATED,
compileForkPattern,
findAnnouncementWarnings,
findDuplicateKey,
Expand Down
162 changes: 162 additions & 0 deletions .github/scripts/fork-seam-check.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
findStaleSeamLines,
findUnlistedChanges,
forkFileTest,
GENERATED,
lineCounts,
lostLines,
lowerList,
Expand Down Expand Up @@ -211,6 +212,67 @@ test("from upstream, a fork pattern that matches an upstream file fails until ex
);
});

test("the route tree is judged as generated output: with a route change and its proof test, or line by line", () => {
const TREE = "apps/web/src/routeTree.gen.ts";
const PROOF = "apps/web/src/forkRouteTree.test.ts";
const ROUTE = "apps/web/src/routes/_chat.settings.fork.tsx";
const tree = "const A = AImport.update({\n getParentRoute: () => Root,\n} as any)\n";
// A fork route's block repeats upstream's lines, which no seam entry can list.
const forkTree = `${tree}const Fork = ForkImport.update({\n getParentRoute: () => Root,\n} as any)\n`;
const base = { [TREE]: tree, [PROOF]: "test\n" };
const withRoute = { [TREE]: forkTree, [PROOF]: "test\n", [ROUTE]: "route\n" };
for (const upstream of [true, false]) {
assert.deepEqual(unlisted({}, base, withRoute, upstream).reasons, [], String(upstream));
// Without a route change, a change to the tree is a hand edit, judged like any upstream file.
const alone = unlisted({}, base, { ...base, [TREE]: forkTree }, upstream).reasons;
assert.equal(alone.length, 1);
assert.match(alone[0], /^apps\/web\/src\/routeTree\.gen\.ts: upstream file with 3 fork lines/);
const { [PROOF]: _proof, ...noProof } = withRoute;
assert.deepEqual(unlisted({}, { [TREE]: tree }, noProof, upstream).reasons, [
`${TREE}: generated from apps/web/src/routes/, but this change has no ${PROOF}, the test that proves it is the generator's output.`,
]);
// Deleting it is still refused.
const { [TREE]: _tree, ...gone } = withRoute;
assert.match(
unlisted({}, base, gone, upstream).reasons[0],
/^apps\/web\/src\/routeTree\.gen\.ts: upstream file this change deletes/,
);
// A folder that only starts like the routes folder is no route change.
const sibling = { ...base, [TREE]: forkTree, "apps/web/src/routes-x/a.ts": "a\n" };
const nearRoute = unlisted({}, base, sibling, upstream).reasons;
assert.equal(nearRoute.length, 1);
assert.match(
nearRoute[0],
/^apps\/web\/src\/routeTree\.gen\.ts: upstream file with 3 fork lines/,
);
}
// On a pull request the proof must be main's: one that changes it (it.skip, an always-green test)
// could pass its own hand edit, so the tree is then judged line by line. From upstream the head's
// own script and tests judge it, and upstream has no proof to compare with.
const weakened = { ...withRoute, [PROOF]: 'it.skip("…", () => {});\n' };
assert.deepEqual(unlisted({}, { [TREE]: tree }, weakened, true).reasons, []);
const refused = unlisted({}, base, weakened, false).reasons;
assert.equal(refused.length, 1);
assert.match(refused[0], /^apps\/web\/src\/routeTree\.gen\.ts: upstream file with 3 fork lines/);
assert.match(refused[0], /forkRouteTree\.test\.ts is not main's/);
// Main's, not the merge-base's: a branch from before main changed the proof is judged line by line
// until it is updated from main.
const judge = (main) =>
findUnlistedChanges(
{ files: {}, pending: {}, forkFiles: [] },
{
changed: [TREE, ROUTE],
atBase: (file) => base[file],
atHead: (file) => withRoute[file],
atMain: (file) => main[file],
upstream: false,
isForkFile: forkFileTest([]),
},
).reasons;
assert.deepEqual(judge(base), []);
assert.match(judge({ ...base, [PROOF]: "stricter test\n" })[0], /is not main's/);
});

test("a pending file: held to its ceiling from upstream; on a pull request it may change but not grow", () => {
const config = { pending: { "p.ts": 2 } };
const main = { "p.ts": `${UP}forkA();\nforkB();\n` };
Expand Down Expand Up @@ -448,6 +510,75 @@ const readReal = (file) =>
// Read in each test, not at load: a parse error then fails the tests that pin it, not the file.
const realConfig = () => parseConfig(readReal(CONFIG));

// The options apps/web/vite.config.ts passes to tanstackRouter(...), which dev and builds generate
// the route tree with. Throws when the call is gone, repeated or not a plain literal.
function viteRouterOptions(source) {
const calls = [...source.matchAll(/\btanstackRouter\(/g)];
const unreadable = (why) =>
new Error(
`apps/web/vite.config.ts: ${why}; teach this test to read the router plugin's options again.`,
);
if (calls.length !== 1) throw unreadable(`${calls.length} tanstackRouter( calls, not 1`);
const start = calls[0].index + calls[0][0].length;
let depth = 1;
let end = start;
while (depth > 0 && end < source.length) {
const char = source[end++];
if (char === "(") depth += 1;
if (char === ")") depth -= 1;
}
const text = source.slice(start, end - 1).trim();
if (text === "") return {};
try {
return new Function(`"use strict"; return (${text});`)();
} catch (error) {
throw unreadable(`its tanstackRouter(${text}) options are not a plain literal (${error})`);
}
}

// GENERATED must name the tree and folder the router plugin really uses, or the seam check skips the
// wrong files. Checked here, not in the proof test: app code must not read this fork-owned script
// (fork-owned-reads.test.py), since a fork-only change to it would skip the app jobs. The proof test
// pins what the plugin resolves these options to (its defaults: src/routes/, src/routeTree.gen.ts).
test("the generated-file table names the route tree and routes folder vite.config.ts generates with", () => {
const read = (file) => {
try {
return readReal(file);
} catch {
return undefined;
}
};
const fileConfig = read("apps/web/tsr.config.json");
const options = {
...(fileConfig === undefined ? {} : JSON.parse(fileConfig)),
...viteRouterOptions(readReal("apps/web/vite.config.ts")),
};
const inWeb = (file) => path.posix.join("apps/web", file);
const source = `${inWeb(options.routesDirectory ?? "./src/routes")}/`;
const tree = inWeb(options.generatedRouteTree ?? "./src/routeTree.gen.ts");
assert.deepEqual(GENERATED.get(tree), { source, proof: "apps/web/src/forkRouteTree.test.ts" });
for (const [file, { source: folder, proof }] of GENERATED) {
assert.notEqual(read(file), undefined, `${file} is not in the tree`);
assert.notEqual(read(proof), undefined, `${proof} is not in the tree`);
assert.ok(
folder.endsWith("/"),
`${folder}: a folder ends with /, or a sibling's name matches it`,
);
const inFolder = execFileSync(
"git",
["-C", REPO_ROOT, "ls-tree", "--name-only", "--full-tree", "HEAD", folder],
{ encoding: "utf8" },
);
assert.notEqual(inFolder.trim(), "", `${folder} has no files`);
}
// The reader itself: a moved or computed option fails it rather than passing on the defaults.
assert.deepEqual(viteRouterOptions("x(tanstackRouter({ autoCodeSplitting: true }))"), {
autoCodeSplitting: true,
});
assert.throws(() => viteRouterOptions("plugins: []"), /0 tanstackRouter\( calls/);
assert.throws(() => viteRouterOptions("tanstackRouter(options)"), /not a plain literal/);
});

test("every listed seam line is in its file and no announced one is yet, so the list is not stale", () => {
const read = (file) => {
try {
Expand Down Expand Up @@ -591,6 +722,37 @@ function withRepo(body) {
}
const seams = (config) => ({ [CONFIG]: JSON.stringify(config) });

// Pins main()'s wiring: the proof is compared with the list's commit (main), not the merge-base.
test("the command line takes the route tree as generated only while the proof is main's", () => {
withRepo(({ git, commit, run }) => {
const TREE = "apps/web/src/routeTree.gen.ts";
const PROOF = "apps/web/src/forkRouteTree.test.ts";
const ROUTE = "apps/web/src/routes/_chat.settings.fork.tsx";
const tree = "const A = AImport.update({\n getParentRoute: () => Root,\n} as any)\n";
const forkTree = `${tree}const Fork = ForkImport.update({\n getParentRoute: () => Root,\n} as any)\n`;
const main = commit(
{ ...seams({ files: SEAM }), ...BASE, [TREE]: tree, [PROOF]: "test\n" },
"main",
);
const route = { [TREE]: forkTree, [ROUTE]: "route\n" };
git("checkout", "-q", "-b", "pr", main);
const pr = commit(route, "a route");
assert.equal(run("--config-ref", main, main, pr).status, 0);
git("checkout", "-q", "-B", "weak", main);
const weak = commit({ ...route, [PROOF]: "it.skip();\n" }, "a route and a weaker proof");
const refused = run("--config-ref", main, main, weak);
assert.equal(refused.status, 1);
assert.match(
refused.stderr,
/routeTree\.gen\.ts: upstream file with 3 fork lines.*is not main's/,
);
// Main tightened the proof after the branch: judged line by line until updated from main.
git("checkout", "-q", "-B", "main2", main);
const main2 = commit({ [PROOF]: "stricter test\n" }, "main: a stricter proof");
assert.match(run("--config-ref", main2, main, pr).stderr, /is not main's/);
});
});

test("the command line judges the lines a branch adds since the merge-base", () => {
withRepo(({ git, commit, run }) => {
const base = commit({ ...seams({ files: SEAM }), ...BASE }, "upstream");
Expand Down
Loading
Loading