Skip to content
LakeSharkDocumentation
GOVERNANCESETS / DOCUMENTATION

Create and manage

Create, draft, edit, import, export, and delete GovernanceSets.

Create manually

Open Governance and select New GovernanceSet.

Provide:

  • Name
  • Description
  • PII action
  • Prompt-injection action
  • Prohibited-content action
  • Provider-call ceiling
  • Input-token ceiling
  • Output-token ceiling
  • Optional blocked terms
  • Optional ordered custom rules for input/output matching, redaction, blocking, and audit

API:

POST https://lakeshark.dev/api/answers/v1/governance-sets
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json

Example:

{
  "name": "Corporate PII",
  "description": "Protect common customer and employee identifiers.",
  "policy": {
    "pii_action": "redact",
    "profanity_action": "block",
    "prompt_injection_action": "block",
    "blocked_terms": [
      "internal-only phrase"
    ],
    "max_input_tokens": 8000,
    "max_output_tokens": 1000,
    "max_provider_calls": 1
  }
}

Make with provider

Select Make with provider when you want a connected provider to draft the policy.

You provide:

  • Provider connection
  • Model
  • Instructions describing the desired controls

Example instruction:

Protect customer PII, block prompt injection, allow no more than one provider
call, and keep output below 800 tokens.

LakeShark asks the selected provider for a draft, validates the returned policy against the GovernanceSet schema, and shows it for review.

Nothing is saved until you approve the draft.

API:

POST /v1/governance-sets/draft
{
  "provider_connection_id": "30f51446-dd2f-498d-bf0e-c589d4d9de44",
  "model": "gpt-5.6",
  "instructions": "Protect customer PII, block prompt injection, allow one provider call, and limit output to 800 tokens."
}

The response contains a draft with name, description, and policy.

Edit

Select a GovernanceSet in the Governance library and choose Save changes after editing it. The console uses PATCH for existing GovernanceSets and POST to create new ones.

For API clients, two update methods are available:

  • PATCH /v1/governance-sets/{governance_set_id} updates only supplied top-level fields and merges supplied policy fields with the saved policy. The form editor and JSON editor use this operation.
  • PUT /v1/governance-sets/{governance_set_id} replaces the complete name, description, and policy. It is a separate full-replacement API operation.

After the revision-enabled backend is deployed, both console editors attach expected_revision to PATCH requests when the server returns a valid revision. The full-replacement PUT API does not enforce that optional PATCH precondition. API clients requiring conflict protection should use revision-aware PATCH.

Because GovernanceSets are reusable, editing one changes the policy used by every AnswerSet currently assigned to that set.

JSON Editor and PATCH

The console includes a GovernanceSet JSON Editor for modifying the resource as JSON. Applying uses:

PATCH /v1/governance-sets/{governance_set_id}

The payload may contain name, description, and/or a policy object. The service retains omitted top-level fields and merges supplied policy fields with the saved policy; when supplied, the rules array replaces that array rather than patching rules individually. Empty or null-only patches are rejected. Unchanged values return updated: false; successful changes return the updated governance_set.

Example:

{
  "policy": {
    "rules": [
      {
        "id": "deny-secret-marker",
        "stage": "output",
        "detector": "contains",
        "action": "block",
        "value": "SECRET-MARKER",
        "priority": 10,
        "enabled": true
      }
    ]
  }
}

Prevent stale editor overwrites

Release status: This API enhancement is staged in source and is not yet verified in production. The following contract applies after the GovernanceSet and Answers backend release is deployed and verified.

A GovernanceSet GET response includes an opaque revision string. When editing a shared GovernanceSet, supply that exact value as expected_revision in the PATCH body:

{
  "expected_revision": "<64-character revision from GET>",
  "policy": {
    "max_output_tokens": 500
  }
}

The service checks the revision inside the same row-locked database transaction that applies the patch. If another editor changed the GovernanceSet after the GET, the PATCH returns HTTP 409 with GovernanceSet revision mismatch, without changing the saved policy. Fetch the current GovernanceSet, review the differences, and retry with its new revision only after reconciling changes.

The precondition is optional for compatibility with existing API clients. Without expected_revision, a PATCH can still overwrite concurrent edits. The revision is an optimistic-concurrency token, not an immutable policy version or audit trail. This applies to GovernanceSet PATCH, not AnswerSet assignment PUT or complete GovernanceSet replacement PUT.

The PATCH operation updates the shared GovernanceSet; review every attached AnswerSet before applying a broadly used change. See advanced rules and policy limits.

Import and export

The Governance console supports workspace-level import and export.

Exports use:

{
  "format": "lakeshark-governance",
  "version": 1,
  "governance_sets": [
    {
      "name": "Corporate PII",
      "description": "Protect common identifiers.",
      "policy": {
        "pii_action": "redact",
        "profanity_action": "block",
        "prompt_injection_action": "block",
        "blocked_terms": [],
        "max_input_tokens": 8000,
        "max_output_tokens": 1000,
        "max_provider_calls": 1
      }
    }
  ]
}

The export does not include GovernanceSet IDs. Import creates new GovernanceSets in the destination workspace.

Delete

A GovernanceSet can be deleted only when it is not attached to any AnswerSet.

If it is still assigned, the API returns a conflict instead of silently removing the assignment.

Detach it from every AnswerSet first, then delete it.