---
phase: 03-registry-compatibility
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
  - src/clawrium/platform/registry/openclaw/manifest.yaml
  - src/clawrium/core/registry.py
  - tests/test_registry.py
autonomous: true
requirements: [REG-01]

must_haves:
  truths:
    - "System can load OpenClaw manifest from bundled registry directory"
    - "Manifest contains version, OS requirements, architecture, and dependencies"
    - "Manifest loading fails gracefully with clear error when manifest is missing or malformed"
  artifacts:
    - path: "src/clawrium/platform/registry/openclaw/manifest.yaml"
      provides: "OpenClaw claw manifest with entries for supported platforms"
      contains: "name: openclaw"
    - path: "src/clawrium/core/registry.py"
      provides: "Registry loading functions"
      exports: ["load_manifest", "list_claws", "get_claw_info", "ManifestEntry", "ClawManifest"]
    - path: "tests/test_registry.py"
      provides: "Tests for registry loading"
      min_tests: 6
  key_links:
    - from: "src/clawrium/core/registry.py"
      to: "src/clawrium/platform/registry/*/manifest.yaml"
      via: "pkg_resources or importlib.resources"
      pattern: "resources\\.(files|read_text|as_file)"
---

<objective>
Create claw manifest structure and registry loading module.

Purpose: Enable the system to discover available claw types and their requirements from bundled manifest files. This provides the foundation for compatibility checking and the registry CLI commands.

Output: OpenClaw manifest file, registry loading module with typed data structures, and comprehensive tests.
</objective>

<execution_context>
@/home/devashish/workspace/ric03uec/clawrium/.claude/get-shit-done/workflows/execute-plan.md
@/home/devashish/workspace/ric03uec/clawrium/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/03-registry-compatibility/03-CONTEXT.md

<interfaces>
<!-- Key types and contracts the executor needs -->

From pyproject.toml (dependencies to add):
```toml
dependencies = [
    "pyyaml>=6.0.0",
    "packaging>=24.0",  # For semver comparison
]
```

From 03-CONTEXT.md manifest schema (D-01 through D-06):
```yaml
name: openclaw
description: "Brief description of claw"
entries:
  - version: "1.2.0"
    os: ubuntu
    os_version: "24.04"
    arch: x86_64
    requirements:
      min_memory_mb: 1024
      gpu_required: false
      dependencies:
        nodejs: ">=20.0.0"
```

TypedDict schemas for registry.py:
```python
from typing import TypedDict

class Requirements(TypedDict):
    min_memory_mb: int
    gpu_required: bool
    dependencies: dict[str, str]  # e.g., {"nodejs": ">=20.0.0"}

class ManifestEntry(TypedDict):
    version: str
    os: str
    os_version: str
    arch: str
    requirements: Requirements

class ClawManifest(TypedDict):
    name: str
    description: str
    entries: list[ManifestEntry]
```
</interfaces>
</context>

<tasks>

