Skip to content

Engine walkthrough cleanups + Cargo.toml heading harmonization#322

Open
martsokha wants to merge 4 commits into
mainfrom
cleanup/engine-walkthrough
Open

Engine walkthrough cleanups + Cargo.toml heading harmonization#322
martsokha wants to merge 4 commits into
mainfrom
cleanup/engine-walkthrough

Conversation

@martsokha

Copy link
Copy Markdown
Member

Summary

Four small quality passes from a walkthrough of `nvisy-engine`:

  1. `RecognizerParams.ner/llm` → `Option` — three-state semantics. Softly-on default (`None`) skips silently when the deployment lineup is empty; `Some(true)` is explicit opt-in and errors on empty lineup; `Some(false)` is explicit opt-out. Requests that used to send `{}` no longer explode on deployments without NER/LLM configured. Dispatch moves into `attach_ner_lineup` / `attach_llm_lineup` — per-modality entries pass the toggle through.
  2. `RecognizedGroup` methods — four free fns in `pipeline/report.rs` become methods on `RecognizedGroup`: `insert_body` → `insert_into_body`, `insert_part` → `insert_as_part`, `collect_overrides_into` stays as a method, `encode_redacted` → `encode_redacted_from`. Reads more naturally at the call site.
  3. Engine walkthrough cleanups:
    • New `impl From<elide_core::Error> for nvisy_core::Error`. `?` composes across the seam; deletes `compile_err` fn + `COMPONENT` const in `pipeline::orchestrator`; trims two `.map_err` blocks in `pipeline::mod`.
    • Remove both `#[allow(unused_mut)]` from `pipeline::orchestrator` — replaced with cfg-gated shadowing `let orchestrator = { ... }` blocks. Respects the standing no-`allow`-attrs rule.
    • Visibility harmonization: `attach_llm_lineup` → `pub(in crate::analyzer)` (matches siblings). `override_attribution` + `attach_override` in `anonymizer/compile/selector` → `pub(super)` (only used within `compile/`).
  4. Cargo.toml heading harmonization — every per-crate `[dependencies]` and `[dev-dependencies]` now uses the exact section-heading vocabulary from the workspace root: `Elide crates`, `Elide extensions`, `Internal crates`, `Serialization`, `Derive macros and error handling`, `Primitive datatypes`, `Encoding and hashing`, `Test utilities`, `Async runtime and parallelism`, `Observability`, `AI / LLM frameworks`. Same order across every crate; no per-line justification prose.

Test plan

  • CI green
  • `make rust-ci` locally (verified before push)
  • Anyone calling with `{}` (default `RecognizerParams`) against a bare deployment doesn't hit an unexpected error — softly-on default absorbs it

🤖 Generated with Claude Code

martsokha added 4 commits July 7, 2026 08:41
Wire: `ner: Option<bool>` / `llm: Option<bool>` on
`RecognizerParams`, replacing plain `bool`.

Semantics:

- `None` (default, omitted on the wire): softly-on. Attaches
  the deployment's lineup when non-empty; skips silently when
  empty. Requests that used to send `{}` no longer explode on
  deployments without NER/LLM configured.
- `Some(true)`: explicit opt-in. Attaches; errors when the
  lineup is empty (or has zero matches for the modality on
  LLM). Explicit intent surfaces the misconfiguration.
- `Some(false)`: explicit opt-out. Skips.

`attach_ner_lineup` and `attach_llm_lineup` take the toggle
directly and own the dispatch — per-modality entries just pass
`spec.recognizers.{ner,llm}` through, no more `if flag` blocks.

Rename `tests/custom_patterns.rs` → `tests/patterns.rs`.
- `insert_body(report, group)` → `group.insert_into_body(report)`
- `insert_part(report, id, group)` → `group.insert_as_part(report, id)`
- `collect_overrides_into(out, group)` → `group.collect_overrides_into(out)`
- `encode_redacted(handle, body)` → `body.encode_redacted_from(handle)`

Reads more naturally at the call site (the group is the natural
receiver — it's the polymorphic thing dispatched on). Trims the
`pipeline/mod.rs` import block: six-fn glob down to `take_body`,
`take_part`.

`take_body` / `take_part` stay free — receiver would be
elide-owned `Report`.
- **`impl From<elide_core::Error> for nvisy_core::Error`** — map
  elide's per-operation error into the runtime's shared
  vocabulary, preserving the elide `ErrorKind` semantically via
  a nearest-match onto `nvisy_core::ErrorKind`. Delete
  `pipeline::orchestrator::compile_err` and its `COMPONENT`
  const; `?` now composes across the seam. Trim two
  `.map_err(|err| Error::internal(...))` blocks in
  `pipeline::mod`. Add `elide-core` as a direct dep of
  `nvisy-core`.
- **`#[allow(unused_mut)]`** — remove both from
  `pipeline::orchestrator`. Replace the `let mut orchestrator`
  pattern with cfg-gated shadowing `let orchestrator = { ... }`
  blocks. Respects the standing no-`allow`-attrs memo.
- **Visibility harmonization** — `attach_llm_lineup` in
  `analyzer::recognizer::llm` was `pub(crate)`; siblings use
  `pub(in crate::analyzer)`. Match. `override_attribution` +
  `attach_override` in `anonymizer::compile::selector` were
  `pub(crate)` but only used within `compile/`; tighten to
  `pub(super)`.
Every per-crate `[dependencies]` (and `[dev-dependencies]`) now
uses the exact section-heading vocabulary from the workspace
root: `Elide crates`, `Elide extensions`, `Internal crates`,
`Serialization`, `Derive macros and error handling`,
`Primitive datatypes`, `Encoding and hashing`, `Test utilities`,
`Async runtime and parallelism`, `Observability`,
`AI / LLM frameworks`.

Same order across every crate; no per-line justification
comments, matching the root's shape. Dep contents unchanged
except reordering within groups.
@martsokha martsokha added chore maintenance, dependency updates, code cleanup engine redaction engine, pipeline runtime, orchestration, configuration refactor code restructuring without behavior change labels Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore maintenance, dependency updates, code cleanup engine redaction engine, pipeline runtime, orchestration, configuration refactor code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant