Arckit data mesh contract

From tractorjuice/arckit-codex · View interactive version

Arckit data mesh contract is an AI agent skill from the GitHub repository tractorjuice/arckit-codex. Create federated data product contracts for mesh architectures with SLAs, governance, and interoperability guarantees (project)

How to use this skill

Skill file

You are helping an enterprise architect create a data mesh contract for a data product in a federated mesh architecture.

This command generates a data-mesh-contract document that defines the formal agreement between a data product provider (domain team) and consumers, following the Open Data Contract Standard (ODCS) v3.2.0.

User Input

$ARGUMENTS

Instructions

Note: Before generating, scan projects/ for existing project directories. For each project, list all ARC-*.md artifacts, check external/ for reference documents, and check 000-global/ for cross-project policies. If no external docs exist but they would improve output, ask the user.

Step 0: Check Prerequisites

IMPORTANT: Before generating a data mesh contract, verify that foundational artifacts exist:

  1. Architecture Principles (REQUIRED):

```text

❌ Architecture principles not found.

Data mesh contracts require architecture principles to be established first.

Principles should include mesh governance standards (federated ownership, data as a product, self-serve infrastructure).

Please run: $arckit-principles Create enterprise architecture principles

Then return here to generate the data mesh contract.

```

  1. Data Model (HIGHLY RECOMMENDED):

```text

⚠️ Warning: No data model found for this project.

Data mesh contracts are typically derived from existing data models (entities become data products).

Consider running: $arckit-data-model Create data model for [project name]

You can proceed without a data model, but you'll need to define schema from scratch.

Continue anyway? (yes/no)

```

  1. Stakeholder Analysis (RECOMMENDED):

```text

⚠️ Warning: No stakeholder analysis found.

Stakeholder analysis helps identify:

Consider running: $arckit-stakeholders Analyze stakeholders for [project name]

You can proceed without stakeholder analysis, but ownership roles will be generic placeholders.

Continue anyway? (yes/no)

```

Gathering rules — the one-message interview in .arckit/references/interview-pattern.md:

Step 1: Parse User Input

Extract the data product name from the user's message. Examples:

The data product name should be:

If the user didn't provide a clear data product name, ask:

What is the name of the data product for this contract?

Examples:
- customer-payments
- seller-analytics
- order-events
- fraud-detection-features

Data product name (kebab-case):

Step 2: Identify the target project

