Skip to main content

firetail_finchly

Python SDK for the Finchly platform. A service or app uses it to register with a Finchly deployment, verify who is calling it, and reach the platform's database, object store, queue and other services.

Status: early. The package is tested, but only the first four modules exist.

The SDK implements the platform API, which is specified in firetail-io/finchly under spec/. This release speaks platform API v1 (draft).

Install

pip install firetail_finchly

Requires Python 3.10 or later. Depends on PyJWT with its crypto extra.

Use

from firetail_finchly import load_config, load_manifest

config = load_config()                         # reads PLATFORM_* settings
manifest = load_manifest(config.manifest_path)

Both raise a FinchlyError with a stable code and a problems tuple that names everything wrong, so a misconfigured container fails once with the full picture.

Who is calling

The gateway puts a short-lived signed token in the x-platform-identity header of every request it proxies. It is the only identity a service should accept.

from firetail_finchly import IdentityError, IdentityVerifier

# Once, at startup. It caches the gateway's issuer and signing keys, and
# is safe to share between threads.
identity = IdentityVerifier(slug=manifest["slug"], gateway_url=config.gateway_url)

# Per request.
try:
    caller = identity.from_headers(request.headers)
    caller.subject   # user id, or "service:<slug>"
    caller.email     # None for a service calling as itself
    caller.groups    # platform groups
    caller.roles     # roles for this service: "user", "operator"
    caller.actor     # "service:<slug>" when a service acts for the user
except IdentityError as err:
    ...  # Unauthenticated: respond 401. err.reason is for logs only.

Any other FinchlyError from the verifier means the gateway could not be reached; respond 503.

A token is rejected unless it is signed with ES256 by a key the gateway publishes, names that gateway as issuer and this service as its only audience, and has not expired. The rules are in spec/identity-token.md in firetail-io/finchly.

No other header is ever consulted. On a path the manifest declares in publicPaths there is no token, and the service authenticates the request itself.

Calling another service

Services never address each other directly. A call goes through the gateway, signed by this instance's own key.

from firetail_finchly import ServiceClient

# Once, at startup. Safe to share between threads.
service = ServiceClient(
    slug=manifest["slug"],
    gateway_url=config.gateway_url,
    credential=config.service_credential,
)
service.start()   # optional: fail now, not on the first call

# As the service itself.
response = service.call(
    "notification-service",
    "/api/send",
    method="POST",
    headers={"Content-Type": "application/json"},
    body=b'{"text": "hello"}',
)
response.status, response.headers, response.body, response.json()

# For a user: the target sees that user, and this service acting for them.
service.call("notification-service", "/api/inbox", as_user=caller.subject)

call returns the response, whatever its status.

  • 403 means this service's manifest does not list the target in calls, or the user has no access to the target.
  • A redirect is handed back, not followed.
  • Nothing is retried. After a 401 the next call registers the key again, in case the gateway no longer knows it.

To use another HTTP client, such as requests or httpx, take the address and the header from the client and send the request yourself. A token is for one target and is valid for a minute, so get fresh headers each time:

requests.post(
    service.url("notification-service", "/api/send"),
    headers=service.headers("notification-service"),
    json={"text": "hello"},
    allow_redirects=False,
)

The instance makes an ES256 key pair in memory the first time it is needed. The private half never leaves the process. The public half is registered with the gateway using the credential the service was deployed with, and extended by itself for as long as the instance runs. The rules are in spec/service-token.md and spec/registration.md in firetail-io/finchly.

An app registers itself

A built-in service has a credential. An app does not: it registers itself with the platform, and that is what gets its key accepted. Give the client an enrolment in place of a credential:

from firetail_finchly import ServiceClient, enrolment_from, load_config, load_manifest

config = load_config()
manifest = load_manifest(config.manifest_path)

service = ServiceClient(
    slug=manifest["slug"],
    gateway_url=config.gateway_url,
    credential=config.service_credential,          # a built-in service
    enrolment=enrolment_from(config, manifest),    # an app
)
service.start()

enrolment_from reads the enrolment token (PLATFORM_ENROLMENT_TOKEN) and the app's address (PLATFORM_APP_ADDRESS, or this machine's hostname and the manifest's port). It returns None when there is no token, so the same code serves a built-in service and an app.

Registration is the first call the client makes, and it sends the manifest exactly as it was loaded. What can come back:

Error code Meaning What to do
none Registered. Calls work
app_pending_approval The release waits for an administrator: it asks for more than the last one, or the app is at an address the deployment does not expect Keep running and try again. The client does not ask the platform again before it was told to
app_registration_refused The platform refused, and problems says why: a bad token, a manifest or address it will not accept, a lower version than the one running Fix the deployment. Trying again will not help
gateway_unreachable The gateway could not be reached Try again

The protocol is in spec/registration.md in firetail-io/finchly.

