clifff is a Common Lisp binding for the C interface of
fff. It provides an in-process indexed search engine and an optional
supervised helper process for applications that need native crashes isolated
from their main Lisp image.
The current binding covers fuzzy file search, glob search, literal, regular expression and fuzzy content search, and multi-pattern content search.
(asdf:load-system :clifff)
(defparameter *engine*
(clifff:make-engine
:library-path #P"/path/to/libfff_c.so"
:base-path #P"/path/to/workspace/"
:cache-directory #P"/path/to/private-cache/"))The caller supplies the compiled fff C library, version 0.11.0 or newer.
clifff does not install a binary, modify PATH, or select a particular fff
revision. Content searches enforce their time budget even when nothing matches,
and the page’s next file offset resumes at the first unsearched file. A file
with more matches than the per-file limit is listed in :truncated-paths, and
the rendered page names it.
Searches return readable property lists. Presentation helpers are provided for compact terminal or model output.
(clifff:render-file-result
(clifff:engine-search-files *engine* "provider" :page-size 20))Structured content searches separate query text from path constraints:
engine-search-structured-content accepts a query and :constraints;
engine-search-structured-multi-content accepts literal patterns and the same
constraints. Both return a result and an optional missing-path note as two
values. Their worker operations are :structured-content and
:structured-multi-content; worker results include the note in rendered text.
Multiple literal directories and files select alternatives, while exclusions
continue to apply. A missing file is reported or, if no location remains,
signals clifff-error.
Always close an engine when it is no longer needed:
(clifff:engine-close *engine*)A host that builds fff’s C library from a pinned commit records the commit with
FFF-LIBRARY-WRITE-MANIFEST beside the library. FFF-LIBRARY-LOCATE then
returns the library in an install directory only when its manifest records the
expected commit, signaling CLIFFF-ERROR otherwise; an :override library,
such as one from a package manager, is trusted as given.
FFF-LIBRARY-FILE-NAME is the platform’s library file name.
Bootstrap scripts can load source/artifact.lisp with only ASDF/UIOP available.
The file contains the shared platform filename, manifest, current-artifact and
atomic publication functions, without loading CFFI or a native library.
fff-library-current-p accepts :required-artifacts for additional outputs,
such as a static archive. Publish each output with fff-library-publish and
write the commit manifest after all required outputs are available.
Queries, globs and constraints cannot contain NUL characters. Invalid input
signals clifff-error with operation :arguments before native initialization.
validate-literal-patterns accepts a nonempty proper list or vector of nonempty
single-line strings and returns a fresh list. It rejects NUL and line endings.
Foreign strings use UTF-8.
make-worker accepts a command that loads clifff and calls worker-main.
The parent restarts a dead helper once and resets its private fff databases
before retrying. This process boundary protects the parent from accidental
native failures. It is not a security sandbox.
The request supplies its workspace, cache, fff library and diagnostic log
paths. A cache or workspace switch can reuse the helper. Before opening the
new native index, the helper acknowledges its configuration to the parent.
After transport failure, reset only that acknowledged cache and retain its
lock.mdb files. Detect an already dead helper before changing the log path.
A live log switch or native-library switch requires a replacement process.
Query errors do not count as transport failure.
worker-file-count asks the helper how many indexed files match a glob, so a
host can check that a path filter names existing files before searching under
it.
./script/bootstrap
./script/check
./script/check --fix./script/check runs the tests, then checks the source with
cheque as cheque.sexp
configures it. --fix skips the tests and repairs what cheque can repair.
cheque and its tools are development dependencies: checks/qlfile lists them,
and the check installs them on first use into ~/.cache/cheque/tools/.
The tests also run on their own:
(asdf:test-system :clifff)Set CLIFFF_LIBRARY to exercise the native integration tests.
Part of the Lambda Symbolics library shelf.