Files
bare-operating-system/packages/bare-os-booter/lib/bare-os-protomux-extensions-proc.js
T
Raven Scott 64a1270d18 - disk.os: replication_operator_sketch schema 7 + corestoreSnapshotUxHint; wire corestore into bridge
- HRPC: bare_os.pkg_index_get, route table schema 3; pkg-swarm-index list/get; pathcap-verify --trusted
- POSIX: profile 1.0.17, ctx API 1.53.0, syscalls.json schema 11 + susv4Refs; JSON schemas + matrix/dashboard
- Feature bits: BARE_OS_KERNEL_FEATURE_BITS_DOC 16; contract + verify scripts; ctx.d.ts + gen helper sync
- Ops: BARE_OS_HOLEPUNCH_DRIFT_TIER1 + tier1Repos; mktemp avoids false XXX marker; /proc boot_budget_summary test list
- Docs: contract spine, env appendix, handbook, compatibility matrix, boot budget schema, vault threat model notes

Covers bare-os P2P roadmap items 1–20 where implemented in-tree; kernel/lib/bare/README left minimal per maintainer edit.
2026-04-05 15:52:59 -04:00

79 lines
2.5 KiB
JavaScript

/**
* `/proc/bare_os/protomux_extensions.json` — policy-gated operator view of Protomux
* channel hints for kernel extensions (no wire secrets).
*/
/**
* @param {Record<string, string | undefined>} env
*/
function protomuxExtensionsRegistryExposed(env) {
const v = String(env?.BARE_OS_PROC_PROTOMUX_EXTENSIONS_REGISTRY ?? '')
.trim()
.toLowerCase()
return v === '1' || v === 'true' || v === 'yes'
}
/**
* @param {{
* env?: Record<string, string | undefined> | null,
* registrySnapshot?: Record<string, unknown> | null,
* ctxApiVersion?: string
* }} opts
*/
export function buildBareOsProtomuxExtensionsProcJson(opts = {}) {
const env = opts.env && typeof opts.env === 'object' ? opts.env : {}
const now = Date.now()
if (!protomuxExtensionsRegistryExposed(env)) {
return {
schema: 1,
exposed: false,
note:
'Set BARE_OS_PROC_PROTOMUX_EXTENSIONS_REGISTRY=1 to expose extension mux hints (alias registry snapshot + stable logical channel names).',
atMs: now
}
}
const snap =
opts.registrySnapshot && typeof opts.registrySnapshot === 'object'
? opts.registrySnapshot
: {}
return {
schemaVersion: 4,
guestContractVersion: 1,
exposed: true,
ctxApiVersion: String(opts.ctxApiVersion || ''),
registry: snap,
muxWirePackage: 'protomux',
muxWireMajor: 3,
channelLifecycle: {
schema: 1,
states: ['paired', 'opening', 'open', 'closing', 'closed'],
backpressureEvent: 'bare-os:protomux-backpressure',
note:
'Guest-facing contract: logical channels follow Protomux createChannel/open/close; framed streams must preserve message boundaries (length-prefixed / secret-stream).'
},
holepunchCompanionPackages: {
rpcPool: 'protomux-rpc-client-pool',
note:
'Logical npm names in the Holepunch org; stock guest does not bundle them unless merged via ctx.bare.'
},
extensionLogicalChannels: [
{
name: 'bare-os-kernel-ext-handshake',
note: 'Reserved logical label for extension pairing over Protomux-framed streams (P2P).'
},
{
name: 'bare-os-extension-telemetry',
note: 'Optional NDJSON-shaped diagnostic channel; host must open explicitly.'
},
{
name: 'bare-os-cap-v1',
protocol: 'bare-os-cap-v1',
envGate: 'BARE_OS_PROTOMUX_CAP_CHANNEL',
note: 'Opaque buffer side channel; application-layer auth required.'
}
],
wireReference: '/proc/bare_os/protomux.json',
atMs: now
}
}