Inspiration

As Vice Chair of OForum and project leader for UFS at Almedalen 2027, I plan events that depend on many independent suppliers at once. Printing, stage hire, catering, transport and volunteers each come with their own prices, capacity and working hours, and the plan rarely fails because something is truly impossible. It fails on one small mismatch that nobody has time to find, and the rescue is usually a single phone call to the right supplier asking for a single change.

Procurement tools cannot make that call. They search what is published and answer "which offer is cheapest", which is useless when every combination of published offers fails. The deal that works only exists after someone proves why the current plan breaks, finds the smallest change that fixes it and gets the one supplier who can grant it to agree. Framvera is built to do exactly that work, end to end, and then pay for the result.

What it does

A buyer writes one sentence, for example "500 promotional kits to Stockholm by Friday 12:00, under 55 000 kr". In the flagship market, 27 independent actors across printing, sourcing, assembly, packaging and delivery could build it together, yet no combination of their published offers works.

  1. Proves the order is impossible as published. A mixed-integer solver returns a minimal set of 14 conditions that cannot hold together, each in plain words such as "Assembly at this supplier must end by Thursday 18:00". A core is marked proven only when the solver itself reported infeasibility.
  2. Catches a misleading supplier. One cheap assembler claims room for 500 kits while 450 are already booked, and its description carries an instruction aimed at automated buyers. The claim is checked against the record and the text is treated as data, never as an instruction.
  3. Finds the smallest change. Inverse feasibility search finds the fewest negotiable adjustments across every supplier and the buyer. Here it is three changes, one assembler working two hours later and two carriers sharing a van.
  4. Creates cooperation that was never on offer. Where no single supplier can do a job, Framvera composes a coalition, such as two carriers sharing one vehicle, with a proposed payment split for each member.
  5. Asks only the suppliers who matter. Typed proposals go to the suppliers whose answer is worth most. Each supplier decides under its own private limits, and an acceptance carries the hash of the exact terms it agreed to.
  6. Verifies before committing. The accepted terms produce a new plan at 52 600 kr, under budget, which a separate verifier re-checks with plain arithmetic for capacity, working windows, hand-offs, deadline and budget.
  7. Commits and pays through PayPal. The plan becomes a hashed agreement with immutable obligations. The buyer approves with a single-use token bound to the agreement, payee, terms hash and exact amount, and Framvera creates, captures and independently re-fetches PayPal sandbox orders.
  8. Survives a failure. When the carrier Lindqvists Transport withdraws, recovery keeps the four unaffected obligations, adds a shared van between Roslagens Åkeri and Mälardalens Budservice and commits an amended agreement at 54 200 kr. A cheaper re-plan at 53 200 kr is refused, because it would cancel an obligation Nacka Emballage had already accepted.

The core of step 3 is a lexicographic optimisation over negotiable fields \(i\), with change indicators \(d_i\) and bounded slacks \(x_i\):

$$ \operatorname{lex\,min}\Big(\sum_i d_i,\ \sum_i w_i x_i\Big)\quad\text{s.t.}\quad g_j(p) \le \sum_i a_{ji}\,x_i\ \ \forall j,\qquad 0 \le x_i \le \bar x_i\,d_i,\qquad d_i \in \{0,1\} $$

so the answer has the fewest changes first and the lowest estimated cost second, within the stated model, fields and bounds.

How PayPal and AI fit together

PayPal is where the deal becomes real. The obligations in a committed agreement are what the PayPal orders are built from, a refund is part of recovery, and every payment's state is part of the traceable history of the deal. Framvera uses Orders v2 and Payments v2 through the PayPal Server SDK with server-side OAuth. Every mutation carries a PayPal-Request-Id, a timeout is held as "unknown" until PayPal confirms either way, refunds are bounded by what was captured, and the status shown to the user is PayPal's own, fetched again with the time it was read. Real sandbox orders, captures and a partial refund are recorded in the repository.

