Skip to content

Commit 12c93cc

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/claude-resume-rejected-session
# Conflicts: # apps/server/src/provider/Layers/ClaudeAdapter.test.ts
2 parents 5c6ff1a + f729e8f commit 12c93cc

713 files changed

Lines changed: 38774 additions & 12264 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.coderabbit.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
reviews:
22
review_status: false
33
auto_review:
4-
enabled: false
4+
enabled: true

‎.github/SECURITY.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Security policy
2+
3+
Report security vulnerabilities affecting T3 Code or T3 Tools-operated infrastructure to
4+
[[email protected]](mailto:[email protected]). Please do not disclose them publicly until we have had
5+
a reasonable opportunity to investigate and remediate them.
6+
7+
See the [full security policy](https://t3.codes/security-policy) for reporting details, scope,
8+
and safe harbor terms for good-faith research.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const MINIMUM_RELEASE_GAP_MS = 6 * 60 * 60 * 1000;
2+
3+
const isNightlyTag = (tag) => /^v.*-nightly\./.test(tag) || tag.startsWith("nightly-v");
4+
5+
// Newest published nightly by publication time, or undefined when none exists.
6+
async function findLatestNightly({ github, context }) {
7+
const releases = await github.paginate(github.rest.repos.listReleases, {
8+
...context.repo,
9+
per_page: 100,
10+
});
11+
return releases
12+
.filter((release) => !release.draft && release.published_at && isNightlyTag(release.tag_name))
13+
.sort((a, b) => Date.parse(b.published_at) - Date.parse(a.published_at))[0];
14+
}
15+
16+
// Runs after the workflow acquires the nightly concurrency lock.
17+
async function shouldReleaseNightly({ github, context, core, now = Date.now() }) {
18+
const lastNightly = await findLatestNightly({ github, context });
19+
20+
if (!lastNightly) {
21+
core.info("No published nightly found. Proceeding with release.");
22+
return true;
23+
}
24+
25+
if (now - Date.parse(lastNightly.published_at) < MINIMUM_RELEASE_GAP_MS) {
26+
core.info(`Nightly ${lastNightly.tag_name} was published less than six hours ago. Skipping.`);
27+
return false;
28+
}
29+
30+
const { data: comparison } = await github.rest.repos.compareCommitsWithBasehead({
31+
...context.repo,
32+
basehead: `${lastNightly.tag_name}...${context.sha}`,
33+
per_page: 1,
34+
});
35+
if (comparison.status !== "ahead") {
36+
core.info(
37+
`Candidate commit is ${comparison.status} relative to ${lastNightly.tag_name}. Skipping.`,
38+
);
39+
return false;
40+
}
41+
42+
core.info(`New commits since ${lastNightly.tag_name}, and the six-hour gap has passed.`);
43+
return true;
44+
}
45+
46+
// Stable releases build the commit the latest nightly shipped, so the stable
47+
// build is one nightly users already ran. Returns the nightly tag, its commit,
48+
// and the stable version that nightly was a preview of.
49+
async function resolveLatestNightlyCommit({ github, context, core }) {
50+
const lastNightly = await findLatestNightly({ github, context });
51+
if (!lastNightly) {
52+
throw new Error("No published nightly found. Stable releases build the latest nightly commit.");
53+
}
54+
55+
const tag = lastNightly.tag_name;
56+
// repos.getCommit dereferences annotated tags, so this is the commit either way.
57+
const { data: commit } = await github.rest.repos.getCommit({ ...context.repo, ref: tag });
58+
const version = /^(?:nightly-)?v(\d+\.\d+\.\d+)-nightly\./.exec(tag)?.[1];
59+
if (!version) {
60+
throw new Error(`Cannot derive a stable version from nightly tag ${tag}.`);
61+
}
62+
63+
core.info(`Latest nightly ${tag} shipped ${commit.sha} as a preview of ${version}.`);
64+
return { tag, sha: commit.sha, version };
65+
}
66+
67+
module.exports = { shouldReleaseNightly, resolveLatestNightlyCommit };
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
const assert = require("node:assert/strict");
2+
const test = require("node:test");
3+
const { shouldReleaseNightly } = require("./check-nightly-release.cjs");
4+
5+
const now = Date.parse("2026-09-05T12:00:00Z");
6+
const hour = 60 * 60 * 1000;
7+
const nightly = (hoursAgo, overrides = {}) => ({
8+
tag_name: "v1.0.1-nightly.20260905.123",
9+
draft: false,
10+
published_at: new Date(now - hoursAgo * hour).toISOString(),
11+
...overrides,
12+
});
13+
14+
function fixture({ releases = [nightly(7)], comparisonStatus = "ahead" } = {}) {
15+
const calls = [];
16+
return {
17+
calls,
18+
options: {
19+
now,
20+
context: { repo: { owner: "example", repo: "app" }, sha: "new" },
21+
core: { info() {} },
22+
github: {
23+
rest: {
24+
repos: {
25+
listReleases() {},
26+
async compareCommitsWithBasehead(params) {
27+
calls.push(params);
28+
return { data: { status: comparisonStatus } };
29+
},
30+
},
31+
},
32+
async paginate() {
33+
return releases;
34+
},
35+
},
36+
},
37+
};
38+
}
39+
40+
test("releases the first nightly when no nightly is published", async () => {
41+
const { options } = fixture({
42+
releases: [nightly(0, { tag_name: "v1.0.0" }), nightly(0, { draft: true })],
43+
});
44+
assert.equal(await shouldReleaseNightly(options), true);
45+
});
46+
47+
test("waits six hours after publication, including manual nightlies", async () => {
48+
for (const age of [0, 3, 6 - 1 / 3600]) {
49+
const { options, calls } = fixture({ releases: [nightly(age)] });
50+
assert.equal(await shouldReleaseNightly(options), false);
51+
assert.equal(calls.length, 0);
52+
}
53+
});
54+
55+
test("releases new commits at six hours and after an idle period", async () => {
56+
for (const age of [6, 7, 24]) {
57+
const { options } = fixture({ releases: [nightly(age)] });
58+
assert.equal(await shouldReleaseNightly(options), true);
59+
}
60+
});
61+
62+
test("skips unchanged commits after the gap", async () => {
63+
const { options } = fixture({ comparisonStatus: "identical" });
64+
assert.equal(await shouldReleaseNightly(options), false);
65+
});
66+
67+
test("uses publication time, not release order or the tagged commit date", async () => {
68+
const { options } = fixture({
69+
releases: [nightly(10), nightly(1), nightly(20, { tag_name: "nightly-v0.9.0" })],
70+
});
71+
assert.equal(await shouldReleaseNightly(options), false);
72+
});
73+
74+
test("ignores stable releases and drafts when checking the gap", async () => {
75+
const { options } = fixture({
76+
releases: [nightly(0, { tag_name: "v1.0.0" }), nightly(0, { draft: true }), nightly(7)],
77+
});
78+
assert.equal(await shouldReleaseNightly(options), true);
79+
});
80+
81+
test("compares against the published tag, including legacy nightly tags", async () => {
82+
const tag = "nightly-v0.9.0";
83+
const { options, calls } = fixture({ releases: [nightly(7, { tag_name: tag })] });
84+
assert.equal(await shouldReleaseNightly(options), true);
85+
assert.equal(calls[0].basehead, `${tag}...new`);
86+
});
87+
88+
test("fails instead of releasing when GitHub cannot supply release state", async () => {
89+
const { options } = fixture();
90+
options.github.paginate = async () => {
91+
throw new Error("GitHub unavailable");
92+
};
93+
await assert.rejects(shouldReleaseNightly(options), /GitHub unavailable/);
94+
});
95+
96+
for (const status of ["behind", "diverged"]) {
97+
test(`skips a candidate commit that is ${status} relative to the last nightly`, async () => {
98+
const { options } = fixture({ comparisonStatus: status });
99+
assert.equal(await shouldReleaseNightly(options), false);
100+
});
101+
}
102+
103+
const { resolveLatestNightlyCommit } = require("./check-nightly-release.cjs");
104+
105+
function nightlyCommitFixture({ releases, commitSha = "abc123" }) {
106+
const refs = [];
107+
const { options } = fixture({ releases });
108+
options.github.rest.repos.getCommit = async ({ ref }) => {
109+
refs.push(ref);
110+
return { data: { sha: commitSha } };
111+
};
112+
return { options, refs };
113+
}
114+
115+
test("stable releases resolve the commit of the newest published nightly", async () => {
116+
const { options, refs } = nightlyCommitFixture({
117+
releases: [
118+
nightly(10, { tag_name: "v1.0.1-nightly.20260905.100" }),
119+
nightly(1, { tag_name: "v1.0.1-nightly.20260905.123" }),
120+
nightly(0, { tag_name: "v1.0.0" }),
121+
nightly(0, { draft: true, tag_name: "v1.0.1-nightly.20260905.999" }),
122+
],
123+
commitSha: "deadbeef",
124+
});
125+
assert.deepEqual(await resolveLatestNightlyCommit(options), {
126+
tag: "v1.0.1-nightly.20260905.123",
127+
sha: "deadbeef",
128+
version: "1.0.1",
129+
});
130+
assert.deepEqual(refs, ["v1.0.1-nightly.20260905.123"]);
131+
});
132+
133+
test("stable releases derive the version from legacy nightly tags", async () => {
134+
const { options } = nightlyCommitFixture({
135+
releases: [nightly(1, { tag_name: "nightly-v0.9.0-nightly.20260905.5" })],
136+
});
137+
assert.equal((await resolveLatestNightlyCommit(options)).version, "0.9.0");
138+
});
139+
140+
test("stable releases fail without a published nightly", async () => {
141+
const { options } = nightlyCommitFixture({ releases: [nightly(0, { tag_name: "v1.0.0" })] });
142+
await assert.rejects(resolveLatestNightlyCommit(options), /No published nightly/);
143+
});

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ jobs:
103103
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
104104
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
105105
106+
- name: Test nightly release checks
107+
run: node --test .github/scripts/check-nightly-release.test.cjs
108+
106109
- name: Test
107110
run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' test
108111

0 commit comments

Comments
 (0)