SOIL.DAYS_TO_STRESS_ADJUSTED not calculating - WEATHER.ET0 dependency not triggered
Problem
The computed term SOIL.DAYS_TO_STRESS_ADJUSTED is not being calculated during v3 intelligence job runs, despite being properly configured in the template.
Root Cause
WEATHER.ET0 is not being fetched during job execution, even though it's a required dependency for the DAYS_TO_STRESS calculation. The term exists in the queue configuration and historical ET0 data exists in the database, but new ET0 observations are not being created when DAYS_TO_STRESS_ADJUSTED is requested.
Evidence
Queue Configuration: Both terms present
SELECT jsonb_array_elements_text(queue_configuration->'environmental-data'->'dataRequired')
FROM industry_templates
WHERE template_id = 'sugarcane-standard';
-- Returns: WEATHER.ET0, SOIL.DAYS_TO_STRESS_ADJUSTED (among 43 total)
Recent Test Results (2025-10-13 02:12 UTC):
- ✅ CONFIG.KC_NDVI_ADJUSTED: 1.2 (working)
- ✅ SOIL.PAW_PERCENT_ENHANCED: 32.06% (working)
- ✅ SOIL.PAW_AVAILABLE_MM: 57.27mm (working)
- ❌ SOIL.DAYS_TO_STRESS_ADJUSTED: Not calculated
- ❌ WEATHER.ET0: Not fetched (last observation 2 hours prior at 00:08 UTC)
Formula Dependencies:
"dependencies": {
"required": [
"SOIL.SM10",
"SOIL.WP",
{
"term": "WEATHER.ET0",
"transform": "$slice(WEATHER.ET0, -7)",
"description": "Last 7 days of ET0 for average calculation"
}
],
"optional": ["CONFIG.KC_NDVI_ADJUSTED"]
}
Hypothesis
The dependency resolution system may not be triggering data fetches for terms that have transformations in their dependency specifications. The transform field might be causing the dependency resolver to skip the fetch step.
Investigation Needed
- Check ComputedTermService dependency resolution: Does it trigger fetches for dependencies with transformations?
- Verify TemplateDrivenProcessor execution order: Are transformed dependencies fetched before formula evaluation?
- Review VocabularyDataFetcher invocation: Is ET0 being requested when DAYS_TO_STRESS_ADJUSTED is in the term list?
- Check execution logs: Look for dependency resolution errors or skipped fetches
Expected Behavior
When SOIL.DAYS_TO_STRESS_ADJUSTED is in the queue configuration's dataRequired list:
- System should recognize
WEATHER.ET0as a required dependency - Fetch ET0 data for the last 7 days
- Transform the data using
$slice(WEATHER.ET0, -7) - Pass transformed data to the DAYS_TO_STRESS formula
- Calculate and persist the result
Current Workaround
None identified. The term simply doesn't calculate without ET0 data.
Template Context
- Template: sugarcane-standard v53.0
- Organization: org_33Ofeg1A2i4xPWEzPYL4tJrnjPD
- Feature: 324299cc-4220-4fbe-82e3-f8bae31c86bb
- Related Issue: #509 (PAW Phase 2 Implementation)
Files to Review
apps/sensor-processor/src/services/computed-term.service.tsapps/sensor-processor/src/services/template-driven-processor.service.tsapps/sensor-processor/src/services/vocabulary-data-fetcher.service.ts- Dependency transformation logic (Issue #495)
Priority
Medium-High: Blocks completion of PAW Phase 2 implementation. The other 3 PAW metrics are working correctly, but DAYS_TO_STRESS is a critical metric for irrigation planning.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