Validation Command

stamp context validate Command

Verify that generated LogicStamp context files match the expected schema and structure. Supports both multi-file validation (all folders) and single-file validation.

Syntax

stamp context validate [file]

[file] – Optional path to a context file created by the stamp context command.

  • With no arguments: Automatically validates all context files using context_main.json (multi-file mode). Falls back to context.json if context_main.json doesn't exist.
  • With a file argument: Validates that specific file (single-file mode). Can be a folder context file or the main index file.

What it checks

1Multi-File Mode (default with no arguments)

When context_main.json exists, validates all context files in your project:

  • Reads context_main.json to discover all folder context files
  • Validates each folder's context.json file
  • Reports comprehensive summary across all folders:
    • Total valid/invalid folders
    • Total errors and warnings across all files
    • Total nodes and edges across all files
  • Shows detailed validation results for each folder
  • Exit code reflects overall validation status (fails if any folder is invalid)

2. Single-File Mode: Folder Context Files

For Folder Context Files (context.json)

  • File exists and parses as JSON.
  • Top-level value is an array of LogicStampBundle objects.
  • Each bundle has the required fields (type, schemaVersion, entryId, graph, meta, etc.).
  • Contracts stored within nodes are UIFContract with schema version 0.3.
  • Warns when bundle hashes or schema versions diverge from expected values.

2. Single-File Mode: Main Index File

For Main Index File (context_main.json)

  • File exists and parses as JSON.
  • Structure matches LogicStampIndex schema.
  • Contains required fields: type, schemaVersion, projectRoot, summary, folders, meta.
  • Each folder entry has valid structure with path, contextFile, bundles, components, etc.
  • Warns when schema versions diverge from expected values.

Note: Validating only context_main.json (single-file mode) does not validate the folder context files themselves. Use multi-file mode (no arguments) to validate all files.

Exit Codes

CodeMeaning
0All files are structurally valid (warnings may be present).
1Validation failed (schema errors, unreadable file, invalid JSON, or any folder is invalid in multi-file mode).

Examples

Multi-File Mode (validates all context files)

# Validate all context files using context_main.json stamp context validate

Single-File Mode (validates a specific file)

# Validate a specific folder's context file stamp context validate src/components/context.json # Validate the main index file only (doesn't validate folder files) stamp context validate context_main.json # Validate custom named bundle stamp context validate artifacts/review-context.json

CI/CD Usage

Pair with the context command to block merges when context files become invalid.

Use multi-file mode (no arguments) to validate all context files in one command.

Combine with npm run scripts or Git hooks for automated checks.

Use the exit code to fail pipelines and prompt regeneration of context files.

Multi-file mode ensures comprehensive validation across the entire project.

Example CI validation (recommended):

# Validate all context files in one command (recommended) stamp context validate # This automatically validates: # - context_main.json structure # - All folder context.json files referenced in the index # - Reports comprehensive summary across all files # - Fails if ANY file is invalid

Legacy single-file approach (not recommended):

# Manual validation of individual files (old approach)
stamp context validate context_main.json && \
  stamp context validate context.json && \
  stamp context validate src/components/context.json

The multi-file mode is preferred because it automatically discovers all context files from the index, validates everything in one command, provides a comprehensive summary, and detects if any folder context files are missing or corrupted.