Guard the Navigator release against deployed plugin runtimes

This commit is contained in:
unimatrixgit 2026-11-29 23:44:50 +01:00
commit 9baca377a7
20 changed files with 402 additions and 39 deletions

View file

@ -0,0 +1,49 @@
name: Guild and Smuggler Navigator Build
on:
workflow_dispatch:
push:
branches: ['feat/smuggler-navigator-*']
jobs:
navigator:
runs-on: dune-ci
steps:
- name: Check out exact revision
shell: bash
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
git init .
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
git checkout --detach FETCH_HEAD
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: '9.2.1'
- name: Build the reviewed Navigator plugin transition
shell: bash
run: |
set -euo pipefail
for module in JarvisConnector DuneRealmsGUI DuneMenus; do
gradle --no-daemon -p "$module" test jar
done
python3 tools/plugin_navigator_transition.py
python3 tools/test_plugin_fleet_install.py -v
python3 tools/test_plugin_pack_properties.py -v
mkdir navigator-artifacts
cp JarvisConnector/build/libs/jarvistranslator.jar DuneRealmsGUI/build/libs/DunerealmsGUI.jar DuneMenus/build/libs/DuneMenus.jar navigator-artifacts/
printf '%s\n' "$(git rev-parse HEAD)" > navigator-artifacts/SOURCE_COMMIT
python3 tools/build-unified-resourcepack.py --source "$GITHUB_SHA" --output "navigator-artifacts/DuneRealms-Resources-${GITHUB_SHA}.zip"
echo "446c0b60fa6e6752ff5260bb22c9a76280b7b10ffa03c3cca4b08f4d9320105b navigator-artifacts/DuneRealms-Resources-${GITHUB_SHA}.zip" | sha256sum --check
python3 tools/write-plugin-manifest.py navigator-artifacts "$GITHUB_SHA"
cp tools/install-plugin-fleet.py tools/plugin_menu_pack.py tools/plugin_backend_abi.py tools/plugin_pillager_abi.py tools/plugin_navigator_transition.py tools/plugin_fleet_rollback.py tools/plugin_pack_properties.py tools/publish-plugin-menu.py tools/navigator-transition.json JarvisConnector/src/test/resources/retained-jarvis-public-abi.json navigator-artifacts/
(cd navigator-artifacts && sha256sum -- *.jar *.zip *.json *.py SOURCE_COMMIT > SHA256SUMS)
- uses: actions/upload-artifact@v3
with:
name: DuneRealms-Navigator
path: navigator-artifacts/
if-no-files-found: error

View file

@ -50,7 +50,10 @@ jobs:
run: |
set -euo pipefail
python3 tools/test_plugin_ci_policy.py -v
python3 tools/test_plugin_pillager_profile.py -v
pillager_input="$(mktemp -d)"
python3 tools/plugin_navigator_transition.py --stage-pillager-baseline "$pillager_input/baseline"
DUNE_PILLAGER_BASELINE_DIR="$pillager_input/baseline" python3 tools/test_plugin_pillager_profile.py -v
python3 tools/plugin_navigator_transition.py
python3 tools/test_plugin_pillager_art.py -v
python3 tools/test_plugin_fleet_install.py -v
python3 tools/test_plugin_menu_pack.py -v

View file

@ -1,7 +1,7 @@
import java.security.MessageDigest
plugins { java }
group = "com.dunerealms"
version = "2.0.7-pillager1"
version = "2.0.8-navigator1"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")

View file

@ -13,7 +13,7 @@ final class CanvasProvider implements FullscreenProvider {
if(services==null||!services.isEnabled())return false;
Map<Integer,String> images=new HashMap<>();
try{if(prepared)for(Card card:screen.cards()){var inventory=screen.contents();if(card.slot()>=0&&card.slot()<inventory.length){String image=art.image(inventory[card.slot()]);if(!image.isEmpty())images.put(card.slot(),image);}}}catch(Exception failure){plugin.getLogger().warning("Menu artwork unavailable: "+failure.getClass().getSimpleName());}
Map<Integer,Runnable> actions=new HashMap<>();for(Card card:screen.cards()){actions.put(card.slot(),()->select.accept(card.slot()));if(SuppliedDocument.summary(card).size()>1)actions.put(1000+card.slot(),()->open(player,screen,select,close,card.slot()));}
Map<Integer,Runnable> actions=new HashMap<>();for(Card card:screen.cards()){if(!card.enabled())continue;actions.put(card.slot(),()->select.accept(card.slot()));if(SuppliedDocument.summary(card).size()>1)actions.put(1000+card.slot(),()->open(player,screen,select,close,card.slot()));}
try{return Boolean.TRUE.equals(services.getClass().getMethod("presentSuppliedMenu",Player.class,String.class,String.class,Map.class,Runnable.class).invoke(services,player,screen.title(),SuppliedDocument.html(screen.id(),screen.title(),screen.subtitle(),screen.cards(),screen.info(),images,selected),actions,close));}
catch(ReflectiveOperationException failure){plugin.getLogger().warning("Menu canvas unavailable: "+failure.getClass().getSimpleName());return false;}
}

View file

@ -3,4 +3,8 @@ package com.dunerealms.menus;
import java.util.List;
/** One clickable thing on a menu, in renderer-neutral form (used for Bedrock forms and fullscreen). */
public record Card(int slot, String title, List<String> lore, String material) {}
public record Card(int slot, String title, List<String> lore, String material, boolean enabled) {
public Card(int slot, String title, List<String> lore, String material) {
this(slot, title, lore, material, true);
}
}