Claude reads the buyer. It turns a free sentence into a typed intent with quantity, hard budget, deadline and what may bend, and asks clarifying questions when something is missing. Its output is grounded against the buyer's own words before use and can only narrow the buyer's spending authority, never widen it. Feasibility, supplier consent and payment are decided by the solver, the suppliers and the buyer, which keeps every guarantee in the chain checkable.

How we built it

  • One shared language. An economic intermediate representation in TypeScript covers intents, markets, offers, constraints, coalitions, typed negotiation messages, agreements, obligations and payments. Money is exact integer minor units, and every fact carries its source.
  • Solver. Markets compile to mixed-integer programs solved with HiGHS. The same solver, compiled to WebAssembly, powers constraint surgery in the browser, where you relax a limit yourself and see what it unlocks in about 0.2 seconds.
  • Negotiation boundary. Supplier policies sit behind a closed set of message types. A person can also take a supplier's seat from a link and answer as that business.
  • Obligations and ledger. An append-only event ledger links every entity to the events that caused it, so any agreement, payment or refusal can be traced back to its origin.
  • Interface and hosting. React and Vite with AG Grid for the market observatory and obligation tables, a Hono API on Node 24, the interface on GitHub Pages and the API on Render.

Results

We built a referee that generates markets from seeds the engine has never seen, hides supplier policies from every strategy and counts a success only when the verifier passes, the budget holds and the hidden real capacity holds.

  • On 30 held-out salvageable markets (impossible as published, fixable by changes some suppliers would grant), Framvera reached 30 of 30 verified plans with 0 false claims, matching the hindsight upper bound. Random relaxations reached 4 of 30, a uniform negotiator 1 of 30 and a conventional optimiser on published offers 0 of 30.
  • Framvera asked 2.0 questions per market on average, and suppliers accepted 59 of 61 proposals. Removing coalitions drops the result to 19 of 30, which shows that cooperation is what turns these orders around.
  • On 30 impossible markets Framvera claimed nothing, which is the correct answer. On feasible markets a direct-procurement baseline made 6 false feasibility claims out of 7, the failure mode that claim checking exists to stop.

Challenges we ran into

  • Keeping consent meaningful. If the system that proposes a change could also decide whether it was accepted, agreement would mean nothing. Supplier decisions therefore cross a typed boundary, bound to the exact terms.
  • Making "minimal" defensible. Each result states its scope, minimal over these constraint groups or these negotiable fields and bounds, which made the claims stronger rather than weaker.
  • Payments without a transaction manager. A timeout is neither success nor failure, so the state machine holds it as unknown until PayPal answers, and a retry can never create a second order.
  • Recovery that respects promises. Finding any feasible plan after a failure is easy. Finding one that keeps every accepted obligation, and explaining the cheaper plans it refused, is what makes recovery trustworthy.

Accomplishments that we're proud of

  • A full deal lifecycle in one product, from a sentence to a proof, a negotiated fix, a verified plan, a signed agreement, a PayPal payment and a recovery that keeps its promises.
  • Benchmarks on held-out seeds with fair baselines and the unfavourable numbers published beside the favourable ones.
  • A live app that anyone can open without an account, with every synthetic fact, estimate and sandbox payment labelled as what it is.

What we learned

  • The most valuable output is often the question, not the answer: which supplier to ask, about which single field.
  • Separating who proposes from who consents makes every downstream guarantee believable.
  • A status shown to a user should be the source's own status, with the time it was read.

What's next

  • Running Framvera on real supplier quotes from the events I plan, starting with Almedalen 2027, so the engine meets real constraints and real answers.
  • Several people at once in the seller terminal, so a whole market of real businesses can negotiate live.
  • More market families on the same engine, from event production to circular resource exchange.
  • Webhook-driven reconciliation of asynchronous PayPal outcomes on a persistent host.

Built With

Share this project:

Updates

Submission history