feat(clauses): add Confidentiality clause type (PL)

Sprint 4 second concrete clause type — validates the add-clause workflow
from compass-clause-taxonomy fundament 7 by exercising every step on
Confidentiality after Liability shipped in Sprint 2.

Pydantic schema (compass_schemas.clauses.confidentiality):
- duration_years, mutual, exceptions (5 Literal values), survives_termination,
  residuals_clause, preliminary_status, key_observations,
  suggested_questions_for_counsel
- Two model_validators parallel to LiabilityClause:
    enforce_counsel_disclaimer  — auto-append the legal-tech sign-off line
    flag_indefinite_duration    — None duration_years + Approved -> downgrade
                                  to Needs Attention with explanatory observation

Prompt (compass_prompts.clauses.confidentiality_extraction_v1):
- PROMPT_VERSION = "confidentiality_v1"
- 13 numbered rules covering schema fields, PL/EN terminology,
  carve-out semantics, never-assert-enforceability discipline
- 4 few-shot examples: mutual 3yr full exceptions (Approved), indefinite
  one-sided no exceptions (Needs Attention), PL § 9 5yr partial
  exceptions (Needs Attention), clause absent

PL jurisdiction overlay (compass_jurisdictions.pl.confidentiality):
- MANDATORY_OBSERVATIONS reference UoZNK art. 11 (tajemnica
  przedsiębiorstwa — statutory indefinite protection independent of
  contract) and KC art. 484 § 2 ("rażąco wygórowana" reduction)
- PROMPT_HINTS adds PL vocabulary, market-norm reference (3-5 years),
  antitrust angle on indefinite obligations
- post_extraction_check downgrades when: duration > 5 years (UoZNK
  statutory already covers indefinitely), fewer than 3 of 4 core
  exceptions present, residuals_clause set in a PL contract

Golden dataset (packages/evals/datasets/confidentiality_pl.jsonl):
- 4 synthetic examples on launch + TODO marker to expand to 20+
  (user-side curation from anonymized PL contracts)
- Mix English / Polish text per PL real-world distribution

Eval test (packages/evals/tests/test_confidentiality_extraction.py):
- @pytest.mark.eval with the same thresholds as liability
  (precision >= 0.85, recall >= 0.80, cost_per_doc <= $0.02)
- Live test skipped when ANTHROPIC_API_KEY absent
- Mock smoke test independent of --profile flag verifies runner pipeline

Registry + zod mirror:
- CLAUSE_REGISTRY in compass_agents.clause_extractor += confidentiality
- apps/web/src/components/contract-form/clauses/confidentiality.ts
  is the manual zod mirror per fundament 2 sync rule

Tests: 17/17 llm-gateway + 9 evals green (2 live correctly skipped).

13-pkt compass-clause-taxonomy self-check:
- Schema fields typed (Literal enums, int, bool), two validators ✓
- Zod mirror created in same change ✓
- CLAUSE_TYPES enum already covers "confidentiality" (Sprint 2 migration) ✓
- Prompt versioned with PROMPT_VERSION constant ✓
- Few-shot count 4 covers standard / red flag / PL / absent ✓
- Disclaimer hardcoded in system prompt + auto-appended by validator ✓
- Golden dataset: 4 synthetic with explicit expand-to-20 TODO ✓
- Eval test with explicit thresholds + CI workflow trigger path ✓
- Prompt change CI hook (eval.yml watches packages/prompts/**) ✓
- PL jurisdiction post_extraction_check ✓
- Confidence threshold default (0.7/0.5) ✓
- legal-tech red flags reflected (indefinite, partial exceptions,
  residuals in PL) ✓
- ADR-001 M2 schema-first + M4 eval-driven satisfied ✓

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
tobayah
2026-05-17 17:40:59 +02:00
co-authored by Claude Opus 4.7
parent 17f6bc1f62
commit 79d20482aa
8 changed files with 646 additions and 3 deletions
@@ -0,0 +1,47 @@
/**
* ConfidentialityClause zod mirror — manual sync with
* packages/schemas/src/compass_schemas/clauses/confidentiality.py
*
* Sprint 4 manual mirror per compass-clause-taxonomy fundament 2 (Opcja A).
* Sprint 5+ may replace this with auto-gen from Pydantic JSON Schema if
* drift proves too costly.
*
* SYNC RULE: any edit to packages/schemas/.../confidentiality.py MUST update
* this file in the same PR. CI test tests/integration/test_schema_sync.py
* (Sprint 5) will validate the two schemas match.
*/
import * as z from "zod";
export const confidentialityExceptionSchema = z.enum([
"publicly_available",
"prior_knowledge",
"required_by_law",
"independently_developed",
"consent_disclosure",
]);
export const confidentialityPreliminaryStatusSchema = z.enum([
"Approved",
"Needs Attention",
"Rejected",
]);
export const confidentialityClauseSchema = z.object({
found: z.boolean(),
text: z.string().nullable(),
source_location: z.string().nullable(),
confidence: z.number().min(0).max(1),
extraction_prompt_version: z.string(),
requires_counsel_review: z.literal(true),
duration_years: z.number().int().nullable(),
mutual: z.boolean().nullable(),
exceptions: z.array(confidentialityExceptionSchema),
survives_termination: z.boolean().nullable(),
residuals_clause: z.boolean(),
preliminary_status: confidentialityPreliminaryStatusSchema.nullable(),
key_observations: z.array(z.string()).max(5),
suggested_questions_for_counsel: z.array(z.string()).max(5),
});
export type ConfidentialityClause = z.infer<typeof confidentialityClauseSchema>;
export type ConfidentialityException = z.infer<typeof confidentialityExceptionSchema>;
@@ -28,7 +28,7 @@ from pydantic import BaseModel, ValidationError
from compass_jurisdictions import get_jurisdiction_module
from compass_llm_gateway import LLMRouter, Model, TaskType, Urgency
from compass_prompts import load_prompt
from compass_schemas.clauses import LiabilityClause
from compass_schemas.clauses import ConfidentialityClause, LiabilityClause
log = logging.getLogger(__name__)
@@ -38,7 +38,11 @@ CLAUSE_REGISTRY: dict[str, dict[str, Any]] = {
"schema": LiabilityClause,
"prompt_version": "liability_v1",
},
# Sprint 3+ adds: ip, termination, dataPrivacy, payment, ...
"confidentiality": {
"schema": ConfidentialityClause,
"prompt_version": "confidentiality_v1",
},
# Sprint 5+ adds: ip, termination, dataPrivacy, payment, ...
}
@@ -0,0 +1,12 @@
{"id": "pl-c-001-synthetic-mutual-3yr-full-exceptions", "jurisdiction": "pl", "input_text": "Section 7. Confidentiality. Each Party agrees that it shall not, during the term of this Agreement and for a period of three (3) years thereafter, use or disclose any Confidential Information of the other Party except as expressly permitted hereunder. The foregoing obligation shall not apply to information that (a) is or becomes publicly available through no fault of the Recipient, (b) was rightfully known to the Recipient prior to disclosure, (c) is required to be disclosed by law or court order, or (d) is independently developed by the Recipient without reference to the Confidential Information.", "expected": {"found": true, "source_location": "Section 7", "confidence": 0.92, "duration_years": 3, "mutual": true, "exceptions": ["publicly_available", "prior_knowledge", "required_by_law", "independently_developed"], "survives_termination": true, "residuals_clause": false, "preliminary_status": "Approved"}, "tags": ["mutual", "finite_duration", "all_core_exceptions", "approved"]}
{"id": "pl-c-002-synthetic-indefinite-no-exceptions-onesided", "jurisdiction": "pl", "input_text": "The Vendor undertakes to keep confidential all information disclosed by the Client in connection with this Agreement. This obligation shall continue indefinitely and without limitation.", "expected": {"found": true, "source_location": "unnamed confidentiality paragraph", "confidence": 0.9, "duration_years": null, "mutual": false, "exceptions": [], "survives_termination": true, "residuals_clause": false, "preliminary_status": "Needs Attention"}, "tags": ["indefinite", "one_sided", "no_exceptions", "red_flag"]}
{"id": "pl-c-003-synthetic-pl-5yr-partial-exceptions", "jurisdiction": "pl", "input_text": "§ 9 Poufność. Każda ze Stron zobowiązuje się zachować w tajemnicy wszelkie informacje poufne przekazane przez drugą Stronę w związku z wykonaniem niniejszej Umowy, w okresie obowiązywania Umowy oraz przez okres pięciu (5) lat po jej rozwiązaniu. Powyższe ograniczenia nie znajdują zastosowania do informacji (a) powszechnie dostępnych bez winy Strony zobowiązanej oraz (b) co do których obowiązek ujawnienia wynika z bezwzględnie obowiązujących przepisów prawa.", "expected": {"found": true, "source_location": "§ 9", "confidence": 0.9, "duration_years": 5, "mutual": true, "exceptions": ["publicly_available", "required_by_law"], "survives_termination": true, "residuals_clause": false, "preliminary_status": "Needs Attention"}, "tags": ["pl_language", "mutual", "finite_duration", "partial_exceptions"]}
{"id": "pl-c-004-synthetic-clause-absent", "jurisdiction": "pl", "input_text": "Section 12 Governing Law. This Agreement shall be governed by the laws of the Republic of Poland. Section 13 Notices. Any notice required under this Agreement shall be in writing and delivered to the addresses set forth above.", "expected": {"found": false, "confidence": 0.85}, "tags": ["clause_absent", "thorough_scan"]}
// TODO Sprint 5 user-side: expand to >= 20 examples per fundament 4 / ADR-001 M4 threshold.
// Target distribution:
// - 6x found + Approved (mutual finite duration, full exceptions, with/without survival)
// - 8x found + Needs Attention (indefinite OR partial exceptions OR very long duration OR residuals in PL)
// - 3x found + Rejected (indefinite + no exceptions + one-sided combination)
// - 3x found=false (clause genuinely absent / buried elsewhere)
// Source: redact / anonymize from actual PL contracts. Mix English-language and Polish-language clauses 50/50.
// Acceptance: precision >= 0.85, recall >= 0.80, cost_per_doc <= $0.02 (Sonnet 4.6 baseline).
@@ -0,0 +1,93 @@
"""Eval test for confidentiality extraction (ADR-001 M4 gate, Sprint 4).
Live mode requires:
- ANTHROPIC_API_KEY in env (LLM gateway hits live model)
- LANGFUSE_* in env (for cost tracking) — optional, set LANGFUSE_ENABLED=false to skip
- Internet access
Mock mode (``--profile=mock`` or ``LLM_PROVIDER=mock``) requires neither —
runs deterministic stub from row["expected"], smoke-tests runner wiring only.
Skipped by default (`@pytest.mark.eval`). Run explicitly::
# Mock (CI, no creds needed)
uv run pytest packages/evals/tests/test_confidentiality_extraction.py -m eval --profile=mock
# Live cloud
uv run pytest packages/evals/tests/test_confidentiality_extraction.py -m eval --profile=cloud-cheap
"""
from __future__ import annotations
import os
import pytest
from compass_evals import run_eval
from compass_evals.runner import _is_mock_mode
pytestmark = pytest.mark.eval
# Per ADR-001 M4 thresholds (mirrors test_liability_extraction.py)
PRECISION_THRESHOLD = 0.85
RECALL_THRESHOLD = 0.80
COST_PER_DOC_USD_THRESHOLD = 0.02
ERROR_RATE_THRESHOLD = 0.10
@pytest.fixture(scope="module")
def llm_keys_present() -> bool:
return bool(os.getenv("ANTHROPIC_API_KEY"))
@pytest.mark.asyncio
async def test_confidentiality_extraction_pl_golden(llm_keys_present: bool) -> None:
if not _is_mock_mode() and not llm_keys_present:
pytest.skip(
"ANTHROPIC_API_KEY not set and LLM_PROVIDER != mock — "
"eval requires live LLM creds OR mock mode (pass --profile=mock)."
)
result = await run_eval(
prompt_version="confidentiality_v1",
dataset="confidentiality_pl",
clause_type="confidentiality",
)
print(f"\nEval summary: {result.summary()}")
assert result.error_rate <= ERROR_RATE_THRESHOLD, (
f"Too many examples failed extraction outright: "
f"{result.error_rate:.2%} > {ERROR_RATE_THRESHOLD:.2%}"
)
assert result.precision >= PRECISION_THRESHOLD, (
f"Precision regression: {result.precision:.4f} < {PRECISION_THRESHOLD}"
)
assert result.recall >= RECALL_THRESHOLD, (
f"Recall regression: {result.recall:.4f} < {RECALL_THRESHOLD}"
)
if result.cost_per_doc > 0: # 0.0 in offline/mock mode
assert result.cost_per_doc <= COST_PER_DOC_USD_THRESHOLD, (
f"Cost regression: ${result.cost_per_doc:.4f} > ${COST_PER_DOC_USD_THRESHOLD}"
)
@pytest.mark.asyncio
async def test_confidentiality_extraction_mock_mode_smoke() -> None:
"""Mock mode smoke test — independent of --profile flag.
Forces mock_mode=True regardless of env so this test runs in any CI config.
Validates runner pipeline wiring (load_dataset, compare_fields,
EvalResult aggregation) without needing LLM creds OR --profile=mock CLI.
"""
result = await run_eval(
prompt_version="confidentiality_v1",
dataset="confidentiality_pl",
clause_type="confidentiality",
mock_mode=True,
)
assert len(result.examples) >= 1, "dataset confidentiality_pl appears empty"
assert result.error_rate == 0.0, f"mock mode produced errors: {result.error_rate}"
assert result.precision == 1.0, f"mock precision != 1.0: {result.precision}"
assert result.recall == 1.0, f"mock recall != 1.0: {result.recall}"
assert result.cost_per_doc == 0.0, "mock mode should report zero cost"
@@ -0,0 +1,127 @@
"""Polish-jurisdiction-specific confidentiality clause rules.
Statutory references:
- Ustawa o zwalczaniu nieuczciwej konkurencji (UoZNK, Dz.U. 2022 poz. 1233)
art. 11 — definicja tajemnicy przedsiębiorstwa: informacje techniczne,
technologiczne, organizacyjne lub inne posiadające wartość gospodarczą,
które nie są powszechnie znane i co do których podjęto, przy zachowaniu
należytej staranności, działania w celu utrzymania ich poufności.
Ochrona trwa tak długo, jak długo spełnione są przesłanki ustawowe —
brak sztywnego limitu czasowego.
- KC art. 72¹ — odpowiedzialność za niewykonanie zobowiązania do zachowania
w tajemnicy informacji uzyskanych w trakcie negocjacji.
- KC art. 484 § 2 — sąd może zmniejszyć karę umowną "rażąco wygórowaną".
Praktyka:
- 3-5 lat post-termination = PL market standard B2B (SaaS / services).
- Tajemnica przedsiębiorstwa wg UoZNK jest osobną podstawą — może
zabezpieczać informacje bezterminowo niezależnie od umownego okresu
poufności (komplementarne, nie alternatywne).
- Kary umowne za naruszenie poufności są częste; KC art. 484 § 2 stosuje
się jeśli kara jest "rażąco wygórowana".
- Bezterminowa poufność contractowo może kolidować z restraint-of-trade
jurysprudencją w niektórych jurysdykcjach EU, jednak w PL B2B między
profesjonalistami sądy są zazwyczaj permisywne — flaga dla counsela.
"""
from __future__ import annotations
from compass_schemas.clauses.confidentiality import ConfidentialityClause
MANDATORY_OBSERVATIONS: list[str] = [
"PL law (UoZNK art. 11): trade secrets meeting statutory criteria are "
"protected indefinitely independently of contractual confidentiality — "
"separate legal basis, complementary not alternative.",
"PL law (KC art. 484 § 2): a court may reduce contractual penalty for "
'breach when "rażąco wygórowana" — high penalty is not absolute protection.',
]
PROMPT_HINTS: str = """
# PL jurisdiction overlay (confidentiality)
Contract governing law is Poland (Kodeks cywilny + UoZNK). Additional checks:
1. Polish terminology to scan for: "poufność", "tajemnica przedsiębiorstwa", \
"informacje poufne", "obowiązek zachowania tajemnicy", "kara umowna za \
naruszenie poufności", "okres obowiązywania zobowiązania do zachowania \
poufności".
2. UoZNK art. 11 (trade secrets) and contractual confidentiality are distinct \
legal bases. The contract may set duration finite (e.g. 5 years) while trade \
secrets enjoy statutory indefinite protection. Treat them as complementary, \
not alternatives.
3. PL B2B market norm: 3-5 years post-termination is acceptable. Anything \
longer than 10 years or indefinite warrants `preliminary_status = "Needs \
Attention"` with an observation pointing to the statutory trade-secret path.
4. PL antitrust angle on indefinite obligations: courts generally accept \
indefinite confidentiality between professional parties, but flag for counsel \
when the obligation is also one-sided OR when no carve-outs are present.
5. Kara umowna (contractual penalty for breach) is common in PL contracts. \
If present in the clause text, mention it in `key_observations` so counsel \
can evaluate against KC art. 484 § 2 ("rażąco wygórowana").
6. `residuals_clause` is rare in PL B2B — if present in a PL contract, treat \
it as a notable deviation worth flagging.
"""
def post_extraction_check(clause: ConfidentialityClause) -> ConfidentialityClause:
"""Apply PL-specific validations AFTER LLM extraction.
Side effects:
- prepends MANDATORY_OBSERVATIONS at the top of key_observations
- downgrades preliminary_status to Needs Attention when duration > 5 years
(PL practice favors 3-5 year window; longer terms duplicate UoZNK art. 11
statutory protection unnecessarily and may run into antitrust scrutiny)
- downgrades to Needs Attention when fewer than 3 of the 4 core exceptions
are present
- flags residuals_clause in a PL contract as deviation from market norm
"""
if not clause.found:
return clause
# Prepend mandatory observations (head of list, dedup)
for obs in reversed(MANDATORY_OBSERVATIONS):
if obs not in clause.key_observations:
clause.key_observations.insert(0, obs)
# Long duration check (>5 years contractual, not trade secret)
if clause.duration_years is not None and clause.duration_years > 5:
if clause.preliminary_status == "Approved":
clause.preliminary_status = "Needs Attention"
clause.key_observations.append(
f"PL practice: confidentiality duration {clause.duration_years} years "
"exceeds the 3-5 year market norm. For trade secrets, statutory "
"protection under UoZNK art. 11 may already apply indefinitely — "
"verify whether a long contractual term is needed."
)
# Core exceptions check (4 expected, fewer than 3 = downgrade)
core_exceptions = {
"publicly_available",
"prior_knowledge",
"required_by_law",
"independently_developed",
}
present_core = core_exceptions & set(clause.exceptions)
if len(present_core) < 3 and clause.preliminary_status == "Approved":
clause.preliminary_status = "Needs Attention"
missing = sorted(core_exceptions - present_core)
clause.key_observations.append(
f"PL practice: missing core exceptions {', '.join(missing)} — "
"fewer than 3 of 4 standard carve-outs present."
)
# Residuals in PL = deviation
if clause.residuals_clause:
clause.key_observations.append(
"Residuals clause present — uncommon in PL B2B; verify implications "
"with counsel (US-style allowance for general knowledge retained in memory)."
)
if clause.preliminary_status == "Approved":
clause.preliminary_status = "Needs Attention"
return clause
@@ -0,0 +1,230 @@
"""Confidentiality extraction prompt v1 — Sprint 4 W3.
Per compass-clause-taxonomy fundament 4 versioning:
- v1 -> v2 bump REQUIRED for: structural schema change, prompt rewrite, model change
- v1 minor edits OK for: typo / clarification (re-run eval anyway per ADR-001 M4)
Eval gate (packages/evals/tests/test_confidentiality_extraction.py @pytest.mark.eval):
- precision >= 0.85
- recall >= 0.80
- cost_per_doc <= $0.02
"""
from __future__ import annotations
PROMPT_VERSION = "confidentiality_v1"
SYSTEM_PROMPT = """You are an AI assistant supporting legal contract review. \
You extract clauses from commercial contracts. You DO NOT provide legal advice.
Task: from the contract text the user provides, extract the **confidentiality \
/ non-disclosure (NDA)** clause (if present) into the ConfidentialityClause schema.
# Rules
1. Focus on the PRIMARY confidentiality obligation clause. Note related \
provisions (e.g. data processing addenda, separate trade-secret clauses) in \
`key_observations`.
2. `confidence`:
- 0.9+ : unambiguous text with clear duration + exceptions + scope
- 0.7-0.9 : inferable but requires interpretation
- <0.7 : ambiguous, flag for human review
3. `source_location`: use the contract's own structural references \
("Section 5", "Clause 7.2", "Schedule B", "§ 9"). \
**NEVER invent section numbers.** If the clause has no clear marker, set \
source_location to a short descriptive phrase like "unnamed confidentiality \
paragraph".
4. `duration_years`: integer years of the confidentiality obligation. Set to \
`null` when the contract states the obligation runs **indefinitely** or has \
no time limit. Do NOT default to null when duration is simply not stated — \
leave `confidence` lower instead.
5. `mutual`:
- true : both parties bound symmetrically
- false : one-sided NDA (only one party owes the obligation)
- null : cannot determine
6. `exceptions`: only items EXPLICITLY listed as carve-outs from the \
obligation. Available values: `publicly_available`, `prior_knowledge`, \
`required_by_law`, `independently_developed`, `consent_disclosure`. \
Market-practice minimum is the first four — missing any one is a red flag.
7. `survives_termination`: true when clause states the obligation persists \
after contract end (often paired with a finite duration like "for 3 years \
after termination"). False when scope is limited to the contract term.
8. `residuals_clause`: true when the contract includes a residuals allowance \
(recipient may use general knowledge retained in unaided memory). Rare in PL \
B2B, common in US tech licensing — flag for review in PL contracts.
9. `preliminary_status`:
- "Approved" : mutual + clear finite duration (typically 3-5 years) + all \
four core exceptions + survives_termination explicit + no obvious red flags
- "Needs Attention" : indefinite duration, missing common exceptions, \
one-sided where mutual was expected, very long duration (>10 years), \
residuals in non-US contract
- "Rejected" : indefinite duration AND no exceptions AND asymmetric — \
combination likely unenforceable in most EU jurisdictions
10. **ALWAYS include "REQUIRES LEGAL COUNSEL SIGN-OFF"** in `key_observations`.
11. **NEVER assert** that anything is "legally enforceable" or "legally \
binding" or "unenforceable". This is preliminary AI-assisted analysis only.
12. If clause not found, return `found=false` with `confidence` reflecting \
how thorough your search was (e.g. 0.9 if you scanned full document, 0.6 if \
input was truncated).
13. Polish-language vocabulary to recognize: "poufność", "informacje poufne", \
"tajemnica przedsiębiorstwa", "obowiązek zachowania tajemnicy", \
"kara umowna za naruszenie poufności", "okres obowiązywania zobowiązania do \
zachowania poufności".
Output MUST match the ConfidentialityClause Pydantic schema exactly.
"""
FEW_SHOT_EXAMPLES: list[dict] = [
# 1) Mutual 3-year with full exceptions — Approved (green path)
{
"input": (
"Section 7. Confidentiality. Each Party (the 'Recipient') agrees "
"that it shall not, during the term of this Agreement and for a "
"period of three (3) years thereafter, use or disclose any "
"Confidential Information of the other Party (the 'Discloser') "
"except as expressly permitted hereunder. The foregoing obligation "
"shall not apply to information that (a) is or becomes publicly "
"available through no fault of the Recipient, (b) was rightfully "
"known to the Recipient prior to disclosure, (c) is required to "
"be disclosed by law or court order (provided the Recipient gives "
"prompt notice), or (d) is independently developed by the "
"Recipient without reference to the Confidential Information."
),
"output": {
"found": True,
"text": "[verbatim Section 7 text]",
"source_location": "Section 7",
"confidence": 0.95,
"extraction_prompt_version": "confidentiality_v1",
"requires_counsel_review": True,
"duration_years": 3,
"mutual": True,
"exceptions": [
"publicly_available",
"prior_knowledge",
"required_by_law",
"independently_developed",
],
"survives_termination": True,
"residuals_clause": False,
"preliminary_status": "Approved",
"key_observations": [
"Mutual 3-year post-termination survival with all four core exceptions — market standard for B2B",
"REQUIRES LEGAL COUNSEL SIGN-OFF",
],
"suggested_questions_for_counsel": [
"Is 3-year survival period sufficient for the type of confidential info exchanged?",
"Does scope cover all categories actually exchanged (technical specs, customer data, pricing)?",
],
},
},
# 2) Indefinite confidentiality, no exceptions, one-sided — Needs Attention
{
"input": (
"The Vendor undertakes to keep confidential all information "
"disclosed by the Client in connection with this Agreement. "
"This obligation shall continue indefinitely and without limitation."
),
"output": {
"found": True,
"text": "[verbatim text]",
"source_location": "unnamed confidentiality paragraph",
"confidence": 0.92,
"extraction_prompt_version": "confidentiality_v1",
"requires_counsel_review": True,
"duration_years": None,
"mutual": False,
"exceptions": [],
"survives_termination": True,
"residuals_clause": False,
"preliminary_status": "Needs Attention",
"key_observations": [
"Indefinite duration (no time limit) — verify whether restraint-of-trade jurisprudence in governing law would limit enforceability",
"Zero exceptions present — market practice requires at minimum publicly_available + prior_knowledge + required_by_law + independently_developed",
"One-sided NDA (only Vendor bound) — likely needs to be made mutual",
"REQUIRES LEGAL COUNSEL SIGN-OFF",
],
"suggested_questions_for_counsel": [
"Can we negotiate finite duration (typically 3-5 years post-termination)?",
"Add the four core exceptions before signing?",
"Make mutual if Client also discloses confidential information to Vendor?",
],
},
},
# 3) Polish-language clause, 5-year mutual, partial exceptions — Needs Attention
{
"input": (
"§ 9 Poufność. Każda ze Stron zobowiązuje się zachować w tajemnicy "
"wszelkie informacje poufne przekazane przez drugą Stronę w "
"związku z wykonaniem niniejszej Umowy, w okresie obowiązywania "
"Umowy oraz przez okres pięciu (5) lat po jej rozwiązaniu. "
"Powyższe ograniczenia nie znajdują zastosowania do informacji "
"(a) powszechnie dostępnych bez winy Strony zobowiązanej oraz "
"(b) co do których obowiązek ujawnienia wynika z bezwzględnie "
"obowiązujących przepisów prawa."
),
"output": {
"found": True,
"text": "[verbatim § 9 text]",
"source_location": "§ 9",
"confidence": 0.93,
"extraction_prompt_version": "confidentiality_v1",
"requires_counsel_review": True,
"duration_years": 5,
"mutual": True,
"exceptions": ["publicly_available", "required_by_law"],
"survives_termination": True,
"residuals_clause": False,
"preliminary_status": "Needs Attention",
"key_observations": [
"Mutual 5-year survival — duration acceptable, on the longer side of PL market norm (3-5 years)",
"Missing exceptions: prior_knowledge + independently_developed — recipient cannot use info already known to them",
"REQUIRES LEGAL COUNSEL SIGN-OFF",
],
"suggested_questions_for_counsel": [
"Negotiate adding prior_knowledge + independently_developed exceptions before signing?",
"Is 5 years appropriate given the technical nature of info exchanged?",
],
},
},
# 4) Clause absent — found=false
{
"input": (
"Section 12 Governing Law. This Agreement shall be governed by "
"the laws of the Republic of Poland. Section 13 Notices. Any "
"notice required under this Agreement shall be in writing and "
"delivered to the addresses set forth above."
),
"output": {
"found": False,
"confidence": 0.85,
"extraction_prompt_version": "confidentiality_v1",
"requires_counsel_review": True,
"duration_years": None,
"mutual": None,
"exceptions": [],
"survives_termination": None,
"residuals_clause": False,
"preliminary_status": None,
"key_observations": [
"No confidentiality clause found in the analyzed text — verify whether confidentiality is covered by a separate NDA",
"REQUIRES LEGAL COUNSEL SIGN-OFF",
],
"suggested_questions_for_counsel": [
"Is there a separate NDA covering this engagement?",
"Should we add a confidentiality clause given the nature of information that will be exchanged?",
],
},
},
]
@@ -1,10 +1,17 @@
"""Per-clause-type Pydantic models. Sprint 2: liability only.
"""Per-clause-type Pydantic models.
Sprint 2: liability.
Sprint 4: + confidentiality.
Future clause types added per compass-clause-taxonomy adding-clause workflow
(7-step: ADR + schema + zod mirror + CLAUSE_TYPES enum + prompt v1 + golden
20+ + eval test + migration + UI form field + per-jurisdiction variants).
"""
from compass_schemas.clauses.base import ClauseBase, ConfidenceScore
from compass_schemas.clauses.confidentiality import (
ConfidentialityClause,
ConfidentialityException,
)
from compass_schemas.clauses.liability import (
CarveOut,
Currency,
@@ -18,6 +25,8 @@ __all__ = [
"CarveOut",
"ClauseBase",
"ConfidenceScore",
"ConfidentialityClause",
"ConfidentialityException",
"Currency",
"LiabilityCap",
"LiabilityClause",
@@ -0,0 +1,121 @@
"""ConfidentialityClause schema — Sprint 4 W3, second concrete clause type.
Validates the add-clause workflow established in Sprint 2 with Liability:
- inherits :class:`ClauseBase` for the 6 standard fields
- two ``model_validator``s parallel to LiabilityClause:
* enforce_counsel_disclaimer — auto-append the legal-tech sign-off line
* flag_indefinite_duration — downgrade Approved -> Needs Attention when
``duration_years is None`` (indefinite confidentiality is a top red flag)
- mirrored in ``apps/web/src/components/contract-form/clauses/confidentiality.ts``
PL legal context (full overlay in ``compass_jurisdictions.pl.confidentiality``):
- Ustawa o zwalczaniu nieuczciwej konkurencji (UoZNK) art. 11 — trade-secret
protection persists as long as the statutory criteria are met; no fixed limit.
- KC art. 72¹ — liability for breaching confidentiality of info from negotiations.
- KC art. 484 § 2 — courts can reduce "rażąco wygórowana" contractual penalty.
Indefinite contractual confidentiality without scope narrowing is flagged
because (a) it duplicates UoZNK statutory protection unnecessarily and
(b) may collide with restraint-of-trade rules in some EU jurisdictions.
"""
from __future__ import annotations
from typing import Literal
from pydantic import Field, model_validator
from compass_schemas.clauses.base import ClauseBase
ConfidentialityException = Literal[
"publicly_available",
"prior_knowledge",
"required_by_law",
"independently_developed",
"consent_disclosure",
]
PreliminaryStatus = Literal["Approved", "Needs Attention", "Rejected"]
class ConfidentialityClause(ClauseBase):
"""Confidentiality / non-disclosure clause."""
duration_years: int | None = Field(
default=None,
description=(
"Confidentiality obligation duration in years. None = indefinite — "
"flagged by the model validator because indefinite contractual "
"confidentiality without explicit scope narrowing is a top red flag "
"(restraint-of-trade jurisprudence in many EU jurisdictions)."
),
)
mutual: bool | None = Field(
default=None,
description="True = both parties bound symmetrically; False = one-sided NDA",
)
exceptions: list[ConfidentialityException] = Field(
default_factory=list,
description=(
"Explicit carve-outs from the obligation. Market-practice minimum: "
"publicly_available + prior_knowledge + required_by_law + "
"independently_developed. Missing any of these four is a red flag."
),
)
survives_termination: bool | None = Field(
default=None,
description="True if the obligation persists after contract end",
)
residuals_clause: bool = Field(
default=False,
description=(
"True when the contract includes a 'residuals' allowance (recipient may "
"use general knowledge retained in unaided memory). Common in US tech "
"licenses, rare in PL B2B — flag for review if present in PL contract."
),
)
preliminary_status: PreliminaryStatus | None = Field(
default=None,
description="AI preliminary assessment. Human counsel sign-off ALWAYS required.",
)
key_observations: list[str] = Field(
default_factory=list,
max_length=5,
description=(
"Bullet points for human reviewer. MUST include "
"'REQUIRES LEGAL COUNSEL SIGN-OFF' (enforced by validator)."
),
)
suggested_questions_for_counsel: list[str] = Field(
default_factory=list,
max_length=5,
)
@model_validator(mode="after")
def enforce_counsel_disclaimer(self) -> "ConfidentialityClause":
"""Hardcoded disclaimer presence — mirrors LiabilityClause."""
if self.found and self.key_observations:
joined = " ".join(self.key_observations).lower()
if "requires legal counsel sign-off" not in joined:
self.key_observations.append("REQUIRES LEGAL COUNSEL SIGN-OFF")
return self
@model_validator(mode="after")
def flag_indefinite_duration(self) -> "ConfidentialityClause":
"""Indefinite confidentiality → downgrade Approved to Needs Attention.
Mirrors LiabilityClause.flag_unlimited_liability — the model should
never let unbounded scope through as Approved without an explicit
positive signal in the text.
"""
if (
self.found
and self.duration_years is None
and self.preliminary_status == "Approved"
):
self.preliminary_status = "Needs Attention"
self.key_observations.insert(
0,
"Indefinite confidentiality (no time limit) — verify scope is narrowed "
"to trade secrets and confirm enforceability in governing-law jurisdiction.",
)
return self