Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

dbbasic-object-server/CONTRIBUTING.md
Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 7 minutes ago History
CONTRIBUTING.md · 9.9 KB · 163 lines

Contributing

DBBASIC Object Server is being extracted from a working private prototype in small, reviewed public commits.

The goal is to keep the public repository useful, testable, and safe while the production runtime is moved here piece by piece.

Contribution Rules

  • Keep commits small enough to review.
  • Include focused tests with implementation changes.
  • Do not copy large private subsystems into this repository before reviewing them for security and product fit.
  • Do not commit secrets, credentials, private URLs, real deployment hostnames, real LAN or cloud IPs, customer data, private object source, local filesystem paths, or deployment-specific station names.
  • Use objects/ for DBBASIC object source. Do not introduce a new public object source root without updating the runtime contract.
  • Preserve compatibility with the existing dbbasic_object_core runtime while package layout is being decided.
  • Treat object execution, permissions, authentication, source loading, state, logs, files, versions, backups, and migrations as security-sensitive.

Public Placeholder Values

Use safe placeholders in docs, tests, examples, and reports:

  • 127.0.0.1 for localhost samples
  • 192.0.2.0/24, 198.51.100.0/24, or 203.0.113.0/24 for documentation IPs
  • example.com, example.net, or example.org for documentation domains
  • .env.example for configuration shape, never real .env values

Runtime Contract

Before changing daemon behavior, object source lookup, scheduler behavior, queue processing, event delivery, or cleanup behavior, read docs/runtime-contract.md.

The public runtime should avoid drifting away from the working private runtime. When a compatibility break is necessary, document it in the same commit as the code and tests.

Local Checks

Run the tests before committing:

pytest

pytest on its own is the reference and stays the same. On a laptop it takes several minutes in one process, so there is also a parallel runner that gives the same result in about a quarter of the time:

scripts/test_fast.sh        # one shard per logical CPU, at most 12
scripts/test_fast.sh 6      # or choose the number of shards

It splits the test files into groups of about equal time (scripts/test_fast_weights.tsv; a file missing from it is weighted by its test count), runs one pytest process per group with its own --basetemp outside the repository, and prints one summary line. It exits non-zero if any shard fails or if the shards together ran a different number of tests than pytest --collect-only selects, so a shard cannot silently drop a test. Each shard's log is kept in build/test-fast/. It needs only bash and the Python on your PATH (set PYTHON= to use another interpreter). pytest-xdist also works (pytest -n auto) and is about as fast; it is not needed. Regenerate the weights after large changes with pytest --junitxml=... and the per-file sums, or leave them: stale weights cost balance, not tests.

Other Python versions

CI runs the suite on Python 3.10 to 3.14 and on the free-threaded 3.14t (.github/workflows/tests.yml). A test that passes on your Python can still fail on another one, so before a push you can run the same thing locally in containers:

scripts/test_versions.sh                  # Python 3.10 and 3.13, at HEAD
scripts/test_versions.sh 3.12 3.14t       # or name the versions
scripts/test_versions.sh -c main 3.10     # or another commit
scripts/test_versions.sh -j 4 3.10        # or choose the number of shards

It tests a commit, not your working tree: it makes its own clean clone of that commit, so an uncommitted change is never part of the run (it says so when the tree is dirty). For each version one container makes a new virtual environment, installs the package the way the workflow does (.[test], then the exchange extra), and runs that commit's scripts/test_fast.sh, so the same check applies: the shards together must run exactly the tests a plain pytest selects. The number of shards defaults to Docker's CPU count minus two. Versions run one after another.

It prints one line per version, the test_fast.sh summary with the version, commit and total time added, and exits non-zero if any version failed. Logs are in build/test-versions/<version>/ (run.log, and shards/shard-*.log for each pytest process).

It needs Docker, git and the network (pip runs in the container). The images are named ci-py:<version> and are built from scripts/ci-image/Dockerfile the first time a version is used; a free-threaded version is installed into its image with uv. Rebuild one with docker rmi ci-py:3.13 and another run. Skip counts differ between versions and from your laptop (what is installed differs); the pass count for one version at one commit does not.

The Linux sandbox lane

