Appearance
Cortex Project Definition Files
This documentation explains the purpose and structure of project definition files in Cortex projects.
Overview
Every Cortex project includes a project definition file, which serves a similar role to go.mod
in Golang projects. This file defines the project identity and its dependencies.
File Location
The project definition file is located in the .cortex
directory at the root of the project and is named project.ctx
.
File Structure
The project definition file has a straightforward structure:
project [project-identifier]
require {
[dependency-identifier] [version] [checksum]
[dependency-identifier] [version] [checksum]
...
}
Example from NDA Project
Here's the project.ctx
file from the NDA example:
project cortex.law/examples/nda
require {
cortex.law/templates/legal-base 1.0.0 #d285563c25c5152b1ae80fc64de64ff2775fa733
cortex.law/compliance/nda-rules 2.1.0 #3ddc9fc93c1d8ce560a3961e55547e5c78bd0f3e
}
Let's break down each part:
Project Identifier
project cortex.law/examples/nda
This line declares the project's unique identifier, which typically follows a domain-style naming convention:
cortex.law
- The domain or organizationexamples
- A category or groupnda
- The specific project name
Dependencies Section
require {
cortex.law/templates/legal-base 1.0.0 #d285563c25c5152b1ae80fc64de64ff2775fa733
cortex.law/compliance/nda-rules 2.1.0 #3ddc9fc93c1d8ce560a3961e55547e5c78bd0f3e
}
The require
block lists all dependencies with:
- Dependency identifier: Similar format to the project identifier
- Version number: Semantic versioning (e.g., 1.0.0, 2.1.0)
- Checksum: SHA hash starting with # to verify integrity
Dependency Management
Cortex uses this file to:
- Identify the project: The unique identifier distinguishes this project from others
- Track dependencies: Lists other Cortex packages this project needs
- Pin versions: Ensures consistent behavior by specifying exact versions
- Verify integrity: Checksums validate that dependencies haven't been altered
Types of Dependencies
A Cortex project might depend on various types of packages:
- Templates: Base templates that provide structure and common elements
- Rules: Compliance or validation rules for specific document types
- Libraries: Reusable components for specific domains
- Utilities: Helper functions or shared code
Version Management
Cortex follows semantic versioning principles:
- Major version (1.x.x): Indicates breaking changes
- Minor version (x.1.x): Adds features in a backward-compatible manner
- Patch version (x.x.1): Backward-compatible bug fixes
Working with Project Definition Files
Creating a New Project
When creating a new Cortex project:
- Create the
.cortex
directory - Create a
project.ctx
file with your project identifier - Add any dependencies your project needs
Adding Dependencies
To add a dependency to an existing project:
- Identify the dependency's identifier and version
- Add it to the
require
block in yourproject.ctx
file - The system will calculate and add the appropriate checksum
Updating Dependencies
To update a dependency:
- Change the version number to the desired version
- The system will update the checksum accordingly
Best Practices
- Meaningful Identifiers: Choose descriptive, hierarchical project identifiers
- Version Control: Keep your project definition file in version control
- Dependency Documentation: Document why each dependency is needed
- Version Pinning: Always pin to specific versions to ensure reproducibility
- Regular Updates: Periodically check for and apply dependency updates
Relationship to Other Files
The project definition file works in conjunction with:
- Template files (
.md
): The actual document templates - Test files (
_test.yml
): Validation rules for templates - Variable files (
variables.json
): Data used to populate templates
Together, these files form a complete Cortex project ecosystem.