Keep HTML anchor destinations out of evidence signatures and Jev excerpts #225

Closed
opened 2026-11-23 00:49:08 +00:00 by svc-agent-writer · 12 comments

Parent #224. This fix merges before the HTML-body feature. Operator ruling

A generated HTML-only MIME message on ec11afc showed that the existing converter appends the href to visible anchor words. The appended destination can enter the full-mode Jev excerpt and can survive in a delimited sign_off used by both evidence tools. Deployed row counts and use of full mode are unmeasured.

Scope

  • Keep anchor destinations out of the signature heuristic input, the sign_off scan, and the full-mode assessor excerpt. Preserve the existing body-part choice and visible anchor words.
  • Filter the legacy rendered destinations when both evidence tools build signatures, including already stored sign_off values and signatures derived from stored body text. Filter the assessor excerpt when building its payload, including for pre-upgrade messages. Apply the existing signature and excerpt limits to the output.
  • Existing stored rows can remain in place. Physical re-derivation is tracked separately. Fixture coverage uses generated data and example destinations.

Completion evidence

  • Use generated MIME and matching JMAP fixtures to check a link-bearing undelimited signature, a delimited sign-off, and a link within the first 500 characters of the assessor input. Assert that both evidence tools and the assessor payload exclude generated destinations and retain visible words. Test fresh ingest and pre-upgrade stored values. Cover plain-text and mixed-part behavior.
  • Start implementation after mind-spec ACCOMMODATE. Send any ADR amendments for ratification. The PR needs independent Standards and Spec passes with zero open findings, a posted §19 review, green exact-head CI, and the raw-log audit recorded under the parent grant.
Parent #224. This fix merges before the HTML-body feature. [Operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/224#issuecomment-46218) A generated HTML-only MIME message on `ec11afc` showed that the existing converter appends the href to visible anchor words. The appended destination can enter the full-mode Jev excerpt and can survive in a delimited `sign_off` used by both evidence tools. Deployed row counts and use of full mode are unmeasured. ## Scope - Keep anchor destinations out of the signature heuristic input, the `sign_off` scan, and the full-mode assessor excerpt. Preserve the existing body-part choice and visible anchor words. - Filter the legacy rendered destinations when both evidence tools build signatures, including already stored `sign_off` values and signatures derived from stored body text. Filter the assessor excerpt when building its payload, including for pre-upgrade messages. Apply the existing signature and excerpt limits to the output. - Existing stored rows can remain in place. Physical re-derivation is tracked separately. Fixture coverage uses generated data and example destinations. ## Completion evidence - Use generated MIME and matching JMAP fixtures to check a link-bearing undelimited signature, a delimited sign-off, and a link within the first 500 characters of the assessor input. Assert that both evidence tools and the assessor payload exclude generated destinations and retain visible words. Test fresh ingest and pre-upgrade stored values. Cover plain-text and mixed-part behavior. - Start implementation after mind-spec `ACCOMMODATE`. Send any ADR amendments for ratification. The PR needs independent Standards and Spec passes with zero open findings, a posted §19 review, green exact-head CI, and the raw-log audit recorded under the parent grant.
Author
Member

STOP on historical href filtering

Mind-spec answered ACCOMMODATE on the output filter and child order. The fresh-ingest boundary can preserve visible anchor words while dropping href attributes. Existing rows lack that distinction. A local fixture produced identical stored text, Alice <profile>, from an anchor labelled “Alice” pointing to the relative destination profile and from an anchor whose visible text was “Alice .” The collision survives in both the stored body representation and the stored delimited sign-off. A filter using only those strings must either drop visible text in some rows or retain a destination in others.

The grant requires an operator decision for this trade-off. Proposed policy for legacy rows is to suppress ambiguous text at the protected output boundaries, with a fixture demonstrating the resulting loss of visible words. Fresh conversions can preserve visible words using the HTML structure. No mailbox or deployed row was read.

## STOP on historical href filtering Mind-spec answered `ACCOMMODATE` on the output filter and child order. The fresh-ingest boundary can preserve visible anchor words while dropping href attributes. Existing rows lack that distinction. A local fixture produced identical stored text, `Alice <profile>`, from an anchor labelled “Alice” pointing to the relative destination `profile` and from an anchor whose visible text was “Alice <profile>.” The collision survives in both the stored body representation and the stored delimited sign-off. A filter using only those strings must either drop visible text in some rows or retain a destination in others. The grant requires an operator decision for this trade-off. Proposed policy for legacy rows is to suppress ambiguous text at the protected output boundaries, with a fixture demonstrating the resulting loss of visible words. Fresh conversions can preserve visible words using the HTML structure. No mailbox or deployed row was read.
Author
Member

#225 · operator §6 ruling on your STOP (comment 46253) · corr mail224-align

Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #225 before you act on it.

Ruling: suppress ambiguous text. For rows written by the legacy converter, evidence signatures, sign_off output and Jev excerpts drop any text that could be a link destination. This fails closed: some real visible words are lost. Add a fixture that shows the loss. The loss lasts until #226 re-derives stored rows under its own grant. Fresh conversions keep visible words by using the HTML structure.

Order:

  • Implementation of #225 needs mind-spec ACCOMMODATE on this policy (grant §3). If the 45a04fd8 answer does not cover it, send one fit question on it and wait.
  • Record in #225 that the number of affected deployed rows is unmeasured.
  • A CLASH, or any other path by which body text, a link or an image label reaches evidence, assessor fields or an external service, is a STOP to the guide.
#225 · operator §6 ruling on your STOP (comment 46253) · corr mail224-align Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #225 before you act on it. Ruling: suppress ambiguous text. For rows written by the legacy converter, evidence signatures, sign_off output and Jev excerpts drop any text that could be a link destination. This fails closed: some real visible words are lost. Add a fixture that shows the loss. The loss lasts until #226 re-derives stored rows under its own grant. Fresh conversions keep visible words by using the HTML structure. Order: - Implementation of #225 needs mind-spec ACCOMMODATE on this policy (grant §3). If the 45a04fd8 answer does not cover it, send one fit question on it and wait. - Record in #225 that the number of affected deployed rows is unmeasured. - A CLASH, or any other path by which body text, a link or an image label reaches evidence, assessor fields or an external service, is a STOP to the guide.
Author
Member

STOP on #225 and #224. Mind-spec returned ACCOMMODATE for the operator's legacy suppression rule in the ruling. Source inspection found a further legacy path. The pinned converter retains line breaks inside the destination it emits. trim_quoted can cut off the closing marker before body_text is stored. delimited_block can start and stop inside the destination, leaving sign_off with neither marker. These values feed the evidence signature paths and the full-mode Jev excerpt. The affected columns carry no source provenance, so a read-time scan for URL syntax or angle brackets cannot guarantee the rule. This finding comes from source inspection.

Please confirm whether #225 should pass an empty input to the existing evidence signature and Jev excerpt logic for historical body values without trusted provenance, and omit historical sign-off values without their own trusted provenance, until a separately authorized #226 re-derivation. This can suppress entire excerpts and signatures, including on legacy plain-text mail. Fresh derivations can preserve visible words by separating the HTML text from destination attributes before trimming. This proposal leaves read/search and the stored historical values in place under #225.

Implementation remains stopped pending the operator's decision through the guide. No live mailbox, deployed mirror, or external assessor was used.

**STOP on #225 and #224.** Mind-spec returned `ACCOMMODATE` for the operator's legacy suppression rule in [the ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/225#issuecomment-46262). Source inspection found a further legacy path. The pinned converter retains line breaks inside the destination it emits. `trim_quoted` can cut off the closing marker before `body_text` is stored. `delimited_block` can start and stop inside the destination, leaving `sign_off` with neither marker. These values feed the evidence signature paths and the full-mode Jev excerpt. The affected columns carry no source provenance, so a read-time scan for URL syntax or angle brackets cannot guarantee the rule. This finding comes from source inspection. Please confirm whether #225 should pass an empty input to the existing evidence signature and Jev excerpt logic for historical body values without trusted provenance, and omit historical sign-off values without their own trusted provenance, until a separately authorized #226 re-derivation. This can suppress entire excerpts and signatures, including on legacy plain-text mail. Fresh derivations can preserve visible words by separating the HTML text from destination attributes before trimming. This proposal leaves read/search and the stored historical values in place under #225. Implementation remains stopped pending the operator's decision through the guide. No live mailbox, deployed mirror, or external assessor was used.
Author
Member

#225 · operator §6 ruling on your STOP (comment 46264) · corr mail224-align

Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #225 before you act on it. It replaces the suppress-ambiguous ruling of comment 46262.

Ruling: withhold historical values. Accept your proposal in comment 46264.

  • Historical body values without trusted provenance give an empty input to the existing evidence signature logic and to the full-mode Jev excerpt.
  • Historical sign_off values without their own trusted provenance are omitted from evidence.
  • Only values marked with trusted provenance by the new derivation (HTML text separated from destination attributes before trimming) feed evidence and Jev.
  • Read and search keep the stored historical values. #225 does not change or delete stored rows.
  • This lasts until a separately authorized #226 re-derivation. The guide is drafting a #226 grant for Piers to review; nothing on #226 starts before Piers issues it.

Order:

  • Implementation needs mind-spec ACCOMMODATE on this policy (grant §3), because it replaces the policy mind-spec accommodated in 68b33b87. Send one fit question and wait.
  • If the trusted-provenance marker needs a schema or storage change, state it in that fit question and in #225 before code.
  • Record on #225 that the loss of signature evidence and excerpts on historical mail, plain-text mail included, is accepted by this ruling, and that deployed impact is unmeasured.
  • A CLASH, or any other path by which body text, a link or an image label reaches evidence, assessor fields or an external service, is a STOP to the guide.
#225 · operator §6 ruling on your STOP (comment 46264) · corr mail224-align Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #225 before you act on it. It replaces the suppress-ambiguous ruling of comment 46262. Ruling: withhold historical values. Accept your proposal in comment 46264. - Historical body values without trusted provenance give an empty input to the existing evidence signature logic and to the full-mode Jev excerpt. - Historical sign_off values without their own trusted provenance are omitted from evidence. - Only values marked with trusted provenance by the new derivation (HTML text separated from destination attributes before trimming) feed evidence and Jev. - Read and search keep the stored historical values. #225 does not change or delete stored rows. - This lasts until a separately authorized #226 re-derivation. The guide is drafting a #226 grant for Piers to review; nothing on #226 starts before Piers issues it. Order: - Implementation needs mind-spec ACCOMMODATE on this policy (grant §3), because it replaces the policy mind-spec accommodated in 68b33b87. Send one fit question and wait. - If the trusted-provenance marker needs a schema or storage change, state it in that fit question and in #225 before code. - Record on #225 that the loss of signature evidence and excerpts on historical mail, plain-text mail included, is accepted by this ruling, and that deployed impact is unmeasured. - A CLASH, or any other path by which body text, a link or an image label reaches evidence, assessor fields or an external service, is a STOP to the guide.
Author
Member

The operator ruling accepts that historical mail, including older plain-text mail, can lose its entire signature or full-mode Jev excerpt. An unverified historical sign-off is omitted. This supersedes the earlier policy of suppressing ambiguous spans. Deployed impact is unmeasured.

Proposed additive SQLite migration for #225. Add a nullable protected_body_text column as the input to the existing evidence signature heuristics and full-mode Jev excerpt. On fresh derivation, this stores text from the legacy-selected body part after the HTML parser separates visible text from destination attributes and before the value is handed off to protected consumers. Apply existing quote trimming at its current stage. SQL NULL means the protected input is unavailable. Read/search continue to use the existing body column. Also add an independent sign_off_verified flag, default false, set atomically with a sign-off produced by the new derivation. A body write alone cannot mark an older retained sign-off verified. The migration leaves all historical body and sign-off values in place. Evidence uses an empty body input and omits an unverified sign-off. Full-mode Jev retains its excerpt field and uses an empty string when the protected body is unavailable. The existing excerpt length, evidence and assessor field lists, scopes, and consent rules stay as specified. #226 requires a separate grant to re-derive historical values.

Cover older plain-text and converted HTML rows using generated fixtures, including the visible words the withholding removes. Fresh fixtures cover visible anchor words and destination exclusion. Awaiting mind-spec's fit answer before implementation.

The [operator ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/225#issuecomment-46267) accepts that historical mail, including older plain-text mail, can lose its entire signature or full-mode Jev excerpt. An unverified historical sign-off is omitted. This supersedes the earlier policy of suppressing ambiguous spans. Deployed impact is unmeasured. Proposed additive SQLite migration for #225. Add a nullable `protected_body_text` column as the input to the existing evidence signature heuristics and full-mode Jev excerpt. On fresh derivation, this stores text from the legacy-selected body part after the HTML parser separates visible text from destination attributes and before the value is handed off to protected consumers. Apply existing quote trimming at its current stage. SQL NULL means the protected input is unavailable. Read/search continue to use the existing body column. Also add an independent `sign_off_verified` flag, default false, set atomically with a sign-off produced by the new derivation. A body write alone cannot mark an older retained sign-off verified. The migration leaves all historical body and sign-off values in place. Evidence uses an empty body input and omits an unverified sign-off. Full-mode Jev retains its excerpt field and uses an empty string when the protected body is unavailable. The existing excerpt length, evidence and assessor field lists, scopes, and consent rules stay as specified. #226 requires a separate grant to re-derive historical values. Cover older plain-text and converted HTML rows using generated fixtures, including the visible words the withholding removes. Fresh fixtures cover visible anchor words and destination exclusion. Awaiting mind-spec's fit answer before implementation.
Author
Member

STOP on #225 and #224. Source inspection found a separate path for markup attributes to reach the evidence signature, sign-off, and full-mode Jev excerpt. Python's HTMLParser can pass raw malformed start tags to handle_data. The pinned renderer treats that callback as body text. The draft filter intercepts completed anchor tags, so it misses this path. The current and draft JMAP body paths can also receive truncated HTML. The draft still derives a protected excerpt from a part marked truncated. This finding comes from source inspection of generated-fixture code paths. Live exposure is unmeasured.

Please confirm through the guide whether to use a protected conversion that only accepts parsed text nodes, withhold the protected body and sign-off input when parsing cannot establish that boundary, and withhold both for JMAP parts marked truncated. The read and search outputs would keep their current rendering in #225. I would verify the protected field boundary with generated fixtures before resuming #224.

Implementation is paused under the security escalation rule. The #225 draft remains uncommitted. No mailbox, deployed mirror, or external assessor was used.

**STOP on #225 and #224.** Source inspection found a separate path for markup attributes to reach the evidence signature, sign-off, and full-mode Jev excerpt. Python's HTMLParser can pass raw malformed start tags to handle_data. The pinned renderer treats that callback as body text. The draft filter intercepts completed anchor tags, so it misses this path. The current and draft JMAP body paths can also receive truncated HTML. The draft still derives a protected excerpt from a part marked truncated. This finding comes from source inspection of generated-fixture code paths. Live exposure is unmeasured. Please confirm through the guide whether to use a protected conversion that only accepts parsed text nodes, withhold the protected body and sign-off input when parsing cannot establish that boundary, and withhold both for JMAP parts marked truncated. The read and search outputs would keep their current rendering in #225. I would verify the protected field boundary with generated fixtures before resuming #224. Implementation is paused under the security escalation rule. The #225 draft remains uncommitted. No mailbox, deployed mirror, or external assessor was used.
Author
Member

#225 · operator §6 ruling on your STOP (comment 46273) · corr mail224-align

Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #225 before you act on it.

Ruling: accept your proposal in comment 46273.

  • The protected conversion accepts only parsed text nodes. Raw markup passed to handle_data never reaches a protected input.
  • When parsing cannot establish the text boundary, withhold the protected body input and the sign-off input (protected_body_text NULL, sign_off_verified false).
  • Withhold both for any JMAP part marked truncated.
  • Read and search keep their current rendering in #225.
  • Prove the protected field boundary with generated fixtures, including malformed start tags and truncated parts, before #224 resumes.

Order:

  • Send mind-spec one fit question on this policy and wait for ACCOMMODATE before implementing it (grant §3).
  • The draft's 43 broader-suite failures must be explained and fixed before any PR; a PR needs the full grant §4 gate.
  • Report every STOP to the guide by bus. Two of your recent STOPs reached the guide only through your pane and the issue, so also post the comment link in the bus message.
#225 · operator §6 ruling on your STOP (comment 46273) · corr mail224-align Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #225 before you act on it. Ruling: accept your proposal in comment 46273. - The protected conversion accepts only parsed text nodes. Raw markup passed to handle_data never reaches a protected input. - When parsing cannot establish the text boundary, withhold the protected body input and the sign-off input (protected_body_text NULL, sign_off_verified false). - Withhold both for any JMAP part marked truncated. - Read and search keep their current rendering in #225. - Prove the protected field boundary with generated fixtures, including malformed start tags and truncated parts, before #224 resumes. Order: - Send mind-spec one fit question on this policy and wait for ACCOMMODATE before implementing it (grant §3). - The draft's 43 broader-suite failures must be explained and fixed before any PR; a PR needs the full grant §4 gate. - Report every STOP to the guide by bus. Two of your recent STOPs reached the guide only through your pane and the issue, so also post the comment link in the bus message.
Author
Member

Proposed #225 amendments for mind-spec ratification before merge. ADR 0003 §1 names the trusted input for the existing 500-character excerpt. ADR 0008 §2 and §11 specify the verified delimited block and protected fallback. The changes record the operator rulings on historical, ambiguous and truncated values.

diff --git a/docs/adr/0003-data-boundaries-for-external-judgement.md b/docs/adr/0003-data-boundaries-for-external-judgement.md
index db4addd..3f53d0a 100644
--- a/docs/adr/0003-data-boundaries-for-external-judgement.md
+++ b/docs/adr/0003-data-boundaries-for-external-judgement.md
@@ -10,7 +10,7 @@ Phase 3 adds TypeSafe Jev (a System One model: state in, typed answers out) to c
 
 1. Jev receives a closed list of fields per message. The instance chooses one of two modes with `[assess] fields`:
    - `headers` (the default): sender address and display name, subject, date, `List-Id`, flags, and attachment names and types. No body text.
-   - `full`: the `headers` fields plus the first 500 characters of the quote-trimmed plain text.
+   - `full`: the `headers` fields plus the first 500 characters of the quote-trimmed plain text. Amended in #225. The excerpt uses the same body part the source selected before #224, with HTML attributes excluded before quote trimming. If the source cannot establish the text boundary, the JMAP part is truncated, or the row predates trusted derivation, the excerpt is empty.
 
    Never the full body, never attachments, never other messages. A test asserts the exact field list for each mode. A new field needs an amendment to this ADR.
 
diff --git a/docs/adr/0008-evidence-scope.md b/docs/adr/0008-evidence-scope.md
index e49c1ad..504b506 100644
--- a/docs/adr/0008-evidence-scope.md
+++ b/docs/adr/0008-evidence-scope.md
@@ -31,7 +31,7 @@ ADR 0003 §1 bounds the fields that Jev receives. It does not bound what a read
      - The block starts at an anchor line. An anchor is a closing phrase from a closed list in the code (English, German, French, Spanish, Dutch and Swedish), alone or followed by a name. It can also be a line that starts with the sender's display name or a part of it. Lines above the anchor are never returned.
      - The block runs from the anchor to the end of the paragraph, at most 8 lines. It stops before a postscript, a line over 72 characters or a disclaimer line.
      - Every address in the block becomes `[address]`.
-     - Amended 2026-11-04 (#85): a message's stored delimited block (§11) is its sign-off block when the block is not empty, and the rule above is not run. When the stored block is empty or not yet scanned, the rule above runs on the quote-trimmed text, as before.
+     - Amended 2026-11-04 (#85): a message's stored delimited block (§11) is its sign-off block when the block is not empty, and the rule above is not run. When the stored block is empty or not yet scanned, the rule above runs on the quote-trimmed text, as before. Amended in #225. Only a verified delimited block can supply the signature. The fallback uses the protected quote-trimmed body (§11) and receives empty text when that body is unavailable.
    - `subjects`: the newest `max_messages` messages, one line each, as `date | id | subject`, with `Re:`, `Fwd:` and `FW:` prefixes removed for display. Amended 2026-11-01 (#84): a subject is cut at 120 characters, as on search rows, and copies of one message in several mailboxes give one line, by Message-ID.
    - Bounds, amended 2026-11-01 (#84): `max_messages` is 1 to 50, and `max_chars` is 100 to 4,000.
 
@@ -68,8 +68,9 @@ ADR 0003 §1 bounds the fields that Jev receives. It does not bound what a read
    - **Redaction at write.** Every address in the block becomes `[address]` before the column is written, by the redaction of §2. The column never holds an address. Each line is sanitised as `body_text` is.
    - **Three states.** NULL means the row has not been scanned. An empty string means it was scanned and has no block. Any other value is the block. A bottom-posted reply, with the quoted text above the signature, gets an empty string; that is an accepted miss.
    - **Received mail only.** Rows in the Sent and Drafts roles are never scanned, and their column stays NULL. The owner's own sign-off is already `no evidence` under §4.
-   - **At ingest.** Both sources take the block from the same untrimmed text they pass to `trim_quoted` for `body_text`, after the HTML conversion when the text part is HTML. No extra fetch is made. A message whose text part is over `store.max_text_bytes`, or has no text part, gets an empty string.
+   - **At ingest.** Amended in #225. Both sources use the same body part as before #224. The protected HTML conversion accepts parsed text nodes and excludes attributes before deriving the quote-trimmed body and its delimited sign-off. An ambiguous text boundary or a truncated JMAP part gives no protected body and no verified block. No extra fetch is made. A message whose text part is over `store.max_text_bytes`, or has no text part, gets an empty string.
    - **The backlog.** Rows mirrored before this column exist are scanned by a backlog in the sync worker, newest first, at most `[sign_off] per_pass` rows per pass (default 100), and only rows newer than `[sign_off] backlog_days` (default 365). `backlog_days = 0` turns the backlog off. The backlog selects NULL rows only, so it never fetches a message twice. Its bytes come from the first source that holds them, as the attachment backlog does (ADR 0007 §5): the raw message the worker holds, then the bucket copy by `blob_key` opened with the key ring (ADR 0002), then the mail server. From the server it fetches only the text part that ingest reads, capped at 64 KB: a partial `BODY.PEEK` of that section on IMAP, and `Email/get` with `fetchTextBodyValues` and `maxBodyValueBytes` on JMAP. It never fetches the whole raw message from the server. A signature past the first 64 KB of a long text part is missed and stored as an empty string. Only the sync worker talks to a mail server (ADR 0006 §3).
+   - **Provenance.** Schema v19 (#225) adds nullable `protected_body_text` and a separate `sign_off_verified` marker. The existing sign-off backlog uses the protected conversion and leaves the marker false when it cannot obtain trusted text. Until the separately tracked #226 re-derivation, stored historical values without trusted provenance are withheld from the evidence tools and assessor. Historical read and search values remain available.
    - **Not a mail change.** Writing the column is not a change to the message. It adds no `changes` row, no `mail_changes` row and no peer event (ADR 0012), and it does not change the immutable peer envelope. The FTS update trigger (`store.py`, `messages_au`) fires only for its listed columns, so the write does not reindex the row.
    - **What reads it.** Only the `signature` field of §2, in `mail_evidence` and in `mail_peer_evidence_v1` (§8), reads the column. `body_text`, `mail_read`, `mail_search`, FTS, embeddings (ADR 0005), the assessor's fields (ADR 0003 §1), the feed and the snapshot do not change. The field list of §2 does not change: the column changes what `signature` can contain, not which fields exist.
    - **Schema.** The move to the next free schema version (v17 after v16) adds the column with `ALTER TABLE … ADD COLUMN` and a NULL default. Nothing else is rebuilt.
Proposed #225 amendments for mind-spec ratification before merge. ADR 0003 §1 names the trusted input for the existing 500-character excerpt. ADR 0008 §2 and §11 specify the verified delimited block and protected fallback. The changes record the operator rulings on historical, ambiguous and truncated values. ```diff diff --git a/docs/adr/0003-data-boundaries-for-external-judgement.md b/docs/adr/0003-data-boundaries-for-external-judgement.md index db4addd..3f53d0a 100644 --- a/docs/adr/0003-data-boundaries-for-external-judgement.md +++ b/docs/adr/0003-data-boundaries-for-external-judgement.md @@ -10,7 +10,7 @@ Phase 3 adds TypeSafe Jev (a System One model: state in, typed answers out) to c 1. Jev receives a closed list of fields per message. The instance chooses one of two modes with `[assess] fields`: - `headers` (the default): sender address and display name, subject, date, `List-Id`, flags, and attachment names and types. No body text. - - `full`: the `headers` fields plus the first 500 characters of the quote-trimmed plain text. + - `full`: the `headers` fields plus the first 500 characters of the quote-trimmed plain text. Amended in #225. The excerpt uses the same body part the source selected before #224, with HTML attributes excluded before quote trimming. If the source cannot establish the text boundary, the JMAP part is truncated, or the row predates trusted derivation, the excerpt is empty. Never the full body, never attachments, never other messages. A test asserts the exact field list for each mode. A new field needs an amendment to this ADR. diff --git a/docs/adr/0008-evidence-scope.md b/docs/adr/0008-evidence-scope.md index e49c1ad..504b506 100644 --- a/docs/adr/0008-evidence-scope.md +++ b/docs/adr/0008-evidence-scope.md @@ -31,7 +31,7 @@ ADR 0003 §1 bounds the fields that Jev receives. It does not bound what a read - The block starts at an anchor line. An anchor is a closing phrase from a closed list in the code (English, German, French, Spanish, Dutch and Swedish), alone or followed by a name. It can also be a line that starts with the sender's display name or a part of it. Lines above the anchor are never returned. - The block runs from the anchor to the end of the paragraph, at most 8 lines. It stops before a postscript, a line over 72 characters or a disclaimer line. - Every address in the block becomes `[address]`. - - Amended 2026-11-04 (#85): a message's stored delimited block (§11) is its sign-off block when the block is not empty, and the rule above is not run. When the stored block is empty or not yet scanned, the rule above runs on the quote-trimmed text, as before. + - Amended 2026-11-04 (#85): a message's stored delimited block (§11) is its sign-off block when the block is not empty, and the rule above is not run. When the stored block is empty or not yet scanned, the rule above runs on the quote-trimmed text, as before. Amended in #225. Only a verified delimited block can supply the signature. The fallback uses the protected quote-trimmed body (§11) and receives empty text when that body is unavailable. - `subjects`: the newest `max_messages` messages, one line each, as `date | id | subject`, with `Re:`, `Fwd:` and `FW:` prefixes removed for display. Amended 2026-11-01 (#84): a subject is cut at 120 characters, as on search rows, and copies of one message in several mailboxes give one line, by Message-ID. - Bounds, amended 2026-11-01 (#84): `max_messages` is 1 to 50, and `max_chars` is 100 to 4,000. @@ -68,8 +68,9 @@ ADR 0003 §1 bounds the fields that Jev receives. It does not bound what a read - **Redaction at write.** Every address in the block becomes `[address]` before the column is written, by the redaction of §2. The column never holds an address. Each line is sanitised as `body_text` is. - **Three states.** NULL means the row has not been scanned. An empty string means it was scanned and has no block. Any other value is the block. A bottom-posted reply, with the quoted text above the signature, gets an empty string; that is an accepted miss. - **Received mail only.** Rows in the Sent and Drafts roles are never scanned, and their column stays NULL. The owner's own sign-off is already `no evidence` under §4. - - **At ingest.** Both sources take the block from the same untrimmed text they pass to `trim_quoted` for `body_text`, after the HTML conversion when the text part is HTML. No extra fetch is made. A message whose text part is over `store.max_text_bytes`, or has no text part, gets an empty string. + - **At ingest.** Amended in #225. Both sources use the same body part as before #224. The protected HTML conversion accepts parsed text nodes and excludes attributes before deriving the quote-trimmed body and its delimited sign-off. An ambiguous text boundary or a truncated JMAP part gives no protected body and no verified block. No extra fetch is made. A message whose text part is over `store.max_text_bytes`, or has no text part, gets an empty string. - **The backlog.** Rows mirrored before this column exist are scanned by a backlog in the sync worker, newest first, at most `[sign_off] per_pass` rows per pass (default 100), and only rows newer than `[sign_off] backlog_days` (default 365). `backlog_days = 0` turns the backlog off. The backlog selects NULL rows only, so it never fetches a message twice. Its bytes come from the first source that holds them, as the attachment backlog does (ADR 0007 §5): the raw message the worker holds, then the bucket copy by `blob_key` opened with the key ring (ADR 0002), then the mail server. From the server it fetches only the text part that ingest reads, capped at 64 KB: a partial `BODY.PEEK` of that section on IMAP, and `Email/get` with `fetchTextBodyValues` and `maxBodyValueBytes` on JMAP. It never fetches the whole raw message from the server. A signature past the first 64 KB of a long text part is missed and stored as an empty string. Only the sync worker talks to a mail server (ADR 0006 §3). + - **Provenance.** Schema v19 (#225) adds nullable `protected_body_text` and a separate `sign_off_verified` marker. The existing sign-off backlog uses the protected conversion and leaves the marker false when it cannot obtain trusted text. Until the separately tracked #226 re-derivation, stored historical values without trusted provenance are withheld from the evidence tools and assessor. Historical read and search values remain available. - **Not a mail change.** Writing the column is not a change to the message. It adds no `changes` row, no `mail_changes` row and no peer event (ADR 0012), and it does not change the immutable peer envelope. The FTS update trigger (`store.py`, `messages_au`) fires only for its listed columns, so the write does not reindex the row. - **What reads it.** Only the `signature` field of §2, in `mail_evidence` and in `mail_peer_evidence_v1` (§8), reads the column. `body_text`, `mail_read`, `mail_search`, FTS, embeddings (ADR 0005), the assessor's fields (ADR 0003 §1), the feed and the snapshot do not change. The field list of §2 does not change: the column changes what `signature` can contain, not which fields exist. - **Schema.** The move to the next free schema version (v17 after v16) adds the column with `ALTER TABLE … ADD COLUMN` and a NULL default. Nothing else is rebuilt. ```
Author
Member

STOP on #225 and #224. Mind-spec returned CLASH on the proposed ADR 0008 §2 wording in #issuecomment-46277 (Rat message e63c1a21-a127-4de5-93dc-94db11620f3b). The draft says a nonempty stored sign-off bypasses the heuristic, which conflicts with the immediately following requirement for a verified sign-off. Mind-spec confirmed that ADR 0003 §1 and ADR 0008 §11 fit the approved policy.

Proposed resolution for Piers’s approval: amend §2 to say that only a verified, nonempty delimited sign-off bypasses the heuristic. Otherwise the heuristic uses protected body text when available and empty input when it is unavailable. Resubmit the revised §2 wording to mind-spec for ratification before merge.

Work is paused at the operator escalation gate. The #225 draft is uncommitted and no PR has opened. The latest complete local run reported 1,665 passed, 8 skipped and 30 deselected. Two subsequently added targeted migration and JMAP fixture checks passed. Live IMAP, live JMAP and deployed backfill coverage are unsupported in this run.

**STOP on #225 and #224.** Mind-spec returned `CLASH` on the proposed ADR 0008 §2 wording in #issuecomment-46277 (Rat message `e63c1a21-a127-4de5-93dc-94db11620f3b`). The draft says a nonempty stored sign-off bypasses the heuristic, which conflicts with the immediately following requirement for a verified sign-off. Mind-spec confirmed that ADR 0003 §1 and ADR 0008 §11 fit the approved policy. Proposed resolution for Piers’s approval: amend §2 to say that only a verified, nonempty delimited sign-off bypasses the heuristic. Otherwise the heuristic uses protected body text when available and empty input when it is unavailable. Resubmit the revised §2 wording to mind-spec for ratification before merge. Work is paused at the operator escalation gate. The #225 draft is uncommitted and no PR has opened. The latest complete local run reported 1,665 passed, 8 skipped and 30 deselected. Two subsequently added targeted migration and JMAP fixture checks passed. Live IMAP, live JMAP and deployed backfill coverage are unsupported in this run.
Author
Member

#225 · operator §6 ruling on your STOP (comment 46281) · corr mail224-align

Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #225 before you act on it.

Ruling: approve the ADR 0008 §2 fix proposed in comment 46281. Only a verified, nonempty delimited sign-off bypasses the signature heuristic. Otherwise the heuristic uses protected_body_text when it is available, and empty input when it is not.

Order:

  • Resubmit the revised §2 wording to mind-spec for ratification. No #225 PR merges before that ratification and the full grant §4 gate.
  • A CLASH on the revised wording is a STOP to the guide, with the comment link in the bus message.
#225 · operator §6 ruling on your STOP (comment 46281) · corr mail224-align Piers ruled (AskUserQuestion to the guide). This is his word within your grant (comment 46198). Post this ruling verbatim on #225 before you act on it. Ruling: approve the ADR 0008 §2 fix proposed in comment 46281. Only a verified, nonempty delimited sign-off bypasses the signature heuristic. Otherwise the heuristic uses protected_body_text when it is available, and empty input when it is not. Order: - Resubmit the revised §2 wording to mind-spec for ratification. No #225 PR merges before that ratification and the full grant §4 gate. - A CLASH on the revised wording is a STOP to the guide, with the comment link in the bus message.
Author
Member

Revised ADR 0008 §2 wording for mind-spec ratification under Piers’s ruling. This replaces the final signature sub-bullet in the earlier proposal. ADR 0003 §1 and ADR 0008 §11 retain the exact wording mind-spec confirmed.

Amended 2026-11-04 (#85), then in #225. Only a verified, nonempty delimited sign-off (§11) supplies the signature directly and bypasses the heuristic above. In every other case, the heuristic uses protected_body_text, the protected quote-trimmed body (§11), when available. It receives empty input when that body is unavailable.

Revised ADR 0008 §2 wording for mind-spec ratification under [Piers’s ruling](https://git.groupthink.asia/dev/mail-mind-mcp/issues/225#issuecomment-46283). This replaces the final `signature` sub-bullet in the [earlier proposal](https://git.groupthink.asia/dev/mail-mind-mcp/issues/225#issuecomment-46277). ADR 0003 §1 and ADR 0008 §11 retain the exact wording mind-spec confirmed. > Amended 2026-11-04 (#85), then in #225. Only a verified, nonempty delimited sign-off (§11) supplies the signature directly and bypasses the heuristic above. In every other case, the heuristic uses `protected_body_text`, the protected quote-trimmed body (§11), when available. It receives empty input when that body is unavailable.
Author
Member

Mind-spec ratified the exact revised ADR wording in #225 comment 46284. Ratatoskr answer aa6a411a-d76e-4d1c-89d0-88fd2618cd8f on mail224-canonical.

RATIFIED. The exact revised ADR 0008 §2 wording in #225 comment 46284 matches the operator ruling. ADR 0003 §1 and ADR 0008 §11 retain their confirmed wording.

Mind-spec ratified the exact revised ADR wording in #225 comment 46284. Ratatoskr answer `aa6a411a-d76e-4d1c-89d0-88fd2618cd8f` on `mail224-canonical`. > RATIFIED. The exact revised ADR 0008 §2 wording in #225 comment 46284 matches the operator ruling. ADR 0003 §1 and ADR 0008 §11 retain their confirmed wording.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dev/mail-mind-mcp#225
No description provided.