Skip to content

Matrix Coder: LOW/NIT backlog from #140 invocation audit (state hygiene, dead code, perf, test gaps) #142

Description

@Interstellar-code

Backlog of LOW-severity and NIT findings from the deep audit done while fixing #140 (persona-injection channel + over-eager IntentGate). The two #140 root-cause bugs and all HIGH/MED findings are being fixed on branch fix/matrix-coder-140-invocation; this issue captures the remaining low-priority items for future consideration. File paths are under plugins/matrix_coder/.

State hygiene (LOW)

  • PL-4_inject_persona clears persona then re-sets it in handle_implicit; a concurrent observer can see the transient cleared-then-not-yet-set window. Subsumed by the session-keyed bridge fix (PL-1) on the active branch; track residual. __init__.py, core/harness.py.
  • KB-3open_child_card / register_child_card / pop_child_card_ids are fully coded + tested but have zero production callers (Phase-3 stubs; relates to Matrix Coder Kanban audit: only one parent card per invocation — per-dispatch child cards not implemented #130). pop_child_card_ids() is never called, so a future register_child_card() without pop grows _active_child_ids unbounded until restart. core/kanban_audit.py:94, core/hermes_bridge.py:109-127.
  • KB-4idempotency_key uses a fresh uuid4().hex per call, negating dedup on retry; retries produce duplicate audit cards. Derive from sha1(f"{session_id}:{role}:{goal[:60]}"). core/kanban_audit.py:81.
  • CF-3enabled flag in load_config() hardcoded True; no Hermes config.yaml overlay path exists, so operators can't disable Matrix Coder without editing source. Stopgap: os.environ.get("MATRIX_CODER_ENABLED","1"). core/config.py:22-41.
  • SW-3has_coding_intent swallows exceptions and returns False at DEBUG only; if a regex ever raises, implicit routing silently misclassifies every message. (Partially addressed by the SW-1 log-tiering on the active branch — confirm coverage.) core/intent_gate.py.

Dead / placeholder code (LOW)

  • DC-1_normalize_output is a registered transform_llm_output no-op (returns None in both branches); pays hook overhead on every LLM output for zero effect. Unregister until needed, or collapse to a one-liner. __init__.py:110-125, registered at :288.
  • DC-2run_passthrough has zero production callers (only test_walking_skeleton.py); /matrix returns help text directly. Also carries the PL-3 stale-card bug. core/harness.py:140-168.
  • DC-3claim_files / release_files / would_conflict implemented but never called; single-writer guardrail is advisory only (README is accurate). Annotate as phase-N stubs. core/hermes_bridge.py:131-156.

Test gaps (LOW)

  • TC-4run_passthrough PL-3 bug (stale _active_card_id leak) is untested. tests/test_walking_skeleton.py.
  • TC-5 — no test for the implicit_routing_enabled=False guard (prospective, once the config flag lands).
  • TC-6_log_injection degraded path (role=unknown, lens=none) has no test. __init__.py:79-89.

Quick wins / perf (NIT)

  • QW-1import re inside _log_injection on every call; move to module level. __init__.py:83.
  • QW-2session_id cast str(kwargs.get("session_id") or "") produces "" where None is the correct sentinel; pass Optional[str] through. __init__.py:110.
  • QW-3_term_pattern() relies on re LRU cache for 40+ _CODING_TERMS every hook turn; pre-compile patterns at module load. core/intent_gate.py:237-239.
  • QW-4kanban_audit.open_card / open_child_card open+close a DB connection per call; a context-managed pool would pay off if the audit layer ever becomes higher-frequency. core/kanban_audit.py.

Open questions (low-confidence, surfaced not blocking)

  • Is post_llm_call actually gated on final_response and not interrupted in the Hermes core? (__init__.py:84-86 docstring claim — unverified.)
  • Does kanban_db.complete_task raise or silently succeed on an already-closed card? Affects the double-close (PL-2) reasoning.

Source: 3-agent read-only audit (architect / security-reviewer / code-reviewer) during the #140 fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions