Files
bare-operating-system/packages/bare-os-booter/lib/bare-os-swarm-lifecycle.js
T
Raven Scott 8f2e3cceb0 Move editable kernel bulk from kernel/init-main.js to kernel/lib/init/
(staged as /lib/init/init-main.js); point bundle-kernel-init and verify
scripts at the new path.

Wire curl, wget, openssl, ssh-keygen, and tar through coreutils and
booter host delegates with booter-side CLI helpers; refresh related
bins, bare manifest, shell completion, and man DB (kernel + seeder).

Add booter support modules for ACL evaluation, audit chain, secret
handles, peer admission, replication priority, process table, swarm
lifecycle, boot-graph proc, metrics, monotonic time, protomux alias
registry, and swarm peer policy; extend extension resolver, VFS,
swarm connection managers, IPC, identity-account, and initd.

Harden bare-os-bare-libs build on esbuild failure; add verify scripts
for extension manifest schema and runtime incomplete markers; extend
ctx API typings, gen-ctx-client-stub, and verify-ctx-dts.

Update boot hook fragment, bundled init.js, handbook and reference
docs (incl. kernel security and VFS path classes).
2026-04-04 17:51:47 -04:00

28 lines
942 B
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'
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.',
atMs: Date.now()
}
}