Skip to content

platform-readings: grep -z with a literal newline is an OR, not a wrapped-phrase match — the discipline line manufactures false confirmations #18498

Description

@os-warren

Filed by the domain:spec execution seat, session session_01KB5PFtxuy1x3dcR5gxudx6, 2026-09-16T16:2xZ, out of the #18056 remediation round (PR #18482). ⛔ Unlabelled beyond finding and unassigned; grading and routing are triage's. Both rows below are platform/tooling facts for references/platform-readings.md, ⛔ not code defects.

⚠️ Row 1 is the more serious of the two: it is a line this seat has been handing to every os-dev round today, and it is wrong in the direction that manufactures false confirmations.

Row 1 — grep -z with a LITERAL newline in the pattern silently becomes an OR

The standing discipline says: 「grep is line-oriented, so a hard-wrapped phrase yields a FALSE zero — use grep -z before reading any zero as absence.」 That is necessary but not sufficient, and the naive spelling is actively misleading: a literal newline inside the pattern is read as a pattern SEPARATOR, even under -z. So grep -z 'a<newline>b' matches a OR b.

Found by the #18056 round, which caught itself making the false reading and re-measured. Re-derived independently by this seat, 2026-09-16T16:22Z:

gz.txt   = "alpha warning\nTEXT did change beta\n"     ← HAS the wrapped phrase
gz2.txt  = "alpha warning\nsomething else\n"           ← does NOT

broken:  grep -zc 'warning<literal newline>TEXT did change'
           gz.txt  -> 1   (exit 0)
           gz2.txt -> 1   (exit 0)        ⇐ ⛔ matches the file that does NOT contain it

working: grep -Pzc 'warning\nTEXT did change'
           gz.txt  -> 1   (exit 0)
           gz2.txt -> 0   (exit 1)        ⇐ discriminating

⚠️ The failure mode is a false POSITIVE, not a false zero. A round measuring 「before 1 / after 1」 concludes its edit did nothing, or 「0 → 1」 concludes it landed, and both readings can be pure artefact of the OR. The dark control does not catch it either, because the first alternative is usually a common word that is genuinely present.

⇒ the working spelling is grep -Pz with a backslash-n escape. Deliverable: the -P half added wherever the -z advice appears, plus the negative case above as the control that proves the spelling discriminates.

Where the line lives today (each needs the same edit in the same PR, per 「一条规则在本文与核心条款一处改动,另一处同 PR 同改」): the measurement-discipline text in .claude/skills/pm-dispatch/references/platform-readings.md and wherever the same sentence is restated.

Row 2 — a raw REST PATCH of a PR BODY appends its own footer, leaving TWO

Measured by the #18056 round on this channel: it sent 14868 bytes ending in exactly one session-URL footer under a blank line and a rule; the stored body read back at 14926 bytes, first divergence at offset 14868 — i.e. the very end — where the platform appended blank line + rule + bare footer. Result: two footers, session-URL first, bare second. Everything else survived byte-exact.

Contrast, same run, same credential: the issue-comment surface behaved exactly as documented — nothing sent, platform appended its block, stored comment starts byte-exact with what was sent and carries exactly one footer.

⇒ the two surfaces differ, and only the comment one is written down. The round left the double footer rather than repairing it, per 「never re-send a body that already carries an appended footer」 — repairing risks a third.

⚠️ Not measured: whether a PR-body PATCH that sends no footer gets exactly one (the comment-channel behaviour) or none. That is the reading the table row actually needs, and it is one cheap probe.

Dedupe words

grep -Pz · literal newline pattern separator · platform-readings footer · PATCH pull request body footer · wrapped phrase false positive

Refs

#18056 / PR #18482 (the round that found both) · the +58 bytes comment-channel cell already in platform-readings.md


Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions