Implement the full BareOS shell roadmap end-to-end, including grammar/tokenization
diagnostics, expansion/runtime hardening, execution graph tooling, builtins/job-control
stability, policy/sandbox controls, and release/traceability documentation updates.
- Add shell grammar baseline and diagnostics primitives:
- introduce `docs/reference/shell-grammar.md` with lexer modes and EBNF contract
- add rich diagnostic tokenizer output (mode + span metadata) via `tokenizeBareShellLineDetailed`
- export structured parse snapshot helpers (`bareOsShellAstSnapshot`) and shell error kinds
- add determinism coverage for tokenizer and AST snapshot outputs
- Harden expansion semantics and guardrails:
- enforce expansion byte budgets (`BARE_OS_SHELL_EXPANSION_MAX_BYTES`)
- add expansion trace hooks (`BARE_OS_SHELL_EXPANSION_TRACE`) with stage-level rows
- add expansion recursion depth limits (`BARE_OS_SHELL_EXPANSION_MAX_DEPTH`)
- tighten POSIX-mode arithmetic invalid-token diagnostics
- preserve declared expansion ordering and document it in code/docs
- Extend redirection/pipeline execution model:
- add normalized redirection planner (`planShellRedirections`) independent of side effects
- add execution graph builder/debug surface (`buildShellExecutionGraph`)
- support `<<-` operator in tokenizer/parser paths
- add pipeline stage timeout safety (`BARE_OS_SHELL_PIPELINE_STAGE_TIMEOUT_MS`)
- keep pipefail/pipestatus behavior verified with integration tests
- Improve builtins and control-flow reliability:
- expand `read` builtin support:
- `-r` raw mode
- `-d` single-char delimiter
- `-t` timeout semantics
- refine wait/jobs semantics:
- stable `jobs -l` parseable format expectations
- synthetic pid mapping (`wait 410x`) and `wait all` support
- keep trap registration/listing behavior deterministic and test-covered
- add trap signal dispatch helper (`dispatchShellTrapSignal`) with normalization
- Add security and policy enforcement hooks:
- command deny/allow policy gates:
- `BARE_OS_SHELL_DENY_COMMANDS`
- `BARE_OS_SHELL_ALLOW_COMMANDS`
- sandbox mode (`BARE_OS_SHELL_SANDBOX`) to block external command execution
- redirect path safety guard (`BARE_OS_SHELL_REDIRECT_GUARD`) for pseudo-path/traversal risks
- emit structured shell audit event rows (`ctx.shellAuditEvents`) for start/error/finish
- Improve interactive UX resilience:
- add prompt-hook timeout protection in fish readline:
- `resolveShellPromptHookSegment`
- env control `BARE_OS_SHELL_PROMPT_HOOK_TIMEOUT_MS`
- ensure prompt segment resolution is non-blocking and safe on timeout/error
- Add reliability/performance artifacts and shell fast lane:
- add `scripts/bench-shell-phases.mjs` for shell microbench sanity checks
- add `scripts/gen-shell-reliability-report.mjs` and generate reliability JSON artifact
- add root scripts:
- `test:shell-fast`
- `bench:shell`
- `report:shell-reliability`
- Expand shell-focused docs and traceability:
- add:
- `docs/reference/shell-unsupported-behavior.md`
- `docs/reference/shell-troubleshooting.md`
- add contributor guides:
- `developer-guide/17-how-to-add-shell-builtin.md`
- `developer-guide/18-how-to-add-shell-grammar-feature.md`
- update indexes/traceability/release gate docs:
- `docs/reference/README.md`
- `docs/reference/posix-issue7-traceability.md`
- `docs/reference/environment-and-posix-appendix.md`
- `docs/release-checklist.md`
- `developer-guide/README.md`
- `scripts/README.md`
- Add and update shell regression tests in `packages/bare-os-booter/test.js` for:
- tokenizer spans/modes and deterministic output
- AST snapshot schema/shape
- redirection planner and execution graph behavior
- expansion trace and strict arithmetic paths
- `<<-` support
- pipeline stage timeout handling
- `read` delimiter/raw/timeout semantics
- jobs/wait parseability and selection semantics
- trap dispatch and normalization behavior
- policy/sandbox/redirect-guard/audit-event pathways
Validation:
- `npm run test -w bare-os-booter`
- `npm run test:shell-bracket -w bare-os-booter`
- `npm run test:shell-fast`
- `npm run report:shell-reliability`
bare-os-seeder
Pear / Bare application that owns the canonical system Hyperdrive: it walks a kernel tree on disk, writes /boot/init.js, /bin/*, /etc/* into the drive (no host temp dirs), builds a 512-byte MBR with the drive key, joins Hyperswarm on bare-os-v1, and serves MBR block reads + Protomux bare-os-v1 replication to peers.
When to use: run the seeder when you want to publish the canonical system image for booters to replicate (typical dev: one terminal with npm run os:seeder). Eligible already-booted peers can later mirror block 0, but the seeder remains the trust anchor for initial publication.
Documentation: Concepts — Boot · Seeder reference · User manual ch.3 · Protocol reference.
Run
From package directory (after npm ci at repo root):
node index.js
Or with Bare/Pear:
npm run pear:dev
From repo root (recommended — fixes workspace node_modules for Pear):
npm run os:seeder
Environment
BARE_OS_KERNEL_ROOT— Absolute path to kernel tree to stage (default: packagekernel/vendored copy, or repokernel/under Nodefile:URL)BARE_OS_HOST_DATA— Base directory for host state (default~/.bare-os)BARE_OS_SEED_STORE— Corestore directory (default~/.bare-os/corestore/seeder)BARE_OS_SEED_CAPABILITY_ATTESTATION_JSON— Optional JSON string for seed RPCbare_os.capability_attestation(operators verify on host; guest does not crypto-verify)
Pear vs Node
import.meta.urlisfile:— seeder may dynamically importbare-os-coreutils/build.mjsandbare-os-bare-libs/build.mjs, rebuilding/binandkernel/lib/barebefore staging.pear:bundle — coreutils and/lib/barebundles must be pre-built intokernel/; runnpm run build -w bare-os-coreutilsandnpm run build -w bare-os-bare-libsbeforepear run(rootnpm run os:seederdoes both).
Layout
index.js— Entry: Corestore, Hyperdrive,stageKernelTree, swarm,setupSeedChannel(RPCs include optionalbare_os.snapshot_hintsandbare_os.peer_firewall_statswhen implemented)lib/paths.js—packageRootDir, kernel root, Corestore path (Pear RTI–aware)kernel/— Vendored mirror of repokernel/for Pear staging — must matchkernel/byte-for-byte (npm testpretestrunsscripts/verify-kernel-seeder-parity.mjs)
Dependencies
bare-os-protocol (workspace), hyperdrive, corestore, hyperswarm, protomux, b4a, compact-encoding, safety-catch, bare-os.