Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

docs(air-gapped): clear the install path before the digest check, not after

xerj-org69a1bb65ec2c
diff --git a/docs/recipes/air-gapped-deployment.md b/docs/recipes/air-gapped-deployment.md
index 617db1110..1c87ff8f1 100644
--- a/docs/recipes/air-gapped-deployment.md
+++ b/docs/recipes/air-gapped-deployment.md
@@ -106,6 +106,8 @@ ASSET="${STAGE}.tar.gz"
set -eu
cd /opt/xerj-staging/release
+ rm -rf "$STAGE" "$STAGE.verified"
+
want="$(sha256sum "$ASSET" | cut -d ' ' -f 1)"
if [[ ! "$want" =~ ^[0-9a-f]{64}$ ]]; then
echo "could not compute a digest for $ASSET" >&2
@@ -114,7 +116,6 @@ ASSET="${STAGE}.tar.gz"
LC_ALL=C grep -qxF -e "$want $ASSET" -e "$want *$ASSET" \
< <(tr -d '\r' < "$ASSET.sha256")
- rm -rf "$STAGE" "$STAGE.verified"
tar -xzf "$ASSET"
test -x "$STAGE/xerj"
mv "$STAGE" "$STAGE.verified"
@@ -148,7 +149,15 @@ form. Inside, a failure ends the subshell and the operator keeps their session.
digest, the extraction and `test -x` have all succeeded.** That is what makes
the block safe when its exit status is ignored — by a wrapping script, an agent,
or a reader who pastes the next section anyway. Nothing needs to check a return
-code, because on any failure there is simply nothing at the install path.
+code, because on any failure there is nothing at the install path.
+
+That last sentence is only true because `rm -rf` runs FIRST. An earlier version
+placed it after the digest check, where it is unreachable on exactly the failure
+that matters: a bad digest exits the subshell before it, so a `$STAGE.verified`
+left by an earlier run — or planted by anyone who can write to the staging
+directory — survived and was installed. Clearing the install path before
+anything else is what makes "nothing to install" the default rather than a
+consequence.
## 2. Install the base lexical node
diff --git a/landing/docs/recipes/air-gapped-deployment.html b/landing/docs/recipes/air-gapped-deployment.html
index f631c221f..8dd8ce7ea 100644
--- a/landing/docs/recipes/air-gapped-deployment.html
+++ b/landing/docs/recipes/air-gapped-deployment.html
@@ -109,6 +109,8 @@ ASSET="${STAGE}.tar.gz"
set -eu
cd /opt/xerj-staging/release
+ rm -rf "$STAGE" "$STAGE.verified"
+
want="$(sha256sum "$ASSET" | cut -d ' ' -f 1)"
if [[ ! "$want" =~ ^[0-9a-f]{64}$ ]]; then
echo "could not compute a digest for $ASSET" &gt;&amp;2
@@ -117,12 +119,11 @@ ASSET="${STAGE}.tar.gz"
LC_ALL=C grep -qxF -e "$want $ASSET" -e "$want *$ASSET" \
&lt; &lt;(tr -d '\r' &lt; "$ASSET.sha256")
- rm -rf "$STAGE" "$STAGE.verified"
tar -xzf "$ASSET"
test -x "$STAGE/xerj"
mv "$STAGE" "$STAGE.verified"
)</pre>
- <p>Three details are load-bearing, and each replaces something that looked right and was not. <strong>The digest is computed here and the file is searched for it, not the other way round</strong> &mdash; <code class="inline">sha256sum -c</code> reads the filename out of the <code class="inline">.sha256</code>, a file that crossed the airgap on the same medium as the archive, skips <code class="inline">#</code> comments silently, and exits <code class="inline">0</code> if any one line verified, so a decoy digest plus a comment naming the archive passes while the archive is never hashed. Filtering that file first does not fix it: <code class="inline">awk '$2 == asset'</code> compares one token while <code class="inline">sha256sum</code> takes the whole rest of the line as the filename, so a line naming <code class="inline">$ASSET decoy</code> satisfies the filter and hashes a decoy. Building the expected line in the shell and demanding it with <code class="inline">grep -qxF</code> removes the disagreement. The two patterns accept GNU text mode and <code class="inline">-b</code> binary mode; <code class="inline">tr -d '\r'</code> accepts a checksum file written on Windows. <strong><code class="inline">set -eu</code> is inside the subshell</strong> &mdash; at the top of the block it kills the operator&rsquo;s login shell on a bad digest, and the natural recovery is to re-paste without it, which is the fail-open form. <strong>Section 2 installs from <code class="inline">$STAGE.verified</code></strong>, which <code class="inline">mv</code> creates only after the digest, the extraction and <code class="inline">test -x</code> have all succeeded &mdash; so the block is safe even when its exit status is ignored, because on any failure there is nothing at the install path.</p>
+ <p>Three details are load-bearing, and each replaces something that looked right and was not. <strong>The digest is computed here and the file is searched for it, not the other way round</strong> &mdash; <code class="inline">sha256sum -c</code> reads the filename out of the <code class="inline">.sha256</code>, a file that crossed the airgap on the same medium as the archive, skips <code class="inline">#</code> comments silently, and exits <code class="inline">0</code> if any one line verified, so a decoy digest plus a comment naming the archive passes while the archive is never hashed. Filtering that file first does not fix it: <code class="inline">awk '$2 == asset'</code> compares one token while <code class="inline">sha256sum</code> takes the whole rest of the line as the filename, so a line naming <code class="inline">$ASSET decoy</code> satisfies the filter and hashes a decoy. Building the expected line in the shell and demanding it with <code class="inline">grep -qxF</code> removes the disagreement. The two patterns accept GNU text mode and <code class="inline">-b</code> binary mode; <code class="inline">tr -d '\r'</code> accepts a checksum file written on Windows. <strong><code class="inline">set -eu</code> is inside the subshell</strong> &mdash; at the top of the block it kills the operator&rsquo;s login shell on a bad digest, and the natural recovery is to re-paste without it, which is the fail-open form. <strong>Section 2 installs from <code class="inline">$STAGE.verified</code></strong>, which <code class="inline">mv</code> creates only after the digest, the extraction and <code class="inline">test -x</code> have all succeeded &mdash; so the block is safe even when its exit status is ignored, because on any failure there is nothing at the install path. That last part is only true because <code class="inline">rm -rf</code> runs <strong>first</strong>: placed after the digest check it is unreachable on exactly the failure that matters, and a <code class="inline">$STAGE.verified</code> left by an earlier run &mdash; or planted by anyone who can write to the staging directory &mdash; would survive and be installed.</p>
<h2>2. Install the base lexical node</h2>
<p>Create the service account first, then install only the staged binary. No model directory is needed for lexical mode:</p>