Skip to main content
A rule is one expected behaviour of a flow - “always cite a source before answering”, “never issue a refund over $500 without approval”, “retry a failed tool call at most twice”. A flow’s rules are its spec: the set of things Glassray checks every trace against, and the reason a deviation exists in the first place.

Where rules come from

Read from code

Most rules come straight from your codebase - found during a code scan and anchored to the file and symbol that enforces them, with the enforcing snippet attached so you can see the ground truth.

Promoted from a deviation

A confirmed deviation that isn’t grounded in code yet can be promoted into a rule of its own - so Glassray starts watching for it even before the code catches up. A promoted rule is marked “not in code” until a later scan finds the matching code, or you merge it into one that already exists.

Watched vs. archived

A rule is either watched or archived:
  • Watched - judged on every trace. A trace that breaks it surfaces as a deviation.
  • Archived - retired. No longer judged, and its backing deviations return to the unmatched pool.
Archiving isn’t deletion - a retired rule can be watched again later. Use it for a behaviour that’s no longer expected (a feature was removed, a policy changed) rather than one that’s simply wrong; a rule you promoted by mistake should be removed instead (see below).

Keeping rules and deviations in sync

A deviation is always found against a rule, but the two can drift apart - a deviation Glassray couldn’t confidently match to one of your existing rules shows up as unmatched. From there you can:
  • Link it to an existing rule it actually violates, instead of leaving it stranded.
  • Promote it into a new rule, if it’s a real behaviour nothing currently covers.
  • Dismiss it as noise, if it isn’t a real behaviour at all.
Glassray also runs this matching automatically in the background - re-checking unmatched deviations against your rules by wording, then meaning, so most resolve themselves without you doing anything. A rule can also turn out to be a duplicate of another (often after being promoted); merge it into the one that should stay, and its deviations follow the link.
See a flow’s rules under its What it should do tab, or over MCP as part of the flow’s rule list.