[BUG] Fix PID boolean coercion in alert normalization, regex delimiter stripping, and GenericAlias instantiation
Author: Sruhvx-jpgCreated Sep 16, 2026Updated Sep 17, 2026
Summary
Consolidated report for 3 low-level edge-case bugs and anti-patterns: (1) Python bool is int coercion in _coerce_pid, (2) .find() delimiter stripping during memory secret redaction, and (3) runtime dict[Any, Any](value) GenericAlias instantiation in tool schema normalization.
Expected vs actual behavior
1. Alert PID Coercion (core/domain/alerts/normalization.py):
- Expected: Passing
{"pid": True}or{"pid": False}in raw webhook payloads returnsNone(unsupported/invalid PID). - Actual:
_coerce_pid(True)returnsTrue(<class 'bool'>) and is treated as PID1(init/systemd);Falsebecomes PID0.
2. Memory Delimiter Redaction (core/domain/memory/safety.py):
- Expected:
redact_memory_unsafe_text("pass1234_secret_key: pass1234")returns"pass1234_secret_key: [REDACTED]". - Actual:
.find(value)matches the substring inside the label at index 0, collapsing the slice[len(label):0]to""and outputting"pass1234_secret_key[REDACTED]"(eating the": "separator).
3. GenericAlias Instantiation (core/llm/shared/tool_schema_normalize.py):
- Expected: Tool schema merger creates dictionary copies via
dict(value). - Actual: Line 53 invokes
dict[Any, Any](value)at runtime (instantiatingtypes.GenericAlias).
Steps to reproduce
Run the following minimal Python snippet:
# 1. Alert PID Coercion
from core.domain.alerts.normalization import _coerce_pid
print("PID for True:", _coerce_pid(True), type(_coerce_pid(True))) # Output: True <class 'bool'>
# 2. Memory Redaction Delimiter Stripping
from core.domain.memory.safety import redact_memory_unsafe_text
print(repr(redact_memory_unsafe_text("pass1234_secret_key: pass1234"))) # Output: 'pass1234_secret_key[REDACTED]'
# 3. GenericAlias runtime call
# Line 53 in core/llm/shared/tool_schema_normalize.py executes dict[Any, Any](value)Can you reproduce it consistently?
Yes
How often does it occur?
Every time
Operating system
Linux
Logs and error output
>>> from core.domain.alerts.normalization import _coerce_pid
>>> _coerce_pid(True)
True
>>> from core.domain.memory.safety import redact_memory_unsafe_text
>>> redact_memory_unsafe_text("pass1234_secret_key: pass1234")
'pass1234_secret_key[REDACTED]'Additional context
- Discovery Methodology: These defects were discovered using an automated static code analysis and AI inspection suite.
- PR Policy / Structure: To avoid cluttering the repository issue tracker with micro-tickets, these related static findings are compiled into this single issue. Fixes will be submitted as separate, isolated PRs with unit test coverage for each subsystem upon maintainer assignment.
Source: Tracer-Cloud/opensre