\DocumentMetadata{%
  language          = {en-GB},%
  pdfversion        = {2.0},%
  tagging           = {on}%
}
\documentclass{article}
\usepackage{linguistix}
\linguistix{%
  languages         = {british,marathi}%
}
\usepackage{hologo}
\usepackage[colorlinks]{hyperref}
\hypersetup{%
  pdftitle          = {%
    tenkana(1): a spider that jumps from the checkpoints of
    your TeX document%
  },%
  pdfdisplaydoctitle%
}

\begin{document}
\title{%
  \texttt{tenkana}: a spider that jumps from the checkpoints
  of your \TeX\ document%
}
\author{%
  निरंजन\\%
  \normalsize
  (Vibe coded using Claude \textsc{llm})%
}
\date{Version 1.0.0\,--\,\today}
\maketitle

\section{Synopsis}

\begin{verbatim}
tenkana [tenkana options] TeX-command [TeX options] file
tenkana [tenkana options] -q file
tenkana [tenkana options] program arguments
\end{verbatim}

\section{Description}

\verb|tenkana| runs a \TeX\ command, such as:
\verb|lualatex thesis|, the way \verb|env(1)| and
\verb|time(1)| run theirs, but makes repeated builds faster.
While \TeX\ runs, \verb|tenkana| keeps frozen copies
(\emph{snapshots}) of the running engine: one just before
\verb|\begin{document}| and one before each \verb|\include|.
After an edit, \verb|tenkana| continues from the last
snapshot before the change, so the preamble, its packages
and fonts, and all unchanged chapters before the edit are
not processed again.

\begin{verbatim}
  tenkana lualatex thesis
  tenkana pdflatex -synctex=1 thesis
  tenkana pdflatex-dev '\nonstopmode\input paper.ltx'
  tenkana -q thesis
  tenkana latexmk -pdf thesis
\end{verbatim}

The \TeX\ command may be any command that runs pdf\TeX,
Lua\TeX\ (LuaHB\TeX, LuaJIT\TeX) or \hologo{XeTeX}:
\verb|pdflatex|, \verb|lualatex|, \verb|xelatex|,
\verb|pdflatex-dev| and so on. \verb|tenkana| finds the
engine from the program the command finally runs. \TeX\ runs
in the current folder. \TeX’s first line, what follows its
options, is usually the file name; if it is \TeX\ code,
\verb|tenkana| takes the file of the first \verb|\input| as
the main file, and without an \verb|\input| it runs the
command as it is, without snapshots. The file is looked for
as \TeX\ does: in the current folder, then on \TeX’s search
path (see \verb|kpsewhich(1)|). If \TeX\ would not find it
either, \verb|tenkana| runs the command as it is and
\TeX\ reports the problem.

The engine and the document are not modified, and no root
access is needed. \verb|tenkana| runs your command as you
typed it, and adds only \verb|-recorder| right after the
command name: it needs the list of files \TeX\ reads, which
\TeX\ writes to \emph{job}\verb|.fls|. \hologo{XeTeX} also
gets \verb|-no-pdf|, followed by one \verb|xdvipdfmx(1)| run
at the end, as \hologo{XeTeX} would run it
(\verb|xdvipdfmx -q -E|); with your own \verb|-no-pdf|,
\verb|tenkana| leaves the \verb|.xdv| file as it is. \TeX’s
questions (after an error, or from \verb|\typein|) appear on
your terminal and take your answers, and Ctrl-C reaches
\TeX, also when a build resumes from a snapshot. Snapshots
are made with \verb|fork(2)| by a small library that
\verb|tenkana| loads into the engine with \verb|LD_PRELOAD|.
They live in memory, as ordinary processes, and survive
between runs of \verb|tenkana| (see \emph{Memory}). The
preamble snapshot is also saved on disk, compressed, so it
survives a reboot (see \emph{Snapshots on disk}).

\TeX’s own terminal output is shown unchanged.
\verb|tenkana|’s messages follow it. Each is one line and
starts with \verb|tenkana:| prefix; error messages go to
standard error.