User objects run behind Landlock, as a separate OS user started by a launcher that runs as root. macOS has no Landlock and CI runners have no root launcher, so on both the tests of the real thing skip. Run them before merging anything that touches object_sandbox.py, object_sandbox_launcher.py, object_worker_pool.py, the Dockerfile or scripts/docker-entrypoint.sh:

scripts/test_linux_sandbox.sh          # the sandbox, launcher, fork-server and worker-pool files
scripts/test_linux_sandbox.sh full     # the whole default suite in the same container
scripts/test_linux_sandbox.sh all      # both

It needs docker (Docker Desktop or OrbStack on a Mac is enough: the container runs on a Linux kernel), git and python3, and installs nothing on the host. It builds the project's image from one commit (LINUX_SANDBOX_COMMIT, default HEAD; the working tree's uncommitted changes are not tested), adds a test layer from tests/linux_sandbox/ (git and pytest at fixed versions), and runs the tests in a throwaway container through the image's real entrypoint: the launcher as root, the tests as dbbasic, user code as dbbasic-sandbox. Each part prints one summary line, logs go to build/test-linux-sandbox/, and the exit status is non-zero if a part failed. In the sandbox part a skipped test is a failure, because there a skip means the container is not the real setup; on a kernel that lacks a Landlock feature, LINUX_SANDBOX_ALLOW_SKIPS=1 lists the skips instead. LINUX_SANDBOX_KEEP=1 keeps the two images for a faster next run.

Some tests kill a worker to see what the server does next. Under the real setup the worker belongs to another user and the tests cannot signal it, so the test image (and only the test image) runs a small root helper, tests/linux_sandbox/signal_helper.py, that sends SIGKILL or SIGSTOP to a process of the sandbox user when the test user asks. Tests reach it through tests/sandbox_signals.py; without the helper those tests skip.

Run a safety scan before publishing copied code or docs:

rg -n "192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|/Users/|/Volumes/|token|secret|password|api[_-]?key|BEGIN .*PRIVATE|askrobots\.com" .

Some hits are expected in policy documents, project metadata, or contact information. Review every hit before pushing.

Release gate

pytest runs on one machine with one Python, a data directory that already has users in it, and whatever tools that machine happens to have. Two regressions got past it for that reason: a brand-new server refused to start (every test site already had users), and a node test failed on machines that have node while the maintainer's machine, which has none, skipped it. Before a push that will be deployed, and before a tag, run:

scripts/release_gate.sh          # all stages; or: fresh | upgrade | node

It needs only Docker (OrbStack or Docker Desktop). Everything it creates is named gate-<run>-... and removed when it exits; it never touches other containers, volumes or images. Building the images needs the network once; every test step runs offline. It exits non-zero if any stage fails.

StageWhat it provesRoughly
freshThe current tree builds into an image that starts on an EMPTY data directory with the flags a real box uses (password login, permission enforcement, package installs, an admin token, no override env); anonymous requests to private routes are denied and the admin token works; the one-click installer's starting apps all install. Then the one-click order (starter policy saved first, setup code waiting): only /health and /setup answer, setup completes, the owner signs in, anonymous still cannot read a private record.10 s
upgradeAn existing box survives the upgrade: the latest tag is built from git archive, bootstrapped (a user with a password, every package installed, a record, an object), stopped; the current image then starts on the same data with the same env, every package reinstalls in directory order (the documented deploy loop), and the record, object and sign-in still work. If the previous tag cannot run that bootstrap for its own reasons, the stage says skipped: <reason> instead of passing.20 s
nodeThe node-marked tests (pytest -m node) run in a Python + nodejs container; it fails if any of them is skipped there. This is what tells you the tests that skip on a machine without node actually pass.30 s

What it does not prove: it runs one Linux image and one Python version (CI covers the Python matrix), it does not run the whole test suite (run pytest too), it does not exercise HTTPS, Caddy, the systemd path or a real domain, and upgrade covers only the previous release, with a small amount of data, not the migrations a large old data directory might need. Tests that need node skip with "node not installed" instead of passing silently, so a skipped count that changes between machines is that, not a failure.

Pull Requests

A useful pull request should include:

  • a short description of what changed
  • the tests that were added or updated
  • the local test result
  • any runtime-contract or security implications

Docs-only changes do not need new tests, but they should still avoid private deployment details.