diff --git a/docs/architecture/rfcs/monorepo-distribution-split-v0.md b/docs/architecture/rfcs/monorepo-distribution-split-v0.md index 3df17f5403..09c83044e0 100644 --- a/docs/architecture/rfcs/monorepo-distribution-split-v0.md +++ b/docs/architecture/rfcs/monorepo-distribution-split-v0.md @@ -4451,3 +4451,25 @@ view shows its independently checked result in the same conversation. complete D2/D5 closure, comparable full costs, R1/M3 and C1 cutover remain unqualified. Preserve prior failures and the original ten requirements; full original-goal regression still precedes completion and EdgeBench preparation. + +### 2026-11-15 — Require installed Core provenance before qualification + +- **Gap:** the Core test fixture trusted its interpreter environment variable; + selecting an ordinary editable checkout could pass an execution test even + though no standalone Core was installed. +- **Delta:** every opt-in Core qualification now checks version agreement, + rejects an ordinary co-install or editable Core, and matches the actual + imported package to its recorded Core installation before Task preparation. + Existing identity checks are shared through that fixture; namespace, help, + manifest and doctor coverage remain. No opt-in still reports an explicit skip. +- **Evidence:** the old ordinary-checkout case passed and dispatched ten CLI + calls. Ordinary, co-installed, source-shadowed, missing `loopx/__init__.py` + RECORD entry and PEP660 editable counterexamples now fail fixture setup before + any Task/CLI dispatch. + A true Core wheel passes identity plus File/SQLite execution, replay and + inspection. Original host, validator and execution oracles are unchanged. +- **Boundary:** this protects qualification provenance; it neither changes + production admission nor authenticates wheel bytes or model execution. + Pinned-source/artifact checks, actual-model adoption, complete D2/D5 costs, + R1/M3 and the original ten requirements remain separate. Preserve earlier + failures and run full original-goal regression before completion. diff --git a/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md b/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md index 76b912063e..61c064be2c 100644 --- a/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md +++ b/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md @@ -3446,3 +3446,19 @@ workspace 批准和脚本模型工作。桌面视图在采用检查后显示原 complete-source、selected-work、准入、context 和结算 owner。安装包大小、模型 采纳、完整 D2/D5 闭包、可比完整成本、R1/M3 与 C1 切换保持未验证。保留历史失败 和原十项要求;完成前仍需完整原目标回归,随后才准备 EdgeBench。 + +### 2026-11-15 — Core 资格验证前检查真实安装来源 + +- **缺口:**Core 测试 fixture 只信任解释器环境变量;指向普通 editable checkout + 也能通过执行测试,即使实际没有安装 standalone Core。 +- **增量:**每个 opt-in Core 资格用例在 Task 准备前检查版本一致、拒绝普通发行包 + 共装和 editable Core,并将实际导入包与 Core 安装记录对应。既有 identity 检查 + 通过该 fixture 共享,namespace、help、manifest 和 doctor 验证保留;未启用 opt-in + 仍明确报告 skip。 +- **证据:**旧普通源码环境通过用例并派发十次 CLI。普通包、共装、source shadow、 + 缺失 `loopx/__init__.py` 的 RECORD 条目和 PEP660 editable 五种反例现在都在 fixture setup 阶段失败,Task/ + CLI 派发为零。真实 Core wheel 通过 identity 及 File/SQLite 执行、回放和查看。 + 原 host、validator 和执行 oracle 均未改变。 +- **边界:**本次保护资格证据来源,不改变生产准入,也不认证 wheel 字节或模型 + 执行。固定源码/产物检查、真实模型采纳、完整 D2/D5 成本、R1/M3 和原十项要求 + 仍需分别验证;保留历史失败,完成前仍需完整原目标回归。 diff --git a/tests/test_core_distribution.py b/tests/test_core_distribution.py index fac7542fd6..9938c4f9e4 100644 --- a/tests/test_core_distribution.py +++ b/tests/test_core_distribution.py @@ -67,12 +67,36 @@ def test_core_staging_excludes_workspace_and_reuses_kernel_bytes(tmp_path): @pytest.fixture -def core_python(): +def core_python(tmp_path): value = os.environ.get("LOOPX_CORE_TEST_PYTHON") if not value: pytest.skip("set LOOPX_CORE_TEST_PYTHON to a clean installed core environment") executable = Path(value).absolute() assert executable.is_file(), executable + # Every selected qualification caller must use the installed Core owner, + # including when the separate identity test was not selected. + script = '''import importlib.metadata as m,json,loopx +from pathlib import Path +installed=m.distribution('loopx-core') +assert installed.version==loopx.__version__ +try:m.distribution('loopx') +except m.PackageNotFoundError:pass +else:raise AssertionError('the ordinary distribution must not be installed') +direct_url=json.loads(installed.read_text('direct_url.json') or '{}') +assert not direct_url.get('dir_info',{}).get('editable',False),'editable Core is not installed qualification' +recorded=next((entry for entry in installed.files or () if entry.as_posix()=='loopx/__init__.py'),None) +assert recorded is not None,'the installed Core RECORD must own loopx/__init__.py' +package=Path(loopx.__file__).resolve() +record_path=Path(installed.locate_file(recorded)).resolve() +assert record_path==package,('imported namespace is not owned by installed Core',str(package),str(record_path)) +assert package.is_relative_to(Path(installed.locate_file('')).resolve()),'Core namespace resolves outside its installed location' +''' + probe = subprocess.run([str(executable), "-I", "-c", script], cwd=tmp_path, + env=_environment(str(executable)), capture_output=True, text=True, timeout=30) + assert probe.returncode == 0, ( + "LOOPX_CORE_TEST_PYTHON must select a clean installed loopx-core distribution", + probe.stdout, probe.stderr, + ) return str(executable) @@ -104,12 +128,8 @@ def _run(python, arguments, cwd, *, environment=None, expected=0): def test_installed_core_identity_help_and_unavailable_workspace(core_python, tmp_path): - script = '''import importlib.metadata as m,importlib.util as u,json,loopx + script = '''import importlib.util as u,json,loopx from pathlib import Path -assert m.version('loopx-core')==loopx.__version__ -try:m.distribution('loopx') -except m.PackageNotFoundError:pass -else:raise AssertionError('the ordinary distribution must not be installed') for name in ('loopx.cli','loopx.chat','loopx.web','loopx.canary'):assert u.find_spec(name) is None,name from loopx.release_manifest import _distribution_runtime_fingerprint assert _distribution_runtime_fingerprint() is not None