Skip to content

fix(stella-cli): resolve the current self-driving root through stella-home too - #1877

Merged
macanderson merged 2 commits into
mainfrom
fix-current-root-duplicate
Aug 6, 2026
Merged

fix(stella-cli): resolve the current self-driving root through stella-home too#1877
macanderson merged 2 commits into
mainfrom
fix-current-root-duplicate

Conversation

@macanderson

@macanderson macanderson commented Aug 6, 2026

Copy link
Copy Markdown
Owner

What & why

Refs #1755

#1810 factored the legacy self-driving roots into stella-home so the writer and the read-only reader could not drift, and moved stella-observatory onto stella_home::self_driving_root for the current one — but left LoopState::open building its own:

let dir = home.join("self-driving").join(&slug);

Half the job. The current root — the one every live loop actually uses — was still two literals in two crates:

$ git grep -n 'self_driving_root()' -- crates/
crates/stella-home/src/lib.rs:181:pub fn self_driving_root() ...
crates/stella-observatory/src/self_driving.rs:73:    roots.extend(stella_home::self_driving_root());
                                                    ^ only the reader used it

That is the exact shape #1755 was filed for. Renaming the directory in one of them would point the dashboard at nothing, and the failure is silent — an empty Self-Driving tab reads as "no runs on this machine", never as "the reader is looking in the wrong place". I introduced this in #1810, so it is mine to close.

The witness

  • This PR includes a witness test.

the_current_root_comes_from_the_shared_resolver pins that the shared resolver still yields the directory this crate writes and the observatory reads — the twin of the existing the_writer_and_the_reader_agree_on_the_legacy_roots.

The migration test helper keeps its own hard-coded literal deliberately: a test that re-derives the expected path from the code under test cannot catch a change to it. The tests state the path; the code resolves it.

The gate

  • cargo test -p stella-cli --bin stella self_driving_cmd::state — 7 / 7
  • cargo fmt --check — clean
  • cargo clippy -p stella-cli --all-targets -- -D warnings — clean for this crate

Workspace clippy currently fails on stella-pipeline (clone_on_copy in witness_stage.rs:55), which is pre-existing on main and already covered by #1873 and #1859. Not touched here.

Nothing left behind

Nothing new. main is currently red on three fronts, all with fixes in flight: the clippy error above (#1873/#1859), the file-size baseline skew and the stale gate-parity count (both in #1845; #1863 carries the same count fix).

Summary by Sourcery

Unify resolution of the current self-driving state root in stella-cli with the shared stella-home resolver to prevent drift between writer and reader paths.

Bug Fixes:

  • Use the shared stella-home self-driving root resolver in LoopState::open instead of constructing the path manually, ensuring the CLI and observatory agree on the current state directory.

Tests:

  • Add a regression test that pins the current self-driving root produced by the shared resolver to the directory used by stella-cli and read by stella-observatory.

…-home too

#1810 factored the LEGACY roots into `stella-home` so the writer and the
read-only reader could not drift, and moved `stella-observatory` onto
`stella_home::self_driving_root` for the current one — but left
`LoopState::open` building `home.join("self-driving")` itself. Half the job:
the current root, the one every live loop actually uses, was still two literals
in two crates.

That is the exact shape #1755 was filed for. Renaming the directory in one of
them would point the dashboard at nothing, and the failure is silent — an empty
Self-Driving tab reads as "no runs", never as "the reader is looking in the
wrong place".

Witness: `the_current_root_comes_from_the_shared_resolver` pins that the shared
resolver still yields the directory this crate writes and the observatory
reads. The test helper keeps its own literal deliberately — a test that
re-derives the expected path from the code under test cannot catch a change to
it.

Refs #1755

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry @macanderson, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
stella-cli-docs Ignored Ignored Preview Aug 6, 2026 6:37pm

@sourcery-ai

sourcery-ai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Routes stella-cli’s self-driving state root resolution through the shared stella-home resolver instead of a hard-coded path, and adds a test to pin that the current root still matches the literal used in migration tests and stella-observatory.

Sequence diagram for shared self-driving root resolution in LoopState::open

sequenceDiagram
    participant LoopState
    participant stella_home
    participant Filesystem

    LoopState->>stella_home: stella_home::stella_home()
    stella_home-->>LoopState: Option<PathBuf> home
    LoopState->>LoopState: repo_slug(repo_root) -> slug
    LoopState->>stella_home: resolve_self_driving_root(Some(home.clone()))
    stella_home-->>LoopState: Option<PathBuf> self_driving_root
    LoopState->>LoopState: self_driving_root.join(slug) -> dir
    LoopState->>Filesystem: migrate_legacy_state(dir, slug, home)
    LoopState-->>LoopState: use dir as self-driving state root
Loading

File-Level Changes

Change Details Files
Use the shared stella-home self-driving root resolver for LoopState::open instead of constructing the path manually.
  • Replace direct construction of the self-driving directory with a call to stella_home::resolve_self_driving_root, propagating failure with a dedicated error message.
  • Pass the resolved self-driving root (joined with the repo slug) into migrate_legacy_state so that migrations and writers use the same root as the reader.
  • Retain use of stella_home::stella_home() as the base home directory input to the resolver.
crates/stella-cli/src/self_driving_cmd/state.rs
Add a witness test to pin the current self-driving root path to the shared resolver’s behavior.
  • Introduce the_current_root_comes_from_the_shared_resolver test to assert that resolve_self_driving_root(Some(home)) yields home.join("self-driving").
  • Use a hard-coded home path in the test to avoid deriving expectations from the implementation, ensuring changes in path spelling are caught.
  • Document in comments the two-readers drift problem and how this test guards against silent misalignment between writer and reader.
crates/stella-cli/src/self_driving_cmd/state.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@macanderson
macanderson merged commit c7424fa into main Aug 6, 2026
4 checks passed
@macanderson
macanderson deleted the fix-current-root-duplicate branch August 6, 2026 19:05
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.

1 participant