lmclean reference
CLI options, --serve endpoints, File methods, SAM interfaces, standard REST/CLI interfaces, and exit codes for lmclean.
CLI flags and server options
| Flag | Mode | Description |
|---|---|---|
| --version | Introspection | Print the lmclean build version. |
| --lmcode-schema [--json] | Introspection | Print the embedded lmclean_v1 schema summary or exact JSON bytes. |
| --lmcode-signatures | Introspection | Print canonical registry signatures. |
| --lmcode FILE.dslb | CLI / Server | Load compiled bytecode program (repeatable in --serve mode for program slots). |
| --exec | CLI | Perform actual deletion or trash moves (default is dry-run). |
| --trash DIR | CLI | With --exec, move matched entries into DIR and append to DIR/manifest.jsonl. |
| --restore | CLI | With --trash DIR, replay manifest.jsonl in reverse order to restore entries. |
| --hidden | CLI | Include dot-prefixed hidden files and directories in the walk. |
| --max-depth N | CLI | Limit recursion depth relative to each root (direct children are depth 0). |
| --param NAME=VALUE | CLI | Pass a parameter read by param_int or param_str (repeatable). |
| --serve | Server | Start the single-connection HTTP/1.1 JSON REST server. |
| --listen ADDR:PORT | Server | Bind address (default 127.0.0.1:0; non-loopback requires --token). |
| --port-file FILE | Server | Write the bound ADDR:PORT to FILE once listening. |
| --presets FILE / --preset NAME | Server | Load named scan setting bundles from FILE and select the initial preset. |
| --idle-timeout SECS | Server | Exit 0 after SECS without requests (default 300; 0 disables timeout). |
| --allow-exec | Server | Permit non-dry POST /clean and POST /restore requests. |
| --token TOKEN | Server | Require Authorization: Bearer TOKEN on every request. |
File type methods and host functions (lmclean_v1)
| Signature | Return type | Description |
|---|---|---|
| File.path() / File.name() / File.extension() | string | Candidate path, base filename, and dotless extension (empty if none). |
| File.size() / File.rsize() | int | Own symlink_metadata byte length and deterministic recursive non-directory byte size. |
| File.depth() | int | Depth relative to the search root (direct children = 0). |
| File.is_file() / File.is_dir() / File.is_symlink() | bool | Entry type predicates derived from symlink_metadata (symlinks are never followed). |
| File.modified() / File.accessed() | int | Entry mtime and atime in Unix epoch seconds. |
| File.rmodified() / File.raccessed() | int | Maximum mtime or atime across non-.git files in a directory subtree. |
| File.is_git_repo() / File.is_git_clean() / File.is_git_pushed() | bool | Check whether a directory is a Git repo, has a clean tree/index/stash, and has all branches pushed. |
| File.git_status() | string | One of not-git, dirty, no-remote, unpushed, or clean-pushed. |
| fn now() | int | Current wall-clock time in Unix epoch seconds. |
| fn param_int(name: string, default_val: int) | int | Read an integer --param or server setting value with fallback. |
| fn param_str(name: string, default_val: string) | string | Read a string --param or server setting value with fallback. |
| fn print(msg: string) | void | Write a diagnostic line to stderr. |
SAM interfaces and standard REST/CLI interfaces
| Interface | Annotation | Signature | Role |
|---|---|---|---|
| Ignore | @ignore | (f: File) -> bool | Pre-filter candidate; returning true skips the entry and prunes directory descent. |
| Filter | @select | (f: File) -> bool | Deletion predicate; multiple @select entries are OR-ed. |
| Report | @report | (f: File) -> void | Audit callback invoked once for each matched File. |
| RestGet..RestOptions, RestHandler | @"/path/:param" | (exchange: RestExchange) -> void | Standard lmcode_std_v3 HTTP route handler interfaces. |
| CliCommand, CliOption | @"cmd" / @"--opt" | (exchange: RestExchange) -> void | Standard lmcode_std_v3 stateless CLI handler interfaces for rest_cli. |
Server REST endpoints and exit codes
| Endpoint or code | Kind | Meaning |
|---|---|---|
| GET /health, GET /presets, GET /settings, PUT /settings | REST endpoint | Inspect liveness, presets, and active scan settings or update settings (drops scan cache). |
| POST /scan[?query], GET /results[?query] | REST endpoint | Walk and cache matches, or slice cached matches through view filters without re-walking. |
| POST /clean, POST /restore, POST /shutdown | REST endpoint | Delete or trash filtered matches (with dry_run or expect_matched/expect_bytes), restore trash, or stop the server. |
| Exit 0 | Exit code | Success (dry-run, exec, restore, or server shutdown). |
| Exit 2 | Exit code | CLI usage or flag error. |
| Exit 3 | Exit code | Bytecode load, schema verification, or rule runtime error. |
| Exit 4 | Exit code | Application failure (unreadable bytecode/presets file or failed deletions). |