RouteScript: a safe rule language for the Auto-TE controller
This commit is contained in:
parent
46fe9e4eba
commit
d99addad88
3 changed files with 12 additions and 2 deletions
|
|
@ -4,6 +4,15 @@ All notable changes to this project are documented here. The project follows
|
|||
[Semantic Versioning](https://semver.org/). Each release is deployed to
|
||||
[seriesoftub.es](https://seriesoftub.es).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- RouteScript: program your Auto-TE controller from the NOC tab with a tiny
|
||||
rule language: `spill at 80%`, `prefer pni for goggle`, `avoid transit for
|
||||
netchill`, `cap transit cogentle at 20 gbps`, `drain paris`, `avoid link
|
||||
fra-ams` and `blackhole ddos`. Check runs a dry run against live traffic
|
||||
and shows what would change; Deploy makes it real. Typos get a "did you
|
||||
mean". Two new badges: Script Kiddie and Fat Finger.
|
||||
|
||||
## [1.9.0] — 2026-10-23
|
||||
|
||||
- Zoom in twice as far as before, handy for crowded spots like the UAE,
|
||||
|
|
|
|||
|
|
@ -1248,7 +1248,7 @@ function compute(){
|
|||
else noPath=true;
|
||||
minF=Math.min(minF,amt/b.bw);tot+=amt;}
|
||||
R2.l2lat[b.id]=noPath?Infinity:maxLat;R2.l2[b.id]=b.bw*minF;R2.egT.l2=(R2.egT.l2||0)+tot;if((b.reqs||[]).includes('diverse'))R2.div[b.id]=diversePaths(b.city,b.city2);}
|
||||
const TE=!!(S.te&&S.te.on),TR=teRules();R2.teMoved=0;R2.teBlack=0;const teCache={},SPILL=TR&&TR.spill?TR.spill:1;
|
||||
const TE=!!(S.te&&S.te.on),TR=teRules();R2.teMoved=0;const teCache={},SPILL=TR&&TR.spill?TR.spill:1;
|
||||
const spPath=(sp,src,dst)=>{const path=[],ns=[dst];let v=dst;while(v!==src){const l=sp.prev[v];path.push(l);v=l.a===v?l.b:l.a;ns.push(v);}return {path,ns};};
|
||||
const altPath=(src,dst,base)=>{const key=src+'>'+dst,c0=teCache[key];
|
||||
if(c0===false)return null;if(c0&&c0.path.every(l=>res[l.id]>1e-3)&&c0.ns.every(n=>nres[n]===undefined||nres[n]>1e-3))return c0;
|
||||
|
|
|
|||
|
|
@ -147,7 +147,8 @@ test('RouteScript: parses safely, reports errors helpfully, and changes routing'
|
|||
ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'})");
|
||||
ev("ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buyTransit({city:'fra',net:'lvl',tier:1});ACT.buyTE();compute()");
|
||||
let p = JSON.parse(ev("JSON.stringify(teParse('spill at 80%\\ncap transit cogentle at 3 gbps\\nprefer ix for goggle\\nnonsense here\\navoid transit for gogle'))"));
|
||||
assert.equal(p.errors.length, 1, 'only the nonsense line fails (gogle is close enough)');
|
||||
assert.equal(p.errors.length, 2, 'the nonsense line and the typo fail');
|
||||
assert.match(p.errors[1], /Did you mean Goggle/, 'typos get a suggestion');
|
||||
p = JSON.parse(ev("JSON.stringify(teParse('avoid transit for zzzzqqq').errors)"));
|
||||
assert.match(p[0], /unknown network/);
|
||||
assert.match(ev("teParse('drain pariss').errors[0]"), /Did you mean Paris/);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue