Skip to content

fix(cosim): the excluded crate's lockfile named neither of the last two releases - #521

Merged
doublegate merged 1 commit into
mainfrom
fix/cosim-lockfile-drift
Sep 18, 2026
Merged

doublegate merged 1 commit into
mainfrom
fix/cosim-lockfile-drift

Conversation

@doublegate

@doublegate doublegate commented Sep 18, 2026

Copy link
Copy Markdown
Owner

What

crates/rustynes-cosim/Cargo.lock pinned the first-party crates at 2.6.17
while the workspace is 2.6.19.

tag workspace cosim lock
v2.6.15 2.6.15 2.6.15 ok
v2.6.16 2.6.16 2.6.16 ok
v2.6.17 2.6.17 2.6.17 ok
v2.6.18 2.6.18 2.6.17 drift
v2.6.19 2.6.19 2.6.17 drift

Why it drifted

The crate is excluded from the workspace — which is the whole reason it needs
a committed lockfile. No workspace command reaches it, so its Cargo.toml
version is bumped by hand each release, and the hand step does not touch the
lockfile beside it. That file moves only when somebody runs cargo in that
directory.

the_excluded_crates_lockfile_is_tracked asserts the file is committed, because
without one CI re-resolves. Necessary, not sufficient: a tracked file can be
stale, and cargo rewrites a stale one on the next build — so the committed
resolve was not the resolve anything used.

How it surfaced

Not by reading the lockfile. The pinned oracle worktree under
~/.cache/rustynes-cosim/ — detached at the v2.6.18 commit, and the source the
co-simulation goldens are exported from — came up dirty during a branch
cleanup. That looked like build residue to discard. It was cargo correcting a
stale file, at a commit where the committed one was already wrong.

The fix

Refreshed with cargo metadata --manifest-path crates/rustynes-cosim/Cargo.toml
— a minimal resolve, so the diff is exactly six version lines with no
third-party churn.

The gate is the_excluded_crates_lockfile_names_the_workspace_version. It walks
[[package]] blocks rather than grepping version = , so a third-party crate
sitting at the same number cannot stand in for a first-party one that is not,
and it fails closed below five first-party entries — a parse that finds
nothing must not read as agreement.

Three mutations, all CAUGHT:

  • the file this release actually shipped (all six at 2.6.17)
  • one entry wrong, the other five correct
  • the lockfile emptied of [[package]] blocks → caught by the fail-closed
    clause, reporting only 0 first-party packages found

Baseline green afterwards, and the committed lockfile verified to read 2.6.19 at
all six entries.

Gates

cargo fmt --all --check clean · clippy clean on the harness · all 5
cosim_manifest_audit tests pass. No emulation code changes, so AccuracyCoin
144/144 and nestest 0-diff hold by construction.

🤖 Generated with Claude Code

https://claude.ai/code/session_014qfTKi2M3swo7qnwvYCkDj

Summary by CodeRabbit

  • Tests
    • Added validation ensuring first-party packages in the co-simulation lockfile use the workspace’s current version.
    • Added safeguards to detect missing, renamed, or unexpectedly structured lockfile package entries.

…wo releases

`crates/rustynes-cosim/Cargo.lock` pinned the first-party crates at 2.6.17
while the workspace was 2.6.19. The drift started one release earlier:

  v2.6.15  workspace 2.6.15  cosim lock 2.6.15  ok
  v2.6.16  workspace 2.6.16  cosim lock 2.6.16  ok
  v2.6.17  workspace 2.6.17  cosim lock 2.6.17  ok
  v2.6.18  workspace 2.6.18  cosim lock 2.6.17  DRIFT
  v2.6.19  workspace 2.6.19  cosim lock 2.6.17  DRIFT

The mechanism is the crate's exclusion, which is the whole reason it needs a
committed lockfile in the first place. No workspace command reaches an excluded
package, so its `Cargo.toml` version is bumped BY HAND at each release -- and
the hand step does not touch the lockfile beside it, which moves only when
somebody runs cargo in that directory.

`the_excluded_crates_lockfile_is_tracked` asserts the file is committed, because
without one CI re-resolves. That is necessary and not sufficient: a tracked file
can be stale, and cargo rewrites a stale one on the next build, so the committed
resolve is not the resolve anything actually uses. The tracked-ness test was
guarding the door while the contents drifted.

HOW IT SURFACED, which is the part worth keeping. It was not found by reading
the lockfile. The pinned oracle worktree at `~/.cache/rustynes-cosim/` -- checked
out detached at the v2.6.18 commit, and the source the co-simulation goldens are
exported from -- came up DIRTY during a branch cleanup, carrying an unstaged
`Cargo.lock` change. That looked like build residue to discard. It was cargo
correcting a stale file, at a commit where the committed one was already wrong.

