Skip to content

Azathoth 1.6.0

Latest

Choose a tag to compare

@OMontano OMontano released this 25 Nov 13:10
9a4ec1e

Azathoth 1.6 makes a remote an Azathoth people work on, not only one they
push to. It names, in code, what a remote asks its policy and tells its
audit for every call of the service API, and what a remote's plugins may
build on; a remote answers its requests together rather than one at a
time, and serves every call of the service API, asking and telling as
named; it runs the calls that take minutes as jobs, kept in its database
and followed as they go; api.connect calls a remote as an instance of
its own; every command but a few runs on a remote with --remote; and a
named remote's token may be printed by a command, as an identity
provider's tool prints one. A new example, the model watch, tries the
models released since its last run on your own workflows' benchmarks, and
leaves any that do the same work for less for you to promote. The
database schema moves from version 7 to version 9, as Upgrading From 1.5
below says.

This release changes what the image runs on AWS: the stack's one-off
init task moves its database from schema version 7 to version 9, and its
workers run jobs as 1.5's did. Release validation requires a release that
changes what the stack runs to be deployed to an AWS sandbox before it
ships, and no sandbox was available, so this release was not deployed. The
template was read, the worker run against botocore's Stubber and the S3
tools against a stand-in for S3, as for every release; what only a real
deployment proves, that the stack's workers run jobs on real SQS and S3, is
unproven for 1.6.0, as what 1.5.0, 1.4.0 and 1.3.0 left unproven still is
(Release Validation).

The Action Catalog

  • Action names all 27 actions of the catalog, the protocol's six keeping
    their values, and HIGH_PRIVILEGE_ACTIONS the five that let a caller run
    code on the remote, read what should not spread, or let others in
    (ADR 0134).
  • AuditEventKind gains a kind for each outcome of an action that changes
    something or reads restricted data, so promoting and rolling back are
    told apart; each kind names the action it records
    (ADR 0134).
  • azathoth.api.calls lists every call of the service API once, with the
    actions it always asks, the resource it acts on, what more it asks and
    when, and what it tells the audit; the calls that name an instance's own
    remotes are never served. Every call's docstring, and a new Actions table
    in the service API's README, say the same, and tests hold all three
    together
    (ADR 0134).
  • PermissionDeniedError, permission_denied, is what a call will raise
    when a remote's policy refuses it, its message the policy's reason; it is
    never a NotFoundError
    (ADR 0134).

A Remote Serves Requests Together

  • A remote answers requests together. Every call to its seams and
    repositories runs off the event loop, at most eight at once, so a slow
    policy or a long push holds up no other request, /health included
    (ADR 0135).
  • A transaction may be read-only, transaction(read_only=True), taking no
    write lock; a write in one raises ReadOnlyTransactionError. Everything
    a remote reads, it reads so
    (ADR 0135).
  • An SQLite file is put in WAL mode the first time it is opened, so readers
    never wait for a writer; it gains -wal and -shm files beside it while
    it is open
    (ADR 0135).
  • A PostgreSQL database keeps a pool of up to eight connections rather than
    one; a transaction that finds none free for thirty seconds raises
    DatabaseBusyError. A transaction begun inside another on the same
    thread raises NestedTransactionError, on either database
    (ADR 0135).
  • Of two pushes of one lineage built on its latest revision, the second is
    told the lineage diverged, never saved as a fork, between the threads of
    one server and between servers on one PostgreSQL database. A save with
    fast_forward raises NotFastForwardError when it would not build on the
    latest
    (ADR 0135).
  • azathoth remote serve refuses to serve an SQLite database another
    server is already serving: SQLite serves one remote process on one
    machine, and PostgreSQL serves more
    (ADR 0135).

The Service API on a Remote

  • A remote serves every call of the service API at POST /v1/calls/<NAME>,
    its arguments a JSON object by name and its answer the call's result as
    JSON, read from the call's method so no route is written by hand; bytes
    travel in base64. azathoth.remote.calling says how each call travels
    (ADR 0136).
  • What a caller changes through a remote is recorded as theirs, under
    their principal's name
    (ADR 0136).
  • A call asks the policy its actions about what it names, and each
    condition it names before a change is made or restricted data is sent; a
    listing leaves out what is refused
    (ADR 0136).
  • The eight calls that take a callback for their events, such as runs.run,
    are answered 501 job until a remote runs them on its workers
    (ADR 0136).
  • GET /v1/service says what a remote serves and its edition, and GET
    and POST /v1/permissions what the caller may do on it and on each
    resource asked about
    (ADR 0136).
  • A service route refuses with {"error", "code"}, the code an
    ApiError's own, and the status its kind is given
    (ADR 0136).
  • A remote tells its audit before it acts or sends what it read, the push
    route too, and follows a change that fails with request_failed, a new
    kind; an audit that cannot be told stops the request, answered 503
    audit_unavailable. A push's audit says how many revisions it offered
    (ADR 0136).
  • A push carrying a process tool asks import_process_tool for it, and is
    told as one, as importing one is
    (ADR 0136).
  • tools.install_standard installs the standard tool library through the
    service API, and init, tool install-standard and api.initialize
    install it the same way
    (ADR 0136).
  • azathoth remote token create and revoke tell the remote's audit before
    the token changes, as operator:<AUTHOR>, and revoke now needs an
    author as create does
    (ADR 0136).
  • A remote reads which providers are on, and their keys, when remote serve starts
    (ADR 0136).