\section{References}

\LaTeX\ reads the previous run’s \verb|.aux| (and
\verb|.toc|, ...) at \verb|\begin{document}|, so after one
plain run a new or moved label shows as \verb|??| or with an
old number. \verb|tenkana| reruns from the preamble snapshot
until the \verb|.aux|, \verb|.toc| and similar files stop
changing (at most 4 passes), like \verb|latexmk(1)|, so
every build ends with cross-references, citations and the
table of contents up to date. The reruns are fast: the
preamble is not processed again.

\section{Other programs}

A command that does not run pdf\TeX, Lua\TeX\ or
\hologo{XeTeX} is another program, such as \verb|arara(1)|,
\verb|latexmk(1)|, \verb|l3build(1)| or \verb|make(1)|.
\verb|tenkana| runs it as it always runs, with another
library (built from \verb|preload/tenkanawatch.rs|) loaded
into it and everything it starts. Whenever one of them
starts a \TeX\ engine, that \TeX\ command runs through
\verb|tenkana| instead, as a single run (as with
\verb|--single|). So the program’s own rules decide how many
runs there are, and its checks of the \verb|.aux| and
\verb|.log| work as they always do; only the runs are
faster. Everything other than \TeX\ runs untouched, and a
\TeX\ command that \verb|tenkana| cannot handle (one with
\verb|-fmt|, as in l3build’s tests) runs as it is. At the
end \verb|tenkana| says how many \TeX\ runs there were and
how each went; \verb|-v| also shows each run’s details.
\verb|tenkana|’s exit status is the program’s.

\verb|tenkana| adds \verb|-recorder|, so these runs write a
\verb|.fls| file even if the program does not ask for one.
The memory statistics at the end of the \verb|.log| differ
slightly from a plain run’s, because of \verb|tenkana|’s
hooks. A program that starts \TeX\ by other means than the C
library’s exec functions and \verb|posix_spawn(3)| runs its
\TeX\ without \verb|tenkana|.

\section{Options}

\verb|tenkana|’s options come before the \TeX\ command; the
first word that is not one of them starts it, and \verb|--|
ends them explicitly.

\begin{description}
  \item[{\texttt{-q}, \texttt{-\/-quick}}]
    Only the file is given, and the default engine is used:

    \verb|tenkana -q thesis| is
    \verb|tenkana lualatex thesis| (or the command in
    \verb|TENKANA_ENGINE|).

  \item[{\texttt{-s}, \texttt{-\/-single}}]
    One \TeX\ run: no reruns for the references, as
    \TeX\ alone does. Each \TeX\ run of another program is
    one (see \emph{Other programs}).

  \item[{\texttt{-v}, \texttt{-\/-verbose}}]
    Also show \verb|tenkana|’s details: passes, changed
    files, snapshots and their memory.

  \item[{\texttt{-\/-silent}}]
    Show only \TeX’s output and \verb|tenkana|’s error
    messages.

  \item[{\texttt{-\/-no-snapshots}}]
    Build with plain runs instead of snapshots.

  \item[{\texttt{-f}, \texttt{-\/-force}}]
    Stop this document’s snapshots, discard \verb|tenkana|’s
    cached state and build from scratch.

  \item[{\texttt{-F}, \texttt{-\/-final}, \texttt{-d},
  \texttt{-\/-draft}}]
    Ignored: since version 0.3.0 every build updates the
    references (see \emph{References}). They are accepted so
    that older uses still work.

  \item[{\texttt{-\/-clean}}]
    Stop a document’s snapshots, delete its cache (see
    \emph{Files}), and exit. Name the document as for a
    build (\verb|tenkana --clean lualatex thesis|) or just
    by its name (\verb|tenkana --clean thesis|). The file
    itself need not exist any more.

  \item[{\texttt{-\/-clean-all}}]
    Stop the snapshots of every document and delete every
    document’s cache, and exit. \verb|tenkana|’s libraries
    stay. It lists the caches with the space each takes and
    asks first [y/n]; without a terminal to ask on, it needs
    \verb|--yes|. A document’s cache is never deleted on its
    own, so this is the way to get the space back from
    documents you no longer build.

  \item[{\texttt{-\/-uninstall}}]
    Remove this \verb|tenkana|, its man page next to it, its
    cache and \verb|/tmp/tenkana-|\emph{uid}, after stopping
    your snapshots, and exit. It lists what it removes and
    asks first [y/n]; without a terminal to ask on, it needs
    \verb|--yes|. A \verb|tenkana| that belongs to
    \TeX\ Live is not removed. For removing that, use:
    \verb|tlmgr remove tenkana|. This option has no
    one-letter form.

  \item[{\texttt{-\/-yes}}]
    With \verb|--uninstall| or \verb|--clean-all|: remove
    without asking.

  \item[{\texttt{-V}, \texttt{-\/-version}}]
    Print the version and exit.

  \item[{\texttt{-h}, \texttt{-\/-help}}]
    Print a short help text and exit.
