Guard Mail Query

Search / fetch / changes filter validator for b.mail.agent. Refuses filter shapes that can't safely cross the worker-thread or queue boundary (functions, regex objects with state, Date objects with non-finite values, cycles), enforces a projection-column allowlist against the mail-store schema, and pins the per-actor fields that the active compliance posture requires (HIPAA → purposeOfUse; PCI-DSS → pciScope; GDPR → lawfulBasis).

Composes b.guardJson (via validate(JSON.stringify(filter))-shape guard) at the structural level and adds mail-specific rules: the filter is recursively walked once with a depth cap, no operator key is allowed outside the documented set, and any field-name used as a comparator key must be in FILTERABLE_COLUMNS.

b.guardMailQuery.validate(filter, opts?) #

stable0.9.20
{
  profile:    "strict" | "balanced" | "permissive",   // default "strict"
  posture:    "hipaa" | "pci-dss" | "gdpr" | "soc2",  // pins strict
  project:    Array,                           // projection columns
}

Validate a filter spec. Returns the input on success; throws GuardMailQueryError on refusal.

b.guardMailQuery.validate({ and: [{ modseq: { gt: 0 } }, { flag: { eq: "\\Seen" } }] });

b.guardMailQuery.validateActor(actor, posture?) #

stable0.9.20

Validate that actor carries the per-posture required fields. Returns actor on success; throws on missing field.

b.guardMailQuery.validateActor({ id: "u1", roles: ["clinician"], purposeOfUse: "TREATMENT" }, "hipaa");

b.guardMailQuery.compliancePosture(name) #

stable0.9.20hipaapci-dssgdprsoc2

Return the effective profile NAME for a compliance posture, or null for a name this parser does not map. Unlike the content-guard variant this returns the resolved profile string (every line-protocol parser composes gateContract.ALL_STRICT_POSTURES, so "hipaa" / "pci-dss" / "gdpr" / "soc2" all resolve to "strict") and never throws — the parser shape carries no overlay-clone, no buildProfile, and no loadRulePack. Wired by gateContract.defineParser.

b.guardMailQuery.compliancePosture("hipaa");                   // → "strict"
b.guardMailQuery.compliancePosture("not-a-regime");            // → null

Last updated 2026-08-08T16:39:49.652Z by seeder.