Commit graph

61 commits

Author SHA1 Message Date
31e745ef95 fix(ume): show WSS connection state separately from alarm activity
Track ws_connection for UI pills, stop overwriting runtime last_error on alarm events, and wire pause/resume to reconnect WSS.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 11:19:00 +08:00
5bd83c58dc feat(ume): expose WSS runtime logs on subscription status UI
Ring-buffer ws_logs API, alarm raise/clear labels with alarmkey, and scrollable log panel on UME page.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 21:15:15 +08:00
635cd52d4f fix(ume): accept empty JSON body on successful delete-subscription
Parse 204/empty UME responses without JSONDecodeError; improve request error messages and orphan-delete failure reporting.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 21:01:24 +08:00
a8b359f60d fix(ume): cancel alarm subscription with DELETE and surface failures
Use DELETE delete-subscription, refresh token before cancel, recover orphan subs on establish, and keep local state when UME delete fails.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 20:47:59 +08:00
4f8735a83f feat(ume): real-time current alarms via WebSocket subscription
Add WS consumer, persisted subscription store, manual subscribe/cancel APIs, and UI controls; extend sync and tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 20:27:43 +08:00
21f7cfba41 feat(ume): denormalize host_name onto alarms for display and grouping
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-20 00:05:10 +08:00
95db646403 feat(ume): English protocol bucket labels via lang query param
Share protocol classification helpers and return en labels for diagnostics when lang=en.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 23:35:47 +08:00
47033f14ab fix(netx): order current alarms by time_created desc
Sort UME current alarms by time_created descending (newest first) with last_seen_at and alarm_key as tie-breakers to keep offset/limit pagination stable. Apply the same default ordering in the MCP tool listing.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 17:28:52 +08:00
16607db3cd fix(netx): prefer UUID net_id from ME{} in objectName
Only treat UUID-like values as net_id. Prefer extracting ME{uuid} from objectName and ignore ME{numeric} wrappers found in alarmkey so alarms join inventory correctly.