\end{description}

The one-letter options \verb|-q|, \verb|-s| and \verb|-v|,
and the ignored \verb|-F| and \verb|-d|, can be combined in
any order: \verb|tenkana -qv| thesis is
\verb|tenkana -q -v thesis|. \verb|-f|, \verb|-h| and
\verb|-V| stand alone. For an unknown or wrongly combined
option, \verb|tenkana| suggests the nearest right one.

\TeX’s options go to \TeX\ unchanged, e.g.:
\verb|-shell-escape|, \verb|-synctex=1|,
\verb|-interaction=batchmode|, \verb|-file-line-error| or
\verb|-jobname=|\emph{name}. Not supported yet, and refused
with a message: \verb|-ini|, \verb|-fmt| (and
\verb|&|\emph{format}), \verb|-output-directory|,
\verb|-aux-directory|, \verb|-output-format| and
\verb|-output-driver|. A change of the \TeX\ command makes
the next build a full run.

With Sync\TeX\ on, the snapshot library keeps \TeX’s
\emph{job}\verb|.synctex(busy)| file in \verb|tenkana|’s
cache, where the snapshots can hold it, and copies it to
\emph{job}\verb|.synctex.gz| at the end instead of renaming
it, so snapshots work as usual.

\section{Snapshots on disk}

After a build that made a new preamble snapshot, a copy of
that snapshot writes itself to \verb|tenkana|’s cache (see
\emph{Files}) in the background, compressed with zstd (zlib
if zstd is missing), unless it would be larger than
\verb|TENKANA_SAVE_LIMIT|. Only memory that differs from the
files on disk is stored, and empty pages are skipped;
typical sizes are 7\,--\,15\textsc{mb}. The default limit is
20\textsc{mb}.

When the snapshots in memory have ended, \verb|tenkana|
starts the engine exactly as before (same command,
environment and memory layout; address-space randomisation
is switched off for the engine) and the snapshot library
restores the image into it before the engine’s \verb|main()|
runs, typically in 0.1\,--\,0.3s. The chapter snapshots are
then made again in memory during that build.

An image is used only on the same kernel and with the same
engine, libraries and font files as when it was saved;
otherwise \verb|tenkana| makes a full run and says why.
Images contain the engine’s memory, including its
environment variables; \verb|tenkana|’s cache is readable
only by you.

\section{What \texttt{tenkana} watches}

Every file the engine reads (recorded with
\verb|-recorder|), assigned to the part of the run that
first read it: the preamble, the body of the main file, or
the stretch after one of the pauses before an
\verb|\include|. The parts follow what \TeX\ actually did,
so \verb|\includeonly|, conditionals and \verb|\include|
inside an \verb|\input| file are handled correctly. A change
to a file read in the preamble needs a full run; a change to
the main file’s body resumes from the preamble snapshot; any
other change resumes from the snapshot just before the part
that first read the file.

