Complete the internal “100 task” roadmap: coreutils and shell parity (xargs,

sh, diff/patch, sort, printf, find, test, getfacl/setfacl/xattr), expanded
/proc and metrics (process table, syscalls, replication, net, security
posture, worker budget, swarm/replication hints), initd DAG supervision
metadata and richer restart journal telemetry, synthetic process groups via
IPC (assignProcessGroup/signalProcessGroup) mirrored into process_table,
optional kernel.ext.d incremental hot reload (BARE_OS_KERNEL_EXT_D_HOT_RELOAD)
with reload audit NDJSON, features proc for hyperblobs dedup and systemd
subset documentation, vault threat model doc plus posture fields for AEAD,
Pear enclave pointer, account rotation continuity, and Ed25519 consistency
across boot manifest / extensions / replication. Adds or extends tests and
keeps kernel/ and packages/bare-os-seeder/kernel/ in parity; guest init is
bundled from kernel/lib/init/init-main.js via bundle-kernel-init.
This commit is contained in:
Raven Scott
2026-04-04 21:23:49 -04:00
parent c29ec13cf9
commit 346bb71ffe
177 changed files with 8087 additions and 876 deletions
@@ -0,0 +1,27 @@
/**
* CI smoke checks for awk/sed sources (POSIX-oriented coverage is partial by design).
*/
import { readFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import test from 'brittle'
const __dirname = dirname(fileURLToPath(import.meta.url))
const srcDir = join(__dirname, '../src')
test('sed.js exists and documents line-oriented operation', async (t) => {
const s = await readFile(join(srcDir, 'sed.js'), 'utf8')
t.ok(s.includes('async function run'))
t.ok(s.length > 200)
})
test('awk.js exists and wires field parsing', async (t) => {
const s = await readFile(join(srcDir, 'awk.js'), 'utf8')
t.ok(s.includes('async function run'))
t.ok(s.includes('field-separator') || s.includes('split'))
})
test('printf FORMAT octal escape helper is defined', async (t) => {
const s = await readFile(join(srcDir, 'printf.js'), 'utf8')
t.ok(s.includes('barePrintfUnescapeFormat'))
})
@@ -0,0 +1,156 @@
/**
* getfacl / setfacl / xattr against an in-memory vfs stub.
*/
import { readFile } from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import test from 'brittle'
import b4a from 'b4a'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
/**
* @param {string} name
*/
async function loadBin(name) {
const runtime = await readFile(
path.join(__dirname, '../lib/runtime.js'),
'utf8'
)
const body = await readFile(
path.join(__dirname, `../src/${name}.js`),
'utf8'
)
return new AsyncFunction(
'ctx',
'argv',
`${runtime}\n${body}\nif (typeof run === 'function') return await run(ctx, argv)\n`
)
}
function createCtx(store) {
const logs = []
const errs = []
return {
b4a,
exitCode: 0,
shellStdin: '',
console: {
log: (m) => logs.push(String(m)),
error: (m) => errs.push(String(m))
},
vfs: {
async stat(p) {
if (!Object.prototype.hasOwnProperty.call(store.files, p)) return null
return store.files[p].stat
},
async readFile(p) {
const ent = store.files[p]
if (!ent) return null
return ent.body
},
async writeFile(p, body) {
store.files[p] = {
stat: { mode: 0o644, type: 'file', mtimeMs: Date.now() },
body: body instanceof Uint8Array ? body : b4a.from(body)
}
},
async unlink(p) {
delete store.files[p]
}
},
_logs: logs,
_errs: errs
}
}
test('getfacl synthesizes mode triples and reads sidecar', async (t) => {
const store = {
files: {
'/a': {
stat: { mode: 0o755, type: 'file', mtimeMs: 1 },
body: null
},
'/b': {
stat: { mode: 0o644, type: 'file', mtimeMs: 1 },
body: null
},
'/b.bare_acl': {
stat: { mode: 0o644, type: 'file', mtimeMs: 1 },
body: b4a.from('user::rw-\n')
}
}
}
const runA = await loadBin('getfacl')
const ctxA = createCtx(store)
await runA(ctxA, ['getfacl', '-c', '/a'])
t.is(ctxA.exitCode, 0)
t.is(ctxA._logs.join('\n'), 'user::rwx\ngroup::r-x\nother::r-x')
const runB = await loadBin('getfacl')
const ctxB = createCtx(store)
await runB(ctxB, ['getfacl', '/b'])
t.is(ctxB.exitCode, 0)
t.ok(ctxB._logs[0].includes('user::rw-'))
})
test('setfacl -b and stdin write', async (t) => {
const store = {
files: {
'/x': {
stat: { mode: 0o644, type: 'file', mtimeMs: 1 },
body: null
},
'/x.bare_acl': {
stat: { mode: 0o644, type: 'file', mtimeMs: 1 },
body: b4a.from('old\n')
}
}
}
const runClear = await loadBin('setfacl')
const ctx1 = createCtx(store)
await runClear(ctx1, ['setfacl', '-b', '/x'])
t.is(ctx1.exitCode, 0)
t.absent(store.files['/x.bare_acl'])
const runSet = await loadBin('setfacl')
const ctx2 = createCtx(store)
ctx2.shellStdin = 'user::r--\n'
await runSet(ctx2, ['setfacl', '/x'])
t.is(ctx2.exitCode, 0)
t.is(b4a.toString(store.files['/x.bare_acl'].body), 'user::r--\n')
})
test('xattr -w -l -d round trip', async (t) => {
const store = {
files: {
'/f': {
stat: { mode: 0o644, type: 'file', mtimeMs: 1 },
body: null
}
}
}
const runW = await loadBin('xattr')
const ctxW = createCtx(store)
await runW(ctxW, ['xattr', '-w', 'user.t', 'hi', '/f'])
t.is(ctxW.exitCode, 0)
const runL = await loadBin('xattr')
const ctxL = createCtx(store)
await runL(ctxL, ['xattr', '-l', '/f'])
t.is(ctxL.exitCode, 0)
t.is(ctxL._logs.join('\n'), 'user.t: hi')
const runD = await loadBin('xattr')
const ctxD = createCtx(store)
await runD(ctxD, ['xattr', '-d', 'user.t', '/f'])
t.is(ctxD.exitCode, 0)
const runNames = await loadBin('xattr')
const ctxN = createCtx(store)
await runNames(ctxN, ['xattr', '/f'])
t.is(ctxN.exitCode, 0)
t.is(ctxN._logs.length, 0)
})