3.2 KiB
3.2 KiB
Workflow Schema Optimization Plan
Current State (Commit 7660f61)
What's Implemented
- Original schema preserved:
workflow-v1.0.jsonremains source of truth with 291 definitions - Optimization script:
script/optimize-workflow-schema.jsprunes unused definitions - Generated files (gitignored):
workflow-v1.0.optimized.json- 281 definitions (pruned)workflow-v1.0.optimized.min.json- minified version loaded at runtime
- Build pipeline:
npm run minify-jsonchains optimize → minify - Tests:
workflow-schema.test.tsvalidates schema integrity
10 Pruned Definitions
These are unreachable from workflow-root-strict entry point:
workflow-root(non-strict variant)on(non-strict variant)on-mapping(non-strict variant)job-if-resultstep-if-resultboolean-needs-contextnumber-needs-contextstring-needs-contextboolean-steps-contextnumber-steps-context
Size Savings
| Metric | Original | Optimized | Savings |
|---|---|---|---|
| Definitions | 291 | 281 | 10 removed |
| Minified | 71,061 B | 69,022 B | 2.9% |
| Gzipped | 12,318 B | 12,172 B | 1.2% |
Optimization Strategies Evaluated
✅ Pruning Unused Definitions (IMPLEMENTED)
- Removes definitions not reachable from entry point
- 1.2% gzip savings
- Low complexity, no runtime overhead
❌ Key Shortening
- Replace long keys with short codes (e.g.,
description→d) - 1.5% gzip savings
- NOT WORTH IT: Adds complexity, minimal benefit after gzip
❌ String Interning
- Deduplicate repeated strings into lookup table
- Makes gzip WORSE (-0.5%)
- NOT WORTH IT: Gzip already handles repetition
❌ Compact Format (like webhooks)
- Restructure to array-based format
- Makes gzip WORSE (-0.4%)
- NOT WORTH IT: Schema structure doesn't benefit
❌ Split Descriptions
- Separate file for descriptions
- Adds 791 bytes when both files gzipped
- NOT WORTH IT: Worse total size
Future Work
Update from Server
The current schema may be missing some definitions from the latest server version. A future PR should:
- Fetch latest
workflow-v1.0.jsonfrom dotcom server - Update the source file
- Verify tests still pass
- Note: Server version had issues last checked (e.g.,
coerce-raw, missingbrancheson merge-group)
Entry Point
- Entry point:
workflow-root-strict(defined inworkflow-constants.ts) - Non-strict
workflow-rootexists but is unused in this codebase
Files
workflow-parser/
├── src/
│ ├── workflow-v1.0.json # Source of truth (tracked, 291 defs)
│ ├── workflow-v1.0.optimized.json # Pruned (gitignored, 281 defs)
│ ├── workflow-v1.0.optimized.min.json # Minified (gitignored)
│ └── workflows/
│ ├── workflow-schema.ts # Loader (imports optimized.min.json)
│ └── workflow-schema.test.ts # Schema integrity tests
└── script/
└── optimize-workflow-schema.js # Pruning script
Test Coverage
workflow-schema.test.ts:- Schema loads from workflow-root-strict
- All referenced definitions are reachable
- Critical definitions exist (jobs, steps, runs-on, etc.)