Also constrain legacy alarmkey split formats (#, csv, space) to UUID-like prefixes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 17:11:58 +08:00
15d9cb5db3 fix(netx): derive ne_id from objectName ME{net_id}
When alarmkey does not contain a net_id, fall back to extracting ME{net_id} from objectName so alarms can join inventory correctly. Add regression coverage for the ME{} objectName pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 17:02:46 +08:00
626bb2b02e fix(netx): parse space-separated net id from alarmkey
Support UME alarmkey values like "<net_id> <x> <y>" when deriving ne_id so current alarms can join inventory correctly. Add regression coverage for hash, csv, and space-delimited alarmkey formats.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 16:29:19 +08:00
67f7e48597 fix(netx): surface scheduler startup init failures
Log startup exceptions for UME scheduler threads and set runtime task status to error with startup_thread_init_failed details instead of silently swallowing exceptions. This prevents tasks from staying in init without actionable diagnostics.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 16:05:05 +08:00
eebfbf25fa fix(netx): avoid alarm sync failures from long UME fields
Store UME alarm payload fields as TEXT and run startup ALTER COLUMN upgrades so large alarm records no longer fail with StringDataRightTruncation. Keep full values during sync while hashing only pathological ultra-long alarm keys to preserve idempotent primary keys.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 15:59:20 +08:00
b253ee7bff fix(netx): do not put debounce wait text in runtime last_error
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 11:36:30 +08:00
666541266b fix(netx): separate scheduler interval vars to avoid closure overwrite
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 11:25:03 +08:00
17cd469b1a netx: log netx.ume.schedule/sync INFO to stderr for prod log files
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 11:18:32 +08:00
936cee1aa2 UME scheduler: resume wakes debounce sleep + skip wait; pause clears hints; loop tick logs
- Event.wait debounce sleep so 开始 interrupts long interval wait\n- resume sets skip+event; wake path discards skip to avoid double-sync\n- pause clears skip/wake; boot resets debounce via _reset_runtime_pause_flags\n- loop tick + thread is_alive logging for netx.ume.schedule

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 11:10:07 +08:00
b17aef0eae UME schedule: interval from any finished job; drop trailing sleep; stale running cleanup; paging logs
- Use last ended_at (done or failed) for debounce; remove duplicate time.sleep after sync\n- On startup mark running+no ended_at jobs failed (crash/interrupt) so interval logic is not fooled\n- Log marker page progress every 25 pages\n- Log when alarm/inventory scheduler threads start

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 10:51:47 +08:00
7a9921b45b UME schedule: reset pause flags on boot; defer sync from DB last done time
- _reset_runtime_pause_flags() after create_all so pause state cannot survive process restart in memory\n- Before each alarms/inventory auto sync, wait until interval elapsed since last status=done job ended_at (any trigger); honor pause during wait\n- Helps avoid immediate duplicate sync on restart when DB was recently updated

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 10:35:38 +08:00
34ee677433 UME scheduled sync: commit running job before long UME pull; schedule logs
Makes schedule attempts visible in ume_sync_jobs while HTTP pagination runs; log iteration/sleep/finish for alarms_current and inventory auto loops.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 10:21:01 +08:00
61f6c99f93 Runtime tasks: refresh last_run_at when alarm/inventory sync starts
Avoid stale last_run_at when sync_alarms_current runs longer than interval; clarifying tooltip on UME page.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 10:18:30 +08:00
ea7931496c Fix deadlock: renew_token must not call login while holding _token_lock
Non-reentrant Lock caused /v1/ume/token/refresh to hang when handshake failed or token empty inside renew; UI stuck on 续期中.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 10:03:20 +08:00
0afc77c06b UME: renew token when expires_in is 0; token UI loading + toasts; sync thread status hint
- keepalive: call renew when has_token and (expires_in<=0 or below renew_before) so 0s stuck state self-heals\n- alarms/inventory auto loops: set last_error while pulling so table is not stuck at init with no hint\n- UmePage: warn pills for connected+需续期, spinners on token actions, toast ok/err from App, invalidate sync status after token ops

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 09:50:13 +08:00
def534e0a6 Fix UME token store sync: load token when expires_at is 0, clear stale memory
Previously exp>mem_exp blocked loading when both were 0 (restart + DB row with missing expiry). Also clear in-memory token when DB row is cleared so token/status matches store after disconnect.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 09:37:07 +08:00
10ff96f17c UME runtime_tasks: expose interval_s and interval_label for UI
Backend computes effective loop interval (same clamps as startup). Table column 间隔 with tooltip seconds.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 19:24:42 +08:00
fa1135a9c2 UmePage: show error banner when runtime pause/resume fails
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 19:19:27 +08:00
1741965de6 UME: system time for alarm time_created, 48h inventory auto-sync, runtime pause/resume
- formatSystemTime for current alarm time_created\n- Background thread inventory_auto_sync (NETX_UME_SYNC_INVENTORY_AUTO_ENABLED, NETX_UME_SYNC_INVENTORY_EVERY_HOURS default 48)\n- Pause/resume for token_keepalive, alarms_current_auto_sync, inventory_auto_sync via POST /v1/ume/runtime/tasks/{task}/pause|resume\n- UmePage后台任务列操作 暂停/开始

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 19:18:28 +08:00
edad7b24fa UME current alarms: filter by host_name instead of ne_id in UI
GET /v1/ume/alarms accepts host_name (contains on inventory); ne_id query kept for API clients. Web uses host_name field and link on host column.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 19:11:55 +08:00
3728e4db71 UmePage: drop ne_name column from NE inventory table
colSpan 8 for expanded row.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 19:07:37 +08:00
dc10034e18 UmePage: one-click clear filters for NE list and current alarms
Reset keyword/ne_id/severity/is_cleared (alarms) or keyword (inventory) and page 1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 19:04:18 +08:00
ca12d66419 UME current alarms UI: ne_id, host_name, ne_type; drop object_name/user_label columns
API /v1/ume/alarms adds host_name and ne_type from inventory join; keyword matches host_name.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 19:00:21 +08:00
c06beecfe6 Unify sync status deleted into single deleted field
API GET /v1/ume/sync/status exposes deleted only (sum of inventory NE + current-alarm reconcile counts from details_json). UI one column.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 18:51:30 +08:00
ac1f573508 Remove UME equipment-holder table; inventory is NE-only
Drop ume_inventory_equipment_holder on startup; remove ORM model and sync/reconcile paths. Sync status API/UI no longer expose deleted_inventory_holders. Nested holder data remains in ne raw_json if UME returns it.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 18:48:45 +08:00
a025245c8f Show UME sync delete counts in API and UME UI
Parse UmeSyncJob.details_json in GET /v1/ume/sync/status for deleted_inventory_ne, deleted_inventory_holders, deleted_stale_current_alarms. Add table columns on UmePage and types.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 18:38:08 +08:00
340fc8ee7d Reconcile UME inventory and current alarms with full snapshot
After a complete marker pull (is_end_of_reply, no iterator/dup abort), delete local NE/holders and current alarms not present in this batch. Replace 48h-only current-alarm expiry. Flush before bulk delete to avoid ORM stale updates. Job/batch JSON records deleted counts and reconcile flags.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 18:31:04 +08:00
c5f82f512d Include host_name in UME NE keyword search
Extend GET /v1/ume/inventory/ne keyword filter with host_name; update Web placeholder.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 17:27:25 +08:00
68c622979b fix(oclaw-bridge): disable system proxy for localhost health calls
Set trust_env=False on netx->oclaw analyze and health clients so localhost checks are not routed through host proxies.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 16:10:34 +08:00
ea0d324624 feat(UME): add raw query, flexible aggregate, and safe SQL endpoint
- Add /v1/ume/alarms/fields and /v1/ume/alarms/raw (select_fields + meta)
- Add /v1/ume/alarms/aggregate/raw with filter/meta echo
- Add /v1/sql/ume_query with table allowlist and optional statement_timeout
- Update README and expand UME regression tests

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 00:06:21 +08:00
84cf70cde3 feat(UME): 增加后台任务监控并启用5分钟告警自动同步
新增当前告警自动同步后台线程(默认300s一次)并提供开关配置;在 /v1/ume/sync/status 返回 runtime_tasks,前端“当前任务”面板展示保活与自动同步运行状态;同时隐藏历史告警UI但保留后端能力。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 22:40:02 +08:00
d0994f6e53 feat(UME): 完善网元字段注释并补齐IPv6地址字段
为 ume_inventory_ne 的关键字段补充建表注释并在启动时执行 COMMENT ON 同步历史库结构,同时新增 ipv6_address 字段并完成入库映射、接口返回与前端类型定义对齐。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 22:19:06 +08:00
037873423d feat(UME): 网元与告警统一marker分页能力
将 marker 分页逻辑抽象为通用流程并同时应用于网元和告警同步,默认按 limit+marker 拉取全量数据,统一处理 is-end-of-reply、缺失marker和重复页保护。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 21:44:21 +08:00
00afaaae3d fix(UME): 兼容首批无marker场景并补充回归测试
告警分页在响应头缺失 marker 时直接结束迭代,避免首批已全量却重复翻页;同时补充对应单测并保持 HTTPTransport 传输方式与现网一致。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 20:13:10 +08:00
2c0b52d972 fix(UME): 改用HTTPTransport并增强token失败提示
UME 客户端改为显式 HTTPTransport 以匹配现网可用链路,前端在手动登录/续期或断开 token 失败时优先展示后端返回的错误信息,便于快速定位问题。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 19:15:10 +08:00
267eddb273 feat(UME): 切换marker分页并简化告警表字段
告警同步改为按响应头 marker 连续迭代,支持 iterator is null 的500尾页兜底,同时移除告警表中的 ne_name/user_label 冗余字段,统一在查询层与网元表 join 补齐展示信息。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 18:58:24 +08:00
3ea4f08bea feat(UME): 完善网元元数据入库并增强告警/前端展示
补齐 ume_inventory_ne 的关键元数据字段并在同步时结构化落库,支持从 alarmkey 推导 ne_id、告警查询连表补齐 user_label/ne_name,同时优化 UME 页面分页显示与网元展开详情,提升运维排障可读性。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 17:02:57 +08:00
3396111f2d fix(UME): 按现场实测调整请求头并强制HTTP/1.1
- 请求头仅保留 content-type 与 accessToken,不再发送 accept/application

- 统一通过 httpx.Client(http2=False) 调用,避免 UME 在 HTTP/2 下超时

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 11:36:06 +08:00
7f2e4ec393 feat(UME): 增加RESTCONF对接与可视化运维页
- 支持 token 获取/续约/断开、DB共享缓存与跨进程单飞锁、keepalive 保活

- 新增 inventory/current/history 告警同步入库与查询接口,前端增加 UME 对接页面与分页

- 修复 stop_netx.ps1 在部分 PowerShell 版本下 Stop-Job -Force 报错

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 01:36:53 +08:00
ab1b76dd47 feat(start): auto-install web dependencies when WithWeb is enabled
Install frontend npm dependencies automatically in start_netx so fresh machines can bring up the 5173 Vite UI without separate manual npm install.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-06 17:38:14 +08:00
d529ff70ff fix(start): launch Vite in foreground API mode when WithWeb is set
Start the web dev server for -WithWeb even without -Background so 5173 is available in the common foreground run path.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-06 17:26:26 +08:00
dbe3062d1b fix(setup): avoid DO $$ in init_pg role bootstrap
Replace the DO-block role upsert with explicit role existence check plus CREATE/ALTER statements, preventing PowerShell/psql quoting issues on some Windows setups.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-06 17:17:30 +08:00