<task type="auto" tdd="true">
  <name>Task 1: Create OpenClaw manifest and registry loader</name>
  <files>
    src/clawrium/platform/__init__.py
    src/clawrium/platform/registry/__init__.py
    src/clawrium/platform/registry/openclaw/manifest.yaml
    src/clawrium/core/registry.py
    tests/test_registry.py
    pyproject.toml
  </files>
  <read_first>
    - /home/devashish/workspace/ric03uec/clawrium/.planning/phases/03-registry-compatibility/03-CONTEXT.md (manifest schema D-01 through D-06)
    - /home/devashish/workspace/ric03uec/clawrium/pyproject.toml (current dependencies)
    - /home/devashish/workspace/ric03uec/clawrium/src/clawrium/core/hardware.py (TypedDict pattern)
  </read_first>
  <behavior>
    - Test: load_manifest("openclaw") returns ClawManifest with name="openclaw"
    - Test: load_manifest("nonexistent") raises ManifestNotFoundError
    - Test: load_manifest with malformed YAML raises ManifestParseError
    - Test: list_claws() returns ["openclaw"]
    - Test: get_claw_info("openclaw") returns dict with name, description, latest_version, supported_platforms
    - Test: get_claw_info("nonexistent") raises ManifestNotFoundError
  </behavior>
  <action>
    1. Add dependencies to pyproject.toml:
       - "pyyaml>=6.0.0" (for YAML parsing)
       - "packaging>=24.0" (for semver version comparison, used in compatibility)

    2. Create package structure:
       - src/clawrium/platform/__init__.py (empty)
       - src/clawrium/platform/registry/__init__.py (empty)

    3. Create OpenClaw manifest at src/clawrium/platform/registry/openclaw/manifest.yaml:
       ```yaml
       name: openclaw
       description: "Open-source AI assistant framework"
       entries:
         - version: "0.1.0"
           os: ubuntu
           os_version: "24.04"
           arch: x86_64
           requirements:
             min_memory_mb: 2048
             gpu_required: false
             dependencies:
               nodejs: ">=20.0.0"
         - version: "0.1.0"
           os: ubuntu
           os_version: "22.04"
           arch: x86_64
           requirements:
             min_memory_mb: 2048
             gpu_required: false
             dependencies:
               nodejs: ">=18.0.0"
       ```

    4. Create src/clawrium/core/registry.py with:
       - TypedDict classes: Requirements, ManifestEntry, ClawManifest
       - Exception classes: ManifestNotFoundError, ManifestParseError
       - load_manifest(claw_name: str) -> ClawManifest
         - Uses importlib.resources to read manifest.yaml from platform.registry.<claw_name>
         - Returns parsed ClawManifest
         - Raises ManifestNotFoundError if claw directory doesn't exist
         - Raises ManifestParseError if YAML is invalid
       - list_claws() -> list[str]
         - Lists subdirectories in platform/registry/ that contain manifest.yaml
         - Returns sorted list of claw names
       - get_claw_info(claw_name: str) -> dict
         - Returns summary dict: name, description, latest_version (highest semver), supported_platforms (list of "os os_version arch")
         - Raises ManifestNotFoundError if claw doesn't exist

    5. Create tests/test_registry.py with tests per <behavior> block.
       Use tmp_path fixture to create test manifests for error cases.
  </action>
  <verify>
    <automated>uv run pytest tests/test_registry.py -v</automated>
  </verify>
  <acceptance_criteria>
    - pyproject.toml contains "pyyaml>=6.0.0"
    - pyproject.toml contains "packaging>=24.0"
    - src/clawrium/platform/registry/openclaw/manifest.yaml exists and contains "name: openclaw"
    - src/clawrium/core/registry.py contains "def load_manifest("
    - src/clawrium/core/registry.py contains "def list_claws("
    - src/clawrium/core/registry.py contains "def get_claw_info("
    - src/clawrium/core/registry.py contains "class ManifestNotFoundError"
    - src/clawrium/core/registry.py contains "class ManifestParseError"
    - tests/test_registry.py contains at least 6 test functions (test_load_manifest, etc.)
    - uv run pytest tests/test_registry.py exits 0
  </acceptance_criteria>
  <done>
    - OpenClaw manifest exists at platform/registry/openclaw/manifest.yaml
    - Registry module loads manifests via importlib.resources
    - list_claws() returns ["openclaw"]
    - get_claw_info("openclaw") returns summary with latest version
    - All 6+ tests pass
  </done>
</task>

</tasks>

<verification>
```bash
# Verify manifest exists and is valid YAML
uv run python -c "import yaml; yaml.safe_load(open('src/clawrium/platform/registry/openclaw/manifest.yaml'))"

# Verify registry module exports
uv run python -c "from clawrium.core.registry import load_manifest, list_claws, get_claw_info, ManifestNotFoundError, ManifestParseError"

# Verify all tests pass
uv run pytest tests/test_registry.py -v

# Verify list_claws returns openclaw
uv run python -c "from clawrium.core.registry import list_claws; assert 'openclaw' in list_claws()"
```
</verification>

<success_criteria>
- OpenClaw manifest bundled at platform/registry/openclaw/manifest.yaml
- Registry loader reads manifests using importlib.resources
- load_manifest("openclaw") returns valid ClawManifest
- list_claws() returns ["openclaw"]
- get_claw_info("openclaw") returns summary with version, platforms
- Error cases (missing, malformed) raise appropriate exceptions
- All tests pass
</success_criteria>

<output>
After completion, create `.planning/phases/03-registry-compatibility/03-01-SUMMARY.md`
</output>
