Skip to content

feat: plumb daemon IDs through to identify a process - #1145

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/cache
Jul 31, 2026
Merged

feat: plumb daemon IDs through to identify a process#1145
twitchyliquid64 merged 1 commit into
mainfrom
tom/cache

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 31, 2026

Copy link
Copy Markdown
Member

Fixes: #1001

Temporary files are now minted using a daemon_id suffix, which if not provided defaults to PID like before.

Needed to fix cache/implement clean under minimald.

Note

Plumb daemon IDs through sandbox, build, and check operations to identify processes

  • Generates a unique alphanumeric daemon_id in minimald::ServerState and propagates it through mctx::Config to all downstream components.
  • Adds daemon_id: Option<String> to op::Options, CheckCtx, sandbox2::config::Config, and the orchestrator, threading the ID through builds, checks, materializations, and standalone tests.
  • Changes sandbox temp directory naming in sandbox2::config::Config.build to use daemon_id as a suffix when set, falling back to the current PID.
  • CLI commands (cmd_check, cmd_materialize, cmd_pkg_patched_build) forward ctx.daemon_id() into their respective operations.
  • Behavioral Change: sandbox temp directories are now named by daemon ID rather than PID when running under minimald, which affects any tooling that parses sandbox directory names.

Macroscope summarized 0a1f61f.

Summary by CodeRabbit

  • New Features
    • Added optional daemon identity support across build, check, materialization, and test operations.
    • Server sessions now receive an automatically generated daemon identifier.
    • Sandbox directories use the daemon identifier when available, improving isolation and traceability.
    • Exposed daemon identity through runtime context and server state APIs.

@twitchyliquid64
twitchyliquid64 requested a review from a team as a code owner July 31, 2026 18:05
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds optional daemon IDs to daemon state, context configuration, sandbox configuration, orchestration, operation options, and check execution. Sandbox directories use the daemon ID when configured and otherwise use the process ID.

Changes

Daemon identity propagation