View file

@ -135,7 +135,7 @@ public final class DuneMenusPlugin extends JavaPlugin implements TabExecutor {
public void openSharedMenu(Player player, String title, org.bukkit.inventory.Inventory model, Map<Integer,Runnable> actions) {
if (!getServer().isPrimaryThread() || !player.isOnline() || !player.hasPermission("dunemenus.use")) return;
String lower=title.toLowerCase(java.util.Locale.ROOT);
String section=lower.contains("travel")||lower.contains("guild")?"travel":lower.contains("exchange")?"exchange":lower.contains("spice")?"spice":lower.contains("quest")?"missions":"hub";
String section=lower.contains("smuggler")?"smuggler":lower.contains("travel")||lower.contains("guild")?"travel":lower.contains("exchange")?"exchange":lower.contains("spice")?"spice":lower.contains("quest")?"missions":"hub";
new ServiceMenu(this,player,section,title,"",model,actions).open();
}

View file

@ -149,11 +149,19 @@ abstract class Menu implements InventoryHolder {
private List<Card> snapshot() {
List<Card> out = new ArrayList<>();
if (routeCards()) {
for (int slot = 0; slot < inv.getSize(); slot++) {
ItemStack it = inv.getItem(slot);
if (disabledRoute(it) && !buttons.containsKey(slot) && !plain(it).isBlank())
out.add(new Card(slot, plain(it), loreOf(it), "gray_dye", false));
}
}
for (int slot : buttons.keySet()) {
ItemStack it = inv.getItem(slot);
if (it == null || plain(it).isBlank()) continue;
out.add(new Card(slot, plain(it), loreOf(it), it.getType().name().toLowerCase()));
}
if (routeCards()) out.sort(java.util.Comparator.comparingInt(Card::slot));
return out;
}
@ -161,7 +169,7 @@ abstract class Menu implements InventoryHolder {
List<String> out = new ArrayList<>();
for (int i = 0; i < inv.getSize(); i++) {
ItemStack it = inv.getItem(i);
if (it == null || buttons.containsKey(i) || it.getType().name().endsWith("_PANE")) continue;
if (it == null || buttons.containsKey(i) || it.getType().name().endsWith("_PANE") || routeCards() && disabledRoute(it)) continue;
String n = plain(it);
if (n.isBlank()) continue;
List<String> lore = loreOf(it).stream().filter(s -> !s.isBlank()).toList();
@ -170,6 +178,9 @@ abstract class Menu implements InventoryHolder {
return out;
}
private boolean routeCards() { return id().equals("travel") || id().equals("smuggler"); }
private static boolean disabledRoute(ItemStack item) { return item != null && item.getType()==Material.GRAY_DYE; }
private void present() {
long shown = ++presentation;
var world = player.getWorld().getUID();

File diff suppressed because one or more lines are too long

View file

@ -40,6 +40,7 @@ public class RendererVerification {
}
System.out.println(id+": parser clean; "+cards.size()+" action hitboxes; maxScroll="+frame.maxScroll()+"; render-and-hitbox-ms="+((System.nanoTime()-started)/1_000_000));
}
verifyNavigators(dir,loader);
var actualIcon=Path.of("../network/resource-pack/central/overlay/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png");Path iconTarget=dir.resolve("pack/assets/dunerealms/textures/item/equipment/legendary_mk14_axe.png");Files.createDirectories(iconTarget.getParent());Files.copy(actualIcon,iconTarget,StandardCopyOption.REPLACE_EXISTING);
for(String name:List.of("item/iron_sword","block/cobblestone")){Path target=dir.resolve("pack/assets/minecraft/textures/"+name+".png");Files.createDirectories(target.getParent());Files.copy(Path.of("../network/resource-pack/vanilla-art/overlay/assets/minecraft/textures/"+name+".png"),target,StandardCopyOption.REPLACE_EXISTING);}
var listing=new Card(13,"\uE400§6Paul's chopper",List.of("LEGENDARY | MK XIV","Used by Paul himself.","Efficiency VIII","Fortune IV","Mending I","Unbreaking IV","Seller: J.A.R.V.I.S. HQ","1 available · 500.00 DM each"),"netherite_axe");
@ -48,4 +49,59 @@ public class RendererVerification {
for(var element:listingPage.document.select(".market-tool,[data-slot='1013']")){var bounds=listingFrame.boundsOf(element);var at=listingFrame.elementAt(bounds.getCenterX(),bounds.getCenterY());if(at==null||!at.closest("[data-slot]").attr("data-slot").equals(element.attr("data-slot")))throw new AssertionError("Detail control hitbox");}
System.out.println("PASS: "+checked+" direct action hitboxes across15 menu families.");
}
private static void verifyNavigators(Path dir,Page.Loader loader)throws Exception{
List<Card> guild=List.of(
new Card(4,"Arrakduin",List.of("Fare: 125.00 DM"),"compass"),
new Card(19,"Kaladam",List.of("House passage required"),"gray_dye",false),
new Card(25,"Giedermark",List.of("Current Guild embargo"),"gray_dye",false),
new Card(37,"Kaiterhof",List.of("Fare: 125.00 DM"),"compass"),
new Card(43,"Sigmadraken IV",List.of("World currently offline"),"gray_dye",false),
new Card(45,"Back",List.of(),"arrow"));
var owned=new ArrayList<Card>();
for(int i=0;i<28;i++){
int slot=10+i/7*9+i%7;
owned.add(new Card(slot,"Company Home Block "+(i+1),
List.of(i%2==0?"Kaladam · View fare":"No registered Home Block"),
i%2==0?"cyan_banner":"gray_dye",i%2==0));
}
owned.add(new Card(45,"Back",List.of(),"arrow"));
owned.add(new Card(51,"Next page",List.of(),"arrow"));
var confirm=List.of(new Card(22,"Company Home Block",List.of("Smuggler fare: 125.07 DM"),"compass"),
new Card(31,"Confirm paid passage",List.of("Payment settles after arrival"),"lime_dye"),
new Card(45,"Back",List.of(),"arrow"));
for(var family:Map.of("guild",guild,"esmar",guild,"owned-home",owned,"confirm",confirm).entrySet()){
String name=family.getKey();
var cards=family.getValue();
String html=SuppliedDocument.html(name.equals("guild")?"travel":"smuggler","Smuggler Navigator","Choose a destination",cards,List.of());
var page=Page.of(html,dir.resolve(name+"-navigator.html"),loader);
var frame=HtmlRenderer.render(page,1536,896,1.5,0,Selector.State.NONE);
if(!page.problems.isEmpty())throw new AssertionError(name+" parser problems "+page.problems);
var rendered=page.document.select("main > *");
if(rendered.size()!=cards.size())throw new AssertionError(name+" duplicate or missing rows: "+rendered.size());
for(int index=0;index<cards.size();index++){
Card card=cards.get(index);
var element=rendered.get(index);
var bounds=frame.boundsOf(element);
if(bounds==null||bounds.isEmpty())throw new AssertionError(name+" invisible "+card.title());
if(!card.enabled()&&(!element.hasClass("locked")||!element.select("[data-slot]").isEmpty()||element.hasAttr("data-slot")))
throw new AssertionError(name+" disabled destination has an action "+card.title());
for(var text:element.select("h2,p")){
var box=frame.boundsOf(text);
if(box!=null&&(box.getMinX()<bounds.getMinX()-1||box.getMaxX()>bounds.getMaxX()+1
||box.getMinY()<bounds.getMinY()-1||box.getMaxY()>bounds.getMaxY()+1))
throw new AssertionError(name+" text outside card "+card.title()+": "+box+" vs "+bounds);
}
if(card.enabled()){
double scroll=Math.max(0,Math.min(frame.maxScroll(),bounds.getCenterY()-260));
var visible=HtmlRenderer.render(page,1536,896,1.5,scroll,Selector.State.NONE);
var hit=visible.elementAt(bounds.getCenterX(),bounds.getCenterY()-scroll);
if(hit==null||hit.closest("[data-slot]")==null||!hit.closest("[data-slot]").attr("data-slot").equals(""+card.slot()))
throw new AssertionError(name+" unreachable action "+card.title());
}
}
ImageIO.write(frame.image(),"png",dir.resolve(name+"-navigator-engine.png").toFile());
System.out.println(name+" navigator: "+cards.size()+" distinct rows, contained text, disabled routes have no actions");
}
}
}

View file

@ -1,6 +1,6 @@
plugins { java }
group = "com.dunerealms"
version = "1.1.39"
version = "1.1.40-navigator1"
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://repo.opencollab.dev/main/") }
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")

View file

@ -165,13 +165,11 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
int centre=CENTRES[i];
var item=icon(p,name,reason==null?detail:reason,"drgui_transparent",reason==null?Material.ENDER_PEARL:Material.GRAY_DYE);
if(reason!=null){
var meta=item.getItemMeta();meta.displayName(Component.text(name,NamedTextColor.GRAY));item.setItemMeta(meta);
item.setType(Material.GRAY_DYE);
var meta=item.getItemMeta();meta.setItemModel(null);meta.displayName(Component.text(name,NamedTextColor.GRAY));item.setItemMeta(meta);
}
screen.inventory.setItem(centre,item);
if(reason==null){
Runnable book=()->bookPassage(p,data,route.world());
for(int row=i<3?-1:0;row<=1;row++)for(int col=-1;col<=1;col++)screen.actions.put(centre+row*9+col,book);
}
if(reason==null)screen.actions.put(centre,()->bookPassage(p,data,route.world()));
}
button(screen,p,45,"Your Mentat","Return to your House adviser",Material.ARROW,()->mentat(p,data));screen.actions.put(46,screen.actions.get(45));
button(screen,p,49,"Cancel booking","No fare is taken for a cancelled booking",Material.BARRIER,()->{cancelBooking(p);travelMenu(p,data);});for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));

