CR-014 - bodies carry customer context and the link carries the content

Nick's decision, 2026-08-20: 'email bodies provide links back to the system.
we can talk about customers we just cant exposed their confidential
documents.' The T7.6-era rule (no customer IP at all, so number + link only)
is refined: context IN, content OUT.

- wp_titled() and wp_where() compose 'number - title' and the CR-004
  location (structured paths first, legacy free text second); the where-line
  is dropped entirely when unset rather than mailing 'Where: '.
- assign, qa-ready, qa-reject and hold bodies gain title + location. The
  scope summary the original CR asked for stays OUT - scope text is document
  content; the link is its summary. Rejection comments stay on the package.
- hold_body gains the house footer it alone lacked.
- kitting and material-request bodies adopt wp_titled for the same identity
  line (their delivery-location rule is unchanged).
- notify.py's docstring states the new rule where the transport documents it.

Pins flipped WITH the rule, reasons in code: qa_gate_check's location canary
is now asserted PRESENT in QA bodies; a new DESC_CANARY (document content) is
asserted absent from every message (40 -> 41 checks). The sink also gains a
decoded-body view: the em-dash switches smtplib to quoted-printable, whose
column-76 soft breaks made raw-payload substring pins pass or fail on luck of
line position - content pins now read the decoded body, header pins still
read the wire payload.

Battery: qa_gate_check 41/41, kitting_notify_check 17/17, mreq_check 19/19.

Items: CR-014 (rule per decisions-2026-08-20.md), CR-011 pins.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 18:11:37 -07:00
parent 16afc56c0a
commit 0f28a27441
6 changed files with 84 additions and 32 deletions

View File

@@ -106,7 +106,7 @@ def main():
rcpts = sorted(m["to"][0] for m in sink.messages)
chk("...exactly them, actor excluded",
rcpts == ["pat@example.test", "sue@example.test"], ascii_(rcpts))
body = sink.messages[0]["data"] if sink.messages else ""
body = sink.messages[0]["text"] if sink.messages else ""
chk("the mail says old status, new status and who",
"In Transit" in body and "Delivered" in body and "Root" in body,
ascii_(body, 260))

View File

@@ -121,13 +121,14 @@ def main():
len((wp.get("data") or {}).get("materialRequests") or []) == 1)
chk("...and the warehouse owner is notified through the T7.6 gate",
wait_for(lambda: any("Material request" in m["data"] for m in sink.messages), 12))
body = next((m for m in sink.messages if "Material request" in m["data"]), {"data": "", "to": [""]})
body = next((m for m in sink.messages if "Material request" in m["data"]),
{"data": "", "text": "", "to": [""]})
chk("...the mail goes to the owner, says the size, the date, the delivery "
"and carries the deep link",
body["to"] == ["sue@example.test"] and "2 lines" in body["data"]
and "2026-09-01" in body["data"] and "Shark cage 7" in body["data"]
and ("/wp-creation-index.html?project=projA&wp=" + wp_id) in body["data"],
ascii_(body["data"], 300))
body["to"] == ["sue@example.test"] and "2 lines" in body["text"]
and "2026-09-01" in body["text"] and "Shark cage 7" in body["text"]
and ("/wp-creation-index.html?project=projA&wp=" + wp_id) in body["text"],
ascii_(body["text"], 300))
_, ev = api(base, "/api/audit?entity_type=wp&entity_id=%s&action=material_requested" % wp_id, root)
chk("...and the audit history has it", bool(ev))

View File

