A robot-support notebook may reconstruct a Python source fragment from tokens and then label the result an unchanged copy. That label needs a declared comparison. Preserving token types and token text does not establish that the reconstructed file has the same bytes, spacing, or source-column positions.

An original offline fixture separates those checks using one invented assignment and a comment. The example is source text for inspection, not a robot parameter update. It does not execute the assignment, load a controller, or modify a deployed script. Python 3.14.7 was used locally; the official reference pages displayed version 3.14.10 when checked.

Start with an exact source artifact

The original ASCII byte string is b'gain = 12 + 3 # bench label\n'. There is one space on each side of the equals and plus signs, two spaces before the comment, and a final newline. The name gain is merely a diagnostic identifier; twelve and three have no device units or approved operating meaning.

Keeping the input as bytes makes an exact-copy requirement testable. The fixture records the original byte sequence and its SHA-256 before doing any token processing. The original digest starts f1c54ee8. That abbreviated value is a reading aid; the complete digest remains in the saved execution evidence.

Tokenize without evaluating the fragment

The fixture passes io.BytesIO(source).readline to tokenize.tokenize and collects the resulting TokenInfo objects. It then constructs a sequence containing only each token's type and string fields. Source positions and full-line fields are deliberately omitted from this second representation.

This choice models a small inspection tool that stores lexical content while discarding layout information. The distinction is explicit: the original bytes remain available, but the reconstruction step receives the reduced token pairs. It is not a claim that every tool using full TokenInfo objects will produce this exact output.

The tokenize reference describes a round-trip guarantee for token type and token string, while allowing spacing and columns to change. It also distinguishes byte output when an ENCODING token is present from string output when it is absent. [Python tokenize reference](https://docs.python.org/3.14/library/tokenize.html).

Reconstruct and compare the actual bytes

Passing the reduced sequence to tokenize.untokenize produces b'gain =12 +3 # bench label\n' on the installed runtime. The assignment name, operators, numeric token strings, and comment text remain visible. Several spaces have changed, so the reconstructed bytes are not equal to the original bytes.

The reconstructed SHA-256 starts 51ddc8b9, different from the original digest. Direct byte comparison already establishes the difference; the hashes help connect each stored artifact to its receipt. The fixture does not use unequal hashes to infer a particular behavioral change or a change to any physical system.

An inspector can therefore truthfully report a successful token round trip and a failed exact-copy check for the same operation. Those are separate predicates over separate representations. Combining them into one field named unchanged would conceal which condition actually passed.

Retokenize the result

The fixture tokenizes the reconstructed bytes again, extracts the same type-and-string pairs, and compares the two pair sequences in order. That comparison is true. It includes the comment token and encoding token rather than silently discarding them before making the claim.

Position comparison tells a different story. The numeric token 12 begins at zero-based column seven in the original line and column six in the reconstructed line. The comment starts at column fifteen originally and column twelve afterward. These positions are observed results for the explicit ASCII fragment, where character and byte column counts coincide.

A source annotation stored as line one, column fifteen cannot automatically be carried forward as the same textual location. The notebook needs either the preserved original artifact or a mapping to the reconstructed representation. Token equality alone supplies neither mapping nor evidence that old editor coordinates remain valid.

Compare syntax under a narrower test

The fixture also parses both byte strings with ast.parse and compares ast.dump results with include_attributes=False. Those dumps match for this fragment. The selected comparison omits source-location attributes and records the same assignment structure and arithmetic expression.

The ast reference documents parsing into a syntax tree and the dump interface's treatment of attributes. The comparison here is an original diagnostic check with declared options. It is not a general proof of behavioral equivalence for arbitrary programs or environments. [Python ast reference](https://docs.python.org/3.14/library/ast.html).

Nothing in the fixture runs the parsed source. Matching tree dumps do not establish that a robot accepts the text, that a configuration is appropriate, or that external dependencies are unchanged. Those questions require evidence beyond the representation comparisons performed in this notebook.

Use a comment control to expose another boundary

A separate control changes the original comment from bench label to revised label while leaving the assignment text intact. The selected AST dumps still match. However, the ordered token-pair comparison is false because the comment token's string changed.

This control prevents the syntax-tree check from being mistaken for a complete textual preservation check. A review comment may matter to a human audit even when it is absent from the selected syntax-tree representation. The example does not treat every comment as executable behavior; it preserves the distinction between audit text and parsed assignment structure.

Track output type as well as content

For another control, the fixture uses tokenize.generate_tokens with a text reader, constructs token pairs, and passes those to untokenize. That path has no ENCODING token and returns a str in the local run. The byte-reader path returns bytes.

A file-writing helper must know which representation it received before selecting an encoding policy. This control does not test non-ASCII characters, byte-order marks, mixed line endings, invalid syntax, or encoding declarations. The conclusions stay with the valid ASCII source and the two interfaces actually exercised.

Keep the preservation contract visible

The saved receipt distinguishes original bytes, reconstructed bytes, their full digests, token-pair equality, observed columns, selected AST comparison, comment control, and output type. A robot-support archive requiring exact source preservation can retain the original bytes and label reconstruction as a derived artifact.

Sources were checked November 18, 2026. All source fragments, comparisons, and observations are original offline editorial work. The accompanying AI-generated illustration compares two synthetic source cards; it is not a deployed editor screenshot or evidence of an approved robot-code change.