Files
Web_BLS_RCUAction_Server/openspec/changes/feature-loop-name-enrichment.md

33 lines
1.4 KiB
Markdown
Raw Normal View History

# Feature: Loop Name Enrichment
**Status**: Proposed
**Date**: 2026-02-02
## Summary
Enrich incoming RCU action events with `loop_name` by looking up metadata from `temporary_project` tables. This allows easier identification of specific device loops (e.g., "Main Chandelier") in the event log.
## Requirements
1. **Cache Mechanism**:
- Load `rooms` and `loops` data from `temporary_project` schema into memory.
- Refresh cache daily at 1:00 AM.
2. **Enrichment**:
- For each incoming event, look up `loop_name` using `device_id` and `dev_addr`.
- `device_id` -> `room_type_id` (via `rooms` table).
- `room_type_id` + `dev_addr` -> `loop_name` (via `loops` table).
3. **Storage**:
- Store `loop_name` in `rcu_action_events` table.
## Ambiguity Resolution
- The requirement mentioned matching `dev_type` to find the loop. However, standard RCU addressing uses `dev_addr` (and `dev_loop`). We assume `loops.loop_address` corresponds to the packet's `dev_addr` (converted to string).
- We will attempt to match `dev_addr` against `loop_address`.
## Schema Changes
- **Table**: `rcu_action.rcu_action_events`
- **Column**: `loop_name` (VARCHAR(255), Nullable)
## Implementation Plan
1. **Database**: Update `init_db.sql` and `databaseManager.js`.
2. **Cache**: Create `src/cache/projectMetadata.js`.
3. **Processor**: Integrate cache lookup in `src/processor/index.js`.
4. **Lifecycle**: Initialize cache in `src/index.js`.