/** * Compatibility Gates (Phase 4 — universal update automation) * * Pure pre-install gates evaluated before a downloaded JAR is applied to a * server: an MC-version gate and a Java class-file-version gate. This module * makes NO config/network/UI calls — the SafeApply wiring passes config * values (`STRICT_COMPAT`, `JAVA_MAJOR_VERSION`) in as parameters. * * House rules encoded here: * - Missing/unknowable data NEVER blocks (level 'unknown', ok: true). * - 'block' is only produced by (a) strictCompat + plugin targeting a newer * MC major than the server, or (b) a class file the host JVM provably * cannot load (known host Java version < required). * - Every result carries a human-readable `reason` — no silent outcomes. * * Distinct from `src/core/health/compatibility-checker.ts`'s * checkMcCompatibility (a HEALTH-SCORING component): this module is the * install-time GATE. Both share the same version parsing/matching helpers. * Import directly from this module — it is intentionally not re-exported * through barrels to avoid colliding with the health checker's export. */ import type { PluginInfo } from './types/plugin.js'; /** Gate verdict severity. Only 'block' stops an install. */ export type CompatGateLevel = 'ok' | 'unknown' | 'warn' | 'block'; /** Options threaded in from config by the apply path. */ export interface CompatGateOptions { /** * When true, "plugin targets a newer MC major than the server" escalates * from 'warn' to 'block'. Maps to the `STRICT_COMPAT` config key (wired by * the apply path; default false). */ strictCompat?: boolean; } /** Result of the MC-version gate. */ export interface McCompatGateResult { /** False only when level === 'block'. */ ok: boolean; level: CompatGateLevel; /** Human-readable explanation — surfaced in results, never swallowed. */ reason: string; } /** Result of the Java class-file-version gate. */ export interface JavaCompatGateResult { /** False only when level === 'block'. */ ok: boolean; level: CompatGateLevel; /** Human-readable explanation — surfaced in results, never swallowed. */ reason: string; /** Class-file major version read from the JAR (e.g. 65), when readable. */ classFileMajor?: number; /** Java feature release the class file requires (e.g. 21), when readable. */ requiredJavaMajor?: number; /** Host Java major the check ran against, when known. */ hostJavaMajor?: number; /** Which .class entry the version was read from, when readable. */ sourceEntry?: string; } /** * Config key for the host's Java feature release (e.g. 21). Optional — * Pluginator runs on Bun, so `process` metadata says nothing about the JVM * that will load plugin JARs. The apply path should pass the configured * value, or fall back to {@link probeHostJavaMajor}. */ export declare const JAVA_MAJOR_VERSION_CONFIG_KEY = "JAVA_MAJOR_VERSION"; /** Fields of PluginInfo the MC gate consumes. */ export type McCompatPluginInfo = Pick; /** * MC-version gate: should this plugin version be installed on a server * running `serverMcVersion`? * * Decision matrix (see tests for the pinned matrix): * - no declared versions / unparseable server or declarations → 'unknown' * - any declared version matches the server (exact / wildcard / range / +) * → 'ok' * - server on year scheme (26.x) + declarations top out at legacy 1.21.x * → 'unknown' (data predates Mojang's year-versioning change — NOT * incompatible); topping out well before 1.21 → 'warn' * - plugin targets a newer MC major than the server (incl. a 26.x-only * plugin on a 1.x server — year versions succeed 1.21.x) → 'warn', or * 'block' when options.strictCompat * - otherwise behind by ≤1 minor → 'ok'; further behind → 'warn' * * Never blocks on missing information. */ export declare function checkMcCompatibility(plugin: McCompatPluginInfo, serverMcVersion: string, options?: CompatGateOptions): McCompatGateResult; /** * Map a class-file major version to the Java feature release that can load * it: 52 → Java 8, 61 → Java 17, 65 → Java 21, 69 → Java 25 (the constant * offset is 44, exact for Java 5+; ancient pre-Java-5 majors 45-48 map to * 1-4, which any modern JVM loads anyway). */ export declare function classFileMajorToJavaMajor(classFileMajor: number): number; /** * Java class-file-version gate: can the host JVM load this plugin JAR? * * `hostJavaMajor` must come from configuration ({@link * JAVA_MAJOR_VERSION_CONFIG_KEY}) or {@link probeHostJavaMajor} — Pluginator * runs under Bun, so its own process metadata says nothing about the JVM. * * - JAR unreadable / no .class entry / bad magic → 'unknown' (never block) * - host version unknown → 'unknown', with the requirement in the reason * - required ≤ host → 'ok' * - required > host → 'block' (the JVM would throw * UnsupportedClassVersionError at load — this is a hard fact, not a guess) */ export declare function checkJavaClassVersion(jarPath: string, hostJavaMajor?: number): Promise; /** * Parse `java -version` output into a Java feature release number. * Handles modern (`openjdk version "21.0.2"`) and legacy (`java version * "1.8.0_392"` → 8) formats. Returns null when no version is found. */ export declare function parseJavaVersionOutput(output: string): number | null; /** * Best-effort probe of the host's Java feature release via `java -version`. * Returns null when java isn't on PATH, times out, or output is * unrecognized — callers then pass `undefined` to * {@link checkJavaClassVersion}, which yields 'unknown' (never a block). */ export declare function probeHostJavaMajor(): number | null; //# sourceMappingURL=compat-gate.d.ts.map