Skip to content

Harden: fix the dedup crash, shrink the image, gate the CI, and make self-update safe - #52

Merged
fyaz05 merged 5 commits into
mainfrom
beta
Nov 15, 2026
Merged

fyaz05 merged 5 commits into
mainfrom
beta

Conversation

@fyaz05

@fyaz05 fyaz05 commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Four changes, each one commit, each independently testable.

1. fix: — a crash in the duplicate-user recovery path. pymongo's
aggregate returns a coroutine and the code iterated it directly, so the
recovery raised TypeError exactly when it was needed. Also swaps
tgcrypto → tgcrypto-pyrofork (the old name has no wheel past cp311, which is
the only reason the image needed a C toolchain) and unpins a stale uvloop.

2. build: — the image. No root, no gcc, no git: every dependency has a
wheel, so 977 MB → 287 MB at uid 10001. The .dockerignore is the part that
matters — COPY . . was baking config.env and a 115 MB .venv into images
built from a deployment tree. It has a test, because a pattern that looks right
and silently misses the file is worse than none.

3. ci: — the workflows. dockerize.yml published thunder:latest on
every push to main with no dependency on the test job, so a red main shipped an
image. Now one workflow: build, smoke-test, then publish. Fork PRs never see the
secret. Suite runs on Linux and Windows at 3.13 plus 3.14, weekly against fresh
dependencies since requirements.txt floats on purpose. Also fixes /restart
(hardcoded /bin/bash, crashed on Windows) and four ways update.py could lose
a user's work or their config.env.

4. build: — self-update. It replaced the repository to apply an update
(git init, throwaway commit, fetch, reset), taking the user's branches, stashes
and remotes with it. It now fetches and resets in place. Dependencies could not
install in an environment made by uv venv (no pip), so an update reported
success with new requirements missing; it now tries pip then uv.

Verification

Tests 145 passed, 1 skipped (Windows) · 146 passed (Linux)
Lint ruff clean, config in pyproject.toml
Each commit tested individually: 117 → 119 → 141 → 145
Workflow actionlint clean, validates against the published schema
Image built and run on a real host; secrets planted at the root and nested are all excluded

The tree is byte-identical to the chore/hardening-phase-* branches this was
squashed from.

Not verified

main has never run this workflow, and the publish path has never executed — it
needs DOCKER_TOKEN, which is now set. The first push to main will be the
first real publish
, so merging this is the point at which that gets exercised.

Duplicate-user recovery raised TypeError exactly when it ran: pymongo's
aggregate is async and the cursor was iterated directly. Two tests cover it,
both failing before the fix.

tgcrypto has no wheel past cp311, so every install needed a compiler.
tgcrypto-pyrofork ships cp313/cp314 wheels. uvloop's pin predated its own.

Cleared five lint findings and the dead requested_action parameter.
Root, gcc, git and libssl-dev existed for one package. Every dependency has a
wheel now, so the image drops from 977 MB to 287 MB and runs as uid 10001.

COPY . . was baking config.env and a 115 MB .venv into images built from a
deployment tree. The new .dockerignore excludes them, with a test: a pattern
that looks right and silently misses the file is worse than no pattern.

update.py reports a deployment that cannot self-update as not applicable
rather than an error, so a container without git boots clean.
dockerize.yml pushed thunder:latest on every push to main with no dependency
on the test job, so a red main shipped an image. One workflow now: the image
is built, smoke-tested, then published. Fork PRs never see the Docker Hub
secret.

Suite runs on Linux and Windows at 3.13 plus 3.14, and weekly against fresh
dependencies, since requirements.txt floats on purpose. Actions pinned to
SHAs. pytest.ini becomes pyproject.toml. New tests cover plugin handler
registration, the platform-only deployment files, and the workflow's own
invariants.

Also fixed /restart, which exec'd a hardcoded /bin/bash and crashed on
Windows, and four ways update.py could lose a user's work or their config.env.
Applying an update replaced the repository: git init, a throwaway commit,
fetch, reset. The user's branches, stashes and remotes went with it. It now
fetches and resets in place, so nothing of theirs changes and rollback only
has to restore the tree.

Dependencies could not install in an environment created by `uv venv`, which
has no pip, so an update reported success with new requirements missing. It
tries pip then uv, and says what to do when neither works.

Test sandboxes copied a virtualenv 24 times a run; excluding it takes the suite
from minutes to seconds.
The comment cited git pack files, which cannot reach this helper any more:
_snapshot() copies the tree with .git excluded, so the rollback directory holds
no git objects. The retry still earns its place, just for a different file.

Measured: a read-only file inside a copied tree makes rmtree raise
PermissionError and leave the directory behind; with the chmod retry it is
removed. copytree preserves the read-only bit, and the user's own tree can hold
such a file, so the helper is still load-bearing on Windows.
@fyaz05
fyaz05 merged commit cd02c7c into main Nov 15, 2026
7 checks passed
@fyaz05
fyaz05 deleted the beta branch November 15, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant