Governance-first judgment detection for Korean LLM systems. NOT a filter.
Project description
k-judgment-gate
Governance-first judgment detection for Korean LLM systems.
NOT a Filter
- NOT a filter. This does not block content.
- Does not decide. This marks boundaries, not policies.
- Pre-execution responsibility boundary. Detects judgment patterns BEFORE execution.
- Triggers human oversight. Returns structured results for handoff, not automation.
Methodology
This is a reference implementation of the stem matching + scope rules approach documented in judgment-refinement-public.
Key differences:
- Refinement-public: 7-role taxonomy research (methodology whitepaper)
- k-judgment-gate: 3-role minimal implementation (governance-first reference)
Built in 3 hours as proof-of-concept.
What It Does
k-judgment-gate detects judgment patterns in text:
- Directives: Commands, imperatives, direct instructions
- Recommendations: Suggestions, advice, guidance
- Obligations: Requirements, duties, must-do statements
When judgment is detected, it returns blocked: true — meaning "handoff required", NOT "policy block."
Installation
pip install k-judgment-gate
Quick Start
from k_judgment_gate import JudgmentGate, JudgmentRole
from k_judgment_gate.scope import ScopeRule
# Configure gate with role stems and optional scope rules
gate = JudgmentGate(
role_stems={
JudgmentRole.DIRECTIVE.value: ["해야 합니다", "하십시오", "must"],
JudgmentRole.RECOMMENDATION.value: ["권장합니다", "should"],
JudgmentRole.OBLIGATION.value: ["의무입니다", "required"],
},
role_scopes={
JudgmentRole.DIRECTIVE.value: [
ScopeRule(
id="medical_only",
include=["의료", "medical"],
exclude=[]
)
]
}
)
# Inspect text for judgment patterns
result = gate.inspect("이 약을 복용해야 합니다")
print(result.to_dict())
Example Output
{
"blocked": true,
"role": "directive",
"reason": "Judgment detected: directive pattern '해야 합니다' with scope rules ['medical_only']",
"confidence": 0.85,
"matched_stem": "해야 합니다",
"scope_applied": ["medical_only"]
}
Schema
GateResult contains:
- blocked (bool): True if judgment detected and handoff required
- role (str | None): Detected role (directive/recommendation/obligation)
- reason (str): Human-readable explanation
- confidence (float): Informational score 0.0-1.0 (NOT for decision-making)
- matched_stem (str | None): The pattern that matched
- scope_applied (list[str]): List of scope rule IDs that applied
Hard Constraints
- Sealed to 3 roles: directive, recommendation, obligation (no extensions)
- Max 2 scope rules per role: Enforced by code (raises
ValueErrorif exceeded) - Confidence is informational only: MUST NOT be used for automated decisions
- No policy logic: This tool marks boundaries; humans make decisions
Telemetry
Generate OpenTelemetry-style attributes:
from k_judgment_gate.telemetry import gate_attributes
attrs = gate_attributes(result)
# {
# "judgment.gate.present": True,
# "judgment.gate.blocked": True,
# "judgment.gate.role": "directive",
# "judgment.gate.matched_stem": "해야 합니다",
# "judgment.gate.scope_applied": "medical_only",
# "judgment.gate.reason": "..."
# }
No OTel dependency required. This is a pure dict generator for observability integration.
Testing
pytest
Tests verify:
- Basic judgment detection (directives, recommendations, obligations)
- Scope rule filtering (include/exclude)
- Max 2 scope rules enforcement (raises
ValueError) - Minimal stem matching (normalization, substring matching)
HuggingFace Demo
See hf_demo/ for a Gradio demo showing judgment detection in action.
cd hf_demo
pip install -r requirements.txt
python app.py
The demo includes a warning: "This demo does not decide. It only marks the boundary where human oversight is required."
Documentation
- PROOF_NOTE.md: What it is, what it is NOT, positioning
- DM_TEMPLATE.md: Enterprise outreach template
- EU_AI_ACT_MAPPING.md: Article 13/14 ↔ Field Mapping (Compliance Reference)
Korean AI Basic Act Context
The Korean AI Basic Act (2024) establishes requirements for transparency, accountability, and human oversight. k-judgment-gate addresses the pre-execution responsibility boundary:
- Transparency: Explicit judgment detection
- Accountability: Clear handoff points
- Human Oversight: Triggers before execution
- Audit Trail: Structured telemetry for compliance
This is execution governance, not compliance theater.
Not for Automation
blocked: true does NOT mean "auto-reject." It means "route to human review."
Confidence scores are informational only. Do NOT use them for automated decision-making.
License
Apache-2.0
Contributing
This is a proof-of-concept demonstrating the interface layer for execution governance. The runtime core (actual execution blocking) is closed.
For questions or feedback, please open an issue.
Not every request deserves execution. STOP is cheaper than scaling.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file k_judgment_gate-1.2.1.tar.gz.
File metadata
- Download URL: k_judgment_gate-1.2.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13da0ac6f61b8b0372601918bb42c2435607f0277a07b7dcccba48582e980aff
|
|
| MD5 |
e03947f3cbbdaacf0ccd4291876de45a
|
|
| BLAKE2b-256 |
1312207e06bdab483027cc620cd865deda5ef21a1d9a48aac82ef86ea13593b2
|
File details
Details for the file k_judgment_gate-1.2.1-py3-none-any.whl.
File metadata
- Download URL: k_judgment_gate-1.2.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ec6be5a62204c29ee04c5c85822de63833621ac42f98f6de8f0d4935b65031d
|
|
| MD5 |
571e4ee27a6813e398abf2c112d666e9
|
|
| BLAKE2b-256 |
5798590a6ce46d09de447e61e2ae4f312b4a841b4e3efa895f74c16b5077d93a
|