Layer / File(s) Summary
Daemon identity and sandbox configuration
crates/minimald/src/server.rs, crates/mctx/src/config.rs, crates/sandbox2/src/config.rs, crates/minimald/src/session.rs
minimald generates a daemon ID. mctx and sandbox configuration store it. Sandbox directory names use it with a process ID fallback.
Context and orchestration propagation
crates/mctx/src/env.rs, crates/mctx/src/lib.rs, crates/orchestrator/src/lib.rs, crates/orchestrator/src/local_backend.rs, crates/minimald/src/env.rs
Contexts, environment channels, orchestrators, builds, subset operations, and patched package builds forward the daemon ID.
Operation option propagation
crates/op/src/*, crates/mip/src/cmd_materialize.rs, crates/mip/src/cmd_pkg_patched_build.rs, crates/minimald/src/session_sop.rs
op::Options stores the daemon ID. Materialization, dependency resolution, sandbox setup, patched builds, and standalone tests propagate it.
Check context propagation
crates/check/src/*, crates/mip/src/cmd_check.rs, crates/mctx/src/lib.rs
CheckCtx accepts the daemon ID and passes it to standalone tests. Callers and test helpers provide the new argument.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ServerState
  participant Context
  participant LocalBackend
  participant OperationOptions
  participant CheckCtx
  participant SandboxConfig
  ServerState->>Context: configure daemon_id
  Context->>LocalBackend: pass daemon_id to orchestrator
  LocalBackend->>OperationOptions: pass daemon_id to build operations
  Context->>CheckCtx: construct with daemon_id
  CheckCtx->>OperationOptions: pass daemon_id to standalone tests
  OperationOptions->>SandboxConfig: apply daemon_id
  SandboxConfig->>SandboxConfig: name sandbox directory with daemon_id or process ID
Loading

Possibly related PRs

Suggested reviewers: evanspearman, norrietaylor

Poem

A rabbit carries one ID,
Through every sandbox path it hops.
Checks and builds receive the tag,
The daemon name replaces old PID stamps.
Each operation keeps it near,
While tests pass None when it is clear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR uses a daemon ID for naming, but issue #1001 requires namespace ownership and reclamation tracking tied to the sandbox leader PID. Implement leader-PID ownership and recording, or provide code evidence that the daemon ID satisfies the issue's leader-lifetime and reclamation requirements.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes consistently implement daemon ID propagation and sandbox naming for the stated minimald cache and cleanup objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly and concisely describes propagating daemon IDs to identify processes.
Description check ✅ Passed The description explains the change and motivation, but it omits the required Testing and Checklist sections.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tom/cache

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

@twitchyliquid64
twitchyliquid64 enabled auto-merge (rebase) July 31, 2026 18:11

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/op/src/lib.rs (1)

13-19: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Pass daemon_id to every production sandbox configuration. Add .with_daemon_id(...) in crates/op/src/specs.rs, crates/op/src/standalone_test.rs, and crates/minimald/src/env.rs. These paths currently fall back to std::process::id(), which can break daemon-scoped cleanup.

🤖 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 `@crates/op/src/lib.rs` around lines 13 - 19, Propagate Options.daemon_id into
every production sandbox configuration by calling with_daemon_id(...) in the
configuration flows in specs.rs, standalone_test.rs, and minimald’s env.rs. Use
the available daemon ID rather than allowing these paths to fall back to
std::process::id(), preserving daemon-scoped cleanup behavior.
🤖 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.

Outside diff comments:
In `@crates/op/src/lib.rs`:
- Around line 13-19: Propagate Options.daemon_id into every production sandbox
configuration by calling with_daemon_id(...) in the configuration flows in
specs.rs, standalone_test.rs, and minimald’s env.rs. Use the available daemon ID
rather than allowing these paths to fall back to std::process::id(), preserving
daemon-scoped cleanup behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 591235ee-10bc-4ee8-9f95-19eb0b6c9413

📥 Commits

Reviewing files that changed from the base of the PR and between 3b4e3da and 3113f7d.

📒 Files selected for processing (19)
  • crates/check/src/lib.rs
  • crates/check/src/outputs.rs
  • crates/check/src/sources.rs
  • crates/mctx/src/config.rs
  • crates/mctx/src/env.rs
  • crates/mctx/src/lib.rs
  • crates/minimald/src/env.rs
  • crates/minimald/src/server.rs
  • crates/minimald/src/session_sop.rs
  • crates/mip/src/cmd_check.rs
  • crates/mip/src/cmd_materialize.rs
  • crates/mip/src/cmd_pkg_patched_build.rs
  • crates/op/src/lib.rs
  • crates/op/src/materialize.rs
  • crates/op/src/specs.rs
  • crates/op/src/subsets.rs
  • crates/orchestrator/src/lib.rs
  • crates/orchestrator/src/local_backend.rs
  • crates/sandbox2/src/config.rs

@twitchyliquid64
twitchyliquid64 force-pushed the tom/cache branch 2 times, most recently from bd72ff5 to 7d0e35d Compare July 31, 2026 18:39

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@crates/minimald/src/session.rs`:
- Line 1427: Update the minimald test configuration built by
sessions.rs::manager() to set a test daemon ID with with_daemon_id(...) before
session tests reach workspace_config. Preserve the existing daemon_id unwrap in
session.rs, since the test configuration should provide the required value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 89b1db36-0f7e-43ef-9bae-c6ab8c779802

📥 Commits

Reviewing files that changed from the base of the PR and between 38b346b and 7d0e35d.

📒 Files selected for processing (21)
  • crates/check/src/lib.rs
  • crates/check/src/outputs.rs
  • crates/check/src/sources.rs
  • crates/mctx/src/config.rs
  • crates/mctx/src/env.rs
  • crates/mctx/src/lib.rs
  • crates/minimald/src/env.rs
  • crates/minimald/src/server.rs
  • crates/minimald/src/session.rs
  • crates/minimald/src/session_sop.rs
  • crates/mip/src/cmd_check.rs
  • crates/mip/src/cmd_materialize.rs
  • crates/mip/src/cmd_pkg_patched_build.rs
  • crates/op/src/lib.rs
  • crates/op/src/materialize.rs
  • crates/op/src/specs.rs
  • crates/op/src/standalone_test.rs
  • crates/op/src/subsets.rs
  • crates/orchestrator/src/lib.rs
  • crates/orchestrator/src/local_backend.rs
  • crates/sandbox2/src/config.rs
🚧 Files skipped from review as they are similar to previous changes (20)
  • crates/op/src/specs.rs
  • crates/mip/src/cmd_materialize.rs
  • crates/op/src/lib.rs
  • crates/minimald/src/session_sop.rs
  • crates/check/src/outputs.rs
  • crates/orchestrator/src/local_backend.rs
  • crates/mip/src/cmd_pkg_patched_build.rs
  • crates/check/src/lib.rs
  • crates/minimald/src/env.rs
  • crates/minimald/src/server.rs
  • crates/op/src/subsets.rs
  • crates/mip/src/cmd_check.rs
  • crates/sandbox2/src/config.rs
  • crates/mctx/src/env.rs
  • crates/op/src/materialize.rs
  • crates/mctx/src/config.rs
  • crates/orchestrator/src/lib.rs
  • crates/check/src/sources.rs
  • crates/mctx/src/lib.rs
  • crates/op/src/standalone_test.rs

Comment thread crates/minimald/src/session.rs
@twitchyliquid64
twitchyliquid64 merged commit 4fbbd0f into main Jul 31, 2026
30 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/cache branch July 31, 2026 19:11
@norrietaylor

Copy link
Copy Markdown
Member

Lgtm

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.

sandbox2: the sandbox leader should own its namespace, not the creating process

2 participants