Refreshed with `cargo metadata --manifest-path crates/rustynes-cosim/Cargo.toml`,
which is a minimal resolve: the diff is exactly six version lines, 2.6.17 ->
2.6.19, with no third-party churn.

The gate is `the_excluded_crates_lockfile_names_the_workspace_version`. It walks
`[[package]]` blocks rather than grepping `version = `, so a third-party crate
that happens to sit at the same number cannot stand in for a first-party one
that does not, and it FAILS CLOSED on fewer than five first-party entries --
a parse finding nothing must not read as agreement, which is this project's
most-repeated defect in its smallest form.

Demonstrated by three mutations, all CAUGHT:

  * the actual file this release shipped (all six at 2.6.17)
  * one entry wrong and the other five correct
  * the lockfile emptied of `[[package]]` blocks -- caught by the fail-closed
    clause rather than by the comparison, reporting "only 0 first-party
    packages found"

Baseline green, `cargo fmt --all --check` clean, clippy clean on the harness.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014qfTKi2M3swo7qnwvYCkDj
Copilot AI lite review requested due to automatic review settings September 18, 2026 04:33
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: c5448c2e-c9b7-4ac5-8e7c-3ce885275f0c

📥 Commits

Reviewing files that changed from the base of the PR and between d76b575 and d90e15e.

⛔ Files ignored due to path filters (1)
  • crates/rustynes-cosim/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • crates/rustynes-test-harness/tests/cosim_manifest_audit.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The test harness now checks that first-party packages in crates/rustynes-cosim/Cargo.lock use the version declared in the workspace manifest. It also requires at least five packages to be checked.

Changes

Lockfile Version Audit

Layer / File(s) Summary
Lockfile version consistency test
crates/rustynes-test-harness/tests/cosim_manifest_audit.rs
Adds a test that reads the workspace version, scans [[package]] blocks in the cosimulation lockfile, validates rustynes- package versions, and rejects empty or malformed results.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to d90e1

The new lockfile audit guards against version drift without an identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 9
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the cosim lockfile versioning problem and relates directly to the primary change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files.
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.
Docs-As-Spec Sync ✅ Passed PASS. The authoritative diff changes only crates/rustynes-cosim/Cargo.lock and crates/rustynes-test-harness/tests/cosim_manifest_audit.rs. It does not change code under crates/rustynes-cpu, `cra…
Changelog Entry For User-Visible Changes ✅ Passed The pull request changes only the excluded, publish = false rustynes-cosim lockfile and an audit test. It does not change runtime source, public behavior, or add a user-facing feature or fix. `CHA…
No Unwrap/Expect/Panic On Untrusted Input ✅ Passed The pull request changes only the cosim lockfile and a new integration test. The only newly added prohibited-style construct is .expect(...), and it is inside `#[test] fn the_excluded_crates_lockfil…
Safety Comment On New Unsafe Blocks ✅ Passed PASS: The pull-request range changes only crates/rustynes-cosim/Cargo.lock and crates/rustynes-test-harness/tests/cosim_manifest_audit.rs. The added Rust code introduces no unsafe { ... } block …
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions

Copy link
Copy Markdown

Antigravity review (Gemini via Ultra)

Updates the excluded rustynes-cosim crate's lockfile to match the workspace version and adds a manual TOML-parsing test to ensure they stay synchronized in the future.

Blocking issues

  • Build failure on stable Rust: The condition if let Some(v) = line.strip_prefix("version = ") && let Some(pkg) = name.take() uses the unstable let_chains feature. Unless this project is compiled strictly on nightly Rust with #![feature(let_chains)] enabled, this will result in a syntax error and fail to compile.

Suggestions

  • Fix the unstable let-chain: Replace the let-chain with a nested if let block or a boolean check (e.g., && name.is_some() followed by let pkg = name.take().unwrap();) to ensure stable compilation.
  • Brittle TOML parsing: Manually walking [[package]] blocks and string-matching name = and version = is highly fragile. Any upstream change in how Cargo formats Cargo.lock (like writing version before name, which is perfectly valid TOML) will break this test. Consider using the toml or cargo-lock crates for robust manifest auditing.

Nitpicks

  • The loop asserts checked >= 5, but the diff updates exactly 6 rustynes-* packages. Consider tightening the assertion to checked >= 6 or checked == 6 to avoid passing if a crate goes missing.
  • The explicit type annotation in let mut name: Option<&str> = None; is redundant and can be omitted.

Automated first-pass review by agy on a self-hosted runner -- not a human review.

@doublegate

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@doublegate
doublegate requested a lite review from Copilot September 18, 2026 05:12
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@doublegate
doublegate merged commit 14d5fec into main Sep 18, 2026
29 of 31 checks passed
@doublegate
doublegate deleted the fix/cosim-lockfile-drift branch September 18, 2026 05:29
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