chore: clean up stale and redundant comments across backend and frontend
This commit is contained in:
1 parent
dbf475d55c
commit
08b3089569
64 files changed
+194
-309
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// Checks the UI and bridge contracts (docs/plugin-architecture.md §5.1, §5.6, §6.3)
|
||||
// Checks the UI and bridge contracts (see docs/plugin-architecture.md)
|
||||
// and writes ui-contract.json / bridge-contract.json for plugin authors.
|
||||
//
|
||||
// Rule "public means implemented": every stable part, state attribute, slot and
|
||||
|
||||
@@ -20,7 +20,7 @@ function walkFiles(dir, exts) {
|
||||
return out
|
||||
}
|
||||
|
||||
test('Static Guard (CRITICAL-1): lazy i18n domain keys are always backed by domain .gen imports', () => {
|
||||
test('lazy i18n domain keys are always backed by domain .gen imports', () => {
|
||||
const lazyDomains = ['wizard', 'settings', 'plugins']
|
||||
const keyToDomain = new Map()
|
||||
for (const dom of ['core', 'vm', ...lazyDomains]) {
|
||||
@@ -90,7 +90,7 @@ test('Static Guard (CRITICAL-1): lazy i18n domain keys are always backed by doma
|
||||
}
|
||||
})
|
||||
|
||||
test('Static Guard (CRITICAL-2): every stack-*, notice-*, error-boundary*, and toast-* class in TSX exists in CSS', () => {
|
||||
test('every stack-*, notice-*, error-boundary*, and toast-* class in TSX exists in CSS', () => {
|
||||
const css =
|
||||
fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') +
|
||||
'\n' +
|
||||
@@ -114,7 +114,7 @@ test('Static Guard (CRITICAL-2): every stack-*, notice-*, error-boundary*, and t
|
||||
}
|
||||
})
|
||||
|
||||
test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never replay on close', () => {
|
||||
test('Radix Presence .menu/.tooltip animations never replay on close', () => {
|
||||
const rawCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8')
|
||||
const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
const titleMenus = fs.readFileSync(path.join(srcDir, 'components', 'TitleMenus.tsx'), 'utf8')
|
||||
@@ -171,7 +171,7 @@ test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never
|
||||
)
|
||||
})
|
||||
|
||||
test('Static Guard (CRITICAL-4): software-composited UI avoids backdrop-filter and slow pre shaping', () => {
|
||||
test('software-composited UI avoids backdrop-filter and slow pre shaping', () => {
|
||||
const rawCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8')
|
||||
const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ export const App: React.FC = () => {
|
||||
refreshSubscribedVMStats()
|
||||
setThemeRevision((r) => r + 1)
|
||||
})
|
||||
// Logs never pop the panel open (docs/design-guidelines.md §7.3); errors only bump a badge.
|
||||
// Logs never pop the panel open (see docs/design-guidelines.md); errors only bump a badge.
|
||||
const offLog = events.onLog((entry) => {
|
||||
if (!entry || typeof entry !== 'object') return
|
||||
const lineText = typeof entry.line === 'string' ? entry.line : String(entry.line ?? '')
|
||||
@@ -465,7 +465,7 @@ export const App: React.FC = () => {
|
||||
// changed, so the workspace gives way to a screen that explains why.
|
||||
const showReadOnly = !!state && !showSetup && !!state.data_root_status?.read_only
|
||||
|
||||
// UI Contract v1 read-only document state attributes (§5.1).
|
||||
// UI Contract v2 read-only document state attributes.
|
||||
const currentView = showSetup ? 'setup' : selected === HOST_ID ? 'host' : selected === INSTALLERS_ID ? 'installers' : selected === PLUGINS_ID ? 'plugins' : selected === SETTINGS_ID ? 'settings' : selected === ABOUT_ID ? 'about' : 'vm'
|
||||
const isBusyAny = Object.keys(busy).length > 0 || runningTasks > 0
|
||||
const hasAnyError = unseenErrors > 0 || !!loadError
|
||||
@@ -544,7 +544,7 @@ export const App: React.FC = () => {
|
||||
}
|
||||
}, [taskMap])
|
||||
|
||||
// Apply active theme pack (zero extra CSS for builtin default theme, §5.1 & §8.1).
|
||||
// Apply active theme pack (zero extra CSS for builtin default theme).
|
||||
useEffect(() => {
|
||||
api.GetActiveTheme().then(setActiveThemePayload).catch((e) => console.warn('[app] GetActiveTheme failed:', e))
|
||||
api.GetPluginUIContributions().then(setPluginUI).catch((e) => console.warn('[app] GetPluginUIContributions failed:', e))
|
||||
@@ -932,7 +932,7 @@ export const App: React.FC = () => {
|
||||
refresh()
|
||||
}
|
||||
|
||||
// Global shortcuts (docs/design-guidelines.md §6). Dialogs own the keyboard while open.
|
||||
// Global shortcuts (see docs/design-guidelines.md). Dialogs own the keyboard while open.
|
||||
const shortcutRef = useRef<(e: KeyboardEvent) => void>(() => {})
|
||||
const appDialogOpen = showSetup || showReadOnly || showWizard || showSettings || affinityTarget || deleteTarget ||
|
||||
discardSuspendTarget || sendTextTarget || cloneSource || onlineRecoveryTarget || confirmUpdate
|
||||
|
||||
@@ -100,8 +100,8 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, tasks = [], draft,
|
||||
const [opts, setOpts] = useState<CreateOpts>(draft?.opts ?? {
|
||||
name: 'macos-tahoe',
|
||||
dir: '',
|
||||
// Offline by default: one exact release that installs with no network
|
||||
// (roadmap M2.3; `reims-ctl create --help`, upstream 3731afd).
|
||||
// Offline by default: installs an exact release without guest network access
|
||||
// (`reims-ctl create --help`, upstream 3731afd).
|
||||
source_mode: 'offline',
|
||||
macos: '',
|
||||
offline: true,
|
||||
|
||||
@@ -20,11 +20,8 @@ interface Props {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sandboxed L4 iframe panel with strict bridge verification (§4.2, §7.3):
|
||||
* - `sandbox="allow-scripts"` (no allow-same-origin, no top-navigation)
|
||||
* - Only responds to postMessage where `event.source === iframe.contentWindow`
|
||||
* - Routes all Host API calls through Go `PanelBridgeCall` for permission & rate checks
|
||||
* - Syncs theme tokens into iframe and provides error placeholder + retry.
|
||||
* Sandboxed L4 iframe panel verifying window identity (`event.source === iframe.contentWindow`
|
||||
* and opaque `null` origin) and routing Host API calls through `PanelBridgeCall`.
|
||||
*/
|
||||
const RE_SAFE_TOKEN = /^[a-f0-9]+$/
|
||||
const RE_SAFE_PLUGIN_ID = /^[a-z0-9][a-z0-9._-]*$/
|
||||
@@ -91,7 +88,7 @@ export const PluginPanelFrame: React.FC<Props> = ({
|
||||
|
||||
const onMessage = async (e: MessageEvent) => {
|
||||
const win = iframeRef.current?.contentWindow
|
||||
// Strict origin + window identity check for sandbox="allow-scripts" opaque origin (§7.3).
|
||||
// Require opaque origin and exact contentWindow identity for sandbox="allow-scripts".
|
||||
if (!win || e.source !== win || e.origin !== 'null') return
|
||||
const msg = e.data
|
||||
if (!msg || typeof msg !== 'object' || msg.type !== 'reims:rpc' || typeof msg.id !== 'string' || typeof msg.method !== 'string') return
|
||||
|
||||
@@ -42,10 +42,7 @@ function hasAppSettings(p: PluginInfo): boolean {
|
||||
return Object.values(schema.properties ?? {}).some((prop) => (prop['x-scope'] || schema['x-scope'] || 'app') === 'app')
|
||||
}
|
||||
|
||||
/**
|
||||
* Dedicated top-level Plugins & Themes management page (§5.1, §8.1, §10).
|
||||
* Grouped inset list, same pattern as the installers page.
|
||||
*/
|
||||
/** Top-level Plugins & Themes management page. */
|
||||
export const PluginsPage: React.FC<Props> = ({
|
||||
locale, appearance, safeMode, onRefresh, onError, onThemeChanged, onLocaleSwitch,
|
||||
}) => {
|
||||
@@ -75,13 +72,12 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
} | null>(null)
|
||||
const [scanBusy, setScanBusy] = useState(false)
|
||||
|
||||
// The market mounts (and touches the network) only once its tab is opened (§8.1).
|
||||
// Mount the market (and touch the network) only after its tab is opened.
|
||||
const [marketOpened, setMarketOpened] = useState(false)
|
||||
const [marketRefresh, setMarketRefresh] = useState(0)
|
||||
const [marketBusy, setMarketBusy] = useState(false)
|
||||
const [reloading, setReloading] = useState(false)
|
||||
|
||||
// Theme scheme editor state (§5.1)
|
||||
const [schemeEditorOpen, setSchemeEditorOpen] = useState(false)
|
||||
const [schemeName, setSchemeName] = useState('')
|
||||
const [seedAccent, setSeedAccent] = useState('#007aff')
|
||||
|
||||
@@ -20,7 +20,7 @@ interface Props {
|
||||
const SECRET_MASK = '••••••••'
|
||||
const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype'])
|
||||
|
||||
/** Lazy-loaded JSON Schema form renderer supporting x-secret, x-effect, x-scope (§6.2, §8.1, §10). */
|
||||
/** Lazy-loaded JSON Schema form renderer supporting x-secret, x-effect, and x-scope. */
|
||||
export const SchemaForm: React.FC<Props> = ({
|
||||
locale, schema, values, scopeFilter, groupFilter, onChange, hideGroupHeader,
|
||||
}) => {
|
||||
|
||||
@@ -44,7 +44,7 @@ import type { VMKeymapPreset, VMKeymapHostModifier, VMKeymapGuestModifier } from
|
||||
|
||||
const SchemaForm = lazy(() => import('./SchemaForm').then((m) => ({ default: m.SchemaForm })))
|
||||
|
||||
// VM settings (docs/design-guidelines.md §2–3): edits are staged here and written in
|
||||
// VM settings (see docs/design-guidelines.md): edits are staged here and written in
|
||||
// one `reims-ctl set` on Save, because upstream applies every change on the
|
||||
// next start. Each row marks itself when it differs from the VM's current
|
||||
// value and can be put back on its own.
|
||||
|
||||
@@ -103,7 +103,7 @@ interface Props {
|
||||
canSuspend: boolean
|
||||
/** Whether the native VM-window installation guide is currently active for this boot. */
|
||||
guideActive: boolean
|
||||
/** Whether the builtin.install-guide plugin is enabled. */
|
||||
/** Whether the VM-window install guide setting on builtin.guest.macos is enabled. */
|
||||
installGuideEnabled: boolean
|
||||
detail: VMDetail | null
|
||||
host: HostReport
|
||||
@@ -366,7 +366,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
}
|
||||
}
|
||||
|
||||
// One primary action per state (docs/design-guidelines.md §4): Start while
|
||||
// One primary action per state (see docs/design-guidelines.md): Start while
|
||||
// stopped, Resume while suspended, Show Window while running. Ctrl+Enter triggers it (App.tsx).
|
||||
let primary: React.ReactNode = null
|
||||
let secondary: React.ReactNode = null
|
||||
@@ -424,7 +424,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
primary = <Button variant="primary" icon={<Terminal size={14} aria-hidden="true" />} onClick={onViewLogs}>{tr('viewLogs')}</Button>
|
||||
}
|
||||
|
||||
// "More" menu, grouped by purpose; destructive items last (docs/design-guidelines.md §5.2).
|
||||
// "More" menu, grouped by purpose with destructive items last (see docs/design-guidelines.md).
|
||||
const menu = (
|
||||
<Menu.Root
|
||||
dir={localeDir(locale)}
|
||||
@@ -572,8 +572,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
</Menu.Root>
|
||||
)
|
||||
|
||||
// Summary: each fact once, in the user's words (docs/design-guidelines.md §5.2).
|
||||
// Row 1 carries live usage bars; raw upstream values stay in "Technical details".
|
||||
// Summary presents each fact once in user-facing words; raw upstream values stay in "Technical details".
|
||||
const specs: Spec[] = []
|
||||
if (detail) {
|
||||
const live = running && !!stats
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Plugin UI bridge contract, bridgeApi 1.0 (docs/plugin-architecture.md §5.6, §6.3).
|
||||
// Plugin UI bridge contract, bridgeApi 1.0 (see docs/plugin-architecture.md).
|
||||
//
|
||||
// Sandboxed plugin views and panels talk to the host only through these
|
||||
// postMessage envelopes. Stable methods and events are implemented and covered
|
||||
|
||||
@@ -7,7 +7,7 @@ function currentDocLocale(): string {
|
||||
return document.documentElement.dataset.locale || document.documentElement.lang || 'en-US'
|
||||
}
|
||||
|
||||
// Human-readable values for the main view (docs/design-guidelines.md §7.1).
|
||||
// Human-readable values for the main view (see docs/design-guidelines.md).
|
||||
// Raw values stay available under "Technical details".
|
||||
|
||||
const MEMORY_CHOICES = [4, 6, 8, 12, 16, 24, 32, 48, 64]
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
// Three-tier Theme Engine (docs/plugin-architecture.md §5.1):
|
||||
// - Builtin theme: zero extra CSS injected, zero UI SDK loaded (§8.1).
|
||||
// - Tier 1 (Token theme): seed colors + declarative lightness/chroma/alpha derivation,
|
||||
// bundled fonts, brand mark, background, and event sounds.
|
||||
// - Tier 2 (Style theme): sanitized stylesheet wrapped in `@layer theme` +
|
||||
// declarative state-driven slot decorations.
|
||||
// - Tier 3 (Interactive theme): lazy-loads `./uiSdk` only when a trusted `ui_script_url` is active.
|
||||
// Theme engine applying token, stylesheet, and interactive theme packs (see docs/plugin-architecture.md).
|
||||
// Builtin default theme injects zero extra CSS and never loads the interactive UI SDK.
|
||||
|
||||
import { UI_CONTRACT_LAYOUT_OPTIONS, UI_CONTRACT_TOKENS, type UIContractSDKEvent } from '../styles/ui-contract'
|
||||
import type { ActiveThemePayload, ThemeDecoration, ThemeDecorationState, TokenDeriveRule } from '../types'
|
||||
@@ -90,7 +85,7 @@ function decodeCSSEscapes(s: string): string {
|
||||
return out
|
||||
}
|
||||
|
||||
/** Validates a token key+value against the UI Contract whitelist and CSS injection rules (B5). */
|
||||
/** Validates a token key+value against the UI Contract whitelist and CSS injection rules. */
|
||||
export function sanitizeTokenValue(key: string, value: string): string | null {
|
||||
if (!ALLOWED_CONTRACT_TOKENS.has(key)) return null
|
||||
if (typeof value !== 'string') return null
|
||||
@@ -147,7 +142,7 @@ export function applyThemeLayout(layout: Record<string, unknown> | null | undefi
|
||||
}
|
||||
}
|
||||
|
||||
/** Verifies stylesheet has balanced braces and no unclosed strings/comments so it cannot escape `@layer theme` (B5). */
|
||||
/** Verifies stylesheet has balanced braces and no unclosed strings/comments so it cannot escape `@layer theme`. */
|
||||
export function isBalancedThemeCSS(css: string): boolean {
|
||||
if (css.toLowerCase().includes('</style')) return false
|
||||
let depth = 0
|
||||
@@ -234,7 +229,7 @@ function buildTokenVarLines(tokens: Record<string, string>): string {
|
||||
|
||||
/**
|
||||
* Applies cached theme tokens via a `@layer theme` `<style>` element (never
|
||||
* inline `element.style`, B8) keyed by appearance to avoid FOUC (§5.1).
|
||||
* inline `element.style`) keyed by appearance to avoid FOUC.
|
||||
*/
|
||||
export function applyCachedThemeTokensSync(): void {
|
||||
clearLegacyInlineCache()
|
||||
@@ -386,7 +381,7 @@ function pickHighContrastAccentText(hex: string): string {
|
||||
return darkContrast > whiteContrast ? '#1d1d1f' : '#ffffff'
|
||||
}
|
||||
|
||||
/** Derives CSS variable values from seed colors using declarative rules (§5.1). */
|
||||
/** Derives CSS variable values from seed colors using declarative rules. */
|
||||
export function deriveTokensFromSeeds(
|
||||
seeds: Record<string, string>,
|
||||
rules: TokenDeriveRule[] | undefined,
|
||||
@@ -467,7 +462,7 @@ export async function applyActiveTheme(
|
||||
): Promise<void> {
|
||||
const gen = ++applyGeneration
|
||||
|
||||
// Always drop prepaint & legacy inline tokens so live theme/builtin always wins (B8).
|
||||
// Drop prepaint and legacy inline tokens so the live or builtin theme always wins.
|
||||
document.getElementById(PREPAINT_EL_ID)?.remove()
|
||||
clearLegacyInlineCache()
|
||||
|
||||
@@ -479,7 +474,6 @@ export async function applyActiveTheme(
|
||||
activeUIScriptURL = ''
|
||||
}
|
||||
|
||||
// Builtin default theme (or safe mode) -> zero extra CSS injected (§8.1).
|
||||
if (!payload || !payload.theme || payload.theme_id === 'builtin.theme.default') {
|
||||
clearDynamicThemeStyles()
|
||||
applyThemeLayout(null)
|
||||
@@ -491,7 +485,6 @@ export async function applyActiveTheme(
|
||||
const rawBaseURL = payload.asset_base_url ?? ''
|
||||
const baseURL = RE_ASSET_BASE_URL.test(rawBaseURL) && !rawBaseURL.includes('..') ? rawBaseURL : ''
|
||||
|
||||
// 1. Resolve active seed colors (custom scheme -> built-in scheme -> theme default seeds).
|
||||
let seeds: Record<string, string> = { ...(th.seeds ?? {}) }
|
||||
if (payload.active_scheme) {
|
||||
const custom = (payload.custom_schemes ?? []).find((s) => s.id === payload.active_scheme && s.theme_id === payload.theme_id)
|
||||
@@ -500,7 +493,6 @@ export async function applyActiveTheme(
|
||||
else if (preset?.seeds) seeds = { ...seeds, ...preset.seeds }
|
||||
}
|
||||
|
||||
// 2. Compute derived + explicit tokens and filter strictly through UI Contract whitelist (B5).
|
||||
const rawTokens: Record<string, string> = {
|
||||
...deriveTokensFromSeeds(seeds, th.deriveRules, appearance),
|
||||
...(th.tokens ?? {}),
|
||||
@@ -512,7 +504,6 @@ export async function applyActiveTheme(
|
||||
if (safe) sanitizedTokens[k] = safe
|
||||
}
|
||||
|
||||
// 3. Inject validated bundled @font-face declarations (B5).
|
||||
let fontCSS = ''
|
||||
for (const f of th.fonts ?? []) {
|
||||
const family = typeof f.family === 'string' ? f.family.trim() : ''
|
||||
@@ -537,7 +528,6 @@ export async function applyActiveTheme(
|
||||
document.getElementById(FONT_EL_ID)?.remove()
|
||||
}
|
||||
|
||||
// 4. Write validated token CSS + Tier-2 stylesheet wrapped inside `@layer theme` (§5.1, B5/B7).
|
||||
const varLines = buildTokenVarLines(sanitizedTokens)
|
||||
let bgCSS = ''
|
||||
if (th.background && baseURL) {
|
||||
@@ -557,7 +547,7 @@ export async function applyActiveTheme(
|
||||
}
|
||||
styleEl.textContent = fullCSS
|
||||
|
||||
// Persist appearance-keyed cache for prepaint (B8).
|
||||
// Persist appearance-keyed cache for prepaint.
|
||||
try {
|
||||
let nextCache: ThemeTokenCache = {
|
||||
themeId: payload.theme_id,
|
||||
@@ -576,7 +566,7 @@ export async function applyActiveTheme(
|
||||
console.warn('[theme] persist theme token cache failed:', e)
|
||||
}
|
||||
|
||||
// 5. Tier 3: lazy-load UI SDK ONLY when an approved interactive theme script is present (§8.1).
|
||||
// Lazy-load UI SDK only when an approved interactive theme script is present.
|
||||
if (nextScriptURL && nextScriptURL !== activeUIScriptURL) {
|
||||
try {
|
||||
const { mountInteractiveThemeScript, notifyThemeSDKState, emitThemeSDKEvent } = await import('./uiSdk')
|
||||
@@ -596,7 +586,7 @@ export async function applyActiveTheme(
|
||||
activeUIScriptURL = nextScriptURL
|
||||
} catch {
|
||||
if (gen === applyGeneration) {
|
||||
// Fallback gracefully to the scriptless style/token theme (§4.2).
|
||||
// Fall back to the scriptless style/token theme.
|
||||
activeUIScriptCleanup = null
|
||||
activeUIScriptURL = ''
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Lazy-loaded Tier-3 Interactive Theme UI SDK (docs/plugin-architecture.md §5.1).
|
||||
// Loaded ONLY when a trusted interactive theme with `ui:script` is enabled (§8.1).
|
||||
// Lazy-loaded interactive theme UI SDK (see docs/plugin-architecture.md).
|
||||
// Loaded only when a trusted interactive theme with `ui:script` is enabled.
|
||||
|
||||
import {
|
||||
UI_API_VERSION, UI_CONTRACT_FEATURES, UI_CONTRACT_LAYERS, UI_CONTRACT_PARTS, UI_CONTRACT_SDK_EVENTS, UI_CONTRACT_SLOTS,
|
||||
@@ -140,7 +140,7 @@ export async function mountInteractiveThemeScript(
|
||||
try {
|
||||
setup((fn) => localDisposers.push(fn))
|
||||
} catch {
|
||||
// Feature-isolated error: tear down only this feature (§4.2, §5.1).
|
||||
// Feature-isolated error: tear down only this feature.
|
||||
localDispose()
|
||||
}
|
||||
},
|
||||
@@ -230,9 +230,8 @@ export async function mountInteractiveThemeScript(
|
||||
}
|
||||
|
||||
// Hide Wails binding globals from `window` before executing any theme script,
|
||||
// and shadow bridge identifiers inside its closure (§5.1, B6). Note: scripts
|
||||
// in the main window still run in the same DOM realm, so `ui:script` remains
|
||||
// a high-trust permission requiring explicit user approval.
|
||||
// and shadow bridge identifiers inside its closure. Scripts in the main
|
||||
// window still share the DOM realm, so `ui:script` requires explicit approval.
|
||||
hideWailsGlobals()
|
||||
|
||||
const resp = await fetch(scriptURL, { credentials: 'same-origin' })
|
||||
|
||||
@@ -39,8 +39,8 @@ interface Props {
|
||||
|
||||
const gb = (b: number) => (b >= 1e9 ? `${(b / 1e9).toFixed(1)} GB` : `${Math.max(1, Math.ceil(b / 1e6))} MB`)
|
||||
|
||||
// reims-util creates the whole image as soon as a download starts (19.7 GB for an
|
||||
// 18.4 GB release, measured 2026-11-28): reserve 10% over the release size.
|
||||
// reims-util preallocates the full image on start (~19.7 GB for an 18.4 GB
|
||||
// release); reserve 10% headroom over the catalog size.
|
||||
const needBytes = (r: Release) => r.size * 1.1
|
||||
|
||||
type ReleaseGroup = { key: string; title: string; major: number | null; releases: Release[] }
|
||||
|
||||
@@ -6,7 +6,7 @@ import { applyCachedThemeTokensSync } from './lib/themeEngine'
|
||||
import './styles/app.css'
|
||||
import { events } from './wails'
|
||||
|
||||
// Inline cached theme tokens before first paint to prevent FOUC (§5.1).
|
||||
// Inline cached theme tokens before first paint to prevent FOUC.
|
||||
applyCachedThemeTokensSync()
|
||||
|
||||
let lastReportedErr = ''
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Layer order: host-guard first so its !important usability invariants beat all
|
||||
normal and !important rules in base/theme/user (CSS Cascade 5); normal rules
|
||||
follow base -> theme -> user (§5.1, B7/M15). */
|
||||
follow base -> theme -> user. */
|
||||
@layer host-guard, base, theme, user;
|
||||
@import "./tokens.css";
|
||||
|
||||
@@ -1349,7 +1349,7 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
.meter-fill.warn { background: var(--status-busy); }
|
||||
.meter-fill.high { background: var(--status-error); }
|
||||
|
||||
/* ── Motion (emil-design-eng & apple-design) ───────────── */
|
||||
/* Motion keyframes */
|
||||
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
|
||||
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
|
||||
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
|
||||
@@ -1533,7 +1533,7 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
}
|
||||
}
|
||||
|
||||
/* ── v0.2.6 Enhancements: Screenshot, Note, Dropzone, Snapshots, Log Filter, Welcome ── */
|
||||
/* Screen screenshot button, notes, dropzone, snapshots, log filter, welcome */
|
||||
.vm-screen.is-live { cursor: pointer; }
|
||||
.vm-screen-shot {
|
||||
position: absolute; right: 8px; bottom: 8px; z-index: 3;
|
||||
@@ -1662,7 +1662,7 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
.welcome-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
|
||||
.welcome-card p { font-size: var(--fs-13); color: var(--text-2); max-width: 380px; }
|
||||
|
||||
/* Plugin system & UI Contract v1 (docs/plugin-architecture.md §5.1, §7.3, §9) */
|
||||
/* Plugin slots, safe-mode banner & UI Contract v2 (see docs/plugin-architecture.md) */
|
||||
.safe-mode-banner {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
|
||||
padding: 6px var(--sp-4); font-size: var(--fs-12);
|
||||
@@ -1679,13 +1679,9 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
}
|
||||
.nav-item-trailing { display: inline-flex; align-items: center; flex-shrink: 0; }
|
||||
|
||||
/* uiApi 2.0 full-window layers (ui-contract.ts): fixed to the window, never
|
||||
take pointer input or focus, and freeze animations under reduced motion.
|
||||
The shell is its own stacking context: the background layer (z -1) paints
|
||||
over the shell's own background and under all of its content (themes make
|
||||
the shell surfaces translucent to reveal it); the overlay layer (z 30) sits
|
||||
above the titlebar and status bar (z 10). Dialogs, menus and tooltips are
|
||||
portaled to body and the toaster sits outside the shell, so they stay on top. */
|
||||
/* uiApi 2.0 full-window layers (ui-contract.ts): `.app-shell` forms an isolated
|
||||
stacking context so background (z -1) sits under content and overlay (z 30)
|
||||
sits above chrome while portaled dialogs/menus/toasts stay on top. */
|
||||
.app-shell { position: relative; isolation: isolate; }
|
||||
.rg-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
|
||||
.rg-layer:empty { display: none; }
|
||||
@@ -2034,7 +2030,7 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
}
|
||||
|
||||
/* Host usability invariants locked with !important in earliest layer so themes
|
||||
cannot override them even with !important (§5.1, B7/M15). */
|
||||
cannot override them even with !important. */
|
||||
@layer host-guard {
|
||||
.rg-p-titlebar { --wails-draggable: drag !important; }
|
||||
:focus-visible:not(.dialog):not(.menu) { box-shadow: var(--focus-ring) !important; }
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
|
||||
--seg-thumb: #ffffff;
|
||||
|
||||
/* Motion (emil-design-eng & apple-design curves) */
|
||||
/* Motion curves and durations */
|
||||
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
||||
--ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
|
||||
--ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Single source of truth for UI Contract v2 (docs/plugin-architecture.md §5.1, §6.3).
|
||||
// Single source of truth for UI Contract v2 (see docs/plugin-architecture.md).
|
||||
// Renaming or removing any stable entry here is a uiApi major bump.
|
||||
//
|
||||
// Every entry is either stable or experimental. Stable entries must be emitted
|
||||
@@ -182,7 +182,7 @@ export type UIContractIcon = (typeof UI_CONTRACT_ICONS)[number]
|
||||
|
||||
export const UI_CONTRACT_ICONS_EXPERIMENTAL = [] as const
|
||||
|
||||
// Where plugin `views` can appear (§5.6).
|
||||
// Where plugin `views` can appear.
|
||||
export const UI_CONTRACT_VIEW_LOCATIONS = [] as const
|
||||
|
||||
export const UI_CONTRACT_VIEW_LOCATIONS_EXPERIMENTAL = [
|
||||
@@ -256,7 +256,7 @@ export const UI_CONTRACT = {
|
||||
},
|
||||
}
|
||||
|
||||
// Stable host features advertised to themes through the UI SDK (§6.3).
|
||||
// Stable host features advertised to themes through the UI SDK.
|
||||
export const UI_CONTRACT_FEATURES: readonly string[] = [
|
||||
...UI_CONTRACT_SLOTS.map((s) => `slot.${s}`),
|
||||
...UI_CONTRACT_LAYERS,
|
||||
|
||||
@@ -71,7 +71,7 @@ interface IconButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElem
|
||||
tipSide?: TipProps['side']
|
||||
}
|
||||
|
||||
/** Icon-only button: always carries a tooltip and an accessible name (§4.5). */
|
||||
/** Icon-only button: always carries a tooltip and an accessible name. */
|
||||
export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
||||
({ label, shortcut, icon, busy, small, disabled, className, tipSide, ...rest }, ref) => (
|
||||
<Tip label={label} shortcut={shortcut} side={tipSide}>
|
||||
|
||||
@@ -3,10 +3,7 @@ import { Check, ChevronsUpDown, CircleAlert, Lock, RotateCcw } from 'lucide-reac
|
||||
import React, { useEffect, useId, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { IconButton } from './controls'
|
||||
|
||||
// Settings page primitives (docs/design-guidelines.md §2–3):
|
||||
// one row shell — title and description on the left, the control on the
|
||||
// right — plus the switch, segmented control, range field and option cards
|
||||
// every category builds its rows from, so the whole panel reads as one set.
|
||||
// Settings page row shell and shared form controls (see docs/design-guidelines.md).
|
||||
|
||||
/** A labelled block of rows, like a grouped list in macOS System Settings. */
|
||||
export const SetGroup: React.FC<{ title?: string; note?: React.ReactNode; children: React.ReactNode }> = ({ title, note, children }) => (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Theme visuals from uiApi 2.0 (docs/plugin-architecture.md §5.1): icon
|
||||
// Theme visuals from uiApi 2.0 (see docs/plugin-architecture.md): icon
|
||||
// overrides, the brand mark, and declarative decorations rendered into slot
|
||||
// anchors (`data-rg-slot`) and full-window layers (`data-rg-layer`).
|
||||
// With the built-in theme none of this injects anything.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// At module boot we privately capture `window.go.app.App` and `window.runtime`
|
||||
// so `hideWailsGlobals()` can remove them from `window` before running any
|
||||
// Tier-3 interactive theme script without breaking the app's own calls (§5.1, B6).
|
||||
// Tier-3 interactive theme script without breaking the app's own calls.
|
||||
import * as Go from '../wailsjs/go/app/App'
|
||||
import {
|
||||
EventsEmit as RawEventsEmit,
|
||||
@@ -42,7 +42,7 @@ for (const key of Object.keys(Go) as Array<keyof typeof Go>) {
|
||||
|
||||
/**
|
||||
* Hides Wails binding globals (`window.go` and unsafe `window.runtime` methods)
|
||||
* before mounting an interactive theme script (§5.1, B6). Only `ResolveFilePaths`
|
||||
* before mounting an interactive theme script. Only `ResolveFilePaths`
|
||||
* (required internally by Wails's native drag-and-drop bridge) is retained on a
|
||||
* frozen runtime stub.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ type AppState struct {
|
||||
Transitions map[string]string `json:"transitions"`
|
||||
PendingChanges map[string][]PendingChange `json:"pending_changes"`
|
||||
ActiveGuides []string `json:"active_guides,omitempty"`
|
||||
// InstallGuideEnabled is true while the builtin.install-guide plugin is active.
|
||||
// InstallGuideEnabled reports whether the VM-window install guide service is active.
|
||||
InstallGuideEnabled bool `json:"install_guide_enabled,omitempty"`
|
||||
// NeedsSetup is true on first launch, until a data folder is chosen (setup.go).
|
||||
NeedsSetup bool `json:"needs_setup"`
|
||||
|
||||
@@ -60,10 +60,10 @@ func appUpdateDir(dataRoot string) string {
|
||||
return filepath.Join(dataRoot, "downloads", "app")
|
||||
}
|
||||
|
||||
// DownloadAppUpdate downloads the newest stable release in the background and
|
||||
// returns the task ID ("app-update", subject = the release tag). Canceling it
|
||||
// keeps the partial file, and the next download continues from there. A
|
||||
// download that already finished and still verifies completes at once.
|
||||
// DownloadAppUpdate downloads the newest eligible release on the selected
|
||||
// update channel in the background and returns the task ID ("app-update",
|
||||
// subject = the release tag). Canceling keeps the partial file so the next
|
||||
// download resumes from there.
|
||||
func (a *App) DownloadAppUpdate() (string, error) {
|
||||
if err := a.updateSupported(); err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package app
|
||||
|
||||
// Finishing an offline install (roadmap M2.3): take the installer out and turn
|
||||
// the network back on, which an offline install keeps off so its installer
|
||||
// downloads no update (`reims-ctl create --help`, upstream 3731afd).
|
||||
// Finishing an offline install ejects the attached installer and re-enables
|
||||
// guest networking (`reims-ctl create --help`, upstream 3731afd).
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -18,12 +17,8 @@ import (
|
||||
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
// recoveryPickerMarkerFile tracks OpenCore ShowPicker state managed by
|
||||
// reims-go's recovery-mode toggle inside the VM directory:
|
||||
// - "want": EnterRecovery ran while VM was running; apply --boot-selection=true before next start.
|
||||
// - "on": --boot-selection=true is active on opencore.qcow2.
|
||||
// - "restore": FinishInstall ran while VM was running; apply --boot-selection=false before next start.
|
||||
// - "": Normal direct boot (file absent).
|
||||
// isRecoveryModeActive reports whether d has an installer attached or an
|
||||
// active/scheduled OpenCore boot-picker marker ("on" or "want").
|
||||
func isRecoveryModeActive(d reims.VMDetail) bool {
|
||||
if d.HasInstaller {
|
||||
return true
|
||||
@@ -104,10 +99,9 @@ func (a *App) EnterRecovery(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// EnterRecovery enables OpenCore's boot picker (--boot-selection=true) so the
|
||||
// VM can boot macOS's built-in Recovery volume without needing an external
|
||||
// installer image (upstream reims-util 7867384 sets HideAuxiliary=false).
|
||||
// If the VM is running, the change is queued for the next start/restart.
|
||||
// enterRecoveryLegacy is the direct reims-ctl fallback when the lifecycle
|
||||
// router is unconfigured; it enables OpenCore's boot picker (--boot-selection=true)
|
||||
// immediately when stopped or queues a "want" marker when running.
|
||||
func (a *App) enterRecoveryLegacy(name string) error {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
// getInstallGuideManager returns the active builtin.install-guide manager when
|
||||
// the plugin is enabled, or nil when disabled or unavailable.
|
||||
// getInstallGuideManager returns the active VM-window install guide manager
|
||||
// provided by builtin.guest.macos, or nil when disabled.
|
||||
func (a *App) getInstallGuideManager() *installguide.Manager {
|
||||
a.mu.Lock()
|
||||
mgr := a.pluginMgr
|
||||
@@ -29,8 +29,7 @@ func (a *App) getInstallGuideManager() *installguide.Manager {
|
||||
return gm
|
||||
}
|
||||
|
||||
// installGuideEnabled reports whether the VM-window installation guide builtin
|
||||
// plugin is currently active.
|
||||
// installGuideEnabled reports whether the VM-window installation guide service is active.
|
||||
func (a *App) installGuideEnabled() bool {
|
||||
return a.getInstallGuideManager() != nil
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package app
|
||||
|
||||
// Wails bindings for offline installers (roadmap M1.3). The download manager
|
||||
// page (M2.2) builds on these; downloads report through tasks (tasks.go).
|
||||
// Wails bindings for querying, downloading, and deleting cached macOS offline installers.
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -247,12 +247,11 @@ func (a *App) startVMLegacy(name string) error {
|
||||
a.emitVMLog(name, "Warning: could not read arg ledger: "+ledgerErr.Error())
|
||||
ledger = &plugin.ArgLedger{Version: 1, Owners: map[string][]plugin.ArgFragment{}}
|
||||
}
|
||||
// Fragments written before the builtins were merged into the core
|
||||
// belong to the core now; carry them instead of re-adding them.
|
||||
// Reassign macOS-owned fragments from legacy builtin.core records to
|
||||
// builtin.guest.macos before reconciling.
|
||||
guest.MigrateLedger(ledger)
|
||||
// Adopt/strip pre-ledger or out-of-band managed fragments before reconciling
|
||||
// so upgrading existing VMs never duplicates QEMU device IDs (B1).
|
||||
// BeforeStartPayload above already saw the original curDetail.ExtraArgs.
|
||||
// Strip pre-ledger or out-of-band managed fragments so upgrading existing
|
||||
// VMs never duplicates QEMU device IDs.
|
||||
baseExtraArgs := stripLegacyManagedExtraArgs(curDetail.ExtraArgs)
|
||||
reconciled := plugin.ReconcileStartIntents(baseExtraArgs, ledger, mgr.Registry().ActivePluginIDs(), intents)
|
||||
reconciled.Changed = strings.TrimSpace(curDetail.ExtraArgs) != reconciled.ExtraArgs
|
||||
|
||||
@@ -63,8 +63,8 @@ func (a *App) initPlugins() {
|
||||
safeMode := a.launch.SafeMode
|
||||
a.mu.Unlock()
|
||||
|
||||
// Idempotent fallback for embedders that construct a Manager directly;
|
||||
// normal startup already ran this as data layout v2 in dataroot.Open.
|
||||
// Idempotent fallback for tests or embedders that construct a Manager directly;
|
||||
// normal startup already ran this as data layout v3 in dataroot.Open.
|
||||
if err := guest.MigrateFiles(dataRoot); err != nil {
|
||||
a.emitLog("plugin", "Could not migrate macOS guest state: "+err.Error())
|
||||
return
|
||||
|
||||
@@ -26,7 +26,7 @@ type macosImporter struct {
|
||||
// source or test files) stops, so the list can only shrink.
|
||||
var macosImporters = map[string]macosImporter{
|
||||
"internal/app": {test: true, why: "GUI composition root tests may exercise native macOS flows"},
|
||||
"internal/datamigrate": {src: true, test: true, why: "data layout v2 invokes and verifies the macOS-owned state and ledger migration"},
|
||||
"internal/datamigrate": {src: true, test: true, why: "data layout v3 invokes and verifies the macOS-owned state and ledger migration"},
|
||||
"internal/plugin/builtin": {src: true, why: "host Guest Tools bridge still uses reims argument helpers; guest registration moved to internal/macos/guest"},
|
||||
"internal/guesttools": {src: true, test: true, why: "mixed: host transport and clipboard next to the macOS guest agent image"},
|
||||
"internal/plugin": {test: true, why: "sidecar manager test builds a reims-ctl stand-in"},
|
||||
|
||||
@@ -366,7 +366,7 @@ func cmdPlugin(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("usage: reims-go plugin disable <id>")
|
||||
}
|
||||
// Load in safeMode so a broken external plugin never prevents disabling it (M9).
|
||||
// Load in safeMode so a broken external plugin never prevents disabling it.
|
||||
mgr, _, err := openCLIPluginManager(cfg, true)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -17,9 +17,7 @@ type Config struct {
|
||||
ActiveRuntime string `json:"active_runtime,omitempty"`
|
||||
AutoPinPCores bool `json:"auto_pin_pcores"`
|
||||
DefaultGPU string `json:"default_gpu,omitempty"`
|
||||
// RuntimeChannel is "stable" (default, also when empty) or "alpha":
|
||||
// whether online install offers alpha runtimes (portable-runtime-spec.md §6).
|
||||
// "candidate", the name used before 2026-11-28, is read as "alpha".
|
||||
// RuntimeChannel is "stable" (default, also when empty) or "alpha" (legacy alias "candidate").
|
||||
RuntimeChannel string `json:"runtime_channel,omitempty"`
|
||||
// AppUpdateChannel is "stable" (default, also when empty), "alpha", or "dev":
|
||||
// controls which Reims-Go client releases CheckAppUpdate offers, and whether
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
// Package datamigrate versions the data folder and upgrades it in place.
|
||||
//
|
||||
// The data folder records the data layout version it is at in StampFile.
|
||||
// Every release carries the steps from older layouts to its own and runs
|
||||
// them on startup, so users can jump straight from an old release to a new
|
||||
// one. A release that has dropped the steps for very old layouts can tell
|
||||
// from the stamp that an intermediate release is needed.
|
||||
//
|
||||
// The stamp lives in its own file, not in reims-go.json, because
|
||||
// config.Save rewrites that file from its struct and an older release
|
||||
// would drop a field it does not know.
|
||||
// Package datamigrate versions the data folder via StampFile and applies
|
||||
// idempotent in-place upgrades on startup. StampFile is separate from
|
||||
// reims-go.json so older releases rewriting Config from their struct do not
|
||||
// strip unknown version fields.
|
||||
package datamigrate
|
||||
|
||||
import (
|
||||
|
||||
@@ -196,7 +196,6 @@ func (p *ParallelDownloader) Download(ctx context.Context, req Request, onProgre
|
||||
return err
|
||||
}
|
||||
|
||||
// 1. Resolve chunk plan (prefer Apple CNKL chunklist when provided).
|
||||
var (
|
||||
chunks []ChunkSpec
|
||||
totalSize int64
|
||||
@@ -239,7 +238,6 @@ func (p *ParallelDownloader) Download(ctx context.Context, req Request, onProgre
|
||||
chunks = splitEqualChunks(totalSize, opts.ChunkSize)
|
||||
}
|
||||
|
||||
// 2. Open target file (preserving existing contents when resuming or writing into a region).
|
||||
flags := os.O_CREATE | os.O_RDWR
|
||||
if !req.Resume && req.DestOffset == 0 {
|
||||
flags |= os.O_TRUNC
|
||||
@@ -257,7 +255,6 @@ func (p *ParallelDownloader) Download(ctx context.Context, req Request, onProgre
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Determine already-completed chunks for instant resume.
|
||||
doneMask := make([]bool, len(chunks))
|
||||
if req.Resume {
|
||||
if loaded := loadResumeState(req.DestPath, req.URL, req.DestOffset, totalSize, len(chunks)); loaded != nil {
|
||||
@@ -295,7 +292,6 @@ func (p *ParallelDownloader) Download(ctx context.Context, req Request, onProgre
|
||||
return nil
|
||||
}
|
||||
|
||||
// 4. Dynamic worker pool with live byte counter & sliding-window speed meter.
|
||||
var (
|
||||
inflightBytes atomic.Int64
|
||||
maskMu sync.Mutex
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// Package driver defines the generic guest VM driver abstraction and router
|
||||
// (docs/plugin-architecture.md §5.3). Existing macOS/reims VMs are served by
|
||||
// builtin.driver.reims-macos with zero migration.
|
||||
// Package driver defines the generic guest VM driver contract and router.
|
||||
package driver
|
||||
|
||||
import (
|
||||
@@ -356,7 +354,7 @@ func (rt *Router) DriverByID(id string) (Driver, error) {
|
||||
}
|
||||
|
||||
// ListAllVMs merges VM listings from all active drivers and appends any VM
|
||||
// directory under vmRootDir whose owning driver is currently unavailable (§4.2, §5.3).
|
||||
// under declared VM roots whose owning driver is currently unavailable.
|
||||
func (rt *Router) ListAllVMs(ctx context.Context) ([]VMInfo, error) {
|
||||
seen := make(map[string]bool)
|
||||
var out []VMInfo
|
||||
|
||||
@@ -79,12 +79,9 @@ type Report struct {
|
||||
AvailRAMGB float64 `json:"avail_ram_gb"`
|
||||
MemoryLoadPct int `json:"memory_load_pct"`
|
||||
MemorySpec *HostMemorySpec `json:"memory_spec,omitempty"`
|
||||
// Commit memory: QEMU commits all guest RAM at start (CreateFileMapping), so
|
||||
// a VM needs its memory free in the commit charge, not just in physical RAM.
|
||||
// Measured 2026-11-28: 14.7 GiB commit free with 17.3 GiB physical free, and a
|
||||
// 16G guest failed ("Cannot set up guest memory"); the paging file setup of
|
||||
// that host was not recorded. Both values include what the paging files can
|
||||
// still grow (CommitHeadroom): Windows grows them when a commit needs it.
|
||||
// QEMU commits all guest RAM at start (CreateFileMapping), so a VM requires
|
||||
// available Windows commit charge rather than physical free RAM alone. Both
|
||||
// values include expandable paging-file headroom (CommitHeadroom).
|
||||
CommitAvailGB float64 `json:"commit_avail_gb"`
|
||||
CommitLimitGB float64 `json:"commit_limit_gb"`
|
||||
PagingFileGrowthGB float64 `json:"paging_file_growth_gb,omitempty"` // part of both values above
|
||||
|
||||
@@ -22,15 +22,12 @@ type PagingFile struct {
|
||||
VolumeFreeGB float64
|
||||
}
|
||||
|
||||
// CommitHeadroom returns the commit limit Windows can reach and the commit it
|
||||
// can still grant, counting what paging files can still grow on top of the
|
||||
// current limit and free commit. A commit larger than the free commit makes
|
||||
// Windows grow a system-managed or min/max-sized paging file on the spot
|
||||
// (measured 2026-12-01: one 24.3 GB CreateFileMapping with 14.3 GB free grew
|
||||
// the limit from 37.4 to 47.4 GB), so the current limit alone refuses VMs
|
||||
// that would start. Growth is capped by each file's maximum and its volume's
|
||||
// free space less pagingFileDiskReserveGB; a fixed-size or absent paging file
|
||||
// adds nothing.
|
||||
// CommitHeadroom returns the reachable Windows commit limit and available
|
||||
// commit charge, adding expandable paging-file capacity on top of current
|
||||
// values. Windows expands system-managed or min/max-sized paging files on
|
||||
// demand when a commit exceeds the current limit, capped by each file's
|
||||
// maximum size and its volume's free space minus pagingFileDiskReserveGB;
|
||||
// fixed-size or disabled paging files add zero growth.
|
||||
func CommitHeadroom(limitGB, availGB float64, files []PagingFile) (reachableLimitGB, reachableAvailGB float64) {
|
||||
growth := PagingFileGrowthGB(files)
|
||||
return limitGB + growth, availGB + growth
|
||||
|
||||
@@ -92,7 +92,7 @@ func EvaluateCoreOptimizations(rep Report) []Optimization {
|
||||
|
||||
var out []Optimization
|
||||
|
||||
// 1. P-Core affinity pinning (hybrid Intel CPUs)
|
||||
// P-Core affinity pinning (hybrid Intel CPUs)
|
||||
if rep.HasHybridCores {
|
||||
detail := fmt.Sprintf("%dP+%dE", rep.PCoreCount, rep.ECoreCount)
|
||||
if len(rep.PCoreLogicalCPUs) > 0 {
|
||||
@@ -116,7 +116,7 @@ func EvaluateCoreOptimizations(rep Report) []Optimization {
|
||||
})
|
||||
}
|
||||
|
||||
// 4. Discrete Vulkan GPU acceleration
|
||||
// Discrete Vulkan GPU acceleration
|
||||
if rep.RecommendedGPU != nil && rep.RecommendedGPU.Compat == GPUCompatUnsupported {
|
||||
out = append(out, Optimization{
|
||||
ID: "discrete_gpu",
|
||||
@@ -154,7 +154,7 @@ func EvaluateCoreOptimizations(rep Report) []Optimization {
|
||||
})
|
||||
}
|
||||
|
||||
// 5. CoW backing chain depth advisory (when any VM disk has depth >= 2 or broken parent)
|
||||
// CoW backing chain depth advisory (depth >= 2 or broken parent)
|
||||
if len(rep.DeepBackingChains) > 0 {
|
||||
var parts []string
|
||||
for _, c := range rep.DeepBackingChains {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Package progress defines task progress shared by host services and engine adapters.
|
||||
// Task progress types shared by host services and engine adapters.
|
||||
package host
|
||||
|
||||
type Kind string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Package redact provides host-wide secret and identifier redaction.
|
||||
// Host-wide secret and hardware-identifier redaction helpers.
|
||||
package host
|
||||
|
||||
import (
|
||||
@@ -15,7 +15,7 @@ var (
|
||||
reLogTokenKV = regexp.MustCompile(`(?i)((?:REIMS_TOKEN|GITHUB_TOKEN|access_token|auth_token|token|"token")\s*[:=]\s*["']?)[A-Za-z0-9._~+/-]{16,}(["']?)`)
|
||||
)
|
||||
|
||||
// Line removes identifiers and credentials before one line is emitted or exported.
|
||||
// RedactLine removes identifiers and credentials before a line is emitted or exported.
|
||||
func RedactLine(line string) string {
|
||||
line = reLogMac.ReplaceAllString(line, "${1}[redacted]")
|
||||
line = reLogSerialKV.ReplaceAllString(line, "${1}[redacted]")
|
||||
@@ -26,7 +26,7 @@ func RedactLine(line string) string {
|
||||
return line
|
||||
}
|
||||
|
||||
// Text applies Line across a multi-line log or JSON text block.
|
||||
// RedactText applies RedactLine across a multi-line log or JSON text block.
|
||||
func RedactText(s string) string {
|
||||
lines := strings.Split(s, "\n")
|
||||
for i, line := range lines {
|
||||
|
||||
@@ -65,7 +65,7 @@ func sanitizeRawDetail(s string) string {
|
||||
// CodedError represents a user-facing error with a stable supportable error code
|
||||
// (e.g. "E_VM_CLONE_RUNNING"), a localized message key + named params, and an
|
||||
// optional redacted raw technical detail string for collapsible display and GitHub
|
||||
// Issue diagnostics (docs/design-guidelines.md §7.1, AGENTS.md Rule 3).
|
||||
// Issue diagnostics (see docs/design-guidelines.md and AGENTS.md).
|
||||
type CodedError struct {
|
||||
Locale Locale
|
||||
Code string
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
// retiredIDs are historical plugin IDs whose macOS state moves to ID.
|
||||
var retiredIDs = []string{LegacyInstallGuideID}
|
||||
|
||||
// MigrateState applies the v2 metadata migration in memory. Explicit values
|
||||
// already stored on the macOS plugin win, then explicit former core values,
|
||||
// then defaults. All records are changed together before one atomic save.
|
||||
// MigrateState moves retired plugin records and former core macOS settings to ID
|
||||
// in memory. Explicit values already stored on the macOS plugin win, then explicit
|
||||
// former core values, then defaults. All records are changed before one atomic save.
|
||||
func MigrateState(st *plugin.StateFile) bool {
|
||||
if st == nil {
|
||||
return false
|
||||
|
||||
@@ -69,9 +69,8 @@ func Dir(cfg *config.Config) string {
|
||||
return filepath.Join(cfg.XDGDataDir(), "reims-ctl", "installers")
|
||||
}
|
||||
|
||||
// Release is one offline installer Apple offers, as
|
||||
// `reims-util --json offline-installer list` reports it (measured 2026-11-28
|
||||
// with reims-util 0.1.0 from runtime 3731afd).
|
||||
// Release is one offline installer Apple offers, as reported by
|
||||
// `reims-util --json offline-installer list`.
|
||||
type Release struct {
|
||||
Product string `json:"product"`
|
||||
Title string `json:"title"` // "macOS Tahoe"
|
||||
|
||||
@@ -818,7 +818,6 @@ func layoutPanel(hwnd uintptr) {
|
||||
innerW := cardW - padX*2
|
||||
y := dp(dpi, 14)
|
||||
|
||||
// 1. Meta row: 20px .badge pill on left, quiet ghost "收起" optically flush right.
|
||||
if stageCtrl != 0 || foldCtrl != 0 {
|
||||
rowH := dp(dpi, 22)
|
||||
maxStageW := innerW
|
||||
@@ -842,7 +841,6 @@ func layoutPanel(hwnd uintptr) {
|
||||
y += rowH + dp(dpi, 10)
|
||||
}
|
||||
|
||||
// 2. Title (15px semibold, wraps up to 3 lines for long European / pseudo-localized headings).
|
||||
if titleCtrl != 0 {
|
||||
setCtrlFont(titleCtrl, fonts.title)
|
||||
tLineH := dp(dpi, 22)
|
||||
@@ -854,7 +852,6 @@ func layoutPanel(hwnd uintptr) {
|
||||
y += titleH + dp(dpi, 4)
|
||||
}
|
||||
|
||||
// 3. Body (13px, 20px line-height = 1.54x, measured to exact line count).
|
||||
if bodyCtrl != 0 {
|
||||
setCtrlFont(bodyCtrl, fonts.body)
|
||||
lineH := dp(dpi, 20)
|
||||
@@ -866,7 +863,6 @@ func layoutPanel(hwnd uintptr) {
|
||||
y += bodyH
|
||||
}
|
||||
|
||||
// 4. Monospace command / filename box (.cmd-line: 32px tall, r=8px).
|
||||
if codeCtrl != 0 {
|
||||
setCtrlFont(codeCtrl, fonts.code)
|
||||
y += dp(dpi, 12)
|
||||
@@ -875,7 +871,6 @@ func layoutPanel(hwnd uintptr) {
|
||||
y += codeH
|
||||
}
|
||||
|
||||
// 5. Input release hint (12px muted).
|
||||
if hintCtrl != 0 {
|
||||
setCtrlFont(hintCtrl, fonts.small)
|
||||
y += dp(dpi, 8)
|
||||
@@ -884,7 +879,6 @@ func layoutPanel(hwnd uintptr) {
|
||||
y += hintH
|
||||
}
|
||||
|
||||
// 6. Footer action buttons (31px tall .btn / .btn-primary / .btn-ghost, 8px gap).
|
||||
if leftCtrl != 0 || extraCtrl != 0 || rightCtrl != 0 {
|
||||
btnH := dp(dpi, 31)
|
||||
btnPadX := dp(dpi, 13)
|
||||
@@ -984,7 +978,6 @@ func layoutPanel(hwnd uintptr) {
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Full-width escape-hatch footer strip separated by a 1px --border hairline.
|
||||
if jumpCtrl != 0 {
|
||||
setCtrlFont(jumpCtrl, fonts.smallMed)
|
||||
y += dp(dpi, 14)
|
||||
|
||||
@@ -13,9 +13,9 @@ type activeGuide struct {
|
||||
cancel context.CancelFunc
|
||||
}
|
||||
|
||||
// Manager coordinates active VM-window installation guides for the lifetime of
|
||||
// the builtin.install-guide plugin. Calling Close cancels every active overlay
|
||||
// and prevents new ones from starting (zero-residue plugin disposal).
|
||||
// Manager coordinates active VM-window installation guides while the install
|
||||
// guide setting on builtin.guest.macos is enabled. Calling Close cancels every
|
||||
// active overlay and prevents new ones from starting.
|
||||
type Manager struct {
|
||||
mu sync.Mutex
|
||||
closed bool
|
||||
|
||||
@@ -209,9 +209,9 @@ func (c *Client) reconcileStaleGPUICD(ctx context.Context, name string, stderr i
|
||||
}
|
||||
|
||||
// StartWithCompat checks the configured Vulkan ICD before starting a VM and
|
||||
// automatically recovers once if QEMU aborts
|
||||
// with the WHPX nested-virtualization property error (hr=80370302) by writing
|
||||
// `-machine kernel-irqchip=off` via `reims-ctl set` (D3) and retrying start.
|
||||
// automatically recovers once if QEMU aborts with the WHPX nested-virtualization
|
||||
// property error (hr=80370302) by setting `-machine kernel-irqchip=off` via
|
||||
// `reims-ctl set` and retrying start.
|
||||
func (c *Client) StartWithCompat(ctx context.Context, name string, stdout, stderr io.Writer, onNote func(string)) error {
|
||||
if err := c.reconcileStaleGPUICD(ctx, name, stderr, onNote); err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
// Package vmstart holds what has to happen around `reims-ctl start` for both
|
||||
// the GUI and the CLI (docs/architecture.md principle 3): the commit-memory
|
||||
// check, VM preparation before QEMU launches, the macOS language preset and
|
||||
// P-core pinning afterwards.
|
||||
//
|
||||
// Two start steps stay in the GUI because they need a process that outlives
|
||||
// the start command: the Guest Tools bridge (guesttools_flow.go) and the Win10
|
||||
// cold-reboot watcher (app.go).
|
||||
// Package startprep runs macOS VM pre-launch checks and OpenCore/disk
|
||||
// preparation shared by the desktop window and direct CLI launches.
|
||||
package startprep
|
||||
|
||||
import (
|
||||
@@ -32,7 +26,7 @@ import (
|
||||
type Prep struct {
|
||||
Client *reims.Client
|
||||
Runtime rt.Installed
|
||||
// SkipWHPXFallback mirrors the core plugin's WHPX setting being off.
|
||||
// SkipWHPXFallback mirrors the whpx_fallback setting on builtin.guest.macos being off.
|
||||
SkipWHPXFallback bool
|
||||
cfg config.Config
|
||||
log func(string)
|
||||
@@ -67,9 +61,8 @@ func (p *Prep) CheckWHPX(rep host.Report) error {
|
||||
}
|
||||
}
|
||||
|
||||
// CheckMemory refuses to start a VM whose guest RAM can't be committed right
|
||||
// now. Without it QEMU exits with "Cannot set up guest memory 'ram'" (measured
|
||||
// 2026-11-28, portable-runtime-spec.md §5.1), which says nothing about what to do.
|
||||
// CheckMemory refuses to start a VM whose guest RAM cannot be committed right
|
||||
// now, avoiding QEMU's opaque "Cannot set up guest memory 'ram'" exit.
|
||||
func (p *Prep) CheckMemory(memory string, rep host.Report) error {
|
||||
avail, ok := host.CommitAvailGB()
|
||||
if !ok {
|
||||
|
||||
@@ -96,7 +96,7 @@ func TestValidateArgFragmentBlocksInjection(t *testing.T) {
|
||||
t.Errorf("ValidateArgFragment(%+v) unexpected error: %v", f, err)
|
||||
}
|
||||
}
|
||||
// External (non-builtin) plugin must be rejected from file/socket options (M1).
|
||||
// External (non-builtin) plugin must be rejected from file/socket options.
|
||||
if err := ValidateArgFragment(ArgFragment{Tokens: []string{"-drive", "file=secret.img"}}); err == nil {
|
||||
t.Error("expected external -drive to be rejected")
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Package builtin registers compiled-in Reims-Go extensions onto the unified
|
||||
// plugin Registry (docs/plugin-architecture.md §3.2, §5.4). Every builtin
|
||||
// plugin Registry (see docs/plugin-architecture.md). Every builtin
|
||||
// runs through the same reversible Scope, service dependency graph and HookBus
|
||||
// as external plugins. The core (core.go) is always on; disabling any optional
|
||||
// extension leaves zero residue.
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/Nwflower/reims-go/internal/version"
|
||||
)
|
||||
|
||||
// Builtin plugin IDs (§3.2, §5.4). IDCore lives in core.go.
|
||||
// Builtin plugin IDs. IDCore lives in core.go.
|
||||
const (
|
||||
// IDThemeDefault is the default theme's contribution ID; the core plugin
|
||||
// contributes it.
|
||||
@@ -287,7 +287,7 @@ func defClipboard(ver string, cb HostCallbacks, desiredFn func(string, bool) boo
|
||||
Title: plugin.LocalizedText{ZhCN: "剪贴板同步统计", EnUS: "Clipboard Sync Counters"},
|
||||
}, func(_ context.Context, _ string) (plugin.DiagnosticsEntry, error) {
|
||||
stats := srv.ClipboardDiagnostics()
|
||||
// Privacy rule (§5.4): record counters and errors only, NEVER clipboard content.
|
||||
// Privacy rule: record counters and errors only, never clipboard content.
|
||||
return plugin.DiagnosticsEntry{
|
||||
PluginID: IDClipboard,
|
||||
Title: "Clipboard Sync Counters",
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Contract catalogs (docs/plugin-architecture.md §4.2, §5.1, §5.6, §6.3).
|
||||
// Contract catalogs (see docs/plugin-architecture.md).
|
||||
//
|
||||
// Every public contract entry is either stable or experimental. Stable entries
|
||||
// are implemented by the host and covered by the compatibility promise;
|
||||
@@ -89,7 +89,7 @@ func anchorSlot(status ContractStatus, max int, extra map[string]ContractStatus)
|
||||
return SlotSpec{Status: status, Max: max, Accepts: accepts}
|
||||
}
|
||||
|
||||
// UISlotCatalog is the slot directory of §5.1.
|
||||
// UISlotCatalog lists every supported UI slot and accepted contribution kinds.
|
||||
var UISlotCatalog = map[string]SlotSpec{
|
||||
"sidebar.footer": anchorSlot(ContractStable, 2, map[string]ContractStatus{SlotPanel: ContractExperimental}),
|
||||
"statusbar.right": anchorSlot(ContractStable, 4, map[string]ContractStatus{SlotStatusItem: ContractExperimental}),
|
||||
@@ -116,7 +116,7 @@ type ViewLocationSpec struct {
|
||||
PerPlugin int // views one plugin may declare at this location
|
||||
}
|
||||
|
||||
// ViewLocationCatalog lists `views[].location` values (§5.6).
|
||||
// ViewLocationCatalog lists `views[].location` values.
|
||||
var ViewLocationCatalog = map[string]ViewLocationSpec{
|
||||
"sidebar": {Status: ContractExperimental, PerPlugin: 2},
|
||||
"vm.tab": {Status: ContractExperimental, PerPlugin: 4},
|
||||
@@ -152,7 +152,7 @@ type BridgeMethodSpec struct {
|
||||
Permission string // "" = always allowed for the calling plugin's own data
|
||||
}
|
||||
|
||||
// BridgeMethodCatalog lists bridgeApi 1.0 methods (§5.6).
|
||||
// BridgeMethodCatalog lists bridgeApi 1.0 methods.
|
||||
var BridgeMethodCatalog = map[string]BridgeMethodSpec{
|
||||
"hello": {Status: ContractStable},
|
||||
"i18n.getBundle": {Status: ContractStable},
|
||||
@@ -209,7 +209,7 @@ func ResolveBridgeMethod(method string) (string, BridgeMethodSpec, bool) {
|
||||
}
|
||||
|
||||
// HostFeatures lists the stable host features advertised in the Sidecar and
|
||||
// bridge handshakes (§6.3), sorted. Plugins feature-detect with these instead
|
||||
// bridge handshakes, sorted. Plugins feature-detect with these instead
|
||||
// of comparing version numbers.
|
||||
func HostFeatures() []string {
|
||||
var out []string
|
||||
|
||||
@@ -265,8 +265,8 @@ func (b *HookBus) DispatchBeforeCreate(ctx context.Context, payload BeforeCreate
|
||||
|
||||
// DispatchBeforeStart runs vm.beforeStart (intercept). Builtin prep hooks run
|
||||
// synchronously on parent ctx without external timeouts so disk/OpenCore I/O
|
||||
// always completes before QEMU starts (B2). External plugin hooks share a 10s
|
||||
// chain budget with 2s per plugin (§4.3).
|
||||
// always completes before QEMU starts. External plugin hooks share a 10s
|
||||
// chain budget with 2s per plugin.
|
||||
func (b *HookBus) DispatchBeforeStart(ctx context.Context, payload BeforeStartPayload) ([]StartIntent, error) {
|
||||
subs := b.snapshot(EventVMBeforeStart)
|
||||
if len(subs) == 0 {
|
||||
@@ -303,7 +303,7 @@ func (b *HookBus) DispatchBeforeStart(ctx context.Context, payload BeforeStartPa
|
||||
break
|
||||
}
|
||||
// Never leak raw host paths, raw ExtraArgs (may contain MACs), or
|
||||
// sensitive HostFacts to external plugins (§1.2, M3).
|
||||
// sensitive HostFacts to external plugins.
|
||||
if !extPayloadInit {
|
||||
extPayload = redactBeforeStartPayload(payload)
|
||||
extPayloadInit = true
|
||||
@@ -327,7 +327,7 @@ func (b *HookBus) DispatchBeforeStart(ctx context.Context, payload BeforeStartPa
|
||||
continue
|
||||
}
|
||||
intent.PluginID = hr.PluginID
|
||||
// Enforce vm:intent permission for external plugins producing start intents (§7.1, M2).
|
||||
// Enforce vm:intent permission for external plugins producing start intents.
|
||||
if !hr.Builtin && b.reg != nil && (len(intent.Args) > 0 || len(intent.Env) > 0 || len(intent.PostStart) > 0 || intent.BlockReason != "") {
|
||||
if !b.reg.PluginHasPermission(hr.PluginID, "vm:intent") {
|
||||
continue
|
||||
@@ -360,7 +360,7 @@ func (b *HookBus) DispatchObserve(event string, payload VMEventPayload) {
|
||||
}
|
||||
|
||||
// EmitLogLine queues a log line for batched log.onLine delivery. When no
|
||||
// subscribers exist, this is a single atomic load (zero allocation, §8.1).
|
||||
// subscribers exist, this is a single atomic load without allocation.
|
||||
// Under backpressure, lines are dropped silently so logging is never blocked.
|
||||
func (b *HookBus) EmitLogLine(vmName, source, line string) {
|
||||
if b.logSubCount.Load() <= 0 {
|
||||
@@ -375,7 +375,7 @@ func (b *HookBus) EmitLogLine(vmName, source, line string) {
|
||||
select {
|
||||
case ch <- LogLineEvent{VMName: vmName, Source: source, Line: line}:
|
||||
default:
|
||||
// Backpressure: drop without blocking VM log pipeline (§4.3).
|
||||
// Backpressure: drop without blocking VM log pipeline.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ func (b *HookBus) runLogBatcher(ch <-chan LogLineEvent) {
|
||||
}
|
||||
|
||||
// redactBeforeStartPayload removes host paths, raw ExtraArgs, and sensitive
|
||||
// keys before handing a BeforeStartPayload to any external plugin (§1.2, M3).
|
||||
// keys before handing a BeforeStartPayload to any external plugin.
|
||||
func redactBeforeStartPayload(p BeforeStartPayload) BeforeStartPayload {
|
||||
return BeforeStartPayload{
|
||||
VMName: p.VMName,
|
||||
|
||||
+11
-17
@@ -14,7 +14,7 @@ import (
|
||||
const ArgLedgerFileName = ".reims-go-arg-ledger.json"
|
||||
|
||||
// AllowedQEMUOptionFamilies lists the QEMU argument families external plugins
|
||||
// are allowed to contribute via StartIntent (§4.4, M1). File/socket/host-memory
|
||||
// are allowed to contribute via StartIntent. File/socket/host-memory
|
||||
// options (-drive, -chardev, -qmp, -fw_cfg, -object, -global) are restricted to
|
||||
// compiled-in builtins via BuiltinOnlyQEMUOptionFamilies.
|
||||
var AllowedQEMUOptionFamilies = map[string]bool{
|
||||
@@ -30,7 +30,7 @@ var AllowedQEMUOptionFamilies = map[string]bool{
|
||||
}
|
||||
|
||||
// BuiltinOnlyQEMUOptionFamilies lists QEMU option families permitted ONLY for
|
||||
// compiled-in builtins (M1).
|
||||
// compiled-in builtins.
|
||||
var BuiltinOnlyQEMUOptionFamilies = map[string]bool{
|
||||
"-drive": true,
|
||||
"-chardev": true,
|
||||
@@ -41,7 +41,7 @@ var BuiltinOnlyQEMUOptionFamilies = map[string]bool{
|
||||
}
|
||||
|
||||
// AllowedHostEnvVars lists non-namespaced environment variables permitted in
|
||||
// builtin/plugin StartIntents (§4.4).
|
||||
// builtin/plugin StartIntents.
|
||||
var AllowedHostEnvVars = map[string]bool{
|
||||
"REIMS_GO_INPUT_URL": true,
|
||||
"REIMS_GO_INPUT_TOKEN": true,
|
||||
@@ -67,7 +67,7 @@ type PostStartAction struct {
|
||||
Params map[string]any `json:"params,omitempty"`
|
||||
}
|
||||
|
||||
// StartIntent is the structured output of a vm.beforeStart hook (§4.4).
|
||||
// StartIntent is the structured output of a vm.beforeStart hook.
|
||||
// Plugins never call `reims-ctl` directly; they return intents merged by host.
|
||||
type StartIntent struct {
|
||||
PluginID string `json:"plugin_id"`
|
||||
@@ -152,7 +152,7 @@ func (l *ArgLedger) MoveOwnerKeys(from, to string, keys []string) bool {
|
||||
|
||||
// ArgLedger persists plugin-owned QEMU arg fragments in a VM directory so that
|
||||
// disabling/uninstalling a plugin strips its exact fragments while NEVER
|
||||
// touching unowned user `--extra-args` (§4.4).
|
||||
// touching unowned user `--extra-args`.
|
||||
type ArgLedger struct {
|
||||
Version int `json:"version"`
|
||||
Owners map[string][]ArgFragment `json:"owners"` // pluginID -> fragments
|
||||
@@ -234,7 +234,7 @@ type ReconcileResult struct {
|
||||
}
|
||||
|
||||
// validateSingleShellToken ensures a fragment token cannot split into multiple
|
||||
// QEMU arguments when joined with spaces (blocking whitespace/quote injection, B4).
|
||||
// QEMU arguments when joined with spaces (blocking whitespace/quote injection).
|
||||
func validateSingleShellToken(tok string) error {
|
||||
if tok == "" {
|
||||
return errors.New("empty QEMU argument token")
|
||||
@@ -284,7 +284,7 @@ func validateSingleShellToken(tok string) error {
|
||||
}
|
||||
|
||||
// ValidateArgFragment checks that every token is a single shell-safe token and
|
||||
// every flag belongs to the host allowlist (B4, §4.4).
|
||||
// every flag belongs to the host allowlist.
|
||||
func ValidateArgFragment(frag ArgFragment) error {
|
||||
if len(frag.Tokens) == 0 {
|
||||
return nil
|
||||
@@ -381,7 +381,7 @@ func validateBuiltinSMBIOSType17(val string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateEnvKey checks whether pluginID is allowed to set envKey (§4.4).
|
||||
// ValidateEnvKey checks whether pluginID is allowed to set envKey.
|
||||
// Shared host env vars (e.g. VK_ICD_FILENAMES, REIMS_GO_INPUT_*) are restricted
|
||||
// to built-in plugins; external plugins may only set their own REIMS_PLUGIN_<ID>_* namespace.
|
||||
func ValidateEnvKey(pluginID, envKey string) bool {
|
||||
@@ -435,11 +435,8 @@ func reconcileStartIntents(currentExtraArgs string, ledger *ArgLedger, activePlu
|
||||
ledger.Owners = map[string][]ArgFragment{}
|
||||
}
|
||||
|
||||
// 1. Extract user-owned (unmanaged) tokens by stripping all previously
|
||||
// recorded ledger fragments from currentExtraArgs.
|
||||
userTokens := stripOwnedTokens(SplitShellTokens(currentExtraArgs), ledger)
|
||||
|
||||
// 2. Drop ledger entries for plugins that are no longer active.
|
||||
if activePlugins != nil {
|
||||
for pid := range ledger.Owners {
|
||||
if !activePlugins[pid] {
|
||||
@@ -535,7 +532,7 @@ func reconcileStartIntents(currentExtraArgs string, ledger *ArgLedger, activePlu
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Arbitrate conflicts across plugins for the same logical key (builtin or higher priority wins).
|
||||
// Arbitrate conflicts across plugins for the same logical key (builtin or higher priority wins).
|
||||
pluginIDs := make([]string, 0, len(newOwners))
|
||||
for pid := range newOwners {
|
||||
pluginIDs = append(pluginIDs, pid)
|
||||
@@ -554,7 +551,6 @@ func reconcileStartIntents(currentExtraArgs string, ledger *ArgLedger, activePlu
|
||||
byKey[frag.Key] = winner{frag: frag}
|
||||
continue
|
||||
}
|
||||
// Conflict!
|
||||
if fragWins(frag, prev.frag) {
|
||||
res.Warnings = append(res.Warnings, fmt.Sprintf("QEMU option conflict on %q: %s overrode %s", frag.Key, frag.PluginID, prev.frag.PluginID))
|
||||
byKey[frag.Key] = winner{frag: frag}
|
||||
@@ -564,7 +560,6 @@ func reconcileStartIntents(currentExtraArgs string, ledger *ArgLedger, activePlu
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild ledger.Owners with winning fragments only.
|
||||
ledger.Owners = make(map[string][]ArgFragment)
|
||||
keys := make([]string, 0, len(byKey))
|
||||
for k := range byKey {
|
||||
@@ -583,7 +578,6 @@ func reconcileStartIntents(currentExtraArgs string, ledger *ArgLedger, activePlu
|
||||
finalTokens = append(finalTokens, f.Tokens...)
|
||||
}
|
||||
|
||||
// Format env slice deterministically.
|
||||
if len(envMap) > 0 {
|
||||
envKeys := make([]string, 0, len(envMap))
|
||||
for k := range envMap {
|
||||
@@ -640,8 +634,8 @@ func stripOwnedTokens(tokens []string, ledger *ArgLedger) []string {
|
||||
return tokens
|
||||
}
|
||||
// Match longest sequences first so composite fragments don't partially match.
|
||||
// Remove AT MOST ONE occurrence per recorded fragment so a user's hand-written
|
||||
// duplicate flag (e.g. `-no-reboot`) is preserved (M13).
|
||||
// Remove at most one occurrence per recorded fragment so a user's hand-written
|
||||
// duplicate flag (e.g. `-no-reboot`) is preserved.
|
||||
sort.Slice(seqs, func(i, j int) bool {
|
||||
return len(seqs[i]) > len(seqs[j])
|
||||
})
|
||||
|
||||
@@ -693,14 +693,14 @@ func (m *Manager) Disable(ctx context.Context, id string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// MarkBootComplete clears the plugin startup crash sentinel AFTER Reconcile
|
||||
// has activated plugins cleanly (M8, §9).
|
||||
// MarkBootComplete clears the plugin startup crash sentinel after Reconcile
|
||||
// has activated plugins cleanly.
|
||||
func (m *Manager) MarkBootComplete() {
|
||||
EndStartupInit(m.layout.Root)
|
||||
}
|
||||
|
||||
// Remove uninstalls a removable external plugin (refusing builtins/bundled or in-use plugins).
|
||||
// Also allows removing orphaned/failed records present only in state.json (M8).
|
||||
// Also allows removing orphaned/failed records present only in state.json.
|
||||
func (m *Manager) Remove(ctx context.Context, id string, purgeData bool) error {
|
||||
if info, ok := m.registry.Info(id); ok {
|
||||
if !info.Removable {
|
||||
|
||||
@@ -548,13 +548,9 @@ func currentPlatformTag() string {
|
||||
return runtime.GOOS + "-" + arch
|
||||
}
|
||||
|
||||
// InstallArchive transactionally verifies and installs a plugin .zip package (§9):
|
||||
// 1. Extract into plugins/tmp/<stage> (rejecting zip-slip and market redline files)
|
||||
// 2. Parse & validate plugin.json (engines, platforms, permissions, id/version anti-swap)
|
||||
// 3. Verify SHA256SUMS covers every extracted file with matching hashes
|
||||
// 4. Verify optional ed25519 signature over SHA256SUMS to derive TrustLevel
|
||||
// 5. Atomically rename stage dir into plugins/pkgs/<id>/<version>
|
||||
// Any error removes stage dir and leaves existing pkgs/ and state.json untouched.
|
||||
// InstallArchive transactionally validates, verifies checksums/signatures, and
|
||||
// atomically installs a plugin .zip archive into plugins/pkgs/<id>/<version>.
|
||||
// Any failure removes the staging directory without altering existing state.
|
||||
func InstallArchive(layout PluginsLayout, archivePath string, opts PackageInstallOptions) (*InstalledPackage, error) {
|
||||
if err := os.MkdirAll(layout.TmpDir(), 0o755); err != nil {
|
||||
return nil, err
|
||||
@@ -573,7 +569,6 @@ func InstallArchive(layout PluginsLayout, archivePath string, opts PackageInstal
|
||||
if err := extractPluginZip(archivePath, stageDir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Enforce market redlines on extracted content.
|
||||
if err := checkMarketRedlines(stageDir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -597,7 +592,6 @@ func InstallArchive(layout PluginsLayout, archivePath string, opts PackageInstal
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Verify SHA256SUMS.
|
||||
sumsPath := filepath.Join(stageDir, "SHA256SUMS")
|
||||
sumsRaw, err := os.ReadFile(sumsPath)
|
||||
if err != nil {
|
||||
@@ -607,7 +601,6 @@ func InstallArchive(layout PluginsLayout, archivePath string, opts PackageInstal
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Verify optional ed25519 signature over SHA256SUMS.
|
||||
trust := TrustCommunity
|
||||
sigPath := filepath.Join(stageDir, "SHA256SUMS.sig")
|
||||
if sigRaw, sigErr := os.ReadFile(sigPath); sigErr == nil {
|
||||
@@ -672,7 +665,7 @@ func InstallArchive(layout PluginsLayout, archivePath string, opts PackageInstal
|
||||
return nil, fmt.Errorf("plugin package blocked by static security gate: %s", strings.Join(reasons, "; "))
|
||||
}
|
||||
|
||||
// Atomic activation into pkgs/<id>/<version> with path-traversal guard (B3).
|
||||
// Atomically activate into pkgs/<id>/<version> after path-traversal validation.
|
||||
finalDir, err := safeJoin(layout.PkgsDir(), m.ID+"/"+m.Version)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid plugin install target: %w", err)
|
||||
|
||||
+13
-15
@@ -85,10 +85,10 @@ type RegisteredDownloader struct {
|
||||
Provider downloader.Provider
|
||||
}
|
||||
|
||||
// Registry is the single unified extension-point and lifecycle kernel for both
|
||||
// compiled-in builtins and external/bundled plugins (§3.1, §4.1, §4.2).
|
||||
// Registry is the unified extension-point and lifecycle kernel for both
|
||||
// compiled-in builtins and external/bundled plugins.
|
||||
type Registry struct {
|
||||
reconcileMu sync.Mutex // serializes Reconcile passes (M7)
|
||||
reconcileMu sync.Mutex // serializes Reconcile passes
|
||||
mu sync.RWMutex
|
||||
|
||||
entries map[string]*pluginEntry
|
||||
@@ -99,7 +99,7 @@ type Registry struct {
|
||||
logger func(source, line string)
|
||||
localeFn func() i18n.Locale
|
||||
|
||||
// Extension point tables (§4.2).
|
||||
// Extension point tables.
|
||||
themes map[string]ThemeContribution
|
||||
activeThemeID string
|
||||
uiScripts map[string]UIScriptContribution
|
||||
@@ -227,8 +227,8 @@ func (r *Registry) Register(def PluginDef) error {
|
||||
var oldScope *Scope
|
||||
r.mu.Lock()
|
||||
if existing, ok := r.entries[def.Manifest.ID]; ok {
|
||||
// If upgrading an already-active plugin, mark for reload by tearing down
|
||||
// the old scope so Reconcile activates the new definition cleanly (M7).
|
||||
// If upgrading an already-active plugin, tear down the old scope so
|
||||
// Reconcile activates the new definition cleanly.
|
||||
if existing.scope != nil && (existing.def.Manifest.Version != def.Manifest.Version || existing.def.InstallDir != def.InstallDir || existing.def.EntryHash != def.EntryHash) {
|
||||
oldScope = existing.scope
|
||||
existing.scope = nil
|
||||
@@ -299,7 +299,7 @@ func (r *Registry) SetDesired(ctx context.Context, id string, enabled bool) erro
|
||||
}
|
||||
e.def.Desired = enabled
|
||||
if enabled {
|
||||
// Allow retrying a previously failed plugin on explicit re-enable (M7).
|
||||
// Allow retrying a previously failed plugin on explicit re-enable.
|
||||
if e.state == StateFailed {
|
||||
e.state = StateOff
|
||||
}
|
||||
@@ -322,7 +322,7 @@ func (r *Registry) checkNotInUse(id string) error {
|
||||
}
|
||||
inUse, reason, err := checker(id)
|
||||
if err != nil {
|
||||
// Fail-closed per §4.1: query failure treated as in-use.
|
||||
// Fail-closed: query failure is treated as in-use.
|
||||
return fmt.Errorf("cannot verify whether plugin %q is in use (treated as in use): %w", id, err)
|
||||
}
|
||||
if inUse {
|
||||
@@ -356,7 +356,7 @@ func (r *Registry) checkNotBusy(id string) error {
|
||||
}
|
||||
|
||||
// Reconcile brings active plugins into convergence with desired state and
|
||||
// service dependency graph using close-then-open fixed-point iteration (§4.1).
|
||||
// service dependency graph using close-then-open fixed-point iteration.
|
||||
func (r *Registry) Reconcile(ctx context.Context) {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
@@ -364,9 +364,8 @@ func (r *Registry) Reconcile(ctx context.Context) {
|
||||
r.reconcileMu.Lock()
|
||||
defer r.reconcileMu.Unlock()
|
||||
|
||||
// Phase 1: Close-first fixed point.
|
||||
// Dispose leaves first (plugins that no other active plugin depends on) so
|
||||
// dependent consumers always unload BEFORE their service providers (M7, §4.1).
|
||||
// dependent consumers always unload before their service providers.
|
||||
for {
|
||||
var toDispose []*pluginEntry
|
||||
r.mu.RLock()
|
||||
@@ -410,7 +409,6 @@ func (r *Registry) Reconcile(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 2: Open-next fixed point.
|
||||
// Activate desired plugins whose pluginApi and required services are satisfied.
|
||||
for {
|
||||
var candidates []*pluginEntry
|
||||
@@ -616,7 +614,7 @@ func (r *Registry) registerManifestContributions(sc *Scope, m Manifest) {
|
||||
rules := append([]RuleHook(nil), m.Contributes.RuleHooks...)
|
||||
r.registerRuleHooks(sc, pid, rules)
|
||||
}
|
||||
// Register declarative services declared in external Manifest.Provides (M7).
|
||||
// Register declarative services declared in external Manifest.Provides.
|
||||
for _, pr := range m.Provides {
|
||||
if pr.Service == "" {
|
||||
continue
|
||||
@@ -631,7 +629,7 @@ func (r *Registry) registerManifestContributions(sc *Scope, m Manifest) {
|
||||
}
|
||||
}
|
||||
|
||||
// PluginHasPermission reports whether pluginID declares perm (M2).
|
||||
// PluginHasPermission reports whether pluginID declares perm.
|
||||
func (r *Registry) PluginHasPermission(pluginID, perm string) bool {
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
@@ -647,7 +645,7 @@ func (r *Registry) PluginHasPermission(pluginID, perm string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// MarkDegraded marks an active plugin as degraded with a reason (§4.3).
|
||||
// MarkDegraded marks an active plugin as degraded with a reason.
|
||||
func (r *Registry) MarkDegraded(pluginID, reason string) {
|
||||
r.mu.Lock()
|
||||
if e, ok := r.entries[pluginID]; ok && (e.state == StateActive || e.state == StateDegraded) {
|
||||
|
||||
@@ -211,7 +211,7 @@ func (c *RPCConn) readLoop() {
|
||||
}
|
||||
if env.Method != "" {
|
||||
// Bounded inbound concurrency so a misbehaving sidecar cannot spawn
|
||||
// unbounded goroutines in the host (M10).
|
||||
// unbounded goroutines in the host.
|
||||
select {
|
||||
case c.inboundSem <- struct{}{}:
|
||||
go func(e rpcEnvelope) {
|
||||
|
||||
@@ -337,7 +337,6 @@ func ScanDirectory(dir, hostVersion string, opts ScanOptions) ScanReport {
|
||||
lowName := strings.ToLower(info.Name())
|
||||
ext := strings.ToLower(filepath.Ext(lowName))
|
||||
|
||||
// 1. Market redlines (Apple proprietary files & SMC OSK literals).
|
||||
for _, pat := range ForbiddenMarketPatterns {
|
||||
if strings.Contains(lowName, pat) {
|
||||
addHard("redline", rel, fmt.Sprintf("forbidden proprietary file detected (%s)", rel),
|
||||
@@ -355,7 +354,6 @@ func ScanDirectory(dir, hostVersion string, opts ScanOptions) ScanReport {
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Executable / script extension inventory & hard-ban.
|
||||
if ForbiddenBinaryExtensions[ext] {
|
||||
sum, _ := fileSHA256Hex(full)
|
||||
declared := false
|
||||
@@ -393,7 +391,6 @@ func ScanDirectory(dir, hostVersion string, opts ScanOptions) ScanReport {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. SVG active-content scan across the entire package.
|
||||
if ext == ".svg" && info.Size() <= maxScanTextBytes {
|
||||
if b, rErr := os.ReadFile(full); rErr == nil {
|
||||
if reason := scanSVGActiveContent(string(b)); reason != "" {
|
||||
@@ -404,7 +401,6 @@ func ScanDirectory(dir, hostVersion string, opts ScanOptions) ScanReport {
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Extra CSS files outside declared theme stylesheets & sandboxed panelDir.
|
||||
if ext == ".css" && !declaredThemeCSS[rel] && !inRelDir(rel, declaredPanelDir) && info.Size() <= maxScanTextBytes {
|
||||
if b, rErr := os.ReadFile(full); rErr == nil {
|
||||
if err := ValidateThemeCSSSafetyInDir(string(b), filepath.Dir(full)); err != nil {
|
||||
@@ -415,7 +411,6 @@ func ScanDirectory(dir, hostVersion string, opts ScanOptions) ScanReport {
|
||||
}
|
||||
}
|
||||
|
||||
// 5. JS / MJS / HTML script static scan.
|
||||
if (ext == ".js" || ext == ".mjs" || ext == ".cjs") && info.Size() <= maxScanTextBytes {
|
||||
if b, rErr := os.ReadFile(full); rErr == nil {
|
||||
hits, hasNet := scanScriptContent(string(b), false)
|
||||
@@ -448,7 +443,6 @@ func ScanDirectory(dir, hostVersion string, opts ScanOptions) ScanReport {
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Checksums & optional ed25519 signature.
|
||||
sumsPath := filepath.Join(dir, "SHA256SUMS")
|
||||
if sumsRaw, sErr := os.ReadFile(sumsPath); sErr == nil {
|
||||
if err := verifyDirSHA256Sums(dir, sumsRaw); err != nil {
|
||||
|
||||
@@ -114,7 +114,7 @@ func (s *SidecarSupervisor) EnsureStarted(ctx context.Context) error {
|
||||
inst, caps, err := s.spawnInstance(ctx)
|
||||
if err != nil {
|
||||
// Count start/handshake failures toward circuit breaker so broken sidecars
|
||||
// don't spin infinitely on every hook call (M10).
|
||||
// don't spin infinitely on every hook call.
|
||||
s.mu.Lock()
|
||||
if !s.stopped {
|
||||
s.crashCount++
|
||||
@@ -208,7 +208,7 @@ func (s *SidecarSupervisor) spawnInstance(ctx context.Context) (*sidecarInstance
|
||||
}
|
||||
|
||||
// Collect stderr into rotated plugin audit log using bufio.Reader so lines
|
||||
// >64 KiB are truncated and drained instead of wedging the pipe (M10, §8).
|
||||
// >64 KiB are truncated and drained instead of wedging the pipe.
|
||||
go func() {
|
||||
const maxLineBytes = 8 * 1024
|
||||
br := bufio.NewReaderSize(stderr, 16*1024)
|
||||
|
||||
@@ -23,7 +23,7 @@ var (
|
||||
|
||||
// ValidateThemeCSSSafety rejects unbalanced braces, unclosed strings/comments,
|
||||
// CSS-escaped url()/image-set()/expression() bypasses, remote @import, and
|
||||
// external or unsafe data: URLs (§5.1, B5).
|
||||
// external or unsafe data: URLs.
|
||||
func ValidateThemeCSSSafety(css string) error {
|
||||
return ValidateThemeCSSSafetyInDir(css, "")
|
||||
}
|
||||
@@ -386,7 +386,7 @@ func validateCSSResourceURL(rawURL, rootDir string, isImport bool) error {
|
||||
}
|
||||
|
||||
// ValidateCSSTokenValue checks a single CSS custom property or seed value to
|
||||
// ensure it cannot break out of a declaration, close @layer, or load external URLs (B5).
|
||||
// ensure it cannot break out of a declaration, close @layer, or load external URLs.
|
||||
func ValidateCSSTokenValue(val string) error {
|
||||
if strings.ContainsAny(val, "\r\n\x00{};") || strings.HasSuffix(strings.TrimSpace(val), `\`) {
|
||||
return fmt.Errorf("CSS token value %q contains forbidden characters", val)
|
||||
@@ -404,7 +404,7 @@ func ValidateCSSTokenValue(val string) error {
|
||||
}
|
||||
|
||||
// ValidateThemeContribution validates all theme manifest fields (tokens, seeds,
|
||||
// fonts, background, and stylesheet) so untrusted strings cannot inject CSS (B5).
|
||||
// fonts, background, and stylesheet) so untrusted strings cannot inject CSS.
|
||||
func ValidateThemeContribution(th ThemeContribution, rootDir string) error {
|
||||
for k, v := range th.Tokens {
|
||||
if !reTokenKey.MatchString(k) {
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package runtime
|
||||
|
||||
// Online install reads runtime packages from the Reims vGPU fork's GitHub
|
||||
// Releases. A runtime release is tagged
|
||||
// "runtime-<commit>" and carries:
|
||||
//
|
||||
// reims-runtime-win-x64-<commit>.tar.zst
|
||||
// reims-runtime-src-<commit>.tar.zst (matching sources, spec §7)
|
||||
// SHA256SUMS.txt
|
||||
//
|
||||
// A GitHub prerelease is the alpha channel (built automatically from upstream
|
||||
// by CI); a full release is stable (promoted by a person after a real-host
|
||||
// smoke test, spec §6). The client lists stable only unless alpha is asked for.
|
||||
// Online install reads runtime packages tagged "runtime-<commit>" from the
|
||||
// Reims vGPU fork's GitHub Releases (archive, matching source archive, and
|
||||
// SHA256SUMS.txt). GitHub prereleases map to the alpha channel; full releases
|
||||
// map to the stable channel.
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -46,14 +39,12 @@ var errRateLimited = errors.New("GitHub API rate limit reached")
|
||||
const (
|
||||
ChannelStable = "stable"
|
||||
ChannelAlpha = "alpha"
|
||||
// channelLegacyCandidate is what the alpha channel was called before
|
||||
// 2026-11-28; configs and manifests written then still say it.
|
||||
// channelLegacyCandidate is the legacy alias for alpha stored in older configs and manifests.
|
||||
channelLegacyCandidate = "candidate"
|
||||
)
|
||||
|
||||
// NormalizeChannel maps a stored or user-given channel name to ChannelStable
|
||||
// or ChannelAlpha. The pre-2026-11-28 name "candidate" means alpha; anything
|
||||
// else (including "") means stable.
|
||||
// or ChannelAlpha ("candidate" maps to alpha; empty or unknown maps to stable).
|
||||
func NormalizeChannel(s string) string {
|
||||
switch strings.ToLower(strings.TrimSpace(s)) {
|
||||
case ChannelAlpha, channelLegacyCandidate:
|
||||
|
||||
@@ -36,8 +36,7 @@ type Manifest struct {
|
||||
RawBytes ByteCount `json:"raw_bytes"`
|
||||
SHA256 map[string]string `json:"sha256"`
|
||||
|
||||
// Schema 2 (docs/portable-runtime-spec.md §3.1, §5, §7): what the package
|
||||
// was really built from. A package with patches is not "pure upstream".
|
||||
// Schema 2 provenance fields: upstream commits, applied patches, build channel, and source archive.
|
||||
VendorQemuCommit string `json:"vendor_qemu_commit,omitempty"`
|
||||
UtilCommit string `json:"util_commit,omitempty"`
|
||||
MetalCommit string `json:"metal2vulkan_commit,omitempty"`
|
||||
@@ -45,7 +44,7 @@ type Manifest struct {
|
||||
Channel string `json:"channel,omitempty"` // channel at build time: alpha (older packages: candidate)
|
||||
SourcePackage string `json:"source_package,omitempty"` // file name of the matching source archive
|
||||
|
||||
// Schema 2+ plugin runtime extensions (docs/plugin-architecture.md §5.2).
|
||||
// Schema 2+ plugin runtime extensions.
|
||||
Kind string `json:"kind,omitempty"` // defaults to "reims-vgpu"
|
||||
RuntimeAPI string `json:"runtime_api,omitempty"` // CLI/driver contract version, e.g. "1.0.0"
|
||||
Capabilities []string `json:"capabilities,omitempty"` // explicit feature/patch capability IDs
|
||||
@@ -54,8 +53,8 @@ type Manifest struct {
|
||||
Origin string `json:"origin,omitempty"` // "official" | "third-party"
|
||||
}
|
||||
|
||||
// ByteCount is an integer that also accepts a whole-number float ("962466926.0"),
|
||||
// which PowerShell 7 wrote into manifests before pack-runtime.ps1 cast it.
|
||||
// ByteCount unmarshals integer byte counts as well as whole-number JSON floats
|
||||
// emitted by older PowerShell runtime packaging scripts.
|
||||
type ByteCount int64
|
||||
|
||||
func (b *ByteCount) UnmarshalJSON(data []byte) error {
|
||||
@@ -288,7 +287,7 @@ func samePath(a, b string) bool {
|
||||
return filepath.Clean(aa) == filepath.Clean(bb)
|
||||
}
|
||||
|
||||
// BuildChildEnv returns a clean, D-drive-isolated environment for invoking reims-ctl.
|
||||
// BuildChildEnv returns an environment isolated under cfg.DataRoot for invoking runtime tools.
|
||||
func BuildChildEnv(cfg *config.Config, rt Installed) []string {
|
||||
binDir := filepath.Join(rt.Dir, "bin")
|
||||
tmpDir := cfg.TempDir()
|
||||
@@ -430,7 +429,7 @@ func InstallFromArchive(cfg *config.Config, archivePath string) (*Installed, err
|
||||
}
|
||||
|
||||
// isSafeRuntimeSegment guards filepath.Join + os.RemoveAll against manifest
|
||||
// path traversal in kind or commit (M6).
|
||||
// path traversal in kind or commit.
|
||||
func isSafeRuntimeSegment(s string) bool {
|
||||
if len(s) == 0 || len(s) > 64 || strings.Contains(s, "..") {
|
||||
return false
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
// Package selfupdate swaps a downloaded Reims-Go executable in for the one
|
||||
// that is running, without a separate updater process.
|
||||
//
|
||||
// Windows won't overwrite a running .exe but will rename it, so Swap moves the
|
||||
// running file aside to "<exe>.old" and puts the new one at the target path
|
||||
// (Target: the original path, or the new release's file name when the running
|
||||
// file still has a release name); the running process keeps its mapped image.
|
||||
// The caller then launches the new file with --wait-pid, which waits for this
|
||||
// process to exit before the window takes the single-instance lock, and quits.
|
||||
// The next start removes the ".old" file (Cleanup).
|
||||
// Package selfupdate replaces the running Windows executable by renaming it to
|
||||
// "<exe>.old", moving the verified update into place, and relaunching with
|
||||
// --wait-pid so the new process waits before acquiring the single-instance lock.
|
||||
package selfupdate
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Package pluginsdk provides a lightweight, zero-dependency Go SDK for writing
|
||||
// external L3 Sidecar plugins (and guest VM drivers such as Linux) for Reims-Go.
|
||||
// Communication uses Content-Length framed JSON-RPC 2.0 over stdin/stdout while
|
||||
// diagnostics/logs write to stderr (docs/plugin-architecture.md §8, §12 Phase 3).
|
||||
// Package pluginsdk provides a zero-dependency Go SDK for external L3 Sidecar
|
||||
// plugins communicating via Content-Length framed JSON-RPC 2.0 over stdin/stdout
|
||||
// while writing diagnostics and logs to stderr.
|
||||
package pluginsdk
|
||||
|
||||
import (
|
||||
|
||||
@@ -148,7 +148,6 @@ $rawDir = Join-Path $OutDir 'raw'
|
||||
New-Item -ItemType Directory -Path $binDir -Force | Out-Null
|
||||
New-Item -ItemType Directory -Path $rawDir -Force | Out-Null
|
||||
|
||||
# 1. Build tools (darwin/amd64 guest-bench + local qmp-blockstats)
|
||||
Write-Host "[io-bench] Building guest-bench (darwin/amd64) and qmp-blockstats..."
|
||||
$guestBin = Join-Path $binDir 'guest-bench-darwin-amd64'
|
||||
$qmpBin = Join-Path $binDir 'qmp-blockstats.exe'
|
||||
@@ -175,7 +174,6 @@ try {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
# 2. Collect environment metadata (section 3.5)
|
||||
Write-Host "[io-bench] Collecting environment metadata..."
|
||||
$osInfo = Get-CimInstance Win32_OperatingSystem
|
||||
$cpuInfo = Get-CimInstance Win32_Processor | Select-Object -First 1
|
||||
@@ -232,14 +230,12 @@ $envMeta = [ordered]@{
|
||||
vm_toml = $vmTomlText
|
||||
}
|
||||
|
||||
# 3. Upload guest-bench and verify
|
||||
$remoteBin = '/tmp/reims-guest-bench'
|
||||
$remoteWorkDir = '$HOME/.reims-io-bench'
|
||||
Write-Host "[io-bench] Uploading guest-bench to ${SshUser}@${SshHost}:${SshPort}..."
|
||||
Invoke-ScpUpload -LocalPath $guestBin -RemotePath $remoteBin
|
||||
[void](Invoke-Ssh -RemoteCmd "chmod +x $remoteBin")
|
||||
|
||||
# 4. Enable QMP latency histograms
|
||||
Write-Host "[io-bench] Enabling QMP latency histogram on device '$Device'..."
|
||||
[void](& $qmpBin histogram -vm-dir $VmDir -device $Device)
|
||||
if ($LASTEXITCODE -ne 0) { throw "Failed to enable QMP latency histogram" }
|
||||
@@ -381,7 +377,6 @@ try {
|
||||
try { [void](& $qmpBin histogram -vm-dir $VmDir -device $Device -clear) } catch { Write-Warning "[io-bench] Failed to clear QMP histogram: $_" }
|
||||
}
|
||||
|
||||
# 5. Aggregate per workload
|
||||
$grouped = @{}
|
||||
foreach ($r in $allRuns) {
|
||||
$k = $r.workload
|
||||
|
||||
Reference in new issue
Block a user