191 lines
6.3 KiB
JavaScript
191 lines
6.3 KiB
JavaScript
/**
|
|
* Capability word 8 optional `/proc/bare_os/*.json` payloads (env-injected; bounded, non-secret).
|
|
* @param {string} id
|
|
* @param {Record<string, string>} env
|
|
* @param {{
|
|
* protomuxWireCorrelate?: Record<string, unknown> | null
|
|
* seedProtomuxRpcPoolHint?: Record<string, unknown> | null
|
|
* }} [runtimeHints]
|
|
*/
|
|
export function buildBareOsBareRuntimeProtoMuxProcJson(id, env, runtimeHints) {
|
|
const now = Date.now()
|
|
const esc = (k) => String(env[k] ?? '').trim()
|
|
|
|
function parseJsonEnv(key) {
|
|
const raw = esc(key)
|
|
if (!raw) return null
|
|
try {
|
|
const o = JSON.parse(raw)
|
|
return o && typeof o === 'object' ? o : null
|
|
} catch {
|
|
return { schema: 1, error: 'invalid_json', key, atMs: now }
|
|
}
|
|
}
|
|
|
|
switch (id) {
|
|
case 'structured_clone_profile':
|
|
return {
|
|
schema: 1,
|
|
profile: parseJsonEnv('BARE_OS_STRUCTURED_CLONE_PROFILE_JSON'),
|
|
note: 'bare-structured-clone max depth / keys cap from host.',
|
|
atMs: now
|
|
}
|
|
case 'form_data_delegate_limits':
|
|
return {
|
|
schema: 1,
|
|
limits: parseJsonEnv('BARE_OS_FORM_DATA_DELEGATE_LIMITS_JSON'),
|
|
note: 'bare-form-data bounded field/file count hints.',
|
|
atMs: now
|
|
}
|
|
case 'hypercore_signing_status':
|
|
return {
|
|
schema: 1,
|
|
status: parseJsonEnv('BARE_OS_HYPERCORE_SIGNING_STATUS_JSON'),
|
|
note: 'hypercore-sign pointer-only signing enabled sketch.',
|
|
atMs: now
|
|
}
|
|
case 'brittle_snapshot_ci':
|
|
return {
|
|
schema: 1,
|
|
ci: parseJsonEnv('BARE_OS_BRITTLE_SNAPSHOT_CI_JSON'),
|
|
note: 'brittle-snapshot CI id pointer; non-secret.',
|
|
atMs: now
|
|
}
|
|
case 'bare_kit_bridge':
|
|
return {
|
|
schema: 1,
|
|
bridge: parseJsonEnv('BARE_OS_BARE_KIT_BRIDGE_JSON'),
|
|
note: 'bare-kit capability flags from env.',
|
|
atMs: now
|
|
}
|
|
case 'protomux_rpc_pool_health': {
|
|
const envHealth = parseJsonEnv('BARE_OS_PROTOMUX_RPC_POOL_HEALTH_JSON')
|
|
const seedHint =
|
|
runtimeHints?.seedProtomuxRpcPoolHint &&
|
|
typeof runtimeHints.seedProtomuxRpcPoolHint === 'object'
|
|
? runtimeHints.seedProtomuxRpcPoolHint
|
|
: null
|
|
return {
|
|
schema: 2,
|
|
health: envHealth,
|
|
seedProtomuxRpcPoolHintEcho: !envHealth ? seedHint : undefined,
|
|
protomuxWireCorrelate:
|
|
runtimeHints?.protomuxWireCorrelate &&
|
|
typeof runtimeHints.protomuxWireCorrelate === 'object'
|
|
? runtimeHints.protomuxWireCorrelate
|
|
: undefined,
|
|
replicationBackpressure: parseJsonEnv(
|
|
'BARE_OS_REPLICATION_BACKPRESSURE_JSON'
|
|
),
|
|
lastProtomuxBackpressureMs: (() => {
|
|
const raw = esc('BARE_OS_LAST_PROTOMUX_BACKPRESSURE_MS')
|
|
const n = Number.parseInt(raw, 10)
|
|
return Number.isFinite(n) ? n : null
|
|
})(),
|
|
note:
|
|
'Schema 2 correlates optional replication backpressure JSON with pool health; bareOsEmitProtomuxBackpressure stamps BARE_OS_LAST_PROTOMUX_BACKPRESSURE_MS. When health env is unset, seedProtomuxRpcPoolHintEcho mirrors the seeder RPC hint. protomuxWireCorrelate links live peer/backpressure/alias counts to protomux.json operatorMetrics.',
|
|
atMs: now
|
|
}
|
|
}
|
|
case 'http_dht_proxy_route':
|
|
return {
|
|
schema: 1,
|
|
route: parseJsonEnv('BARE_OS_HTTP_DHT_PROXY_ROUTE_JSON'),
|
|
note: 'http-dht-proxy route table summary (capped).',
|
|
atMs: now
|
|
}
|
|
case 'hypermininet_topology':
|
|
return {
|
|
schema: 1,
|
|
topology: parseJsonEnv('BARE_OS_HYPERMININET_TOPOLOGY_JSON'),
|
|
note: 'hypermininet doc-first test topology id.',
|
|
atMs: now
|
|
}
|
|
case 'oidc_publishing_pointer':
|
|
return {
|
|
schema: 1,
|
|
pointer: parseJsonEnv('BARE_OS_OIDC_PUBLISHING_POINTER_JSON'),
|
|
note: 'oidc-publishing URL pointer only; no tokens.',
|
|
atMs: now
|
|
}
|
|
case 'gip_transport_sketch':
|
|
return {
|
|
schema: 1,
|
|
sketch: parseJsonEnv('BARE_OS_GIP_TRANSPORT_SKETCH_JSON'),
|
|
note: 'gip-transport class enum sketch.',
|
|
atMs: now
|
|
}
|
|
case 'safe_sodium_buffer_policy':
|
|
return {
|
|
schema: 1,
|
|
policy: parseJsonEnv('BARE_OS_SAFE_SODIUM_BUFFER_POLICY_JSON'),
|
|
note: 'safe-sodium-buffer no raw key export policy ack.',
|
|
atMs: now
|
|
}
|
|
case 'react_native_bare_kit':
|
|
return {
|
|
schema: 1,
|
|
rn: parseJsonEnv('BARE_OS_REACT_NATIVE_BARE_KIT_JSON'),
|
|
note: 'react-native-bare-kit bridge presence flags.',
|
|
atMs: now
|
|
}
|
|
case 'cellery_sidecar_hint':
|
|
return {
|
|
schema: 1,
|
|
hint: parseJsonEnv('BARE_OS_CELLERY_SIDECAR_HINT_JSON'),
|
|
note: 'cellery sidecar pattern pointer (doc-heavy).',
|
|
atMs: now
|
|
}
|
|
case 'libmqjs_queue_depth':
|
|
return {
|
|
schema: 1,
|
|
depth: parseJsonEnv('BARE_OS_LIBMQJS_QUEUE_DEPTH_JSON'),
|
|
note: 'libmqjs bounded depth when host sets env.',
|
|
atMs: now
|
|
}
|
|
case 'pear_sidecar_bundle_index':
|
|
return {
|
|
schema: 1,
|
|
index: parseJsonEnv('BARE_OS_PEAR_SIDECAR_BUNDLE_INDEX_JSON'),
|
|
note: 'bare-sidecar-bundle manifest pointer list (capped).',
|
|
atMs: now
|
|
}
|
|
case 'rocksdb_pointer':
|
|
return {
|
|
schema: 1,
|
|
pointer: parseJsonEnv('BARE_OS_ROCKSDB_POINTER_JSON'),
|
|
note: 'rocksdb-native storage boundary pointer only.',
|
|
atMs: now
|
|
}
|
|
case 'sandbox_worker_queue':
|
|
return {
|
|
schema: 1,
|
|
queue: parseJsonEnv('BARE_OS_SANDBOX_WORKER_QUEUE_JSON'),
|
|
note: 'Sandbox worker queue depth when enabled.',
|
|
atMs: now
|
|
}
|
|
case 'hyper_multisig_trust_pointer':
|
|
return {
|
|
schema: 2,
|
|
trustGraphId: esc('BARE_OS_HYPER_MULTISIG_TRUST_GRAPH_ID').slice(
|
|
0,
|
|
256
|
|
),
|
|
pointer: parseJsonEnv('BARE_OS_HYPER_MULTISIG_TRUST_POINTER_JSON'),
|
|
vaultMultisigContinuity: parseJsonEnv(
|
|
'BARE_OS_VAULT_MULTISIG_CONTINUITY_JSON'
|
|
),
|
|
note:
|
|
'Schema 2: optional vaultMultisigContinuity from BARE_OS_VAULT_MULTISIG_CONTINUITY_JSON (operator continuity sketch; no secret keys). pear-multisig / hyper-multisig trust pointer unchanged.',
|
|
atMs: now
|
|
}
|
|
default:
|
|
return {
|
|
schema: 1,
|
|
error: 'unknown_wave8_proc_id',
|
|
id,
|
|
atMs: now
|
|
}
|
|
}
|
|
}
|