\verb|tenkana| also records every file \TeX\ \emph{looked
for but did not find} in the document’s folder: a chapter
not written yet, an image, a \verb|.bbl| before
\verb|biber(1)| has run, an \verb|.ind| before
\verb|makeindex(1)|. When such a file appears, the next
build continues from the part of the document that looked
for it.

In addition, files that other programs generate for \TeX\ to
read are watched by name, even if \TeX\ has not looked for
them yet:

\begin{verbatim}
  .bbl      biber, BibTeX
  .ind      makeindex, xindy
  .gls      makeglossaries (main glossary)
  .acr      makeglossaries (acronyms)
  .nls      makeindex for nomencl
  .glstex   bib2gls (read in the preamble: a full run)
\end{verbatim}

Glossary types declared in the \verb|.aux| file are added
automatically. Files are matched as \emph{job}.\emph{ext},
\emph{job}-*.\emph{ext} and \emph{chapter}.\emph{ext}. More
extensions can be added with \verb|TENKANA_WATCH|.

Changes to the \verb|.aux|, \verb|.toc| and similar files
written by \TeX\ itself are not watched: \verb|tenkana|
reruns until they stop changing (see \emph{References}).

\section{Environment}

\begin{description}
  \item[{\texttt{TENKANA\_ENGINE}}]
    The command for \verb|-q| instead of \verb|lualatex|; it
    may have options, as in
    \verb|TENKANA_ENGINE="pdflatex -shell-escape"|.

  \item[{\texttt{TENKANA\_SILENT}}]
    If set, as \verb|--silent|.

  \item[{\texttt{TENKANA\_TTL}}]
    Seconds the snapshots live after the document’s last
    build (default 28800, i.e. 8 hours).

  \item[{\texttt{TENKANA\_SAVE\_LIMIT}}]
    Largest preamble snapshot to keep on disk, in
    \textsc{mb} (default 20). \verb|0| turns saving off.

  \item[{\texttt{TENKANA\_WATCH}}]
    Additional generated-file extensions to watch, separated
    by commas or spaces, e.g. \verb|TENKANA_WATCH=xyz,abc|.
    They are assumed to be read in the preamble, so a change
    causes a full run.

  \item[{\texttt{TENKANA\_DEBUG}}]
    If set, explain why a snapshot could not be used.

  \item[{\texttt{TENKANA\_SHIM}}]
    Use this snapshot library instead of the built-in one.
\end{description}

\section{Files}

\begin{description}
  \item[{\texttt{\textasciitilde{}/.cache/tenkana/}}]
    \verb|tenkana|’s cache (\verb|$XDG_CACHE_HOME/tenkana/|
    if that is set), readable only by you: \verb|tenkana|’s
    two libraries, written there from \verb|tenkana| itself
    on first use (in \verb|/tmp/tenkana-|\emph{uid}\verb|/|
    instead if the cache’s path contains a space or a colon,
    which \verb|LD_PRELOAD| cannot handle), and one folder
    per document under \verb|docs/|, named after the job and
    a hash of the document’s location. One build of a
    document runs at a time; a second one waits for the
    first. Nothing is written next to the document except
    \TeX’s own output (including \emph{job}\verb|.fls|), so
    a folder synchronised between computers (by Nextcloud,
    Syncthing, ...) carries no snapshots; each computer
    keeps its own.

  \item[{\texttt{\textasciitilde{}/.cache/tenkana/docs/}%
  \emph{job}\texttt{-}\emph{hash}\texttt{/}\emph{job}%
  \texttt{-snap/ck000.img}}]
    The preamble snapshot on disk.
\end{description}

\section{Memory}

A snapshot holds what the engine holds at that point, mostly
fonts and packages; \verb|-v| shows the total. Snapshots
mark themselves as the first processes for the kernel’s
out-of-memory killer to stop (other memory managers, such as
\verb|systemd-oomd(8)|, may choose differently).