A Client for the Service API

  • api.connect(url) returns an instance whose every call is sent to the
    remote, and instance.remote(name).connect() connects to a remote an
    instance named, with the token its own variable holds
    (ADR 0137).
  • api.Instance is a Protocol that a local Azathoth and a
    ConnectedInstance both satisfy, so code written for one runs against
    either; a connected instance's collections are typed as a local
    instance's and take the same arguments
    (ADR 0137).
  • A refusal through a remote raises the error the local call would have
    raised, with the remote's message: a service route's refusal now names
    the kinds its error descends from, in kinds, and a ModelInUseError's
    carries its dependents
    (ADR 0137).
  • RemoteRefusedError gains status and refusal, the status and code
    of a refusal of no kind this Azathoth knows, and RemoteUnavailableError,
    remote_unavailable, is such a refusal with 503, which may be tried
    again later
    (ADR 0137).
  • A connected instance calls the eight jobs as a local instance does: it
    submits one, hands its events to on_event, asks the remote to stop it
    when its cancel is cancelled, and returns its result or raises its
    refusal. A stream that drops is followed again from the last event seen,
    up to 5 more times
    (ADR 0137,
    ADR 0138).
  • A connected instance's jobs submits a job without waiting, follows,
    reads, lists and stops one
    (ADR 0138).

Jobs on a Remote

  • A remote runs the eight calls that take a callback for their events,
    such as runs.run and benchmarks.run, as jobs. Each is asked of the
    policy and told to the audit as its call is, queued in the database, and
    answered 202 with a JobAccepted and its path in Location
    (ADR 0138).
  • azathoth remote serve runs 2 jobs at once on its own threads, each as
    its caller, and --jobs runs another number; --jobs 0 runs none, and
    queues them for another server over the same PostgreSQL database
    (ADR 0138).
  • A job outlives the request that submitted it. When its server stops, or
    stops beating for 90 seconds, a run, a resumed run or an invocation is
    queued again and goes on from its journal; any other job is refused 409
    interrupted, saying how to go on
    (ADR 0138,
    ADR 0139).
  • RunStarted names its run in run_id before the run starts, here and on
    a remote, so a runs.run job a stopped server left is resumed from the
    run's journal, and a runner is taken for stopped only once a run it held
    has let its lease go
    (ADR 0139).
  • A job's event stream reads its events once more when it sees the job
    has finished, so its last event, such as invocation_finished, is never
    lost
    (ADR 0139).
  • GET /v1/jobs lists the caller's own jobs, GET /v1/jobs/{job_id}
    returns one with its result, POST /v1/jobs/{job_id}/cancel stops one,
    and GET /v1/jobs/{job_id}/events streams its events as server-sent
    events, from Last-Event-ID when a client reconnects. Another caller's
    job is read with read_runs and stopped with its call's actions, and a
    restricted job's result is sent only with read_restricted
    (ADR 0138).
  • AuditEventKind.JOB_CANCELLED, job_cancelled, is told before a job is
    asked to stop
    (ADR 0138).
  • GET /v1/service says in jobs how many jobs wait and run, and how many
    runners beat in the last 60 seconds
    (ADR 0138).

The Command Line on a Remote

  • Every command takes --remote <NAME>, a remote this instance named, or
    its URL, and runs on that remote, printing exactly what it prints here:
    the same lines, records and exit status. Without --remote, a command
    runs as it always has
    (ADR 0140).
  • Fourteen commands never run on a remote, such as init, remote push
    and tool verify, and say why in one line, with status 2
    (ADR 0140).
  • A run, an invocation, a job request, a resume, a benchmark run or
    comparison and an optimization run as jobs on the remote and are shown
    as they go; Ctrl-C or SIGTERM stops the job there. A file given as input
    is read here, as only file: references are, and sent
    (ADR 0140).
  • A command a step of another run started takes no --remote, since it
    runs where its parent does
    (ADR 0140).
  • A remote with no such name, or no token, is refused in one line, with
    status 1, before a command does anything; so is a remote that cannot be
    reached, or one whose policy refuses the caller
    (ADR 0140).
  • The service API's views hold all a command prints: a run's source,
    lineage and evaluations, a step's resources and emits_values, an
    invocation's error_code, request_digest, lineage, input_provenance
    and citations, a production's emissions, a benchmark's cited_cases
    and comparisons, an execution's totals, and an optimization's
    experiments with their winners
    (ADR 0140).
  • tools.definition, tools.implementations, tools.implementation,
    tools.test_cases and tools.test_case read a tool's current
    artifacts, each the read_catalog action, and the tool commands read
    through them
    (ADR 0140).
  • An argument that is a model or a JSON value, such as runs.invoke's
    input, is read over HTTP as the model first, so a file arrives as a file
    (ADR 0140).
  • tool from-mcp no longer sends a remote what only tests give it
    (ADR 0140).