View file

@ -157,11 +157,10 @@ final class OrganisationMenus implements Listener {
put(screen, SmugglerDestinations.slot(index++), destination.name(), details + "\nView fare", icon,
() -> select.accept(destination));
} else {
put(screen, SmugglerDestinations.slot(index++), destination.name(), details + "\n" + destination.unavailableReason(),
Material.GRAY_DYE, () -> {
player.sendMessage(destination.unavailableReason());
smugglerNavigator(player, destinations, pageNumber, select, back);
});
int slot = SmugglerDestinations.slot(index++);
put(screen, slot, destination.name(), details + "\n" + destination.unavailableReason(), Material.GRAY_DYE, null);
screen.choices.put(slot,new BedrockForms.Choice("§8"+destination.name()+" · "+destination.unavailableReason(),details,
()->smugglerNavigator(player,destinations,pageNumber,select,back)));
}
}
if (page.destinations().isEmpty()) {
@ -183,11 +182,8 @@ final class OrganisationMenus implements Listener {
if (quote.canBoard()) {
put(screen, 31, "Confirm paid passage", "Reserve the quoted fare. Payment settles on arrival.", Material.LIME_DYE, board);
} else {
put(screen, 31, "Passage unavailable", quote.unavailableReason(), Material.GRAY_DYE,
() -> {
player.sendMessage(quote.unavailableReason());
confirmSmugglerPassage(player, quote, board, back);
});
put(screen, 31, "Passage unavailable", quote.unavailableReason(), Material.GRAY_DYE, null);
screen.choices.put(31,new BedrockForms.Choice("§8"+quote.unavailableReason(),"Passage unavailable",back));
}
put(screen, 45, "Back", "Smuggler Navigator", Material.ARROW, back);
close(screen, player);
@ -232,7 +228,7 @@ final class OrganisationMenus implements Listener {
private static String name(JsonObject row){return row.get("name").getAsString();}
private Panel panel(Player p,String title,boolean company){var panel=new Panel(p);panel.title=title;panel.inventory=Bukkit.createInventory(panel,54,Component.text(title,company?NamedTextColor.AQUA:NamedTextColor.GOLD));for(int slot=0;slot<54;slot++)if(slot<9||slot>=45||slot%9==0||slot%9==8){var trim=new ItemStack(company?Material.CYAN_STAINED_GLASS_PANE:Material.GREEN_STAINED_GLASS_PANE);var meta=trim.getItemMeta();meta.displayName(Component.empty());trim.setItemMeta(meta);panel.inventory.setItem(slot,trim);}return panel;}
private Panel panel(Player p,String title,int screen){if(!artwork.test(p)||BedrockForms.isBedrock(p))return panel(p,title,screen==2);var panel=new Panel(p);panel.title=title;panel.artwork=true;panel.inventory=Bukkit.createInventory(panel,54,Component.text(GuiArtwork.background(0xE340+screen),NamedTextColor.WHITE).font(net.kyori.adventure.key.Key.key("dunerealms:house_selector")));return panel;}
private void put(Panel panel,int slot,String title,String description,Material material,Runnable action){var item=new ItemStack(panel.artwork?Material.PAPER:material);var meta=item.getItemMeta();meta.displayName(Component.text(title,NamedTextColor.GOLD));meta.lore(Arrays.stream(description.split("\n")).map(line->Component.text(line,NamedTextColor.GRAY)).toList());if(panel.artwork)meta.setItemModel(new NamespacedKey("dunerealms","drgui_transparent"));item.setItemMeta(meta);panel.inventory.setItem(slot,item);panel.actions.put(slot,action);if(panel.artwork&&Set.of(19,22,25,37,40,43).contains(slot))for(int alias:new int[]{slot-1,slot+1}){panel.inventory.setItem(alias,item.clone());panel.actions.put(alias,action);}panel.choices.put(slot,new BedrockForms.Choice(title,description,action));}
private void put(Panel panel,int slot,String title,String description,Material material,Runnable action){var item=new ItemStack(panel.artwork?Material.PAPER:material);var meta=item.getItemMeta();meta.displayName(Component.text(title,NamedTextColor.GOLD));meta.lore(Arrays.stream(description.split("\n")).map(line->Component.text(line,NamedTextColor.GRAY)).toList());if(panel.artwork)meta.setItemModel(new NamespacedKey("dunerealms","drgui_transparent"));item.setItemMeta(meta);panel.inventory.setItem(slot,item);if(action==null)return;panel.actions.put(slot,action);if(panel.artwork&&Set.of(19,22,25,37,40,43).contains(slot))for(int alias:new int[]{slot-1,slot+1}){panel.inventory.setItem(alias,item.clone());panel.actions.put(alias,action);}panel.choices.put(slot,new BedrockForms.Choice(title,description,action));}
private void close(Panel panel,Player p){put(panel,53,"Close","Return to the game",Material.BARRIER,p::closeInventory);}
private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,"Current organisation keys",List.copyOf(panel.choices.values()));return;}if(MCGUIMenus.show(p,panel.title,"Current organisation keys",panel.inventory,panel.actions,panel.gate))return;p.openInventory(panel.inventory);Bukkit.getScheduler().runTaskLater(plugin,panel.gate::expire,2400L);}
@EventHandler public void click(InventoryClickEvent e){if(!(e.getView().getTopInventory().getHolder() instanceof Panel panel))return;e.setCancelled(true);if(!(e.getWhoClicked() instanceof Player p)||!panel.owner.equals(p.getUniqueId())||e.getClickedInventory()!=panel.inventory||e.getClick()!=ClickType.LEFT)return;var action=panel.actions.get(e.getRawSlot());if(action!=null&&panel.gate.claim(p.getUniqueId()))Bukkit.getScheduler().runTask(plugin,()->{if(p.isOnline()&&p.getOpenInventory().getTopInventory()==panel.inventory)action.run();});}

