Architecture
lxask is one Rust program and five files: the model, two small LoRA adapters (restriction and precision), a small encoder and a SQLite index of documentation. Everything runs on your machine, on the CPU. Python is used only to build those files and to measure the result, and it calls the same Rust core the program uses, so what is measured is what ships.
For the reasoning behind each step in prose, see How it works; for numbers, Accuracy and limits.
#Answering a request
What happens between lxask "..." and the printed command
(rust/crates/lxask/src/main.rs, rust/crates/lxask-core/src/answer.rs):
Two shortcuts answer without the model at all: questions about lxask itself, and requests too vague for one command ("add a proxy"). Everything else goes through the model, one call per task plus one for the split, and up to two more per task when the checks object.
#Components
| crate | what it is |
|---|---|
lxask |
the program: options, the server, feedback, settings |
lxask-core |
every rule, with no I/O: the model and the search are passed in, so it is tested without them |
lxask-llm |
the model, the adapter and the encoder, through llama.cpp |
lxask-py |
the core as the Python module lxask._core, used by src/lxask and scripts/ |
#The server
lxask --serve keeps everything loaded, so later questions skip the few seconds of
loading. With serve = auto (the installer's default) a question that finds no
server starts one in the background, detached from the terminal, and waits for it;
a lock next to the socket makes sure only one is started (server::start_and_wait).
#Feedback
#How the model and the index are made
Offline, on a machine with a GPU (a free Colab T4 or a laptop RTX card):
The evaluation sets are kept out of training throughout; the execution tests run each command as an unprivileged user in a container with no network (Development).
#Files on disk
Everything lives in ~/.local/share/lxask: the model, the adapters, the encoder, the
index, last.json and your feedback.jsonl; the program is ~/.local/bin/lxask.
The full list and every setting: Configuration.
#Design choices
- Check, don't trust. A 1.5B model gets details wrong, so every command is
checked against the documentation and the request, retried when a check objects,
and marked
unverified:when it still fails. It never runs a command. - Small, local, offline. One program and about 1.2 GB of files, 1.4 GB of memory while answering, no network after installing.
- Route instead of retrain. A model fine-tuned on one kind of request drifts
on the others, so the fixes ship as two small adapters and each request goes to
the one it is for: restrictions to
restrict.gguf, everything else toprecision.gguf. - Ask back instead of guessing when a request means different commands in different contexts.
- Fixed text for questions about lxask, rather than teaching the model facts about itself.
- One core for the program and the measurements. Training and evaluation call
the same Rust code through
lxask._core.
#SecAsk: the cybersecurity assistant
lxask sec is a second assistant in the same program, kept deliberately separate: its own
documentation base, its own index, its own adapter, and questions that never touch the
Linux-command data of lxask itself.
- The catalogue (
secask/tools/*.json) is curated, embedded into the binary at compile time, and validated by thelxask-seccrate's tests. Flags and descriptions come from the tools' own documentation only; there is no generation step that could invent options. - The index (
secask.sqlitenext todocs.sqlite) is built on first use from that catalogue, in exactly the schema of the docs index:docs/pagesFTS5 tables, the embeddings table, the validation catalogue tables. Because the schemas match, retrieval, validation, constraint checking, explanation and rendering are the same lxask-core code, pointed at the other file � the two indexes never mix. - The flow is lxask's flow (
rust/crates/lxask/src/sec.rsmirrorsmain.rs's): split, retrieve, answer with the security adapter (security.gguf) when it is installed and the base model otherwise, repair, validate, retry, explain, warn. The security adapter is never routed to:lxask secalways uses it, plainlxasknever does. - Environment awareness:
/etc/os-releaseand the PATH are read at answer time. Retrieved documentation of tools the machine lacks is marked not-installed with the install command for the distribution, so generation can prefer what is present, and the printed answer says when a command needs a tool that is missing. - Safety follows lxask: nothing is executed. Tools in intrusive categories (scanning, password attacks, exploitation, wireless) add an authorization note to the answer.
- The server does not answer sec questions;
lxask secanswers in-process.--badfeedback is shared with lxask through the samelast.jsonmechanism.
lxask-sec (the crate) is pure data and detection � catalogue parsing, the index builder,
distribution/tool detection � with no model dependency, so it is testable on its own.