This document defines the schema evolution, migration rules, and compatibility policies for caatinga.artifacts.json.
We enforce a strict versioning convention for the caatinga.artifacts.json format:
- Incremental Bumps: Schema versions are represented by sequential integers (1, 2, 3, etc.) defined in the root
versionfield. - Non-Breaking Changes (Minor updates): Adding optional fields (e.g. metadata) does not require changing the schema version. The format remains fully compatible.
- Breaking Changes (Major updates): Modifying structural shapes, changing required types, or removing fields requires a schema version increment (e.g., from
2to3) and the implementation of an explicit migration script in the Orchestration Engine.
To avoid lock-in and support teams upgrading their CLI, Caatinga implements the following rules:
- New Projects Start on v2:
ctg init(template or--minimal) andctg zk initalways writeversion: 2; a template that ships a v1caatinga.artifacts.json(for example a custom one viaCAATINGA_TEMPLATES_DIR) is migrated while scaffolding. Before 3.12.0, the official templates shippedversion: 1. - Read As-Is:
readArtifactsaccepts both version1and version2files and parses them without converting the shape in memory. Existing v1 files are migrated only byctg migrate artifactsor the writeback below. - Writeback on History-Producing Writes: A v1 file is bumped to
version: 2on the first write that records history:ctg upgrade, a superseding redeploy (ctg deploy --force/--upgrade), orctg rollback. A plain first deploy keepsversion: 1. Runctg migrate artifactsto bump the file explicitly.
- Safety Fail-Fast: If the Orchestration Engine detects an artifacts file version greater than
CURRENT_ARTIFACTS_SCHEMA_VERSION(e.g.,parsedJson.version > 2), it immediately halts execution with aCAATINGA_ARTIFACT_INVALIDerror. - Why this matters: Preventing older CLIs from parsing newer schemas protects users from corrupted metadata state or loss of registry history.
When a future breaking change is introduced:
- Schema Definition:
- Define the new schema version in
packages/core/src/artifacts/artifact.schema.ts(e.g.CaatingaArtifactsV3Schema). - Bump
CURRENT_ARTIFACTS_SCHEMA_VERSIONto the new version number. - Update
CaatingaArtifactsSchemaunion.
- Define the new schema version in
- Migration Code:
- Create a migration function
migrateArtifactsToV3inpackages/core/src/artifacts/migrate-artifacts.ts. - Update
migrateArtifactsFileto invoke the chain of migrations sequentially (v1 → v2 → v3).
- Create a migration function
- Test Coverage:
- Add unit test fixtures capturing old schema files and verify they convert correctly.
Run from the repository root:
pnpm test:compatThis executes:
packages/core/src/compat/compat.test.ts— v1/v2 fixtures, migration roundtrip,migrateArtifactsFilepackages/core/src/compat/exports-snapshot.test.ts—@caatinga/coreand@caatinga/clientpackage.jsonexportspackages/core/src/public-api/export-manifest.test.ts— Tier 1 client export manifestpackages/core/src/recovery/recovery-scenarios.test.ts— artifact and CLI recovery paths
Fixtures live in packages/core/src/compat/fixtures/.
Consumer isolation (pnpm test:consumer) validates packed tarball installs end-to-end.