@@ -40,7 +40,8 @@ from sections_check import set_sop # noqa: E40
from stepper_check import dismiss_dialogs # noqa: E402
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CANARY = "FAB-9 SECRET SECTOR" # rides on the package; must never reach a body
CANARY = "FAB-9 SECRET SECTOR" # location: customer CONTEXT - IN bodies since 2026-08-20
DESC_CANARY = "PULL-SCHED-CANARY-7X" # document CONTENT - must never reach a body
def ascii_(v, n=300):
@@ -87,7 +88,7 @@ class SmtpSink(threading.Thread):
self.sock.bind(("127.0.0.1", 0))
self.sock.listen(8)
self.port = self.sock.getsockname()[1]
self.messages = [] # {"to": [...], "data": str}
self.messages = [] # {"to": [...], "data": wire str, "text": decoded body}
self._stop = False
def run(self):
@@ -127,8 +128,22 @@ class SmtpSink(threading.Thread):
return
if in_data:
if line.rstrip(b"\r\n") == b".":
raw = b"".join(buf)
# "data" is the wire payload (headers + body, transfer-encoded).
# "text" is the DECODED body: any non-ASCII character (the
# bodies' em-dash) switches smtplib to quoted-printable, whose
# soft line breaks split words at column 76 - a substring pin
# against "data" then fails on luck of line position. Content
# pins read "text"; header pins (Subject:) still read "data".
import email as _email
try:
_msg = _email.message_from_bytes(raw)
_text = _msg.get_payload(decode=True).decode("utf-8", "replace")
except Exception:
_text = raw.decode("utf-8", "replace")
self.messages.append({"to": list(rcpt),
"data": b"".join(buf).decode("utf-8", "replace")})
"data": raw.decode("utf-8", "replace"),
"text": _text})
rcpt, in_data, buf = [], False, []
conn.sendall(b"250 OK\r\n")
else:
@@ -177,7 +192,7 @@ def set_qa_group(ids):
def mkwp(base, tok, wp_id, status="In Progress", extra_data=None, assignee=None):
data = {"constraints": [{"name": "Boom lift", "status": "cleared", "comment": ""}],
"location": CANARY, "desc": "600ft of 3/4 EMT through " + CANARY}
"location": CANARY, "desc": "600ft of 3/4 EMT through " + DESC_CANARY}
data.update(extra_data or {})
return api(base, "/api/wps", tok, "POST", {
"id": wp_id, "project_id": "projA", "number": "QA-" + wp_id[-2:],
@@ -263,12 +278,16 @@ def main():
rcpts = sorted(m["to"][0] for m in qa_msgs())
chk("...addressed to the group members and NOBODY else",
rcpts == ["pat@example.test", "sue@example.test"], ascii_(rcpts))
body = qa_msgs()[0]["data"] if qa_msgs() else ""
body = qa_msgs()[0]["text"] if qa_msgs() else ""
chk("the message carries the WP number", "QA-A2" in body, ascii_(body, 200))
chk("...and a link that opens THAT work package, not the app root",
"/wp-creation-index.html?project=projA&wp=wpQA2" in body, ascii_(body, 400))
chk("...and no customer IP: the location canary does not appear",
CANARY not in body and all(CANARY not in m["data"] for m in sink.messages))
# Decided 2026-08-20: context IN, content OUT. This pin asserted the
# location's ABSENCE until that decision; it flipped with the rule.
chk("...and the location and title ride in the body (context, allowed)",
CANARY in body and "conduit" in body, ascii_(body, 300))
chk("...but document content never does: the desc canary appears nowhere",
all(DESC_CANARY not in m["text"] + m["data"] for m in sink.messages))
chk("...and no SMTP password either", "SMTP_PASSWORD" not in body
and os.getenv("SMTP_PASSWORD", "hunter2-not-set") not in body)
@@ -290,7 +309,7 @@ def main():
chk("...exactly them", rcpts == ["mix@example.test", "pat@example.test",
"sue@example.test"], ascii_(rcpts))
chk("...and the comment itself stays on the package, out of the mail",
all("Torque strap" not in m["data"] for m in sink.messages))
all("Torque strap" not in m["text"] + m["data"] for m in sink.messages))
# The upsert path enforces the same comment rule (it is how the browser saves).
code, _ = api(base, "/api/wps/wpQA2/status", root, "POST", {"status": "Ready for QA"})