diff --git a/.cargo/mutants.toml b/.cargo/mutants.toml index 7951f67..bb2007b 100644 --- a/.cargo/mutants.toml +++ b/.cargo/mutants.toml @@ -8,6 +8,8 @@ # - Infallible header parsing and multipart byte collection: adjacent public tests # prove exact ETag/runtime headers and streamed multipart errors; unwrap mutants # are behaviorally equivalent at these validated boundaries. +# - hemx-build source inspection delegates to hemplate's currently infallible +# Surface parser; file I/O and invalid Rust-context errors remain explicitly proven. exclude_re = [ "test_process_try_wait", "test_process_poll_delay", @@ -20,4 +22,7 @@ exclude_re = [ "replace String::from_utf8.* with String::from_utf8.*unwrap\\(\\) in InteractionForm::parse_multipart", "replace HeaderValue::from_str.*runtime_js_hash.* with HeaderValue::from_str.*unwrap\\(\\) in ::into_response", 'replace "runtime hash is a valid ETag" with "" in ::into_response', + "replace surface_for_heml_source.* with surface_for_heml_source.*unwrap\\(\\) in diagnostics_for_heml_source", + "replace surface_for_heml_source.* with surface_for_heml_source.*unwrap\\(\\) in generated_targets_for_heml_source", + "replace surface_for_heml_source.* with surface_for_heml_source.*unwrap\\(\\) in template_context_facts_for_heml_source", ] diff --git a/PLAN.md b/PLAN.md index 464f5b4..7ef1f6e 100644 --- a/PLAN.md +++ b/PLAN.md @@ -21,7 +21,7 @@ - [ ] **State:** In progress — the package-native capped xtask entry point is reachable, rejects unknown packages, propagates mutest failure, and mutation-tests `hemx-axum`, `hemx-core`, `hemx-js`, and the full `hemx-test` package cleanly; full package closure remains. - **User value:** maintainers can run one bounded repository command and trust that meaningful Rust logic across every mutation-applicable library is either killed or explicitly justified. - **Build:** add a capped `hemx-xtask` mutation command that invokes `/opt/repositories/mutest`/`mutest` through package-native test targets rather than the broken workspace-wide example path; enumerate only current mutation-applicable library/proc-macro packages; finish adversarial tests or simplify code until every survivor is classified; keep equivalent, invariant-only, and infrastructure-inapplicable classifications inspectable and minimal; document the exact local release command in the existing readiness surface. -- **Blocked by:** none; broad survivors currently remain in `hemx-build`, `hemx-derive`, and `hemx-lsp` outside already-clean focused contracts. The current `hemx-build` slice now adversarially proves policy, client-module/event/state, confirmation, SSE, delay, throttle, and mixed-event diagnostics; remaining generated-resource and diagnostic-contract survivors remain. The complete 470-mutant `hemx-axum` package gate now passes with 262 caught and 208 unviable after public page/form/multipart/registry/response/runtime proofs and narrow classification of infallible header parsing and streamed multipart unwrap-equivalent mutants. +- **Blocked by:** none; broad survivors currently remain in `hemx-build`, `hemx-derive`, and `hemx-lsp` outside already-clean focused contracts. The current `hemx-build` frontier now adversarially proves static convention diagnostics plus public file/source diagnostics, generated-target extraction, Hemlate-derived context facts, missing-file propagation, and invalid Rust-context diagnostics mutation-clean; remaining generated-resource and internal diagnostic survivors remain. The complete 470-mutant `hemx-axum` package gate now passes with 262 caught and 208 unviable after public page/form/multipart/registry/response/runtime proofs and narrow classification of infallible header parsing and streamed multipart unwrap-equivalent mutants. - **Proof:** the new xtask mutation command exits zero within its documented bound, covers each applicable package, emits no unexplained missed mutant, and a deliberate adjacent mutation makes it fail. `cargo run -p hemx-xtask -- test` remains green. req: test/020 req: test/021 ## 3. Elect and enforce the release license policy diff --git a/hemx-build/src/lib.rs b/hemx-build/src/lib.rs index b796a22..7798de9 100644 --- a/hemx-build/src/lib.rs +++ b/hemx-build/src/lib.rs @@ -2326,6 +2326,93 @@ fn parse_error(path: &Path, err: impl std::fmt::Display) -> io::Error { mod tests { use super::*; + #[test] + fn public_heml_inspection_entry_points_preserve_paths_and_io_diagnostics() { + let root = std::env::temp_dir().join(format!( + "hemx-build-inspection-{}-{}", + std::process::id(), + std::thread::current().name().unwrap_or("test") + )); + std::fs::create_dir_all(&root).unwrap(); + let template = root.join("card.heml"); + let source = r#""#; + std::fs::write(&template, source).unwrap(); + + let from_source = diagnostics_for_heml_source(&template, source.to_owned()).unwrap(); + let from_file = diagnostics_for_heml_file(&template).unwrap(); + assert_eq!(from_file, from_source); + assert_eq!(from_source.len(), 1); + assert_eq!(from_source[0].file, template); + assert_eq!(from_source[0].directive, "data-hemx-handle"); + + let targets = generated_targets_for_heml_source( + &template, + r#"
"#, + ) + .unwrap(); + assert_eq!(targets.len(), 1); + assert_eq!(targets[0].name, "save"); + assert_eq!( + template_context_facts_for_heml_source( + &template, + "
{{ self.title }}
".to_owned(), + ) + .unwrap(), + None + ); + let crate_root = root.join("crate"); + let templates = crate_root.join("templates"); + std::fs::create_dir_all(crate_root.join("src")).unwrap(); + std::fs::create_dir_all(&templates).unwrap(); + std::fs::write( + crate_root.join("Cargo.toml"), + "[package]\nname='facts'\nversion='0.0.0'\n", + ) + .unwrap(); + std::fs::write( + crate_root.join("src/lib.rs"), + "#[derive(Hemplate)] struct Profile { title: String }\nstruct Plain { title: String }", + ) + .unwrap(); + let profile = templates.join("profile.heml"); + let facts = template_context_facts_for_heml_source( + &profile, + "
{{ self.title }}
".to_owned(), + ) + .unwrap() + .expect("Hemlate-derived context facts"); + assert_eq!(facts.context_type, "Profile"); + assert_eq!(facts.self_fields[0].name, "title"); + std::fs::write(crate_root.join("src/broken.rs"), [0xff]).unwrap(); + assert_eq!( + template_context_facts_for_heml_source( + &profile, + "
{{ self.title }}
".to_owned(), + ) + .unwrap_err() + .kind(), + io::ErrorKind::InvalidData + ); + std::fs::remove_file(crate_root.join("src/broken.rs")).unwrap(); + assert_eq!( + template_context_facts_for_heml_source( + templates.join("plain.heml"), + "
{{ self.title }}
".to_owned(), + ) + .unwrap(), + None + ); + let missing = root.join("missing.heml"); + for error in [ + diagnostics_for_heml_file(&missing).unwrap_err(), + template_context_facts_for_heml_file(&missing).unwrap_err(), + ] { + assert_eq!(error.kind(), io::ErrorKind::NotFound); + } + let _ = std::fs::remove_dir_all(root); + // test req: diagnostics/004 req: diagnostics/006 req: surface/008 + } + #[test] fn generated_contract_fingerprint_and_client_bootstrap_are_deterministic() { let resource = |symbol: &str, component: &str, id| Resource {