Updates
This commit is contained in:
@@ -10,7 +10,7 @@ Shared **wire format and constants** for the Bare operating system monorepo: Hyp
|
||||
| `topicKey()` | 32-byte topic for `swarm.join()` |
|
||||
| `BLOCK_SIZE`, `MBR_MAGIC` | 512-byte MBR, magic `BIOS` at offset 0 |
|
||||
| `buildMbr` / `parseMbr` | Pack/unpack primary + optional failover Hyperdrive keys |
|
||||
| `setupSeedChannel` | Wire Protomux messages 0–6 for RAM block reads, gossip stub, search, RPC stub, and `drive.replicate` |
|
||||
| `setupSeedChannel` | Wire Protomux messages 0–6 for RAM block reads, gossip bitfield, manifest path **search**, **RPC** (incl. `bare_os.capabilities` / `bare_os.gossip`), and `drive.replicate` |
|
||||
|
||||
Subpath exports: `bare-os-protocol/constants.js`, `bare-os-protocol/messages` (compact-encoding schemas), `bare-os-protocol/kernel-feature-bits.js` (documented booter capability bitmask; surfaced in **`/proc/bare_os_features`**).
|
||||
|
||||
|
||||
@@ -22,5 +22,15 @@ export {
|
||||
BARE_OS_FEATURE_IPC_DUPLEX,
|
||||
BARE_OS_FEATURE_VFS_UNION,
|
||||
BARE_OS_FEATURE_PROC_SWARM,
|
||||
BARE_OS_FEATURE_SHELL_STREAMING_PIPES,
|
||||
BARE_OS_FEATURE_SHELL_CMDSUBST,
|
||||
BARE_OS_FEATURE_SEED_CAP_RPC,
|
||||
BARE_OS_FEATURE_EXTENDED_PROC,
|
||||
BARE_OS_FEATURE_VIRTUAL_FILE_META,
|
||||
BARE_OS_FEATURE_VFS_UNION_WRITE_POLICY,
|
||||
BARE_OS_FEATURE_IPC_PER_CHANNEL,
|
||||
BARE_OS_FEATURE_SANDBOX_WORKER,
|
||||
BARE_OS_FEATURE_TELEMETRY_EXPORT,
|
||||
BARE_OS_FEATURE_BOOT_POLICY,
|
||||
BARE_OS_KERNEL_FEATURES_STOCK_V1
|
||||
} from './lib/kernel-feature-bits.js'
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import b4a from 'b4a'
|
||||
import c from 'compact-encoding'
|
||||
import { PROTOCOL_NAME } from '../constants.js'
|
||||
import {
|
||||
BARE_OS_KERNEL_FEATURE_BITS_DOC,
|
||||
BARE_OS_KERNEL_FEATURES_STOCK_V1
|
||||
} from './kernel-feature-bits.js'
|
||||
import {
|
||||
msgDataEncoding,
|
||||
msgSearchReqEncoding,
|
||||
@@ -10,12 +14,19 @@ import {
|
||||
} from './messages.js'
|
||||
|
||||
/**
|
||||
* Seeder-side Protomux channel: MBR block service + stub search/RPC + drive replication.
|
||||
* Seeder-side Protomux channel: MBR block service + manifest search + RPC + drive replication.
|
||||
* @param {import('protomux')} mux
|
||||
* @param {Map<number, Uint8Array>} localRAM
|
||||
* @param {(stream: any) => void} replicateDrive - e.g. (s) => drive.replicate(s)
|
||||
* @param {{ manifestPaths?: string[], searchMaxMatches?: number }} [opts]
|
||||
*/
|
||||
export function setupSeedChannel(mux, localRAM, replicateDrive) {
|
||||
export function setupSeedChannel(mux, localRAM, replicateDrive, opts = {}) {
|
||||
const manifestPaths = Array.isArray(opts.manifestPaths) ? opts.manifestPaths : []
|
||||
const searchMax =
|
||||
typeof opts.searchMaxMatches === 'number' && opts.searchMaxMatches > 0
|
||||
? Math.min(opts.searchMaxMatches, 2000)
|
||||
: 500
|
||||
|
||||
const chan = mux.createChannel({ protocol: PROTOCOL_NAME })
|
||||
|
||||
chan.addMessage({
|
||||
@@ -35,7 +46,17 @@ export function setupSeedChannel(mux, localRAM, replicateDrive) {
|
||||
chan.addMessage({
|
||||
encoding: msgSearchReqEncoding,
|
||||
onmessage(m) {
|
||||
chan.messages[4].send({ id: m.id, matches: [] })
|
||||
const q = (m.query || '').trim().toLowerCase()
|
||||
/** @type {string[]} */
|
||||
let matches = []
|
||||
if (!q) {
|
||||
matches = manifestPaths.slice(0, searchMax)
|
||||
} else {
|
||||
matches = manifestPaths
|
||||
.filter((p) => p.toLowerCase().includes(q))
|
||||
.slice(0, searchMax)
|
||||
}
|
||||
chan.messages[4].send({ id: m.id, matches })
|
||||
}
|
||||
})
|
||||
|
||||
@@ -77,13 +98,47 @@ export function setupSeedChannel(mux, localRAM, replicateDrive) {
|
||||
success: true,
|
||||
result: JSON.stringify({
|
||||
protocol: PROTOCOL_NAME,
|
||||
rpc: ['bare_os.version', 'bare_os.health', 'bare_os.kernel_info'],
|
||||
rpc: [
|
||||
'bare_os.version',
|
||||
'bare_os.health',
|
||||
'bare_os.kernel_info',
|
||||
'bare_os.capabilities',
|
||||
'bare_os.gossip'
|
||||
],
|
||||
note: 'Kernel and image semver are resolved at boot on the booter; this channel is seeder-local.'
|
||||
}),
|
||||
error: ''
|
||||
})
|
||||
return
|
||||
}
|
||||
if (m.module === 'bare_os' && m.method === 'capabilities') {
|
||||
chan.messages[6].send({
|
||||
id: m.id,
|
||||
success: true,
|
||||
result: JSON.stringify({
|
||||
doc: BARE_OS_KERNEL_FEATURE_BITS_DOC,
|
||||
bits: BARE_OS_KERNEL_FEATURES_STOCK_V1,
|
||||
role: 'seeder',
|
||||
protocol: PROTOCOL_NAME
|
||||
}),
|
||||
error: ''
|
||||
})
|
||||
return
|
||||
}
|
||||
if (m.module === 'bare_os' && m.method === 'gossip') {
|
||||
chan.messages[6].send({
|
||||
id: m.id,
|
||||
success: true,
|
||||
result: JSON.stringify({
|
||||
role: 'seeder',
|
||||
protocol: PROTOCOL_NAME,
|
||||
manifestPathCount: manifestPaths.length,
|
||||
atMs: Date.now()
|
||||
}),
|
||||
error: ''
|
||||
})
|
||||
return
|
||||
}
|
||||
chan.messages[6].send({
|
||||
id: m.id,
|
||||
success: false,
|
||||
|
||||
@@ -39,6 +39,36 @@ export const BARE_OS_FEATURE_VFS_UNION = 1 << 9
|
||||
/** Bit 10: Swarm snapshot proc (`/proc/bare_os_swarm`). */
|
||||
export const BARE_OS_FEATURE_PROC_SWARM = 1 << 10
|
||||
|
||||
/** Bit 11: Relaxed / multiplied pipeline capture limits (`BARE_OS_SHELL_STREAMING=1`). */
|
||||
export const BARE_OS_FEATURE_SHELL_STREAMING_PIPES = 1 << 11
|
||||
|
||||
/** Bit 12: Bounded command substitution `$(…)` (`BARE_OS_SHELL_CMDSUBST=1`). */
|
||||
export const BARE_OS_FEATURE_SHELL_CMDSUBST = 1 << 12
|
||||
|
||||
/** Bit 13: Seed-channel RPC capability query (`bare_os.capabilities` / handshake). */
|
||||
export const BARE_OS_FEATURE_SEED_CAP_RPC = 1 << 13
|
||||
|
||||
/** Bit 14: Extended synthetic `/proc` / `/sys` nodes (e.g. `/proc/self/fd`, `/sys/devices`). */
|
||||
export const BARE_OS_FEATURE_EXTENDED_PROC = 1 << 14
|
||||
|
||||
/** Bit 15: Virtual file registration metadata (`mime`, `ttlMs` on `bareOsRegisterVirtualFile`). */
|
||||
export const BARE_OS_FEATURE_VIRTUAL_FILE_META = 1 << 15
|
||||
|
||||
/** Bit 16: Union overlay write deny list (`BARE_OS_VFS_UNION_WRITE_DENY`). */
|
||||
export const BARE_OS_FEATURE_VFS_UNION_WRITE_POLICY = 1 << 16
|
||||
|
||||
/** Bit 17: IPC per-channel byte caps / optional JSON shape hints (`BARE_OS_IPC_CHANNEL_MAX_BYTES`). */
|
||||
export const BARE_OS_FEATURE_IPC_PER_CHANNEL = 1 << 17
|
||||
|
||||
/** Bit 18: Sandbox worker-thread path (`BARE_OS_SANDBOX_WORKER=1` + optional `bare-worker`). */
|
||||
export const BARE_OS_FEATURE_SANDBOX_WORKER = 1 << 18
|
||||
|
||||
/** Bit 19: Unified telemetry sink (`BARE_OS_TELEMETRY_NDJSON`). */
|
||||
export const BARE_OS_FEATURE_TELEMETRY_EXPORT = 1 << 19
|
||||
|
||||
/** Bit 20: Declarative boot policy file (`/etc/bare-os/boot.policy.json`). */
|
||||
export const BARE_OS_FEATURE_BOOT_POLICY = 1 << 20
|
||||
|
||||
/** Default bitmask implied by current stock booter. */
|
||||
export const BARE_OS_KERNEL_FEATURES_STOCK_V1 =
|
||||
BARE_OS_FEATURE_IPC_FANOUT |
|
||||
@@ -51,4 +81,14 @@ export const BARE_OS_KERNEL_FEATURES_STOCK_V1 =
|
||||
BARE_OS_FEATURE_BOOT_PHASE_HOOKS |
|
||||
BARE_OS_FEATURE_IPC_DUPLEX |
|
||||
BARE_OS_FEATURE_VFS_UNION |
|
||||
BARE_OS_FEATURE_PROC_SWARM
|
||||
BARE_OS_FEATURE_PROC_SWARM |
|
||||
BARE_OS_FEATURE_SHELL_STREAMING_PIPES |
|
||||
BARE_OS_FEATURE_SHELL_CMDSUBST |
|
||||
BARE_OS_FEATURE_SEED_CAP_RPC |
|
||||
BARE_OS_FEATURE_EXTENDED_PROC |
|
||||
BARE_OS_FEATURE_VIRTUAL_FILE_META |
|
||||
BARE_OS_FEATURE_VFS_UNION_WRITE_POLICY |
|
||||
BARE_OS_FEATURE_IPC_PER_CHANNEL |
|
||||
BARE_OS_FEATURE_SANDBOX_WORKER |
|
||||
BARE_OS_FEATURE_TELEMETRY_EXPORT |
|
||||
BARE_OS_FEATURE_BOOT_POLICY
|
||||
|
||||
Reference in New Issue
Block a user