Shared building blocks of the Scalio apps: job leases, schema migrations, health, error reports, app links, setup wizard state, roles and permissions, factory reset, audit log, jobs, mail, encrypted file attachments, the demo mode, the AI module and the server side of the Scalio Agent
pip install scalio-platform==0.42.0 Copy PIP instructions
scalio-platform==0.1.0 # backend/requirements.txt, exact version from scalio_platform import error_report, health, job_lease from scalio_platform.migrations import BASELINE, run_migrations MIGRATIONS = BASELINE # append (2, migrate_002_...) and so on, never edit past steps async def startup(): await run_migrations(db, MIGRATIONS) # before the background loops for name, loop in LOOPS.items(): asyncio.create_task(job_lease.run_exclusive(db, name, loop)) error_report.install(app, "citadel", build_info) code, body = await health.health_report(db, build_info(), lease_jobs=sorted(LOOPS)) # probe of the provisioning engine (SaaS on the Docker engine), header X-Provision-Health-Secret code, body = await health.provision_report(db, build_info(), secret=os.environ.get("PROVISION_HEALTH_SECRET", ""), provided=request.headers.get("x-provision-health-secret", "")) # 0.9.0 (AR5): busy= int> reports running work an update would break; the engine waits while > 0 A migration step must be safe to run twice: two instances can start at the same moment.
From the first pre-release (Vorabversion) of a version on, customers run its migrations. A later RC that changes a step never reaches them (their schema_version is already past it). The check compares MIGRATIONS with an earlier git ref:
python -m scalio_platform.migrations check --against 1.3.0rc2 # or --against latest-rc (highest X.Y.ZrcN tag) python -m scalio_platform.migrations check --against 1.3.0rc2 --file backend/migrations.py --variable MIGRATIONS Every step of the ref keeps its number, name and content hash; new steps only come after the last one; numbers strictly increase. Exit code 0 = in order, 1 = violation (German list of the steps), 2 = check not possible (ref unknown, file or list not readable). Only the source is read (ast), nothing is imported. The hash covers the code of the step without docstring, comments and formatting, plus the functions, classes and constants of the same file it uses. Code in other modules called by a step (orgs.migrate_legacy) is not covered; the rule holds there too. A file missing at the ref counts as all new. Function in Python: migration_check.check(path, ref).
CI step for an app (GitHub Actions; the last published release or pre-release of the repo, tags without v):
migrations: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: { fetch-depth: 0 } # tags for the comparison - uses: actions/setup-python@v5 with: { python-version: "3.12" } - run: pip install "scalio-platform>=0.36.0" - name: Migrationen nur ergänzen (ADR 0115 prerel/P11) env: { GH_TOKEN: "${{ github.token }}" } run: | ref=$(gh release list --exclude-drafts --limit 1 --json tagName --jq '.[0].tagName') if [ -z "$ref" ]; then echo "Noch keine Freigabe: nichts zu prüfen."; exit 0; fi python -m scalio_platform.migrations check --against "$ref" Zurücksetzen (factory reset, ADR 0064 / 0069) from scalio_platform.factory_reset import factory_reset_router async def after_wipe(remove_license: bool): if remove_license: await licensing.runtime.refresh(db) # free edition right away await login_policy.announce_setup_code() # new setup code in the log app.include_router(factory_reset_router( get_db=lambda: db, current_user=require_admin, password_hash=lambda u: u.get("password_hash"), verify_password=auth.verify_password, has_second_factor=lambda u: bool(u.get("mfa_enabled")), verify_second_factor=check_mfa_code, keep_meta=(f"{PRODUCT.code}_installation", "schema_version"), license_meta=(PRODUCT.meta_id,), saas_mode=saas_mode, after_wipe=after_wipe)) GET /api/admin/factory-reset answers {available, password, second_factor} (SaaS: not available, the customer portal resets it); POST takes {confirm: "RESET", password, code, remove_license}. Since 0.11.0 (N21, security review 2026-10-27) the second factor is required: has_second_factor(user) and verify_second_factor(user, code) are mandatory, verify_second_factor checks a TOTP or backup code and consumes it (last step stored, backup code removed). An admin without a second factor gets second_factor_missing, a wrong code second_factor_wrong; the password is checked as well when the account has one. allowed(user) narrows who may (Foundry: platform owner), error(code) maps the codes reset_in_portal, reset_confirm_wrong, current_password_wrong, second_factor_missing, second_factor_wrong to the app's own errors. The frontend is FactoryReset from @scalio-cloud/ui (0.32.0 with the code field).
from scalio_platform import agent hub = agent.AgentHub(lambda: db, app="nexus", instance_id=installation_id, roles={"identity": "Active Directory"}, on_report=save_inventory, # async (agent, worker, kind, body) on_complete=after_task, # async (task, status, message, result), default queue only legacy_enroll=old_token_matches, # async (token) -> bool, Upgrade von Agent 1.x audit=audit_agent_action) # async (user, action, detail) app.include_router(hub.router(require_admin=require_admin)) # /api/agent/v2/... await hub.ensure_indexes() task_id = await hub.enqueue("identity", "createUser", data, ref=workflow_id) await hub.agents_online("identity") # "kein Agent online"-Hinweis A worker whose tasks live in the app's own queue gets a TaskSource (claim, extend, complete, recent) in sources={"identity": ...}; Nexus uses this for db.agent_jobs. tests/agent_vector.json is the shared vector with scalio-agent (signature format IEEE P1363).
from scalio_platform import audit, jobs from scalio_platform.audit import Category CATEGORIES = (Category("access", "Zugriff", "Access", ("user.", "role.")), Category("license", "Lizenz", "License", ("license.",), always=True)) await audit.record(db, "user.create", user, category="access", target=audit.target("user", u["id"], u["email"]), detail=f"Konto angelegt · {u['email']}", request=request) app.include_router(audit.audit_router(get_db=lambda: db, viewer=require_perm(CATALOG, me, get_db, "audit.view"), categories=CATEGORIES, tenant_scope=lambda u: None), prefix="/api") # worker REGISTRY = jobs.Registry([jobs.Job("mail_intake", "Mail-Eingang", "Mail intake", "Jede Minute", "Every minute")]) await jobs.run(db, "mail_intake", mail_intake) # inside the loop; return None when nothing happened await jobs.serve_requests(db, REGISTRY, HANDLERS) # own loop every few seconds («Jetzt ausführen») # API app.include_router(jobs.jobs_router(registry=REGISTRY, get_db=lambda: db, viewer=view, runner=run_perm, queue=MyQueue(), audit=log), prefix="/api") Call audit.ensure_indexes(db) and jobs.ensure_indexes(db) at startup. Never write passwords, tokens or contents into detail, changes or a job summary (changes drops fields named like pass/secret/token/key).
from scalio_platform import mail KINDS = (mail.MailKind("resolved", ("Ticket erledigt", "Ticket done"), ("An die meldende Person, wenn ein Ticket erledigt ist", "To the reporter when a ticket is done"), subject={"de": "[{key}] Erledigt: {title}", "en": "[{key}] Done: {title}"}, body={"de": "Guten Tag {name}\n\n...\n\n{sender}", "en": "Hello {name}\n\n...\n\n{sender}"}, tokens=("key", "title", "name", "link"), sample={"key": "IT-12", "title": "Drucker", ...}, switchable=True),) mailer = mail.Mailer(get_db=lambda: db, app_name="Scalio Beacon", kinds=KINDS, seal=secret_box.seal, unseal=secret_box.unseal, # the app's own encryption collection="meta", # default "settings" override=scalio_selftest.mail.smtp_settings, # test mailbox on test instances allowed=scalio_selftest.mail.allowed, base_url=lambda: os.environ.get("APP_PUBLIC_URL", "")) app.include_router(mailer.router(admin=require_admin, audit=log), prefix="/api") # /api/mail/... # ADR 0090: one default for all apps of a customer. Self-hosted: MAIL_* from mail.env; SaaS: Compass (scalio-connect). mailer = mail.Mailer(..., defaults=mail.first_default(mail.env_defaults, compass_mail.defaults), relay=compass_mail.relay) # «Über Scalio», only when Compass allows it for the customer await mailer.send(person["email"], "resolved", {"key": t["key"], ...}, lang=person.get("language"), ref=t["id"]) await jobs.run(db, "mail_outbox", mailer.flush) # worker, every 30 seconds; call mailer.ensure_indexes() once Every template knows {app_name}, {app_url} and {sender} (sender name of the settings, else the app name). A template may be plain text or HTML (from the editor); in HTML the values are escaped. The built-in kind test is the test mail. send returns False when mail is off, the kind is switched off, or allowed refuses the address. check(subject, html) may refuse a mail with ValueError (Foundry: no forms, only https links); it runs on saving or testing a template and before a mail goes into the outbox.
Since 0.10.0: queue(to, subject, body, ref=...) puts a free mail into the same outbox (own subject and text, plain text or HTML, no template), for mails whose text the customer writes elsewhere (Nexus workflow steps); it returns False like send and runs check. An app with its own connection to the customer's tenant passes graph_token= (async, returns a Graph token or raises MailError): the settings then offer the provider tenant («Microsoft 365 über die Tenant-Verbindung», scalio-ui 0.31.0), which needs only the sending mailbox graph.sender and no second app secret. settings() lists the offered providers in providers.
Since 0.12.0: an app connected to several tenants (Citadel, Foundry, Pulse) also passes tenants= (async, returns [{"id": Entra tenant ID, "name", "client_id"}]); the administrator then picks the tenant that sends (graph.tenant_id, taken without asking when there is only one) and the mailer calls graph_token(tenant_id). settings() lists tenants (ID and name only) and send_rights. GET /mail/send-rights (and send_rights_script) writes the PowerShell that gives the send right in Exchange Online with «RBAC for Applications», limited to the sending mailbox (management scope + role «Application Mail.Send»), for the provider graph and for tenant with tenants; the app registration then needs no Mail.Send permission in Entra ID. The script can run again and checks every value.
Both files in this release have provenance metadata.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




