Priority 1: Schema Models (Depends on P0)
Task 4: HookConfig Pydantic Models
Status: NOT STARTED Agent: @python-cli-architect Dependencies: Task 2 Priority: 2 Complexity: M Accuracy Risk: High
Context
Need Pydantic models to validate hooks.json structure against official Claude Code hook schema with 15 event types and 3 hook action types.
Objective
Create type-safe Pydantic models for hooks.json validation that enforce official schema constraints.
Required Inputs
- Architecture spec: ./architect-plugin-linter.md lines 135-194 (HookConfig schema)
- Official docs: https://docs.anthropic.com/en/docs/claude-code/hooks.md (cite as comment)
- Example hooks.json files from codebase
Requirements
- Create
HookTypeStrEnum with values: COMMAND, PROMPT, AGENT - Create
HookEventTypeStrEnum with all 15 valid event names - Create
HookDefinitionPydantic model with discriminated union for type field - Create
EventMatcherPydantic model with matcher and hooks list - Create
HookConfigPydantic model with hooks dict structure - Add field validators for:
- Hook type field presence matching discriminator
- Regex pattern validity in matcher field
- Timeout positive integer validation
Constraints
- MUST cite official schema URL in model docstrings
- MUST use Pydantic 2.0+ discriminated unions for hook type
- MUST NOT execute regex patterns during validation (compile only)
- MUST preserve case-sensitivity of event names
Expected Outputs
- Modified file:
plugins/plugin-creator/scripts/plugin_validator.py(new models section) - 5 new Pydantic models defined
- Field validators for type matching and regex validation
- Docstrings with schema source citations
Acceptance Criteria
- All 15 event types defined in HookEventType enum
- HookDefinition validates type discriminator correctly
- Invalid regex patterns rejected with clear error
- Timeout validation rejects zero and negative values
- Models pass Pydantic schema validation
- Docstrings cite official docs URL
Verification Steps
- Create valid hooks.json test case, parse with HookConfig.model_validate()
- Create invalid hooks.json with bad event type, verify validation error
- Create invalid regex pattern, verify compilation error caught
- Run
mypy --stricton modified file - Verify Pydantic error messages reference field names correctly
CoVe Checks
Accuracy Risk: High (schema compliance is critical)
Key claims to verify:
- All 15 event types match official documentation exactly
- Hook type discriminator matches official schema
- Field validators match official requirements
Verification questions:
- Are all 15 event type names spelled and capitalized correctly?
- Does hook type discriminator allow all 3 action types?
- Are optional vs required fields correct per schema?
Evidence to collect:
- Fetch official schema:
WebFetch("https://docs.anthropic.com/en/docs/claude-code/hooks.md") - Cross-reference event names with official list
- Test with real hooks.json from codebase
- Fetch official schema:
Revision rule:
- If official schema differs from architecture spec, update models to match official schema
- Document any discrepancies found
Can Parallelize With: Task 5 (MCPConfig models), Task 6 (LSPConfig models), Task 7 (Agent enum models) Reason: Schema models are independent (different JSON files) Handoff: Provide model code, verification test outputs, official schema cross-reference