Complete the full planned effort for the detailed ctx.bare code audit and the new ctx.pear surface, delivering the ability to create, stage, and integrate real Pear applications from within a booted Bare OS. ### Audit (ctx.bare) - Performed exhaustive code audit of bare-os-ctx-bare.js (host import path, drive bundle eval + require.addon wrappers, referrer workarounds). - Inventoried all manifest/bundle verifiers and related scripts. - Researched manifest format, implicit tiering model, and dual loading strategy (JSON + .data.mjs). - Deep analysis of the local Holepunch clone (bare-* and pear-* packages) to identify realistic guest vs host-delegate boundaries. - Full cross-reference of call sites, greps, and historical pain points (pear:// referrer resolution, nativeHint handling, addon stubs). ### Implementation (ctx.pear) - Added `pearEntries` tier to bare-module-manifest.json with initial high-value packages (pear-build, pear-bundle, pear-ref, etc.). - Implemented `loadPearModuleManifest()` and `buildPearCtxObjectFromHost()`. - Wired ctx.pear exposure through the booter into the guest context. - Updated TypeScript definitions (`bare-os-ctx.d.ts`). ### User-Facing Surface - Created full `/bin/pear` command with `help`, `info`, `list`, `init` (functional skeleton creation), and improved `stage` subcommands. - Registered as Tier-1 command (now 183 total commands). - Added man page and rebuilt coreutils (kernel + seeder). ### Agent Autonomy - Created production-quality `pear-dev` agent skill. - Added to skill seed list with cross-references to the appstore skill. ### P2P App Store Integration - Updated appstore skill with explicit Pear development synergy section. - Updated p2p-app-store design doc to document the new closed loop. - Added cross-references in both skills and design documents. ### Verification & Hygiene - Created `scripts/verify-pear-module-manifest-data.mjs`. - Enhanced `verify-pear-no-static-node-import.mjs` with explicit pear command coverage. - Integrated new verifier into release-checklist and agent hints. - Performed comprehensive zero-TODO/scaffolding sweep across all new Pear artifacts (clean). - Multiple full verification harness runs (all green). ### Documentation & Governance - Added complete "Pear Development Environment" thread to feature-roadmap.md. - Updated developer guide (Chapter 12). - Maintained living plan document and detailed audit notes with full Implementation Log throughout. - Updated command counts across READMEs and supporting docs. All changes follow project governance: - Bare-only guest constraints strictly observed - Verifier-first discipline maintained - Living plan + audit documents kept as single source of truth - Production quality bar matching the completed P2P App Store feature Plan items 04–21 completed. See: - docs/design/ctx-pear-surface-and-bare-audit-plan.md - docs/audit/ctx-bare-audit-notes.md (full audit + implementation log)
154 lines
6.5 KiB
JavaScript
154 lines
6.5 KiB
JavaScript
/**
|
|
* Operator-facing `/proc/bare_os/kernel_program.json` snapshot (env-driven, non-secret).
|
|
* Legacy path `/proc/bare_os/giant_phase_program.json` resolves to the same payload.
|
|
* Guest surfaces avoid Node `node:*` built-ins — see kernel-program-extension skill.
|
|
* @param {Record<string, string | undefined>} env
|
|
*/
|
|
export const KERNEL_PROGRAM_PROC_SCHEMA = 3
|
|
export const KERNEL_PROGRAM_PROC_VERSION = 3
|
|
|
|
export function buildKernelProgramProcJson(env) {
|
|
const now = Date.now()
|
|
const esc = (k) => String(env[k] ?? '').trim()
|
|
const on = (k) => {
|
|
const v = esc(k)
|
|
return v === '1' || v === 'true'
|
|
}
|
|
|
|
function parseOverride() {
|
|
const rawNew = esc('BARE_OS_KERNEL_PROGRAM_PROC_JSON')
|
|
const rawLegacy = esc('BARE_OS_GIANT_PHASE_PROGRAM_JSON')
|
|
const raw = rawNew || rawLegacy
|
|
if (!raw) return null
|
|
const key = rawNew
|
|
? 'BARE_OS_KERNEL_PROGRAM_PROC_JSON'
|
|
: 'BARE_OS_GIANT_PHASE_PROGRAM_JSON'
|
|
try {
|
|
const o = JSON.parse(raw)
|
|
return o && typeof o === 'object' ? o : null
|
|
} catch {
|
|
return { error: 'invalid_json', key, atMs: now }
|
|
}
|
|
}
|
|
|
|
function parseJsonEnv(key) {
|
|
const raw = esc(key)
|
|
if (!raw) return null
|
|
try {
|
|
const o = JSON.parse(raw)
|
|
return o && typeof o === 'object' ? o : null
|
|
} catch {
|
|
return { error: 'invalid_json', key, atMs: now }
|
|
}
|
|
}
|
|
|
|
const base = {
|
|
schema: KERNEL_PROGRAM_PROC_SCHEMA,
|
|
program: 'bare-os-kernel-program',
|
|
programVersion: KERNEL_PROGRAM_PROC_VERSION,
|
|
atMs: now,
|
|
hooks: {
|
|
bootSafeMode: on('BARE_OS_BOOT_SAFE_MODE'),
|
|
bootTransactionJournal: (() => {
|
|
const v = esc('BARE_OS_BOOT_TRANSACTION_JOURNAL')
|
|
return v === '1' || v === 'true' || v === 'ndjson' ? v : ''
|
|
})(),
|
|
bootCheckpoint: on('BARE_OS_BOOT_CHECKPOINT'),
|
|
bootPolicy: on('BARE_OS_BOOT_POLICY'),
|
|
bootPolicyStrict: on('BARE_OS_BOOT_POLICY_STRICT'),
|
|
bootMinimal: on('BARE_OS_BOOT_MINIMAL'),
|
|
bootDryRun: on('BARE_OS_BOOT_DRY_RUN'),
|
|
bootRollbackApply: on('BARE_OS_BOOT_ROLLBACK_APPLY'),
|
|
kernelDebug: on('BARE_OS_KERNEL_DEBUG'),
|
|
lazyPersonalDrive: on('BARE_OS_LAZY_PERSONAL_DRIVE'),
|
|
kernelHotReload: on('BARE_OS_KERNEL_HOT_RELOAD'),
|
|
delegateTrace: on('BARE_OS_DELEGATE_TRACE'),
|
|
loaderAudit: on('BARE_OS_LOADER_AUDIT')
|
|
},
|
|
bareStacks: {
|
|
note:
|
|
'Prefer bare-module, bare-crypto, bare-fs, bare-net, bare-dns, bare-process, bare-subprocess, bare-ipc, bare-worker, bare-tls, bare-fetch, bare-http1, bare-ws per holepunch bare-node map.',
|
|
bareCryptoVersion: esc('BARE_OS_BARE_CRYPTO_VERSION').slice(0, 64),
|
|
pearIpcVersion: esc('BARE_OS_PEAR_IPC_PACKAGE_VERSION').slice(0, 64),
|
|
bareTlsVersion: esc('BARE_OS_BARE_TLS_VERSION').slice(0, 64)
|
|
},
|
|
workstreams: {
|
|
bootRuntime: { status: 'active', items: '1-20' },
|
|
moduleLoading: { status: 'active', items: '21-30' },
|
|
processIpc: { status: 'framework', items: '31-40' },
|
|
vfsStorage: { status: 'framework', items: '41-50' },
|
|
networking: { status: 'framework', items: '51-60' },
|
|
security: { status: 'framework', items: '61-70' },
|
|
observability: { status: 'framework', items: '71-80' },
|
|
distribution: { status: 'framework', items: '81-90' },
|
|
quality: { status: 'active', items: '91-100' }
|
|
},
|
|
operatorSketches: {
|
|
schema: 1,
|
|
bootBundleDigestHex: esc('BARE_OS_BOOT_BUNDLE_DIGEST_HEX').slice(0, 128),
|
|
requireCtxApiMin: esc('BARE_OS_REQUIRE_CTX_API_MIN').slice(0, 32),
|
|
dnsProfile: esc('BARE_OS_DNS_PROFILE').slice(0, 64),
|
|
netDelegateSketch: parseJsonEnv(
|
|
'BARE_OS_NET_DELEGATE_SKETCH_JSON'
|
|
) || parseJsonEnv('BARE_OS_GP2_NET_DELEGATE_SKETCH_JSON'),
|
|
egressPolicyV2: parseJsonEnv('BARE_OS_EGRESS_POLICY_V2_JSON'),
|
|
listenerRegistry: parseJsonEnv('BARE_OS_LISTENER_REGISTRY_JSON'),
|
|
tlsSessionCacheHint: parseJsonEnv('BARE_OS_BARE_TLS_SESSION_CACHE_HINT_JSON'),
|
|
wsDevtoolsSketch: parseJsonEnv('BARE_OS_BARE_WS_DEVTOOLS_SKETCH_JSON'),
|
|
subprocessResourceHints: parseJsonEnv('BARE_OS_SUBPROCESS_RESOURCE_HINTS_JSON'),
|
|
vfsWatchDebounceMs: Math.min(
|
|
60000,
|
|
Math.max(
|
|
0,
|
|
Number.parseInt(esc('BARE_OS_VFS_WATCH_DEBOUNCE_MS'), 10) || 0
|
|
)
|
|
),
|
|
binCacheStats: parseJsonEnv('BARE_OS_VFS_BIN_CACHE_STATS_JSON'),
|
|
zlibLogPolicy: parseJsonEnv('BARE_OS_ZLIB_LOG_POLICY_JSON'),
|
|
keyringRotationPointer: parseJsonEnv('BARE_OS_KEYRING_ROTATION_POINTER_JSON'),
|
|
configAttestation: parseJsonEnv('BARE_OS_CONFIG_ATTESTATION_JSON'),
|
|
entropyHealth: parseJsonEnv('BARE_OS_ENTROPY_HEALTH_JSON'),
|
|
otelResourceAttrs:
|
|
parseJsonEnv('BARE_OS_OTEL_RESOURCE_ATTRS_KERNEL_JSON') ||
|
|
parseJsonEnv('BARE_OS_OTEL_RESOURCE_ATTRS_GP2_JSON'),
|
|
logRetentionHints: parseJsonEnv('BARE_OS_LOG_RETENTION_HINTS_JSON'),
|
|
circuitBreakerDelegates: parseJsonEnv('BARE_OS_DELEGATE_CIRCUIT_BREAKER_JSON'),
|
|
execLineAnomalyThreshold: Math.min(
|
|
1e9,
|
|
Math.max(0, Number.parseInt(esc('BARE_OS_EXEC_LINE_ANOMALY_THRESHOLD'), 10) || 0)
|
|
),
|
|
signedComponentManifest: parseJsonEnv('BARE_OS_SIGNED_COMPONENT_MANIFEST_JSON'),
|
|
abChannelHint: esc('BARE_OS_AB_CHANNEL_HINT').slice(0, 64),
|
|
lockfileTransitiveAllow: parseJsonEnv('BARE_OS_LOCKFILE_TRANSITIVE_ALLOW_JSON'),
|
|
sandboxProfileRegistry: parseJsonEnv('BARE_OS_SANDBOX_PROFILE_REGISTRY_JSON'),
|
|
cpuSliceHints: parseJsonEnv('BARE_OS_CPU_SLICE_HINTS_JSON'),
|
|
ipcReadWatchdogMs: Math.min(
|
|
300000,
|
|
Math.max(0, Number.parseInt(esc('BARE_OS_IPC_READ_WATCHDOG_MS'), 10) || 0)
|
|
),
|
|
crossDriveTxPointer: parseJsonEnv('BARE_OS_CROSS_DRIVE_TX_POINTER_JSON'),
|
|
mountNamespaceSketch: parseJsonEnv('BARE_OS_MOUNT_NAMESPACE_SKETCH_JSON'),
|
|
note:
|
|
'Optional operator JSON hints (non-secret). See developer-guide/kernel-program.md and kernel-superfeature-backlog.md.'
|
|
},
|
|
docAnchor: 'developer-guide/kernel-program.md',
|
|
batchC: {
|
|
status: 'active',
|
|
note: 'Governed continuation after 200-item baseline. Consult kernel-program-extension skill + local BARE_OS_HOLEPUNCH_CLONES_ROOT for all guest code (bare-* only, no node: builtins).'
|
|
}
|
|
}
|
|
|
|
const override = parseOverride()
|
|
if (override && !override.error) {
|
|
const sch =
|
|
typeof override.schema === 'number' && override.schema >= 1 && override.schema <= 4
|
|
? override.schema
|
|
: KERNEL_PROGRAM_PROC_SCHEMA
|
|
return { ...base, ...override, schema: sch, atMs: now }
|
|
}
|
|
if (override && override.error) {
|
|
return { ...base, overrideError: override }
|
|
}
|
|
return base
|
|
}
|