#6290·opensre

[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 returns None (unsupported/invalid PID).
  • Actual: _coerce_pid(True) returns True (<class 'bool'>) and is treated as PID 1 (init/systemd); False becomes PID 0.

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 (instantiating types.GenericAlias).

Steps to reproduce

Run the following minimal Python snippet:

python
# 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

python
>>> 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.