Skip to content

[US-054-T1] Implement bundle validation engine with TDD #204

Description

@KochTobi-Agent

Task Description

Implement the core bundle validation engine for the oc bundle validate command using TDD (red-to-green approach).

TDD Cycle

RED Phase - Write Failing Tests

Create comprehensive tests in internal/bundle/bundle_test.go for ValidateBundle() function:

  • TestValidateBundle_ValidBundle - valid bundle passes validation
  • TestValidateBundle_MissingManifest - missing opencode-bundle.manifest.json returns error
  • TestValidateBundle_InvalidJSON - malformed JSON in manifest returns error
  • TestValidateBundle_InvalidManifestVersion - unsupported manifest_version returns error
  • TestValidateBundle_MissingRequiredFields - missing bundle_name/bundle_version/presets detected
  • TestValidateBundle_MissingEntrypoint - preset entrypoint file does not exist
  • TestValidateBundle_InvalidPresetJSON - preset file exists but contains invalid JSON
  • TestValidateBundle_MissingPromptFile - prompt_files entry references non-existent file

GREEN Phase - Implement to Pass

Add to internal/bundle/bundle.go:

  • ValidationError struct (Category, Message, File fields)
  • ValidationResult struct (Errors []ValidationError, Valid bool, Warnings []string)
  • ValidateBundle(bundleRoot string) (*ValidationResult, error) function

Validation logic per REQ-F-022:

  1. Check manifest file exists at opencode-bundle.manifest.json
  2. Validate manifest is valid JSON
  3. Validate against JSON schema (embedded 1.0.0.schema.json)
  4. For each preset: verify entrypoint path exists
  5. For each preset: verify all prompt_files paths exist
  6. Validate each preset JSON file is valid JSON

Acceptance Criteria

  • All tests written and initially failing
  • Implementation passes all tests
  • Exit code semantics: validation errors return non-nil result with Valid=false
  • Error categories: manifest, schema, entrypoint, prompt_files, preset
  • Follows existing code patterns in internal/bundle/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions