OpenFief

Open source · self-hosted · Kubernetes

Give your AI agents a fief, not the kingdom.

OpenFief tracks everything you own across brokers, then lets AI agents trade a slice of it. Each agent gets a revocable capital lease, a fief, with limits enforced by code and separate broker accounts, never by a prompt.

Take the tour How it works GitHub

Kasztan, OpenFief's żubr mascot, on duty with a sealed charter

How it works#

Statements, prices and rates come in through connectors. The core keeps the record: an append-only ledger and a valuation of every holding on every day. Views show it, and your own scripts read it through the same read-only API. Each plugin runs in its own pod with only the permissions you granted, and reaches the internet only through an egress proxy that knows which hosts it may call.

Your Kubernetes cluster

statements,
prices

transactions

read API

pages

read API

Brokers, NBP, GUS,
market data

Egress proxy

Connectors

Core: ledger,
valuations, read API

PostgreSQL

Views: built-in UI,
Ghostfolio

You

Your scripts

Your Kubernetes cluster

statements,
prices

transactions

read API

pages

read API

Brokers, NBP, GUS,
market data

Egress proxy

Connectors

Core: ledger,
valuations, read API

PostgreSQL

Views: built-in UI,
Ghostfolio

You

Your scripts

See how the parts fit together, or take the tour of a running OpenFief.

Build on it#

OpenFief is a platform before it is an app: everything outside the core is a plugin. Connectors bring data in, views show it, and agents, later, trade inside their fief. A plugin is a container image whose signed manifest says what it needs: which hosts it calls, which Secrets it reads, what it may do. You approve exactly that, and the operator enforces it.

Write it
on the Go SDK

Sign the image
and its manifest

The owner approves
its grant

The operator runs it,
isolated

The core calls it

Write it
on the Go SDK

Sign the image
and its manifest

The owner approves
its grant

The operator runs it,
isolated

The core calls it

Build a plugin walks through a real connector, from its manifest to its signature.

Where it’s going#

The tracker comes first; the agents follow on top of it. This is the planned flow for one agent:

  1. Spawn a thesis agent. “Company X is undervalued; three-year horizon.” Give it a fief of 5,000 PLN. It sees its thesis, public data and its own fief, nothing else.
  2. It proposes a trade: a limit order, its reasoning, and what would prove the thesis wrong. The gateway checks it against the lease and your rules.
  3. You approve it on your phone. The order goes to a separate broker account that holds only capital set aside for agents.
  4. Pull the kill switch if something looks off. The agent loses its trading rights, its open orders are cancelled, and the rest of your portfolio is untouched.

trade proposal

approval request

approve

order

revoke and cancel

Thesis agent
in its own pod

Order gateway:
lease and rules

Your phone

Separate
broker account

Kill switch

trade proposal

approval request

approve

order

revoke and cancel

Thesis agent
in its own pod

Order gateway:
lease and rules

Your phone

Separate
broker account

Kill switch

Why a fief#

In medieval Europe, a lord granted a vassal a fief: land to run as the vassal saw fit, held on conditions, and taken back when they broke. The vassal ruled the fief, never the kingdom. OpenFief makes the same deal with software agents, and writes the conditions in code.

Our mascot keeps the gate. Kasztan is a żubr, the bison of Białowieża, a royal forest whose bison Polish kings put under crown protection in the 16th century: a creature living inside a guarded domain, under rules it can’t argue with. His name is the kasztelan, the castellan who kept a castle for the crown, and kasztan, the chestnut of his coat.

Where it stands

OpenFief is in its first milestone, M0: the tracker, with Polish broker and treasury bond imports. The agents come in later milestones, and nothing here is ready for real money yet.

  1. M0 Tracker Imports, the ledger, valuations, the read API, the built-in UI and isolated plugins.
  2. M1 Control plane Leases, the order gateway and approvals, on paper trading.
  3. M2 Agents Thesis agents as plugins, each with its own fief and models.
  4. M3 A live fief The first small lease trading real money.

Every design decision has an ID, every requirement is traced to the code and the tests behind it, and a docs page that falls behind its code fails the build. This build counts the decisions:

See every decision and its evidence

Help shape it

The design is public, with every decision numbered and every proposal open to critique. The most useful input now is a hard look at the security model, and experience with the Interactive Brokers API or its linked accounts as a Polish resident. Start with the introduction, then how it works.