Tokens Printed by a Command

  • azathoth remote add <NAME> <URL> --token-command "<COMMAND>", or
    instance.remotes.add(..., token_command=[...]), names a remote whose
    token a command prints, such as gcloud auth print-identity-token,
    instead of one read from a variable; a name keeps one or the other,
    never both, and remote list shows the command quoted
    (ADR 0141).
  • The command is run without a shell, given no input, and has 30 seconds
    to print the token alone; one that does not is refused before anything
    is sent, saying what it said on standard error
    (ADR 0141).
  • Its token is kept in the process, never on disk, until 30 seconds before
    a JWT's expiry, or for 5 minutes. Pushes, pulls, statuses and --remote
    reach a named remote with it, and a connected instance asks for it
    before each request
    (ADR 0141).
  • NamedRemote.token_command holds a name's command, and token_variable
    is None for such a name. api.token_of(remote, environ=None) returns
    the token a named remote is reached with now
    (ADR 0141).

Serving on Windows

  • Serving a remote and running the queue worker are tested on Linux and
    macOS. On Windows azathoth remote serve and azathoth worker run still
    run, at their operator's own risk, after one line saying so
    (ADR 0142).
  • Their tests are skipped on Windows, each saying why; every other test,
    reaching a remote included, runs on every platform
    (ADR 0142).
  • A server's runners claim no job once it is stopping, so a job one runner
    hands back as the server stops is not taken by another, only to be
    handed back again.

Examples

  • examples/model-watch/ is a workflow to run every night: Discover New
    Models, Add to Local Portfolio, Benchmark Against New Models, Compare Cost
    & Quality, and Propose Winner. A ledger remembers every model it has
    considered, so a rejected model never comes back; new models are
    authorized on the local instance only, tried on each target's own
    benchmark, and any winner that keeps its accuracy on a new model is
    proposed with its promote command, never promoted. It is built on what
    1.5 already does, optimizing and promoting an experiment's winner, and
    needs no decision of its own.

Plugins

  • A remote calls a plugin's seams from several threads at once; Writing a
    Plugin says what that asks of one
    (ADR 0135).
  • The remote's README names, under Writing a Plugin, everything a plugin
    may rely on within 1.x, and a test fails if any of it goes missing
    (ADR 0134).
  • azathoth.persistence.database_location finds the database
    AZATHOTH_DATABASE names, or azathoth.db, as the command line does, so a
    plugin finds the database azathoth remote serve does; run_backfills is
    exported beside it
    (ADR 0134).
  • PersistenceError is among what a plugin may rely on, so a plugin may
    catch every error the database raises
    (ADR 0136).
  • A policy may say more of its edition with an edition_detail, such as who
    it is licensed to. Nothing in Azathoth acts on an edition or its detail,
    and a test reads every shipped module to keep it so
    (ADR 0134).

Upgrading From 1.5

Upgrade, and run azathoth init as after every upgrade:

python -m pip install --upgrade azathoth-ai
azathoth init
python -m pip install --upgrade azathoth-ai
azathoth init

If you serve workflows with azathoth-mcp, upgrade it in the same command,
as Installing Azathoth shows: 1.6 of it requires 1.6 of
azathoth-ai.

The database schema moves from version 7 to version 9, which adds the
tables a remote keeps its jobs in
(ADR 0138)
and the table of the commands named remotes' tokens are printed by
(ADR 0141).
An SQLite file is upgraded the first time it is used. A PostgreSQL
database refuses every command until azathoth init has run once, from
any one machine, and 1.5 refuses it after that, so upgrade Azathoth on
every machine first; a database 1.6.0b1 made, at version 8, is upgraded
the same way. init keeps everything the database holds.

azathoth remote serve now runs jobs, 2 at once by default, and says so
on a second line when it starts.

A few refusals now say what the service API says
(ADR 0140):

  • benchmark run and benchmark compare refuse a benchmark with no
    cases before any case runs, rather than ending in a traceback or saying
    no case was recorded.
  • benchmark compare refuses fewer than two distinct workflows with
    A comparison needs at least two distinct workflows., and workflow optimize no generations with An optimization session needs at least one generation.; both refuse a target not above zero with Input should be greater than 0, rather than the whole validation error.
  • An error of the service API that a command does not report itself is
    reported in one line, with status 1, rather than as a traceback.