fix(plugins): let an admin run a plugin outside its TREK range, and tidy the plugins panel

TREK 5.0 left most registry plugins blocked because their authors still declare
"<5.0.0", and the only way past that was TREK_PLUGINS_IGNORE_TREK_RANGE for every
plugin at once. An admin can now install or switch on one such plugin after a
warning; the consent is kept on its row for that plugin version and TREK major,
so an update or a new major asks again. The environment switch works as before.

Discover marks a plugin not confirmed for this TREK on its card, and Install opens
the warning first. Admin > Plugins reads cleaner: one row of alike facts per plugin
with each state that needs attention on its own line, type, status and order behind
one Filter button, and the containment notes in a dialog behind the shield in the
header. The row, the filter menu and the dialog moved into their own files.
This commit is contained in:
Maurice
2026-10-26 00:48:13 +01:00
parent d589da59f2
commit 0067b0ff19
62 changed files with 1673 additions and 575 deletions
+4
View File
@@ -35,6 +35,8 @@ export class Plugins {
update_block_version?: string | null;
trek_range?: string | null;
update_hold: number & Opt = 0;
trek_range_accepted_version?: string | null;
trek_range_accepted_host?: string | null;
}
export const PluginsSchema = defineEntity({
@@ -72,5 +74,7 @@ export const PluginsSchema = defineEntity({
update_block_version: p.text().nullable(),
trek_range: p.text().nullable(),
update_hold: p.integer().default(0),
trek_range_accepted_version: p.text().nullable(),
trek_range_accepted_host: p.text().nullable(),
},
});
+2
View File
@@ -34,4 +34,6 @@ export interface PluginsTable {
update_block_version: InsertOptional<string | null>;
trek_range: InsertOptional<string | null>;
update_hold: InsertOptional<number>;
trek_range_accepted_version: InsertOptional<string | null>;
trek_range_accepted_host: InsertOptional<string | null>;
}
@@ -0,0 +1,18 @@
import { Migration } from '@mikro-orm/migrations';
/**
* An admin can run one plugin outside the TREK versions its author declared,
* instead of switching the check off for every plugin through
* TREK_PLUGINS_IGNORE_TREK_RANGE. The consent belongs to what the admin was
* shown: `trek_range_accepted_version` is the plugin version they accepted and
* `trek_range_accepted_host` the TREK version it ran on then. An update of the
* plugin or a new TREK major asks again.
*/
export class Migration20200101046310_an_admin_can_run_a_plugin_outside_its_trek_range extends Migration {
override name = 'Migration20200101046310_an_admin_can_run_a_plugin_outside_its_trek_range';
override up(): void {
this.addSql('ALTER TABLE plugins ADD COLUMN trek_range_accepted_version TEXT');
this.addSql('ALTER TABLE plugins ADD COLUMN trek_range_accepted_host TEXT');
}
}
@@ -26,13 +26,16 @@ export interface PluginIdPermissionRow {
permissions: string | null;
}
/** PR17 — `SELECT permissions, granted_permissions, dependencies, trek_range, api_version FROM plugins WHERE id = ?` (`assertActivatable`'s one-row activation gate). */
/** PR17 — the one-row activation gate `assertActivatable` reads: grants, dependencies, the TREK range and an admin's consent to run outside it. */
export interface PluginActivationGateRow {
permissions: string;
granted_permissions: string;
dependencies: string | null;
trek_range: string | null;
api_version: number | null;
version: string | null;
trek_range_accepted_version: string | null;
trek_range_accepted_host: string | null;
}
/** PR18 — `SELECT permissions, config FROM plugins WHERE id = ?` (`spawnActivated`). */
@@ -89,6 +92,8 @@ export interface PluginAdminRow {
dependencies: string | null;
operator_egress: number;
trek_range: string | null;
trek_range_accepted_version: string | null;
trek_range_accepted_host: string | null;
author_pubkey: string | null;
update_block_code: string | null;
update_block_detail: string | null;
@@ -144,7 +149,18 @@ export class PluginsRepository extends TrekRepository<Plugins> {
async findActivationGate(id: string): Promise<PluginActivationGateRow | null> {
const row = await this.findOne(
{ id },
{ fields: ['permissions', 'granted_permissions', 'dependencies', 'trek_range', 'api_version'] },
{
fields: [
'permissions',
'granted_permissions',
'dependencies',
'trek_range',
'api_version',
'version',
'trek_range_accepted_version',
'trek_range_accepted_host',
],
},
);
return row
? {
@@ -153,6 +169,9 @@ export class PluginsRepository extends TrekRepository<Plugins> {
dependencies: row.dependencies ?? null,
trek_range: row.trek_range ?? null,
api_version: row.api_version ?? null,
version: row.version ?? null,
trek_range_accepted_version: row.trek_range_accepted_version ?? null,
trek_range_accepted_host: row.trek_range_accepted_host ?? null,
}
: null;
}
@@ -370,6 +389,8 @@ export class PluginsRepository extends TrekRepository<Plugins> {
'dependencies',
'operator_egress',
'trek_range',
'trek_range_accepted_version',
'trek_range_accepted_host',
'author_pubkey',
'update_block_code',
'update_block_detail',
@@ -396,6 +417,8 @@ export class PluginsRepository extends TrekRepository<Plugins> {
dependencies: r.dependencies ?? null,
operator_egress: r.operator_egress,
trek_range: r.trek_range ?? null,
trek_range_accepted_version: r.trek_range_accepted_version ?? null,
trek_range_accepted_host: r.trek_range_accepted_host ?? null,
author_pubkey: r.author_pubkey ?? null,
update_block_code: r.update_block_code ?? null,
update_block_detail: r.update_block_detail ?? null,
@@ -545,6 +568,11 @@ export class PluginsRepository extends TrekRepository<Plugins> {
await this.nativeUpdate({ id }, { update_hold: hold ? 1 : 0 });
}
/** An admin accepted running this plugin version outside its TREK range, on this TREK. */
async acceptTrekRange(id: string, version: string, host: string): Promise<void> {
await this.nativeUpdate({ id }, { trek_range_accepted_version: version, trek_range_accepted_host: host });
}
/**
* RG8 (`commitUpload`, sideload step 2) — `` UPDATE plugins SET source_repo = ?,
* source_commit = NULL, sha256 = NULL, reviewed_at = NULL, author_pubkey = NULL,
+89 -8
View File
@@ -126,18 +126,98 @@ export interface TrekRangeBypass {
/** The plugin's declared range, or null when it declared none at all. */
trekRange: string | null;
hostVersion: string;
/**
* True when an admin accepted this one plugin outside its range, false when
* TREK_PLUGINS_IGNORE_TREK_RANGE lets every plugin through.
*/
acceptedByAdmin: boolean;
}
/** An admin's consent to run one plugin outside its range, as the plugins row keeps it. */
interface TrekRangeAcceptance {
/** The plugin version that was installed when the admin accepted. */
acceptedVersion: string | null;
/** The TREK version it ran on then. */
acceptedHost: string | null;
}
/**
* Non-null exactly when `range` would have been refused and only the bypass lets it
* through: the marker that makes an install/activate response say "this worked, but
* only because you told TREK to ignore the version check". Null for a normal install
* (the range fits) and null when the bypass is off (the gate refuses instead).
* Whether an admin's consent still covers the plugin as it is installed now: the
* same plugin version, on the same TREK major. An update of the plugin, or a TREK
* major past the one the admin saw it run on, asks again.
*/
export function bypassedRange(range: string | null | undefined): TrekRangeBypass | null {
export function acceptanceHolds(
pluginVersion: string | null | undefined,
a: TrekRangeAcceptance | null | undefined,
): boolean {
if (!a?.acceptedVersion || !a.acceptedHost || !pluginVersion) return false;
if (a.acceptedVersion !== pluginVersion) return false;
const accepted = semver.coerce(a.acceptedHost);
const host = normalizedHost();
if (!accepted || host === null) return false;
return semver.major(accepted) === semver.major(host);
}
/**
* Non-null exactly when `range` would have been refused and only a bypass lets it
* through: the marker that makes an install/activate response say "this worked, but
* only because you told TREK to run it anyway". `accepted` is this one plugin's
* consent from the admin; the environment switch covers every plugin. Null for a
* normal install (the range fits) and null when neither applies (the gate refuses).
*/
export function bypassedRange(range: string | null | undefined, accepted = false): TrekRangeBypass | null {
if (hostSatisfies(range)) return null;
if (!trekRangeBypassed()) return null;
return { trekRange: range ?? null, hostVersion: hostVersion() };
const everyPlugin = trekRangeBypassed();
if (!everyPlugin && !accepted) return null;
return { trekRange: range ?? null, hostVersion: hostVersion(), acceptedByAdmin: !everyPlugin };
}
/** What the activation gate reads off a plugin's row to decide whether it may run on this TREK. */
interface TrekRangeRow {
trek_range: string | null;
version: string | null;
trek_range_accepted_version: string | null;
trek_range_accepted_host: string | null;
}
/** Why the activation gate refuses a plugin on this TREK, in the shape its error carries. */
interface TrekRangeRefusal {
message: string;
code: 'TREK_VERSION_UNKNOWN' | 'TREK_VERSION_INCOMPATIBLE';
detail: { trekRange: string | null; hostVersion: string };
}
/**
* The TREK-version half of the activation gate: null when the plugin may run, else why
* not. An admin's consent (`acceptNow`, or one kept on the row for this version and TREK
* major) or TREK_PLUGINS_IGNORE_TREK_RANGE lets an outgrown plugin through, and every
* start of one says so in the log; the plugin list carries the same marker for the UI.
*/
export function trekRangeRefusal(id: string, row: TrekRangeRow, acceptNow = false): TrekRangeRefusal | null {
const accepted =
acceptNow ||
acceptanceHolds(row.version, {
acceptedVersion: row.trek_range_accepted_version,
acceptedHost: row.trek_range_accepted_host,
});
const bypass = bypassedRange(row.trek_range, accepted);
if (bypass) {
warnRangeBypass(id, bypass);
return null;
}
if (!row.trek_range) {
return {
message: `plugin ${id} does not declare which TREK versions it supports`,
code: 'TREK_VERSION_UNKNOWN',
detail: { trekRange: null, hostVersion: hostVersion() },
};
}
if (hostSatisfies(row.trek_range)) return null;
return {
message: `plugin ${id} requires TREK ${row.trek_range} — this is TREK ${hostVersion()}`,
code: 'TREK_VERSION_INCOMPATIBLE',
detail: { trekRange: row.trek_range, hostVersion: hostVersion() },
};
}
/**
@@ -147,7 +227,8 @@ export function bypassedRange(range: string | null | undefined): TrekRangeBypass
*/
export function warnRangeBypass(id: string, b: TrekRangeBypass): void {
const declared = b.trekRange ? `declares TREK ${b.trekRange}` : 'declares no TREK version range';
const because = b.acceptedByAdmin ? 'an admin chose to run it anyway' : 'TREK_PLUGINS_IGNORE_TREK_RANGE is set';
console.warn(
`[plugins] ${id} ${declared} — this is TREK ${b.hostVersion}; continuing because TREK_PLUGINS_IGNORE_TREK_RANGE is set. The author has not verified it on this version: it may not work, and it could corrupt TREK data.`,
`[plugins] ${id} ${declared} — this is TREK ${b.hostVersion}; continuing because ${because}. The author has not verified it on this version: it may not work, and it could corrupt TREK data.`,
);
}
@@ -62,7 +62,7 @@ import { scanForNativeBinaries } from './install/native-scan';
import { devLinkEnabled, DEV_LINK_SOURCE } from './dev-link';
import { pluginCodeDir, pluginDataDir } from './paths';
import { assertHostCompatible, PluginRegistryService, RegistryError } from './registry/registry.service';
import { hostSatisfies, hostVersion, bypassedRange, warnRangeBypass } from './install/host-compat';
import { hostSatisfies, hostVersion, trekRangeRefusal } from './install/host-compat';
import type { TrekRangeBypass } from './install/host-compat';
import { keyFingerprint } from './signature-status';
import { AuditService } from '../audit/audit.service';
@@ -639,8 +639,10 @@ export class PluginRuntimeService implements OnApplicationBootstrap, OnModuleDes
* freshly-installed plugin (no prior grant) is itself the consent for its
* declared set; widening an already-consented set requires `consentWiden` (the
* update consent dialog), and otherwise throws PluginConsentRequired.
* `acceptTrekRange` is the admin's "run it anyway" outside the TREK range the author
* declared: for this plugin only, never a dependency, kept on its row for this version.
*/
async activate(id: string, consentWiden = false): Promise<void> {
async activate(id: string, consentWiden = false, acceptTrekRange = false): Promise<void> {
const installed = await this.installedDepRows();
// Deps-first order over the installed graph (throws DependencyCycleError on a
// cycle). Missing deps aren't in `installed` so they don't appear here — the
@@ -652,6 +654,7 @@ export class PluginRuntimeService implements OnApplicationBootstrap, OnModuleDes
// blocked dependency never leaves the chain half-activated. Only the target
// may consent-widen; dependencies are auto-enabled at their existing grant.
const toCheck = rootInstalled ? order : [id];
if (acceptTrekRange) await this.rememberRangeAcceptance(id);
for (const nodeId of toCheck) await this.assertActivatable(nodeId, installed, nodeId === id ? consentWiden : false);
// Enable dependencies first (skip ones already enabled), then the target.
@@ -661,6 +664,16 @@ export class PluginRuntimeService implements OnApplicationBootstrap, OnModuleDes
}
}
/**
* Keeps the admin's "run it anyway" for the installed version, when it is in fact outside its range.
* @txStandalone the admin's answer to a dialog; it stands whether or not the plugin then starts.
*/
private async rememberRangeAcceptance(id: string): Promise<void> {
const row = await this.plugins.findActivationGate(id);
if (!row?.version || hostSatisfies(row.trek_range)) return;
await this.plugins.acceptTrekRange(id, row.version, hostVersion());
}
/** All plugin rows projected to what the dependency helpers reason over. */
private async installedDepRows(): Promise<Map<string, PluginDepRow>> {
const rows: PluginDepRow[] = await this.plugins.listDepRows();
@@ -682,24 +695,8 @@ export class PluginRuntimeService implements OnApplicationBootstrap, OnModuleDes
// it would not make the plugin start. It is also the gate that catches the case
// install can't — TREK was upgraded PAST the plugin's declared upper bound, so code
// that was legitimately installed no longer supports the host it's sitting on.
const bypass = bypassedRange(row.trek_range);
if (bypass) {
// TREK_PLUGINS_IGNORE_TREK_RANGE: the operator chose to run it anyway. Say so in the
// log every time it starts — the plugin list carries the same marker for the UI.
warnRangeBypass(id, bypass);
} else if (!row.trek_range) {
throw new PluginDependencyError(
`plugin ${id} does not declare which TREK versions it supports`,
'TREK_VERSION_UNKNOWN',
{ trekRange: null, hostVersion: hostVersion() },
);
} else if (!hostSatisfies(row.trek_range)) {
throw new PluginDependencyError(
`plugin ${id} requires TREK ${row.trek_range} — this is TREK ${hostVersion()}`,
'TREK_VERSION_INCOMPATIBLE',
{ trekRange: row.trek_range, hostVersion: hostVersion() },
);
}
const refusal = trekRangeRefusal(id, row);
if (refusal) throw new PluginDependencyError(refusal.message, refusal.code, refusal.detail);
// Same reasoning as the TREK-version gate above: a plugin whose manifest apiVersion
// outpaces this TREK's plugin-API surface can never run correctly, so it must be
// refused before any consent dialog is offered.
+10 -3
View File
@@ -113,8 +113,15 @@ export class PluginsController {
// compatible version and reporting addons the admin still has to enable.
// Dependency resolution pins versions internally but never DELIBERATELY, so
// only the plain path below recomputes the update hold.
if (body.withDependencies) return await this.registry.installWithDependencies(body.id, body.constraint);
const res = await this.registry.install(body.id, { version: body.version, constraint: body.constraint });
const acceptTrekRange = body.acceptTrekRange === true;
if (body.withDependencies) {
return await this.registry.installWithDependencies(body.id, body.constraint, acceptTrekRange);
}
const res = await this.registry.install(body.id, {
version: body.version,
constraint: body.constraint,
acceptTrekRange,
});
await this.registry.recomputeUpdateHold(res.id, res.version, !!body.version);
return res;
} catch (e) {
@@ -272,7 +279,7 @@ export class PluginsController {
async activate(@Param('id') id: string, @Body() body: PluginActivateDto) {
if (!pluginsEnabled()) throw new HttpException({ error: 'Plugins are disabled by server configuration' }, 503);
try {
await this.runtime.activate(id, !!body?.consent);
await this.runtime.activate(id, !!body?.consent, body?.acceptTrekRange === true);
} catch (e) {
// Re-enabling a plugin whose update widened its permissions must NOT grant
// them silently — surface a distinct code so the UI opens the consent dialog.
+16 -5
View File
@@ -25,7 +25,7 @@ import {
import { devLinkEnabled } from './dev-link';
import { readAudit } from './host/plugin-audit';
import { pluginBudgetUsage } from './host/plugin-host-state';
import { bypassedRange, hostSatisfies, hostVersion, trekRangeBypassed } from './install/host-compat';
import { acceptanceHolds, bypassedRange, hostSatisfies, hostVersion, trekRangeBypassed } from './install/host-compat';
import type { TrekRangeBypass } from './install/host-compat';
import type { PluginDependency } from './install/manifest';
import { pluginsEnabled } from './kill-switch';
@@ -71,6 +71,8 @@ interface PluginRawRow {
capabilities: string;
dependencies: string | null;
trek_range: string | null;
trek_range_accepted_version: string | null;
trek_range_accepted_host: string | null;
author_pubkey: string | null;
update_block_code: string | null;
update_block_detail: string | null;
@@ -113,9 +115,10 @@ export interface PluginListItem {
/** The running TREK, so the UI can say "needs X, you have Y" without doing semver. */
hostVersion: string;
/**
* Non-null when the plugin is outside its declared range (or declared none) and only
* TREK_PLUGINS_IGNORE_TREK_RANGE lets it activate. The card shows it as a warning
* rather than a blocker: the admin chose this, but must keep seeing what they chose.
* Non-null when the plugin is outside its declared range (or declared none) and only an
* admin's "run it anyway" for this plugin, or TREK_PLUGINS_IGNORE_TREK_RANGE, lets it
* activate. The card shows it as a warning rather than a blocker: the admin chose this,
* but must keep seeing what they chose.
*/
trekRangeBypassed: TrekRangeBypass | null;
/** The concrete blockers, so the UI can render chips + the resolve dialog. */
@@ -200,7 +203,13 @@ export class PluginsService {
const state = resolveDependencyState(deps, installed);
// Mirrors the order of assertActivatable's gate, so the card explains the same
// blocker the activate call would hit rather than a second, lesser one.
const trekBypass = bypassedRange(r.trek_range);
const trekBypass = bypassedRange(
r.trek_range,
acceptanceHolds(r.version, {
acceptedVersion: r.trek_range_accepted_version,
acceptedHost: r.trek_range_accepted_host,
}),
);
const dependencyStatus: PluginDependencyStatus =
!hostSatisfies(r.trek_range) && !trekBypass
? 'hostIncompatible'
@@ -213,6 +222,8 @@ export class PluginsService {
dependencies: _raw,
operator_egress: _oe,
trek_range,
trek_range_accepted_version: _acceptedVersion,
trek_range_accepted_host: _acceptedHost,
author_pubkey,
update_block_code,
update_block_detail,
@@ -392,11 +392,11 @@ export class PluginRegistryService {
* version (`minTrekVersion`/`maxTrekVersion`). Throws if the plugin isn't in the
* registry or nothing qualifies. Backs "download the latest compatible version".
*/
async resolveVersion(id: string, constraint?: string): Promise<RegistryVersion> {
async resolveVersion(id: string, constraint?: string, acceptTrekRange = false): Promise<RegistryVersion> {
const reg = await this.fetchRegistry();
const entry = reg.plugins.find((p) => p.id === id);
if (!entry) throw new RegistryError(`plugin ${id} not in registry`);
const v = this.latestCompatible(entry, constraint);
const v = this.latestCompatible(entry, constraint) ?? (acceptTrekRange ? this.newestOf(entry, constraint) : null);
if (!v) {
throw new RegistryError(
constraint
@@ -427,6 +427,15 @@ export class PluginRegistryService {
return [...candidates].sort((a, b) => semver.rcompare(a.version, b.version))[0];
}
/**
* The newest version that satisfies `constraint`, whatever TREK it declares: what an
* admin's "install anyway" takes when no version fits this TREK. A version that does
* fit is always preferred over this (see {@link selectVersion}).
*/
private newestOf(entry: RegistryEntry, constraint?: string): RegistryVersion | null {
return this.latestCompatible(entry, constraint, () => true);
}
/**
* Pick the version `install()` will fetch, and refuse an incompatible one — on EVERY
* path, which is the whole point. An explicit `version` and the bare "install latest"
@@ -434,11 +443,15 @@ export class PluginRegistryService {
* through resolveVersion), so the admin UI's own Install button — which sends neither —
* happily installed a plugin that declared it doesn't support this TREK.
*/
private selectVersion(entry: RegistryEntry, opts?: { version?: string; constraint?: string }): RegistryVersion {
private selectVersion(
entry: RegistryEntry,
opts?: { version?: string; constraint?: string; acceptTrekRange?: boolean },
): RegistryVersion {
const accept = opts?.acceptTrekRange === true;
if (opts?.version) {
const ver = entry.versions.find((v) => v.version === opts.version);
if (!ver) throw new RegistryError(`version ${opts.version} not found for ${entry.id}`);
if (!installable(ver, normalizedHost())) {
if (!accept && !installable(ver, normalizedHost())) {
throw new RegistryError(
`${entry.id} ${ver.version} requires TREK ${trekRequirement(ver)} — this is TREK ${hostVersion()}`,
'TREK_VERSION_INCOMPATIBLE',
@@ -446,7 +459,8 @@ export class PluginRegistryService {
}
return ver;
}
const ver = this.latestCompatible(entry, opts?.constraint);
const ver =
this.latestCompatible(entry, opts?.constraint) ?? (accept ? this.newestOf(entry, opts?.constraint) : null);
if (ver) return ver;
// Nothing compatible. Say WHY against the newest version the admin was actually
// shown, rather than a bare "not found" — the fix is a TREK upgrade, not a retry.
@@ -476,7 +490,7 @@ export class PluginRegistryService {
*/
async install(
id: string,
opts?: { version?: string; constraint?: string; retrustKey?: string },
opts?: { version?: string; constraint?: string; retrustKey?: string; acceptTrekRange?: boolean },
): Promise<{ id: string; version: string; trekRangeBypassed: TrekRangeBypass | null }> {
const reg = await this.fetchRegistry();
const entry = reg.plugins.find((p) => p.id === id);
@@ -518,7 +532,7 @@ export class PluginRegistryService {
// published entries usually carry a lower bound and no upper one at all, so a
// plugin that declares "<4.0.0" passes the pre-download filter on TREK 4 and is
// caught only here.
const trekRangeBypassed = assertHostCompatible(manifest.trekRange, id);
const trekRangeBypassed = assertHostCompatible(manifest.trekRange, id, opts?.acceptTrekRange === true);
if (scanForNativeBinaries(pluginRoot).length) throw new RegistryError('artifact contains native binaries');
// 6. atomic move into place
@@ -543,6 +557,9 @@ export class PluginRegistryService {
// The plugin is now on new code that passed every check — whatever refusal was
// recorded before no longer describes reality.
await clearUpdateBlock(this.plugins, id);
// The admin's "install anyway" for this plugin, kept for the version that landed
// so activating it later does not ask a second time.
if (trekRangeBypassed?.acceptedByAdmin) await this.plugins.acceptTrekRange(id, ver.version, hostVersion());
});
return { id, version: ver.version, trekRangeBypassed };
} finally {
@@ -560,6 +577,7 @@ export class PluginRegistryService {
async installWithDependencies(
id: string,
constraint?: string,
acceptTrekRange = false,
): Promise<{ installed: string[]; requiredAddons: string[]; trekRangeBypassed: TrekRangeBypass | null }> {
let trekRangeBypassed: TrekRangeBypass | null = null;
const installedNow = new Set(await this.plugins.listAllIds());
@@ -570,12 +588,14 @@ export class PluginRegistryService {
const visit = async (pid: string, range: string | undefined, stack: string[]): Promise<void> => {
if (done.has(pid)) return;
if (stack.includes(pid)) throw new RegistryError(`plugin dependency cycle: ${[...stack, pid].join(' -> ')}`);
const ver = await this.resolveVersion(pid, range); // throws if not in registry / unsatisfiable
// The admin's "install anyway" covers the plugin they asked for, never a dependency.
const acceptHere = acceptTrekRange && pid === id;
const ver = await this.resolveVersion(pid, range, acceptHere); // throws if not in registry / unsatisfiable
if (!installedNow.has(pid)) {
// Install the version we just RESOLVED. Passing the range back (or nothing, for
// the root) made install() re-pick on its own and land on entry.versions[0] —
// so the compatible version resolveVersion had chosen was computed and discarded.
const res = await this.install(pid, { version: ver.version });
const res = await this.install(pid, { version: ver.version, acceptTrekRange: acceptHere });
// The admin asked for the root; that is the bypass they are warned about (a
// dependency's own bypass still lands in the log).
if (pid === id) trekRangeBypassed = res.trekRangeBypassed;
@@ -817,13 +837,14 @@ function installable(v: RegistryVersion, host: string | null): boolean {
* every install front door (registry, sideload, dev-link) so they all fail the same way,
* with a code the admin UI can act on rather than prose it would have to string-match.
*
* Under TREK_PLUGINS_IGNORE_TREK_RANGE the refusal becomes a log warning, and the
* returned marker is what the front door hands back so the admin is told too. Null
* means the range fits and nothing was bypassed.
* Under TREK_PLUGINS_IGNORE_TREK_RANGE, or when the admin `accepted` this one plugin
* outside its range, the refusal becomes a log warning, and the returned marker is what
* the front door hands back so the admin is told too. Null means the range fits and
* nothing was bypassed.
*/
export function assertHostCompatible(range: string | null, id: string): TrekRangeBypass | null {
export function assertHostCompatible(range: string | null, id: string, accepted = false): TrekRangeBypass | null {
if (hostSatisfies(range)) return null;
const bypass = bypassedRange(range);
const bypass = bypassedRange(range, accepted);
if (bypass) {
warnRangeBypass(id, bypass);
return bypass;