jan/feature/20261107-lib-execapp-rename-pkg-filter-to-path-filter into master The exec context's default filter selects paths, not just packages, so the pkg spelling of the option and environment variable that set it no longer fit. Rename both and some variables accordingly: - ExecApp: --pkg-filter becomes --path-filter, and the fallback environment variable JW_DEFAULT_PKG_FILTER becomes JW_DEFAULT_PATH_FILTER - Distro: the default_pkg_filter constructor argument and property become default_path_filter, matching FileContext, ExecContext, and CopyContext; App and KvFile pass the renamed argument - Adapt the help test's expected output and the unit tests Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Drop the re-read of JW_DEFAULT_PKG_FILTER, and derive the filter from the ctor and URI like all other FileContext instances would. Use that to filter the backend for the packages provinding secrets. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
PackageFilterString and Pkg are duplicates. The PackageFilter and FileContextFilter base classes live in lib/PackageFilter.py, imported by Pkg, Distro, and the tests. Move the two base classes into lib/pf/Pkg.py (where Pkg already lives), drop PackageFilterString, delete lib/PackageFilter.py, and repoint Distro and the tests to the new location. Move the test suite with the module to test/.../pf/Pkg/. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Create an app's exec context with the user-specified path filter, and drop the ExecApp.path_filter property, now a duplicate of exec_context.path_filter. Use the latter in the two call sites. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
The select command names PackageFilterString directly, but the filter is a spec string and the class is resolved dynamically by the loader. Build the filter through PathFilter.create() so the concrete class no longer appears at the call site. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
The default package filter is typed PackageFilter, but it is handed over from file contexts that carry a PathFilter. Widen the default_pkg_filter parameter. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Add the Pkg path filter to the lib.pf module, the loader-visible home of the package filter spec. A spec of the form pkg:criterion=~regex instantiates Pkg through PathFilter.create(). The parsing duplicates the one of PackageFilterString for now; a later commit consolidates the two. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
This commit moves package-based filtering from the package level to the path level, using the new path filter framework. Derive PackageFilter from a new FileContextFilter base, which binds a PathFilter to the FileContext it guards, and implements _access(). The filter's space is the file list of the packages it selects, taken from the backing distro's pkg_files(). An address is allowed only if it names one of those files. The backing distro is taken from the file context, if the context carries one, and is otherwise autodetected from the host the context executes on, so the filter also works on a bare exec context. A context that is not an exec context and carries no distro rejects path queries with an error. The filter string now follows the loader syntax, pkg:url=~ regex, and a bare url=~regex like the old url=~jw.dev form is rejected; update JW_DEFAULT_PKG_FILTER values accordingly. PackageFilter's match() is renamed match_pkg(), to make clear that it matches packages, and Distro._select() calls the new name. ExecApp.path_filter builds the filter through PathFilter.create() and binds it to the exec context. CmdSelect passes its argument to the new constructor, CmdCopy hands the app's filter to the copy, and the App distro picks it up as the default package filter. Extend the unit test to cover the space membership and the distro lookup. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Hand the new default_path_filter parameter to the CopyContext copy() opens, and to the recursive calls it makes for a list of URIs, so an app can limit the addresses a copy touches the same way it limits its own contexts. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
CopyContext creates its src and dst contexts from URIs when they are not given as instances. Pass an optional default_path_filter into that creation, so a copy made under a filter limits the addresses it reads and writes. A context given as an instance keeps the filter it already carries. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Allow to attach a default path filter to a FileContext, given in the constructor as default_path_filter, or in the URI query as "path-filter". Passing False as default_path_filter will make the FileContext ignore any path-filter in the query. The filter is created lazily on first use through PathFilter.create(), so a string spec is loaded from the lib.pf module like any other filter. Every path based action evaluates the filter before it is carried out. An IGNORE verdict is logged and the action is skipped: reads and stats raise FileNotFoundError, writes, unlinks, erases, renames, and mkdirs are no-ops, and readdir() drops the filtered entries. An ABORT verdict raises PermissionError. Every path-driven method also takes a flag parameter, "filtered", defaulting to True, so a caller that must work regardless of the context's filter can opt out of the check. Add a unit test that exercises the verdicts, the filtered bypass, and the distribution probe on a Local context. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Add the abstract PathFilter class, designed to be attached to a FileContext in later commits. This is the first commit of a series that generalizes the JW_DEFAULT_PKG_FILTER / --pkg-filter framework into loadable path filters that can be attached to any FileContext. A filter answers an access check, _access(), with a bool. run() turns the answer into a verdict: ALLOW when the check passes, otherwise ABORT or IGNORE according to the filter's deny action, LOG or ABORT. The verdict is handled by the filter's handle, a pair of per-verdict gates: with the ABORT gate set, an ABORT verdict raises PermissionError; with the LOG gate set, an IGNORE verdict is logged and returned. A verdict whose gate is not set passes through unhandled. Also add the lib.pf module that hosts the concrete filters. A filter spec of the form foo:something is loaded by PathFilter.create() as the Foo class from the jw.pkg.lib.pf.Foo module. A spec without the name prefix, or a name that no module provides, is rejected with an error that names the expected class and module. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0