[pitboss/grind] cleanup session-0004 (20260522T163126Z-7d60)

This commit is contained in:
pitboss 2026-05-22 13:17:28 -05:00
parent 0e4e393000
commit 0d4ab22c4c
7 changed files with 119 additions and 45 deletions

View file

@ -36,6 +36,12 @@ impl Commands {
&& (fmt == OutputFormat::Json || fmt == OutputFormat::Sarif)
}
/// Whether the user explicitly asked this invocation to suppress
/// human-readable output.
pub fn quiet_requested(&self) -> bool {
matches!(self, Commands::Scan { quiet: true, .. })
}
/// Whether this is a long-running server command (skip timing output).
pub fn is_serve(&self) -> bool {
matches!(self, Commands::Serve { .. })

View file

@ -14,10 +14,16 @@ use tracing_subscriber::{EnvFilter, Registry, fmt as tracing_fmt};
// use tracing_appender::rolling::{RollingFileAppender, Rotation};
// use tracing_appender::non_blocking;
fn init_tracing() {
fn init_tracing(quiet: bool) {
// let file_appender = RollingFileAppender::new(Rotation::HOURLY, "logs", "nyx-scanner.log");
// let (file_writer, guard) = non_blocking(file_appender);
let filter = if quiet {
EnvFilter::new("off")
} else {
EnvFilter::from_default_env()
};
let fmt_layer = tracing_fmt::layer()
.pretty()
.with_writer(std::io::stderr)
@ -29,17 +35,11 @@ fn init_tracing() {
// .without_time()
// .json();
Registry::default()
.with(EnvFilter::from_default_env())
.with(fmt_layer)
.init();
Registry::default().with(filter).with(fmt_layer).init();
}
fn main() -> NyxResult<()> {
let now = Instant::now();
init_tracing();
tracing::debug!("CLI starting up");
if std::env::args().count() == 1 {
eprint!("{}", fmt::render_welcome());
@ -60,6 +60,10 @@ fn main() -> NyxResult<()> {
let (mut config, config_note) = Config::load(config_dir)?;
let explicit_quiet = config.output.quiet || cli.command.quiet_requested();
init_tracing(explicit_quiet);
tracing::debug!("CLI starting up");
rayon::ThreadPoolBuilder::new()
.stack_size(config.performance.rayon_thread_stack_size)
.build_global()
@ -67,7 +71,7 @@ fn main() -> NyxResult<()> {
let is_serve = cli.command.is_serve();
let is_info = cli.command.is_informational();
let quiet = config.output.quiet || cli.command.is_structured_output(&config);
let quiet = explicit_quiet || cli.command.is_structured_output(&config);
// Print config note before scanning (human-readable mode only). Pure
// informational commands suppress it too, their output is usually

View file

@ -788,6 +788,7 @@ impl GlobalSummaries {
.wrapping_mul(0x9E37_79B9)
.wrapping_add(probe);
key.disambig = Some(SYNTHETIC_DISAMBIG_BIT | (synth & !SYNTHETIC_DISAMBIG_BIT));
key.arity = Some(body.param_count);
probe = probe.wrapping_add(1);
if probe >= 1024 {
tracing::warn!(

View file

@ -3272,27 +3272,17 @@ fn insert_body_param_count_mismatch_rekeys() {
assert_eq!(head.param_count, 2);
// Invariant 2: the conflicting body is preserved under a synthetic
// disambig, not dropped. Reconstruct the expected synth disambig
// using the same formula as `reconcile_body_key`.
let mut found_conflicting = false;
// disambig at its own arity, not dropped.
let base = (4u32).wrapping_mul(0x9E37_79B9);
for probe in 0u32..1024 {
let synth = base.wrapping_add(probe);
let synth_key = FuncKey {
disambig: Some(0x8000_0000 | (synth & 0x7FFF_FFFF)),
..key.clone()
};
if let Some(body) = gs.get_body(&synth_key)
&& body.param_count == 4
{
found_conflicting = true;
break;
}
}
assert!(
found_conflicting,
"the 4-param body must be preserved under a synthetic disambig key"
);
let synth_key = FuncKey {
arity: Some(4),
disambig: Some(0x8000_0000 | (base & 0x7FFF_FFFF)),
..key.clone()
};
let conflicting = gs
.get_body(&synth_key)
.expect("the 4-param body must be preserved under a synthetic disambig key");
assert_eq!(conflicting.param_count, 4);
}
#[test]

View file

@ -1940,18 +1940,10 @@ pub(crate) fn extract_intra_file_ssa_summaries(
Err(_) => continue,
};
// Param count = number of formal params (from CFG), falling back to
// counting all SsaOp::Param ops when no local summary is available.
let param_count = if !formal_params.is_empty() {
formal_params.len()
} else {
func_ssa
.blocks
.iter()
.flat_map(|b| b.phis.iter().chain(b.body.iter()))
.filter(|i| matches!(i.op, crate::ssa::ir::SsaOp::Param { .. }))
.count()
};
// `formal_params` is authoritative even when it is empty. SSA lowering
// also emits Param ops for external captures; counting those as arity
// makes zero-arg functions look like synthetic overloads.
let param_count = formal_params.len();
// Zero-param helpers are normally elided, a fixture with no
// parameters cannot carry per-parameter taint transforms. But