Skip to content

os: release-check uses the key the running lemond holds, not the first line of the file - #597

Merged
bong-water-water-bong merged 2 commits into
mainfrom
1bit/os-check-key-from-lemond
Oct 26, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
1bit/os-check-key-from-lemond

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Candidate 10 on the board (26 Oct, Secure Boot on): FAIL lemonade : the server answered 401 with the key (wanted 200), and behind it models, gguf, chat, chat-hrx and bench all degraded. Measured cause: /data/lemonade/lemond.conf held two active LEMONADE_API_KEY lines for a while, a staged one glued onto the previous line (the stock file ends without a newline, so an append joins it) and the one init then minted because its anchored test did not see the glued one. lemond sources the file, so it ran on the last; the check took the first (head -1), sent it and read the 401 as a wrong key. With the current single key, Bearer <key> → 200 on /api/v1/models (X-API-Key → 401, no key → 401, /health → 200).

Change, os/mini/release-check.sh: the key comes from the environment of the process that listens on the Lemonade port (socket inode in /proc/net/tcp → /proc/<pid>/fd → /proc/<pid>/environ), which is what the server actually compares against; the file is the fallback, and then the last assignment wins, matching the shell that started lemond. --self-test PASS, bash -n clean. Pairs with #596 (the gguf row's three messages).

Follow-up on the writer side: the stick-prep in liveusb_vmtest.py and any hand prep must append the key with a leading newline and assert exactly one ^LEMONADE_API_KEY= line.

🤖 Generated with Claude Code

bong-water-water-bong and others added 2 commits October 26, 2026 05:35
…t line of the file

Candidate 10 on the board (26 Oct): the conf held two active LEMONADE_API_KEY lines for a while (a
staged one glued to the previous line without a newline, and the one init then minted because the
anchored test did not see the glued one). lemond sources the file, so it ran on the last; the check
took the first, sent it, got 401 and reported "the server answered 401 with the key", and every row
that needs the model list degraded behind it.

The key now comes from the environment of the process that listens on the Lemonade port (socket
inode in /proc/net/tcp -> /proc/<pid>/fd -> /proc/<pid>/environ), which is what the server actually
checks against; the file is the fallback, and then the last assignment wins, as it does for the shell
that started lemond. Verified on the stick: Bearer <that key> -> 200 on /api/v1/models.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@bong-water-water-bong
bong-water-water-bong merged commit 5dea717 into main Oct 26, 2026
8 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/os-check-key-from-lemond branch October 26, 2026 08:44
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

596 - Partially compliant

Compliant requirements:

  • The release-check.sh script now reads the key from the running lemond process environment
  • The key reading mechanism matches shell semantics by using tail -n 1 as fallback
  • The self-test passes and bash -n is clean

Non-compliant requirements:

  • The gguf row messages were not updated in this PR (this is noted in the PR description as "Not in this PR")

Requires further human verification:

  • The specific messages for the three gguf situations need to be verified in the UI or logs
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Key Reading Logic

The key reading logic correctly prioritizes the key from the running lemond process environment over the config file, which addresses the issue where the check was using the first key line instead of the last one that the shell would use. This change ensures that the API key used for checking matches what the server actually uses.

# The key the running lemond actually holds, read from the environment of the process that listens on
# the Lemonade port (via the socket inode in /proc/net/tcp). Candidate 10 on the board (26 Oct): the conf
# held two active key lines for a while (a staged one glued to the previous line, and the one init then
# minted); lemond, which SOURCES the file, ran on the last one, and this check, taking the first, sent the
# other and read 401 as "the key is wrong". The file is only the fallback, and then the last assignment
# wins, as it does for the shell that started lemond.
lemond_key() {
    ino=$(awk -v p="$(printf ':%04X' "$PORT")" '$2 ~ p"$" && $4 == "0A" { print $10; exit }' /proc/net/tcp 2>/dev/null)
    [ -n "$ino" ] || return 1
    for d in /proc/[0-9]*; do
        if ls -l "$d/fd" 2>/dev/null | grep -q "socket:\[$ino\]"; then
            tr '\0' '\n' < "$d/environ" 2>/dev/null | sed -n 's/^LEMONADE_API_KEY=//p' | head -n 1
            return 0
        fi
    done
    return 1
}
KEY=$(lemond_key)
[ -n "$KEY" ] || KEY=$(sed -n 's/^LEMONADE_API_KEY=//p' /data/lemonade/lemond.conf 2>/dev/null | tail -n 1)
API="http://127.0.0.1:$PORT"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant