Moving waves checks the room the broker would sell: bandwidth for managed waves, and what is kept back

Managed waves need a channel as big as the wave and their bandwidth spare after your own traffic and
the share kept back, on leased fiber too. A move bumps CM_V so their capacity follows them, merging
needs the same size, and alien waves leave the kept-back channels alone. Pinned customers' badges
share one path graph per routing result.
This commit is contained in:
Christopher Hawker 2026-11-09 16:45:08 +11:00
parent 93d7c87dc7
commit 3554e9f700
10 changed files with 96 additions and 8 deletions

View file

@ -14,7 +14,7 @@ All notable changes to this project are documented here. The project follows
- Big networks no longer freeze for a moment at every new game day, above all with a NOC intern on duty. The intern now plans cache boxes, router ports and PNIs for every POP in one pass. On a network of 190 POPs the intern's shift held the page for about a tenth of a second on a computer and half a second on a phone; it now takes a few thousandths, and a whole day holds the page a quarter as long. The game plays exactly as before. - Big networks no longer freeze for a moment at every new game day, above all with a NOC intern on duty. The intern now plans cache boxes, router ports and PNIs for every POP in one pass. On a network of 190 POPs the intern's shift held the page for about a tenth of a second on a computer and half a second on a phone; it now takes a few thousandths, and a whole day holds the page a quarter as long. The game plays exactly as before.
- A low-latency boutique with a lot of its own fiber no longer stalls every day while it times its finance routes. On a big fiber network that check held the page for about a third of a second and now takes a few hundredths; checking customers who want a path without subsea or under a latency limit got quicker too. The game plays exactly as before. - A low-latency boutique with a lot of its own fiber no longer stalls every day while it times its finance routes. On a big fiber network that check held the page for about a third of a second and now takes a few hundredths; checking customers who want a path without subsea or under a latency limit got quicker too. The game plays exactly as before.
- The NOC intern no longer holds a big network for more than half a second each time it weighs taking out a spare wave. Before it decides, it checks every customer promised diverse paths, no subsea or a latency limit, and on a network of 390 POPs that check now takes a few hundredths of a second. Spotting new sovereign cloud and trading offers is about ten times quicker too, and the game plays exactly as before. - The NOC intern no longer holds a big network for more than half a second each time it weighs taking out a spare wave. Before it decides, it checks every customer promised diverse paths, no subsea or a latency limit, and on a network of 390 POPs that check now takes a few hundredths of a second. Spotting new sovereign cloud and trading offers is about ten times quicker too, and the game plays exactly as before.
- You can now move a customer to another path between the same two POPs, with the most diverse options listed first. Alien waves and leased fiber pairs move to another fiber, and circuits can be pinned to a path of your choice, falling back to normal routing while a link on it is down. - You can now move a customer to another path between the same two POPs, with the most diverse options listed first. Waves and leased fiber pairs move to another fiber with room for them, leaving alone what you keep back for your own traffic, and circuits can be pinned to a path of your choice, falling back to normal routing while a link on it is down.
## [3.2.0] — 2026-11-07 ## [3.2.0] — 2026-11-07

View file

@ -1770,9 +1770,12 @@
"customer_paths.name_follows_routing_again":"<b>{name}</b> folgt wieder dem Routing.", "customer_paths.name_follows_routing_again":"<b>{name}</b> folgt wieder dem Routing.",
"customer_paths.name_moved_to_fiber":"<b>{name}</b> ist auf {fiber} umgezogen.", "customer_paths.name_moved_to_fiber":"<b>{name}</b> ist auf {fiber} umgezogen.",
"customer_paths.name_now_rides_path":"<b>{name}</b> läuft jetzt über {path}.", "customer_paths.name_now_rides_path":"<b>{name}</b> läuft jetzt über {path}.",
"customer_paths.needs_a_g_channel":"Braucht einen Kanal mit {g} oder mehr",
"customer_paths.no_other_path":"Zwischen {a} und {b} gibt es gerade keinen anderen funktionierenden Pfad.", "customer_paths.no_other_path":"Zwischen {a} und {b} gibt es gerade keinen anderen funktionierenden Pfad.",
"customer_paths.no_other_working_fiber":"Zwischen {a} und {b} gibt es keine andere funktionierende Glasfaser. Bau eine, dann kannst du diesen Kunden darauf umziehen.", "customer_paths.no_other_working_fiber":"Zwischen {a} und {b} gibt es keine andere funktionierende Glasfaser. Bau eine, dann kannst du diesen Kunden darauf umziehen.",
"customer_paths.not_enough_free_channels":"Zu wenig freie Kanäle: {free} frei, {n} nötig", "customer_paths.not_enough_free_channels":"Zu wenig freie Kanäle: {free} frei, {n} nötig",
"customer_paths.not_enough_spare_capacity":"Zu wenig freie Kapazität: {free} übrig nach deinem eigenen Traffic und den {hold} %, die du zurückhältst, {g} nötig",
"customer_paths.not_enough_spare_channels":"Zu wenig freie Kanäle: {free} übrig nach den {hold} %, die du für deinen eigenen Traffic zurückhältst, {n} nötig",
"customer_paths.now_on":"Aktuell auf", "customer_paths.now_on":"Aktuell auf",
"customer_paths.only_your_own_fiber_rents_pairs":"Nur deine eigene Glasfaser kann Paare vermieten", "customer_paths.only_your_own_fiber_rents_pairs":"Nur deine eigene Glasfaser kann Paare vermieten",
"customer_paths.over_the_ms_budget":"Über dem Budget von {ms} ms", "customer_paths.over_the_ms_budget":"Über dem Budget von {ms} ms",

View file

@ -1768,9 +1768,12 @@
"customer_paths.name_follows_routing_again":"<b>{name}</b> vuelve a seguir el enrutamiento.", "customer_paths.name_follows_routing_again":"<b>{name}</b> vuelve a seguir el enrutamiento.",
"customer_paths.name_moved_to_fiber":"<b>{name}</b> se ha movido a {fiber}.", "customer_paths.name_moved_to_fiber":"<b>{name}</b> se ha movido a {fiber}.",
"customer_paths.name_now_rides_path":"<b>{name}</b> ahora va por {path}.", "customer_paths.name_now_rides_path":"<b>{name}</b> ahora va por {path}.",
"customer_paths.needs_a_g_channel":"Necesita un canal iluminado a {g} o más",
"customer_paths.no_other_path":"Ahora mismo no hay otra ruta operativa entre {a} y {b}.", "customer_paths.no_other_path":"Ahora mismo no hay otra ruta operativa entre {a} y {b}.",
"customer_paths.no_other_working_fiber":"No hay otra fibra operativa entre {a} y {b}. Construye una y podrás mover a este cliente a ella.", "customer_paths.no_other_working_fiber":"No hay otra fibra operativa entre {a} y {b}. Construye una y podrás mover a este cliente a ella.",
"customer_paths.not_enough_free_channels":"No hay canales libres suficientes: {free} libres, necesita {n}", "customer_paths.not_enough_free_channels":"No hay canales libres suficientes: {free} libres, necesita {n}",
"customer_paths.not_enough_spare_capacity":"No hay capacidad libre suficiente: quedan {free} tras tu propio tráfico y el {hold} % que reservas, necesita {g}",
"customer_paths.not_enough_spare_channels":"No hay canales libres suficientes: quedan {free} tras el {hold} % que reservas para tu propio tráfico, necesita {n}",
"customer_paths.now_on":"Ahora en", "customer_paths.now_on":"Ahora en",
"customer_paths.only_your_own_fiber_rents_pairs":"Solo tu propia fibra puede alquilar pares", "customer_paths.only_your_own_fiber_rents_pairs":"Solo tu propia fibra puede alquilar pares",
"customer_paths.over_the_ms_budget":"Supera el presupuesto de {ms} ms", "customer_paths.over_the_ms_budget":"Supera el presupuesto de {ms} ms",

View file

@ -1768,9 +1768,12 @@
"customer_paths.name_follows_routing_again":"<b>{name}</b> suit de nouveau le routage.", "customer_paths.name_follows_routing_again":"<b>{name}</b> suit de nouveau le routage.",
"customer_paths.name_moved_to_fiber":"<b>{name}</b> a été déplacé vers {fiber}.", "customer_paths.name_moved_to_fiber":"<b>{name}</b> a été déplacé vers {fiber}.",
"customer_paths.name_now_rides_path":"<b>{name}</b> passe maintenant par {path}.", "customer_paths.name_now_rides_path":"<b>{name}</b> passe maintenant par {path}.",
"customer_paths.needs_a_g_channel":"Il faut un canal allumé à {g} ou plus",
"customer_paths.no_other_path":"Il n'y a pas d'autre chemin en service entre {a} et {b} pour le moment.", "customer_paths.no_other_path":"Il n'y a pas d'autre chemin en service entre {a} et {b} pour le moment.",
"customer_paths.no_other_working_fiber":"Il n'y a pas d'autre fibre en service entre {a} et {b}. Construis-en une et tu pourras y déplacer ce client.", "customer_paths.no_other_working_fiber":"Il n'y a pas d'autre fibre en service entre {a} et {b}. Construis-en une et tu pourras y déplacer ce client.",
"customer_paths.not_enough_free_channels":"Pas assez de canaux libres : {free} libres, il en faut {n}", "customer_paths.not_enough_free_channels":"Pas assez de canaux libres : {free} libres, il en faut {n}",
"customer_paths.not_enough_spare_capacity":"Pas assez de capacité libre : il reste {free} après ton propre trafic et les {hold} % que tu gardes de côté, il en faut {g}",
"customer_paths.not_enough_spare_channels":"Pas assez de canaux libres : il en reste {free} après les {hold} % que tu gardes pour ton propre trafic, il en faut {n}",
"customer_paths.now_on":"Actuellement sur", "customer_paths.now_on":"Actuellement sur",
"customer_paths.only_your_own_fiber_rents_pairs":"Seule ta propre fibre peut louer des paires", "customer_paths.only_your_own_fiber_rents_pairs":"Seule ta propre fibre peut louer des paires",
"customer_paths.over_the_ms_budget":"Au-delà du budget de {ms} ms", "customer_paths.over_the_ms_budget":"Au-delà du budget de {ms} ms",

View file

@ -1768,9 +1768,12 @@
"customer_paths.name_follows_routing_again":"<b>{name}</b> segue di nuovo il routing.", "customer_paths.name_follows_routing_again":"<b>{name}</b> segue di nuovo il routing.",
"customer_paths.name_moved_to_fiber":"<b>{name}</b> spostato su {fiber}.", "customer_paths.name_moved_to_fiber":"<b>{name}</b> spostato su {fiber}.",
"customer_paths.name_now_rides_path":"<b>{name}</b> ora passa per {path}.", "customer_paths.name_now_rides_path":"<b>{name}</b> ora passa per {path}.",
"customer_paths.needs_a_g_channel":"Serve un canale acceso a {g} o più",
"customer_paths.no_other_path":"Al momento non c'è un altro percorso funzionante tra {a} e {b}.", "customer_paths.no_other_path":"Al momento non c'è un altro percorso funzionante tra {a} e {b}.",
"customer_paths.no_other_working_fiber":"Non c'è un'altra fibra funzionante tra {a} e {b}. Costruiscine una e potrai spostarci questo cliente.", "customer_paths.no_other_working_fiber":"Non c'è un'altra fibra funzionante tra {a} e {b}. Costruiscine una e potrai spostarci questo cliente.",
"customer_paths.not_enough_free_channels":"Canali liberi insufficienti: {free} liberi, ne servono {n}", "customer_paths.not_enough_free_channels":"Canali liberi insufficienti: {free} liberi, ne servono {n}",
"customer_paths.not_enough_spare_capacity":"Capacità libera insufficiente: restano {free} dopo il tuo traffico e il {hold}% che tieni da parte, ne servono {g}",
"customer_paths.not_enough_spare_channels":"Canali liberi insufficienti: ne restano {free} dopo il {hold}% che tieni da parte per il tuo traffico, ne servono {n}",
"customer_paths.now_on":"Ora su", "customer_paths.now_on":"Ora su",
"customer_paths.only_your_own_fiber_rents_pairs":"Solo la tua fibra può affittare coppie", "customer_paths.only_your_own_fiber_rents_pairs":"Solo la tua fibra può affittare coppie",
"customer_paths.over_the_ms_budget":"Oltre il budget di {ms} ms", "customer_paths.over_the_ms_budget":"Oltre il budget di {ms} ms",