View file

@ -1,6 +1,6 @@
name: DunerealmsGUI
main: com.dunerealms.gui.DuneGUI
version: 1.1.39
version: 1.1.40-navigator1
api-version: '1.21.8'
depend: [JarvisTranslator]
softdepend: [Citizens, MCGUI, DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion]

View file

@ -1,6 +1,6 @@
plugins { java }
group = "com.dunerealms"
version = "0.5.37-crysknife1"
version = "0.5.38-navigator1"
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/") }
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")

View file

@ -1,6 +1,6 @@
name: JarvisTranslator
main: com.dunerealms.jarvis.JarvisTranslator
version: 0.5.37-crysknife1
version: 0.5.38-navigator1
api-version: '1.21.8'
description: Shared J.A.R.V.I.S. website API and native server action translator.
softdepend: [Citizens, Citizens, CoreProtect, SCore, ExecutableItems, ExecutableCrafting, DuneEss, ImageFrame, DecentHolograms, MedievalFactions, Towny, WorldGuard]

View file

@ -54,10 +54,11 @@ def identity(path):
def plan(artifacts, inventory, expected_source):
mode=inventory.get('mode')
if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife'}:
if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator'}:
raise ValueError('An explicit supported rollout mode is required')
pillager=mode=='pillager-preserve-economy'
crysknife=mode=='arrakis-crysknife'
navigator=mode=='navigator'
artifacts = Path(artifacts).resolve(strict=True)
manifest = json.loads((artifacts / 'release-manifest.json').read_text())
if not re.fullmatch(r'[0-9a-f]{40}', expected_source) or manifest.get('sourceCommit') != expected_source:
@ -95,8 +96,13 @@ def plan(artifacts, inventory, expected_source):
if inventory.get('menuPack') is not None:
_, menu = load_menu(artifacts, expected_source)
verify_public_menu(inventory['menuPack']['url'], menu)
if (pillager or crysknife) and not(menu and menu.get('unified')):
if (pillager or crysknife or navigator) and not(menu and menu.get('unified')):
raise ValueError('This rollout requires its verified unified item/skin pack')
if navigator:
from plugin_navigator_transition import verify_module as verify_navigator, verify_jarvis as verify_navigator_jarvis
transition=json.loads((artifacts/'navigator-transition.json').read_text())
if menu['sha256'] != transition['packSha256']:
raise ValueError('Navigator rollout must preserve the accepted Crysknife pack bytes')
servers, ids, roots, units = [], set(), set(), set()
for server in inventory['servers']:
sid, unit = server['id'], server['serviceUnit']
@ -122,7 +128,7 @@ def plan(artifacts, inventory, expected_source):
uses_menu='dunemenus' in wanted or bool(menu and menu.get('unified') and not crysknife)
if menu and menu.get('unified') and not crysknife and 'dunerealmsgui' not in wanted:
raise ValueError('Unified pack rollout must select its matching DunerealmsGUI adapter')
if not (pillager or crysknife) and wanted - {'dunemenus','dunerealmsgui','dunenpc','dunelobby','mcgui'}:
if not (pillager or crysknife or navigator) and wanted - {'dunemenus','dunerealmsgui','dunenpc','dunelobby','mcgui'}:
raise ValueError('GUI rollout must retain working Ess/JARVIS/Core/Terrain binaries')
if crysknife and (
sid != 'arrakis' or unit != 'dune-arrakis.service'
@ -130,6 +136,12 @@ def plan(artifacts, inventory, expected_source):
or wanted != {'jarvistranslator','duneterrain'} or selected_prerequisites
):
raise ValueError('Crysknife rollout is restricted to the Arrakis JARVIS and Terrain pair')
if navigator:
planets={'arrakis','caladan','giedi_prime','kaitain','sigma_draconis_iv'}
target=(Path('/opt/dunerealms/lobby') if sid=='lobby' else Path('/opt/dunerealms/servers')/sid)
expected={'dunemenus','dunerealmsgui'} | ({'jarvistranslator'} if sid in planets else set())
if sid not in planets|{'lobby'} or root!=target or unit!=f'dune-{sid}.service' or wanted!=expected or selected_prerequisites:
raise ValueError('Navigator rollout requires its reviewed server root, unit and plugin selection')
if pillager:
if sid not in {'lobby','arrakis','caladan','giedi_prime','kaitain','sigma_draconis_iv'}:
raise ValueError('Pillager rollout requires a reviewed backend identity')
@ -164,7 +176,7 @@ def plan(artifacts, inventory, expected_source):
if (plugins / name).exists() and name not in old_names:
raise ValueError('Artifact filename collides with another plugin: ' + name)
retained=[]; abi_result=None
if uses_menu:
if uses_menu and not navigator:
fixture=json.loads((artifacts/'preserved-backend-abi.json').read_text())
if pillager:
incoming=next((e for e in chosen if e['name'].casefold()=='jarvistranslator'),None)
@ -224,6 +236,32 @@ def plan(artifacts, inventory, expected_source):
replaced = {entry['filename'] for entry in previous}
retained = [{'filename': path.name, 'sha256': digest(path), 'metadata': metadata(path)}
for path in sorted(plugins.glob('*.jar')) if path.name not in replaced]
if navigator:
abi_result={}
runtime=existing_paths.get('mcgui')
if runtime is None or digest(runtime)!=PRIVATE_PREREQUISITES['MCGUI']['sha256']:
raise ValueError('Navigator rollout requires the pinned MCGUI runtime')
if sid=='lobby':
lobby_jarvis=existing_paths.get('jarvistranslator')
if lobby_jarvis is None or digest(lobby_jarvis)!=transition['lobbyJarvisSha256']:
raise ValueError('Navigator rollout requires the reviewed retained Lobby JARVIS')
for entry in chosen:
name=entry['name']
installed=existing_paths.get(name.casefold())
if installed is None:
raise ValueError('Navigator rollout requires an existing reviewed '+name)
prior=digest(installed)
guard=transition['modules'][name]
if name=='JarvisTranslator':
if prior!=entry['sha256'] and prior!=transition['jarvisByServer'][sid]:
raise ValueError('Navigator JARVIS baseline differs from the reviewed world runtime')
abi=json.loads((artifacts/'retained-jarvis-public-abi.json').read_text())
abi_result[name]=verify_navigator_jarvis(entry['source'],guard,abi,None if prior==entry['sha256'] else prior)
else:
abi_result[name]=verify_navigator(entry['source'],guard,None if prior==entry['sha256'] else prior)
replaced={entry['filename'] for entry in previous}
retained=[{'filename':path.name,'sha256':digest(path),'metadata':metadata(path)}
for path in sorted(plugins.glob('*.jar')) if path.name not in replaced]
configurations = []
if uses_menu or crysknife:
if menu is None:
@ -232,10 +270,10 @@ def plan(artifacts, inventory, expected_source):
target = plugins / relative
if target.is_symlink() or target.parent.is_symlink():
raise ValueError('Menu configuration path must not be a symlink')
if crysknife and relative == 'MCGUI/config.yml' and (
if (crysknife or navigator) and relative == 'MCGUI/config.yml' and (
not target.is_file() or target.read_bytes() != content.encode()
):
raise ValueError('Crysknife rollout must preserve the existing MCGUI engine configuration')
raise ValueError('Rollout must preserve the existing MCGUI engine configuration')
previous_hash = None
if target.exists():
if not target.read_text().startswith('# Managed by DuneRealms plugin CI;'):

View file

@ -0,0 +1,82 @@
{
"packSha256": "446c0b60fa6e6752ff5260bb22c9a76280b7b10ffa03c3cca4b08f4d9320105b",
"lobbyJarvisSha256": "5c632e3db85fc58e55c1917b29916ef1865b3c9eca3e3e70b9131ef44dad1aaf",
"jarvisByServer": {
"caladan": "663c28c5fb246b3d5c14b2faeaf0b6c000e38a53b3d45459221e4d3b85f242c3",
"giedi_prime": "663c28c5fb246b3d5c14b2faeaf0b6c000e38a53b3d45459221e4d3b85f242c3",
"kaitain": "663c28c5fb246b3d5c14b2faeaf0b6c000e38a53b3d45459221e4d3b85f242c3",
"sigma_draconis_iv": "663c28c5fb246b3d5c14b2faeaf0b6c000e38a53b3d45459221e4d3b85f242c3",
"arrakis": "1128d8d1a9ab7b0d257089e52c46c9a7dc6096e3b8bfbf241169474d503ee5ab"
},
"modules": {
"DuneMenus": {
"version": "2.0.8-navigator1",
"changedClasses": [
"com/dunerealms/menus/CanvasProvider.class",
"com/dunerealms/menus/Card.class",
"com/dunerealms/menus/DuneMenusPlugin.class",
"com/dunerealms/menus/JarvisBackend.class",
"com/dunerealms/menus/Menu.class",
"com/dunerealms/menus/SuppliedDocument.class",
"com/dunerealms/menus/TravelMenu.class"
],
"baselines": {
"a978fe6564f33cbee611c00ac5377729bd707254b1b52ec02f5140909a2cf6b5": {
"addedClasses": [],
"retainedTreeSha256": "b1935938cbcb63b8af33de6d172763ab92270d401f791099389f9f5f07b30341"
}
}
},
"DunerealmsGUI": {
"version": "1.1.40-navigator1",
"changedClasses": [
"com/dunerealms/gui/DuneGUI$1.class",
"com/dunerealms/gui/DuneGUI.class",
"com/dunerealms/gui/GuildRoutes$Route.class",
"com/dunerealms/gui/GuildRoutes.class",
"com/dunerealms/gui/HouseBridge.class",
"com/dunerealms/gui/OrganisationMenus.class",
"com/dunerealms/gui/QuestMenus.class"
],
"baselines": {
"fb58d724d3421faea2e0600c197145f887a2ce6e016cec95621759cb855a179c": {
"addedClasses": [
"com/dunerealms/gui/GuildRoutes$Offer.class",
"com/dunerealms/gui/OrganisationMenus$1.class",
"com/dunerealms/gui/SmugglerDestinations$Destination.class",
"com/dunerealms/gui/SmugglerDestinations$Kind.class",
"com/dunerealms/gui/SmugglerDestinations$Page.class",
"com/dunerealms/gui/SmugglerDestinations$Quote.class",
"com/dunerealms/gui/SmugglerDestinations.class"
],
"retainedTreeSha256": "42eff6929008eff94ab5866effaf1f430e0734c8805e60821791d06230a60860"
}
}
},
"JarvisTranslator": {
"version": "0.5.38-navigator1",
"changedClasses": [
"com/dunerealms/jarvis/GuildTransport.class",
"com/dunerealms/jarvis/JarvisTranslator.class",
"com/dunerealms/jarvis/OrganisationTransport.class",
"com/dunerealms/jarvis/SharedGameApi.class"
],
"baselines": {
"663c28c5fb246b3d5c14b2faeaf0b6c000e38a53b3d45459221e4d3b85f242c3": {
"addedClasses": [
"com/dunerealms/jarvis/Crysknife.class",
"com/dunerealms/jarvis/CrysknifeRules.class",
"com/dunerealms/jarvis/HomeSmugglerTransport.class"
],
"retainedTreeSha256": "296d4823a7a721355d741bd3d6179911d03825c2f8b20b079bbc3489683536ee"
},
"1128d8d1a9ab7b0d257089e52c46c9a7dc6096e3b8bfbf241169474d503ee5ab": {
"addedClasses": [
"com/dunerealms/jarvis/HomeSmugglerTransport.class"
],
"retainedTreeSha256": "34711cc8b84d1477a5270f21dc672404c77fc8e41af7769018c57a22ad107182"
}
}
}
}
}

View file

@ -0,0 +1,111 @@
"""Pinned archive transitions for the reviewed Navigator release."""
import argparse
import hashlib
import io
import json
from pathlib import Path
import re
import urllib.request
import zipfile
from plugin_pillager_abi import verify_contract
JARS = {
'DuneMenus': 'DuneMenus/build/libs/DuneMenus.jar',
'DunerealmsGUI': 'DuneRealmsGUI/build/libs/DunerealmsGUI.jar',
'JarvisTranslator': 'JarvisConnector/build/libs/jarvistranslator.jar',
}
def archive(path):
with zipfile.ZipFile(path) as jar:
names = [name for name in jar.namelist() if not name.endswith('/')]
if len(set(names)) != len(names):
raise ValueError('Duplicate plugin archive entry')
return {name: jar.read(name) for name in names}
def retained_tree(entries, omitted):
rows = []
for name, data in sorted(entries.items()):
if name in omitted:
continue
if name == 'plugin.yml':
data, count = re.subn(br'^version:[^\r\n]*', b'version: <navigator-version>', data, flags=re.M)
if count != 1:
raise ValueError('Expected exactly one plugin descriptor version')
rows.append(name + '\0' + hashlib.sha256(data).hexdigest())
return hashlib.sha256('\n'.join(rows).encode()).hexdigest()
def verify_module(path, contract, prior_sha=None):
if prior_sha is not None and prior_sha not in contract['baselines']:
raise ValueError('Installed plugin is not a reviewed Navigator input')
entries = archive(path)
match = re.search(br'^version:\s*([^\r\n]+)', entries['plugin.yml'], re.M)
if not match or match[1].decode().strip() != contract['version']:
raise ValueError('Unexpected Navigator plugin version')
changed = set(contract['changedClasses'])
for baseline in contract['baselines'].values():
added = set(baseline['addedClasses'])
if not (changed | added) <= entries.keys():
raise ValueError('A reviewed Navigator class is missing')
if retained_tree(entries, changed | added) != baseline['retainedTreeSha256']:
raise ValueError('Navigator archive differs outside the reviewed classes and version')
return {'version': contract['version'], 'baselines': len(contract['baselines'])}
def verify_jarvis(path, contract, abi, prior_sha=None):
result = verify_module(path, contract, prior_sha)
allowed = set(contract['changedClasses'])
abi = {**abi, 'unchangedClassSha256': {
name: sha for name, sha in abi['unchangedClassSha256'].items() if name not in allowed
}}
return {**result, **verify_contract(path, abi)}
def stage_pillager_baseline(directory, fixture):
url = 'https://www.dunerealms.com/git/api/v1/repos/unimatrix/plugins/actions/artifacts/7691/zip'
with urllib.request.urlopen(url, timeout=60) as response:
payload = response.read(80_000_001)
if len(payload)>80_000_000:
raise ValueError('Unexpected Pillager baseline archive size')
with zipfile.ZipFile(io.BytesIO(payload)) as wrapper:
members = wrapper.infolist()
if len(members)==1 and members[0].filename.endswith('.zip'):
if members[0].file_size>80_000_000:
raise ValueError('Unexpected nested Pillager baseline size')
payload = wrapper.read(members[0])
inputs = {}
with zipfile.ZipFile(io.BytesIO(payload)) as baseline:
for name, path in JARS.items():
filename = Path(path).name
expected = fixture['jarvisByServer']['caladan'] if name=='JarvisTranslator' else next(iter(fixture['modules'][name]['baselines']))
data = baseline.read(filename)
if hashlib.sha256(data).hexdigest()!=expected:
raise ValueError('Pillager baseline hash differs: '+filename)
inputs[filename] = data
directory.mkdir(exist_ok=False)
for filename, data in inputs.items():
(directory/filename).write_bytes(data)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--contract', type=Path, default=Path('tools/navigator-transition.json'))
parser.add_argument('--abi', type=Path, default=Path('JarvisConnector/src/test/resources/retained-jarvis-public-abi.json'))
parser.add_argument('--stage-pillager-baseline', type=Path)
args = parser.parse_args()
fixture = json.loads(args.contract.read_text())
if args.stage_pillager_baseline is not None:
stage_pillager_baseline(args.stage_pillager_baseline, fixture)
return
for name, path in JARS.items():
guard = fixture['modules'][name]
report = verify_jarvis(path, guard, json.loads(args.abi.read_text())) if name == 'JarvisTranslator' else verify_module(path, guard)
print(name, json.dumps(report, sort_keys=True))
if __name__ == '__main__':
main()

View file

@ -36,6 +36,10 @@ def validate(text):
for script in CHECKS:
if 'python3 tools/' + script + ' -v' not in text:
raise ValueError('Missing release regression check: ' + script)
for command in ('python3 tools/plugin_navigator_transition.py --stage-pillager-baseline',
'\n python3 tools/plugin_navigator_transition.py\n'):
if command not in text:
raise ValueError('Missing Navigator transition check: ' + command.strip())
if re.search(r'^\s*(continue-on-error|if):', text, re.M):
raise ValueError('Do not skip or ignore required build steps')
# Both shell groups must propagate a failed test/build to the commit status.
@ -74,6 +78,12 @@ class PluginCIPolicyTests(unittest.TestCase):
with self.subTest(old=old), self.assertRaises(ValueError):
validate(self.text.replace(old, new))
def test_legacy_baseline_and_navigator_candidate_both_remain_checked(self):
for command in ('python3 tools/plugin_navigator_transition.py --stage-pillager-baseline',
'\n python3 tools/plugin_navigator_transition.py\n'):
with self.subTest(command=command), self.assertRaises(ValueError):
validate(self.text.replace(command, ''))
if __name__ == '__main__':
unittest.main()

View file

@ -17,6 +17,11 @@ from test_plugin_fleet_install import jar,Service,SOURCE
spec=importlib.util.spec_from_file_location('pillager_installer',Path(__file__).with_name('install-plugin-fleet.py'))
installer=importlib.util.module_from_spec(spec);spec.loader.exec_module(installer)
ROOT=Path(__file__).resolve().parents[1]
BASELINE=Path(os.environ['DUNE_PILLAGER_BASELINE_DIR']) if 'DUNE_PILLAGER_BASELINE_DIR' in os.environ else None
def compiled_artifact(module, filename):
return BASELINE/filename if BASELINE is not None else ROOT/module/'build/libs'/filename
class PillagerProfileTests(unittest.TestCase):
@ -89,7 +94,7 @@ class PillagerProfileTests(unittest.TestCase):
class PillagerAbiTests(unittest.TestCase):
def test_compiled_jarvis_retains_both_actual_variants_and_missing_api_fails(self):
fixture=json.loads((ROOT/'JarvisConnector/src/test/resources/retained-jarvis-public-abi.json').read_text());path=ROOT/'JarvisConnector/build/libs/jarvistranslator.jar'
fixture=json.loads((ROOT/'JarvisConnector/src/test/resources/retained-jarvis-public-abi.json').read_text());path=compiled_artifact('JarvisConnector','jarvistranslator.jar')
result=abi.verify_contract(path,fixture);self.assertEqual(result['classes'],83);self.assertGreaterEqual(result['descriptors'],363)
broken=copy.deepcopy(fixture);broken['classes']['com/dunerealms/jarvis/JarvisTranslator']['methods'].append(['missingPaidBypass','()V'])
with self.assertRaisesRegex(ValueError,'missingPaidBypass'):abi.verify_contract(path,broken)
@ -100,7 +105,7 @@ class PillagerAbiTests(unittest.TestCase):
self.assertIn('com/dunerealms/jarvis/'+name+'.class',fixture['unchangedClassSha256'])
broken=copy.deepcopy(fixture);broken['unchangedClassSha256']['com/dunerealms/jarvis/ExchangeInventory.class']='0'*64
with self.assertRaisesRegex(ValueError,'Retained implementation changed'):
abi.verify_contract(ROOT/'JarvisConnector/build/libs/jarvistranslator.jar',broken)
abi.verify_contract(compiled_artifact('JarvisConnector','jarvistranslator.jar'),broken)
def test_menu_artwork_may_change_but_no_class_or_unrelated_resource_may_change(self):
with tempfile.TemporaryDirectory() as tmp:
before=Path(tmp)/'old.jar';after=Path(tmp)/'new.jar'
@ -114,13 +119,13 @@ class PillagerAbiTests(unittest.TestCase):
with self.assertRaises(ValueError):abi.verify_menu_resources(after,before)
def test_current_compiled_frontends_match_accepted_classes_and_resource_content(self):
fixture=json.loads((ROOT/'DuneMenus/src/test/resources/pillager-accepted-frontends.json').read_text())
result=abi.verify_menu_contract(ROOT/'DuneMenus/build/libs/DuneMenus.jar',fixture)
self.assertEqual(abi.archive_content_hash(ROOT/'DuneRealmsGUI/build/libs/DunerealmsGUI.jar'),fixture['guiContentTreeSha256'])
result=abi.verify_menu_contract(compiled_artifact('DuneMenus','DuneMenus.jar'),fixture)
self.assertEqual(abi.archive_content_hash(compiled_artifact('DuneRealmsGUI','DunerealmsGUI.jar')),fixture['guiContentTreeSha256'])
self.assertEqual(result['identicalClasses'],73);self.assertEqual(result['unchangedResources'],3223)
@unittest.skipIf(os.name=='nt','Literal GUI archive hash is enforced on canonical Linux CI; Windows ZIP metadata differs')
def test_canonical_gui_archive_is_byte_identical_to_the_deployed_release(self):
fixture=json.loads((ROOT/'DuneMenus/src/test/resources/pillager-accepted-frontends.json').read_text())
abi.verify_accepted_frontends(ROOT/'DuneMenus/build/libs/DuneMenus.jar',ROOT/'DuneRealmsGUI/build/libs/DunerealmsGUI.jar',fixture)
abi.verify_accepted_frontends(compiled_artifact('DuneMenus','DuneMenus.jar'),compiled_artifact('DuneRealmsGUI','DunerealmsGUI.jar'),fixture)
def test_vendor_hash_mismatch_fails_before_loading_any_runtime(self):
with tempfile.TemporaryDirectory() as tmp:
p=Path(tmp)/'vendor.jar';p.write_bytes(b'not reviewed')