Context Library

Rules

Definition

Human-authored operational constraints applied at session boundaries — append-only records that define what the AI model may not do within a governed session, regardless of role.

Definition

Rules are human-authored operational constraints applied at session boundaries. They define what an AI model may not do, propose, or act on within a governed session — regardless of the active Role. Rules are append-only artifacts in the Yanzi corpus: once authored, they constrain all sessions to which they are applied until explicitly superseded by a newer Rule revision.

Rules define the floor of governance — the minimum constraints that apply in any governed session. Roles add bounded authority above that floor. Rules cannot be overridden by Roles.

What Rules Constrain

Rules can constrain any class of AI-assisted operation. Common categories include:

Dependency constraints: prohibited library versions, banned packages, minimum version requirements.

Scope constraints: files, directories, or services the agent may not modify without explicit approval.

Pattern constraints: code patterns, API usage, or architectural approaches that are prohibited in this project.

Escalation thresholds: conditions under which the agent must stop and seek human review before proceeding.

Output constraints: formats, lengths, or structures that outputs must conform to.

Difference from Roles

Roles define what an agent may do — bounded positive authority. Rules define what an agent may not do — negative constraints that apply unconditionally.

An agent with an architect role may propose changes to service boundaries. But if an active Rule prohibits modifying the authentication service without a security review, that constraint applies regardless of the role. Rules take precedence.

Append-Only and Versioned

Rules are append-only. A Rule that is in effect cannot be modified — it can only be superseded by a newer Rule version. This means the constraints that applied to a session are permanently auditable: the Rule versions active at that time are part of the session’s operational lineage.

If an exception to a Rule is required, a new Rule revision is authored that explicitly documents the exception, its rationale, and its scope. This keeps the constraint history intact.

In Yanzi

Rules are committed to the corpus with yanzi rules add <file> and are applied to session context during deterministic context composition. Active Rules are listed in the composed context document that the model receives at session start.