View file

@ -1768,9 +1768,12 @@
"customer_paths.name_follows_routing_again":"<b>{name}</b> volta a seguir o roteamento.", "customer_paths.name_follows_routing_again":"<b>{name}</b> volta a seguir o roteamento.",
"customer_paths.name_moved_to_fiber":"<b>{name}</b> movido para {fiber}.", "customer_paths.name_moved_to_fiber":"<b>{name}</b> movido para {fiber}.",
"customer_paths.name_now_rides_path":"<b>{name}</b> agora passa por {path}.", "customer_paths.name_now_rides_path":"<b>{name}</b> agora passa por {path}.",
"customer_paths.needs_a_g_channel":"Precisa de um canal aceso a {g} ou mais",
"customer_paths.no_other_path":"Agora não há outro caminho funcionando entre {a} e {b}.", "customer_paths.no_other_path":"Agora não há outro caminho funcionando entre {a} e {b}.",
"customer_paths.no_other_working_fiber":"Não há outra fibra funcionando entre {a} e {b}. Construa uma e você poderá mover este cliente para ela.", "customer_paths.no_other_working_fiber":"Não há outra fibra funcionando entre {a} e {b}. Construa uma e você poderá mover este cliente para ela.",
"customer_paths.not_enough_free_channels":"Canais livres insuficientes: {free} livres, precisa de {n}", "customer_paths.not_enough_free_channels":"Canais livres insuficientes: {free} livres, precisa de {n}",
"customer_paths.not_enough_spare_capacity":"Capacidade livre insuficiente: sobram {free} depois do seu próprio tráfego e dos {hold}% que você reserva, precisa de {g}",
"customer_paths.not_enough_spare_channels":"Canais livres insuficientes: sobram {free} depois dos {hold}% que você reserva para o seu próprio tráfego, precisa de {n}",
"customer_paths.now_on":"Agora em", "customer_paths.now_on":"Agora em",
"customer_paths.only_your_own_fiber_rents_pairs":"Só a sua própria fibra pode alugar pares", "customer_paths.only_your_own_fiber_rents_pairs":"Só a sua própria fibra pode alugar pares",
"customer_paths.over_the_ms_budget":"Acima do orçamento de {ms} ms", "customer_paths.over_the_ms_budget":"Acima do orçamento de {ms} ms",

View file

@ -8,8 +8,13 @@ const trenchOf=l=>l.kind==='vxc'?'fab:'+l.prov:(l.trench||l.id);
const pathCity=c=>CITY[c].name,pathStr=p=>p.map(pathCity).join(' → '); const pathCity=c=>CITY[c].name,pathStr=p=>p.map(pathCity).join(' → ');
const samePair=(l,a,b)=>(l.a===a&&l.b===b)||(l.a===b&&l.b===a); const samePair=(l,a,b)=>(l.a===a&&l.b===b)||(l.a===b&&l.b===a);
const fibLab=l=>tr('customer_paths.fiber_label',{name:l.cname?esc(l.cname):capName(l),km:Math.round(l.km).toLocaleString()}); const fibLab=l=>tr('customer_paths.fiber_label',{name:l.cname?esc(l.cname):capName(l),km:Math.round(l.km).toLocaleString()});
// Why this fiber cannot take this customer, in the same terms as the offers for it. // Why this fiber cannot take this customer, in the same terms as the market that sold it: waves only where the broker
function fiberNo(b,l){if(b.type==='wwave'){const n=b.slots||1,free=freeCh(l);return free>=n?'':tr('customer_paths.not_enough_free_channels',{free:Math.max(0,free),n});} // could sell them, after the share kept back for your own traffic.
function fiberNo(b,l){const n=b.slots||1,hold=S.cm.hold;
if(b.type==='wwave'){const free=freeCh(l),spare=cmSpare(l,'spec');return spare>=n?'':free<n?tr('customer_paths.not_enough_free_channels',{free:Math.max(0,free),n}):tr('customer_paths.not_enough_spare_channels',{free:spare,n,hold});}
// A managed wave rides one channel of your lit capacity, so it needs an optic that big and that many Gbps spare.
if(b.type==='mwave'){const g=b.g||100,free=Math.max(0,cmFreeG(l));if(cmOptG(l)<g)return tr('customer_paths.needs_a_g_channel',{g:fmtCap(g)});
return free>=n*g?'':tr('customer_paths.not_enough_spare_capacity',{free:fmtCap(free),g:fmtCap(n*g),hold});}
if(!l.own)return tr('customer_paths.only_your_own_fiber_rents_pairs'); if(!l.own)return tr('customer_paths.only_your_own_fiber_rents_pairs');
if(b.type==='dfpair')return pairFree(l)?'':tr('customer_paths.its_spare_pairs_are_taken'); if(b.type==='dfpair')return pairFree(l)?'':tr('customer_paths.its_spare_pairs_are_taken');
return S.biz.some(x=>x!==b&&x.link===l.id&&['pairs','capfib','dfpair'].includes(x.type))?tr('customer_paths.its_spare_pairs_are_taken'):'';} return S.biz.some(x=>x!==b&&x.link===l.id&&['pairs','capfib','dfpair'].includes(x.type))?tr('customer_paths.its_spare_pairs_are_taken'):'';}
@ -28,7 +33,10 @@ function pathWalk(G,a,b,cost){const dist={[a]:0},prev={},done=new Set();for(;;){
for(const e of G.N[u]||[]){const v=e.a===u?e.b:e.a,nd=ud+cost(e);if(nd<(dist[v]??Infinity)){dist[v]=nd;prev[v]=u;}}} for(const e of G.N[u]||[]){const v=e.a===u?e.b:e.a,nd=ud+cost(e);if(nd<(dist[v]??Infinity)){dist[v]=nd;prev[v]=u;}}}
if(dist[b]===undefined)return null;const p=[b];while(p[0]!==a)p.unshift(prev[p[0]]);return p;} if(dist[b]===undefined)return null;const p=[b];while(p[0]!==a)p.unshift(prev[p[0]]);return p;}
const pathHops=(G,p)=>{const o=[];for(let i=1;i<p.length;i++){const e=G.E[hopKey(p[i-1],p[i])];if(!e)return null;o.push(e);}return o;}; const pathHops=(G,p)=>{const o=[];for(let i=1;i<p.length;i++){const e=G.E[hopKey(p[i-1],p[i])];if(!e)return null;o.push(e);}return o;};
const pinUp=b=>!!pathHops(pathEdges(),b.pin); // The panels ask for every pinned customer: one graph per routing (a new R), not one per customer.
let PIN_G=null;
const pinG=()=>{const c=PIN_G;if(!c||c.R!==R||c.S!==S||c.d!==S.day||c.n!==S.links.length)PIN_G={R,S,d:S.day,n:S.links.length,G:pathEdges()};return PIN_G.G;};
const pinUp=b=>!!pathHops(pinG(),b.pin);
// Where the circuit runs today. Scenic circuits remember it; the others take the shortest path of their kind. // Where the circuit runs today. Scenic circuits remember it; the others take the shortest path of their kind.
function pathNow(b,G){if(b.pin&&pathHops(G,b.pin))return b.pin; function pathNow(b,G){if(b.pin&&pathHops(G,b.pin))return b.pin;
const r=R.l2route&&R.l2route[b.id+'>'+b.city+'>'+b.city2];if(r&&r[0]){const p=r[0].ns.slice();if(p[0]!==b.city)p.reverse();if(pathHops(G,p))return p;} const r=R.l2route&&R.l2route[b.id+'>'+b.city+'>'+b.city2];if(r&&r[0]){const p=r[0].ns.slice();if(p[0]!==b.city)p.reverse();if(pathHops(G,p))return p;}

View file

@ -1,10 +1,12 @@
Object.assign(ACT,{ Object.assign(ACT,{
pathOpen:({id})=>{const b=S.biz.find(x=>x.id===id);if(b&&pathKind(b))pathModal(b);}, pathOpen:({id})=>{const b=S.biz.find(x=>x.id===id);if(b&&pathKind(b))pathModal(b);},
pathMove:({id,link})=>{const b=S.biz.find(x=>x.id===id),l=b&&pathKind(b)==='fiber'&&fiberTargets(b).find(t=>t.l.id===link&&!t.no);if(!l)return; pathMove:({id,link})=>{const b=S.biz.find(x=>x.id===id),l=b&&pathKind(b)==='fiber'&&fiberTargets(b).find(t=>t.l.id===link&&!t.no);if(!l)return;
// A carrier already renting waves on that fiber: one contract, as when it orders more there. // A carrier already renting waves of that kind (and size) on that fiber: one contract, as when it orders more there.
const more=b.type==='wwave'&&S.biz.find(x=>x!==b&&x.type==='wwave'&&x.link===link&&x.name===b.name); const wv=b.type==='wwave'||b.type==='mwave',what=(x,n)=>b.type==='wwave'?wwWhat(l.l,n):cmWhat(l.l,cmWP(x.g),n);
if(more){more.slots=(more.slots||0)+(b.slots||0);more.rate+=b.rate;more.since=Math.min(more.since??0,b.since??0);more.mood=Math.min(more.mood??100,b.mood??100);more.what=wwWhat(l.l,more.slots);S.biz=S.biz.filter(x=>x!==b);} const more=wv&&S.biz.find(x=>x!==b&&x.type===b.type&&x.link===link&&x.name===b.name&&x.g===b.g);
else{b.link=link;if(b.type==='wwave')b.what=wwWhat(l.l,b.slots||1);} if(more){more.slots=(more.slots||0)+(b.slots||0);more.rate+=b.rate;more.since=Math.min(more.since??0,b.since??0);more.mood=Math.min(more.mood??100,b.mood??100);more.what=what(more,more.slots);S.biz=S.biz.filter(x=>x!==b);}
else{b.link=link;if(wv)b.what=what(b,b.slots||1);}
CM_V++; // managed waves come off their fiber's capacity (mwG()), which caches by fiber
closeModal();toast(tr('customer_paths.name_moved_to_fiber',{name:esc(b.name),fiber:fibLab(l.l)}),'good');sfx('build');after();}, closeModal();toast(tr('customer_paths.name_moved_to_fiber',{name:esc(b.name),fiber:fibLab(l.l)}),'good');sfx('build');after();},
pathPin:({id,via})=>{const b=S.biz.find(x=>x.id===id);if(!b||pathKind(b)!=='circuit'||typeof via!=='string')return;const p=via.split(','); pathPin:({id,via})=>{const b=S.biz.find(x=>x.id===id);if(!b||pathKind(b)!=='circuit'||typeof via!=='string')return;const p=via.split(',');
if(p.length<2||p[0]!==b.city||p[p.length-1]!==b.city2||new Set(p).size!==p.length||!pathHops(pathEdges(),p))return; if(p.length<2||p[0]!==b.city||p[p.length-1]!==b.city2||new Set(p).size!==p.length||!pathHops(pathEdges(),p))return;

View file

@ -1769,9 +1769,12 @@
"customer_paths.name_follows_routing_again":"<b>{name}</b> follows routing again.", "customer_paths.name_follows_routing_again":"<b>{name}</b> follows routing again.",
"customer_paths.name_moved_to_fiber":"<b>{name}</b> moved to {fiber}.", "customer_paths.name_moved_to_fiber":"<b>{name}</b> moved to {fiber}.",
"customer_paths.name_now_rides_path":"<b>{name}</b> now rides {path}.", "customer_paths.name_now_rides_path":"<b>{name}</b> now rides {path}.",
"customer_paths.needs_a_g_channel":"Needs a channel lit at {g} or more",
"customer_paths.no_other_path":"There is no other working path between {a} and {b} right now.", "customer_paths.no_other_path":"There is no other working path between {a} and {b} right now.",
"customer_paths.no_other_working_fiber":"There is no other working fiber between {a} and {b}. Build one, and you can move this customer onto it.", "customer_paths.no_other_working_fiber":"There is no other working fiber between {a} and {b}. Build one, and you can move this customer onto it.",
"customer_paths.not_enough_free_channels":"Not enough free channels: {free} free, needs {n}", "customer_paths.not_enough_free_channels":"Not enough free channels: {free} free, needs {n}",
"customer_paths.not_enough_spare_capacity":"Not enough spare capacity: {free} left after your own traffic and the {hold}% you keep back, needs {g}",
"customer_paths.not_enough_spare_channels":"Not enough spare channels: {free} left after the {hold}% you keep back for your own traffic, needs {n}",
"customer_paths.now_on":"Now on", "customer_paths.now_on":"Now on",
"customer_paths.only_your_own_fiber_rents_pairs":"Only your own fiber can rent out pairs", "customer_paths.only_your_own_fiber_rents_pairs":"Only your own fiber can rent out pairs",
"customer_paths.over_the_ms_budget":"Over the {ms} ms budget", "customer_paths.over_the_ms_budget":"Over the {ms} ms budget",

View file

@ -55,6 +55,66 @@ test('a carrier already renting waves on the new fiber ends up with one contract
assert.deepEqual(errors, []); assert.deepEqual(errors, []);
}); });
test('a wave leaves alone the channels kept back for your own traffic', (t) => {
// 47 channels lit of 64: 17 free, but a quarter of the fiber is kept back, so 1 spare.
const { ev, errors } = game(t, wave + "S.cm.hold=25;S.links.find(l=>l.id==='c').ch=Array(47).fill('zr4');");
assert.match(ev("fiberTargets(S.biz[0]).find(x=>x.l.id==='c').no"), /1 left after the 25% you keep back.*needs 2/);
ev("ACT.pathMove({id:'w',link:'c'})");
assert.equal(biz(ev, 'w', 'link'), 'a', 'refused');
ev("S.cm.hold=0;ACT.pathMove({id:'w',link:'c'})");
assert.equal(biz(ev, 'w', 'link'), 'c', 'nothing kept back: it fits');
assert.deepEqual(errors, []);
});
// Four managed 400G waves, 1.6T in all, carved out of fiber a's lit capacity.
const mwave = (id = 'm', link = 'a', g = 400, slots = 4) => `S.biz.push({id:'${id}',type:'mwave',g:${g},name:'Photon Express',city:'nyc',city2:'ash',link:'${link}',slots:${slots},bw:1,rate:5000,reqs:[],mood:80,since:0,day:0,route:'normal',what:'x'});`;
test('managed waves need that much spare lit capacity on the new fiber, on leased fiber too, and their capacity moves with them', (t) => {
// c has 1.6T lit, but a quarter is kept back: 1.2T spare, room for three of the four. b has 3.2T: 2.4T spare.
const { ev, errors } = game(t, mwave() + "S.cm.hold=25;S.links.find(l=>l.id==='c').ch=Array(4).fill('zr4');");
const no = () => JSON.parse(ev("JSON.stringify(Object.fromEntries(fiberTargets(S.biz[0]).map(x=>[x.l.id,x.no])))"));
assert.match(no().c, /Not enough spare capacity/);
assert.equal(no().b, '');
ev("ACT.pathMove({id:'m',link:'c'})");
assert.equal(biz(ev, 'm', 'link'), 'a', '1.6T does not fit in 1.2T');
// A leased fiber is lit capacity like any other: the reason is the room, not whose glass it is.
ev("S.links.find(l=>l.id==='b').own=false;S.links.find(l=>l.id==='c').own=false;");
assert.equal(no().b, '');
assert.doesNotMatch(no().c, /own fiber/);
assert.match(no().c, /spare capacity/);
// What the fiber gives your own traffic follows the waves, at once.
assert.equal(ev("mwG(S.links.find(l=>l.id==='a'))"), 1600);
ev("ACT.pathMove({id:'m',link:'b'})");
assert.equal(biz(ev, 'm', 'link'), 'b');
assert.equal(ev("mwG(S.links.find(l=>l.id==='a'))"), 0);
assert.equal(ev("mwG(S.links.find(l=>l.id==='b'))"), 1600);
assert.equal(ev("dfCap0(S.links.find(l=>l.id==='a'))"), 3200);
assert.equal(ev("dfCap0(S.links.find(l=>l.id==='b'))"), 1600);
assert.match(biz(ev, 'm', 'what'), /4/);
assert.deepEqual(errors, []);
});
test('a managed wave needs a channel as big as it is; a carrier renting the same size there gets one contract, another size does not', (t) => {
{ const { ev, errors } = game(t, mwave('m', 'a', 800, 1) + "S.cm.hold=0;");
assert.match(ev("fiberTargets(S.biz[0]).find(x=>x.l.id==='c').no"), /Needs a channel lit at/, '400G optics only');
ev("S.links.find(l=>l.id==='c').ch=Array(8).fill('zr8');");
assert.equal(ev("fiberTargets(S.biz[0]).find(x=>x.l.id==='c').no"), '');
assert.deepEqual(errors, []); }
{ const { ev, errors } = game(t, mwave() + mwave('m2', 'b', 100, 2) + "S.cm.hold=0;");
ev("ACT.pathMove({id:'m',link:'b'})");
assert.equal(ev("S.biz.filter(b=>b.type==='mwave'&&b.link==='b').length"), 2, '400G and 100G waves stay apart');
assert.equal(biz(ev, 'm2', 'slots'), 2);
assert.equal(ev("mwG(S.links.find(l=>l.id==='b'))"), 1800);
assert.deepEqual(errors, []); }
{ const { ev, errors } = game(t, mwave() + mwave('m2', 'b', 400, 2) + "S.cm.hold=0;");
ev("ACT.pathMove({id:'m',link:'b'})");
assert.equal(ev("S.biz.filter(b=>b.type==='mwave').length"), 1);
assert.equal(biz(ev, 'm2', 'slots'), 6); assert.equal(biz(ev, 'm2', 'rate'), 10000); assert.equal(biz(ev, 'm2', 'g'), 400);
assert.match(biz(ev, 'm2', 'what'), /6/);
assert.equal(ev("mwG(S.links.find(l=>l.id==='b'))"), 2400);
assert.deepEqual(errors, []); }
});
test('fiber pairs follow the same rules as signing them: your own fiber, and pairs still free', (t) => { test('fiber pairs follow the same rules as signing them: your own fiber, and pairs still free', (t) => {
for (const type of ['dfpair', 'pairs', 'capfib']) { for (const type of ['dfpair', 'pairs', 'capfib']) {
const { ev, errors } = game(t, pair(type) + pair('pairs', 'q', 'b') + "S.links.find(l=>l.id==='e').x=1;"); const { ev, errors } = game(t, pair(type) + pair('pairs', 'q', 'b') + "S.links.find(l=>l.id==='e').x=1;");