Skip to content

Commit a4306d6

Browse files
authored
feat(durable): add recoverable runtime and streamline public APIs (#4154)
1 parent 36cabf4 commit a4306d6

2,627 files changed

Lines changed: 130613 additions & 302139 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.

‎.dockerignore‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
!**/.env.example
2525
**/test-results
2626
**/playwright-report
27-
agentscope-service/docs/test-reports
28-
agentscope-service/release/dist
29-
agentscope-service/service-controlplane/bin
30-
agentscope-service/service-controlplane/ui
3127
docs/_build
3228
**/*.ppt
3329
**/*.pptx

‎.github/MAVEN_RELEASE.md‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Maven Central release
2+
3+
[中文](MAVEN_RELEASE_zh.md)
4+
5+
The `Maven Central staging` workflow (`maven-central-release.yml`) runs on a pushed
6+
version tag, such as `v2.1.0-BETA2`, `v2.1.0-RC1`, or `v2.1.0`.
7+
SNAPSHOT versions and Service/Go module tags are not release inputs.
8+
It does not run on branch pushes or pull requests.
9+
10+
Configure these repository Actions secrets:
11+
12+
| Secret | Value |
13+
| --- | --- |
14+
| `MAVEN_CENTRAL_USERNAME` | Central Portal user token username |
15+
| `MAVEN_CENTRAL_PASSWORD` | Central Portal user token password |
16+
| `MAVEN_GPG_PRIVATE_KEY` | ASCII-armored private signing key |
17+
| `MAVEN_GPG_PASSPHRASE` | Signing key passphrase |
18+
19+
Before tagging, set `revision` to the release version in the root `pom.xml`,
20+
`agentscope-dependencies-bom/pom.xml`, and
21+
`agentscope-distribution/agentscope-bom/pom.xml`. Merge the release preparation
22+
and workflow changes into the intended release branch. The workflow rejects
23+
a tag that differs from any of these versions; it never overrides the version
24+
of a SNAPSHOT checkout.
25+
26+
For example, after preparing `2.1.0-BETA2` on `main`:
27+
28+
```bash
29+
git switch main
30+
git pull --ff-only origin main
31+
git tag -a v2.1.0-BETA2 -m "Release 2.1.0-BETA2"
32+
git push origin v2.1.0-BETA2
33+
```
34+
35+
The workflow checks module/BOM declarations, runs Maven tests and formatting
36+
checks, generates sources and Javadoc, signs artifacts, and uploads the Maven
37+
library reactor (Core, Harness, extensions, BOMs, and distribution). Service
38+
applications, examples, and provider E2E tests are excluded from this reactor.
39+
Their release workflows are independent.
40+
41+
The deploy command explicitly sets `-DautoPublish=false -DwaitUntil=validated`.
42+
Success means the deployment is **VALIDATED**, awaiting manual publication;
43+
it does not make the packages available on Maven Central. Review
44+
`agentscope-java-<version>` in [Central Portal deployments](https://central.sonatype.com/publishing/deployments)
45+
and click **Publish** when ready. See the [Central plugin documentation](https://central.sonatype.org/publish/publish-portal-maven/).
46+
47+
For a failed run, inspect the Actions log and Portal state before rerunning.
48+
An upload may have succeeded even if a later validation request timed out.
49+
Remove an unwanted unpublished deployment in the Portal before uploading again;
50+
published versions cannot be overwritten. Rerun the workflow for the same tag
51+
instead of moving the tag.
52+
53+
After creating the release tag, subsequent development commits can return
54+
Maven versions to `SNAPSHOT`; the workflow builds the tagged source.

‎.github/MAVEN_RELEASE_zh.md‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Maven Central 发布
2+
3+
[English](MAVEN_RELEASE.md)
4+
5+
推送版本 tag(例如 `v2.1.0-BETA2`、`v2.1.0-RC1` 或 `v2.1.0`)时,
6+
触发 `Maven Central staging` 工作流(`maven-central-release.yml`)。
7+
SNAPSHOT 版本、Service tag 和 Go 模块独立 tag 不属于本流程的发布输入。
8+
推送分支、提交 PR 不会触发上传。
9+
10+
在仓库的 Actions secrets 中配置:
11+
12+
| Secret | 内容 |
13+
| --- | --- |
14+
| `MAVEN_CENTRAL_USERNAME` | Central Portal 用户 token 的 username |
15+
| `MAVEN_CENTRAL_PASSWORD` | Central Portal 用户 token 的 password |
16+
| `MAVEN_GPG_PRIVATE_KEY` | ASCII armored 格式的 GPG 签名私钥 |
17+
| `MAVEN_GPG_PASSPHRASE` | 签名私钥密码 |
18+
19+
打 tag 前,将根 `pom.xml`、`agentscope-dependencies-bom/pom.xml` 和
20+
`agentscope-distribution/agentscope-bom/pom.xml` 的 `revision` 改为发布版本,
21+
把版本准备与工作流改动合入准备发布的分支。
22+
工作流要求三个版本都与 tag 一致,不会通过参数把 SNAPSHOT 源码临时改成发布版本。
23+
24+
例如,在 `main` 准备好 `2.1.0-BETA2` 后执行:
25+
26+
```bash
27+
git switch main
28+
git pull --ff-only origin main
29+
git tag -a v2.1.0-BETA2 -m "Release 2.1.0-BETA2"
30+
git push origin v2.1.0-BETA2
31+
```
32+
33+
工作流校验模块与 BOM 声明,执行 Maven 测试和格式检查,生成 sources、Javadoc,
34+
签名并上传 Maven 库模块(Core、Harness、extensions、BOM 和 distribution)。
35+
构建范围排除 Service 应用、examples 和需要外部模型服务的 E2E 测试模块。
36+
其他组件由各自的工作流发布。
37+
38+
部署命令明确设置 `-DautoPublish=false -DwaitUntil=validated`。
39+
成功后进入 **VALIDATED** 状态,等待手动发布,包此时还不能从 Maven Central 下载。
40+
进入 [Central Portal deployments](https://central.sonatype.com/publishing/deployments),
41+
检查 `agentscope-java-<版本号>`,确认后手动点击 **Publish**。
42+
行为说明见 [Central 插件文档](https://central.sonatype.org/publish/publish-portal-maven/)。
43+
44+
运行失败时,先检查 Actions 日志及 Portal 中的状态,再决定是否重跑。
45+
校验请求超时并不代表上传失败。再次上传前,在 Portal 删除不需要的未发布 deployment;
46+
已正式发布的版本不能覆盖。通过 GitHub Actions 重跑原 tag 的工作流,不移动 tag。
47+
48+
发布 tag 创建后,后续开发提交可以把 Maven 版本切回 `SNAPSHOT`;工作流始终构建 tag 对应的源码。
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2024-2026 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
"""Require a non-SNAPSHOT version tag matching all independent Maven revisions."""
17+
18+
import argparse
19+
import os
20+
from pathlib import Path
21+
import re
22+
import xml.etree.ElementTree as ET
23+
24+
25+
POMS = (
26+
"pom.xml",
27+
"agentscope-dependencies-bom/pom.xml",
28+
"agentscope-distribution/agentscope-bom/pom.xml",
29+
)
30+
NS = {"m": "http://maven.apache.org/POM/4.0.0"}
31+
VERSION_TAG = re.compile(
32+
r"v(\d+\.\d+\.\d+(?:-[A-Za-z0-9]+(?:[.-][A-Za-z0-9]+)*)?)"
33+
)
34+
EXCLUDED_MODULES = {
35+
"agentscope-examples",
36+
"agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-e2e-tests",
37+
}
38+
39+
40+
def check_version(root: Path, tag: str) -> str:
41+
match = VERSION_TAG.fullmatch(tag)
42+
if not match or "SNAPSHOT" in tag.upper():
43+
raise ValueError(f"Expected a non-SNAPSHOT release tag such as v2.1.0-BETA2: {tag}")
44+
version = match.group(1)
45+
for filename in POMS:
46+
pom = ET.parse(root / filename).getroot()
47+
revision = pom.findtext("m:properties/m:revision", namespaces=NS)
48+
if revision != version:
49+
raise ValueError(f"{filename}: revision {revision!r} does not match tag version {version}")
50+
if pom.findtext("m:version", namespaces=NS) != "${revision}":
51+
raise ValueError(f"{filename}: project version must use ${{revision}}")
52+
return version
53+
54+
55+
def release_projects(root: Path) -> list[str]:
56+
"""Select library modules recursively; Maven 3 exclusions are not recursive."""
57+
projects = []
58+
59+
def visit(directory: Path) -> None:
60+
relative = directory.relative_to(root).as_posix()
61+
if relative in EXCLUDED_MODULES:
62+
return
63+
projects.append(relative)
64+
pom = ET.parse(directory / "pom.xml").getroot()
65+
for module in pom.findall("m:modules/m:module", NS):
66+
visit(directory / module.text)
67+
68+
visit(root)
69+
return projects
70+
71+
72+
def main() -> None:
73+
parser = argparse.ArgumentParser(description=__doc__)
74+
parser.add_argument("tag")
75+
args = parser.parse_args()
76+
try:
77+
version = check_version(Path.cwd(), args.tag)
78+
projects = ",".join(release_projects(Path.cwd()))
79+
except (ValueError, OSError, ET.ParseError) as error:
80+
raise SystemExit(str(error)) from error
81+
print(f"Maven release version: {version}")
82+
if output := os.environ.get("GITHUB_OUTPUT"):
83+
with open(output, "a", encoding="utf-8") as stream:
84+
stream.write(f"version={version}\n")
85+
stream.write(f"projects={projects}\n")
86+
87+
88+
if __name__ == "__main__":
89+
main()

‎.github/scripts/check-service-release-source.sh‎

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Copyright 2024-2026 the original author or authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import importlib.util
16+
import os
17+
from pathlib import Path
18+
import subprocess
19+
import sys
20+
import tempfile
21+
import unittest
22+
23+
24+
SCRIPT = Path(__file__).resolve().parents[1] / "check-maven-release-version.py"
25+
spec = importlib.util.spec_from_file_location("maven_release_version", SCRIPT)
26+
release = importlib.util.module_from_spec(spec)
27+
spec.loader.exec_module(release)
28+
29+
30+
class MavenReleaseVersionTest(unittest.TestCase):
31+
def setUp(self):
32+
self.directory = tempfile.TemporaryDirectory()
33+
self.addCleanup(self.directory.cleanup)
34+
self.root = Path(self.directory.name)
35+
36+
def write_poms(self, revision, project_version="${revision}"):
37+
for filename in release.POMS:
38+
pom = self.root / filename
39+
pom.parent.mkdir(parents=True, exist_ok=True)
40+
pom.write_text(
41+
'<project xmlns="http://maven.apache.org/POM/4.0.0">'
42+
f"<version>{project_version}</version>"
43+
f"<properties><revision>{revision}</revision></properties>"
44+
"</project>",
45+
encoding="utf-8",
46+
)
47+
48+
def test_stable_and_prerelease_tags(self):
49+
for version in ("2.1.0", "2.1.0-BETA2", "2.1.0-RC1", "2.0.5"):
50+
with self.subTest(version=version):
51+
self.write_poms(version)
52+
self.assertEqual(release.check_version(self.root, f"v{version}"), version)
53+
54+
def test_reject_snapshot_and_unrelated_tags(self):
55+
for tag in (
56+
"v2.1.0-SNAPSHOT", "v2.1.0-snapshot", "2.1.0-BETA2", "v2.1",
57+
"library-v2.1.0-BETA2",
58+
"library/component/v2.1.0-BETA2",
59+
"v2.1.0-BETA2\n", "v2.1.0;echo hello",
60+
):
61+
with self.subTest(tag=tag), self.assertRaises(ValueError):
62+
release.check_version(self.root, tag)
63+
64+
def test_reject_each_independent_revision_mismatch(self):
65+
for filename in release.POMS:
66+
with self.subTest(pom=filename):
67+
self.write_poms("2.1.0-BETA2")
68+
pom = self.root / filename
69+
pom.write_text(pom.read_text().replace("2.1.0-BETA2", "2.1.0-SNAPSHOT"))
70+
with self.assertRaisesRegex(ValueError, "does not match tag"):
71+
release.check_version(self.root, "v2.1.0-BETA2")
72+
73+
def test_reject_project_version_not_using_revision(self):
74+
self.write_poms("2.1.0-BETA2", project_version="2.1.0-SNAPSHOT")
75+
with self.assertRaisesRegex(ValueError, "must use"):
76+
release.check_version(self.root, "v2.1.0-BETA2")
77+
78+
def test_exclude_entire_examples_and_model_e2e_trees(self):
79+
self.write_poms("2.1.0-BETA2")
80+
(self.root / "pom.xml").write_text(
81+
'<project xmlns="http://maven.apache.org/POM/4.0.0"><modules>'
82+
'<module>library</module><module>agentscope-examples</module>'
83+
'<module>agentscope-extensions/agentscope-extensions-model</module>'
84+
'</modules></project>'
85+
)
86+
for module in ("library", "agentscope-extensions/agentscope-extensions-model"):
87+
directory = self.root / module
88+
directory.mkdir(parents=True)
89+
children = (
90+
"<modules><module>agentscope-extensions-model-e2e-tests</module></modules>"
91+
if module.endswith("model") else ""
92+
)
93+
(directory / "pom.xml").write_text(
94+
f'<project xmlns="http://maven.apache.org/POM/4.0.0">{children}</project>'
95+
)
96+
# Excluded trees need not be read or selected, including their children.
97+
self.assertEqual(release.release_projects(self.root), [
98+
".", "library", "agentscope-extensions/agentscope-extensions-model",
99+
])
100+
101+
def test_cli_outputs_only_after_successful_validation(self):
102+
output = self.root / "github-output"
103+
env = dict(os.environ, GITHUB_OUTPUT=str(output))
104+
self.write_poms("2.1.0-SNAPSHOT")
105+
failed = subprocess.run(
106+
[sys.executable, str(SCRIPT), "v2.1.0-BETA2"],
107+
cwd=self.root, env=env, capture_output=True, text=True,
108+
)
109+
self.assertNotEqual(failed.returncode, 0)
110+
self.assertFalse(output.exists())
111+
self.write_poms("2.1.0-BETA2")
112+
passed = subprocess.run(
113+
[sys.executable, str(SCRIPT), "v2.1.0-BETA2"],
114+
cwd=self.root, env=env, capture_output=True, text=True,
115+
)
116+
self.assertEqual(passed.returncode, 0, passed.stderr)
117+
self.assertEqual(output.read_text(), "version=2.1.0-BETA2\nprojects=.\n")
118+
119+
120+
if __name__ == "__main__":
121+
unittest.main()

0 commit comments

Comments
 (0)