You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What exact public frontmatter shape, validation rules, and matcher algebra should expose fileContains while preserving compatibility with existing rule files? Incorporate the map’s standing preferences for OR literals, AND composition across matcher types, standalone use, case sensitivity, empty values, duplicates, and same-observation correlation.
The fileContains public contract, settled against the map's standing preferences and the current parser/matcher behavior:
Field syntax
Accepts a single YAML string scalar (shorthand for one literal) or a string array of literals: fileContains: "TODO" ≡ fileContains: ["TODO"].
OR semantics across literals: the content check passes when any literal matches.
Non-string, non-array YAML values (number, boolean, map) are invalid entries and are dropped, matching the existing per-entry leniency in extractStringArray.
Normalization and validation (fail-closed)
Each literal is trimmed; entries empty after trimming are dropped; exact (case-sensitive) duplicates are deduplicated. "Foo" and "foo" remain distinct literals.
Empty literals are invalid: if the field is declared but yields no valid literal (empty scalar, null, or every entry empty/invalid), the condition fails closed — the rule never matches and a warning is logged. It must not silently degrade to unconditional injection. This is deliberately stricter than today's fail-open behavior for unparseable frontmatter.
Matching semantics
Case-sensitive literal substring test (includes) on the observation text. Spans lines naturally; no glob, regex, or anchor syntax — regex metacharacters are matched literally.
Composition: file-observation family
globs and fileContains form a file-observation family that always composes with AND over the same single successful file observation: the observation's path matches a glob AND the same observation's text contains a literal. The family counts as one condition check inside the existing match: any|all algebra.
fileContains without globs is a family of one: content alone, no path condition (standalone use, per the standing preference).
Backward compatible: rules without fileContains behave exactly as today. Other fields remain flat checks. Example: globs + fileContains + keywords under match: any evaluates as (globs AND fileContains) OR keywords.
Path and content must come from the same normalized observation of the same successful tool event; no cross-event joins or historical replay. Observation normalization mechanics are Define normalized file observations across supported tools #42's scope.
Spec obligations surfaced
The specification must document field syntax with examples, fail-closed validation, and the family algebra (including the (globs AND fileContains) OR keywords example), and enumerate doc surfaces to update in the same change: README matcher sections, docs/rules.md, skills/crafting-rules/SKILL.md.
No migration needed for existing rule files; compatibility is preserved by construction.
Activity
frap129 commentedon Aug 29, 2026
Resolution
The
fileContainspublic contract, settled against the map's standing preferences and the current parser/matcher behavior:Field syntax
fileContains: "TODO"≡fileContains: ["TODO"].extractStringArray.Normalization and validation (fail-closed)
"Foo"and"foo"remain distinct literals.null, or every entry empty/invalid), the condition fails closed — the rule never matches and a warning is logged. It must not silently degrade to unconditional injection. This is deliberately stricter than today's fail-open behavior for unparseable frontmatter.Matching semantics
includes) on the observation text. Spans lines naturally; no glob, regex, or anchor syntax — regex metacharacters are matched literally.Composition: file-observation family
globsandfileContainsform a file-observation family that always composes with AND over the same single successful file observation: the observation's path matches a glob AND the same observation's text contains a literal. The family counts as one condition check inside the existingmatch: any|allalgebra.fileContainswithoutglobsis a family of one: content alone, no path condition (standalone use, per the standing preference).fileContainsbehave exactly as today. Other fields remain flat checks. Example:globs+fileContains+keywordsundermatch: anyevaluates as(globs AND fileContains) OR keywords.Lifetime and correlation
fileContainsis a durable condition kind (likeglobs); undermatch: allit never downgrades a rule to ephemeral. Delivery follows the universal earliest-dispatch contract (Specify earliest-dispatch delivery for every newly matched rule #45).Spec obligations surfaced
(globs AND fileContains) OR keywordsexample), and enumerate doc surfaces to update in the same change: README matcher sections,docs/rules.md,skills/crafting-rules/SKILL.md.