lmclean reference

CLI options, --serve endpoints, File methods, SAM interfaces, standard REST/CLI interfaces, and exit codes for lmclean.

CLI flags and server options

FlagModeDescription
--versionIntrospectionPrint the lmclean build version.
--lmcode-schema [--json]IntrospectionPrint the embedded lmclean_v1 schema summary or exact JSON bytes.
--lmcode-signaturesIntrospectionPrint canonical registry signatures.
--lmcode FILE.dslbCLI / ServerLoad compiled bytecode program (repeatable in --serve mode for program slots).
--execCLIPerform actual deletion or trash moves (default is dry-run).
--trash DIRCLIWith --exec, move matched entries into DIR and append to DIR/manifest.jsonl.
--restoreCLIWith --trash DIR, replay manifest.jsonl in reverse order to restore entries.
--hiddenCLIInclude dot-prefixed hidden files and directories in the walk.
--max-depth NCLILimit recursion depth relative to each root (direct children are depth 0).
--param NAME=VALUECLIPass a parameter read by param_int or param_str (repeatable).
--serveServerStart the single-connection HTTP/1.1 JSON REST server.
--listen ADDR:PORTServerBind address (default 127.0.0.1:0; non-loopback requires --token).
--port-file FILEServerWrite the bound ADDR:PORT to FILE once listening.
--presets FILE / --preset NAMEServerLoad named scan setting bundles from FILE and select the initial preset.
--idle-timeout SECSServerExit 0 after SECS without requests (default 300; 0 disables timeout).
--allow-execServerPermit non-dry POST /clean and POST /restore requests.
--token TOKENServerRequire Authorization: Bearer TOKEN on every request.

File type methods and host functions (lmclean_v1)

SignatureReturn typeDescription
File.path() / File.name() / File.extension()stringCandidate path, base filename, and dotless extension (empty if none).
File.size() / File.rsize()intOwn symlink_metadata byte length and deterministic recursive non-directory byte size.
File.depth()intDepth relative to the search root (direct children = 0).
File.is_file() / File.is_dir() / File.is_symlink()boolEntry type predicates derived from symlink_metadata (symlinks are never followed).
File.modified() / File.accessed()intEntry mtime and atime in Unix epoch seconds.
File.rmodified() / File.raccessed()intMaximum mtime or atime across non-.git files in a directory subtree.
File.is_git_repo() / File.is_git_clean() / File.is_git_pushed()boolCheck whether a directory is a Git repo, has a clean tree/index/stash, and has all branches pushed.
File.git_status()stringOne of not-git, dirty, no-remote, unpushed, or clean-pushed.
fn now()intCurrent wall-clock time in Unix epoch seconds.
fn param_int(name: string, default_val: int)intRead an integer --param or server setting value with fallback.
fn param_str(name: string, default_val: string)stringRead a string --param or server setting value with fallback.
fn print(msg: string)voidWrite a diagnostic line to stderr.

SAM interfaces and standard REST/CLI interfaces

InterfaceAnnotationSignatureRole
Ignore@ignore(f: File) -> boolPre-filter candidate; returning true skips the entry and prunes directory descent.
Filter@select(f: File) -> boolDeletion predicate; multiple @select entries are OR-ed.
Report@report(f: File) -> voidAudit callback invoked once for each matched File.
RestGet..RestOptions, RestHandler@"/path/:param"(exchange: RestExchange) -> voidStandard lmcode_std_v3 HTTP route handler interfaces.
CliCommand, CliOption@"cmd" / @"--opt"(exchange: RestExchange) -> voidStandard lmcode_std_v3 stateless CLI handler interfaces for rest_cli.

Server REST endpoints and exit codes

Endpoint or codeKindMeaning
GET /health, GET /presets, GET /settings, PUT /settingsREST endpointInspect liveness, presets, and active scan settings or update settings (drops scan cache).
POST /scan[?query], GET /results[?query]REST endpointWalk and cache matches, or slice cached matches through view filters without re-walking.
POST /clean, POST /restore, POST /shutdownREST endpointDelete or trash filtered matches (with dry_run or expect_matched/expect_bytes), restore trash, or stop the server.
Exit 0Exit codeSuccess (dry-run, exec, restore, or server shutdown).
Exit 2Exit codeCLI usage or flag error.
Exit 3Exit codeBytecode load, schema verification, or rule runtime error.
Exit 4Exit codeApplication failure (unreadable bytecode/presets file or failed deletions).