From 975d142a75e61b8c70fcb096b021858224d95933 Mon Sep 17 00:00:00 2001 From: Lan_zhijiang Date: Sun, 29 Nov 2026 16:24:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(dx):=20=E6=8F=90=E5=89=8D=E6=A0=B8?= =?UTF-8?q?=E9=AA=8C=E6=89=A9=E5=B1=95=E8=BA=AB=E4=BB=BD=E4=B8=8E=20Core?= =?UTF-8?q?=20=E6=B6=88=E8=B4=B9=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 旧 Local Files wheel 在资格检查时拒绝,修复源码入口声明 - 共享数据库变更自动以两端精确提交运行浏览器验收 --- .github/workflows/ci.yml | 83 +++++++++++++++++++ docs/40-deployment/docker.md | 6 ++ .../.changes/wheel-entry-point.fixed.md | 1 + extensions/local_files/pyproject.toml | 2 +- release/browser-consumer.ref | 1 + scripts/extension_distribution.py | 26 ++++++ 6 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 extensions/local_files/.changes/wheel-entry-point.fixed.md create mode 100644 release/browser-consumer.ref diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16eac7b9..d8748408 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,6 +99,89 @@ jobs: - name: Validate GitHub Actions definitions run: pdm run pre-commit run actionlint --all-files + browser-consumer: + name: Core browser consumer + runs-on: ubuntu-latest + timeout-minutes: 25 + steps: + - name: Checkout exact Core candidate + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + fetch-depth: 0 + persist-credentials: false + + - name: Select the browser consumer for shared database changes + id: consumer + env: + BASE_REVISION: ${{ github.event.pull_request.base.sha }} + run: | + if [ -n "$BASE_REVISION" ]; then + changes="$(git diff --name-only "$BASE_REVISION"...HEAD -- \ + migrations app/database_contract inkcre_core/database_contract \ + release/database-contract release/browser-consumer.ref Dockerfile pdm.lock \ + scripts/automation/runtime_artifact.sh scripts/automation/runtime_contract.sh \ + .github/workflows/ci.yml)" + if [ -z "$changes" ]; then + echo 'No shared database delivery change.' >> "$GITHUB_STEP_SUMMARY" + exit 0 + fi + fi + revision="$(cat release/browser-consumer.ref)" + [[ "$revision" =~ ^[0-9a-f]{40}$ ]] + printf 'revision=%s\n' "$revision" >> "$GITHUB_OUTPUT" + { + printf 'Core source: `%s`\n\n' "$(git rev-parse HEAD)" + printf 'TypeScript consumer: `%s`\n' "$revision" + } >> "$GITHUB_STEP_SUMMARY" + + - name: Checkout exact browser consumer + if: steps.consumer.outputs.revision != '' + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + repository: InKCre/impl-ts + ref: ${{ steps.consumer.outputs.revision }} + path: .browser-consumer + persist-credentials: false + + - name: Set up Python and PDM + if: steps.consumer.outputs.revision != '' + uses: pdm-project/setup-pdm@973541a5febeafcfdadf8a51211435be6ecfd90f # v4.5 + with: + python-version-file: .python-version + version: 2.28.0 + + - name: Install pnpm + if: steps.consumer.outputs.revision != '' + uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + with: + package_json_file: .browser-consumer/package.json + + - name: Install Node + if: steps.consumer.outputs.revision != '' + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: .browser-consumer/package.json + cache: pnpm + cache-dependency-path: .browser-consumer/pnpm-lock.yaml + + - name: Run the two browsers against this candidate + if: steps.consumer.outputs.revision != '' + working-directory: .browser-consumer + run: | + pnpm install --frozen-lockfile + pnpm exec playwright install --with-deps chromium + pnpm test:e2e:core .. + + - name: Upload cross-repository failure evidence + if: failure() && steps.consumer.outputs.revision != '' + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: core-browser-consumer-failure + path: .browser-consumer/test-results/ + if-no-files-found: ignore + retention-days: 7 + artifact: name: impl-py e2e tests runs-on: ubuntu-latest diff --git a/docs/40-deployment/docker.md b/docs/40-deployment/docker.md index f0bbf109..2cd80334 100644 --- a/docs/40-deployment/docker.md +++ b/docs/40-deployment/docker.md @@ -109,6 +109,12 @@ secrets. ## CI Evidence +Core pull requests that change the shared database delivery path run Web and WebExt against +the exact Core PR head. The [browser consumer pin](../../release/browser-consumer.ref) selects +the TypeScript checkout. Update that pin in the Core PR for a coordinated change. The job +summary identifies both commits, so a follow-up TypeScript change needs a new pin to qualify +the new pair. + The artifact job in `.github/workflows/ci.yml` builds the source image and PostgREST, then proves the full fresh-database chain: duplicate init, JSON readiness, negative drift cases, the production PostgREST wrapper binding from `$PORT`, JWT read/write and denial behavior, diff --git a/extensions/local_files/.changes/wheel-entry-point.fixed.md b/extensions/local_files/.changes/wheel-entry-point.fixed.md new file mode 100644 index 00000000..0f63ecab --- /dev/null +++ b/extensions/local_files/.changes/wheel-entry-point.fixed.md @@ -0,0 +1 @@ +修复 Local Files wheel 的入口点身份,使其与宿主加载的扩展类一致。 diff --git a/extensions/local_files/pyproject.toml b/extensions/local_files/pyproject.toml index 9f8185bf..2f9980d3 100644 --- a/extensions/local_files/pyproject.toml +++ b/extensions/local_files/pyproject.toml @@ -14,7 +14,7 @@ dependencies = [ ] [project.entry-points."inkcre.core.extensions"] -local_files = "extensions.local_files:Extension" +local-files = "extensions.local_files:Extension" [tool.inkcre-extension] name = "inkcre/local-files" diff --git a/release/browser-consumer.ref b/release/browser-consumer.ref new file mode 100644 index 00000000..68280ea4 --- /dev/null +++ b/release/browser-consumer.ref @@ -0,0 +1 @@ +4b14bbe69155ff3f013377960448a00bbbb6cbe2 diff --git a/scripts/extension_distribution.py b/scripts/extension_distribution.py index e554a1cb..a4da7f78 100644 --- a/scripts/extension_distribution.py +++ b/scripts/extension_distribution.py @@ -3,6 +3,7 @@ from __future__ import annotations import argparse +import ast import configparser from email.parser import BytesParser import json @@ -133,6 +134,31 @@ def verify_wheel(project: ProducerProject, wheel_path: Path) -> None: entry_points.read_string( archive.read(f"{dist_info_directory}/entry_points.txt").decode("utf-8") ) + module, _, class_name = project.entry_object.partition(":") + module_path = "/".join(module.split(".")) + sources = [ + path for path in (f"{module_path}.py", f"{module_path}/__init__.py") if path in names + ] + if len(sources) != 1: + raise ValueError(f"expected one wheel module for {project.entry_object}") + tree = ast.parse(archive.read(sources[0]), filename=sources[0]) + declarations = [ + keyword.value + for definition in tree.body + if isinstance(definition, ast.ClassDef) and definition.name == class_name + for keyword in definition.keywords + if keyword.arg == "ext_id" + ] + declared_id = declarations[0] if len(declarations) == 1 else None + if not isinstance(declared_id, ast.Constant) or not isinstance(declared_id.value, str): + raise ValueError( + f"{project.entry_object} must declare its literal ExtensionBase ext_id" + ) + if declared_id.value != project.entry_name: + raise ValueError( + f"{project.entry_object} declares ext_id {declared_id.value!r}, " + f"but the wheel entry point is {project.entry_name!r}" + ) if canonicalize_name(metadata["Name"]) != canonicalize_name(project.project): raise ValueError("wheel Project Name differs from pyproject") From aea4b9eae37cc55ca0f2cfab336d594b41880de5 Mon Sep 17 00:00:00 2001 From: Lan_zhijiang Date: Sun, 29 Nov 2026 16:31:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix(local-files):=20=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E7=B1=BB=E4=B8=8E=20Python=20=E5=8C=85?= =?UTF-8?q?=E5=92=8C=E5=85=A5=E5=8F=A3=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 保留已声明的 wheel 入口点和对外扩展名称。 - 将安装时的 Python 包边界纳入 wheel 检查。 --- .../local_files/.changes/wheel-entry-point.fixed.md | 2 +- extensions/local_files/__init__.py | 2 +- extensions/local_files/pyproject.toml | 2 +- scripts/extension_distribution.py | 8 +++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/extensions/local_files/.changes/wheel-entry-point.fixed.md b/extensions/local_files/.changes/wheel-entry-point.fixed.md index 0f63ecab..2b808841 100644 --- a/extensions/local_files/.changes/wheel-entry-point.fixed.md +++ b/extensions/local_files/.changes/wheel-entry-point.fixed.md @@ -1 +1 @@ -修复 Local Files wheel 的入口点身份,使其与宿主加载的扩展类一致。 +使 Local Files 的扩展类身份与 wheel 入口点及 Python 包一致,恢复安装后的启用。 diff --git a/extensions/local_files/__init__.py b/extensions/local_files/__init__.py index 35d9126f..22f277f5 100644 --- a/extensions/local_files/__init__.py +++ b/extensions/local_files/__init__.py @@ -10,7 +10,7 @@ class LocalFilesConfig(pydantic.BaseModel): class Extension( - ExtensionBase[LocalFilesConfig], ext_id="local-files", config_cls=LocalFilesConfig + ExtensionBase[LocalFilesConfig], ext_id="local_files", config_cls=LocalFilesConfig ): @classmethod def _init_resolvers(cls) -> None: diff --git a/extensions/local_files/pyproject.toml b/extensions/local_files/pyproject.toml index 2f9980d3..9f8185bf 100644 --- a/extensions/local_files/pyproject.toml +++ b/extensions/local_files/pyproject.toml @@ -14,7 +14,7 @@ dependencies = [ ] [project.entry-points."inkcre.core.extensions"] -local-files = "extensions.local_files:Extension" +local_files = "extensions.local_files:Extension" [tool.inkcre-extension] name = "inkcre/local-files" diff --git a/scripts/extension_distribution.py b/scripts/extension_distribution.py index a4da7f78..cbd96887 100644 --- a/scripts/extension_distribution.py +++ b/scripts/extension_distribution.py @@ -135,7 +135,13 @@ def verify_wheel(project: ProducerProject, wheel_path: Path) -> None: archive.read(f"{dist_info_directory}/entry_points.txt").decode("utf-8") ) module, _, class_name = project.entry_object.partition(":") - module_path = "/".join(module.split(".")) + module_parts = module.split(".") + if module_parts[:2] != ["extensions", project.entry_name]: + raise ValueError( + f"wheel entry point {project.entry_name!r} must live in " + f"extensions.{project.entry_name}, got {module!r}" + ) + module_path = "/".join(module_parts) sources = [ path for path in (f"{module_path}.py", f"{module_path}/__init__.py") if path in names ] From a411de903e0237db5b990440576984d3b3f66dd3 Mon Sep 17 00:00:00 2001 From: Lan_zhijiang Date: Sun, 29 Nov 2026 16:38:16 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix(extensions):=20=E5=8C=BA=E5=88=86=20Reg?= =?UTF-8?q?istry=20=E8=BA=AB=E4=BB=BD=E5=92=8C=20Python=20=E5=8C=85?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 复用绑定时的扩展类身份校验和安装包归属检查。 - 支持原有 Local Files 扩展的 local_files 入口点。 --- .changes/python-package-identity.fixed.md | 1 + app/business/extension/main.py | 17 +++++++---------- .../.changes/wheel-entry-point.fixed.md | 1 - extensions/local_files/__init__.py | 2 +- scripts/extension_distribution.py | 10 ++++++++-- 5 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 .changes/python-package-identity.fixed.md delete mode 100644 extensions/local_files/.changes/wheel-entry-point.fixed.md diff --git a/.changes/python-package-identity.fixed.md b/.changes/python-package-identity.fixed.md new file mode 100644 index 00000000..6afb64c9 --- /dev/null +++ b/.changes/python-package-identity.fixed.md @@ -0,0 +1 @@ +恢复 Python Peer 对 Local Files 扩展的启用,区分 Registry 扩展名和 Python 入口点名称。 diff --git a/app/business/extension/main.py b/app/business/extension/main.py index 631c1c09..5fe87091 100644 --- a/app/business/extension/main.py +++ b/app/business/extension/main.py @@ -779,22 +779,19 @@ async def _start_acquired( association: PythonReleaseDescriptor, acquired: AcquiredDistribution, ) -> RunningExtension: + runtime_id = state.name.partition("/")[2] + if association.entry_point.name.replace("_", "-") != runtime_id: + raise ExtensionCompatibilityError( + "Python entry point does not represent the installed Extension identity" + ) + modules = DistributionModules(acquired) try: - claim = ExtensionRuntimeClaim.acquire(association.entry_point.name) + claim = ExtensionRuntimeClaim.acquire(runtime_id) except ExtensionRuntimeClaimConflictError as error: raise ExtensionStateConflictError(str(error)) from error - try: - modules = DistributionModules(acquired) - except Exception: - claim.release() - raise extension_class: type[ExtensionBase] | None = None try: extension_class = typing.cast(type[ExtensionBase], modules.load(ExtensionBase)) - if extension_class.__extid__ != association.entry_point.name: - raise ExtensionCompatibilityError( - "ExtensionBase identity differs from the declared entry point" - ) extension_class.bind( _ActiveExtensionModel( name=state.name, diff --git a/extensions/local_files/.changes/wheel-entry-point.fixed.md b/extensions/local_files/.changes/wheel-entry-point.fixed.md deleted file mode 100644 index 2b808841..00000000 --- a/extensions/local_files/.changes/wheel-entry-point.fixed.md +++ /dev/null @@ -1 +0,0 @@ -使 Local Files 的扩展类身份与 wheel 入口点及 Python 包一致,恢复安装后的启用。 diff --git a/extensions/local_files/__init__.py b/extensions/local_files/__init__.py index 22f277f5..35d9126f 100644 --- a/extensions/local_files/__init__.py +++ b/extensions/local_files/__init__.py @@ -10,7 +10,7 @@ class LocalFilesConfig(pydantic.BaseModel): class Extension( - ExtensionBase[LocalFilesConfig], ext_id="local_files", config_cls=LocalFilesConfig + ExtensionBase[LocalFilesConfig], ext_id="local-files", config_cls=LocalFilesConfig ): @classmethod def _init_resolvers(cls) -> None: diff --git a/scripts/extension_distribution.py b/scripts/extension_distribution.py index cbd96887..e404ef7b 100644 --- a/scripts/extension_distribution.py +++ b/scripts/extension_distribution.py @@ -135,6 +135,12 @@ def verify_wheel(project: ProducerProject, wheel_path: Path) -> None: archive.read(f"{dist_info_directory}/entry_points.txt").decode("utf-8") ) module, _, class_name = project.entry_object.partition(":") + runtime_id = project.coordinate.partition("/")[2] + if project.entry_name.replace("_", "-") != runtime_id: + raise ValueError( + f"wheel entry point {project.entry_name!r} does not represent " + f"the runtime identity {runtime_id!r}" + ) module_parts = module.split(".") if module_parts[:2] != ["extensions", project.entry_name]: raise ValueError( @@ -160,10 +166,10 @@ def verify_wheel(project: ProducerProject, wheel_path: Path) -> None: raise ValueError( f"{project.entry_object} must declare its literal ExtensionBase ext_id" ) - if declared_id.value != project.entry_name: + if declared_id.value != runtime_id: raise ValueError( f"{project.entry_object} declares ext_id {declared_id.value!r}, " - f"but the wheel entry point is {project.entry_name!r}" + f"but {project.coordinate!r} requires {runtime_id!r}" ) if canonicalize_name(metadata["Name"]) != canonicalize_name(project.project): From 335e2bf6d82e0110fb5e727aa2f94b888af0363b Mon Sep 17 00:00:00 2001 From: Lan_zhijiang Date: Sun, 29 Nov 2026 16:41:08 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix(learn-english):=20=E8=AE=A9=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E7=B1=BB=E4=BD=BF=E7=94=A8=20Registry=20=E7=9F=AD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 保留 Python 入口点和 Resolver ID。 --- extensions/learn_english/.changes/registry-identity.fixed.md | 1 + extensions/learn_english/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 extensions/learn_english/.changes/registry-identity.fixed.md diff --git a/extensions/learn_english/.changes/registry-identity.fixed.md b/extensions/learn_english/.changes/registry-identity.fixed.md new file mode 100644 index 00000000..8915ed9b --- /dev/null +++ b/extensions/learn_english/.changes/registry-identity.fixed.md @@ -0,0 +1 @@ +使 Learn English 扩展类匹配 Registry 扩展名,恢复安装后的启用。 diff --git a/extensions/learn_english/__init__.py b/extensions/learn_english/__init__.py index a41b8e87..77e2e791 100644 --- a/extensions/learn_english/__init__.py +++ b/extensions/learn_english/__init__.py @@ -10,7 +10,7 @@ class LearnEnglishState(sqlmodel.SQLModel): ... class Extension( ExtensionBase[LearnEnglishConfig], - ext_id="learn_english", + ext_id="learn-english", config_cls=LearnEnglishConfig, ): @classmethod