Snapshots are ordinary processes: they survive closing the
terminal. They end at a reboot; at a logout only if the
system ends a user’s processes then (with systemd, when
\verb|KillUserProcesses| is set in \verb|logind.conf(5)|);
\verb|TENKANA_TTL| after the document’s last build; with
\verb|tenkana --clean| or \verb|--clean-all|; and within
half a minute after the document’s cache folder is deleted.
\verb|tenkana| does not watch for any of this: at the next
build it finds that the snapshots are gone, and restores the
preamble snapshot from disk, or makes a full run if there is
none.

Snapshots keep the output files open. If another program
replaces one of them (some synchronisation tools do), the
snapshots that hold it cannot be used, and \verb|tenkana|
starts from an earlier one or makes a full run.

\section{Exit status}

0 on success; \TeX’s exit status if \TeX\ stopped with an
error (or \verb|xdvipdfmx|’s, if it failed); 2 for a missing
or unknown command or a wrong option; 128 plus the signal’s
number if \verb|tenkana| or \TeX\ was ended by a signal; 1
for other errors. For another program, its exit status.

\section{Notes}

\verb|tenkana| is built for \textsc{gnu}/Linux and needs
nothing else installed. Snapshots need an x86-64 processor;
on others, such as aarch64, \verb|tenkana| builds with plain
runs. Its libraries are loaded into \TeX\ and into programs
such as \verb|latexmk(1)|, which must therefore use the
\textsc{gnu} C library (2.17 or newer); with an engine that
cannot load them, \verb|tenkana| builds with plain runs.
Snapshots need \verb|\begin{document}| in the main file
itself; other documents (plain \TeX, for example) are built
with plain runs. With \verb|\includeonly|, only the chapters
it includes get snapshots. \verb|\today|, time stamps and
\verb|\write18| side effects come from the run that made the
snapshot.

\section{Unsafe code}

\verb|tenkana| is written in Rust. Where it calls the C
library, takes the place of C library functions in \TeX\ and
other programs, or restores a snapshot, it uses
\verb|unsafe| code, which the Rust compiler does not check.
Claude checked every \verb|unsafe| block against the
behaviour that the Rust Reference and the Rustonomicon list
as undefined (data races, dangling or misaligned pointers,
broken aliasing rules, invalid or uninitialised values,
calls with the wrong \textsc{abi}, unwinding, misused inline
assembly), and changed the code until it found none of it.
This is a check by an \textsc{llm}, not a human review or a
proof: the Reference says that its list is not complete, and
restoring a snapshot from disk replaces the memory of the
engine, which Rust’s rules do not describe (that code uses
only system calls and its own instructions).

\section{Author}

Written by Claude, a large language model (\textsc{llm})
made by Anthropic. Designed, directed and tested by निरंजन
(Niranjan), who does not understand its code; as far as he
knows, no human has reviewed it.

\section{License}

Copyright © 2026 निरंजन (Niranjan)

\noindent
This program is free software: you can redistribute it
and/or modify it under the terms of the \textsc{gnu} General
Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be
useful, but \textsc{without any warranty}; without even the
implied warranty of \textsc{merchantability} or
\textsc{fitness for a particular purpose}. See the
\textsc{gnu} General Public License for more details.

You should have received a copy of the \textsc{gnu} General
Public License along with this program. If not, see
\url{https://www.gnu.org/licenses/}.

\verb|tenkana| was written by Claude, a large language model
(\textsc{llm}) made by Anthropic. Its maintainer designs
\verb|tenkana| and tests what it does, but does not
understand its code; as far as he knows, no human has
reviewed it. Courts are divided on whether material
generated by an \textsc{llm} can be protected by copyright.
Should it be found that the copyright claimant cannot hold
copyright in any part of \verb|tenkana|, that part is in the
public domain. Wherever copyright does hold, \verb|tenkana|
is distributed under the terms of the aforementioned
license.

\section{Reporting bugs}

Home page, sources and releases:
\url{https://sij.ai/niru/tenkana}.

\section{See also}

\verb|arara(1)|, \verb|l3build(1)|, \verb|lualatex(1)|,
\verb|pdflatex(1)|, \verb|xelatex(1)|, \verb|latexmk(1)|,
\verb|biber(1)|, \verb|makeindex(1)|

\end{document}
