Skip to content

v1.26.0

Latest

Choose a tag to compare

@jmf-pobox jmf-pobox released this 27 Nov 03:59
· 64 commits to main since this release
eeaf768

Added

  • A read reply that carries mail asks the client to confirm it (ack frame,
    needs_ack on the reply); biffd marks the mail read only then. A client that
    timed out, or a connection that dropped, no longer consumes mail it never
    received. Two residuals, both at-least-once delivery: an abandoned read still
    consumes mail from a consuming relay (NATS), which the next read serves
    from the daemon's outbox, and mail held in that outbox is lost if the daemon
    dies first.
  • biffd keeps a session record per session id and role, so a shell and an
    agent that share a session id no longer share an inbox; a read of a shared
    broadcast inbox no longer serves a message another session already read, and
    its more counts mail a consuming relay still holds behind one pull.
  • biff daemon serve runs biffd in the foreground. It listens on
    127.0.0.1:8424 (--port overrides; --port 0 picks a free port), answers
    an unauthenticated GET /health with its version and uptime, keeps a bearer
    token in ~/.punt-labs/biff/run/serve.token (mode 0600, created once) and
    records its port in serve.port, which a clean shutdown removes. Nothing
    uses the daemon yet; biff mcp, the CLI and the hooks still run in-process.
  • biffd speaks JSON frames (hello, request, reply, subscribe, event,
    each with a protocol version) over that WebSocket and serves who,
    finger, write, read, plan, last, wall, mesg, tty and
    status. It holds one relay connection per relay target however many
    sessions share it, binds each connection to the one session its hello named,
    and closes any connection that does not open with a valid challenge and a
    hello carrying the right MAC. biff.client is the matching client; it imports no relay.
  • The biffd token never crosses the wire. Client and daemon prove they hold it
    with a mutual challenge-response over two fresh 128-bit nonces: the client
    sends a nonce, the daemon answers with its own nonce and an HMAC of both
    under the token, and only then does the client send a hello whose HMAC (a
    different label, the nonces in the other order) replaces the token. A hello
    MAC works on one connection only, so a process that merely bound the port, or
    one that records a hello, gets nothing it can reuse. A relay that sits on a
    live connection can still read it; closing that needs a Unix socket or TLS.
    The client also refuses a run directory that is not 0700, or a token file
    that is not 0600 or not owned by the current user, and prints the chmod
    that repairs it.
  • biffd no longer hangs or dies silently. A relay outage is retried: the
    subscription tells its client degraded once and recovered once and logs
    one line per outage. A bug in a request becomes an internal reply that
    names the method and the log. Requests run concurrently and time out; the
    client's connect, request, subscribe and next_event raise
    DaemonUnreachableError, RequestTimeoutError or ConnectionLostError
    (with the close code and reason) instead of waiting forever. subscribe
    is answered, a second one is refused, and a run replaced by a newer run is
    closed. biff daemon serve prints one actionable line when its port is
    taken or its run directory is not private.
  • The biffd token file must hold a 43-character token; an empty or short file
    is refused instead of becoming an empty MAC key. The token and port files
    are written atomically.
  • biffd drops BIFF_USER, BIFF_OWNER and BIFF_RELAY_* from its own
    environment at start and says so; a client carries its BIFF_USER and is
    refused, by name, if it sets a BIFF_RELAY_* variable biffd cannot carry
    yet. A session's hook and its MCP server resolve the same user.
  • The daemon keeps one relay per relay server, credentials and repository.
    Two repositories on one NATS server get two relays, each scoped to its own
    repository, so one repository's mail, presence and wall stay in its own
    namespace.
  • biff key init, biff key agent, biff key attest and biff key show:
    each person and each agent gets one Nostr key (secp256k1, BIP-340 Schnorr).
    The owner signs an agent's public key with a NIP-OA attestation that
    expires (24 hours by default, 7 days with --image, or
    BIFF_ATTESTATION_HOURS); a receiver checks the expiry on its own clock.
    Private keys rest in the OS keyring, never in the repository or an ethos
    ext file. The owner key sits behind a keychain item that trusts no
    application (macOS) or a passphrase-encrypted file (Linux), and an agent
    process cannot create it or sign with it. The keychain write sends the
    secret to security -i on stdin, never on a command line. Signing and key
    derivation run in nostr-sdk (Rust secp256k1); only verification, which
    takes public inputs, is pure Python. Every agent key read is logged.
    biff key attest refuses a released owner secret that is not the key
    recorded at biff key init. On macOS the owner key's access list is read
    before every use and an item that trusts an application (after "Always
    Allow") is refused. The Linux passphrase is at least 12 characters,
    confirmed twice, read only from /dev/tty, and sealed with scrypt at
    N=2^17, with the parameters stored in the file. Publishing never overwrites
    an unreadable file, and with ethos present a refusal is an error, never a
    silent local copy. The biff who NPUB column shows ? for an invalid
    npub or a failed lookup.
    Public keys and attestations go in the identity's ext nostr namespace,
    or in ~/.punt-labs/biff/nostr.yaml when ethos is absent. With ethos
    present, reads use ethos alone, so an older local file cannot mix a stale
    key into a current one.
    biff key init run again after a failed first run finishes the setup with
    the stored owner secret instead of stranding it. When this machine holds no
    key for an agent, biff key attest signs the npub in the shared directory
    only if the owner confirms it with --npub; the directory is
    unauthenticated, so without the flag it prints the npub and signs nothing.
    It refuses when the published npub differs from the local key. The first biff key command on a
    machine records whether agent keys live in the OS keyring or in files
    (~/.punt-labs/biff/keys/agent-backend); a later session that cannot reach
    the keyring is an error, not a second key. The owner's public key is
    recorded in the clear in ~/.punt-labs/biff/keys/owner/<handle>.pub, so
    biff key show verifies an attestation with no passphrase and no keyring;
    biff --json key show carries the verdict: valid/expired only when the
    owner key matched the local pin, unpinned/unpinned-expired when the
    signature verifies but no pin exists for the owner. A recorded key that cannot be
    read leaves the attestation unverified, and a corrupt one is invalid.
  • biff who adds an NPUB column with each user's short published npub. It is
    the key published under that name, not proof the session holds it.
    biff key show checks an attestation against the owner key recorded on this
    machine and prints the owner's short npub; an owner with no recorded key is
    labelled as published under that name only, and a directory key that
    differs from the recorded one is invalid.

Changed

  • docs/specs/nats-relay.tex and docs/specs/session-model.tex model the
    per-user daemon (DES-095): client attached, detached and daemon absent; the
    daemon owns the one relay handle; per-session attachment, run replacement and
    restart-to-dormant.

  • /who no longer prints the "N sessions stopped responding (last seen ...)"
    footnote under the table. Sessions that died without deregistering are
    logged to biff.log at INFO instead.

Fixed

  • biff key show refuses a malformed published npub and neutralises every
    string it prints or returns from the shared directory (npub, owner, handles,
    ethos error text), so a published entry cannot write control sequences into
    your terminal; the biff who NPUB column shows the canonical npub or ?.
  • npubs must be all-lowercase or all-uppercase ASCII (BIP-173), so a mixed-case
    or lookalike spelling is refused by show, attest and who; show
    refuses a directory entry whose field names collide once neutralised.
  • biff key show says what the owner pin proves: the pin is a file your user
    can write, so a match is not proof against code running as you.
  • In an agent container, git rewrites github remotes through the model gateway
    (url.<gateway>.insteadOf), and git remote get-url origin returns the
    gateway form with an extra route segment. The repo slug failed to parse and
    fell back to the directory name, so container sessions sat in repo
    punt-labs while host sessions sat in punt-labs/punt-labs. The slug is now
    read from the raw first remote.origin.url value, which holds the
    canonical clone URL; the expanded URL is the fallback for shorthand
    aliases such as gh:owner/repo.

Removed

  • NatsRelay.reset_infrastructure(). It cleared the cached KV and stream
    handles while keeping the connection, so a relay could report a connected
    transport with no handles. It had no caller; its docstring named test
    cleanup. The ResetInfrastructure operation is gone from
    docs/specs/nats-relay.tex with it, which closes the handle-validity finding
    without changing the invariant (PL-1702).