test(workspace): add direct regression tests for scoped_to_user rebinding (#1652) - #1875
Conversation
…ding (nearai#1652) - Verify primary user_id switches correctly and original workspace is unchanged - Verify private memory layers rescope to new user while shared layers stay intact - Verify secondary read scopes are preserved exactly and old primary is removed with no duplicates - Verify identity reads via both read_primary() and read() pin to new primary, not old or shared scopes - Verify non-identity reads still span preserved shared scopes after old primary removal - Verify bootstrap flags (pending + completed) preserve on same-user rebind and reset on different-user rebind - Establish precondition probes to ensure bootstrap reset tests validate true→false, not default false
There was a problem hiding this comment.
Code Review
This pull request adds a comprehensive suite of regression tests in tests/workspace_scoped_rebind.rs to verify the behavior of Workspace::scoped_to_user(). The tests cover primary user ID changes, layer rescoping, read scope preservation, and bootstrap flag management. A review comment identifies a brittle implementation reference in a code comment and suggests a more descriptive alternative for better maintainability.
| "read_primary must return exactly the new primary's identity" | ||
| ); | ||
|
|
||
| // read — identity paths get special primary-only treatment (mod.rs:665). |
There was a problem hiding this comment.
Referencing a specific line number in another file (mod.rs:665) makes this comment brittle and hard to maintain. If src/workspace/mod.rs changes, this reference will become outdated and misleading. It's better to describe the behavior itself rather than pointing to a specific line of implementation.
| // read — identity paths get special primary-only treatment (mod.rs:665). | |
| // read — identity paths are specially handled to read from the primary scope only. |
zmanian
left a comment
There was a problem hiding this comment.
Well-structured regression tests for scoped_to_user rebinding. 7 focused tests covering user ID change, layer rescoping, identity pinning, and bootstrap flag behavior. Test-only, zero production changes. Good.
|
can it merge? |
Code reviewFound 2 issues:
43: fn assert_no_duplicates(scopes: &[String]) {
177: // read — identity paths get special primary-only treatment (mod.rs:665). Assessment: This is a well-structured regression test suite for
Zero production code changes, no security issues, no blocking logic errors. The reported issues are cosmetic — an uninformative error message and a stale comment reference. |
…ding (#1652) (#1875) - Verify primary user_id switches correctly and original workspace is unchanged - Verify private memory layers rescope to new user while shared layers stay intact - Verify secondary read scopes are preserved exactly and old primary is removed with no duplicates - Verify identity reads via both read_primary() and read() pin to new primary, not old or shared scopes - Verify non-identity reads still span preserved shared scopes after old primary removal - Verify bootstrap flags (pending + completed) preserve on same-user rebind and reset on different-user rebind - Establish precondition probes to ensure bootstrap reset tests validate true→false, not default false
…ding (nearai#1652) (nearai#1875) - Verify primary user_id switches correctly and original workspace is unchanged - Verify private memory layers rescope to new user while shared layers stay intact - Verify secondary read scopes are preserved exactly and old primary is removed with no duplicates - Verify identity reads via both read_primary() and read() pin to new primary, not old or shared scopes - Verify non-identity reads still span preserved shared scopes after old primary removal - Verify bootstrap flags (pending + completed) preserve on same-user rebind and reset on different-user rebind - Establish precondition probes to ensure bootstrap reset tests validate true→false, not default false
…ding (nearai#1652) (nearai#1875) - Verify primary user_id switches correctly and original workspace is unchanged - Verify private memory layers rescope to new user while shared layers stay intact - Verify secondary read scopes are preserved exactly and old primary is removed with no duplicates - Verify identity reads via both read_primary() and read() pin to new primary, not old or shared scopes - Verify non-identity reads still span preserved shared scopes after old primary removal - Verify bootstrap flags (pending + completed) preserve on same-user rebind and reset on different-user rebind - Establish precondition probes to ensure bootstrap reset tests validate true→false, not default false
Summary
Change Type
Linked Issue
Closes #1652
Validation
cargo fmt --all -- --checkcargo clippy --all --benches --tests --examples --all-features -- -D warningscargo buildcargo test --features integrationif database-backed or integration behavior changedreview-prorpr-shepherd --fixwas run before requesting reviewSecurity Impact
None.
Database Impact
None.
Blast Radius
tests/workspace_scoped_rebind.rsRollback Plan
Delete
tests/workspace_scoped_rebind.rs.Review Follow-Through
#![cfg(feature = "libsql")]—cargo testalone will not run themscoped_to_user(), this file should be extendedReview track:
A