The other half of the app module is not built: serving the /{slug}/_platform/* endpoints, which let an administrator register an app that is already running, and fetching the settings the platform creates for an app.

What every request carries

Every request this SDK makes to the platform says which SDK and which release is asking:

Header Value
x-platform-sdk firetail_finchly
x-platform-sdk-version This release, for example 0.0.2
x-platform-api-version The platform API version it speaks, v1

That covers fetching the gateway's issuer and keys, registering an instance key, registering an app, and every call to another service. On a call the headers reach the target service too, and a caller cannot replace them. service.headers() includes them, for use with another HTTP client.

Settings

Variable Required Meaning
PLATFORM_GATEWAY_URL yes The gateway's internal address
PLATFORM_MANIFEST_PATH no Manifest path in the container. Default /finchly/manifest.json
PLATFORM_APP_ADDRESS no Address the gateway should use to reach this service
PLATFORM_ENROLMENT_TOKEN no Token for self-registration
PLATFORM_SERVICE_CREDENTIAL no What a built-in service registers its instance key with

The enrolment token and the service credential are left out of the config's repr, so logging the config does not leak them.

Modules

The Python SDK may trail the Node SDK for modules that only Node services use.

Module What it does State
config Read and validate the platform settings Done
manifest Load the manifest and check what the SDK depends on Done
identity Verify x-platform-identity Done. Directory lookups (list_users, members_of) and require_* helpers are planned
app Register with the platform, serve /_platform/*, renew keys, fetch settings Self-registration and key renewal are done, through service. Serving /_platform/* and fetching settings are not
service Call other services through the gateway, as the service or for a user Done, for built-in services and for apps
db PostgreSQL: queries, transactions, advisory locks, migrations Planned
blobs Object storage with conditional writes Planned
queue Publish, lease, ack, nack Planned
secrets Secrets and envelope encryption Planned
llm Model calls through the platform Planned
audit, usage, notify, schedule, connectors Clients for platform services Planned
ui Shared header, footer and theme Not planned; Node only

The manifest check here is not the full schema. The platform runs the full check at registration and is the authority.

Develop

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
python -m pytest

Without a local Python environment, run them in a container:

docker run --rm -v "$PWD":/src:ro python:3.12-slim sh -c \
  "cp -r /src /w && cd /w && pip install -q -e '.[dev]' && python -m pytest -q"

Conformance vectors

tests/conformance/ holds test vectors copied from firetail-io/finchly (conformance/vectors/). Both SDKs must reach the verdict each vector states. Do not edit them here: change them in finchly, regenerate, and copy the file to both SDK repositories. Until finchly publishes its conformance suite as an image, the copy is made by hand.

Release

Each package version follows semver, independent of the Node SDK and of the platform.

  1. Changes land on main by pull request. Each one adds a line to CHANGELOG.md under "Unreleased".
  2. To release, set the version in src/firetail_finchly/_version.py, move the changelog entries under that version, merge, and tag the merge commit v plus the version, for example v1.2.0.
  3. The release workflow checks the tag matches the version, runs the tests, builds the sdist and wheel, and publishes.
  4. A release candidate uses the PEP 440 form, 1.2.0rc1, tagged v1.2.0rc1. pip does not install pre-releases unless asked.
  5. A bad release is yanked on PyPI and followed by a patch release.

Publishing uses PyPI trusted publishing: the workflow proves its identity to PyPI with its GitHub Actions token, so no PyPI token is stored in this repository.

One-time setup, not yet done:

  • On PyPI, add a pending trusted publisher for the project firetail_finchly: owner firetail-io, repository finchly-sdk-py, workflow release.yml, environment pypi.
  • Create a GitHub environment called pypi in this repository, restricted to tags.

Still to add: the conformance suite from firetail-io/finchly, run in CI on every change, once that suite exists.

Metadata

Release files for firetail-finchly 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for firetail-finchly 0.0.2
File Size Uploaded Provenance Actions
firetail_finchly-0.0.2.tar.gz 34.9 kB With provenance Details for firetail_finchly-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for firetail-finchly 0.0.2
File Interpreter ABI Platform Actions
firetail_finchly-0.0.2-py3-none-any.whl Python 3 none any Details for firetail_finchly-0.0.2-py3-none-any.whl

Total release size: 56.2 kB

Release files / firetail_finchly-0.0.2.tar.gz

Download URL firetail_finchly-0.0.2.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
81ef97d0b94cf587a63dc99245026bfd501aa96a47352401bc258aeffab5ab03
BLAKE2b-256 checksum
How to use checksums
646f05ba4935948ae04ca543f5b361995b158f16d9d00313f6939a9e32b9a8d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

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.

Transparency log

Release files / firetail_finchly-0.0.2-py3-none-any.whl

Download URL firetail_finchly-0.0.2-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d7f932524f1d5f39652d282471a074e12cc97622d9f6b5e1d4e130a88c74f36
BLAKE2b-256 checksum
How to use checksums
ee111c565624e120a88c39d3498fd4d3232a5335ee1c7a1a612363054a33d24e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

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.

Transparency log

Security for firetail-finchly 0.0.2

Provenance

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for firetail_finchly-0.0.2.tar.gz

PyPI Publish Attestation

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.

Transparency log

A note on package security

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page