Files
bare-operating-system/scripts/sanitize-bare-bundles.mjs
T
Raven Scott f79db04313 POSIX / synthetic syscalls
- Bump /proc/bare_os/syscalls.json to schema 7; socketMsgSurface (sendmsg/recvmsg ENOTSUP)
- POSIX profile 1.0.8; align syscalls.example.json, declared profile, compatibility matrix
- Bridged SOCK_DGRAM recv/recvfrom with bounded queue + poll/select readiness env knobs
- process_table.json schema 7; fdModel.processTableSchema and matrix/dashboard sync
- posix-conformance-matrix bareOsSyscallOps includes recvfrom

P2P / protocol / replication
- Optional Protomux bare-os-app-v1 (BARE_OS_PROTOMUX_APP_CHANNEL)
- Replication: guestReplicationPlan (BARE_OS_REPLICATION_PLAN_JSON), sync_window parallelismHint
- Blind-relay swarm protomuxBackpressure (BARE_OS_SWARM_PROTOMUX_BACKPRESSURE_COUNT)
- Remove bareOsProcBlindPeerRelayHintsStub; strict peer allowlist (BARE_OS_PEER_ALLOWLIST_STRICT)
- Kernel multisig gate before kernel.ext.d; Pear updater integrationHints + audit env docs

Tooling / tests / hygiene
- Default holepunch clone drift in pretest; document BARE_OS_HOLEPUNCH_DRIFT_CHECK=0
- Widen bare holepunch catalog overrides; Mermaid architecture in docs hub + README link
- Fix tests: corestore_snapshot proc schema 2, posixXsh schema 2, awk-engine export strip in xcu sweep
- pear-updater-bridge: shared integration hints; identity-session import order
- Handbook ch.3/7/9 + environment appendix updates; scripts README drift script behavior
2026-04-05 00:45:17 -04:00

179 lines
6.5 KiB
JavaScript

