vendored Bare bundles and seeder parity; tighten the no-`node:` verifier and host-vs-image docs; expand syscall/proc JSON with POSIX XSH-style ops, errno hints, signals, and schema updates; add simulated FD table hooks, pathconf/getconf coverage, IPC message-queue surface, swarm/protomux pool metrics and HyperDHT stats env; extend systemctl verbs, cron TZ-aware matching, Pear updater and corestore snapshot hints, WASM instantiate behind a gate, and runBin default timeout merging with caller abort options. Bump BARE_OS_CTX_API_VERSION to 1.34.0 and BARE_OS_POSIX_PROFILE_VERSION to 1.0.1; sync declared profile, compliance matrix, handbook, example syscalls JSON, CHANGELOG, and generated ctx client helper; extend bare-os-ctx.d.ts for new ctx members.
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
/**
|
|
* Swarm session lifecycle labels for operators (non-authoritative; driven by env + peer count).
|
|
* @param {Record<string, unknown> | null | undefined} env
|
|
* @param {number} peerCount
|
|
*/
|
|
export function bareOsSwarmLifecycleSnapshot(env, peerCount) {
|
|
const peers = Math.max(0, Math.floor(peerCount))
|
|
const syncing =
|
|
env &&
|
|
(env.BARE_OS_SWARM_SYNCING === '1' || env.BARE_OS_SWARM_SYNCING === 'true')
|
|
const degraded =
|
|
env &&
|
|
(env.BARE_OS_SWARM_DEGRADED === '1' || env.BARE_OS_SWARM_DEGRADED === 'true')
|
|
/** @type {'discovering' | 'syncing' | 'steady' | 'degraded'} */
|
|
let state = 'steady'
|
|
if (degraded) state = 'degraded'
|
|
else if (syncing) state = 'syncing'
|
|
else if (peers === 0) state = 'discovering'
|
|
|
|
/** @type {number | undefined} */
|
|
let dhtActiveQueries
|
|
/** @type {number | undefined} */
|
|
let udxEphemeralPort
|
|
const raw = env && env.BARE_OS_HYPERDHT_STATS_JSON
|
|
if (raw != null && String(raw).trim()) {
|
|
try {
|
|
const j = JSON.parse(String(raw))
|
|
if (typeof j.activeQueries === 'number') dhtActiveQueries = j.activeQueries
|
|
if (typeof j.udpPort === 'number') udxEphemeralPort = j.udpPort
|
|
} catch {
|
|
/* ignore invalid operator JSON */
|
|
}
|
|
}
|
|
|
|
return {
|
|
schema: 1,
|
|
state,
|
|
peerCount: peers,
|
|
note:
|
|
'Lifecycle is derived from BARE_OS_SWARM_* env hints and live peer count; host may override via env.',
|
|
hyperdhtSketch: {
|
|
schema: 1,
|
|
note: 'Capped non-secret hints from BARE_OS_HYPERDHT_STATS_JSON when the host sets it.',
|
|
dhtActiveQueries,
|
|
udxEphemeralPort
|
|
},
|
|
atMs: Date.now()
|
|
}
|
|
}
|