feat(fleet): add shared WireGuard profiles and bounded rover transport

Add portable shared WireGuard profiles while retaining Tailscale and Worker boundaries. Bound rover command/telemetry delivery, recovery and diagnostic capture across Core and Node.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:10:01 +03:00
parent bec20d63e2
commit e06ff9a214
180 changed files with 20140 additions and 400 deletions
@@ -3,6 +3,8 @@ import assert from 'node:assert/strict';
import {build} from 'esbuild';
const result=await build({entryPoints:[new URL('../src/core/fleet/useRoverControl.ts',import.meta.url).pathname],bundle:true,write:false,platform:'node',format:'esm',plugins:[{name:'hook-fixture',setup(b){
b.onResolve({filter:/^react$/},()=>({path:'react',namespace:'fixture'}));
b.onResolve({filter:/^\.\/roverTransport$/},()=>({path:'transport',namespace:'fixture-transport'}));
b.onLoad({filter:/.*/,namespace:'fixture-transport'},()=>({contents:`export class RoverHttpError extends Error{constructor(message,status){super(message);this.status=status;}};export const retainRoverTransport=()=>()=>{};export const roverConnection=()=>"connected";export async function roverRequest(url,body){const response=await fetch(url,{body:body?JSON.stringify(body):undefined});const result=await response.json();if(!response.ok)throw new RoverHttpError(result.detail,response.status);return result;}`}));
b.onLoad({filter:/.*/,namespace:'fixture'},()=>({contents:`export const useRef=v=>({current:v});export const useState=v=>[v,()=>{}];export const useCallback=f=>f;export const useEffect=f=>globalThis.roverEffects.push(f);`}));
}}]});
const {useRoverControl}=await import('data:text/javascript;base64,'+Buffer.from(result.outputFiles[0].contents).toString('base64'));
@@ -20,24 +22,24 @@ async function fixture(run){
}
test('command heartbeat sends neutral on lost blur, keeps session, and accepts new focused input',async()=>fixture(async f=>{
f.c.setInputGuard(()=>true);f.c.setDemand({left:1,right:-1});await flush();
assert.equal(f.calls.at(-1).body.left,1);f.blur();f.timers.find(t=>t.ms===100).f();await flush();
assert.equal(f.calls.at(-1).body.stop,false);assert.equal(f.calls.at(-1).body.left,0);
f.c.setDemand({left:1,right:1});await flush();assert.equal(f.calls.at(-1).body.left,0);
f.focus();f.timers.find(t=>t.ms===100).f();await flush();assert.equal(f.calls.at(-1).body.left,0);
assert.equal(f.calls.at(-1).body.left,1);f.blur();f.timers.find(t=>t.ms===50).f();await flush();
assert.ok(f.calls.at(-1).url.endsWith('/hold'));assert.equal('left' in f.calls.at(-1).body,false);
f.c.setDemand({left:1,right:1});await flush();assert.ok(f.calls.at(-1).url.endsWith('/hold'));
f.focus();f.timers.find(t=>t.ms===50).f();await flush();assert.equal(f.calls.at(-1).body.left,0);
f.c.setDemand({left:1,right:1});await flush();assert.equal(f.calls.at(-1).body.left,1);
assert.equal(f.calls.filter(x=>x.url.endsWith('/arm')).length,1);
}));
test('expired physical input prevents heartbeat from renewing remembered demand',async()=>fixture(async f=>{
let valid=true;f.c.setInputGuard(()=>valid);f.c.setDemand({left:1,right:-1});await flush();valid=false;
f.timers.find(t=>t.ms===100).f();await flush();assert.equal(f.calls.at(-1).body.stop,false);
f.timers.find(t=>t.ms===50).f();await flush();assert.equal(f.calls.at(-1).body.stop,false);
}));
test('no registered input scope cannot issue motion',async()=>fixture(async f=>{
f.c.setDemand({left:1,right:1});await flush();assert.equal(f.calls.at(-1).body.stop,false);
assert.equal(f.calls.some(x=>x.body?.left===1),false);
}));
test('hidden document sends only neutral without a visibility event',async()=>fixture(async f=>{
test('hidden document hands neutral readiness to Core even without a visibility event',async()=>fixture(async f=>{
f.c.setInputGuard(()=>true);f.hide();f.c.setDemand({left:1,right:1});await flush();
assert.equal(f.calls.at(-1).body.stop,false);assert.equal(f.calls.some(x=>x.body?.left===1),false);
assert.ok(f.calls.at(-1).url.endsWith('/hold'));assert.equal(f.calls.some(x=>x.body?.left===1),false);
}));
test('explicit pause clears demand without revoking session; explicit stop still revokes it',async()=>fixture(async f=>{