GAF Validation Guardrails for Node
Goal
Standardize safe runtime patterns in Node-based GAF automations.
Use This Skill When
- Creating a new Node automation entrypoint.
- Refactoring existing task runtime logic.
- User requests reliability hardening.
Guardrail Patterns
- Validate required env vars at startup with explicit error messages.
- Validate input payload required fields before processing.
- Enforce freshness/time-window checks where task requires it.
- Use idempotency keys for duplicate-run prevention.
- Acquire and release distributed locks safely (with
try/finally). - Use consistent status lifecycle:
running -> success|failed. - Emit structured logs for start, checkpoints, failures, and completion.
- Use
run.jsas the task entrypoint and place internal subtasks/modules underscripts/.
Implementation Sequence
- Add startup validation.
- Add input and schema-oriented checks.
- Wrap critical section with idempotency + lock.
- Add status writes and structured log events.
- Add failure-path handling that always closes resources.
Output
- list of guardrails added
- residual risks or TODOs
- quick local test plan
Guardrails
- Do not add brittle abstractions unless reused.
- Keep dependencies minimal and explicit in
package.json.