@@ -304,7 +304,12 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
304304 // Issue #471:政策轴——作用域级可逆闸门。两个键都是嵌套子字段,漏登记的后果
305305 // 同上(effective 静默缺键、面板读不到也 PUT 不进)。
306306 "scopeState.enabled" : [ "scopeState" , "enabled" ] ,
307- "scopeState.enforce" : [ "scopeState" , "enforce" ]
307+ "scopeState.enforce" : [ "scopeState" , "enforce" ] ,
308+ // #275 容量预警:三个阈值都是嵌套子字段(两个整数走 INT_RANGES、一个浮点走
309+ // NUMBER_RANGES),漏登记的后果同上——effective 静默缺键、面板读不到也 PUT 不进。
310+ "capacityWarning.dbSizeWarnMb" : [ "capacityWarning" , "dbSizeWarnMb" ] ,
311+ "capacityWarning.archivedRowsWarn" : [ "capacityWarning" , "archivedRowsWarn" ] ,
312+ "capacityWarning.archivedRatioWarn" : [ "capacityWarning" , "archivedRatioWarn" ]
308313 // sensitiveScanEnabled(#164 A2)是顶层扁平键,不需要进这张表——走 configFlagValue
309314 // 的默认分支即可。
310315 } ;
@@ -2232,7 +2237,7 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
22322237 }
22332238 } ) ;
22342239
2235- // --- health: mirror sync state (F-NEW-03 / v0.3.6) ---
2240+ // --- health: mirror sync state (F-NEW-03 / v0.3.6) + capacity (#275) ---
22362241 // Auth-gated; only returns a sanitized error code (never raw last_error which
22372242 // may leak paths/token-like strings/internal hosts). On state read failure it
22382243 // reports unknown/degraded (fail-closed) instead of a false dirty=false.
@@ -2241,23 +2246,34 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
22412246 path : "/api/dsh-mneme/health" ,
22422247 policy : "token" ,
22432248 handler ( req , res ) {
2249+ // 容量预警(#275 空间维度):与镜像状态同面但**互相独立**——镜像读失败不该
2250+ // 把容量数字一起藏掉,所以每个分支都带上。getCapacityHealth 自身 fail-safe
2251+ // (读失败回 status:"unknown");?.() 兜住没接线的老 mock service(此时显式
2252+ // capacity:null,面板渲染成「未知」,不冒充正常)。
2253+ let capacity = null ;
2254+ try {
2255+ capacity = service . getCapacityHealth ?. ( ) ?? null ;
2256+ } catch {
2257+ capacity = null ;
2258+ }
22442259 let state = null ;
22452260 try {
22462261 state = service . getMirrorHealth ?. ( ) ?? null ;
22472262 } catch {
22482263 // read failure is itself a health signal: do not report a false clean
2249- sendJson ( res , 200 , { mirror : { dirty : null , status : "unknown" , last_error : null , last_attempt : null , success_at : null } } ) ;
2264+ sendJson ( res , 200 , { mirror : { dirty : null , status : "unknown" , last_error : null , last_attempt : null , success_at : null } , capacity } ) ;
22502265 return ;
22512266 }
22522267 if ( ! state ) {
2253- sendJson ( res , 200 , { mirror : { dirty : null , status : "unknown" , last_error : null , last_attempt : null , success_at : null } } ) ;
2268+ sendJson ( res , 200 , { mirror : { dirty : null , status : "unknown" , last_error : null , last_attempt : null , success_at : null } , capacity } ) ;
22542269 return ;
22552270 }
22562271 // Real read failure surfaces as dirty === null (peer blocker 5): report
22572272 // unknown explicitly instead of collapsing into a false "ok"/"degraded".
22582273 if ( state . dirty === null ) {
22592274 sendJson ( res , 200 , {
2260- mirror : { dirty : null , status : "unknown" , last_error : null , last_attempt : null , success_at : null }
2275+ mirror : { dirty : null , status : "unknown" , last_error : null , last_attempt : null , success_at : null } ,
2276+ capacity
22612277 } ) ;
22622278 return ;
22632279 }
@@ -2275,7 +2291,8 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
22752291 last_error : code ,
22762292 last_attempt : state . last_attempt ?? null ,
22772293 success_at : state . success_at ?? null
2278- }
2294+ } ,
2295+ capacity
22792296 } ) ;
22802297 }
22812298 } ) ;
0 commit comments