Build standard: never take a fiber dark under a customer's wave; the intern no longer skips leased pairs and IRUs

The build standard's Apply could swap the line system on a fiber that carries a
sold alien wave or a Lambda Bazaar managed wave, taking those customers dark for
a day with no warning. The intern refused any fiber with any customer on it,
leased pairs and IRUs included, though a line-system swap cannot touch them.

One helper next to fiberOk(), dfWaveCust(), says whether a customer rides the
fiber's line system (every fiber type but glass: dfpair, pairs, capfib), and both
bstdDarkOk() and opsDarkPre() use it. bstdPlan() holds such a fiber (J.held) and
lists it in J.wv; the sheet and the MCP quote give that reason. The link
panel's own upgrade button (ACT.upSys) still swaps with a warning toast.
This commit is contained in:
jvanvik 2026-11-09 22:47:21 +01:00
parent 1f76639b8f
commit 286ae48207
14 changed files with 102 additions and 24 deletions

View file

@ -9,6 +9,7 @@ All notable changes to this project are documented here. The project follows
- Linking to an island or remote town where no subsea cable lands, like Iqaluit or Adamstown, now says that a satellite can get there too. Each of your teleports that reaches it gets a button to its order sheet; without one, the window says where a teleport would have to go (#83).
- IPv4 notices in the NOC's notifications, like "Your IPv4 is full", now have an Open button that takes you to the bank's Address space, as the notice's own button does (#150).
- In dark mode, red warning text is now a lighter red that reads well on the dark panels, and the capacity market's Hot and Cool tags take the night colours instead of staying bright pastel chips (#80).
- "Bring everything up now" in the build standard no longer takes a fiber dark for a day while a customer's alien or managed wave rides it. Such a fiber keeps its line system and the sheet says why; the upgrade button on the fiber itself still does it when you choose. Your intern waits for those fibers too, but no longer skips fibers that only carry leased pairs or IRUs, which a line system swap never touches.
- The NOC dashboard's connections list no longer breaks when one of your fabric ports is already at 400G, the biggest a fabric port gets: it offers a LAG member instead of an upgrade.
- Broadband cities can now go IPv6-only with 464XLAT, a second way to save IPv4 next to CGNAT. Start it from a city's Home broadband, which also says what it does to your monthly IPv4 bill: its home routers are swapped over a month or more, paid as each one goes in (new homes there get one too, at the same price), and the homes then need no IPv4 address of their own, only a share of a NAT64 pool at up to 256 homes per address, with fewer refunds than CGNAT at the same ratio. The bank's Address space section shows your homes as public, behind CGNAT and IPv6-only, with the NAT64 ratio next to the CGNAT one, and says which of the two to stretch when space runs out.
- CGNAT gets a little cheaper every year: the world moves to IPv6 about two points a year, so less of your homes' traffic needs IPv4 and the CGNAT and NAT64 boxes carry less of it.

View file

@ -429,6 +429,7 @@
"bstd.g_port":"Ports und Peering",
"bstd.generator":"Generator",
"bstd.held":{"one":"Eine Glasfaser behält vorerst ihr Line System, bis sie ruhig ist oder ein paralleler Link ihre Last für den Tag trägt, an dem sie dunkel ist. Bis dahin bekommt sie die schnellste Optik, die ihr Line System nimmt.","other":"{n} Glasfasern behalten vorerst ihr Line System, bis sie ruhig sind oder ein paralleler Link ihre Last für den Tag trägt, an dem sie dunkel sind. Bis dahin bekommen sie die schnellste Optik, die ihr Line System nimmt."},
"bstd.held_wave":{"one":"Eine Glasfaser behält ihr Line System: Auf ihr läuft die Wave eines Kunden, die am Tag des Tauschs mit ihr dunkel wäre. Der Upgrade-Button an der Glasfaser selbst macht es trotzdem, wann du willst. Bis dahin bekommt sie die schnellste Optik, die ihr Line System nimmt.","other":"{n} Glasfasern behalten ihr Line System: Auf ihnen laufen Waves von Kunden, die am Tag des Tauschs mit ihnen dunkel wären. Der Upgrade-Button an jeder Glasfaser macht es trotzdem, wann du willst. Bis dahin bekommen sie die schnellste Optik, die ihr Line System nimmt."},
"bstd.hire_note":"Stell in Ops einen NOC-Praktikanten ein, dann hält er jeden POP, Port und jede Glasfaser auf dem Standard: ein paar Jobs pro Tag, die meistbelasteten zuerst, im Monatsbudget und nur mit Geld übrig.",
"bstd.in_n_cities":"In mindestens {n} Städten",
"bstd.intern_keeps":"{name} hält das Netz auf Standard",

View file

@ -427,6 +427,7 @@
"bstd.g_port":"Puertos y peering",
"bstd.generator":"generador",
"bstd.held":{"one":"Una fibra mantiene por ahora su sistema de línea, hasta que vaya tranquila o un enlace paralelo pueda llevar su carga el día que quede apagada. Mientras tanto recibe la óptica más rápida que admite su sistema de línea.","other":"{n} fibras mantienen por ahora su sistema de línea, hasta que vayan tranquilas o un enlace paralelo pueda llevar su carga el día que queden apagadas. Mientras tanto reciben la óptica más rápida que admite su sistema de línea."},
"bstd.held_wave":{"one":"Una fibra mantiene su sistema de línea: lleva la wave de un cliente, que se apagaría con ella el día del cambio. El botón de mejora de la propia fibra lo hace igualmente, cuando tú decidas. Mientras tanto recibe la óptica más rápida que admite su sistema de línea.","other":"{n} fibras mantienen su sistema de línea: llevan waves de clientes, que se apagarían con ellas el día del cambio. El botón de mejora de cada fibra lo hace igualmente, cuando tú decidas. Mientras tanto reciben la óptica más rápida que admite su sistema de línea."},
"bstd.hire_note":"Contrata a un becario del NOC en Ops y mantendrá cada POP, puerto y fibra en el estándar: unos pocos trabajos al día, los más cargados primero, dentro de un presupuesto mensual y solo con dinero de sobra.",
"bstd.in_n_cities":"En al menos {n} ciudades",
"bstd.intern_keeps":"{name} mantiene la red en el estándar",

View file

@ -427,6 +427,7 @@
"bstd.g_port":"Ports et peering",
"bstd.generator":"groupe électrogène",
"bstd.held":{"one":"Une fibre garde son système de ligne pour l’instant, jusqu’à ce qu’elle soit calme ou qu’un lien parallèle puisse porter sa charge le jour où elle est éteinte. D’ici là, elle reçoit l’optique la plus rapide que son système de ligne accepte.","other":"{n} fibres gardent leur système de ligne pour l’instant, jusqu’à ce qu’elles soient calmes ou qu’un lien parallèle puisse porter leur charge le jour où elles sont éteintes. D’ici là, elles reçoivent l’optique la plus rapide que leur système de ligne accepte."},
"bstd.held_wave":{"one":"Une fibre garde son système de ligne : la wave d’un client y passe et s’éteindrait avec elle le jour du changement. Le bouton de mise à niveau de la fibre elle-même le fait quand même, quand tu le décides. D’ici là, elle reçoit l’optique la plus rapide que son système de ligne accepte.","other":"{n} fibres gardent leur système de ligne : des waves de clients y passent et s’éteindraient avec elles le jour du changement. Le bouton de mise à niveau de chaque fibre le fait quand même, quand tu le décides. D’ici là, elles reçoivent l’optique la plus rapide que leur système de ligne accepte."},
"bstd.hire_note":"Recrute un stagiaire NOC dans Ops et il garde chaque POP, port et fibre au standard : quelques chantiers par jour, les plus chargés d’abord, dans un budget mensuel et seulement avec de l’argent en trop.",
"bstd.in_n_cities":"Dans au moins {n} villes",
"bstd.intern_keeps":"{name} garde le réseau au standard",

View file

@ -427,6 +427,7 @@
"bstd.g_port":"Porte e peering",
"bstd.generator":"generatore",
"bstd.held":{"one":"Una fibra tiene per ora il suo sistema di linea, finché non è tranquilla o un link parallelo può reggerne il carico il giorno in cui resta spenta. Nel frattempo riceve l’ottica più veloce che il suo sistema di linea accetta.","other":"{n} fibre tengono per ora il loro sistema di linea, finché non sono tranquille o un link parallelo può reggerne il carico il giorno in cui restano spente. Nel frattempo ricevono l’ottica più veloce che il loro sistema di linea accetta."},
"bstd.held_wave":{"one":"Una fibra tiene il suo sistema di linea: ci passa la wave di un cliente, che resterebbe spenta con lei il giorno del cambio. Il pulsante di upgrade sulla fibra stessa lo fa comunque, quando decidi tu. Nel frattempo riceve l’ottica più veloce che il suo sistema di linea accetta.","other":"{n} fibre tengono il loro sistema di linea: ci passano wave di clienti, che resterebbero spente con loro il giorno del cambio. Il pulsante di upgrade su ogni fibra lo fa comunque, quando decidi tu. Nel frattempo ricevono l’ottica più veloce che il loro sistema di linea accetta."},
"bstd.hire_note":"Assumi uno stagista NOC in Ops e terrà ogni POP, porta e fibra a standard: qualche lavoro al giorno, i più carichi prima, dentro un budget mensile e solo con soldi in avanzo.",
"bstd.in_n_cities":"In almeno {n} città",
"bstd.intern_keeps":"{name} tiene la rete a standard",

View file

@ -427,6 +427,7 @@
"bstd.g_port":"Portas e peering",
"bstd.generator":"gerador",
"bstd.held":{"one":"Uma fibra mantém por enquanto o seu sistema de linha, até ficar tranquila ou um link paralelo poder levar a carga dela no dia em que ela fica apagada. Até lá, ela recebe a óptica mais rápida que o seu sistema de linha aceita.","other":"{n} fibras mantêm por enquanto o seu sistema de linha, até ficarem tranquilas ou um link paralelo poder levar a carga delas no dia em que ficam apagadas. Até lá, elas recebem a óptica mais rápida que o seu sistema de linha aceita."},
"bstd.held_wave":{"one":"Uma fibra mantém o seu sistema de linha: a wave de um cliente passa por ela e ficaria apagada com ela no dia da troca. O botão de atualizar da própria fibra faz isso mesmo assim, quando você quiser. Até lá, ela recebe a óptica mais rápida que o seu sistema de linha aceita.","other":"{n} fibras mantêm o seu sistema de linha: waves de clientes passam por elas e ficariam apagadas com elas no dia da troca. O botão de atualizar de cada fibra faz isso mesmo assim, quando você quiser. Até lá, elas recebem a óptica mais rápida que o seu sistema de linha aceita."},
"bstd.hire_note":"Contrate um estagiário de NOC em Ops e ele mantém cada POP, porta e fibra no padrão: alguns trabalhos por dia, os mais carregados primeiro, dentro de um orçamento mensal e só com dinheiro sobrando.",
"bstd.in_n_cities":"Em pelo menos {n} cidades",
"bstd.intern_keeps":"{name} mantém a rede no padrão",

View file

@ -448,8 +448,10 @@ const API_CMD={
bstdSet:{args:[['k','bstdKey'],['v','string',false]],watch:['popStd'],
doc:'Set one target of the build standard: g router model, rt routers, site2 second building, gen generator, lag LAG members on transit, IX and PNI ports, split LAGs across both buildings, ix an IX port wherever the city has an exchange, pni PNIs per network in at least that many cities, sys line system, opt fastest optics, wv waves at least that size. g and sys are also what the intern\'s routers and optup orders standardize on. Without v it steps to the next value; with v (a position in the list the sheet shows, 0 first, "keep" first) it picks that one.'},
bstdApply:{args:[['quote','string',false],['q','shownTotal',false]],watch:['pops','transit','pni','ixp','ixn','ixSite','links','spares'],
quote:a=>{const q=bstdQuote(false);return {setup:q.cost,monthly:q.mo,key:bstdPlanKey(bstdPlan(false)),blocked:q.held.map(w=>w.split('|').map(c=>CITY[c].name).join('–')+': its line system waits until the fiber is quiet or a parallel link can carry its load for the day it goes dark')};},
doc:'Bring everything up to the build standard now, the busiest first, while cash lasts: routers, buildings, generators, LAG members, IX ports, PNIs, line systems, optics and waves. A line-system swap waits unless the fiber is quiet or a parallel link carries its load: such a fiber gets the best optics its line system takes, and the quote lists it under blocked. The quote is the whole bill. quote and q (optional): the plan\'s key and the total you were shown; another plan, or a total more than 1% away, is refused and the sheet shown again.'},
quote:a=>{const q=bstdQuote(false),nm=w=>w.split('|').map(c=>CITY[c].name).join('–');return {setup:q.cost,monthly:q.mo,key:bstdPlanKey(bstdPlan(false)),
blocked:[...q.wait.map(w=>nm(w)+': its line system waits until the fiber is quiet or a parallel link can carry its load for the day it goes dark'),
...q.wv.map(w=>nm(w)+': its line system waits: a customer\'s wave rides it and would go dark with it for the day (upSys on the fiber still swaps it)')]};},
doc:'Bring everything up to the build standard now, the busiest first, while cash lasts: routers, buildings, generators, LAG members, IX ports, PNIs, line systems, optics and waves. A line-system swap waits unless the fiber is quiet or a parallel link carries its load, and while a customer\'s alien or managed wave rides the fiber (leased pairs and IRUs do not count: they are glass): such a fiber gets the best optics its line system takes, and the quote lists it under blocked. The quote is the whole bill. quote and q (optional): the plan\'s key and the total you were shown; another plan, or a total more than 1% away, is refused and the sheet shown again.'},
/* ---------- utilities ---------- */
utilityRouteServers:{args:[['city','cityId',false]],watch:['rs'],
doc:'Join the route server at every IX you have a port at. One call does what the button does.'},

View file

@ -305,9 +305,10 @@ function opsAround(l){const adj={};for(const x of S.links){if(x===l||linkDown(x)
// answers (OPS_ROUTE, then {dark}: opsDarkTrial(), in play in the route worker).
// Nothing rides the fiber: no traffic of its own (customers' circuits are in it), none on an express through it (#58).
const opsUnused=l=>{const L=(R&&R.load)||{};return !(L[l.id]>1e-6)&&!xpOver(l.id).some(x=>L[x.id]>1e-6);};
// What a day dark comes to, said without routing: false (a customer rides it, or it carries traffic with no other way
// between its cities), true (nothing rides it, so nothing is lost), null (a routing decides: opsDarkTrial()).
function opsDarkPre(l){if(S.biz.some(b=>b.link===l.id))return false;return opsUnused(l)?true:opsAround(l)?null:false;}
// What a day dark comes to, said without routing: false (a customer's wave rides its line system, or it carries traffic
// with no other way between its cities), true (nothing rides it, so nothing is lost), null (a routing decides:
// opsDarkTrial()). Leased pairs and IRUs are glass: a line-system swap never touches them. ws: as dfWaveCust() takes it.
function opsDarkPre(l,ws){if(dfWaveCust(l,ws))return false;return opsUnused(l)?true:opsAround(l)?null:false;}
const OPS_ROUTE={route:true};
// X.dk.t counts the tests that route.
function* opsDark(l,X){let k=opsDarkPre(l);if(k===false)return false;if(X.dirty){yield OPS_ROUTE;X.dirty=false;k=opsDarkPre(l);}

View file

@ -77,8 +77,9 @@ function bstdLine(D){const a=bstdPopParts(D),n=['lag','split','ix','pni','sys','
rest of that chain waits. A job that needs another chain's work first (optics only the new router model takes, a split
that needs the second building) names that job in dep and waits for it too. Whether a fiber may go dark is settled
here, not on the way, so the plan is what the button does and its sum is the quote.
intern: only where the intern may work (per-POP exceptions). J.held: fibers whose line system has to wait. */
function bstdPlan(intern){const J=[];J.held=[];if(!S||!S.popStd||pzOn())return J;const D=bstd(),here=c=>!intern||opsHere('std',c);
intern: only where the intern may work (per-POP exceptions). J.held: fibers whose line system has to wait; J.wv: those
of them that wait because a customer's wave rides the line system (dfWaveCust()), which no traffic test changes. */
function bstdPlan(intern){const J=[];J.held=[];J.wv=[];if(!S||!S.popStd||pzOn())return J;const D=bstd(),here=c=>!intern||opsHere('std',c);
const load=c=>Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));
const cs=Object.keys(S.pops).filter(here),ld={};for(const c of cs)ld[c]=load(c);cs.sort((a,b)=>ld[b]-ld[a]||(a<b?-1:1));
// Router ports: what the POP will have once its own jobs are done, less what pending PNI augments will take.
@ -119,7 +120,7 @@ function bstdPlan(intern){const J=[];J.held=[];if(!S||!S.popStd||pzOn())return J
if(!q||!take(c,q.slots))continue;const tier=q.tier;k--;
job('port','pni','n:'+net+'@'+c,c+' '+net,q.cost,pniMo({net,tier,n:1},0),()=>{const x=pniQuote(c,net,tier,resv(c));if(!x||x.why||x.ex||!spend(x.cost))return false;pniPlace(x);return true;},{c});}}}
// Fiber and waves, hottest first. A POP excepted from the order keeps its links as they are too.
if(D.sys!=='keep'||D.opt!=='keep'||D.wv!=='keep'){const sp={...(S.spares||{})},dk=new Map(),wv=new Map();
if(D.sys!=='keep'||D.opt!=='keep'||D.wv!=='keep'){const sp={...(S.spares||{})},dk=new Map(),wv=new Map();let wc=null;
const ls=S.links.filter(l=>(l.kind==='df'||l.kind==='wave')&&here(l.a)&&here(l.b)&&S.pops[l.a]&&S.pops[l.b]).map(l=>({l,u:(R.load[l.id]||0)/Math.max(1e-9,capOf(l))})).sort((a,b)=>b.u-a.u||(a.l.id<b.l.id?-1:1));
// Waves: the size each goes up to. The decom order hands back the smaller waves a pair no longer needs, judged with
// the sizes these upgrades give: never pay a month's rent on one it is about to return.
@ -131,13 +132,15 @@ function bstdPlan(intern){const J=[];J.held=[];if(!S||!S.popStd||pzOn())return J
if(l.kind==='wave'){const t=wv.get(l);if(t){const nm=Math.round(waveMo(l.km,l.sub,t)*(l.mult||1));job('fiber','wv',ch,l.a+'|'+l.b,nm,nm-(l.mo||0),()=>{ACT.upLink({id:l.id,tier:t});return l.tier===t;},{l});}continue;}
if(l.eqDown>S.day)continue;
let sys=l.sys;const lit=l.ready<=S.day,nx=D.sys!=='keep'&&BSTD_SYS[sys]<BSTD_SYS[D.sys]&&sysNext({sys});
// A lit fiber goes dark for a day. Busy with nothing parallel to carry it: it keeps its line system for now, and
// gets the best optics that one takes. A parallel fiber goes dark first in this plan: it waits for next time.
// The intern's plan leaves the rest to the shift's own test (opsDark(): a routing without the fiber), as the optical
// order does: here only what is known without one (opsDarkPre()), and a fiber that failed the test this week.
if(nx&&techOk('sys',nx,DF_SYS[nx].lvl)){
if(lit&&!(intern?!(OPTUP_NO.get(l.id)>S.day)&&opsDarkPre(l)!==false:bstdDarkOk(l)))J.held.push(l);
else if(lit&&(intern?pairLinks(l.a,l.b).some(x=>x!==l&&dk.get(x.id)):!bstdDarkOk(l,dk))){J.held.push(l);continue;}
// A lit fiber goes dark for a day. Busy with nothing parallel to carry it, or a customer's wave on its line system:
// it keeps its line system for now, and gets the best optics that one takes. A parallel fiber goes dark first in
// this plan: it waits for next time. The intern's plan leaves the rest to the shift's own test (opsDark(): a
// routing without the fiber), as the optical order does: here only what is known without one (opsDarkPre()), and
// a fiber that failed the test this week.
if(nx&&techOk('sys',nx,DF_SYS[nx].lvl)){const ws=lit?wc||(wc=dfWaveSet()):null;
if(lit&&dfWaveCust(l,ws)){J.held.push(l);J.wv.push(l);}
else if(lit&&!(intern?!(OPTUP_NO.get(l.id)>S.day)&&opsDarkPre(l,ws)!==false:bstdDarkOk(l,undefined,ws)))J.held.push(l);
else if(lit&&(intern?pairLinks(l.a,l.b).some(x=>x!==l&&dk.get(x.id)):!bstdDarkOk(l,dk,ws))){J.held.push(l);continue;}
else{const busy=lit&&(intern?!opsUnused(l):bstdBusy(l));
while(BSTD_SYS[sys]<BSTD_SYS[D.sys]){const to=sysNext({sys});if(!to||!techOk('sys',to,DF_SYS[to].lvl))break;
const s0=sys;job('fiber','sys',ch,l.a+'|'+l.b,sysCost(to)*(to==='cl'&&l.own?Math.max(1,l.pairs|0):1),0,()=>{if(l.sys!==s0)return false;ACT.upSys({id:l.id});return l.sys===to;},{l,dark:lit,busy});sys=to;}
@ -189,16 +192,17 @@ function bstdOptJobs(l,sys,sp,V,take,ch){const rg=c=>V[c]?V[c].g:(S.pops[c].rgen
// The new ones could not go in (ports, cash): the old optics go back in from the shelf.
(l.ch=l.ch||[]).push(...Array(k).fill(o0));S.spares[o0]-=k;return false;}});}
return out;}
// The button's test of a line-system swap, which darkens the fiber for a day: only while it carries little, or its
// parallel links can take its load. No routing, so the quote is what the click does. (The intern routes: opsDark().)
// The button's test of a line-system swap, which darkens the fiber for a day: never under a customer's wave (it would go
// dark with the fiber: dfWaveCust()), and only while it carries little, or its parallel links can take its load. No
// routing, so the quote is what the click does. (The intern routes: opsDark().)
// ex: fibers already going dark today (id → whether they carry traffic): they carry nothing for this one, and one whose
// traffic leans on its parallel links keeps them lit.
// traffic leans on its parallel links keeps them lit. ws: as dfWaveCust() takes it.
const bstdBusy=l=>((R.load&&R.load[l.id])||0)>Math.max(1,capOf(l)*0.1);
// Express lightpaths (#58) ride the fiber's glass: its own load says nothing about them, and its parallel links do not
// carry them, so an express with any traffic at all keeps the fiber lit (the line system waits, as for a busy fiber).
// The intern's routing test needs no such rule: an express goes dark with its fiber there (opsDarkTrial()).
const bstdXpBusy=l=>xpSlots(l)>0&&xpOver(l.id).some(x=>((R.load&&R.load[x.id])||0)>1e-6);
function bstdDarkOk(l,ex){if(bstdXpBusy(l))return false;const P=pairLinks(l.a,l.b).filter(x=>x!==l);if(ex&&P.some(x=>ex.get(x.id)))return false;if(!bstdBusy(l))return true;
function bstdDarkOk(l,ex,ws){if(dfWaveCust(l,ws)||bstdXpBusy(l))return false;const P=pairLinks(l.a,l.b).filter(x=>x!==l);if(ex&&P.some(x=>ex.get(x.id)))return false;if(!bstdBusy(l))return true;
return P.filter(x=>!linkDown(x)&&!x.standby&&!(ex&&ex.has(x.id))).reduce((a,x)=>a+Math.max(0,capOf(x)-((R.load&&R.load[x.id])||0)),0)>=((R.load&&R.load[l.id])||0);}
/* Do the plan's jobs in order. can(j): may it be paid for (budget, floor, cash); pay(j): run it, true if it took.
dark(j, ex): may the first job that darkens a fiber go ahead (ex: fibers gone dark so far, as bstdDarkOk() takes them),
@ -219,9 +223,11 @@ function bstdDo(J,can,pay){const g=bstdRun(J,can,pay,function*(j,ex){return bstd
const bstdPrice=j=>j.price?j.price():j.cost;
// The sheet's summary and the MCP quote: how much is below the standard, and what bringing it all up costs. The plan is
// what the button does, so its sum is the bill. held: the fibers whose line system waits ("fra|ams"); they are below it.
// Of them, wait: the ones that wait for their traffic, wv: the ones that wait for a customer's wave to leave.
function bstdQuote(intern){const J=bstdPlan(intern),P=new Set(),Q=new Set(),L=new Set(J.held.map(l=>l.id));let cost=0,mo=0;
for(const j of J){cost+=j.cost;mo+=j.mo;if(j.grp==='pop')P.add(j.c);else if(j.grp==='port')Q.add(j.ch);else L.add(j.l.id);}
return {cost:Math.round(cost),mo:Math.round(mo),pops:P.size,ports:Q.size,links:L.size,n:J.length,held:J.held.map(l=>l.a+'|'+l.b)};}
const w=l=>l.a+'|'+l.b;
return {cost:Math.round(cost),mo:Math.round(mo),pops:P.size,ports:Q.size,links:L.size,n:J.length,held:J.held.map(w),wait:J.held.filter(l=>!J.wv.includes(l)).map(w),wv:J.wv.map(w)};}
// The optics order lights the standard's fastest optics while this order keeps to a standard that wants them.
const bstdFast=()=>!!(S.popStd&&opsHired()&&S.ops.on.std&&bstd().opt==='fast');
/* The intern's shift: the same plan, every job through the budget and the cash floor at what it costs then, a few at a

View file

@ -95,7 +95,15 @@ const linkIds=()=>{const m=new Map();for(const l of S.links)if(!m.has(l.id))m.se
function fiberUse(){const sold=new Map(),dfp=new Map(),pairs=new Set();
for(const b of S.biz){if(b.type==='wwave')sold.set(b.link,(sold.get(b.link)||0)+(b.slots||0));else if(b.type==='dfpair')dfp.set(b.link,(dfp.get(b.link)||0)+1);else if(b.type==='pairs'||b.type==='capfib')pairs.add(b.link);}
return {sold,dfp,pairs};}
function fiberOk(b,ids){const l=ids?ids.get(b.link):S.links.find(x=>x.id===b.link);if(!l)return false;if(b.type==='dfpair'||b.type==='pairs'||b.type==='capfib')return l.ready<=S.day&&!(l.cut>S.day);return l.ready<=S.day&&!(l.cut>S.day)&&!(l.eqDown>S.day)&&(b.type!=='mwave'||dfLit(l)>=mwG(l));}
// Fiber customers come in two kinds: glass (a leased pair, an IRU, a hyperscaler's pairs) needs only the fiber; the rest
// (alien and managed waves) ride its line system too, and go dark with it for the day a line-system swap takes.
const FIB_GLASS=new Set(['dfpair','pairs','capfib']);
function fiberOk(b,ids){const l=ids?ids.get(b.link):S.links.find(x=>x.id===b.link);if(!l)return false;if(FIB_GLASS.has(b.type))return l.ready<=S.day&&!(l.cut>S.day);return l.ready<=S.day&&!(l.cut>S.day)&&!(l.eqDown>S.day)&&(b.type!=='mwave'||dfLit(l)>=mwG(l));}
// A customer rides this fiber's line system: a swap would take it dark (the build standard and the intern wait for the
// player). ws: the fibers that carry one (dfWaveSet()), when many fibers are asked about at once.
const dfOnSys=b=>!!b.link&&!!BIZ_T[b.type]&&!!BIZ_T[b.type].fiber&&!FIB_GLASS.has(b.type);
const dfWaveSet=()=>{const s=new Set();for(const b of S.biz)if(dfOnSys(b))s.add(b.link);return s;};
const dfWaveCust=(l,ws)=>ws?ws.has(l.id):S.biz.some(b=>b.link===l.id&&dfOnSys(b));
function soldSlots(l,u){return u?u.sold.get(l.id)||0:S.biz.filter(b=>b.type==='wwave'&&b.link===l.id).reduce((a,b)=>a+(b.slots||0),0);}
// Spare capacity other carriers can rent on a dark fiber (#51): free channels for alien waves, and on your own build
// a spare pair in the trench. Random offers and broker listings follow the same rules and the same prices.

View file

@ -28,7 +28,7 @@ function bstdModal(msg){if(!S||pzOn())return;const D=bstd(),q=bstdQuote(false),h
const n={pop:q.pops,port:q.ports,fiber:q.links},w=q.held.length;
h+=`<section><h3>${tr('bstd.below')}</h3>${q.n||w?BSTD_GRP.map(([g,lab])=>`<div class="kv"><span>${tr(lab)}</span><b>${n[g]}</b></div>`).join('')
+`<div class="kv"><span>${tr('bstd.cost_now')}</span><b>${fmt$(q.cost)}</b></div><div class="kv"><span>${tr('bstd.cost_mo')}</span><b>${tr('common.price_mo',{price:opsMo$(q.mo)})}</b></div>`
+(w?`<p class="meta">${trn('bstd.held',w)}</p>`:'')
+(q.wait.length?`<p class="meta">${trn('bstd.held',q.wait.length)}</p>`:'')+(q.wv.length?`<p class="meta">${trn('bstd.held_wave',q.wv.length)}</p>`:'')
:`<p class="meta">${S.popStd?tr('bstd.all_up'):tr('bstd.none_set')}</p>`}</section>`;
// The intern keeps it there: the order's switch and budget, or a word on hiring one.
h+=`<section><h3>${tr('ops.o_std')}</h3>${hired?`<div class="ops-o${on?' on':''}"><div class="ops-h"><span class="ops-i" aria-hidden="true">${INTERNS[S.ops.intern].i}</span><div class="grow"><div class="nm">${esc(tr('bstd.intern_keeps',{name:opsName()}))}</div><div class="meta">${tr('ops.o_std_around_d')}</div></div>

View file

@ -428,6 +428,7 @@
"bstd.g_port":"Ports and peering",
"bstd.generator":"generator",
"bstd.held":{"one":"One fiber keeps its line system for now, until it is quiet or a parallel link can carry its load for the day it goes dark. Until then it gets the fastest optics its line system takes.","other":"{n} fibers keep their line system for now, until they are quiet or a parallel link can carry their load for the day they go dark. Until then they get the fastest optics their line system takes."},
"bstd.held_wave":{"one":"One fiber keeps its line system: a customer's wave rides it and would go dark with it for the day of the swap. The upgrade button on the fiber itself still does it, when you choose. Until then it gets the fastest optics its line system takes.","other":"{n} fibers keep their line system: customers' waves ride them and would go dark with them for the day of the swap. The upgrade button on each fiber still does it, when you choose. Until then they get the fastest optics their line system takes."},
"bstd.hire_note":"Hire a NOC intern in Ops and they keep every POP, port and fiber to the standard: a few jobs a day, the busiest first, within a monthly budget and only with money to spare.",
"bstd.in_n_cities":"In at least {n} cities",
"bstd.intern_keeps":"{name} keeps the network to it",

View file

@ -283,6 +283,51 @@ test('a busy fiber with nothing parallel keeps its line system: the sheet, the b
assert.deepEqual(errors, []);
});
test("a customer's wave keeps its fiber's line system, for the button and the intern; leased pairs and IRUs do not", t => {
const h = load({ agent: true });
t.after(() => h.dom.window.close());
const { ev, errors } = h;
ev(BASE);
const chonk = ev("RG.findIndex(r=>r.n==='Chonk 800')");
ev(`ACT.buildPop({city:'par'});for(const c of ['fra','ams','par']){S.pops[c].rgen=${chonk};S.pops[c].routers=4;}`);
// Two quiet fibers: Amsterdam's carries a carrier's managed 100G wave (Lambda Bazaar), Paris's nothing.
const a = fiber(ev, 'fra', 'ams', ['zr4', 'zr4']), b = fiber(ev, 'fra', 'par', ['zr4', 'zr4']);
ev(`S.biz.push({id:'mw',name:'Photon Express',city:'fra',city2:'ams',link:${lit(a)},slots:1,g:100,type:'mwave',bw:1,rate:1000,reqs:[],mood:100,since:S.day})`);
const quiet = 'compute();for(const l of S.links)R.load[l.id]=0;';
ev(quiet);
assert.equal(ev("fiberOk(S.biz.find(b=>b.id==='mw'))"), true);
std(ev, { sys: 'roadm' });
const q = JSON.parse(ev('JSON.stringify(bstdQuote(false))'));
assert.deepEqual([q.held, q.wv, q.wait, q.links, q.n], [['fra|ams'], ['fra|ams'], [], 2, 1], 'only Paris\'s fiber is on the bill');
ev(`closeModal();${quiet}`);
const dry = JSON.parse(ev("JSON.stringify(apiRun('bstdApply',{},{dryRun:true}))"));
assert.match(dry.quote.blocked[0], /^Frankfurt–Amsterdam: its line system waits: a customer's wave rides it/);
ev(`${quiet}ACT.bstdOpen()`);
const txt = h.dom.window.document.getElementById('modalCard').textContent;
assert.match(txt, /One fiber keeps its line system: a customer's wave rides it/);
assert.doesNotMatch(txt, /until it is quiet/, 'not the reason a busy fiber waits for');
ev(`${quiet}document.querySelector('#modalCard [data-act="bstdApply"]').click()`);
const L = id => JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(id)}))`));
assert.equal(L(b).sys, 'roadm', 'the free fiber is swapped');
assert.deepEqual([L(a).sys, L(a).eqDown > ev('S.day')], ['lite', false], 'the wave\'s fiber stays lit');
ev('compute()');
assert.equal(ev("fiberOk(S.biz.find(b=>b.id==='mw'))"), true, 'and the customer is served');
// The intern waits on it too: no swap, however quiet.
hire(ev, 'annie');
ev(`S.day+=2;${quiet}opsDay(S.day)`);
assert.equal(L(a).sys, 'lite');
// Glass only (an IRU, or a hyperscaler's pairs on your own build) never notices a line-system swap: the intern goes ahead.
for (const type of ['dfpair', 'pairs']) {
ev(`S.links.find(l=>l.id===${lit(a)}).sys='lite';S.links.find(l=>l.id===${lit(a)}).own=true;S.biz=S.biz.filter(b=>b.id!=='mw'&&b.id!=='g');S.biz.push({id:'g',name:'Strand Theft Auto',city:'fra',city2:'ams',link:${lit(a)},type:'${type}',bw:1,rate:1000,reqs:[],mood:100,since:S.day})`);
ev(`S.day+=2;${quiet}`);
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(true).held)')), [], type + ': nothing waits');
ev(`${quiet}opsDay(S.day)`);
assert.deepEqual([L(a).sys, L(a).eqDown > ev('S.day')], ['roadm', true], type + ': the intern swapped it');
assert.equal(ev("fiberOk(S.biz.find(b=>b.id==='g'))"), true, type + ': and the pair stays up');
}
assert.deepEqual(errors, []);
});
test('optics a new router model takes are on the bill with it, and wait for its swap', t => {
const { ev, errors } = game(t);
// Edge Lords take no zr8: the Absolute Unit does.
@ -304,7 +349,7 @@ test('optics a new router model takes are on the bill with it, and wait for its
ev('ACT.bstdApply()');
assert.equal(c0 - ev('S.cash'), q.cost);
assert.deepEqual(JSON.parse(ev(`JSON.stringify(S.links.find(l=>l.id===${lit(a)}).ch)`)), ['zr8', 'zr8']);
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(false))')), { cost: 0, mo: 0, pops: 0, ports: 0, links: 0, n: 0, held: [] }, 'one tap brought everything up');
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(false))')), { cost: 0, mo: 0, pops: 0, ports: 0, links: 0, n: 0, held: [], wait: [], wv: [] }, 'one tap brought everything up');
assert.deepEqual(errors, []);
});
@ -377,7 +422,7 @@ test('"Bring everything up now" spends what the quote said and does what it list
const c0 = ev('S.cash');
ev("document.querySelector('#modalCard [data-act=\"bstdApply\"]').click()");
assert.equal(c0 - ev('S.cash'), q.cost, 'it cost exactly the quote');
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(false))')), { cost: 0, mo: 0, pops: 0, ports: 0, links: 0, n: 0, held: [] }, 'and everything is up to the standard');
assert.deepEqual(JSON.parse(ev('JSON.stringify(bstdQuote(false))')), { cost: 0, mo: 0, pops: 0, ports: 0, links: 0, n: 0, held: [], wait: [], wv: [] }, 'and everything is up to the standard');
assert.match(ev("document.getElementById('toasts').textContent"), /jobs done for the build standard/);
assert.match(ev("document.getElementById('modalCard').textContent"), /Everything meets the standard/);
assert.equal(ev('S.ixSite.ams'), 'ab');

View file

@ -69,6 +69,15 @@ test('no way around, or a customer on the fiber: no swap; bigger optics instead,
heat(ev2);
ev2('opsDay(S.day)');
assert.equal(fiber(ev2).sys, 'lite');
// A managed wave too. Leased pairs and IRUs are glass: the swap never touches them, so it goes ahead.
for (const [type, sys] of [['mwave', 'lite'], ['dfpair', 'roadm'], ['pairs', 'roadm']]) {
const { ev: ev3, errors: e3 } = game(t, `S.biz.push({id:'cx',name:'Customer',city:'fra',city2:'ams',type:'${type}',link:'f',slots:1,g:100,bw:1,rate:1})`);
order(ev3, { at: 80, swap: false });
heat(ev3);
ev3('opsDay(S.day)');
assert.equal(fiber(ev3).sys, sys, type);
assert.deepEqual(e3, []);
}
assert.deepEqual(errors, []);
});