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 five 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. The
db module also needs psycopg, installed with the db 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.
A database of its own
A service whose manifest sets permissions.db is given a PostgreSQL role
and a schema that only that role can use. The db extra installs psycopg:
pip install 'firetail_finchly[db]'
from pathlib import Path
from firetail_finchly import connect_database
# Once, at startup. Asks the platform for the role and schema it made.
# Safe to share between threads.
db = connect_database(service=service)
db.migrate(Path(__file__).parent / "migrations")
rows = db.execute("SELECT id, body FROM notes WHERE author = %s", [caller.subject]).rows
with db.transaction() as tx:
tx.execute("INSERT INTO notes (body, author) VALUES (%s, %s)", ["hello", caller.subject])
tx.execute("UPDATE authors SET notes = notes + 1 WHERE id = %s", [caller.subject])
# One instance at a time, across every instance of this service.
with db.advisory_lock("nightly-import") as tx:
...
- Names need no schema.
notesmeans the service's own table. The service cannot read the platform's tables or another service's. - Values go in the second argument, as
%s. They are never built into the SQL. Rows come back as dicts. - A transaction commits if its block ends and rolls back if it raises.
- Migrations are files named
NNNN_name.sql, applied in order, once each, in one transaction. Every instance may callmigrateat startup: they take turns. A migration that was applied is never edited; add a new one. A problem is aFinchlyErrorwith codemigration_invalid. connect_databaseraisesdatabase_not_grantedif the manifest does not ask for a database, anddatabase_unavailableif the platform or the database cannot be reached.
To run a service on its own, without a platform, give the URL directly:
connect_database(url=..., slug=...).
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.4 |
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 | Done |
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.
Changes
See CHANGELOG.md.
Metadata
Release files for firetail-finchly 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| firetail_finchly-0.0.4.tar.gz | 21.0 kB | With provenance | Details for firetail_finchly-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| firetail_finchly-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for firetail_finchly-0.0.4-py3-none-any.whl |
Total release size: 46.2 kB
Release files / firetail_finchly-0.0.4.tar.gz
| Download URL | firetail_finchly-0.0.4.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e397a853dc97136038c630a2e9d9d5895632470524276d51b90a8ab9de1c2124
|
|
BLAKE2b-256 checksum How to use checksums |
dc4efb41fdb915f0d10e2dd0031dea1845bc5c5d741e6a2e539664bf4fb44d40
|
| 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 logRelease files / firetail_finchly-0.0.4-py3-none-any.whl
| Download URL | firetail_finchly-0.0.4-py3-none-any.whl |
|---|---|
| Size | 25.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7519a47d9090962d288ec135c72363c186578d396e55aa8652861c8357159724
|
|
BLAKE2b-256 checksum How to use checksums |
454ff825c38f284e24b92c9ba40fa3d7b74df48a1e68e48072fa4b05a80daf6b
|
| 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 logSecurity for firetail-finchly 0.0.4
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.
Attestation for firetail_finchly-0.0.4.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 logA 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.