jan/feature/20261107-lib-ec-secret-store-kvfile-refactor-and-construct-from-a-uri into master A directory node of the store, the root included, stats as a directory, but a get on it falls through to the key lookup below its parent and fails with a FileNotFoundError naming a path the caller never asked for: get() on the root fails with an empty name, get() on a branch with its parent's compound path. Raise IsADirectoryError from _get() when the path is a directory on the host, after the compound and the blob lookups, so get() and stat() agree: a directory stats as FT_DIR and refuses a get. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0 Signed-off-by: Jan Lindemann <jan@janware.com>
KvFile.__init__() accepts a host FileContext plus an optional Distro, and the two may live on different hosts. In effect, files are read from one host based on another host's package set, which may have its use cases but is generally undesirable. The context parameter also breaks the uniformity of the store constructors: Sops, TarGpg, and Vault are constructed from a URI alone, and FileContext.create() needs a special case that builds the kvfile store's inner context before handing it to the constructor. This commit has KvFile constructed from a URI alone like the other stores. The URI's authority names the host, no authority means "local", and the constructor builds the inner context through FileContext.create() with chroot off, forwarding the store's constructor parameters to it. The inner context is always an exec context, which the distro derivation needs: it is lazy, Distro.instantiate() runs on the first file listing, with the JW_DEFAULT_PKG_FILTER environment variable as the default package filter, as before. Adapt all call sites: - FileContext.create(): the kvfile case returns KvFile(uri) directly. - FilesContext: the distro parameter goes; the store URI is derived from the exec context's scheme, authority, and path, so a local context with a hostname in its URI stays local. - DistroContext.install(): the kvfile source wrap goes; the compounds read directly through the source context with parse_kv(). - The store tests monkey-patch Distro.instantiate() for the stores that list something Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0 Signed-off-by: Jan Lindemann <jan@janware.com>
KvFile contains symbol names "addr" or "entry" which look better defined than they are. I prefer sticking to well-defined names like "path". "path" in itself is ambiguous and makes it necessary to understand its context, but so be it: At least it's used uniformly throughout the codebase and makes it even more obvious that the function it's used in needs to bear a meaningful name. Which is what this commit does, along with renaming some member variables to more self-explanatory variants. In detail, __addr() composes a host path from the URI path and the store's relpath, __resolve() strips the store's suffixes, __entry_kv() and __is_entry() operate on a config path that has a .jw-secret file, __subtree holds the path component of the URI, and __raw holds the context under the FcCache. The local variables config, entry, real, and blob do not name the things they hold either. - The __addr() method becomes __host_path(), its parameter is named relpath. - The __resolve() method becomes __strip_suffix(). - The __entry_kv() and __is_entry() methods become __compound_kv() and __is_compound(), their parameters are named config_path. - The __subtree and __raw members become __root and __inner. - The locals config, entry, real, and blob become config_path, compound, host_path, and secret_path. Update the error messages and the comments that name the old symbols to use the new ones. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0 Signed-off-by: Jan Lindemann <jan@janware.com>
KvFile works but is up for a major refactoring: It features an unnecessary amount of special cases, and its private method names are not self-explanatory enough. First thing to remove are the code comments, because they would account for much churn and would be obsolete afterwards anyway. This commit does it now in the expectation that the move from package- to path-based filters will also touch KvFile. Signed-off-by: Jan Lindemann <jan@janware.com>