Controls and composition
GovernanceSet actions, limits, defaults, and effective-policy rules.
Each GovernanceSet contains deterministic content controls, ordered custom rules, and provider-usage ceilings.
Policy fields
| Field | Allowed values | Default |
|---|---|---|
pii_action |
allow, redact, block |
redact |
profanity_action |
allow, redact, block |
block |
prompt_injection_action |
allow, block |
block |
blocked_terms |
Up to 100 strings | Empty |
max_input_tokens |
128 to 200,000 | 8,000 |
max_output_tokens |
32 to 32,000 | 1,000 |
max_provider_calls |
1 to 2 | 1 |
rules |
Up to 100 ordered custom rules via the public API | Empty |
GovernanceSet policy authoring rejects unknown top-level control names rather than silently discarding them. For example, pii_acton is invalid and must be corrected to pii_action. Token and provider ceilings must be JSON integers, not strings, decimals, or booleans. blocked_terms must be an array of strings. Invalid policy changes are rejected before they become effective. This protects AnswerSet input/output evaluation and downstream ExecutionSet workflows from accidental policy misconfiguration.
Blocked terms are case-insensitive during enforcement. Each term can be up to 120 characters.
PII handling
LakeShark currently detects common patterns including:
- email addresses
- U.S. Social Security numbers
- phone numbers
- IPv4 addresses
- payment-card numbers that pass checksum validation
Actions:
- Allow: leave matched content unchanged.
- Redact: replace detected values with a redaction marker.
- Block: reject the request or response.
Prompt injection
Prompt-injection handling supports:
- Allow
- Block
When set to block, LakeShark rejects input matching the platform’s prompt-injection detection rules before provider execution.
Prohibited content
The prohibited-content action applies to:
- the built-in profanity detector
- custom blocked terms
Actions:
- Allow
- Redact
- Block
Token and provider-call limits
GovernanceSets also enforce hard request ceilings:
- maximum approximate input tokens
- maximum output tokens
- maximum provider calls
These controls are separate from plan quotas. They are per-request policy limits.
Input and output enforcement: max_input_tokens and max_output_tokens are checked before and after policy transformations. Redaction markers can be longer than the original sensitive value; even a request or response that fits the initial budget must be blocked if its redacted form exceeds the ceiling. The output limit is enforced for known, generated, and ExecutionSet answers, not just passed to a provider as max_tokens. For typed JSON objects and arrays, LakeShark additionally checks the entire serialized structure before and after redaction, so multiple short fields cannot evade the aggregate ceiling. A violation is rejected with HTTP 422; LakeShark does not silently truncate an answer or structured result. Token estimates use UTF-8 bytes divided by four, rounded up. They are deterministic estimates, not model-specific tokenizer counts.
Typed payload complexity limits (staged, not yet production-verified): The shared evaluator rejects nested objects and arrays deeper than 64 levels or containing more than 50,000 value nodes before detector evaluation. These independent limits bound worst-case CPU and recursion work for AnswerSet outputs and mapped ExecutionSet inputs. Rejected values use the stage-specific HTTP 422 contract; an input rejection occurs before any external action is dispatched. This feature is under backend PR #146 and must not be treated as active until its tests, image build, and production rollout are verified.
ExecutionSet stage boundary (staged, not yet production-verified): Before an HTTP ExecutionSet action is dispatched, the mapped action input, including nested context values, is evaluated using input-stage rules and max_input_tokens. This is separate from the question’s own input evaluation. After the remote action completes, its returned payload is evaluated using output-stage rules and max_output_tokens. Input policy rejection prevents the side effect; output rejection does not undo an action that has already executed. Output-only restrictions must not be applied as input restrictions, and input-only restrictions must not be omitted from action payloads. The corrected input-stage handling is awaiting a verified backend deployment.
Advanced rules
In addition to the baseline policy fields, use policy.rules to configure named, independently enabled input/output rules. The public Answers API accepts up to 100 rules per GovernanceSet. Rules are evaluated in ascending priority order (ties sort by id).
| Rule field | Meaning |
|---|---|
id |
Unique identifier, 1–64 characters; begins with a letter; remaining characters are letters, numbers, underscores, or hyphens |
stage |
input or output |
detector |
contains, pii, profanity, or prompt_injection |
action |
block, redact, or audit |
value |
Required for contains; case-insensitive text match, at most 256 characters |
priority |
Integer from 0 to 10,000; default 100 |
enabled |
Boolean; default true |
Example policy fragment:
{
"rules": [
{
"id": "reject-internal-only",
"stage": "output",
"detector": "contains",
"value": "INTERNAL ONLY",
"action": "block",
"priority": 10,
"enabled": true
},
{
"id": "audit-sensitive-input",
"stage": "input",
"detector": "pii",
"action": "audit",
"priority": 20,
"enabled": true
}
]
}
The example is a policy fragment, not the full creation request. A complete GovernanceSet creation body also needs name, description, and policy. Custom rules execute before baseline content filtering; an audit match records a reason in the evaluation result but does not override a baseline block/redaction. prompt_injection rules cannot use redact. Every matching block rule inspects the original, unredacted stage text before any redaction is applied, regardless of the rule’s configured priority. This prevents a lower-priority deny from being bypassed by an earlier mask. Baseline blocked terms and profanity checks also inspect the original text. An audit rule observes the original text even if another rule masks it; redact rules transform the current text in priority order. A matching block ends evaluation of that stage. Custom rules do not automatically replace the baseline PII/profanity/injection settings.
The shared policy runtime implements an additional restricted regex detector internally, but the current public GovernanceSet schema does not accept it; do not send regex rules through the customer API. The internal composition ceiling is separate from the public per-set limit.
Test a policy without applying it
A workspace-authorized caller can evaluate sample text with POST /v1/governance-sets/evaluate. This is side-effect-free: it does not save the policy, change assignments, or send text to a provider. The request includes stage (input or output), text, and a complete policy. The response includes action, text, reasons, and redactions.
Multiple GovernanceSets
An AnswerSet can use multiple GovernanceSets.
LakeShark composes them into one effective policy.
For action-based controls:
allow < redact < block
The stricter action wins.
For numeric ceilings, the lowest value wins.
Example:
| GovernanceSet | Output ceiling | Provider calls |
|---|---|---|
| Corporate baseline | 2,000 | 2 |
| Support production | 800 | 1 |
| Effective policy | 800 | 1 |
Blocked terms from all assigned GovernanceSets are combined and deduplicated case-insensitively. The 100-term limit applies to authoring one GovernanceSet, not to the effective policy across multiple assigned sets. LakeShark preserves up to 5,000 composed custom rules from 50 assigned sets rather than silently dropping restrictions. Custom rule IDs receive source prefixes; IDs that would exceed 64 characters are shortened with a deterministic hash suffix so distinct originating sets remain distinguishable. A composed-policy validation failure blocks evaluation instead of falling back to a weaker policy.
No assignment
If no GovernanceSets are assigned, GovernanceSet enforcement is disabled for that AnswerSet.
The default policy values are used for normalization and composition, but they are not globally applied to unassigned AnswerSets.