Files
aios/docs/superpowers/specs/2026-07-12-weixin-quoted-text-failclosed-design.md
T

2.6 KiB

Weixin Quoted Text Fail-Closed Design

Goal

Prevent quoted-text questions from being answered with invented message metadata when Weixin does not provide the quoted body. Preserve normal text and confirmed image behavior.

Evidence

  • A quoted text event can arrive as ref_msg.message_item.type=0 with only msg_id and timestamps.
  • Session transcripts retain text but not the original Weixin numeric message ID.
  • Outbound clientId values are not the same format as quoted numeric msg_id values, and the send API does not expose a server message ID.
  • Therefore recent-message, timestamp, session, and outbound-client-ID matching are not exact evidence and must not be used.

Decision

Use an evidence-only resolver in process-message:

  1. If reference payload contains an explicit text item, extract that text and build a bounded quoted-text context for the ordinary text model path.
  2. If reference context exists but has no explicit text and is not a confirmed image, return a deterministic response: 无法读取被引用文字,请复制原文后再提问。
  3. The unresolved branch is handled before ordinary model dispatch and before Hermes image dispatch.
  4. Do not infer quoted text from metadata, recent messages, session order, timestamps, or approximate IDs.

No persistent text cache is introduced in this change. Outbound ID aliasing remains a separate observation task because an exact mapping has not been proved.

Interfaces

  • extractHermesReferencedText(items): string returns only explicit referenced text, otherwise an empty string.
  • resolveHermesQuotedTextContext(items, currentText) returns one of:
    • { referenced: false, handled: false, prompt: currentText, reason: "none" }
    • { referenced: true, handled: false, prompt, reason: "quoted_text_resolved" }
    • { referenced: true, handled: true, replyText: "无法读取被引用文字,请复制原文后再提问。", reason: "quoted_text_unavailable" }
  • Confirmed referenced images bypass this text resolver and keep the existing exact image path.

Privacy And Logging

  • Do not log quoted or current text.
  • Log only reason, account ID, a one-way bounded hash of quoted ID when available, and boolean evidence flags.
  • Do not persist tokens, credentials, full payloads, or message text.

Acceptance

  • Explicit quoted text is supplied to the ordinary text model with a clear delimiter.
  • Type 0 reference without text returns the deterministic Chinese response and does not call the model.
  • Plain text, current image, and exact quoted image behavior remain unchanged.
  • Generated TS and JS remain byte-idempotent under --process-only.