kindling-service 0.1.0

In-process orchestration layer for kindling memory: capsules, observations, retrieval and pins.
Documentation
//! Content filtering for kindling observations.
//!
//! Secret masking, length truncation, excluded-path filtering. Owned by the
//! server side (daemon) so non-Rust consumers cannot accidentally bypass the
//! redactions.
//!
//! The canonical behaviour reference is the production hook filter at
//! `plugins/kindling-claude-code/hooks/lib/filter.js` (this is what the Rust
//! hook path replaces in PORT-015); the excluded-path rules come from
//! `packages/kindling-adapter-claude-code/src/claude-code/filter.ts`, which
//! has no equivalent in the hook filter. Snapshot tests in
//! `tests/node_fixtures.rs` pin the output byte-for-byte against fixtures
//! generated by the actual Node.js implementations.

mod paths;
mod secrets;
mod tools;
mod truncate;

pub use paths::is_excluded_path;
pub use secrets::{contains_secrets, mask_secrets};
pub use tools::{filter_tool_result, is_noisy_tool, should_capture_tool};
pub use truncate::{truncate, MAX_CONTENT_LENGTH, NOISY_TOOL_MAX_LENGTH};

/// Filter content with all safety rules: mask secrets when detected, then
/// truncate to [`MAX_CONTENT_LENGTH`]. Mirrors `filterContent` in the
/// Node.js hook filter.
pub fn filter_content(content: &str) -> String {
    let filtered = if contains_secrets(content) {
        mask_secrets(content)
    } else {
        content.to_string()
    };
    truncate(&filtered, MAX_CONTENT_LENGTH)
}