Merge pull request 'alpha.5: capsule trust (#139); CI uploads (#184); block reads refused (#187); POST.md steady (#199); Downloads and Documents (#191); the demo's transcripts (#192)' (#201) from StarForth-v4.0.0 into master
Runner image / Build and publish the runner image (push) Failing after 9m6s

This commit was merged in pull request #201.
This commit is contained in:
2026-11-24 13:46:08 +00:00
96 changed files with 92935 additions and 61 deletions
+13
View File
@@ -175,3 +175,16 @@ So:
sake. sake.
- It is touched only to keep the gates that still run it green: the docs stage's dictionary check - It is touched only to keep the gates that still run it green: the docs stage's dictionary check
(`v4/tools/mkdictionary.py`) and `make -C v4 test`. Ruled "Keep the boot.c change", for that reason. (`v4/tools/mkdictionary.py`) and `make -C v4 test`. Ruled "Keep the boot.c change", for that reason.
## Capsules, keys and trust (Captain Bob, 2026-11-20)
- **Never a throwaway CA or key**, for a test or anything else: "No throwaway. I never would want that,
it's a stupid idea." What needs a real signature is shown in CI, with the real key (#139, ruling 4).
- **The root CA's private key is on the CI server**, `/var/lib/starshipos-ca/root/`, beside its
certificate. Never mount or copy that directory anywhere. The root's public certificate is in the tree,
`ci/pki/starshipos-root-ca.pem`.
- **Capsules are becoming trains:** the v4 runtime engine (a `.f18a`) towing named blobs as rolling stock.
Each blob is signed by its author and hashed, and the capsule's `MANIFEST.md` holds each blob's hash.
Bona fide contributors get their own intermediate certificate under the StarshipOS root; casual users get
a snakeoil one, told apart by the chain to the root. For ADR step 4
(`docs/v4.0.0/plans/2026-11-20-capsule-trust.md`).
+9 -5
View File
@@ -75,13 +75,17 @@ jobs:
if: failure() if: failure()
run: scripts/nightly.sh diagnose # build only; the failed step stays the job's failure run: scripts/nightly.sh diagnose # build only; the failed step stays the job's failure
# #184 (Captain Bob, 2026-11-20: "A warning only"): only what this run wrote is uploaded -- the logs and
# CSVs newer than its start, and the stages' output (scripts/nightly.sh run-logs) -- not every log in
# the tree. The upload is a copy for convenience, the evidence is committed: a failed upload is a
# warning (continue-on-error), and cannot turn a passing run red.
- name: This run's logs and DoE CSVs, gathered
if: always()
run: scripts/nightly.sh run-logs || true
- name: Keep the logs and DoE CSVs - name: Keep the logs and DoE CSVs
if: always() if: always()
continue-on-error: true
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: acceptance-logs-${{ github.run_number }} name: acceptance-logs-${{ github.run_number }}
path: | path: build/nightly/run-logs/
logs/
experiments/bare_metal/runs/
build/nightly/accept-*.txt
build/nightly/test-32.txt
+12 -3
View File
@@ -65,6 +65,9 @@ jobs:
run: scripts/nightly.sh accept stick-high run: scripts/nightly.sh accept stick-high
- name: Acceptance 32-bit build - name: Acceptance 32-bit build
run: scripts/nightly.sh test-32 run: scripts/nightly.sh test-32
- name: A signed kernel refuses an unsigned capsule (#139)
if: always()
run: scripts/nightly.sh capsule-trust
- name: Images - name: Images
run: scripts/nightly.sh images run: scripts/nightly.sh images
@@ -98,11 +101,17 @@ jobs:
if: failure() if: failure()
run: scripts/nightly.sh diagnose # build only; the failed step stays the job's failure run: scripts/nightly.sh diagnose # build only; the failed step stays the job's failure
# #184 (Captain Bob, 2026-11-20: "A warning only"): only what this run wrote is uploaded -- the logs and
# CSVs newer than its start, and the stages' output (scripts/nightly.sh run-logs) -- not every log in
# the tree. The upload is a copy for convenience, the evidence is committed: a failed upload is a
# warning (continue-on-error), and cannot turn a passing run red.
- name: This run's logs and DoE CSVs, gathered
if: always()
run: scripts/nightly.sh run-logs || true
- name: Keep the logs and DoE CSVs - name: Keep the logs and DoE CSVs
if: always() if: always()
continue-on-error: true
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: logs-${{ github.run_number }} name: logs-${{ github.run_number }}
path: | path: build/nightly/run-logs/
logs/
experiments/bare_metal/runs/
+9 -3
View File
@@ -111,11 +111,17 @@ jobs:
if: failure() if: failure()
run: scripts/nightly.sh diagnose # build only; the failed step stays the job's failure run: scripts/nightly.sh diagnose # build only; the failed step stays the job's failure
# #184 (Captain Bob, 2026-11-20: "A warning only"): only what this run wrote is uploaded -- the logs and
# CSVs newer than its start, and the stages' output (scripts/nightly.sh run-logs) -- not every log in
# the tree. The upload is a copy for convenience, the evidence is committed: a failed upload is a
# warning (continue-on-error), and cannot turn a passing run red.
- name: This run's logs and DoE CSVs, gathered
if: always()
run: scripts/nightly.sh run-logs || true
- name: Keep the logs and DoE CSVs - name: Keep the logs and DoE CSVs
if: always() if: always()
continue-on-error: true
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: release-logs-${{ github.ref_name }} name: release-logs-${{ github.ref_name }}
path: | path: build/nightly/run-logs/
logs/
experiments/bare_metal/runs/
+1 -1
View File
@@ -278,7 +278,7 @@ INIT_PROOFS ?= 1
INIT_COMMON := build-essential make git git-lfs python3 curl ca-certificates xz-utils \ INIT_COMMON := build-essential make git git-lfs python3 curl ca-certificates xz-utils \
xorriso mtools gdisk dosfstools fdisk \ xorriso mtools gdisk dosfstools fdisk \
qemu-user qemu-user
INIT_DOCPKGS := pandoc latexmk texlive-xetex texlive-latex-base texlive-latex-recommended \ INIT_DOCPKGS := pandoc latexmk texlive-xetex texlive-latex-base texlive-latex-recommended texlive-science \
texlive-latex-extra texlive-pictures texlive-fonts-recommended lmodern \ texlive-latex-extra texlive-pictures texlive-fonts-recommended lmodern \
fonts-dejavu fonts-dejavu-extra doxygen graphviz fonts-dejavu fonts-dejavu-extra doxygen graphviz
INIT_amd64 := qemu-system-x86 ovmf INIT_amd64 := qemu-system-x86 ovmf
+25
View File
@@ -59,6 +59,31 @@ ss -ltnp | grep 7681 # the ttyd of starshipos-demo, not
The service expects the checkout's `demo/` at `/opt/starshipos-demo/demo` (step 1 put it there). The service expects the checkout's `demo/` at `/opt/starshipos-demo/demo` (step 1 put it there).
**The transcripts (#192, ruled 2026-11-21: "Write-only drop box").** Each session writes what the
visitor typed and what the machine answered to `/var/lib/starshipos-demo-transcripts`, one file per
session, mode 0600 (`console.py`). The directory is yours, group `starshipos-demo`, mode 1730: a
session can add a file, but cannot list the directory or read anything in it. A root timer hands each
file to you and deletes every one older than 7 days (`transcripts-tidy.sh`). The Try it page says so.
Before (re)starting the service, with `OWNER` your own login:
```bash
OWNER=<your login>
install -d -o "$OWNER" -g starshipos-demo -m 1730 /var/lib/starshipos-demo-transcripts
sed "s/^Environment=OWNER=CHANGE-ME$/Environment=OWNER=$OWNER/" \
demo/starshipos-demo-transcripts.service > /etc/systemd/system/starshipos-demo-transcripts.service
cp demo/starshipos-demo-transcripts.timer /etc/systemd/system/
systemctl daemon-reload && systemctl enable --now starshipos-demo-transcripts.timer
systemctl restart starshipos-demo # its unit now writes the transcripts directory
systemctl list-timers starshipos-demo-transcripts --no-pager
```
Then the check: open a session, type a line, close it; within 5 minutes its file is in
`/var/lib/starshipos-demo-transcripts`, owned by you, mode `-rw-------`, and `sudo -u
starshipos-demo ls /var/lib/starshipos-demo-transcripts` is refused. A file older than 7 days
(`touch -d '8 days ago' FILE.log`) is gone at the next run (`systemctl start
starshipos-demo-transcripts` runs it at once). Apache must not serve the directory: nothing in
`apache-demo.conf` maps it, and nothing should.
## 5. TLS and Apache for try.starshipos-f18.com (~10 min) ## 5. TLS and Apache for try.starshipos-f18.com (~10 min)
DNS: `try.starshipos-f18.com` must point at this server (an A record) before certbot. DNS: `try.starshipos-f18.com` must point at this server (an A record) before certbot.
+7
View File
@@ -21,6 +21,9 @@ XWiki "Try it" page (iframe) -> Apache: TLS, websocket -> ttyd -> start-session.
| `console.py` | Joins the visitor's terminal to the machine only once it runs, discarding keys typed while it loads | | `console.py` | Joins the visitor's terminal to the machine only once it runs, discarding keys typed while it loads |
| `qemu-args.sh` | The machine, shared by the two above: a resumed machine must match the saved one exactly | | `qemu-args.sh` | The machine, shared by the two above: a resumed machine must match the saved one exactly |
| `starshipos-demo.service` | ttyd as a systemd service, on localhost; two guests at once, a busy message for the rest (#114, #116) | | `starshipos-demo.service` | ttyd as a systemd service, on localhost; two guests at once, a busy message for the rest (#114, #116) |
| `transcripts-tidy.sh` | Hands each session's transcript to its owner, mode 0600, and deletes those over 7 days (#192) |
| `starshipos-demo-transcripts.service`, `.timer` | Runs `transcripts-tidy.sh` as root every 5 minutes (#192) |
| `test_transcripts.py` | Tests the transcript and the tidy, with a stand-in machine: `python3 demo/test_transcripts.py` |
| `DEPLOY.md` | Putting it on the server, step by step | | `DEPLOY.md` | Putting it on the server, step by step |
| `apache-demo.conf` | Example vhost: TLS, the websocket, framing allowed for the `.com` only (#115) | | `apache-demo.conf` | Example vhost: TLS, the websocket, framing allowed for the `.com` only (#115) |
| `xwiki-try-it.xwiki` | The "Try it" page, its own page on the `.com` XWiki (`TryIt`), in the landing page's style | | `xwiki-try-it.xwiki` | The "Try it" page, its own page on the `.com` XWiki (`TryIt`), in the landing page's style |
@@ -33,6 +36,10 @@ seccomp sandbox (no spawning, no privilege changes), as an unprivileged user, in
that fences memory, CPU and the file system. A session lasts at most `DEMO_SESSION_LIMIT` seconds that fences memory, CPU and the file system. A session lasts at most `DEMO_SESSION_LIMIT` seconds
(1800). (1800).
What is kept: a transcript of each session -- what the visitor typed and what the machine answered
-- for up to 7 days, readable by the server's owner only, then deleted (#192; `DEPLOY.md`, step 4).
The Try it page and the session's first lines say so.
## Setting it up ## Setting it up
From a checkout of the most recent green commit -- the latest that passed acceptance, `master` From a checkout of the most recent green commit -- the latest that passed acceptance, `master`
+21
View File
@@ -10,6 +10,13 @@ A resumed machine takes a moment to load. Anything typed meanwhile would reach a
whose state is about to be replaced, and be lost half-way through a line ("3 4 + ." arriving as whose state is about to be replaced, and be lost half-way through a line ("3 4 + ." arriving as
"4 + ."). So: wait until QEMU says the machine is running, throw away what was typed before, "4 + ."). So: wait until QEMU says the machine is running, throw away what was typed before,
say so, and only then pass bytes both ways. Ends when either side closes. say so, and only then pass bytes both ways. Ends when either side closes.
The transcript (#192, ruled 2026-11-13 and 2026-11-21): what the machine sends -- its prompt, the visitor's
line as it echoes it, what it prints -- is also written to DEMO_TRANSCRIPTS
(/var/lib/starshipos-demo-transcripts), one file a session, named by its UTC start and this process, mode 0600.
The directory is a drop box this user can write in but not list or read (DEPLOY.md); transcripts-tidy.sh
hands each file to its owner and deletes it after 7 days. The Try It page says so. If it cannot be written,
the session goes on without one.
""" """
import json, os, select, socket, sys, termios, time, tty import json, os, select, socket, sys, termios, time, tty
@@ -38,6 +45,14 @@ while True: # until the machine runs
time.sleep(0.1) time.sleep(0.1)
con = connect(con_path) con = connect(con_path)
transcript = None
try:
tdir = os.environ.get("DEMO_TRANSCRIPTS", "/var/lib/starshipos-demo-transcripts")
name = os.path.join(tdir, time.strftime("%Y%m%d-%H%M%S", time.gmtime()) + "-%d.log" % os.getpid())
transcript = os.open(name, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
os.write(transcript, ("# StarshipOS demo session, %s UTC\n" % time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())).encode())
except OSError:
transcript = None # no transcript, the session as before
stdin, stdout = sys.stdin.fileno(), sys.stdout.fileno() stdin, stdout = sys.stdin.fileno(), sys.stdout.fileno()
saved = None saved = None
if os.isatty(stdin): if os.isatty(stdin):
@@ -56,7 +71,13 @@ try:
data = con.recv(4096) data = con.recv(4096)
if not data: break if not data: break
os.write(stdout, data) os.write(stdout, data)
if transcript is not None:
try: os.write(transcript, data)
except OSError: transcript = None
except OSError: except OSError:
pass # the visitor's terminal went away pass # the visitor's terminal went away
finally: finally:
if saved: termios.tcsetattr(stdin, termios.TCSADRAIN, saved) if saved: termios.tcsetattr(stdin, termios.TCSADRAIN, saved)
if transcript is not None:
os.write(transcript, ("\n# ended %s UTC\n" % time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())).encode())
os.close(transcript)
+12
View File
@@ -0,0 +1,12 @@
# starshipos-demo-transcripts.service -- the demo's transcripts (#192, ruled 2026-11-21: "Write-only drop box").
# Each session (console.py) writes its transcript, mode 0600, into /var/lib/starshipos-demo-transcripts:
# owned by Captain Bob, group starshipos-demo, mode 1730, so a session can add a file but not list or
# read the directory. This hands each file to the owner and deletes every one older than 7 days.
# Run by starshipos-demo-transcripts.timer. Set OWNER below to the owner's login (DEPLOY.md, step 4).
[Unit]
Description=StarshipOS demo transcripts: hand them to their owner, delete those over 7 days
[Service]
Type=oneshot
Environment=OWNER=CHANGE-ME
ExecStart=/opt/starshipos-demo/demo/transcripts-tidy.sh /var/lib/starshipos-demo-transcripts ${OWNER}
+10
View File
@@ -0,0 +1,10 @@
# starshipos-demo-transcripts.timer -- runs starshipos-demo-transcripts.service every 5 minutes (#192).
[Unit]
Description=StarshipOS demo transcripts, every 5 minutes
[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
[Install]
WantedBy=timers.target
+3
View File
@@ -14,6 +14,8 @@ Group=starshipos-demo
Environment=DEMO_STATE=/var/lib/starshipos-demo Environment=DEMO_STATE=/var/lib/starshipos-demo
Environment=DEMO_SESSION_LIMIT=1800 Environment=DEMO_SESSION_LIMIT=1800
Environment=DEMO_MAX_GUESTS=2 Environment=DEMO_MAX_GUESTS=2
# each session's transcript (console.py, #192): a write-only drop box, kept 7 days
Environment=DEMO_TRANSCRIPTS=/var/lib/starshipos-demo-transcripts
# the guests' slot locks (start-session.sh): /run/starshipos-demo, made for this user, gone at stop # the guests' slot locks (start-session.sh): /run/starshipos-demo, made for this user, gone at stop
RuntimeDirectory=starshipos-demo RuntimeDirectory=starshipos-demo
# --max-clients: the guests and a few more, so a visitor over the limit reaches the busy message # --max-clients: the guests and a few more, so a visitor over the limit reaches the busy message
@@ -30,6 +32,7 @@ ProtectHome=yes
PrivateTmp=yes PrivateTmp=yes
PrivateDevices=yes PrivateDevices=yes
ReadOnlyPaths=/var/lib/starshipos-demo ReadOnlyPaths=/var/lib/starshipos-demo
ReadWritePaths=/var/lib/starshipos-demo-transcripts
# Sized for this server (3.8 GiB, two cores; both wikis, Gitea, Nexus, CI). Since #151 an idle guest # Sized for this server (3.8 GiB, two cores; both wikis, Gitea, Nexus, CI). Since #151 an idle guest
# halts (1% of a core at the prompt, was 100%), so a session costs CPU only while its visitor runs # halts (1% of a core at the prompt, was 100%), so a session costs CPU only while its visitor runs
# something. All sessions together get 1.5 cores at the lowest priority (Captain Bob, 2026-11-08): # something. All sessions together get 1.5 cores at the lowest priority (Captain Bob, 2026-11-08):
+2 -1
View File
@@ -42,7 +42,8 @@ trap 'rm -rf "$tmp"' EXIT
cp "$dir/vars.fd" "$tmp/vars.fd" cp "$dir/vars.fd" "$tmp/vars.fd"
demo_qemu_args "$dir" "$tmp/vars.fd" demo_qemu_args "$dir" "$tmp/vars.fd"
printf '\r\nStarshipOS -- starting a throwaway machine, yours for up to %d minutes. Nothing you do is kept.\r\n' $((limit / 60)) printf '\r\nStarshipOS -- starting a throwaway machine, yours for up to %d minutes. Nothing you do is kept on it.\r\n' $((limit / 60))
printf 'A transcript of this session is kept for up to 7 days, then deleted.\r\n'
printf 'Try: 3 4 + . : SQUARE DUP * ; 7 SQUARE .\r\n\r\n' printf 'Try: 3 4 + . : SQUARE DUP * ; 7 SQUARE .\r\n\r\n'
# QEMU is a tracked child, not exec'd, so that whatever ends the session ends the machine: ttyd # QEMU is a tracked child, not exec'd, so that whatever ends the session ends the machine: ttyd
# hangs up (it signals this script only), the service stops, or the time runs out. Its console is # hangs up (it signals this script only), the service stops, or the time runs out. Its console is
+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LicenseRef-Starship-1.0
# Copyright (c) 2023-2026 Robert A. James
"""test_transcripts.py -- the demo's transcripts (#192, ruled 2026-11-13 and 2026-11-21): console.py writes each
session's console into DEMO_TRANSCRIPTS, one dated file a session, readable only by its writer; and
transcripts-tidy.sh hands each to the directory's owner and deletes those older than 7 days. No QEMU: a fake QMP
socket that says the machine runs, and a fake console that echoes. Prints PASS:/FAIL: and RESULT:."""
import json, os, socket, subprocess, sys, tempfile, threading, time, glob
HERE = os.path.dirname(os.path.abspath(__file__))
ok = True
def check(what, cond):
global ok
print(("PASS: " if cond else "FAIL: ") + what)
ok = ok and bool(cond)
def qmp_server(path):
s = socket.socket(socket.AF_UNIX); s.bind(path); s.listen(1)
def run():
c, _ = s.accept(); f = c.makefile("rw")
f.write(json.dumps({"QMP": {}}) + "\n"); f.flush()
for line in f:
f.write(json.dumps({"return": {"status": "running"}} if "query-status" in line else {"return": {}}) + "\n"); f.flush()
threading.Thread(target=run, daemon=True).start()
def console_server(path):
s = socket.socket(socket.AF_UNIX); s.bind(path); s.listen(1)
def run():
c, _ = s.accept()
c.sendall(b"[zuse@Hera] ok> ")
while True:
d = c.recv(1024)
if not d: break
c.sendall(d) # the machine echoes
if b"\r" in d: c.sendall(b"7 ok\r\n[zuse@Hera] ok> ")
threading.Thread(target=run, daemon=True).start()
with tempfile.TemporaryDirectory() as t:
tr = os.path.join(t, "transcripts"); os.mkdir(tr, 0o730)
qmp_server(os.path.join(t, "qmp.sock")); console_server(os.path.join(t, "con.sock"))
env = dict(os.environ, DEMO_TRANSCRIPTS=tr)
p = subprocess.Popen([sys.executable, "-I", os.path.join(HERE, "console.py"), os.path.join(t, "qmp.sock"), os.path.join(t, "con.sock")],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env)
time.sleep(1.0); p.stdin.write(b"3 4 + .\r"); p.stdin.flush(); time.sleep(1.0); p.stdin.close()
out = p.stdout.read(); p.wait(timeout=10)
files = glob.glob(os.path.join(tr, "*.log"))
check("the visitor still sees the session: %r" % out[-40:], b"7 ok" in out)
check("one transcript for the session (%d)" % len(files), len(files) == 1)
if files:
f = files[0]; text = open(f, "rb").read()
check("named by its date, UTC: %s" % os.path.basename(f), os.path.basename(f)[:8].isdigit())
check("it holds what was typed, as the machine echoed it, and what it printed", b"3 4 + ." in text and b"7 ok" in text)
check("readable by its writer only (mode %o)" % (os.stat(f).st_mode & 0o777), os.stat(f).st_mode & 0o777 == 0o600)
# a directory it cannot write: the session goes on, without a transcript
ro = os.path.join(t, "nowhere")
env2 = dict(os.environ, DEMO_TRANSCRIPTS=ro)
os.unlink(os.path.join(t, "qmp.sock")); os.unlink(os.path.join(t, "con.sock"))
qmp_server(os.path.join(t, "qmp.sock")); console_server(os.path.join(t, "con.sock"))
p = subprocess.Popen([sys.executable, "-I", os.path.join(HERE, "console.py"), os.path.join(t, "qmp.sock"), os.path.join(t, "con.sock")],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env2)
time.sleep(1.0); p.stdin.write(b"3 4 + .\r"); p.stdin.flush(); time.sleep(1.0); p.stdin.close()
out = p.stdout.read(); p.wait(timeout=10)
check("with no directory to write in, the session still works", b"7 ok" in out)
# transcripts-tidy.sh: handed to the owner, the old deleted
box = os.path.join(t, "box"); os.mkdir(box)
new, old = os.path.join(box, "20261121-000000-1.log"), os.path.join(box, "20261101-000000-2.log")
for f in (new, old): open(f, "w").write("x"); os.chmod(f, 0o600)
eight_days = time.time() - 8 * 86400; os.utime(old, (eight_days, eight_days))
r = subprocess.run(["bash", os.path.join(HERE, "transcripts-tidy.sh"), box, "nobody"], capture_output=True, text=True)
check("the tidy succeeds: %s" % (r.stderr.strip() or "ok"), r.returncode == 0)
check("a transcript older than 7 days is deleted", not os.path.exists(old))
check("a newer one is kept", os.path.exists(new))
if os.path.exists(new):
import pwd
st = os.stat(new)
check("and handed to the directory's owner (%s), mode 600" % pwd.getpwuid(st.st_uid).pw_name,
pwd.getpwuid(st.st_uid).pw_name == "nobody" and st.st_mode & 0o777 == 0o600)
print("RESULT: " + ("PASS" if ok else "FAIL"))
sys.exit(0 if ok else 1)
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
# SPDX-License-Identifier: LicenseRef-Starship-1.0
# Copyright (c) 2023-2026 Robert A. James
# transcripts-tidy.sh DIR OWNER -- the demo's transcripts (#192): each handed to OWNER, mode 0600, so only OWNER
# reads it (the session's user wrote it, and cannot list the directory); every one older than 7 days deleted.
# Run as root by starshipos-demo-transcripts.timer every 5 minutes. Tests: demo/test_transcripts.py.
set -euo pipefail
dir=${1:?usage: transcripts-tidy.sh DIR OWNER}
owner=${2:?usage: transcripts-tidy.sh DIR OWNER}
[ -d "$dir" ] || { echo "transcripts-tidy: no $dir" >&2; exit 1; }
find "$dir" -maxdepth 1 -type f -name '*.log' -mmin +10080 -delete # 7 days
find "$dir" -maxdepth 1 -type f -name '*.log' ! -user "$owner" -exec chown "$owner:" {} + -exec chmod 0600 {} +
+2 -1
View File
@@ -13,7 +13,8 @@ This is a real StarshipOS machine, started just for you and already at its promp
simulation of StarshipOS and not a recording: the console below is the serial console of an simulation of StarshipOS and not a recording: the console below is the serial console of an
amd64 machine running the same image the project publishes every night. You are logged in as amd64 machine running the same image the project publishes every night. You are logged in as
**Zuse**, the superuser -- of a machine that exists only for your session. There is nothing to **Zuse**, the superuser -- of a machine that exists only for your session. There is nothing to
break, and nothing you do is kept. Close the page and it is gone. break, and nothing you do is kept on it. Close the page and it is gone. A transcript of your
session -- what you type and what the machine answers -- is kept for up to 7 days, then deleted.
{{html clean="false"}} {{html clean="false"}}
<iframe src="https://try.starshipos-f18.com/" title="StarshipOS console" <iframe src="https://try.starshipos-f18.com/" title="StarshipOS console"
+36
View File
@@ -6847,3 +6847,39 @@ What the record asks beyond POST, each gap put to Captain Bob one at a time:
tag"): PR #197 merges once its Acceptance passes, and a tag on `master` marks the line. New work starts tag"): PR #197 merges once its Acceptance passes, and a tag on `master` marks the line. New work starts
after it. after it.
## XLIX. Capsule trust: the intermediate is the anchor, and a signed kernel refuses an unsigned capsule (#139, 2026-11-20)
### 1. Found
XLVI left two things open (2026-11-07). The kernel does not check the image's signing certificate against
the StarshipOS Root CA. And an unsigned capsule (`CAPSULE_SIG_MISSING`) is only a warning, as ruled on
2026-08-26, when CI had no key. Since XLVI, CI signs every build, and the gate into master and a release
refuse an unsigned one (#174).
### 2. Ruled (Captain Bob, 2026-11-20; `docs/v4.0.0/plans/2026-11-20-capsule-trust.md`)
1. **"Intermediate is the anchor; no root check."** The "StarshipOS Capsule Signing" certificate in the
image (XLVI) is what capsules are trusted by. No root key goes in the kernel or in CI. First ruled
"verify at boot"; withdrawn when asked where CI would take the root's certificate from: "Actually we
decided to include an intermediate certificate in the kernel". On the way it was found that the root's
private key is on the CI server beside its certificate, in `/var/lib/starshipos-ca/root/` (mode 700),
so mounting that directory into CI jobs, one way to reach the certificate, would have exposed it.
2. **"Refuse on signed builds."** A kernel built with the signing key refuses an unsigned capsule. A
developer build, without the key, warns and boots.
3. **"NO_ROOT_KEY, by build."** A signing certificate missing from the image, or one that cannot be read,
is refused on a signed build and warned of on a developer build.
4. **"Left to CI."** The boot of a signed kernel with an unsigned capsule is CI's to show, since only CI
has the key.
### 3. Built
- `capsule_sig_refused()` (`kernel/src/capsule/capsule_sig.c`): the one decision. INVALID always;
MISSING and NO_ROOT_KEY on a signed build (`CAPSULE_SIGNED_BUILD`, set by `kernel/Makefile` and
`v4/Makefile` exactly when they sign). v4's boot and v3's three births ask it.
- `kernel/tests/test_capsule_sig.c`, built twice, unsigned and signed: written first, it did not build
without the function. It now passes 4 checks each way.
- `scripts/nightly.sh capsule-trust`, a step of `nightly.yml`: a signed build with `v4:centre.4th` left
unsigned (`CAPSULE_TEST_UNSIGN`, `scripts/capsule_unsign.py`, for the test only), booted on amd64. It
must say `missing (unsigned)` and stop with `POST: FAILED`, and give no prompt. It is not a protocol
stage, since a developer has no key. It is first seen in the nightly after this merges.
+9 -8
View File
@@ -6,10 +6,10 @@ the standard first -- FORTH-79, FORTH-83, ANS 1994 -- then v3's table, not v3's
The cases are `v4/system/post_cases.c`; those of the words `capsules/v4/physics.4th` defines The cases are `v4/system/post_cases.c`; those of the words `capsules/v4/physics.4th` defines
need the kernel and are not run by the hosted product. need the kernel and are not run by the hosted product.
POST runs 992 cases. 783 are v3's, with what the hosted v3 binary did as the POST runs 992 cases. 782 are v3's, with what the hosted v3 binary did as the
expected result. This file lists every other case, and why. expected result. This file lists every other case, and why.
## 1. Rewritten: the standard's result, or v3's table's (159) ## 1. Rewritten: the standard's result, or v3's table's (160)
v3 departs from the standard, or the case is written for v3's machine. v4 v3 departs from the standard, or the case is written for v3's machine. v4
follows the standard (standing ruling), so the expected result is the follows the standard (standing ruling), so the expected result is the
@@ -67,7 +67,7 @@ standard's and not v3's.
| `UPDATE.no_block` | `0 SCR ! UPDATE` | error | unchanged | stack `empty`, prints nothing | v3 raises an error FORTH-79 does not ask for | | `UPDATE.no_block` | `0 SCR ! UPDATE` | error | unchanged | stack `empty`, prints nothing | v3 raises an error FORTH-79 does not ask for |
| `SCR.after_load` | `1 LOAD SCR @ . CR` | stack `empty`, printed `1 \n` | unchanged | stack `empty`, prints `1 \n` | v3 prints nothing after 1 LOAD; SCR is still 1 from the LIST before | | `SCR.after_load` | `1 LOAD SCR @ . CR` | stack `empty`, printed `1 \n` | unchanged | stack `empty`, prints `1 \n` | v3 prints nothing after 1 LOAD; SCR is still 1 from the LIST before |
| `FIND.existing` | `FIND DUP . CR` | stack `empty`, printed `7883424 \n` | unchanged | 0 value(s) left; output not compared | FORTH-79: FIND takes the next word, DUP here, and leaves its address, which is printed | | `FIND.existing` | `FIND DUP . CR` | stack `empty`, printed `7883424 \n` | unchanged | 0 value(s) left; output not compared | FORTH-79: FIND takes the next word, DUP here, and leaves its address, which is printed |
| `FIND.user_word` | `: test5 44 ; FIND test5 . CR` | stack `empty`, printed `8206544 \n` | unchanged | 0 value(s) left; output not compared | the address FIND leaves is printed | | `FIND.user_word` | `: test5 44 ; FIND test5 . CR` | stack `empty`, printed varies run to run | unchanged | 0 value(s) left; output not compared | the address FIND leaves is printed |
| `FIND.empty` | `FIND` | error | unchanged | stack `0`, prints nothing | FORTH-79: FIND leaves 0 when there is no word; v3 raises an error | | `FIND.empty` | `FIND` | error | unchanged | stack `0`, prints nothing | FORTH-79: FIND leaves 0 when there is no word; v3 raises an error |
| `VOCABULARY.cross_vocab_access` | `VOCABULARY V1 V1 DEFINITIONS : V1WORD 11 ; FORTH V1WORD . CR` | stack `empty`, printed `11 \n` | unchanged | an error | FORTH-79: a word defined in another vocabulary is not found from FORTH; v3 finds it | | `VOCABULARY.cross_vocab_access` | `VOCABULARY V1 V1 DEFINITIONS : V1WORD 11 ; FORTH V1WORD . CR` | stack `empty`, printed `11 \n` | unchanged | an error | FORTH-79: a word defined in another vocabulary is not found from FORTH; v3 finds it |
| `VOCABULARY.duplicate` | `VOCABULARY TESTVOC VOCABULARY TESTVOC` | error | unchanged | stack `empty`, prints nothing | v3 raises an error FORTH-79 does not ask for: defining a name again | | `VOCABULARY.duplicate` | `VOCABULARY TESTVOC VOCABULARY TESTVOC` | error | unchanged | stack `empty`, prints nothing | v3 raises an error FORTH-79 does not ask for: defining a name again |
@@ -127,8 +127,8 @@ standard's and not v3's.
| `LATEST.basic~2` | `LATEST @ . CR` | stack `empty`, printed `0 \n` | `LATEST 0<> . CR` | stack `empty`, prints `-1 \n` | v3's own word: v3 prints a value of its own machine (its DictEntry); the case as its description has it | | `LATEST.basic~2` | `LATEST @ . CR` | stack `empty`, printed `0 \n` | `LATEST 0<> . CR` | stack `empty`, prints `-1 \n` | v3's own word: v3 prints a value of its own machine (its DictEntry); the case as its description has it |
| `LATEST.after_def` | `: test7 46 ; LATEST @ . CR` | stack `empty`, printed `0 \n` | `: test7 46 ; LATEST ' test7 = . CR` | stack `empty`, prints `-1 \n` | v3's own word: v3 prints a value of its own machine (its DictEntry); the case as its description has it | | `LATEST.after_def` | `: test7 46 ; LATEST @ . CR` | stack `empty`, printed `0 \n` | `: test7 46 ; LATEST ' test7 = . CR` | stack `empty`, prints `-1 \n` | v3's own word: v3 prints a value of its own machine (its DictEntry); the case as its description has it |
| `LATEST.after_forget` | `CREATE test8 FORGET test8 LATEST @ . CR` | stack `empty`, printed `0 \n` | `LATEST CREATE test8 FORGET test8 LATEST = . CR` | stack `empty`, prints `-1 \n` | v3's own word: v3 prints a value of its own machine (its DictEntry); the case as its description has it | | `LATEST.after_forget` | `CREATE test8 FORGET test8 LATEST @ . CR` | stack `empty`, printed `0 \n` | `LATEST CREATE test8 FORGET test8 LATEST = . CR` | stack `empty`, prints `-1 \n` | v3's own word: v3 prints a value of its own machine (its DictEntry); the case as its description has it |
| `>BODY.basic` | `CREATE test9 ' test9 >BODY . CR` | stack `empty`, printed `8207624 \n` | `CREATE test9 FIND test9 >BODY ' test9 = . CR` | stack `empty`, prints `-1 \n` | FORTH-83 >BODY takes a compilation address -- FORTH-79's FIND gives one; FORTH-79's ' gives the parameter field already, so v3's ' xxx >BODY goes one too far. v3 prints an address: the case shows >BODY's field is ''s (and VARIABLE's) | | `>BODY.basic` | `CREATE test9 ' test9 >BODY . CR` | stack `empty`, printed varies run to run | `CREATE test9 FIND test9 >BODY ' test9 = . CR` | stack `empty`, prints `-1 \n` | FORTH-83 >BODY takes a compilation address -- FORTH-79's FIND gives one; FORTH-79's ' gives the parameter field already, so v3's ' xxx >BODY goes one too far. v3 prints an address: the case shows >BODY's field is ''s (and VARIABLE's) |
| `>BODY.variable` | `VARIABLE var1 ' var1 >BODY . CR` | stack `empty`, printed `8208136 \n` | `VARIABLE var1 FIND var1 >BODY var1 = . CR` | stack `empty`, prints `-1 \n` | FORTH-83 >BODY takes a compilation address -- FORTH-79's FIND gives one; FORTH-79's ' gives the parameter field already, so v3's ' xxx >BODY goes one too far. v3 prints an address: the case shows >BODY's field is ''s (and VARIABLE's) | | `>BODY.variable` | `VARIABLE var1 ' var1 >BODY . CR` | stack `empty`, printed varies run to run | `VARIABLE var1 FIND var1 >BODY var1 = . CR` | stack `empty`, prints `-1 \n` | FORTH-83 >BODY takes a compilation address -- FORTH-79's FIND gives one; FORTH-79's ' gives the parameter field already, so v3's ' xxx >BODY goes one too far. v3 prints an address: the case shows >BODY's field is ''s (and VARIABLE's) |
| `ORDER.basic` | `ORDER` | stack `empty`, printed `Search order: (FIND)\nCurrent: (FIND)\n` | unchanged | stack `empty`, prints `Search order: FORTH \nCurrent: FORTH\n` | ANS Forth 16.6.2.1985 ORDER: the form is the system's; v3 names FORTH '(FIND)' -- v4's form with v4's names | | `ORDER.basic` | `ORDER` | stack `empty`, printed `Search order: (FIND)\nCurrent: (FIND)\n` | unchanged | stack `empty`, prints `Search order: FORTH \nCurrent: FORTH\n` | ANS Forth 16.6.2.1985 ORDER: the form is the system's; v3 names FORTH '(FIND)' -- v4's form with v4's names |
| `ORDER.multiple` | `VOCABULARY TEST-VOC9 TEST-VOC9 DEFINITIONS ORDER` | stack `empty`, printed `Search order: TEST-VOC9 (FIND)\nCurrent:` | unchanged | stack `empty`, prints `Search order: TEST-VOC9 FORTH\nCurrent: TEST-VOC9\n` | ANS Forth 16.6.2.1985 ORDER: the form is the system's; v3 names FORTH '(FIND)' -- v4's form with v4's names | | `ORDER.multiple` | `VOCABULARY TEST-VOC9 TEST-VOC9 DEFINITIONS ORDER` | stack `empty`, printed `Search order: TEST-VOC9 (FIND)\nCurrent:` | unchanged | stack `empty`, prints `Search order: TEST-VOC9 FORTH\nCurrent: TEST-VOC9\n` | ANS Forth 16.6.2.1985 ORDER: the form is the system's; v3 names FORTH '(FIND)' -- v4's form with v4's names |
| `ORDER.after_forth` | `TEST-VOC9 FORTH ORDER` | stack `empty`, printed `Search order: (FIND)\nCurrent: (FIND)\n` | unchanged | stack `empty`, prints `Search order: FORTH \nCurrent: FORTH\n` | ANS Forth 16.6.2.1985 ORDER: the form is the system's; v3 names FORTH '(FIND)' -- v4's form with v4's names | | `ORDER.after_forth` | `TEST-VOC9 FORTH ORDER` | stack `empty`, printed `Search order: (FIND)\nCurrent: (FIND)\n` | unchanged | stack `empty`, prints `Search order: FORTH \nCurrent: FORTH\n` | ANS Forth 16.6.2.1985 ORDER: the form is the system's; v3 names FORTH '(FIND)' -- v4's form with v4's names |
@@ -138,12 +138,13 @@ standard's and not v3's.
| `FROZEN?.not_found` | `S" __nonexistent_freeze_xyz__" FROZEN? . CR` | stack `empty`, printed `7229 \n` | unchanged | stack `empty`, prints `0 \n` | v3 prints a number its table's description does not ask for; the description's value | | `FROZEN?.not_found` | `S" __nonexistent_freeze_xyz__" FROZEN? . CR` | stack `empty`, printed `7229 \n` | unchanged | stack `empty`, prints `0 \n` | v3 prints a number its table's description does not ask for; the description's value |
| `HEAT!.basic` | `: __heat_store_test_word__ ; 999 S" __heat_store_test_word__" HEAT! S" __heat_store_test_word__" HEAT@ . CR` | stack `empty`, printed `7289 \n` | unchanged | stack `empty`, prints `999 \n` | v3 prints a number its table's description does not ask for; the description's value | | `HEAT!.basic` | `: __heat_store_test_word__ ; 999 S" __heat_store_test_word__" HEAT! S" __heat_store_test_word__" HEAT@ . CR` | stack `empty`, printed `7289 \n` | unchanged | stack `empty`, prints `999 \n` | v3 prints a number its table's description does not ask for; the description's value |
| `HEAT@.of_fresh_word` | `: __heat_fetch_test_word__ ; S" __heat_fetch_test_word__" HEAT@ . CR` | stack `empty`, printed `7328 \n` | unchanged | stack `empty`, prints `0 \n` | v3 prints a number its table's description does not ask for; the description's value | | `HEAT@.of_fresh_word` | `: __heat_fetch_test_word__ ; S" __heat_fetch_test_word__" HEAT@ . CR` | stack `empty`, printed `7328 \n` | unchanged | stack `empty`, prints `0 \n` | v3 prints a number its table's description does not ask for; the description's value |
| `ENTROPY!.overwrite` | `: ENTOV ; 10 ' ENTOV ENTROPY! 20 ' ENTOV ENTROPY! ' ENTOV ENTROPY@ . CR` | stack `empty`, printed varies run to run | unchanged | stack `empty`, prints `20 \n` | the second ENTROPY! overwrites the first: 20. v3's run printed 20 or 0, as its heartbeat cooled the word between the lines in real time |
| `DECAY-RATE@.basic` | `DECAY-RATE@ . CR` | stack `empty`, printed `0 \n` | unchanged | stack `empty`, prints `1 \n` | v3's own word: the build's DECAY_RATE_PER_US_Q16, 1 by default (v3/Makefile, Kconfig.physics); the v3 that made the table was built with 0 | | `DECAY-RATE@.basic` | `DECAY-RATE@ . CR` | stack `empty`, printed `0 \n` | unchanged | stack `empty`, prints `1 \n` | v3's own word: the build's DECAY_RATE_PER_US_Q16, 1 by default (v3/Makefile, Kconfig.physics); the v3 that made the table was built with 0 |
| `Q.VARIANCE.three_cells` | `100 HERE ! 200 HERE 8 + ! 300 HERE 16 + ! HERE 3 Q.VARIANCE Q.TO-INT . CR` | stack `empty`, printed `6666 \n` | `100 HERE ! 200 HERE 1 + ! 300 HERE 2 + ! HERE 3 Q.VARIANCE Q.TO-INT . CR` | stack `empty`, prints `6666 \n` | v3's address unit is a byte in 8-byte cells; v4's is a cell (D-1): the case in v4's units, a byte address 4 * a cell's | | `Q.VARIANCE.three_cells` | `100 HERE ! 200 HERE 8 + ! 300 HERE 16 + ! HERE 3 Q.VARIANCE Q.TO-INT . CR` | stack `empty`, printed `6666 \n` | `100 HERE ! 200 HERE 1 + ! 300 HERE 2 + ! HERE 3 Q.VARIANCE Q.TO-INT . CR` | stack `empty`, prints `6666 \n` | v3's address unit is a byte in 8-byte cells; v4's is a cell (D-1): the case in v4's units, a byte address 4 * a cell's |
| `INFER-DECAY-SLOPE.three_cells` | `300 HERE ! 200 HERE 8 + ! 100 HERE 16 + ! HERE 3 INFER-DECAY-SLOPE Q.TO-INT . CR` | stack `empty`, printed `0 \n` | `300 HERE ! 200 HERE 1 + ! 100 HERE 2 + ! HERE 3 INFER-DECAY-SLOPE Q.TO-INT . CR` | stack `empty`, prints `0 \n` | v3's address unit is a byte in 8-byte cells; v4's is a cell (D-1): the case in v4's units, a byte address 4 * a cell's | | `INFER-DECAY-SLOPE.three_cells` | `300 HERE ! 200 HERE 8 + ! 100 HERE 16 + ! HERE 3 INFER-DECAY-SLOPE Q.TO-INT . CR` | stack `empty`, printed `0 \n` | `300 HERE ! 200 HERE 1 + ! 100 HERE 2 + ! HERE 3 INFER-DECAY-SLOPE Q.TO-INT . CR` | stack `empty`, prints `0 \n` | v3's address unit is a byte in 8-byte cells; v4's is a cell (D-1): the case in v4's units, a byte address 4 * a cell's |
| `INFER-VARIANCE@.after_run` | `INFER-RUN INFER-VARIANCE@ Q.TO-INT . CR` | stack `empty`, printed `39 \n` | `INFER-RUN INFER-VARIANCE@ Q.TO-INT DROP CR` | stack `empty`, prints `\n` | the value comes of the run's own history, the same on no two runs or machines: the case as its description has it ('no error') | | `INFER-VARIANCE@.after_run` | `INFER-RUN INFER-VARIANCE@ Q.TO-INT . CR` | stack `empty`, printed varies run to run | `INFER-RUN INFER-VARIANCE@ Q.TO-INT DROP CR` | stack `empty`, prints `\n` | the value comes of the run's own history, the same on no two runs or machines: the case as its description has it ('no error') |
| `INFER-WINDOW@.after_run` | `INFER-RUN INFER-WINDOW@ . CR` | stack `empty`, printed `0 \n` | `INFER-RUN INFER-WINDOW@ DROP CR` | stack `empty`, prints `\n` | the value comes of the run's own history, the same on no two runs or machines: the case as its description has it ('no error') | | `INFER-WINDOW@.after_run` | `INFER-RUN INFER-WINDOW@ . CR` | stack `empty`, printed varies run to run | `INFER-RUN INFER-WINDOW@ DROP CR` | stack `empty`, prints `\n` | the value comes of the run's own history, the same on no two runs or machines: the case as its description has it ('no error') |
| `INFER-EARLY-EXIT@.after_run` | `INFER-RUN INFER-EARLY-EXIT@ . CR` | stack `empty`, printed `0 \n` | `INFER-RUN INFER-EARLY-EXIT@ DUP 0= SWAP 1 = OR . CR` | stack `empty`, prints `-1 \n` | the value comes of the run's own history, the same on no two runs or machines: the case as its description has it ('no error') (0 or 1) | | `INFER-EARLY-EXIT@.after_run` | `INFER-RUN INFER-EARLY-EXIT@ . CR` | stack `empty`, printed varies run to run | `INFER-RUN INFER-EARLY-EXIT@ DUP 0= SWAP 1 = OR . CR` | stack `empty`, prints `-1 \n` | the value comes of the run's own history, the same on no two runs or machines: the case as its description has it ('no error') (0 or 1) |
| `Q.1.raw_value` | `Q.1 . CR` | stack `empty`, printed `65536 \n` | `Q.1 D. CR` | stack `empty`, prints `65536 \n` | Q48.16 on v4 is a double, low cell then high (ruled 2026-11-14): its raw value printed with D. | | `Q.1.raw_value` | `Q.1 . CR` | stack `empty`, printed `65536 \n` | `Q.1 D. CR` | stack `empty`, prints `65536 \n` | Q48.16 on v4 is a double, low cell then high (ruled 2026-11-14): its raw value printed with D. |
| `Q.0.raw_value` | `Q.0 . CR` | stack `empty`, printed `0 \n` | `Q.0 D. CR` | stack `empty`, prints `0 \n` | Q48.16 on v4 is a double, low cell then high (ruled 2026-11-14): its raw value printed with D. | | `Q.0.raw_value` | `Q.0 . CR` | stack `empty`, printed `0 \n` | `Q.0 D. CR` | stack `empty`, prints `0 \n` | Q48.16 on v4 is a double, low cell then high (ruled 2026-11-14): its raw value printed with D. |
| `Q.SCALE.raw_value` | `Q.SCALE . CR` | stack `empty`, printed `65536 \n` | `Q.SCALE D. CR` | stack `empty`, prints `65536 \n` | Q48.16 on v4 is a double, low cell then high (ruled 2026-11-14): its raw value printed with D. | | `Q.SCALE.raw_value` | `Q.SCALE . CR` | stack `empty`, printed `65536 \n` | `Q.SCALE D. CR` | stack `empty`, prints `65536 \n` | Q48.16 on v4 is a double, low cell then high (ruled 2026-11-14): its raw value printed with D. |
@@ -0,0 +1,94 @@
# Capsule trust: no unsigned capsule on a signed build (#139) -- design, for ruling
Written 2026-11-20. **Built 2026-11-20** (section "Built", below; FABRIC-3 XLIX).
## The rulings (Captain Bob, 2026-11-20, one at a time)
1. **The anchor: "Intermediate is the anchor; no root check."** The "StarshipOS Capsule Signing"
certificate built into the image (`capsules/pki/starshipos-intermediate.der`, FABRIC-3 XLVI, ruled
2026-11-07) is what the capsules are trusted by. The kernel does not check it against the StarshipOS
Root CA, and no root key is put in the kernel or in CI.
- First ruled "Yes, verify at boot". Then, asked where CI should take the root's public certificate
from, Captain Bob: "Actually we decided to include an intermediate certificate in the kernel" --
XLVI's decision -- and the root check was withdrawn.
- On the way it was found that the root's private key is on the CI server, beside its certificate, in
`/var/lib/starshipos-ca/root/` (mode 700). The root's public certificate is also in the tree,
`ci/pki/starshipos-root-ca.pem`.
2. **"Refuse on signed builds."** A kernel built with the signing key (CI, releases) refuses an unsigned
capsule at boot. A developer build without the key keeps the warning, so local work still boots.
3. **A certificate that cannot be read: "NO_ROOT_KEY, by build."** If the image's signing certificate is
missing or does not parse, every capsule is NO_ROOT_KEY, with a line saying why. A signed build
refuses it, as it refuses MISSING; an unsigned build warns and boots.
## What is there
- `kernel/src/capsule/capsule_sig.c` gives each capsule a result: OK, MISSING, INVALID or NO_ROOT_KEY.
The callers refuse INVALID only (`capsule_sig.h`, ruled 2026-08-26, when CI had no key).
- The callers: v4's boot (`v4/system/boot.c:345`, each capsule it loads) and v3's birth
(`kernel/src/capsule/capsule_birth.c`, three places).
- The build signs only when `SIGN_KEY` is set (`kernel/Makefile`, `v4/Makefile`): CI sets it from the
secret `CAPSULE_SIGN_KEY`. The gate into master and a release already refuse an unsigned build (#174).
## The design
1. **One decision, in one place:** `capsule_sig_refused(result)` in `capsule_sig.c`. INVALID is always
refused. MISSING and NO_ROOT_KEY are refused when the build is signed, and warned of otherwise. Every
caller asks it, instead of testing for INVALID itself. Each caller still says why: "missing
(unsigned)", "invalid", "no signing certificate".
2. **A signed build** is compiled with `-DCAPSULE_SIGNED_BUILD=1`, set by the kernel's and v4's Makefiles
exactly when they pass `--sign-key` to mkcapsule. So the flag and the signatures always agree.
3. **`capsule_sig.h`'s comment** (the 2026-08-26 reason MISSING was a warning) is corrected, dated, and
FABRIC-3 gets the ruling.
4. **Tests, written first:**
- A host test of `capsule_sig_refused` built both ways: on a signed build MISSING, INVALID and
NO_ROOT_KEY are refused and OK is not; on an unsigned build only INVALID is.
- **The boots on the three architectures:** the acceptance runs, signed in CI, show a signed build
booting, as today. A signed build with one capsule unsigned is refused at that capsule. An unsigned
developer build still boots, with its warnings.
## Ruled
4. **The refused-capsule boot: "Left to CI".** CI has the real key. A job builds signed, strips one
capsule's signature, and expects the boot refused at that capsule. This container has no key, so that
boot is CI's, and the host test and the boots here cover the rest. Asked: that, or a throwaway CA made
here, its intermediate standing in for the real one in a test build.
## Built (2026-11-20)
As the design, with one difference in step 4: the refused-capsule boot is CI's (ruling 4).
`scripts/nightly.sh capsule-trust`, in `nightly.yml`, builds signed with `CAPSULE_TEST_UNSIGN=v4:centre.4th`
(`scripts/capsule_unsign.py` takes that one signature out after mkcapsule), and boots amd64 in the session's
`unsigned_capsule` mode. It expects the capsule's "missing (unsigned)" line, `POST: FAILED` and no prompt.
- **Checked here:** the mode refuses to run without `SIGN_KEY`. The script unsigns only the capsule named,
and refuses one that is not signed and one that is not there.
- **To see in CI:** the boot itself, in the first nightly after the merge.
`kernel/tests/test_capsule_sig.c` (and `_signed.c`) was written first and did not build without
`capsule_sig_refused`. It now passes 4 checks on each build (`logs/20261120-capsule-trust/`).
## Given for ADR step 4, when capsules carry trains (Captain Bob, 2026-11-20)
Recorded as given, to design from at step 4 ("Integrity, provenance, and reproducibility checks" and the
carrying of artifacts in capsules). Nothing of it is built.
- **The capsule is a train:** "we are evolving to capsules with the v4 runtime engine towing rolling stock
named blobs". The engine is the train's `.f18a`, and the cars are its named blobs (ABI.md, "one train
per capsule").
- **Each blob is signed by its author and hashed:** "Each blob in the capsule is signed by the author and
hashed. The MANIFEST.md inside the capsule will hold each named blobs hash."
- **The authors:** "Bonafide contributors will have their own intermediate certificate and 'casual' users
get a snakeoil cert." StarshipOS's own trains are signed with the StarshipOS Capsule Signing certificate,
as today.
- **How they are told apart:** "It can tell the intermediate cert from a snakeoil because it has an
intermediate chained to the CA." So at step 4 the kernel checks an author's intermediate against the
StarshipOS Root CA's public key, anchored in the kernel. The public certificate is in the tree
(`ci/pki/starshipos-root-ca.pem`, with its published hash); the root's private key stays on the server.
This is the chain check ruling 1 leaves out for now, for the one system certificate. It comes in with
contributors' trains.
**For step 4's design, to be asked one at a time then:**
- whether `MANIFEST.md` is itself a signed blob, so its hashes are trusted;
- what placement does with a blob whose hash differs from its manifest's;
- what each tier is allowed: StarshipOS, a contributor, a snakeoil user. `contrib_capsule_refused()`
(`capsule_birth.c`, FABRIC-2 I.5) is where tiers began.
+7 -1
View File
@@ -249,6 +249,11 @@ MKARTEMIS_BIN = $(BUILD_DIR)/tools/mkartemis
# which boots with a warning per capsule. mkcapsule refuses a key that is not the certificate's. # which boots with a warning per capsule. mkcapsule refuses a key that is not the certificate's.
SIGN_KEY ?= SIGN_KEY ?=
SIGN_KEY_ARGS = $(if $(wildcard $(SIGN_KEY)),--sign-key $(SIGN_KEY),) SIGN_KEY_ARGS = $(if $(wildcard $(SIGN_KEY)),--sign-key $(SIGN_KEY),)
# #139: a kernel whose capsules are signed refuses an unsigned one (capsule_sig.h)
CAPSULE_SIGNED_DEF = $(if $(wildcard $(SIGN_KEY)),-DCAPSULE_SIGNED_BUILD=1,)
# For the test only (#139, scripts/qemu_session.py unsigned_capsule): a signed build with this one capsule's
# signature taken out after mkcapsule, which the kernel must refuse. Never set for a build that ships.
CAPSULE_TEST_UNSIGN ?=
CAPSULE_GENERATED = $(BUILD_DIR)/capsule_generated.c CAPSULE_GENERATED = $(BUILD_DIR)/capsule_generated.c
CAPSULE_GENERATED_OBJ = $(BUILD_DIR)/capsule_generated.o CAPSULE_GENERATED_OBJ = $(BUILD_DIR)/capsule_generated.o
CAPSULE_GENERATED_KOBJ = $(KERNEL_OBJ_DIR)/capsule_generated.o CAPSULE_GENERATED_KOBJ = $(KERNEL_OBJ_DIR)/capsule_generated.o
@@ -435,7 +440,7 @@ DOE_SEED ?= 12345
# production default (Kconfig.heartbeat's own default n, same decision). # production default (Kconfig.heartbeat's own default n, same decision).
$(eval $(call kconfig_bool,EMERGENCY_CONSOLE_ENABLED,0)) $(eval $(call kconfig_bool,EMERGENCY_CONSOLE_ENABLED,0))
LOADER_CFLAGS := $(LOADER_BASE_CFLAGS) -I$(KERNEL_SRC)/vm LOADER_CFLAGS := $(LOADER_BASE_CFLAGS) -I$(KERNEL_SRC)/vm
KERNEL_CFLAGS := $(COMMON_CFLAGS) -D__STARKERNEL__ -I$(KERNEL_SRC)/vm KERNEL_CFLAGS := $(COMMON_CFLAGS) -D__STARKERNEL__ -I$(KERNEL_SRC)/vm $(CAPSULE_SIGNED_DEF)
# Linker flags # Linker flags
ifeq ($(ARCH),aarch64) ifeq ($(ARCH),aarch64)
@@ -859,6 +864,7 @@ $(CAPSULE_GENERATED): $(MKCAPSULE_BIN) $(CAPSULE_SRCS)
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@echo " MKCAP $(CAPSULES_DIR) -> $@" @echo " MKCAP $(CAPSULES_DIR) -> $@"
@$(MKCAPSULE_BIN) $(SIGN_KEY_ARGS) $(CAPSULES_DIR) $@ @$(MKCAPSULE_BIN) $(SIGN_KEY_ARGS) $(CAPSULES_DIR) $@
@$(if $(CAPSULE_TEST_UNSIGN),python3 scripts/capsule_unsign.py $@ $(CAPSULE_TEST_UNSIGN),:)
@echo " MKCAP $(CAPSULES_DIR) -> $(CAPSULES_DIR)/BLOCK_MAP.md" @echo " MKCAP $(CAPSULES_DIR) -> $(CAPSULES_DIR)/BLOCK_MAP.md"
@$(MKCAPSULE_BIN) --manifest $(SIGN_KEY_ARGS) $(CAPSULES_DIR) $(CAPSULES_DIR)/BLOCK_MAP.md @$(MKCAPSULE_BIN) --manifest $(SIGN_KEY_ARGS) $(CAPSULES_DIR) $(CAPSULES_DIR)/BLOCK_MAP.md
+18
View File
@@ -8,6 +8,14 @@
* signature/behavior stays untouched; this is a new, additive check * signature/behavior stays untouched; this is a new, additive check
* called alongside it, not folded into it. * called alongside it, not folded into it.
* *
* Which results are refused is capsule_sig_refused()'s, the one decision every caller asks (#139,
* docs/v4.0.0/plans/2026-11-20-capsule-trust.md, ruled 2026-11-20): INVALID on every build; MISSING
* and NO_ROOT_KEY as well on a signed build (CAPSULE_SIGNED_BUILD 1, set by kernel/Makefile and
* v4/Makefile exactly when they sign the capsules). A developer build, without the key, warns of them
* and boots. The anchor is the signing certificate in the image (FABRIC-3 XLVI): it is not checked
* against the root CA (ruled 2026-11-20). Corrected 2026-11-20: until then, as below, only INVALID
* was refused on any build.
*
* Enforced ONLY on CAPSULE_SIG_INVALID (2026-08-26, after landing * Enforced ONLY on CAPSULE_SIG_INVALID (2026-08-26, after landing
* WARN-only and proving correct on all three architectures against both * WARN-only and proving correct on all three architectures against both
* a valid and a deliberately-corrupted capsule -- see FABRIC-2.md's * a valid and a deliberately-corrupted capsule -- see FABRIC-2.md's
@@ -31,6 +39,12 @@
* mkcapsule refuses to sign with a key that is not this certificate's. */ * mkcapsule refuses to sign with a key that is not this certificate's. */
#define CAPSULE_SIGNING_CERT_NAME "pki:starshipos-intermediate.der" #define CAPSULE_SIGNING_CERT_NAME "pki:starshipos-intermediate.der"
/* 1 when the kernel is built with the signing key (kernel/Makefile, v4/Makefile): its capsules are
* signed, so an unsigned one, or no certificate to check by, is refused (#139). */
#ifndef CAPSULE_SIGNED_BUILD
#define CAPSULE_SIGNED_BUILD 0
#endif
typedef enum { typedef enum {
CAPSULE_SIG_OK = 0, /* has_sig=1, and it verifies */ CAPSULE_SIG_OK = 0, /* has_sig=1, and it verifies */
CAPSULE_SIG_MISSING, /* has_sig=0 -- not signed at all */ CAPSULE_SIG_MISSING, /* has_sig=0 -- not signed at all */
@@ -58,4 +72,8 @@ CapsuleSigResult capsule_verify_signature(
* capsule_validate_result_str()'s existing shape. */ * capsule_validate_result_str()'s existing shape. */
const char *capsule_sig_result_str(CapsuleSigResult result); const char *capsule_sig_result_str(CapsuleSigResult result);
/* 1 if a capsule with this result is refused (#139): INVALID always; MISSING and NO_ROOT_KEY on a
* signed build (CAPSULE_SIGNED_BUILD). Every caller asks this rather than testing a result itself. */
int capsule_sig_refused(CapsuleSigResult result);
#endif /* STARKERNEL_CAPSULE_SIG_H */ #endif /* STARKERNEL_CAPSULE_SIG_H */
+3 -3
View File
@@ -593,7 +593,7 @@ CapsuleRunResult capsule_birth_mama(
if (sr != CAPSULE_SIG_OK) { if (sr != CAPSULE_SIG_OK) {
log_message(LOG_WARN, "capsule sig: %s: %s", log_message(LOG_WARN, "capsule sig: %s: %s",
names[idx].name, capsule_sig_result_str(sr)); names[idx].name, capsule_sig_result_str(sr));
if (sr == CAPSULE_SIG_INVALID) return CAPSULE_RUN_ERR_INVALID; if (capsule_sig_refused(sr)) return CAPSULE_RUN_ERR_INVALID;
} }
} }
@@ -674,7 +674,7 @@ CapsuleRunResult capsule_birth_baby(
if (sr != CAPSULE_SIG_OK) { if (sr != CAPSULE_SIG_OK) {
log_message(LOG_WARN, "capsule sig: %s: %s", log_message(LOG_WARN, "capsule sig: %s: %s",
names[idx].name, capsule_sig_result_str(sr)); names[idx].name, capsule_sig_result_str(sr));
if (sr == CAPSULE_SIG_INVALID) return CAPSULE_RUN_ERR_INVALID; if (capsule_sig_refused(sr)) return CAPSULE_RUN_ERR_INVALID;
} }
/* FABRIC-2.md §I.5: contrib trust tier -- see contrib_capsule_ /* FABRIC-2.md §I.5: contrib trust tier -- see contrib_capsule_
* refused()'s own doc comment. */ * refused()'s own doc comment. */
@@ -940,7 +940,7 @@ CapsuleRunResult capsule_run_experiment(
if (sr != CAPSULE_SIG_OK) { if (sr != CAPSULE_SIG_OK) {
log_message(LOG_WARN, "capsule sig: %s: %s", log_message(LOG_WARN, "capsule sig: %s: %s",
names[idx].name, capsule_sig_result_str(sr)); names[idx].name, capsule_sig_result_str(sr));
if (sr == CAPSULE_SIG_INVALID) return CAPSULE_RUN_ERR_INVALID; if (capsule_sig_refused(sr)) return CAPSULE_RUN_ERR_INVALID;
} }
/* FABRIC-2.md §I.5: contrib trust tier -- see contrib_capsule_ /* FABRIC-2.md §I.5: contrib trust tier -- see contrib_capsule_
* refused()'s own doc comment. */ * refused()'s own doc comment. */
+11
View File
@@ -67,3 +67,14 @@ const char *capsule_sig_result_str(CapsuleSigResult result) {
default: return "unknown"; default: return "unknown";
} }
} }
int capsule_sig_refused(CapsuleSigResult result)
{
switch (result) {
case CAPSULE_SIG_OK: return 0;
case CAPSULE_SIG_INVALID: return 1;
case CAPSULE_SIG_MISSING:
case CAPSULE_SIG_NO_ROOT_KEY: return CAPSULE_SIGNED_BUILD;
}
return 1; /* not a result this code knows: refused */
}
+5 -1
View File
@@ -19,7 +19,7 @@ CC ?= cc
CFLAGS := -std=c99 -Wall -Wextra -Werror -O2 -g -I$(HERE) -I$(ROOT)/kernel/include \ CFLAGS := -std=c99 -Wall -Wextra -Werror -O2 -g -I$(HERE) -I$(ROOT)/kernel/include \
-I$(ROOT)/kernel/include/starkernel -I$(ROOT)/v3/include -I$(ROOT)/kernel/include/starkernel -I$(ROOT)/v3/include
TESTS := test_heartbeat test_gpt test_usb_config test_sk_v4_stop test_sk_v4_slots test_sk_v4_mint test_sk_v4_identity test_heartbeat_export test_ssm_jacquard test_physics_l2 test_stadium_node test_stadium_ops test_stadium_words TESTS := test_capsule_sig test_capsule_sig_signed test_heartbeat test_gpt test_usb_config test_sk_v4_stop test_sk_v4_slots test_sk_v4_mint test_sk_v4_identity test_heartbeat_export test_ssm_jacquard test_physics_l2 test_stadium_node test_stadium_ops test_stadium_words
# the one adaptive heartbeat paces itself (plan 2026-11-17-one-adaptive-heartbeat): heartbeat.c, its Q48.16, and the # the one adaptive heartbeat paces itself (plan 2026-11-17-one-adaptive-heartbeat): heartbeat.c, its Q48.16, and the
# v4 inference arithmetic its slope provider runs # v4 inference arithmetic its slope provider runs
SRC_test_heartbeat := $(ROOT)/kernel/src/heartbeat.c $(ROOT)/kernel/src/math/q48_16.c $(ROOT)/v4/system/inference.c SRC_test_heartbeat := $(ROOT)/kernel/src/heartbeat.c $(ROOT)/kernel/src/math/q48_16.c $(ROOT)/v4/system/inference.c
@@ -40,6 +40,10 @@ EXTRA_test_sk_v4_mint := -D__STARKERNEL__ -I$(ROOT)/v4/include
SRC_test_sk_v4_slots := $(ROOT)/kernel/src/v4/sk_v4_slots.c SRC_test_sk_v4_slots := $(ROOT)/kernel/src/v4/sk_v4_slots.c
SRC_test_sk_v4_stop := $(ROOT)/kernel/src/v4/sk_v4_stop.c SRC_test_sk_v4_stop := $(ROOT)/kernel/src/v4/sk_v4_stop.c
SRC_test_gpt := $(ROOT)/kernel/src/gpt.c SRC_test_gpt := $(ROOT)/kernel/src/gpt.c
# #139: the signature results the kernel refuses, on a developer build and a signed one
SRC_test_capsule_sig := $(ROOT)/kernel/src/capsule/capsule_sig.c $(addprefix $(ROOT)/kernel/src/crypto/,x509_ed25519.c ed25519.c fe25519.c scalar25519.c sha512.c)
SRC_test_capsule_sig_signed := $(SRC_test_capsule_sig)
EXTRA_test_capsule_sig_signed := -DCAPSULE_SIGNED_BUILD=1
SRC_test_usb_config := $(ROOT)/kernel/src/usb/usb_config.c SRC_test_usb_config := $(ROOT)/kernel/src/usb/usb_config.c
define TEST_RULE define TEST_RULE
+27
View File
@@ -0,0 +1,27 @@
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
* Copyright (c) 2023-2026 Robert A. James
*/
/* test_capsule_sig.c -- which capsule signature results the kernel refuses (#139;
* docs/v4.0.0/plans/2026-11-20-capsule-trust.md, ruled 2026-11-20): capsule_sig_refused(), the one
* decision every caller asks. INVALID is refused on every build. A signed build (built with the
* signing key, CAPSULE_SIGNED_BUILD 1) also refuses MISSING and NO_ROOT_KEY; a build without the key
* warns of them and boots. Built twice: as here, unsigned, and as test_capsule_sig_signed.c.
*/
#include "harness.h"
#include "starkernel/capsule_sig.h"
#ifndef CAPSULE_SIGNED_BUILD
#define CAPSULE_SIGNED_BUILD 0
#endif
int main(void)
{
printf("capsule_sig_refused, a %s build\n", CAPSULE_SIGNED_BUILD ? "signed" : "developer (unsigned)");
CHECK(!capsule_sig_refused(CAPSULE_SIG_OK), "a good signature is never refused");
CHECK(capsule_sig_refused(CAPSULE_SIG_INVALID), "a signature that does not verify is always refused");
CHECK(capsule_sig_refused(CAPSULE_SIG_MISSING) == CAPSULE_SIGNED_BUILD,
"an unsigned capsule: refused on a signed build, warned of on a developer build");
CHECK(capsule_sig_refused(CAPSULE_SIG_NO_ROOT_KEY) == CAPSULE_SIGNED_BUILD,
"no signing certificate to check by: refused on a signed build, warned of on a developer build");
return DONE();
}
+6
View File
@@ -0,0 +1,6 @@
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
* Copyright (c) 2023-2026 Robert A. James
*/
/* test_capsule_sig_signed.c -- test_capsule_sig.c on a signed build (CAPSULE_SIGNED_BUILD 1, from the
* Makefile's EXTRA, as the kernel's build sets it with the signing key). */
#include "test_capsule_sig.c"

Some files were not shown because too many files have changed in this diff Show More