Fixes from the third Supermarket run: coreapp mail, route wait, skill edges

coreapp mail shows what the Core's mail server did with the app's mail
(from its log: accepted, delivered, deferred or bounced). Deploy waits
until traefik routes the public address, so it doesn't answer 404 just
after "Updated". The skill's settings rules no longer contradict, the
lowest role means read-only, the Core's admin gets no local password or
reset, and SQLite may need allowing in an app's multi-user edition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 19:36:28 -07:00
co-authored by Claude Opus 5.5
parent d860dd9200
commit 2d29ca62b3
6 changed files with 135 additions and 15 deletions
+17
View File
@@ -450,6 +450,23 @@ Steps:
versions, which PostgreSQL extensions an app can enable: the
trusted ones; pgvector needs a superuser), and `coreapp core`
prints it live from the Core
- Run 3, 2026-12-03 (after the table): deployed with SQLite in
`/data` (told by the skill this time), sso and email; the Core's
admin is owner; other Core accounts join with nothing. Fixed from
it: the skill's two settings rules no longer contradict (upstream
`ENV` in an entrypoint: override; the app's own code: Core values
as defaults); deploy waits until traefik routes the public address
(it answered 404 for a moment after "Updated"); `coreapp mail`
shows what the Core's mail server did with the app's mail (from
the mail log: accepted, delivered/deferred/bounced); the skill says
the lowest role means read-only, not nothing; the Core's admin has
no local password or reset; an app's SQLite mode may need allowing
in its multi-user edition; `coreapp status` shows a database
version only for apps with one; signin runs in the app's folder;
deploy's last line no longer says "from the internet"
- [ ] A mailbox for the test account (`coreapp.test`), so mail to
it is delivered and `coreapp mail` could read it; needs the
Core's mailbox conventions (uidNumber, homeDirectory)
- [ ] `[postgres] extensions = ["vector"]`: the installer enables
extensions an app can't (when an app needs one)
- [ ] PostgreSQL 18 on the Core (Federated's), or a minimum version
+1
View File
@@ -89,6 +89,7 @@ each new app explains the files and the settings it gets.
| `coreapp deploy [--recreate]` | Build its image, copy it to the Core over SSH, install it, or update it keeping its settings and data; a failed update rolls back to the version before (`--recreate`: a fresh container even if nothing changed) |
| `coreapp check` | It answers at `https://<name>.<domain><health>` with a valid certificate |
| `coreapp core` | What the Core in the VM offers apps: PostgreSQL (and which extensions an app can enable), MariaDB, Authelia, the mail server and Traefik with their versions, Docker, and the machine |
| `coreapp mail` | What the Core's mail server did with the mail the app sent in the last day: accepted from its account, then delivered, deferred or bounced, with the reason (apps with `email`) |
| `coreapp signin [path]` | Sign in to it as a browser would, with the Core's test account (`coreapp.test@<domain>`, made on the VM's Core when first needed), starting at `path` (default `/login`), and show each step; `--cookies <file>` keeps the app's cookies, `--code` gets a code for apps that start sign-in in the browser, `--remove-account` removes the account |
| `coreapp status` / `logs [-f]` / `shell [command]` | Its container, its log, a shell in it (or one command, without a terminal) |
| `coreapp list` | The apps on the Core installed this way |
+10 -1
View File
@@ -208,7 +208,10 @@ The Core's own scripts trace secrets, so their output goes to
5. Raise `version` to 0.2.0, `coreapp deploy`: "Updated"; the container
runs `:0.2.0`; `docker image ls localhost/coreapp/hello` on the Core lists
only 0.2.0.
5a. An app that answers 421 to an unknown `Host` (Supermarket): deploy's
5a. Right after "Updated" (also with `--recreate`), the public address
answers (deploy waits until traefik routes it, not 404): `curl
https://<name>.<domain><health>` four times in a row gives 200 each time.
An app that answers 421 to an unknown `Host` (Supermarket): deploy's
wait passes because it sends `Host: <name>.<domain>`; on the Core, curl
of its health URL gives 421 bare, 200 with that `Host`.
5b. `coreapp core` (anywhere, no app needed): the domain, PostgreSQL's
@@ -415,6 +418,12 @@ has the `DB_*` variables, `.coreapp` says `needs=postgres`.
entry is unchanged (its password too), and remove leaves it.
6. Adding `"email"` to an installed app's `needs` and deploying makes the
account and adds the `SMTP_*` settings.
7. `coreapp mail` after the app sent a message (Supermarket: a password
reset for `coreapp.test@<domain>`): "<time> from <name>@<domain>,
accepted", then "to coreapp.test@<domain>: deferred (... 451 4.3.0 ...
Temporary internal error ...)" (the test account has no mailbox), one
line per message even after retries. No mail in the last day: "has no
mail from <name>". In an app without "email": refused.
### With both
+13 -1
View File
@@ -13,6 +13,9 @@
# coreapp status its container, address and URL
# coreapp logs [-f] its log
# coreapp shell [command] a shell in its container, or run one command there
# coreapp mail what the Core's mail server did with the mail the
# app sent in the last day (accepted, delivered,
# deferred, bounced; apps with "email")
# coreapp core what the Core in the VM offers apps: its database,
# sign-in and mail servers with their versions,
# PostgreSQL extensions, and the machine
@@ -277,7 +280,7 @@ cmd_deploy() {
# Install, or update (which recreates the container if the image changed,
# even under the same version)
installer install $addon $recreate || exit 1
[[ "$state" == new ]] && echo "(coreapp check tests it from the internet.)"
[[ "$state" == new ]] && echo "(coreapp check tests it at its public address, as people reach it.)"
return 0
}
@@ -403,6 +406,14 @@ cmd_signin() {
fi
}
cmd_mail() {
load_app
[[ " $NEEDS " == *" email "* ]] \
|| die "$NAME doesn't send mail through the Core (no \"email\" in coreapp.toml's needs)."
sync_installer
core "$REMOTE_INSTALLER/coreapps mail $NAME"
}
cmd_core() {
init_core
sync_installer
@@ -615,6 +626,7 @@ case "$cmd" in
shell) cmd_shell "$@" ;;
signin) cmd_signin "$@" ;;
core) cmd_core ;;
mail) cmd_mail ;;
remove | rm) cmd_remove ;;
list | ls) cmd_list ;;
publish) cmd_publish "$@" ;;
+62
View File
@@ -23,6 +23,8 @@ coreapps login <host> <user> keep a token (read from stdin) for
installing private apps from host
coreapps logout <host> forget host's token
coreapps logins the hosts this Core has tokens for
coreapps mail <name> what the Core's mail server did with the
mail the app sent in the last day
coreapps core what this Core offers apps: its services
and their versions, and the machine
coreapps test-account [--remove] make (or refresh, with the password on
@@ -875,6 +877,7 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
# installapp's start step only knows Federated's own apps
compose_up(m, log)
wait_until_answering(m, p)
wait_for_route(m, p)
else:
before = service_value(f"{APPS}/{name}/.env", "IMAGE_VERSION")
if before == m["version"]:
@@ -899,6 +902,7 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
raise Refused(f"Updating failed (whole log on the Core: {log}).")
compose_up(m, log, recreate)
wait_until_answering(m, p)
wait_for_route(m, p)
except (Exception, KeyboardInterrupt) as e:
say(f"{e}" if isinstance(e, Refused) else f"Updating failed: {e!r}")
raise Refused(roll_back(m, p, backup, log)) from e
@@ -1176,6 +1180,21 @@ def wait_until_answering(m, p):
"its log is above).")
def wait_for_route(m, p):
"""Until traefik routes https://<name>.<domain> to the new container
(it answers 404 for a few seconds after a container starts)."""
host = f"{m['name']}.{p['domain']}"
traefik = service_value(os.path.join(SERVICES, "traefik", "service"), "INTERNAL_IP")
if not traefik:
return
for _ in range(30):
code = run(["curl", "-sk", "-o", "/dev/null", "-w", "%{http_code}", "--max-time", "3",
"--resolve", f"{host}:443:{traefik}", f"https://{host}{m['health']}"]).stdout
if code not in ("", "000", "404", "502", "503"):
return
time.sleep(1)
say(f"Note: traefik doesn't route https://{host}/ to it yet; it may take a moment.")
def update(name, addon_ok):
"""An app installed from a repository, to its newest release."""
@@ -1301,6 +1320,47 @@ def core_info():
return 0
# --- The app's mail (coreapp mail) ---------------------------------------------------
def app_mail(name, since="24h"):
"""What the Core's mail server did with the mail the app sent: accepted
from its account, then delivered, deferred or bounced, per recipient."""
if not re.fullmatch(FIELDS["name"], name) or not is_ours(name):
raise Refused(f"No app called '{name}' installed by coreapps on this Core.")
out = run(["docker", "logs", "--since", since, "mail"])
lines = (out.stdout + out.stderr).splitlines()
account = re.compile(r" ([0-9A-F]{6,}): client=\S+, sasl_method=\S+, sasl_username=coreapp-"
+ re.escape(name) + r"@")
ids = {}
for line in lines:
found = account.search(line)
if found:
ids[found.group(1)] = line[:19].replace("T", " ")
if not ids:
say(f"The Core's mail server has no mail from {name} in the last {since} "
f"(from its account, coreapp-{name}).")
return 0
for qid, when in list(ids.items())[-20:]:
sender, results = "", []
for line in lines:
if f" {qid}: " not in line:
continue
found = re.search(r"from=<([^>]*)>", line)
if found and not sender:
sender = found.group(1)
found = re.search(r"to=<([^>]*)>.*status=(\w+)(?: \((.*)\))?", line)
if found:
to, status, why = found.groups()
results.append(f" to {to}: {status}"
+ (f" ({why[:160]})" if why and status != "sent" else ""))
say(f"{when} from {sender or '?'}, accepted")
for r in dict.fromkeys(results):
say(r)
if not results:
say(" (no delivery yet)")
return 0
# --- The test account (coreapp signin) ---------------------------------------------
# A person in the Core's LDAP that coreapp signin signs in with, on a
@@ -1429,6 +1489,8 @@ def main(args):
return list_logins()
if cmd == "list" and not rest:
return list_apps()
if cmd == "mail" and len(rest) == 1:
return app_mail(rest[0])
if cmd == "core" and not rest:
return core_info()
if cmd == "test-account" and rest in ([], ["--remove"]):
+32 -13
View File
@@ -127,7 +127,10 @@ using it runs, so deploy, `coreapp check` and a sign-in can all pass.
What's inside the image is the app's own: its language runtime, SQLite and
other libraries are whatever the Dockerfile installs, not the Core's.
SQLite in `/data` is a fine database for an app that supports it.
SQLite in `/data` is a fine database for an app that supports it. An
app's SQLite mode is often its single-user mode, though: if its multi-user
edition insists on PostgreSQL or MySQL, allow SQLite there when it runs on
a Core (`CORE_DOMAIN` set), rather than using the single-user edition.
## Needs
@@ -142,8 +145,8 @@ The Core makes a PostgreSQL user and database just for this app, and adds:
| `DB_NAME`, `DB_USER` | `coreapp_<name>` with `-` as `_` (e.g. `coreapp_my_app`) |
| `DB_PASSWORD` | random |
The server is PostgreSQL 17 (17.6 today; `coreapp status` shows the Core's
version), shared with the Core's other apps; the app owns its database and
The server is PostgreSQL 17 (17.6 today; `coreapp core` shows the Core's
version, and `coreapp status` once the app needs it), shared with the Core's other apps; the app owns its database and
nothing else. Check what version the app needs before choosing this (its
docs, its own compose file's `postgres:` image, its migrations): features
of a newer PostgreSQL fail only when the code that uses them runs, so a
@@ -236,14 +239,18 @@ may log; it should retry).
link), skip it on a Core: the Core's admin is the owner. If the app can't
run without an owner (its pages say "not set up" until there is one),
make `CORE_ADMIN_EMAIL` the owner at startup, without a password; it
signs in with the Core. The example app
signs in with the Core. That account signs in only with the Core: turn
off the app's password sign-in and password reset for it, or its
forgot-password page could give it a local password. The example app
(`coreapp new --sso`) shows the check in `oidc.py`. `coreapp signin`
signs in as the test account, not the admin, so ask the user to sign in
once as `admin@<domain>` in a browser and check it gets the admin pages.
- **Everyone else gets the lowest role.** Any other Core account (a person
at the company) may sign in, with no invitation, and gets the app's
lowest role (viewer, or whatever can do least). The app's admins raise
people from there in the app. Don't hand out more by default, and don't
lowest role that can still look around: read-only, seeing what the app
shows its members but changing nothing (a viewer). Not "nothing until an
admin grants access": they should find the app useful to look at. The
app's admins raise people from there in the app. Don't hand out more by default, and don't
require invitations for Core accounts. `coreapp signin` checks this: the
test account should land with that role.
- Discovery: `$OIDC_ISSUER/.well-known/openid-configuration`. The Core
@@ -280,9 +287,13 @@ isn't delivered anywhere (the account has no mailbox), so set a reply-to
if people should be able to answer. The account can't sign in to anything
else on the Core. `coreapp new --email` adds the need (there's no example
app for it). There's no inbox to check that a test message arrived: send
one the app's usual way (e.g. a password reset for `coreapp.test@<domain>`)
and check `coreapp logs` for mail errors; ask the user to confirm delivery
to a real address.
one the app's usual way (e.g. a password reset for `coreapp.test@<domain>`),
then `coreapp mail`: what the Core's mail server did with each message from
the app's account in the last day (accepted, then delivered, deferred or
bounced, with the reason). Mail to `coreapp.test@<domain>` is accepted and
then deferred ("451 ... Temporary internal error"), because the test
account has no mailbox; that's expected and shows the app's sending
works. Ask the user to confirm delivery to a real address.
### Not available yet
@@ -350,9 +361,12 @@ and make the Dockerfile fit the Core:
them too, not only the server started by the entrypoint.
- **Read settings from the environment**, mapping the Core's names to the
app's in an entrypoint script or config file if they differ
(`SECRET_KEY="$APP_SECRET"`, `DATABASE_URL=...`). Set the app's own
variables outright rather than "only if unset": upstream images often set
defaults in `ENV` (a SQLite path, a port) that would win otherwise.
(`SECRET_KEY="$APP_SECRET"`, `DATABASE_URL=...`). In an entrypoint for
an upstream image, set the app's variables outright rather than "only if
unset": the image's own `ENV` defaults (a SQLite path, a port) would win
otherwise, and on a Core nobody else sets them. (In the app's own code,
as above, the Core's values are defaults that the app's explicit
settings override: that's for its other editions, not upstream `ENV`.)
- **Images without a shell** (built `FROM scratch` or distroless) can't run
an entrypoint script, and `coreapp shell` can't open one. Copy a static
busybox in and run the script with it:
@@ -427,6 +441,10 @@ coreapp signin /signin # a page whose button starts sign-in: pressed
coreapp signin --cookies jar /login && curl -b jar https://<name>.<domain>/api/me
```
Like the other commands, run it in the app's folder (it reads
`coreapp.toml`); the cookie jar can be anywhere, e.g. `--cookies
"$TMPDIR/jar"`.
A page with a sign-in button (a form with only hidden fields, such as a
CSRF token) is submitted as a person pressing it would; with several such
forms, pick one with `--form <action>`. Don't add routes to the app just for
@@ -450,7 +468,8 @@ pages, and that the admin gets the admin role).
| Command | Shows |
|---|---|
| `coreapp status` | Its container, address, port, needs, the Core's database version, URL |
| `coreapp status` | Its container, address, port, needs, URL, and the Core's PostgreSQL or MariaDB version if it needs one |
| `coreapp mail` | What the Core's mail server did with the mail it sent (apps with `email`) |
| `coreapp logs` / `coreapp logs -f` | The app's own log |
| `coreapp signin [path]` | Signs in with the Core's test account and shows each step |
| `coreapp shell '<command>'` | Run one command in its container, e.g. `coreapp shell 'id; env; ls -l /data'` (without a command it opens an interactive shell, which needs a terminal) |