1.9 KiB
1.9 KiB
Story 3.2: Permission Code Generation System
Metadata
- Story ID: 3.2
- Title: Permission Code Generation System
- Epic: 3 - Module Framework
- Status: Pending
- Priority: High
- Estimated Time: 4-5 hours
- Dependencies: 3.1
Goal
Create automated permission code generation from module manifests to ensure type-safe permission constants.
Description
This story implements a code generation system that scans module manifests and generates type-safe permission constants, ensuring permissions are defined in one place and used consistently throughout the codebase.
Deliverables
1. Permission Generation Script (scripts/generate-permissions.go)
- Scan all
modules/*/module.yamlfiles - Extract permissions from manifests
- Generate
pkg/perm/generated.gowith Permission constants - Support for multiple modules
- Error handling and validation
- Format generated code
2. Go Generate Integration
//go:generatedirective inpkg/perm/perm.go- Automatic generation on build
- Integration with build process
3. Makefile Integration
make generatecommand- Run permission generation
- Verify generated code
Implementation Steps
-
Create Generation Script
- Create
scripts/generate-permissions.go - Implement YAML parsing
- Implement code generation
- Create
-
Add Go Generate Directive
- Add directive to
pkg/perm/perm.go - Test generation
- Add directive to
-
Update Makefile
- Add
make generatecommand - Integrate with build process
- Add
Acceptance Criteria
- Permission constants are generated from
module.yaml - Generated code is type-safe
- Code generation runs automatically
- Permissions follow naming convention
- Multiple modules are supported
- Generated code is properly formatted
Files to Create/Modify
scripts/generate-permissions.go- Generation scriptpkg/perm/perm.go- Add go:generate directiveMakefile- Add generate command