code_passenger 0.2.0 — scans a workspace with klepto, then does the writing klepto never does:
feature gates, cargo edits, headers, reports.
the feature-gating loop (new in 0.2.0)
write a spec that says what you want the feature model to look like:
# klepto.toml — move `beta` behind a feature `b` in package `app`
[]
= ["beta"]
= []
[]
= ["dep:beta"]
then:
# what would change (plan + diff), nothing written
# CI: exit 1 while there is gating left to do
# prove it with real `cargo check` on a scratch copy, then write it
what happens:
- klepto plans the gates: every use of
betathat is not already behindfeature = "b"gets a#[cfg(feature = "b")]on its carrier, and everything that depends on those carriers gets one too (the cascade). - the cargo oracle copies the tree to a scratch dir (minus
target,.git,.passenger), applies the plan there, and runscargo checkfor every feature combination that matters. errors the plan missed come back as forced gates; it goes again until everything compiles. - only then, and only with
--write, the real files change:#[cfg]lines above the items (an existing#[cfg(unix)]becomes#[cfg(all(unix, feature = "b"))], never two attributes stacked) andCargo.tomledits throughtoml_editso your formatting survives.
exit codes: 0 nothing to do or converged, 1 --check found work or
the oracle gave up, 2 something a person has to decide (the plan lists
it under unknown / human). nothing is written on 1 or 2.
review before you gate
--json on any of them prints the structure instead of the text.
the rest of klepto, on the command line
the default lint policy denies ungated dependency uses (KLEP010) and cfg-edge violations (KLEP011) and allows the noisy info rules. a policy file looks like:
[]
= "deny" # unreferenced private items fail the build
= "allow"
[]
= 0 # no unwrap in public API
the original job: headers
check out report.json, it was made by doing this:
if you wanna see the crate it was made from, go check out:
https://github.com/jameshuntt/classified
it is designed to make file headers and documentations that explains itself
it is intended to be a templating engine for max flexibility
intended to produce things like this on command:
//! ----------------------------------------------
//! DOCUMENT DETAILS -----------------------------
//!
//! filename:thread_pool_manager.rs
//! description:
//! usages:none in crate yet
//!
//! ----------------------------------------------
//! FEATURE NOTES --------------------------------
//!
//! feature_name:async
//! deps:[tokio][async_trait]
//! scope:[impl ThreadPoolManager]
//! corpus:true
//!
//! feature_name:std
//! deps:[std]
//! scope:[impl ThreadPoolManager]
//! corpus:false
//!
//! ----------------------------------------------
//! CORPUS FEATURES ------------------------------
//!
#![cfg(feature = "async")]
#![cfg(feature = "std")]
scan, annotate, scaffold and passenger (the checkpoint store) are
unchanged in 0.2.0.
notes
- klepto is a path dependency until klepto 0.2.0 is on crates.io.
- the oracle runs
cargooffline; path dependencies only, nothing is downloaded and nothing outside the scratch copy is touched. - the rules every command follows, with the fixture and tests that pin
them, are in
the gate rules (cited in the source)andtests/gate.rs.