Cronjob Documentation System
This directory contains auto-generated documentation for all cronjobs defined in system-crontab.md.
Overviewβ
Cronjobs are production-critical workflows that run silently in the background. This documentation system ensures:
- π Visibility: Every cronjob has structured documentation
- π Traceability: Links from cron schedules to Symfony Command classes
- β οΈ Risk Assessment: Identification of critical workflows (sales, payments, stock)
- π Freshness: Automated checks for documentation completeness and staleness
- π¨ CI Enforcement: Automated validation that fails on missing or outdated docs
Directory Structureβ
docs/
βββ system-crontab.md # Source of truth for all cronjobs
βββ cronjobs/ # Auto-generated documentation per command
β βββ menzzo-v2-sales.md
β βββ menzzo-v2-products.md
β βββ ...
βββ meta/
βββ documentation-progress.md # Coverage report and TODO tracking
Documentation Formatβ
Each cronjob documentation file follows this structure:
---
title: "command:name"
type: cronjob
source: system-crontab
status: active | undocumented | needs-regeneration
last_verified: YYYY-MM-DD
schedule:
- "*/10 * * * *"
command:
- "full:command --with-options"
risk_level: critical | high | medium | unknown
command_class: "src/Path/To/CommandClass.php"
regeneration:
trigger: "Cron definition or command code changed"
instruction: "Re-run documentation agent starting from system-crontab.md"
---
# Command Name
## Overview
...
Risk Levelsβ
- π΄ CRITICAL: Commands involving sales, payments, refunds, or stock mutations
- π‘ HIGH: Commands with significant business impact (products, sync, orders)
- π’ MEDIUM: Supporting commands (logs, stats, alerts, notifications)
- βͺ UNKNOWN: Risk needs assessment through code inspection
Generating Documentationβ
Initial Generationβ
To generate all cronjob documentation from scratch:
python3 tools/cronjob_doc_generator.py
This will:
- Parse
docs/system-crontab.mdfor all active cron entries - Extract unique Symfony console commands
- Generate documentation files in
docs/cronjobs/ - Attempt to locate corresponding Command class files
- Generate
docs/meta/documentation-progress.mdwith coverage statistics
When to Regenerateβ
Run the generator whenever:
- β
Cron entries are added, removed, or modified in
system-crontab.md - β Command schedules change
- β New Command classes are created
- β Command classes are moved or renamed
- β You want to refresh coverage statistics
Regeneration Policyβ
NEVER manually update generated documentation without regenerating.
If a cronjob changes:
- Update
system-crontab.mdif the cron schedule changed - Re-run
python3 tools/cronjob_doc_generator.py - Manually enhance the generated docs with business intent
- Update
last_verifieddate
CI Enforcementβ
Documentation updates should be validated locally and in Jenkins when relevant files change.
What It Checksβ
- β
All cronjobs in
system-crontab.mdhave corresponding documentation files - β
docs/meta/documentation-progress.mdexists and is parseable - β οΈ Warns about commands without located class files (undocumented)
- β οΈ Warns about commands with unknown risk levels
- β οΈ Identifies potentially stale documentation (>90 days old)
- π Reports coverage statistics
CI Failuresβ
The CI will fail if:
- Documentation files are missing for cronjobs
system-crontab.mdordocumentation-progress.mdis missing- Documentation structure is malformed
The CI will pass with warnings if:
- Command classes couldn't be located (needs manual investigation)
- Risk levels are marked as "unknown"
- Documentation is marked as "undocumented"
Documentation Workflowβ
1. Initial Bootstrap (DONE)β
- Parse
system-crontab.md - Generate skeleton documentation for all cronjobs
- Create progress tracking
- Set up CI enforcement
2. Code Traceability (IN PROGRESS)β
For each cronjob:
-
Locate Command Class
- Already auto-detected for 95/115 commands
- Remaining 20 need manual investigation
-
Add @doc. Annotations* (TODO)
- Add structured documentation tags to Command classes
- Example:
/*** @doc.intent: Syncs sales from Magento 2 to LogiDAV ERP* @doc.side_effects: Decrements stock, sends customer emails* @doc.risk: critical - modifies sales and stock data*/
-
Enhance Documentation (TODO)
- Fill in business purpose and workflow
- Document side effects and dependencies
- Add error handling procedures
3. Maintenance (ONGOING)β
- Run generator after crontab changes
- Keep
last_verifieddates current - Monitor CI warnings
- Address high-risk undocumented commands first
Priority Tasksβ
Based on documentation-progress.md:
π΄ Critical Priority (46 commands)β
These commands involve sales, payments, refunds, or stock and require immediate attention:
menzzo:v2:salesmenzzo:v2:sales:paymentmenzzo:sale:shipping:dropshipmenzzo:refund:check- ... (see full list in progress doc)
π‘ High Priority (40 commands)β
These commands have significant business impact:
menzzo:v2:productsmenzzo:sync:shipping-ratesmenzzo:product:stat- ... (see full list in progress doc)
βͺ Unknown Risk (21 commands)β
These commands need risk assessment through code inspection.
Key Principlesβ
- Crontab is Source of Truth:
system-crontab.mdis the authoritative definition - Never Silent: Cronjobs run in background but must be documented
- Operational Debt: Undocumented cronjobs are technical debt
- Regenerate, Don't Edit: Always regenerate base docs from source
- Code Linkage: Documentation must trace to actual Command classes
- Risk First: Prioritize documenting critical workflows
Commands Not in This Systemβ
This system tracks cronjobs only. It does NOT document:
- API endpoints
- Web workflows
- Manual console commands
- Event listeners
- Message queue consumers
These will be addressed in separate documentation initiatives.
Troubleshootingβ
Command class not foundβ
If a Command class can't be located:
- Search manually:
find src/ -name "*Command.php" | xargs grep "setName('command:name')" - Check if it's an external script (not Symfony)
- Update the finder logic in
tools/cronjob_doc_generator.pyif needed
Documentation out of syncβ
If documentation doesn't match system-crontab.md:
# Regenerate everything
python3 tools/cronjob_doc_generator.py
# Check what changed
git diff docs/cronjobs/
CI fails on PRβ
If CI fails:
- Check the error message in Jenkins
- Regenerate docs locally with
python3 tools/cronjob_doc_generator.py - Regenerate docs if needed
- Commit and push the updates
Related Documentationβ
../system-crontab.md- Source crontab../meta/documentation-progress.md- Coverage report../../tools/cronjob_doc_generator.py- Generator script../../Jenkinsfile- CI pipeline
Questions?β
This documentation system was created as part of a cronjob-first documentation initiative. It treats cronjobs as production-critical workflows that deserve first-class documentation and reliable validation.
For issues or improvements, discuss with the team or update the generator script.