Repository navigation
Conversation
…submodules
In TransactionLog._order_changes(), from-imports against an allowed
package that is not yet in sys.modules previously had an empty namespace
dict and skipped adding f"{source}.{member}" to the checked import set,
allowing disallowed submodules to bypass allowed_import and execute at
commit time.
Resolve unloaded package search locations statically via
_package_search_locations(), _static_find_spec(), and
_find_spec_in_paths() without importing any module (covering regular
packages, multi-level packages, PEP 420 namespace packages, zipimport,
and custom meta-path finders), and add submodule candidates to names so
allowed_import rejects disallowed submodules at preflight while
preserving non-submodule attribute imports and stdlib imports.
Add conformance tests covering top-level and nested unloaded regular
packages, PEP 420 namespace packages, relative imports from unloaded
subpackages, and allowed non-submodule attributes.
Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: 李浩瑞 <haoruileee@gmail.com>
jiangkuaixue123
left a comment
There was a problem hiding this comment.
静态复核 601ff8d1。这次改动在 Box 核心的导入预检,不是单个引擎的适配。PR 记录了多种加载器的本地验证,但提交中的新增回归主要覆盖普通文件包。建议把至少一个 namespace package 和一个 zip loader 的无害场景放进现有 conformance 测试,用可观测标记断言预检不会执行模块初始化,同时保留合法导入的正例。这样后续改预检或升级 Python 时,不必依赖本地探针才能发现跨加载器回退。目前仍是 Draft;未运行复现、设备或 CI,也不代 #1015 接受范围。
…ader tests Replace pkgutil.get_importer() and the process-wide PathFinder.invalidate_caches() call inside TransactionLog._order_changes() with a local _path_finder(entry, finder_cache) helper that invokes sys.path_hooks directly into a per-call cache. Preflight now leaves sys.path_importer_cache and global FileFinder caches untouched while still detecting newly written modules even when a cached FileFinder is stale. Expand test_unloaded_package_from_import_enforces_allowed_import_policy with an observable import-execution marker verifying zero module initialization runs during preflight, a zip loader positive and negative case, a positive PEP 420 namespace submodule case, an unloaded stdlib from-import case, and a sys.path_importer_cache invariance assertion. Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author) Signed-off-by: 李浩瑞 <haoruileee@gmail.com>
|
Antigravity (Gemini 4 Neon, xhigh), acting for @haoruilee. @jiangkuaixue123 Thanks for the review. In
Verified locally on Linux x86_64 under |
Resolve conflict in src/inferrsi/box/kernel/transaction.py against main by dropping removed _verify_contents, aligning _package_search_locations with syntax.exact_type(), and keeping all unloaded-package from-import policy checks and tests intact. Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author) Signed-off-by: 李浩瑞 <haoruileee@gmail.com>
Resolve EOF test conflict in tests/box/conformance/test_structural_transactions.py against main while keeping src/inferrsi/box/kernel/transaction.py auto-merged and unloaded-package from-import policy checks intact. Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author) Signed-off-by: 李浩瑞 <haoruileee@gmail.com>
|
inferRSI, acting for @amy-why-3459. I reviewed base The preflight change in I am not Approving this head. #1015 is still proposed: no accountable owner or implementer delegation is recorded, and this PR remains Draft until that decision is made. Please have a Box / Harness maintainer accept the scope on #1015 (including the documented limits about runtime |
Governing Issue and delivery slice
Refs #1015
src/inferrsi/box/kernel/transaction.py:_path_finder,_find_spec_in_paths,_static_find_spec,_package_search_locations, usingsyntax.exact_type(paths, list, tuple)) that invokesys.path_hooksinto a per-callfinder_cachedict without importing or executing any module, without callingPathFinder.invalidate_caches(), and without mutatingsys.path_importer_cacheor globalFileFindercaches. Handles regular packages, multi-level unloaded packages, PEP 420 namespace packages (including split roots and nested namespace subpackages),zipimport, customsys.meta_pathfinders, and already-loaded parent__path__entries (rejecting non-inspectable custom__path__objects), while still detecting newly written.pyfiles even when a global cachedFileFinderhas a stale_path_mtime.TransactionLog._order_changes()so whenloaded is None and source not in created and members and allowed(source), it resolveslocations = _package_search_locations(source, finder_cache)and addschild = f"{source}.{member}"tonameswhenever_static_find_spec(child, locations, finder_cache)[0]isTrue.allowed(item)then rejects disallowed submodules at preflight withBoxError("restart_required", ...)without loading eithersourceorchildintosys.modules, while non-submodule attribute imports (from allowed_pkg import PUBLIC) and unloaded stdlib submodule imports (from wsgiref import headers) continue to pass.tests/box/conformance/test_structural_transactions.py:test_unloaded_package_from_import_enforces_allowed_import_policycovering:__init__.pyandforbidden.py, assertingnot marker.exists()and zero modules added tosys.modulesacross every rejected loader (top-level and multi-level unloaded regular packages, nested and top-level PEP 420 namespace packages, zip loader, and relative imports from unloaded subpackages), and confirmingmarker.exists()on positive execution.from pkg import PUBLIC,from pkg.sub import SUB_PUBLIC), zip loader (from zip_pkg import ZIP_PUBLIC), PEP 420 namespace package (from ns_pkg import allowed_mod), and unloaded stdlib (from wsgiref import headers), all installing and uninstalling cleanly.sys.path_importer_cache == before_cacheafter all preflight rejections.allowed_importpolicies in repo adapters (vllm_omni,vllm_common), changes toswap.pyclosure tracking, or Issue closure.__path__mutation (for example, an unloadedpkgutil-style namespace package whose__init__.pyextends__path__at import time) or unloaded prefixes with no static spec (where_package_search_locations()returnsNone; already-loaded parents with non-inspectable custom__path__objects are rejected explicitly)._path_finder()invokessys.path_hooksdirectly into a per-call cache rather than reading or writingsys.path_importer_cache. This is read-only for the standardFileFinderandzipimporterhooks, whereas third-party customsys.path_hooksregistered by a host application will execute during preflight.Knowledge authorship declaration
No path protected by
docs/knowledge-model-policy.mdis changed. The declaration is filled for completeness against the current head.Changed artifacts and evidence
allowed_importat preflight forfrom <pkg> import <submodule>when<pkg>is unloaded, purely read-only without importing modules or mutating global import cachessrc/inferrsi/box/kernel/transaction.py:_path_finder,_find_spec_in_paths,_static_find_spec,_package_search_locations, and_order_changes()static submodule lookup oversys.path_hookswith a per-call cache954ad306):from allowed_pkg import forbiddenreturnedokand executedallowed_pkg.forbidden(run: 99); after (118886cd): rejected at preflight withrestart_required, observable init marker absent, zero modules loaded,sys.path_importer_cacheunchanged, and metaclass__eq__probe confirms 0__eq__calls; covered bytest_unloaded_package_from_import_enforces_allowed_import_policyon Py3.10 & Py3.11118886cdpending; known limits documented abovesrc/inferrsi/box/kernel/transaction.py: addschildonly when static spec lookup succeeds; loaded-package branch unchangedfrom pkg import PUBLIC,from pkg.sub import SUB_PUBLIC,from zip_pkg import ZIP_PUBLIC,from ns_pkg import allowed_mod,from wsgiref import headers, and fulltests/box/+test_architecture_anchors.py(340 passed, 0 failedon Py3.10 & Py3.11)118886cdpendingChecks and dependencies
118886cddfa57f270307a53ab2ed2f4e12cab25a(mergingorigin/main87bbfc77, underenv -u PYTHONPATH):ruff check src tests tools(Python 3.10.20 & 3.11.14): passed (All checks passed!).git diff origin/main..HEAD --check: passed.env -u PYTHONPATH pytest -n 4 tests/box/ tests/repository/test_architecture_anchors.py:340 passed, 0 failedon both Python 3.10.20 (8.08s) and Python 3.11.14 (7.83s).0a66baceandce28a2fepassed upstream CI (all non-skipped jobs +knowledge-model-policyPASS) plus targeted stale-cache, zero-mutation, and metaclass__eq__probes.tools/check_pr_references.py,tools/check_knowledge_model_policy.py, andgit merge-tree --write-tree origin/main HEAD(87bbfc77): passed.git 2.43.0 < 2.45), Windows/macOS advisoryhost-compatibility,installed-package,dashboard-browser, and upstream GitHub Actions CI for118886cd(triggered on push).origin/main87bbfc77(including fix(box): verify live object attributes at commit and compare container types by identity #1021, fix(box): track and migrate construction-time closures in ManagedModule #1023, feat(box): support proven local captures and active branch body edits #1060, and fix(box): pass the new nested-pair signatures at construction time #1082). Zero file overlap with open PRs; no public Box protocol orTransactionLogsignature changes.Remaining work and Issue closure
118886cd, and independent review.