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)
kernel — system image sources
Files in this directory are read from disk by the seeder (or copied into packages/bare-os-seeder/kernel/ for Pear) and written into the system Hyperdrive with no temporary directory on the host.
This README.md file only documents the tree layout in the repository; the seeder does not install it as /README.md on the image (so the guest root directory stays free of repo docs).
Documentation: Concepts — Boot · User manual · Handbook · Kernel image reference · Developer guide.
Staging map (seeder)
init.js—/boot/init.jsbin/<name>—/bin/<name>etc/...—/etc/...share/man/...—/share/man/...lib/bare/...—/lib/bare/...(optionalctx.barebundles; seebare-os-bare-libs)- Any other file —
/<relative path> **README.md(this file)** — (skipped — not copied to/README.md)
Contents
init.js— Kernel entry: must defineasync function start(ctx). Boot order:/etc/os-release→/etc/motd→ optional/etc/bare-os/rc.profile.<profile>(profile fromBARE_OS_BOOT_PROFILEor first line of/etc/bare-os/profile; the booter mirrors the resolved name inctx.env.BARE_OS_BOOT_PROFILE_RESOLVEDand/run/bare-os/boot_profile) →/etc/bare-os/rc→**/etc/bare-os/rc.d/*** (sorted; digit-prefixed names only; skip dotfiles,*~,README*,*.md; optionalBARE_OS_RC_D_SKIPcomma list andprefix*patterns) → optional/etc/bare-os/rc.local→/etc/bare-os/kernel.d/*(same rules asrc.d) → banner → whenBARE_OS_SKIP_REPL, optional onboot lines fromBARE_OS_ONBOOTor/etc/bare-os/onboot→**readLine/execLine**loop. BootexecLineerrors in trusted snippets are logged; withBARE_OS_BOOT_STRICT=1ortrue, the first throw callsrequestBooterExit(1)and stops later boot phases. Custom kernels may callctx.registerKernelShutdownHook(fn)before initd disposers; usectx.bareOsRuntimeCapsfor limits, pseudo paths, andfeatures([developer-guide/02-the-context-object.md](../developer-guide/02-the-context-object.md)).bin/— Tier-1 utilities built by bare-os-coreutils plussshd/bare-sshdfrom bare-os-openssh (179 commands inCOREUTILS_COMMANDS;sshdis listed for man/help but its concatenated script is emitted by the openssh package build, not coreutilssrc/). Each file isruntime.js+ optional preamble (lib/md5.jsformd5sum,lib/sha224.jsforsha224sum,lib/*-engine.jsforsed/awk,jq-engine.js,lib/man-render.js,lib/edit-*.jsforedit/nano, lscolors forls/dircolors, …) +**async function run(ctx, argv)**(no ESMimportinsrc/)./bin/nanoduplicates/bin/editfor familiarity; the shell’s default**nano→edit**alias uses theeditcommand name after expansion.dir/vdirinvokelsviactx.runBinCommand.lib/bare/— Optional IIFE bundles +manifest.jsonforctx.baredrive merge, built by bare-os-bare-libs. Same trust model asbin/(trusted seeded image).share/man/man.json— Merged manual database for/bin/man(built bybare-os-coreutils; see handbook ch.10).etc/os-release— Static OS metadata (NAME,VERSION, …).etc/motd— Optional message printed afteros-release(distributors can customize).etc/bare-os/banneror/etc/issue— If present on the system drive, the default kernel prints one of these instead of the built-in session hint (unlessBARE_OS_SKIP_REPLshortens the banner). SetBARE_OS_BOOT_TRACE=1ortruefor[boot] phase: Nmslines on stderr,jsonfor{"phase":"…","ms":n}per phase, orndjsonfor machine-readable lines withsessionId. Recovery:BARE_OS_BOOT_MINIMAL, granularBARE_OS_BOOT_SKIP, optionalBARE_OS_KERNEL_SELFTEST(TAP viaBARE_OS_SELFTEST_FORMAT=tap; includes/proc/bare_os_resources//proc/bare_os_featureschecks), readiness viactx.bareOsPublishBootReady→/run/bare-os/readyand/run/bare-os/boot.json(phasesfrom the stock kernel plusbooterPhasesfrom the booter — see developer guide ch.2).etc/bare-os/rc— Optional boot snippet: oneexecLineper non-comment line (trusted).etc/bare-os/rc.d/— Optional extra snippets (basename must start with a digit), same line rules, run afterrcin filename order. Human-oriented notes live in.README(a dotfile so legacyinit.jsnever executes it).
Editing workflow
Do not edit kernel/init.js by hand. It is generated from kernel/lib/boot/*.js (sorted), kernel/lib/init/fragments/*.js (sorted), and kernel/lib/init/init-main.js via npm run bundle:kernel (scripts/bundle-kernel-init.mjs). CI and npm run verify:init-bundle fail when the file drifts. Edit the fragments under lib/boot/, lib/init/fragments/, and lib/init/ only, then bundle and rsync to packages/bare-os-seeder/kernel/ for Pear parity. See lib/init/STRUCTURE.md.
- Change sources under
kernel/orpackages/bare-os-coreutils/src/. - Run
npm run build -w bare-os-coreutilsto refreshkernel/bin/*. - Run
npm run build -w bare-os-bare-libswhenpackages/bare-os-booter/lib/bare-module-manifest.jsonor bundle entries change. - Run seeder again to re-stage the drive (or use a fresh Corestore for a clean image).
Host boot perf: when BARE_OS_BOOT_PERF_DETAIL=1, the stock booter logs bare_stdlib_merge_ns after maybeMergeBareFromDrive (monotonic hrtime delta in nanoseconds) alongside guest boot-perf.json stages.
Pear bundles use the vendored tree under packages/bare-os-seeder/kernel/; keep it in sync by running the same builds before pear stage. Use npm run maintainer:kernel-image from the repo root for coreutils + bare-libs + init bundle + extensions index + parity verify (then rsync -a --delete kernel/ packages/bare-os-seeder/kernel/ if the verifier reports drift). npm test runs scripts/verify-kernel-seeder-parity.mjs, scripts/verify-ctx-api-feature-bits.mjs, and scripts/validate-example-schemas.mjs (after bare-os-coreutils and bare-os-bare-libs builds) so the two trees match byte-for-byte, ctx semver / feature words stay wired, example JSON matches docs/schemas/, and every kernel/bin/* file contains the BARE_OS_BIN_API pragma (coreutils runtime.js and hand-written stubs such as systemctl / journalctl).
Optional system image examples: etc/bare-os/boot.allow.example (copy to boot.allow when using host BARE_OS_BOOT_ALLOWLIST=1), etc/bare-os/boot.policy.example.json (install as boot.policy.json when using BARE_OS_BOOT_POLICY=1; v2 fields maxExecLineDepth, denyEnvKeys, requireProcNodes; v3 requireKernelCapabilitiesExtendedSeedingPlatform, requireKernelCapabilitiesRlimitsDelegatesShell, allowedPearIpcChannels, denyVfsPrefixes, maxInitdRestartsPerUnit; v4 requireKernelCapabilitiesOfflineNetExtensions, denyExecLineBuiltins, allowedCtxMethods; v9 requireKernelCapabilitiesBareModuleCryptoStaging, requirePearRuntimeRange, denyBareModuleSpecifierPatterns, requireBareCryptoMin, denyKernelSyscalls, requirePearIpcMin, extensionSignerPinsV2, offlineLkgManifestMaxAgeSec, bootPhasesRequireProcIndexMinSchema; v10 requireKernelCapabilitiesPearInspectLoggerTls, requireBareBootMin, bootPhasesRequireLifecycleMinSchema, extensionSignerPinsV3, …; JSON Schema: [docs/schemas/boot.policy.schema.json](../docs/schemas/boot.policy.schema.json)), etc/bare-os/kernel.extensions.registry.example.json (shape for /proc/bare_os/extensions.json schema 7), etc/bare-os/boot-trace-line.example.json and etc/bare-os/telemetry-ndjson.example.json (shape checks for CI), etc/bare-os/rc.profile.full (sample full profile referenced from profile), etc/bare-os/crontab.example (system-wide cron lines merged ahead of user ~/.crontab), etc/bare-os/timers/*.timer.example (copy to ~/.config/bare-os/timers/*.timer for OnCalendar=, EveryMs=, or OnInactiveSec= jobs). kernel.ext.d scripts register into /proc/bare_os/extensions.json when the booter provides ctx.bareOsRegisterKernelExtensionRecord.