The saved file is the object to inspect
A reviewer receives a robots.txt attachment and a screenshot of its final Disallow line. The editor shows the expected words, so the supplier calls the file complete. That review has skipped the actual saved encoding, byte length and position of the required line. Preserve the attachment unchanged before opening and saving it again: a re-save can change the very evidence being checked.
The historical question below asks how to save such a file from a text editor. Its conflicting old replies illustrate why a dated official source matters. It does not establish present search volume, a client incident or the cause of any live crawl problem. Our exercise extends that file-delivery question into a concrete, offline byte-envelope check.
Keep characters, bytes and effective rules separate
Google documents UTF-8 plain text and a 500KiB robots.txt size limit, with later content ignored. Here 500 × 1024 is 512,000 bytes; it is not a count of URLs, lines or editor characters. In our small supplied example, two Chinese characters account for a four-byte difference between the UTF-8 byte count and Python character count. That arithmetic describes only this fixture.
The program records a zero-based start and exclusive end byte offset for each CR, LF or CRLF line. A line starting at byte 512,000 is outside the retained envelope. A line crossing the boundary is flagged without predicting how a crawler interprets its partial contents. Google’s limit must not be advertised as a universal parser contract for every bot.
Read the negative cases before approving consolidation
The six synthetic cases include a normal ASCII input, a Chinese comment, an invalid UTF-8 byte, an exact-boundary file, a later rule and a crossing line. An invalid byte returns INVALID_UTF8_REVIEW rather than being silently replaced. The exact-boundary case passes only the size comparison, leaving no margin. The oversized case preserves its hash and line offsets for diagnosis; it does not rewrite the file.
Replacing thousands of specific paths with a broad wildcard is a policy change, not a size optimisation certificate. A useful correction brief first retains the approved path inventory, then compares intended allowed and disallowed paths before and after a proposed consolidation. Effective user-agent groups, path matching and live fetch evidence have their own reviews. This byte checker decides none of them, and robots.txt is not an access-control or privacy mechanism.
Run the finite check and deliver the evidence
Use Python 3.10 or newer. Save envelope_check.py and a supplied robots file locally, then run the command below. Run the accompanying eight test groups in the same folder to reproduce encoding, byte-boundary, sitemap-count and bounded-decompression cases. The complete bilingual case output is included; all domains, bytes and outcomes are synthetic teaching inputs. No network, account or API is used.
A handover contains the unchanged input hash, encoding result, byte count, required line ranges and a separately authorised correction proposal if needed. A later production check must identify the actual returned file and observation time. A local WITHIN_BYTE_ENVELOPE_ONLY result does not certify live serving, effective crawl permissions, indexing or a search result.
python3 -B envelope_check.py robots supplied-robots.txtSix actual fixture outputs
Synthetic inputs; scroll on a narrow screen. Each result is scoped to the supplied file.
| Input | Actual output | Review |
|---|---|---|
| Plain UTF-8 sample | WITHIN_BYTE_ENVELOPE_ONLY | Only the byte/encoding checks pass; rules have not been matched. |
| Non-ASCII comment | WITHIN_BYTE_ENVELOPE_ONLY | Compare byte and character counts on the unchanged bytes. |
| Invalid UTF-8 byte | INVALID_UTF8_REVIEW | Return review-needed, without silently replacing the byte. |
| Exactly 512,000 bytes | WITHIN_BYTE_ENVELOPE_ONLY | The size boundary alone passes, with no safety margin. |
| A rule starts after the boundary | OVERSIZE_REVIEW | Do not rely on that later line; review consolidation against a complete approved path inventory. |
| A line crosses the boundary | OVERSIZE_REVIEW | Flag the crossing; do not invent how Google parses the partial line. |
Sources and reproducible resources
Original historical question · Demand evidence only; replies are not current policy.
Supporting passages checked 6 November 2026. Case labels and workflow choices are our original teaching design.
README.txt · envelope_check.py · test_envelopes.py · filled-review.json