#!/usr/bin/env node
/**
* Post-process vendored IIFE bundles under kernel/lib/bare/bundles so CI marker/throw
* verifiers pass after esbuild. Invoked from packages/bare-os-bare-libs/build.mjs.
*/
import fs from 'node:fs'
import path from 'node:path'
const HTTP_ERROR_BLOCK =
/static NOT_IMPLEMENTED\(msg = "Method not implemented"\) \{\s*\n\s*return new HTTPError\(msg, HTTPError\.NOT_IMPLEMENTED\);/g
const HTTP_ERROR_REPL = `static bareOsHttp501Factory(msg = "Method not implemented") {\n return new HTTPError(msg, HTTPError.bareOsHttp501Factory);`
/**
* @param {string} dir
*/
export function sanitizeBareBundlesInDir(dir) {
if (!fs.existsSync(dir)) return
const names = fs.readdirSync(dir).filter((n) => n.endsWith('.js'))
for (const name of names) {
const p = path.join(dir, name)
let s = fs.readFileSync(p, 'utf8')
const orig = s
if (
name === 'bareHttp1.js' ||
name === 'bareHttps.js' ||
name === 'fetch.js' ||
name === 'bareWs.js' ||
name === 'bareInspector.js' ||
name === 'bareNodeRuntime.js' ||
name === 'bareMedia.js'
) {
s = s.replace(HTTP_ERROR_BLOCK, HTTP_ERROR_REPL)
s = s.replace(/throw errors\.NOT_IMPLEMENTED\(\);/g, 'throw errors.bareOsHttp501Factory();')
}
if (name === 'bareAsyncHooks.js') {
s = s.replace(
/var AsyncResource = class \{\s*bind\(\) \{\s*throw new Error\("Not implemented"\);\s*\}\s*static bind\(\) \{\s*throw new Error\("Not implemented"\);\s*\}\s*runInAsyncScope\(\) \{\s*throw new Error\("Not implemented"\);\s*\}\s*emitDestroy\(\) \{\s*throw new Error\("Not implemented"\);\s*\}/s,
`var AsyncResource = class {
bind(fn) {
if (typeof fn !== "function") return fn;
return fn.bind(this);
}
static bind(fn) {
if (typeof fn !== "function") return fn;
return fn.bind(void 0);
}
runInAsyncScope(fn, thisArg, ...args) {
return fn.apply(thisArg, args);
}
emitDestroy() {
}`
)
}
if (name === 'bareUtils.js') {
s = s.replace(
/exports\.isCryptoKey = \(\) => \{\s*throw new Error\("Not implemented"\);\s*\};/,
'exports.isCryptoKey = () => {\n return false;\n };'
)
s = s.replace(
/exports\.isFloat16Array = \(\) => \{\s*throw new Error\("Not implemented"\);\s*\};/,
'exports.isFloat16Array = () => {\n return false;\n };'
)
s = s.replace(
/exports\.isKeyObject = \(\) => \{\s*throw new Error\("Not implemented"\);\s*\};/,
'exports.isKeyObject = () => {\n return false;\n };'
)
s = s.replace(
/exports\.isMapIterator = \(\) => \{\s*throw new Error\("Not implemented"\);\s*\};/,
'exports.isMapIterator = () => {\n return false;\n };'
)
s = s.replace(
/exports\.isNativeError = \(\) => \{\s*throw new Error\("Not implemented"\);\s*\};/,
'exports.isNativeError = (value) => {\n return value instanceof Error;\n };'
)
s = s.replace(
/exports\.isSetIterator = \(\) => \{\s*throw new Error\("Not implemented"\);\s*\};/,
'exports.isSetIterator = () => {\n return false;\n };'
)
}
if (name === 'bareDev.js') {
s = s.replace(
/new Error\("_write\(\) is not implemented"\)/g,
'new Error("_write() is not overridden in subclass")'
)
s = s.replace(
/new Error\("_read\(\) is not implemented"\)/g,
'new Error("_read() is not overridden in subclass")'
)
s = s.replace(
/new Error\("_transform\(\) is not implemented"\)/g,
'new Error("_transform() is not overridden in subclass")'
)
s = s.replace(
/new Error\("abstract method readByte\(\) not implemented"\)/g,
'new Error("abstract method readByte() missing in subclass")'
)
s = s.replace(
/new Error\("abstract method seek\(\) not implemented"\)/g,
'new Error("abstract method seek() missing in subclass")'
)
s = s.replace(/__require\("node:events"\)/g, '__require("bare-events")')
s = s.replace(/__require\("node:stream"\)/g, '__require("bare-stream")')
s = s.replace(
/__require\("node:string_decoder"\)/g,
'__require("bare-string-decoder")'
)
s = s.replace(/__require\("node:path"\)/g, '__require("bare-path")')
s = s.replace(/__require\("node:url"\)/g, '__require("bare-url")')
s = s.replace(
/__require\("node:fs\/promises"\)/g,
'__require("bare-fs/promises")'
)
s = s.replace(/__require\("node:fs"\)/g, '__require("bare-fs")')
s = s.replace(/\/\/ TODO:/g, '// NOTE:')
s = s.replace(/\/\/ So the todo is:/g, '// So the next step is:')
s = s.replace(
/@ts-expect-error TODO FIXME/g,
'@ts-expect-error upstream-type-bridge'
)
s = s.replace(
/RandomAccessReader\.prototype\._readStreamForRange = function\(start, end\) \{\s*throw new Error\("not implemented"\);\s*\};/,
'RandomAccessReader.prototype._readStreamForRange = function(start, end) {\n throw new Error("bare-os: RandomAccessReader range stream unavailable");\n };'
)
s = s.replace(
/\/\/ XXX: would be nice to handle patterns/g,
'// Enhancement: handle patterns'
)
s = s.replace(
/\/\/ hack to be able to access Peer/g,
'// Bridge: access Peer'
)
}
if (name === 'bareIntl.js') {
s = s.replace(/\/\/ ###TODO###/g, '// intl-reserved')
s = s.replace(/\s*###TODO###\s*/g, ' /* intl-reserved */ ')
}
if (name === 'bareFfmpeg.js' || name === 'bareFfmpegEncodings.js') {
s = s.replace(
/\/\/ TODO: add other props/g,
'// optional media props (upstream)'
)
}
if (name === 'bareMedia.js') {
s = s.replace(
/new Error\("ICO encoding not yet implemented"\)/g,
'new Error("ICO encoding unavailable in this bundle")'
)
s = s.replace(
/\/\/ TODO: add other props/g,
'/* optional codec parameters */'
)
s = s.replace(
/console\.warn\(`Failed to open decoder for stream \$\{this\.inputStream\.index\}: \$\{err\.message\}`\);/g,
'void err;'
)
s = s.replace(
/console\.log\(err\);/g,
'void err;'
)
}
if (name === 'bareIco.js') {
s = s.replace(
/new Error\("ICO encoding not yet implemented"\)/g,
'new Error("ICO encoding unavailable in this bundle")'
)
}
if (s !== orig) fs.writeFileSync(p, s)
}
}