Skip to content

feat(shell): add zero-config default like the database worker - #320

Merged
andersonleal merged 2 commits into
mainfrom
shell-zero-config-default
Jun 23, 2026
Merged

feat(shell): add zero-config default like the database worker#320
andersonleal merged 2 commits into
mainfrom
shell-zero-config-default

Conversation

@andersonleal

@andersonleal andersonleal commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

What

Gives the shell worker a zero-config default so it boots with no config file at all, matching the database worker's pattern.

Before this, the shell worker could not boot config-less: ShellConfig::default() is intentionally unjailed (host_root: None) and rejected by build_runtime, and register_config never seeded a built-in value. With no --config and nothing stored, boot failed closed.

How

  • config.rs — add ShellConfig::seed_default(): a bootable permissive dev default (jailed to /tmp, inherit_env: true, open exec with a catastrophic-only denylist). It mirrors the shipped config.yaml exactly, drift-guarded by seed_default_matches_shipped_config_yaml.
  • configuration.rsregister_config seeds seed_default() as initial_value on first registration when no --config seed is given and nothing is stored yet (should_seed_default_value), validated via build_runtime before persisting.
  • Tests: drift guard + prepare_config_accepts_seed_default.
  • README / ARCHITECTURE: document the zero-config default.

Safety

ShellConfig::default() stays unchanged (unjailed) so a partial operator config that omits the jail still fails closed. fetch_config still returns default() on a null stored value, so:

  • boot fails closed if the seed itself can't be built, and
  • a steady-state hot-reload keeps last-good rather than silently widening the live jail to the /tmp seed.

Note: the zero-config default carries the existing shipped config.yaml posture (/tmp jail, inherit_env: true, open exec) — a config-less boot now behaves exactly like cargo run did before. Tightening that default (e.g. inherit_env: false) would be a separate decision.

Verification

cargo build clean, cargo clippy clean, 243 lib tests pass. Reviewed via /review (boot/reload paths traced, independent adversarial pass — no security regressions).

https://claude.ai/code/session_01YCgHHh8hLBXy9v1zKjGLtK

Summary by CodeRabbit

Release Notes

  • New Features

    • Shell worker now features a built-in zero-config default configuration, eliminating the requirement for explicit configuration files on first startup.
  • Documentation

    • Updated architecture and README with comprehensive documentation on zero-config initialization, startup configuration behavior, and fallback mechanisms when configuration is unavailable.
  • Improvements

    • Enhanced startup warning messages to clarify configuration loading and fallback behavior.

The shell worker required a config file to boot: ShellConfig::default() is
intentionally unjailed (host_root: None) and rejected by build_runtime, and
register_config never seeded a built-in value, so with no --config and
nothing stored the worker failed closed at boot.

Add ShellConfig::seed_default(), a bootable permissive dev default (jailed
to /tmp, env forwarded, open exec with a catastrophic-only denylist) that
mirrors the shipped config.yaml, drift-guarded by a unit test.
register_config seeds it as initial_value on first registration when no
--config seed is given and nothing is stored, so the worker boots with no
config file at all (database parity).

Default::default() stays unjailed so a partial operator config still fails
closed, and fetch_config still returns it on a null stored value: boot fails
closed and a hot-reload keeps last-good rather than silently widening the
live jail to the /tmp seed.

Claude-Session: https://claude.ai/code/session_01YCgHHh8hLBXy9v1zKjGLtK
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview, Comment Jun 23, 2026 8:27pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@andersonleal, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 27 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 30cd4485-ba1f-432a-a052-e64419494b16

📥 Commits

Reviewing files that changed from the base of the PR and between 7e3dd2a and 77e9936.

📒 Files selected for processing (1)
  • shell/src/config.rs
📝 Walkthrough

Walkthrough

Adds a ShellConfig::seed_default() constructor that returns a bootable zero-config default (jailed to /tmp, with denylist regexes and env inheritance). The register_config function now uses this seed as initial_value when the configuration worker has no stored or non-null value. A unit test enforces that the in-code seed matches the shipped config.yaml. Docs in README and ARCHITECTURE are updated to describe the new behavior.

