docs(06-02): complete event codegen plan
- SUMMARY.md with codegen tool details and verification results - STATE.md updated with position, decisions, session context - ROADMAP.md progress: Phase 6 at 2/3 plans - REQUIREMENTS.md: QUAL-02 marked complete
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
---
|
||||
phase: 06-sql-consolidation-code-quality
|
||||
plan: 02
|
||||
subsystem: codegen
|
||||
tags: [go-ast, codegen, typescript, go-generate, lefthook]
|
||||
|
||||
# Dependency graph
|
||||
requires: []
|
||||
provides:
|
||||
- Go→TypeScript event constant generator (genevents)
|
||||
- go:generate directive for automatic event sync
|
||||
- LibraryConfigChanged gap automatically fixed
|
||||
- Pre-commit codegen-check hook covers event constants
|
||||
affects: [frontend, backend-events]
|
||||
|
||||
# Tech tracking
|
||||
tech-stack:
|
||||
added: [go/ast, go/parser, go/token]
|
||||
patterns: [AST-based codegen for cross-language constant sync, atomic file writes via temp+rename]
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- backend/events/cmd/genevents/main.go
|
||||
modified:
|
||||
- backend/events/events.go
|
||||
- frontend/src/events.ts
|
||||
|
||||
key-decisions:
|
||||
- "Iterate f.Decls directly (not map) for deterministic declaration-order output"
|
||||
- "Strip trailing period from Go doc comments for cleaner TypeScript comments"
|
||||
- "Atomic writes via temp file + os.Rename to prevent partial output"
|
||||
|
||||
patterns-established:
|
||||
- "Cross-language constant sync: Go source of truth → go/ast parser → TypeScript codegen"
|
||||
- "go:generate directive per package with relative paths to output"
|
||||
|
||||
requirements-completed: [QUAL-02]
|
||||
|
||||
# Metrics
|
||||
duration: 2min
|
||||
completed: 2026-03-05
|
||||
---
|
||||
|
||||
# Phase 06 Plan 02: Event Codegen Summary
|
||||
|
||||
**Go→TypeScript event constant generator using go/ast, fixing LibraryConfigChanged gap and wiring pre-commit drift detection**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 2 min
|
||||
- **Started:** 2026-03-05T00:20:57Z
|
||||
- **Completed:** 2026-03-05T00:23:43Z
|
||||
- **Tasks:** 2
|
||||
- **Files modified:** 3
|
||||
|
||||
## Accomplishments
|
||||
- Built `genevents` codegen tool parsing Go AST for deterministic TypeScript output
|
||||
- Fixed missing `LibraryConfigChanged` constant — now automatically generated from Go source
|
||||
- Verified codegen-check pre-commit hook detects drift when Go constants change without regenerating TS
|
||||
- All 21 event constants synced between Go and TypeScript, frontend typecheck passes
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **Task 1: Create event codegen tool** - `3e9edd0` (feat)
|
||||
2. **Task 2: Wire codegen-check pre-commit hook** - No changes needed (lefthook.yml already correctly configured; task was verification-only)
|
||||
|
||||
## Files Created/Modified
|
||||
- `backend/events/cmd/genevents/main.go` - Go→TypeScript event constant generator using go/ast
|
||||
- `backend/events/events.go` - Added `//go:generate` directive for automatic codegen
|
||||
- `frontend/src/events.ts` - Regenerated with all 21 constants including LibraryConfigChanged
|
||||
|
||||
## Decisions Made
|
||||
- Iterated `f.Decls` directly (not collected into map) for deterministic declaration-order output
|
||||
- Stripped trailing periods from Go doc comments for cleaner TypeScript comments
|
||||
- Used atomic writes (temp file + `os.Rename`) to prevent partial output on failure
|
||||
- No lefthook.yml changes needed — existing `codegen-check` hook already runs `go generate ./...` which now includes the event generator
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
None - plan executed exactly as written.
|
||||
|
||||
## Issues Encountered
|
||||
None
|
||||
|
||||
## User Setup Required
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
- Event codegen complete, ready for remaining Phase 6 plans
|
||||
- Pre-commit hook validates all generated code (templ, sqlc, events) in <2 seconds
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
---
|
||||
*Phase: 06-sql-consolidation-code-quality*
|
||||
*Completed: 2026-03-05*
|
||||
Reference in New Issue
Block a user