Skip to content
Open
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
1 change: 1 addition & 0 deletions .changes/python-package-identity.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
恢复 Python Peer 对 Local Files 扩展的启用,区分 Registry 扩展名和 Python 入口点名称。
83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions app/business/extension/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions docs/40-deployment/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
使 Learn English 扩展类匹配 Registry 扩展名,恢复安装后的启用。
2 changes: 1 addition & 1 deletion extensions/learn_english/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LearnEnglishState(sqlmodel.SQLModel): ...

class Extension(
ExtensionBase[LearnEnglishConfig],
ext_id="learn_english",
ext_id="learn-english",
config_cls=LearnEnglishConfig,
):
@classmethod
Expand Down
1 change: 1 addition & 0 deletions release/browser-consumer.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4b14bbe69155ff3f013377960448a00bbbb6cbe2
38 changes: 38 additions & 0 deletions scripts/extension_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import argparse
import ast
import configparser
from email.parser import BytesParser
import json
Expand Down Expand Up @@ -133,6 +134,43 @@ 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(":")
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(
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
]
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 != runtime_id:
raise ValueError(
f"{project.entry_object} declares ext_id {declared_id.value!r}, "
f"but {project.coordinate!r} requires {runtime_id!r}"
)

if canonicalize_name(metadata["Name"]) != canonicalize_name(project.project):
raise ValueError("wheel Project Name differs from pyproject")
Expand Down
Loading