Changes

Shell worker zero-config default seeding

Layer / File(s) Summary
ShellConfig::seed_default() constructor and YAML sync test
shell/src/config.rs
Adds seed_default() returning a permissive bootable ShellConfig with a custom timeout, inherit_env: true, catastrophic-only denylist regexes, and an FS jail at /tmp. A new unit test parses the shipped config.yaml and asserts JSON equality with seed_default() to keep them synchronized.
register_config seeding logic
shell/src/configuration.rs, shell/src/main.rs
register_config gains a should_seed_default_value check that reads the current stored config and treats missing/null as seed-required. When seeding, it picks seed_default() as the sole built-in candidate, validates it via build_runtime, and only sets initial_value if valid. The startup warning log is updated to describe the new fallback priority. A new test asserts that prepare_config(&ShellConfig::seed_default()) succeeds.
README and ARCHITECTURE docs
shell/README.md, shell/ARCHITECTURE.md
README adds a "Zero-config default" section describing first-registration seeding and fail-closed behavior. ARCHITECTURE updates the --config flag entry and boot step to replace "continue without a seed" with "warn and seed the built-in default".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • iii-hq/workers#117: Modifies fs.allow_unjailed in the shipped shell/config.yaml, directly affecting what the new seed_default_matches_shipped_config_yaml sync test evaluates.
  • iii-hq/workers#302: Edits shell/config.yaml and related exec-policy test expectations in shell/src/config.rs, which are the same files now coupled to seed_default() and its synchronization test.

Suggested reviewers

  • sergiofilhowz

Poem

🐇 Hippity hop, no config? No fear!
A /tmp-jailed default will appear.
seed_default() springs from the code with care,
The YAML and Rust stay equal and fair.
Fail-closed and snug, the rabbit says: "Boot without dread!" 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(shell): add zero-config default like the database worker' accurately and concisely captures the main change: adding zero-config default functionality to match the database worker pattern.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shell-zero-config-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 25 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
shell/src/config.rs (1)

179-191: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align seed_default() docs with the actual null-fallback behavior.

Line 181 currently says seed_default() is the runtime fallback for null stored config, but runtime null fallback is actually ShellConfig::default() (fail-closed). Please update the comment to avoid security-semantics confusion.

📝 Suggested doc-only fix
-    /// registration and used as the runtime fallback when the stored value is
-    /// null, so the worker boots with no config file at all (database-style
-    /// zero-config). This is deliberately NOT `Default::default()` — that is
+    /// registration when no value is stored yet, so the worker can boot with
+    /// no config file at all (database-style zero-config). Runtime fallback on
+    /// a stored `null` remains `Default::default()` (intentionally invalid) so
+    /// boot fails closed. This is deliberately NOT `Default::default()` — that is
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shell/src/config.rs` around lines 179 - 191, The documentation comment for
the seed_default() method incorrectly states that it is used as the runtime
fallback when the stored value is null, but the actual runtime null fallback is
ShellConfig::default() (fail-closed). Update the comment to clarify that
seed_default() is used only as the initial value on first registration, and
explicitly note that the runtime fallback for null stored config is
ShellConfig::default(), not seed_default(), to avoid security-semantics
confusion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@shell/src/config.rs`:
- Around line 179-191: The documentation comment for the seed_default() method
incorrectly states that it is used as the runtime fallback when the stored value
is null, but the actual runtime null fallback is ShellConfig::default()
(fail-closed). Update the comment to clarify that seed_default() is used only as
the initial value on first registration, and explicitly note that the runtime
fallback for null stored config is ShellConfig::default(), not seed_default(),
to avoid security-semantics confusion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 90ff6d9b-8a1e-48b3-8353-fe0f463062e8

📥 Commits

Reviewing files that changed from the base of the PR and between 39cc517 and 7e3dd2a.

📒 Files selected for processing (5)
  • shell/ARCHITECTURE.md
  • shell/README.md
  • shell/src/config.rs
  • shell/src/configuration.rs
  • shell/src/main.rs

@andersonleal
andersonleal merged commit 6b8c600 into main Jun 23, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants