Miril · miril.net
Two countries stop talking. The cost lands on people who were never at the table. This is the case for solving that problem as a network, not a duel — and an honest account of where the method runs out.
A trade stalemate is usually described as a failure of will. One side is stubborn, the other is posturing, and if the leaders were more reasonable there would be a deal. That description is comforting and mostly wrong. The interesting stalemates are the ones where no agreement exists to be found — where the thing one side needs is something the other genuinely cannot give.
Consider the clearest live example. The United States has sought duty concessions for its agricultural and dairy exporters in India. India has refused. It is tempting to read this as bargaining, but look at what a concession would require: Indian agriculture is overwhelmingly smallholder, working small plots with limited access to storage, insurance and cheap credit, against American farms that are larger, heavily mechanised and substantially supported. There is no tariff number at which those two things compete evenly. When Punjab farmers marched on Delhi in July 2026 and the Shambhu border was sealed, that was not a negotiating tactic. It was the constraint making itself visible.
The bilateral solution space is empty. No amount of goodwill finds a point inside it, because there are no points inside it.
Meanwhile the meter runs. Yale’s Budget Lab put the cost of current-law tariff policy at roughly $1,100 per American household a year, raising consumer prices about 0.7% (11 August 2026). An earlier draft of this page quoted a range of $570 to $2,500 — a spread of more than four times — and that spread was the honest state of the estimates at the time. It has since narrowed to a sourced central figure, which is the direction these things are supposed to move. Procter & Gamble raised prices on a quarter of its products against a roughly $1bn annual tariff impact. None of those households is party to the dispute. They are simply where the cost settles.
Why a third country changes the arithmetic
If A needs something B will not supply, the bilateral question — what will B accept? — has no answer. But that is not the only question available. A different one: is there any arrangement among a larger group that satisfies A's need and B's constraint simultaneously?
Often there is, because trade is not a set of independent pairs. It is a network, and networks have paths that pairs do not. C can supply what A needs. A makes something C wants. C also makes something B needs, and B has raw materials C is short of. Route the goods around the loop and both original parties get what they required without either conceding to the other. Nothing was surrendered. Nobody lost face. That last point is not a nicety; it is frequently the binding constraint in real negotiations.
For the technical reader
This is a multi-commodity network flow problem. Lanes are decision variables bounded by real production capacity; demands are equality constraints with a penalised shortfall term so an infeasible case reports which demand failed rather than returning a bare "infeasible". The objective maximises delivered value net of transport cost — never gross value, or a route that costs more to run than it delivers still scores as a gain. Solved with CBC through PuLP.
The allocation problem
A workable route is only half an agreement. The surplus it creates has to be divided, and the division decides whether anyone signs. The tempting answer — split it evenly — is precisely wrong, because the participants are not equally load-bearing. Remove one country and the loop may still work. Remove another and it collapses. Those two should not be paid the same.
The Shapley value answers this properly: each participant's share reflects what the arrangement loses without them, averaged over every possible order of joining. On our reference network the allocation lands like this:
| Nation | Position | Share |
|---|---|---|
| A | Origin of the dispute; sole agricultural supplier | 9,354.17 |
| C | Primary chip supplier | 8,710.00 |
| B | Withholding party; sole source of raw materials | 7,462.50 |
| D | Marginal supplier; clears machinery to B | 6,783.33 |
| E | Swing capacity | 5,410.00 |
| Sum | 37,720.00 | |
Note that B earns a substantial share despite being the party that refused the original trade. That is not a flaw. B's raw materials are what make C and D's participation worthwhile, and a method that punished B for its position would produce an allocation B would never accept — which is to say, no agreement at all.
For the technical reader
v(S) is the same flow solve restricted to coalition S, so the allocation and the route come from one model rather than two that could disagree. Exact Shapley is 2n solves — 32 for five nations (230ms), 1,024 for ten, over a million for twenty — so past a tier's ceiling it degrades to unbiased permutation sampling, and says so. One guard matters: if the grand coalition cannot meet its critical demands, v(N)=0 and marginal contributions net to zero, which handed one nation −6,651 in an early run. A "fair share" worse than not participating is worse than no answer, so the allocation is refused instead.
Trade balance as a hard requirement
Maximise surplus alone and the optimiser will do something quietly disastrous. On our network it produced this:
| Nation | Exports | Imports | Net | Imbalance |
|---|---|---|---|---|
| E | 0 | 6,100 | −6,100 | 200.0% |
| B | 17,050 | 8,100 | +8,950 | 71.2% |
| A | 14,000 | 16,500 | −2,500 | 16.4% |
E buys and never sells. This is arithmetically optimal and politically dead. A country asked to run a permanent structural deficit under a treaty it signed has been handed the grievance that becomes the next stalemate — which is, more or less, how the disputes in our own case files began. So balance is a hard constraint, not a preference. Every participant's exports must stay within a tolerance band of its imports.
It is not free:
| Band | Status | Surplus | Worst imbalance |
|---|---|---|---|
| Off | Optimal | 37,720 | 200% |
| ±30% | Optimal | 33,732 | 30% |
| ±15% | Infeasible | — | — |
Equilibrium costs 10.6% of surplus at a ±30% band, and at ±15% the network simply cannot do it. That last result is the one worth pausing on.
Cumulative balance, and a correction
Our first attempt at this got the concept wrong, and the error is instructive. We enforced balance in every single year, tightening the band on a schedule and solving each year on its own. That model reported that ±15% was unreachable in ten years — and that conclusion was an artefact of the formulation, not a fact about trade.
The flaw: solving year by year, a deficit run in year 1 can never be repaid in year 3, because year 3 does not know year 1 happened. But no real trade agreement demands annual balance. What matters is that the running total converges over the life of the agreement, with intermediate years free to be lopsided.
That freedom is not a concession. It is the mechanism. A country that must import machine tools before it can export finished goods needs an early deficit. Forbid it and you forbid the investment the agreement exists to enable.
True win-win is two conditions, not one: cumulative balance within tolerance, and every party strictly better off than the stalemate. Not on average — every party.
That second condition carries the weight. A country can finish perfectly balanced and still worse off than if it had never signed. Averaging gains across nations is exactly how a deal that impoverishes one participant gets reported as a collective win. The binding party is the worst-off one.
Reformulated as a single joint optimisation across all years, the answer changes completely:
| Horizon | ±10% | ±15% | ±20% | ±25% | ±30% |
|---|---|---|---|---|---|
| 3 years | — | — | WIN | WIN | WIN |
| 5 years | — | — | WIN | WIN | WIN |
| 8 years | — | — | WIN | WIN | WIN |
| 12 years | — | — | WIN | WIN | WIN |
Two things stand out. ±20% is the tightest equilibrium this network can reach — and it is reachable in three years. Below that, tightening A's balance starves its chip imports, and a critical demand goes unmet; the constraint binds against physical trade requirements, not against patience.
And the frontier is flat across every horizon. Twelve years buys nothing that three did not. Which restates, in a cleaner form, the finding from the section above:
Time does not buy equilibrium. Structure does.
The shortest true win-win comes in at two years at ±25%, with all five parties better off. Look at what the intermediate years are doing:
| Nation | Cumulative net | Imbalance | Gain | Year 1 | Year 2 |
|---|---|---|---|---|---|
| A | −5,075 | 16.4% | 13,797 | −2,500 | −2,575 |
| C | −2,432 | 8.6% | 13,944 | −1,052 | −1,380 |
| B | +4,698 | 25.0% | 4,393 | +121 | +4,577 |
| D | +4,072 | 25.0% | 2,748 | +4,431 | −359 |
| E | −1,263 | 25.0% | 1,121 | −1,000 | −263 |
D runs a +4,431 surplus in year 1 and swings to −359 in year 2. B does the reverse, starting near flat and finishing +4,577. Neither year is balanced; the period is. Every party gains, and the binding party — E, at 1,121 — still gains. Total surplus over the period is 67,751.
For the technical reader
One LP over lanes × years, not a sequence of independent solves. Cumulative balance enters as two inequalities per nation on the summed position across the whole horizon; a deliberately wide per-year rail (±60%) prevents a party being abandoned for four years and settled up in the fifth, but it is a plausibility guard, not the equilibrium condition. Capacity compounds at 6% a year, demand at 3% — both stated assumptions, applied uniformly, returned in the result rather than buried. The win-win test runs on per-nation cumulative gain against a disagreement point of zero, checked individually, never averaged.
Leapfrog technologies
Everything so far is conservative by construction. It takes the world's production map as given and finds the best path through it. That is genuinely useful, and it is also a ceiling: a country that depends on one supplier for a critical input is still dependent after the cleverest route is signed. The route buys time. It does not buy independence.
Here is that dependence, measured from filed customs declarations rather than commentary — US imports of rare-earth and alkali metals:
| Year | Imports | China share | HHI | Verdict |
|---|---|---|---|---|
| 2019 | $82.0M | 38.9% | 0.313 | concentrated |
| 2021 | $78.1M | 47.7% | 0.345 | concentrated |
| 2023 | $97.6M | 71.2% | 0.556 | critical |
Demand grew 4.46% a year while dependence on the disputing counterparty nearly doubled. No routing solution reverses that line. Something else has to.
That something is substitution — and the point is worth stating plainly: if a motor needs no rare earths, an export licence on rare earths stops being leverage. Not routed around. Gone. Iron-nitride and ferrite magnets, sodium-ion battery chemistry, recovery of rare earths from end-of-life magnets: each dissolves a constraint rather than navigating it.
But these are chronically under-funded relative to their strategic value, and the reason is structural rather than technical. The incumbents holding the constraint are not neutral parties. A dominant supplier's market position is the bottleneck. A magnet maker with a depreciated production line, a state with an export-licence lever — each holds capital whose value depends on the bottleneck persisting. Their rational move is to defer the substitute, not fund it.
So the model carries an explicit resistance term, and it changes the answer materially:
| Technology | Engineering | Realistic | Resistance | Ceiling |
|---|---|---|---|---|
| Rare-earth recovery | 2027 | 2028.8 | 0.45 | 25% |
| Iron-nitride magnets | 2027 | 2030.0 | 0.75 | 60% |
| Sodium-ion cells | 2026 | 2027.2 | 0.30 | 35% |
Incumbent resistance adds three years to the magnet timeline on its own. And sodium-ion is the illuminating exception: its resistance is low because the incumbent lithium cell maker is the one commercialising it. When the party that would be displaced is the party doing the displacing, the drag largely vanishes. That is what the term measures — misalignment of capital, not technical difficulty.
The two answers, side by side
Route around it: available now, costs ~10.6% of surplus for balance,
leaves the dependence intact.
Dissolve it: $232M of capex identified,
would take HHI from 0.556 to 0.05,
earliest material effect 2.8 years out.
The tool does not choose. That decision turns on a political horizon no model can see, and software that hides that behind a recommendation is claiming an authority it does not have.
Pairs, regions, or the world — live at miril.net
The deployed console asks the user to pick a scope before it computes anything, because scope changes what can even be asked. A bilateral pair has no third party, so the solver can only confirm the deadlock. A region has enough members for a loop. The world has the most routing freedom and a cost that grows as 2ⁿ: twenty nations is 1,048,576 coalitions, which is why the menu states each scope’s cost before it is chosen and the allocation degrades to unbiased sampling — and says so — past each tier’s exact ceiling.
Every network is built from filed customs flows, never invented: a Comtrade partner row — “reporter X imported $V of commodity C from P” — is a lane, evidence that P can supply C at that volume at prices the market already cleared. Supply reaching the scope from outside it is counted as external dependence rather than dropped, which is why the critical-minerals scope reports that 88% of rare-earth-compound supply lies beyond its members: a resolution there is partial by construction, and the console says so.
The US–Canada worked example
For a deadlocked pair the product does not stop at diagnosis. It ranks third countries by two observed quantities — export capability toward the needing side, and import demand that offers the withholding side an alternate market — and solves the expanded coalition. For the US–Canada steel, aluminium and autos break, the proposal invites Germany, Japan and Mexico: Germany with $78.8bn of observed vehicle exports and a $12.8bn import market Canada can sell into; Japan and Mexico with equivalents. The five-nation coalition yields 35 routes and $273.4bn of surplus, split by exact Shapley: the United States takes $126.9bn and Canada — the tariffed party — is the second-largest gainer at $47.6bn. Neither original party concedes anything to the other, which is what makes the page worth putting in front of either.
From flows to factors
Beneath the flows are the endowments — what each nation holds, what its people can do, which way it is moving. The console profiles every scope member on sixteen World Bank indicators across six axes (resources, people, trajectory, services, energy, institutions), each figure carrying its own observation year because the series lag unevenly and flattening them would fake a synchronicity the data does not have. Diagnosis is rule-based with the threshold printed beside every conclusion: South Africa’s 59.9% youth unemployment (2025) against the ILO’s 20% alarm line; Japan’s 58.8% working-age share; Singapore importing 280% of the energy it uses.
Complementarity is then computed, not asserted: one nation’s measured strength paired with another’s measured problem on the same axis. South Africa’s resources meet China’s research intensity; Malaysia’s energy exports meet Singapore’s imports; strong-law slow-growers can host the arbitration and custody that fast-growers’ capital inflows outrun. These pairs are what “growing together” means operationally — and they feed back into the solver as candidate new lanes.
The waterfall, and the yardstick that walked
The stochastic verdict was stuck at 42.2% for a reason worth confessing: the console kept re-evaluating the unimproved deal, and when the levers were first composed, each stage normalised success by its own centre surplus — the yardstick walked with the deal, and three levers moved the number +0.3 points. Anchored instead to signing-day surplus — does the improved agreement, in a bad future, still deliver what the original promised? — the waterfall moves honestly: the reference deal goes … → …, with … from new trade lanes, … from compounding capacity, and … from leapfrog displacement — substitution removes trade along with dependence, and the tool reports that cost rather than crediting every lever. Success was tightened first: an infeasible future counts as failure outright.
On the real networks, North America reaches … and the EU core … — past the gate — while the world scope tops out at …. The platform passes some deals and fails others, which is the only behaviour that makes passing mean anything.
25 August 2026
The dispute this document uses as its worked example is live, and it moved while the page was being written. On 1 July 2026 the United States declined to extend USMCA for a further sixteen years at the mandatory joint review, converting the agreement to annual reviews; it remains in force to 2036. On 24 August 2026 bilateral talks were suspended by Canada, followed by announced tariffs of 50% on Canadian automotive and steel imports, with an effective date in 2027. Section 232 rates were separately lowered from 25% to 15% on certain equipment categories on 1 June, and the Bureau of Industry and Security proposed adding fourteen derivative articles to the tariff scope on 6 August.
Those measures are reported rather than filed, and the platform keeps them on the other side of that line: they are extracted into typed records, solved as a second scenario, and never permitted to move the baseline. What they change here is only the reader’s sense of whether this is a historical illustration. It is not.
miril.net
Miril runs at miril.net — public TLS in front, the solver loopback-only behind a reverse proxy, on the same small cloud box that serves this suite’s identity provider. That adjacency dictates the operations: per-endpoint rate classes with a global two-slot solver semaphore, disk-persisted result caches so no visitor pays the three-minute world solve interactively, a three-strikes health watchdog, and a nightly database backup — because the ingested customs snapshot was fetched through a rate-limited public API and Comtrade revises history, a lost database is not fully re-fetchable. Every ceiling was measured on the deployment target before being written down.
The tiers, and what each one can actually do
Most analytics products sell the same answer at four speeds. That model does not fit here, because the expensive part of this problem is not compute — a bilateral solve finishes in milliseconds. The expensive part is what the model knows. So the tiers are drawn along two axes that genuinely change the answer: which negotiation instruments a workspace may impose on the programme, and whether it may bring its own private data into the network at all.
A negotiator does not trade in flows. They trade in devices: rules of origin, local-content floors, safeguards, offsets, reciprocity commitments. Each of those is implemented here as a real constraint on the linear programme, never as a label on a settings page. Switching one on moves the routes and moves the surplus, and if it makes the agreement infeasible the solver says so rather than quietly relaxing it. That property is what makes the tier boundary defensible: a cheaper plan is not being throttled, it is being sold a smaller vocabulary.
Measured on the US–Canada metals and autos network
One workspace, one scope, five configurations. Every figure below came from the deployed solver on filed customs data, not from an illustration:
| Configuration | Realised surplus | Difference | Status |
|---|---|---|---|
| Public data only | … | — | Optimal |
| + the workspace’s own plant data | … | … | Optimal |
| + safeguard, 60% import ceiling | … | … | Optimal |
| + regional value content, 75% | — | … | … |
Read the third row carefully: the safeguard costs …. That is not a failure of the instrument, it is the price of the policy, stated in the same units as the gain — which is the number a minister actually needs and almost never gets. And the fourth row is the more important one. A 75% local-content rule, the real USMCA automotive threshold, cannot be satisfied by the United States and Canada alone on these commodities. The pair does not have the qualifying supply. That single infeasibility is the entire argument for widening the table, arrived at arithmetically rather than asserted.
Every ingested customs flow, every World Bank endowment, every scope from a bilateral pair to the whole world, the Shapley allocation, the equilibrium path, the fulfilment waterfall, and the proposer that names which third countries can carry a deadlocked loop. Three resolutions a day, up to six nations, exact Shapley throughout. Nothing is crippled and no result is watermarked: a free workspace can evaluate a genuine dispute end to end and get the same numbers a paying one would from the same public inputs. What it cannot do is bring anything of its own.
The first paid step buys the two things that change the answer. Two thousand rows of private overlay — a plant under construction, capacity headroom behind last year’s shipments, an offtake signed after the filing year, committed capex with the year it lands — and the four instruments a single party can impose without needing the coalition to agree: rules of origin, local content, safeguards, and offsets. Twelve nations, exact Shapley to ten, which covers most regional blocs. This is the tier for one practitioner working real cases.
Two further devices unlock, and they are the ones that read a workspace’s proprietary layer rather than merely its capacity numbers. Reciprocity floors bind a pair’s exchange in both directions at once. Finished-goods floors require that a stated share of a country’s exports leave as manufactured product rather than raw input — the Indonesian nickel-ore device — and that instrument is only meaningful when the model knows whether a nation can actually finish the good. Public data cannot tell you that. Process capability enters as a know-how overlay, per nation and per commodity, and it is precisely the thing a competitor cannot reconstruct from public research. Twenty nations, fifty thousand overlay rows, twenty-five seats.
Forty nations, a million overlay rows, half a million Monte Carlo draws, and seven-year retention because that is the horizon over which a treaty is actually litigated. The limits at this tier are contractual rather than technical — but they are still finite, and stated. An unbounded tier is an unbounded bill and an unschedulable queue, and promising one would be the first dishonest number in this document.
For the technical reader — how the gate is enforced
Instrument availability is checked server-side on every call, and a request for an instrument above the workspace’s tier is refused, never silently downgraded. That distinction matters more than it looks: a route computed without a constraint you asked for is not a partial answer, it is the wrong answer, and it is worse than an error because it looks like an answer. The same reasoning governs instrument failure — an earlier version of the code caught exceptions and appended “not applied” to a notes array, which meant a workspace could request a 75% content floor and receive a fully-solved route honouring no such floor. It now raises.
Tenant isolation is by query, not by convention: every overlay read and delete carries tenant_id in the WHERE clause, so a valid key for one workspace cannot reach another’s rows even given the exact row id. API keys are stored only as SHA-256, so a database dump yields no working credentials. And the plan table on the pricing page is generated at request time from the same constants the admission check enforces — a hand-maintained pricing table drifts from the code behind it, and the drift always favours the seller.
One last property is worth stating plainly, because it is the honest test of whether any of this is real. The workspace returns the public-only result and the private result side by side, every time. The difference between them is the measurable value of a customer’s own data, in the same units as everything else. If that number is small, the page says so. A product that could not report a disappointing delta would not be worth the subscription it is asking for.
Co-development, collective defence, and covenants with numbers
A trade agreement between parties of grossly unequal size is a contract the larger party can rewrite whenever it wishes. That is not an accusation; it is a structural property of the instrument. USMCA sets rules of origin, dispute panels and tariff schedules, and is silent on the three things that actually decide whether neighbours prosper together: whether they build each other’s capability, whether they defend each other, and whether the largest of them agrees to bound its own power.
The extension modelled here adds three pillars, and every clause in it is a number rather than a sentiment — because a pledge that cannot be measured cannot be breached, and a pledge that cannot be breached is decoration. Each borrows an instrument that already exists and the threshold that instrument actually sets.
The three pledges, tested against North America today
| Undertaking | Precedent | United States | Canada | Mexico |
|---|---|---|---|---|
| Research intensity ≥1% of GDP | EU Lisbon / Cohesion | 3.45 | 1.79 | 0.25 |
| Defence spending ≥2% of GDP | NATO Wales 2014 | 3.42 | 1.31 | 0.89 |
| Government debt ≤60% of GDP | Maastricht Art. 126 | 115.8 | 64.1 | 50.3 |
Read the last row before the others. The borrowing restraint — the pledge not to export your own risk to your partners — is failed worst by the largest member, at nearly twice the Maastricht ceiling, and met only by the smallest. A covenant framework that produced the opposite result would be worth distrusting; this one was built from thresholds chosen by other unions, applied without adjustment, and it lands where the data lands.
The research row is the case for the co-development pillar in one figure. Thirty years of tariff-free access did not converge research capability across North America — it concentrated it, at a ratio of roughly fourteen to one. Free trade moves goods, not capability, and a member that only ever assembles never acquires the ability to design.
The third covenant is the one the user asked for and the one with no precedent pointed inward: a pledge not to use economic might to cripple a partner’s development. The EU built exactly this device in Regulation (EU) 2023/2675, its Anti-Coercion Instrument — and aimed it outward, at third countries. No bloc has pledged it to its own members.
Written as arithmetic, it becomes a concentration ceiling: no member may hold more than 60% of another member’s supply of a critical good without a standing supply guarantee. Tested on filed customs data, North America shows 19 dependencies above that line. The sharpest is Canada, which draws 100% of one filed dairy line from the United States. Whether that dependency is ever used is a political question this platform cannot answer. Whether it exists is a matter of record, and a member is entitled to know the number before signing anything.
For the technical reader — why there is no composite score
Results are reported per clause and per member, never rolled into an index. A composite would let a member’s defence contribution offset its debt position, and these clauses are not fungible: a partner cannot spend its way out of a coercion exposure. Three provisions — mutual defence, the shared industrial base, and progression up the value chain — carry no test at all, because this platform holds no data for them. They are listed as untestable rather than dropped, since a framework that showed only its measurable parts would understate what such a union actually requires.
Where the method stops
A system that tells governments it has mathematical proof of mutual benefit had better be unusually careful about what it asserts. Several deliberate refusals follow from that, and they cost capability:
The last one deserves emphasis, because the original prototype of this system failed exactly there. Its Monte Carlo engine drew samples from a fixed distribution centred at 1.05, independent of any input, which meant the "success probability" was approximately 100% for every route ever tested. The specification gated publication on that figure clearing 95%. A rubber stamp wearing the costume of a test.
Rebuilt honestly, the same route scores 42.2% — and fails. That inversion, from an engine that always says yes to one that says no when no is the answer, is the entire product.
Every figure in this essay comes from a solved run or a cited source: trade flows from UN Comtrade customs filings; household cost estimates from the Yale Budget Lab, Tax Foundation and US Joint Economic Committee; technology timelines from company and programme announcements. Growth rates in the glide path are stated assumptions applied uniformly, and should be replaced with sourced per-commodity figures before informing any real negotiation. Nothing here is investment, legal or diplomatic advice.