1. Use Glob to list projects/*/ directories and find the highest NNN-* number (or start at 001 if none exist)

2. Calculate the next number (zero-padded to 3 digits, e.g., 002)

3. Slugify the project name (lowercase, replace non-alphanumeric with hyphens, trim)

4. Use the Write tool to create projects/{NNN}-{slug}/README.md with the project name, ID, and date — the Write tool will create all parent directories automatically

5. Also create projects/{NNN}-{slug}/external/README.md with a note to place external reference documents here

6. Set PROJECT_ID = the 3-digit number, PROJECT_PATH = the new directory path

Important: If the script creates a NEW project, inform the user:

Created new project: Project {project_id} - {project_name}
   Location: {project_path}

Note: This is a new project. You may want to run these commands first:
- $arckit-stakeholders - Identify domain owners and consumers
- $arckit-data-model - Define entities that become data products
- $arckit-requirements - Capture DR-xxx data requirements

If the project ALREADY EXISTS, just acknowledge it:

Using existing project: Project {project_id} - {project_name}
   Location: {project_path}

Step 3: Create Contract Directory

Data mesh contracts should be organized in a subdirectory. The directory will be created automatically when saving the file with the Write tool.

The contract file will use the multi-instance naming pattern:

{project_path}/data-contracts/ARC-{PROJECT_ID}-DMC-{NNN}-v1.0.md

Where {NNN} is the next sequential number for contracts in this project. Check existing files in data-contracts/ and use the next number (001, 002, ...).

Step 4: Read the Template

Read the data mesh contract template:

Read the template (with user override support):

Tip: Users can customize templates with $arckit-customize data-mesh-contract

Step 4b: Read external documents and policies

Step 5: Gather Context from Existing Artifacts

IF ARC-*-DATA-*.md exists in the project:

IF ARC-*-REQ-*.md exists:

IF ARC-*-STKE-*.md exists:

IF projects/000-global/ARC-000-PRIN-*.md exists:

Step 6: Generate the Data Mesh Contract

Using the template and context gathered, generate a comprehensive data mesh contract.

Key Sections to Populate:

  1. Document Information:
  1. Fundamentals (Section 1):
  1. Schema (Section 2):
  1. Data Quality (Section 3):
  1. Service-Level Agreement (Section 4):
  1. Access Methods (Section 5):
  1. Security and Privacy (Section 6):
  1. Governance and Change Management (Section 7):
  1. Consumer Obligations (Section 8):
  1. Pricing (Section 9):
  1. Infrastructure (Section 10):
  1. Observability (Section 11):
  1. Testing (Section 12):
  1. Limitations (Section 13):
  1. Roadmap (Section 14):
  1. Related Contracts (Section 15):
  1. Appendices (Section 16):

Step 7: Construct Document ID


CRITICAL - Auto-Populate Document Control Fields:

Before completing the document, populate ALL document control fields in the header:

Construct Document ID:

Populate Required Fields:

Auto-populated fields (populate these automatically):

User-provided fields (extract from project metadata or user input):

Calculated fields:

Pending fields (leave as [PENDING] until manually updated):

Populate Revision History:

| 1.0 | {DATE} | ArcKit AI | Initial creation from `$arckit-data-mesh-contract` command | [PENDING] | [PENDING] |

Populate Generation Metadata Footer:

The footer should be populated with:

**Generated by**: ArcKit `$arckit-data-mesh-contract` command
**Generated on**: {DATE} {TIME} GMT
**ArcKit Version**: {ARCKIT_VERSION}
**Project**: {PROJECT_NAME} (Project {PROJECT_ID})
**AI Model**: [Use actual model name, e.g., "Claude Sonnet 5 (session default)"]
**Generation Context**: [Brief note about source documents used]

Before writing the file, read .arckit/references/quality-checklist.md and verify all Common Checks plus the DMC per-type checks pass. Fix any failures before proceeding.

Step 8: Write the Contract File

IMPORTANT: Use the Write tool to create the file. Do NOT output the full document content to the user (it will be 2000-4000 lines and exceed token limits).

Write tool:
  file_path: {project_path}/data-contracts/ARC-{PROJECT_ID}-DMC-{NNN}-v1.0.md
  content: {full contract content}

Note: Use the constructed document ID format for the filename.

Step 9: Show Summary to User

After writing the file, show the user a concise summary (do NOT show the full document):

✅ Data Mesh Contract Generated

**Contract**: ARC-{PROJECT_ID}-DMC-{NNN}-v1.0.md
**Location**: {project_path}/data-contracts/
**Document ID**: ARC-{project_id}-DMC-{NNN}-v1.0
**ODCS Version**: v3.2.0
**Contract Version**: 1.0.0
**Status**: DRAFT

---

## Contract Summary

**Data Product**: {data_product_name}
**Domain**: {domain_name}
**Purpose**: {brief_purpose}

### Schema
- **Objects**: {N} objects defined
- **Properties**: {M} total properties
- **PII Fields**: {P} fields contain PII

### SLA Commitments
- **Availability**: {99.9%} uptime
- **Response Time (p95)**: {<200ms}
- **Freshness**: {<5 minutes}
- **Data Retention**: {7 years}

### Quality Rules
- {N} automated quality rules defined
- Quality dimensions: Accuracy, Conformity, Completeness, Consistency, Timeliness, Uniqueness (ODCS calls validity `conformity`)

### Access Methods
- REST API: {endpoint}
- SQL Query: {database.schema.table}
- Data Lake: {s3://bucket/prefix}

### Security
- Classification: {OFFICIAL-SENSITIVE} (contains PII)
- Encryption: AES-256 at rest, TLS 1.3 in transit
- Access Control: RBAC (Consumer-Read, Analyst-FullRead, Admin)
- GDPR Compliant: ✅

### Governance
- Change Process: Minor (7 days notice), Major (90 days notice)
- Review Cycle: Quarterly
- Deprecation Policy: 90-day notice + migration support

---

## Next Steps

1. **Review Contract**: Open the file and customize placeholders ({...})
2. **Domain Team Review**: Product Owner should review all sections
3. **DPO Review** (if PII): Ensure GDPR compliance is accurate
4. **Security Review**: Validate encryption and access controls
5. **Publish to Catalogue**: Register contract in data catalogue for discovery
6. **Consumer Onboarding**: Set up sandbox environment for consumers to test

## Related Commands

- `$arckit-traceability` - Link this contract to requirements and consumers
- `$arckit-analyze` - Score contract completeness and governance quality
- `$arckit-dpia` - Generate Data Protection Impact Assessment (if PII present)

---

**Full contract**: `{project_path}/data-contracts/ARC-{PROJECT_ID}-DMC-{NNN}-v1.0.md` ({line_count} lines)

Step 10: Post-Generation Recommendations

Based on what artifacts exist, recommend next steps:

If no ARC--REQ-.md:

💡 Tip: Run $arckit-requirements to capture DR-xxx data requirements.
   These will inform SLA targets and quality rules in future contract updates.

If no ARC--STKE-.md:

💡 Tip: Run $arckit-stakeholders to identify domain owners and consumers.
   This will help assign real names to ownership roles instead of placeholders.

If PII exists but no ARC--DPIA-.md:

⚠️  This contract contains PII ({N} fields marked as PII).

UK GDPR Article 35 may require a Data Protection Impact Assessment (DPIA).

Consider running: $arckit-dpia Generate DPIA for {project_name}

If this is a UK Government project:

💡 UK Government Alignment:
   - Technology Code of Practice: Point 8 (Share, reuse and collaborate) ✅
   - National Data Strategy: Data foundations and Data availability pillars ✅
   - Government Data Quality Framework: 6 core dimensions covered ✅

Consider running:
   - $arckit-tcop - Technology Code of Practice assessment
   - $arckit-service-assessment - GDS Service Standard (if digital service)

Important Notes

  1. Token Limit Handling: ALWAYS use the Write tool for the full document. NEVER output the complete contract to the user (it's 2000-4000 lines). Only show the summary.
  1. ODCS Compliance: This contract follows Open Data Contract Standard (ODCS) v3.2.0, released 8 September 2026. In v3.2.0 the required fields are apiVersion, kind, id and version; status is optional but keep it. version must be a string, so write 1.0.0, not 1.0 (YAML reads 1.0 as a number). The Appendix A contains a YAML export that can be consumed programmatically, and it must validate against the ODCS v3.2.0 JSON Schema. That schema rejects keys it does not define at the top level and in schema objects, properties, quality rules and SLA entries, so put anything else in customProperties.
  1. UK Government Context: If this is a UK Government project, ensure:
  1. Traceability: The contract links to:
  1. Versioning: Use semantic versioning (MAJOR.MINOR.PATCH):
  1. Federated Ownership: The domain team owns this contract end-to-end. They are responsible for:
  1. One Contract Per Product: Don't bundle unrelated datasets. Each domain data product should have its own contract.
  1. Automation is Critical: The contract is meaningless without observability and automated policy enforcement. Ensure:

Example User Interactions

Example 1: Simple contract creation

User: $arckit-data-mesh-contract Create contract for customer payments
Assistant:
  - Checks prerequisites ✅
  - Creates project 001-customer-payments
  - Finds ARC-*-DATA-*.md with CUSTOMER and TRANSACTION entities
  - Generates contract mapping entities → objects
  - Shows summary (not full document)

Example 2: Contract without data model

User: $arckit-data-mesh-contract seller-analytics contract
Assistant:
  - Checks prerequisites ✅
  - Warns: No data model found
  - User confirms to proceed
  - Generates contract with generic schema placeholders
  - Recommends running $arckit-data-model first

Example 3: Contract with full context

User: $arckit-data-mesh-contract fraud-detection-features
Assistant:
  - Checks prerequisites ✅
  - Finds ARC-*-DATA-*.md, ARC-*-REQ-*.md, ARC-*-STKE-*.md
  - Maps entities → objects
  - Maps DR-xxx → quality rules
  - Maps NFR-P-xxx → SLA response time targets
  - Maps stakeholders → ownership roles
  - Generates comprehensive contract with minimal placeholders
  - Shows summary

Error Handling

If architecture principles don't exist:

If user provides unclear data product name:

If project creation fails:

If template file is missing:

If file write fails:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.