WIP: rustic #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "rustic"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change introduces a Valkey/Redis-backed list manager script (`vk-list.rs`) and ensures the bootstrapped test runner (`tests.sh`) is executable. **Capabilities** - New `vk-list` CLI (via `rust-script`) that manages named lists with: - Commands: `add`, `get`, `edit`, `remove`, `clear`, `list` (default), `export`, `import`, `config`, `help`. - 1-based stable IDs, position-safe deletion (marker + `LREM`), and contextual error messages. - Robust data handling: - Line-delimited and null-delimited import/export. - Exact content preservation in null-delimited mode (including newlines). - Size limits: max item size and max list length to reduce DoS risk. - Bootstrap improvement: - `bootstrap-dev.sh` now runs `chmod +x tests.sh`, making tests directly runnable. **Operations / Workflows** - Typical flows: - `todo add "task"` → validated add → Redis `LPUSH` → list view. - `todo remove 3` → mark index with unique token → `LREM` that token → list view. - `todo export [-|FILE]` → `LRANGE` → stream to stdout/file, SIGPIPE-safe for pipelines like `| head`. - `todo import [-|FILE]` → read stdin/file (line or `\0` delimited) → `add` per item → list view. - Dev workflow: - `bootstrap-dev.sh` produces `tests.sh` and makes it executable for `./tests.sh`. **Systems & Integration** - Components: - `vk-list.rs` with `Config`, `VkList`, `Valkey` abstractions. - `valkey-cli --raw` as the underlying storage interface (no shell, arguments passed directly). - Interfaces: - Env vars: - `VK_APPNAME` (CLI name), `VK_PREFIX` (key prefix), `VK_LIST` (validated list name), `VK_NULL_DELIM` (delimiter mode). - Redis key format: `{prefix}:{list}`, with strict validation on `list`. **Data & Information** - Key semantics: - ID translation: user ID `n` → Redis index `n-1`. - List name constraints: non-empty, ≤ 100 chars, no `:`, only `[A-Za-z0-9_-]`. - Import: skips empty/whitespace-only lines in line mode; preserves all bytes except `\0` in null mode. **Project Impact & Risks** - Moves toward self-contained, scriptable Valkey-based tooling and smoother bootstrap (tests immediately runnable). - Risks / follow-ups: - `valkey-cli` availability and connection configuration are assumed, not managed. - `LRANGE`-based export still loads full lists in memory for very large lists. - Potential subtlety from trimming stdout in `Valkey::exec` (whitespace-sensitive items should be tested). ---This introduces a new `vlists` Cargo package with two Rust-script binaries: - `vlist`: a Valkey-backed list manager for a single list. - `vlists`: a multi-list manager for all lists under a prefix. **Capabilities** - `vlist` supports: - `add`, `get`, `edit`, `remove`, `clear`, `export`, `import`, `config`, `help`, and default `list`. - Line-delimited and null-delimited exports/imports with streaming I/O. - Strict list-name validation and size limits (`MAX_ITEM_SIZE`, `MAX_LIST_LENGTH`). - Safe, position-based deletion using a unique marker (`LSET` + `LREM`). - `vlists` supports: - Listing all lists under `VK_PREFIX:*` with item counts. - Renaming, deleting, copying lists, and `info` (metadata + usage hints). **Operations / Workflows** - Typical `vlist` flows: - `vlist` → show tasks. - `vlist add "task"` → append and re-list. - `vlist edit ID "new text"` / `vlist remove ID` → mutate and re-list. - `vlist export [FILE|-]` / `import [FILE|-]` → pipeline-friendly data transfer; null-delim preserves newlines. - Typical `vlists` flows: - `vlists` / `vlists list` → overview of all lists. - `vlists rename OLD NEW`, `vlists delete LIST`, `vlists copy SRC DST`, `vlists info LIST`. **Systems & Integration** - New Cargo package `vlists` (edition 2024) with `[[bin]]` targets `vlist` and `vlists`. - Both binaries use `valkey-cli --raw` for all data operations (no shell invocation; arguments passed via `Command::args`). - Configuration via environment: - `VK_LIST`, `VK_PREFIX`, `VK_APPNAME`, `VK_NULL_DELIM` (for `vlist`). - `VK_PREFIX` (for `vlists`). **Data & Information** - Redis key format: `{VK_PREFIX}:{VK_LIST}` (e.g. `vk-list:todo`), with strict name rules for `VK_LIST`. - `vlist` exports: - Line mode: one task per line; whitespace-only lines skipped on import. - Null mode: tasks delimited by `\0`, preserving all other content; SIGPIPE/BrokenPipe on export treated as normal termination. **Project Impact & Risks** - Establishes a layered, self-documenting architecture for Valkey-backed lists and provides a coherent multi-list story. - Enables future features like tagging, archiving, and CI integration around stable CLIs. - Risks/notes: - `vlists` uses `KEYS`, which may be expensive on large keyspaces. - `vlists` does not yet reuse the strict list-name validation logic from `vlist`. - Large lists are always fully retrieved for listing; pagination is a possible follow-up. ---**Summary** Adds namespace globbing to `vlist` (`*` and `**` patterns), defines clear CLI behavior for globbed list names, documents usage patterns, and introduces a fix for null-delimited import. Manpages and workspace docs are updated; a new test script validates core glob scenarios. **Capabilities** - `vlist` now treats `*` and `**` in list names as glob patterns: - `vlist ctx:*` lists matching namespaces (single level). - `vlist ctx:**` lists all descendant namespaces (recursive). - `export` with a glob outputs matching namespace names (one per line), suitable for piping: - `vlist ctx:** export | parallel vlist {} export`. - Non-`export` commands (`add/remove/edit/clear/...`) with globbed names now error, preventing accidental multi-list mutation. - Null-delimited import is fixed to use a persistent `BufReader`, avoiding record corruption and `nul byte found in provided data` failures. **Operations / Workflows** - New namespace workflows: - Discover and iterate over structured list hierarchies: `vlist ctx:** export | cut -f1-2 -d: | uniq`. - Build trees with `treeify-rs` via `vlist 'ctx:**' export | parallel vlist {} export`. - Null-delim workflows remain: - `VK_NULL_DELIM=1 vlist LIST import -` for robust filename/content ingestion. **Systems & Integration** - `src/vlist.rs`: - New helpers: `contains_glob`, `expand_glob`, `match_single_level`, `match_recursive`, `list_namespaces`, `export_namespaces`. - `main()` branches behavior on glob presence and enforces glob/mutation restrictions. - Tests: - `tests/test_glob.sh` checks single-level, recursive, and export-piping behavior. - Manpages: - `man/vlist.1` gains a **NAMESPACE PATTERNS** section; dates updated for both `vlist.1` and `vlists.1`. **Data & Information** - Glob semantics (documented in `docs/namespace_glob_design.md`): - `*`: matches exactly one colon-delimited segment. - `**`: matches deeper descendants; current implementation excludes the bare prefix itself. - Extensive usage patterns are documented in `docs/usage-guide.md` and mirrored in `workspace/docs`. **Project Impact** - Moves `vlist` toward a proper namespace-aware shell primitive suitable for hierarchical list operations and integration with `treeify-rs`. - Improves documentation and test coverage for critical behaviors (globbing, null-delim IO), paying down previous “AI-confused” README/notes. **Issues / Risks** - `Valkey::keys("{}:*")` can be expensive for large keyspaces; future work should consider `SCAN`-like strategies. - Design notes call for listing parent namespaces when only descendants exist (e.g. `ctx:terminal-ai:*` when only `ctx:terminal-ai:foo:bar` exists); this is not yet implemented and tracked as a high-priority follow-up. ---View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.