Skip to content

Match Rules from successful Read observations #54

Closed

Description

@frap129

Parent

#38

What to build

Allow Rule authors to select guidance with case-sensitive literal fileContains conditions evaluated against text successfully observed by Read. Keep File observations runtime-owned and separate from path-only Working context, and require globs plus fileContains to match the same observation.

Acceptance criteria

  • Scalar and array declarations are trimmed, deduplicated exactly, preserve case and multiline text, and use literal substring matching with OR semantics.
  • A declared field with no valid literals logs one warning and makes the entire Rule fail closed.
  • Content-only matching works, while combined globs and fileContains conditions require one File observation to satisfy both and remain one family under match: any|all.
  • Successful text Reads contribute only returned file text, excluding wrappers and line-number prefixes; continuation and truncated Reads contribute only their returned slice.
  • Binary, image, PDF, and otherwise unparseable file Reads are path-only; directory Reads and failed Reads contribute no File observation.
  • File observations are retained monotonically for the resident session without filesystem scanning or historical tool-event replay.
  • Existing initial-turn durable Rule delivery remains functional and the full repository verification suite passes.

Blocked by

  • None (can start immediately).

Activity

  1. frap129 commented on Aug 30, 2026

    @frap129
    OwnerAuthor

    Implemented in 1d4504d (feat(rules): fileContains matching with observation-time admission).

    • Scalar/array declarations trimmed, exact-deduped, case-preserved, multiline literals with OR semantics: src/rule-metadata.test.ts:84, OR across literals in src/rule-filter.test.ts:400
    • Declared-but-invalid field warns once and fails the rule closed: src/file-contains-warning.test.ts, src/rule-filter.test.ts:392
    • Content-only matching and same-observation globs+fileContains family (one condition in match:any|all): src/rule-filter.test.ts:328-390
    • Read text excludes wrappers/line prefixes; continuation and truncated reads contribute only the returned slice: src/file-observation-read.test.ts
    • Binary/image/PDF/unparseable reads path-only; directory reads no observation: src/file-observation-read.test.ts:34,40,45
    • Observations retained monotonically for the resident session, no filesystem scanning or historical tool-event replay: src/file-observation-context.test.ts, src/observation-admission.test.ts:35
    • Initial durable delivery unchanged; full suite green (lint, tsc, 527 tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions