Appearance
Cortex Projects
This documentation explains how Cortex projects are structured.
Project Structure Overview
A Cortex project consists of the following key components:
shell
project/
├── .cortex/ # Configuration directory
│ └── project.ctx # Project definition file
│ └── variables.json # Optional: Central variable definitions
├── *.md # Markdown template files
└── *_test.yml # Test files for validating templates
Project Definition
The .cortex
directory contains the project definition file called project.ctx
, defining the project and its dependencies.
Example project.ctx
:
shell
project cortex.law/examples/nda
require {
cortex.law/templates/legal-base 1.0.0 #d285563c25c5152b1ae80fc64de64ff2775fa733
cortex.law/compliance/nda-rules 2.1.0 #3ddc9fc93c1d8ce560a3961e55547e5c78bd0f3e
}
The project.ctx
file specifies:
- Project identifier (
cortex.law/examples/nda
) - Dependencies with specific versions and checksums
Template Files
Cortex projects can include any number of markdown files with any structure. These files contain template content with variable placeholders.
Variables in templates use the syntax . For example, from the NDA template:
markdown
This Mutual Non-Disclosure Agreement (this "**Agreement**") is entered into as of {{effective_date}} (the "**Effective Date**"), by and between:
**{{party_a}}**, a company organized under the laws of {{party_a_jurisdiction}}, having its principal place of business at {{party_a_address}} ("**{{party_a_short}}**"), and
**{{party_b}}**, a company organized under the laws of {{party_b_jurisdiction}}, having its principal place of business at {{party_b_address}} ("**{{party_b_short}}**").
Variable Definitions
Variables are defined centrally in a variables.json
file, which provides values for the placeholders in templates. While the NDA example doesn't include this file, it's referenced as the central place for variables in a project.
Test Files
Test files (with _test.yml
suffix) validate the content of template files. They define assertions to ensure the template meets specific requirements.
Example from nda_test.yml
:
yaml
name: NDA Compliance Test
model: cortex.law/claude-3-7
document: nda.md
tests:
- name: Contains Confidentiality Definition
assert: contains
text: "Confidential Information"
- name: Has Proper Term Length
assert: regex
pattern: "period of \\{\\{term_years\\}\\} years"
validate: "$term_years <= 5"
The test file specifies:
- Test suite name
- AI model to use for AI-based assertions
- Target document to test
- List of assertions to validate the document content
Types of Assertions
The testing framework supports several types of assertions:
contains: Checks if the document contains specific text
yaml- name: Has Return of Information Clause assert: contains text: "return or destroy all Confidential Information"
regex: Uses regular expressions to match patterns
yaml- name: Has Proper Term Length assert: regex pattern: "period of \\{\\{term_years\\}\\} years" validate: "$term_years <= 5"
ai: Performs AI-powered evaluation based on specific criteria
yaml- name: Evaluates Scope of Confidentiality assert: ai prompt: "Evaluate if the confidentiality clause is sufficiently comprehensive" criteria: "Must cover both disclosed information and derived information, and include both written and oral disclosures"
AI assertions can use different models:
yaml
- name: Evaluates International Compliance
assert: ai
model: cortex.law/claude-3-5
prompt: "Evaluate if this NDA complies with international data protection standards"
criteria: "The agreement should address cross-border data transfers, comply with GDPR if applicable, and include provisions for data security measures"
Project Flexibility
Cortex projects are designed to be flexible:
- Can have any number of markdown files
- Can use any directory structure
- Templates can contain any content with variable placeholders
Summary
Cortex projects provide a framework for creating, validating, and managing templated documents. The project structure combines template files with variable definitions and includes a robust testing framework to ensure document compliance and quality.