You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrate Netsuke to the Polonius alpha borrow-checking analysis
(-Zpolonius=next) and use the migration to evolve internal APIs towards a
borrow-centric ownership model.
Netsuke is a pre-1.0 application, so this should use Mode E: model
evolution, not stop at enabling a compiler flag. The goal is to replace
NLL-shaped owned-value APIs with natural reference-returning forms where
Polonius removes a lifetime limitation, while retaining ownership where
aliasing, suspension points, thread/process boundaries, or persistent identity
require it.
Deployment posture
Adopt Polonius now:
Pin a dated nightly toolchain.
Enable -Zpolonius=next for Cargo, CI, and rust-analyzer.
Reconcile the current stable/MSRV CI policy and rust-version = "1.89.0"
metadata with a nightly-only, Polonius-dependent source tree.
Record the compiler-policy decision in an ADR and update build, contributor,
and release documentation.
Audit and model evolution
Run the nll-to-polonius two-pass audit and classify every candidate with the
compiler as the oracle:
For each change, verify it both with and without -Zpolonius=next so the
tracking document distinguishes genuine Polonius-dependent designs from
improvements that already compile under NLL.
The existing audit identifies an initial evolution target in src/graph_view/mod.rs: the three entry(path.clone()).or_insert(...) sites
should be routed through a node-path registry accessor that returns &mut NodeKind, performs one lookup on hits, and clones a path only on insertion.
The action hash in src/ir/from_manifest_support.rs is a deliberate refusal:
the hash is persistent IR identity, so it should remain owned unless callers
develop a demonstrated need for the canonical interned value. Record it as POLONIUS-REFUSED(id-is-data) rather than converting ids indiscriminately.
Documentation and sequencing
Land one owning API evolution per atomic commit, migrating call sites before
deleting superseded APIs.
Add docs/polonius.md with rewritten sites, API evolution targets,
stabilization candidates, and principled refusals.
Tag source sites with POLONIUS(...), POLONIUS-CANDIDATE(...), or POLONIUS-REFUSED(...) as appropriate.
Add anti-regression guidance to AGENTS.md so direct borrow-centric forms are
not rewritten into double lookups, defensive clones, or id indirection.
Update README.md, docs/developers-guide.md, docs/netsuke-design.md, the
changelog, and docs/contents.md with the new toolchain and design contract.
Acceptance criteria
A dated nightly is pinned and Cargo, CI, and rust-analyzer consistently
enable -Zpolonius=next.
An ADR explicitly resolves the stable/MSRV, package metadata, and release
consequences of adopting a nightly-only borrow checker.
The complete two-pass audit is recorded in docs/polonius.md, including
refusals for permanent ownership constraints.
The graph_view node registry uses the borrow-returning, clone-on-miss
accessor and its Polonius dependency is compiler-verified.
Each evolution is checked with and without the Polonius flag, then covered
by the unchanged behavioural test suite.
No test behaviour is weakened merely to accommodate ownership changes.
Clone counts and clone-modify-writeback findings are recorded before and
after the migration.
make check-fmt, make lint, make test, make markdownlint, and make nixie pass under the adopted toolchain contract.
Summary
Migrate Netsuke to the Polonius alpha borrow-checking analysis
(
-Zpolonius=next) and use the migration to evolve internal APIs towards aborrow-centric ownership model.
Netsuke is a pre-1.0 application, so this should use Mode E: model
evolution, not stop at enabling a compiler flag. The goal is to replace
NLL-shaped owned-value APIs with natural reference-returning forms where
Polonius removes a lifetime limitation, while retaining ownership where
aliasing, suspension points, thread/process boundaries, or persistent identity
require it.
Deployment posture
Adopt Polonius now:
-Zpolonius=nextfor Cargo, CI, and rust-analyzer.rust-version = "1.89.0"metadata with a nightly-only, Polonius-dependent source tree.
and release documentation.
Audit and model evolution
Run the
nll-to-poloniustwo-pass audit and classify every candidate with thecompiler as the oracle:
indirection, clone-modify-writeback, eager error context, snapshot
collection, and clone hotspots.
For each change, verify it both with and without
-Zpolonius=nextso thetracking document distinguishes genuine Polonius-dependent designs from
improvements that already compile under NLL.
The existing audit identifies an initial evolution target in
src/graph_view/mod.rs: the threeentry(path.clone()).or_insert(...)sitesshould be routed through a node-path registry accessor that returns
&mut NodeKind, performs one lookup on hits, and clones a path only on insertion.The action hash in
src/ir/from_manifest_support.rsis a deliberate refusal:the hash is persistent IR identity, so it should remain owned unless callers
develop a demonstrated need for the canonical interned value. Record it as
POLONIUS-REFUSED(id-is-data)rather than converting ids indiscriminately.Documentation and sequencing
deleting superseded APIs.
docs/polonius.mdwith rewritten sites, API evolution targets,stabilization candidates, and principled refusals.
POLONIUS(...),POLONIUS-CANDIDATE(...), orPOLONIUS-REFUSED(...)as appropriate.AGENTS.mdso direct borrow-centric forms arenot rewritten into double lookups, defensive clones, or id indirection.
README.md,docs/developers-guide.md,docs/netsuke-design.md, thechangelog, and
docs/contents.mdwith the new toolchain and design contract.Acceptance criteria
enable
-Zpolonius=next.consequences of adopting a nightly-only borrow checker.
docs/polonius.md, includingrefusals for permanent ownership constraints.
graph_viewnode registry uses the borrow-returning, clone-on-missaccessor and its Polonius dependency is compiler-verified.
by the unchanged behavioural test suite.
after the migration.
make check-fmt,make lint,make test,make markdownlint, andmake nixiepass under the adopted toolchain contract.References
src/graph_view/mod.rssrc/ir/from_manifest_support.rsrust-toolchain.toml.github/workflows/ci.ymldocs/netsuke-design.mddocs/developers-guide.md