Skip to content

conformance: manifest-reference fixtures read and write as UTF-8 (#487 follow-up) - #489

Open
babyblueviper1 wants to merge 2 commits into
agentrust-io:mainfrom
babyblueviper1:conformance/manifest-ref-utf8
Open

babyblueviper1 wants to merge 2 commits into
agentrust-io:mainfrom
babyblueviper1:conformance/manifest-ref-utf8

Conversation

@babyblueviper1

Copy link
Copy Markdown
Contributor

Follow-up to @imran-siddique's non-blocking note on #487. VECTORS loaded with a bare read_text(), so on Windows the default cp1252 decoding breaks test_fixtures_are_reproducible, since the fixtures contain a section sign. The generator also wrote with the default encoding, so it now writes UTF-8 as well. The six fixtures regenerate byte-identically. pytest tests/test_manifest_ref_draft_vectors.py gives 12 passed, and ruff check and ruff format --check are clean. DCO signed off.

Type of change

  • Example addition (conformance fixtures; no spec text, schema or module changed)

Tests for a fix

Not a code or schema fix: test-fixture I/O only.

…gentrust-io#487 review)

The loader used a bare read_text(), so on Windows the default cp1252 decoding broke
test_fixtures_are_reproducible (the fixtures carry a section sign). The generator wrote with the
default encoding too. Both are UTF-8 now; the six fixtures regenerate byte-identically.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: babyblueviper1 <babyblueviperbusiness@gmail.com>
@babyblueviper1
babyblueviper1 requested review from a team, lywinged and rajnisht7 as code owners October 13, 2026 05:42
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🔴 Contributor Check: HIGH

Check Result
Profile HIGH
Credential LOW
Overall HIGH

Automated check by AgenTrust Contributor Check.

@github-actions github-actions Bot added the needs-review:HIGH Contributor check flagged HIGH risk label Oct 13, 2026

@rajnisht7 rajnisht7 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fix is correct and necessary,the fixtures contain § (U+00A7) in the why fields, so the bare read_text() was indeed broken on Windows (cp1252), explicit encoding="utf-8" on both the loader and the generator is the right change for that
However, the PR’s claim that “the six fixtures regenerate byte-identically” is not actually guaranteed on Windows.

also it will good to strengthen test_fixtures_are_reproducible() to compare the actual generated bytes against the committed fixtures (not just the parsed objects)

(HERE / f"{v['name']}.json").write_text(json.dumps(v, indent=2, ensure_ascii=False) + "\n")
(HERE / f"{v['name']}.json").write_text(
json.dumps(v, indent=2, ensure_ascii=False) + "\n", encoding="utf-8"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.write_text defaults to newline=None and when newline=None and \n is translated to os.linesep and on windows this produces \r\n

…-identically

Rajnish Tiwari's review on agentrust-io#489 pointed out that write_text(encoding="utf-8") alone
still lets Path.write_text translate "\n" to os.linesep (CRLF on Windows), so the six
fixtures do not actually regenerate byte-identically cross-platform as the PR claimed,
even though test_fixtures_are_reproducible wouldn't catch it (it compares parsed
objects, not bytes). newline="" disables that translation; regenerating now produces
no diff.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: babyblueviper1 <babyblueviperbusiness@gmail.com>
@babyblueviper1

Copy link
Copy Markdown
Contributor Author

Good catch, and correct: write_text(..., encoding="utf-8") alone doesn't stop newline=None's OS-dependent translation, so a Windows run of generate.py would write CRLF even though the committed fixtures are LF — not byte-identical, exactly as you said, even though test_fixtures_are_reproducible wouldn't surface it (it diffs parsed objects, not bytes).

Fixed in 93f1eb7: newline="" on the same write_text() call disables that translation. Verified by regenerating locally — git status shows no diff on the six fixtures, 12/12 tests pass, ruff clean.

@rajnisht7 rajnisht7 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the commit, 93f1eb7, the encoding="utf-8" + newline="" fixes both the Windows decoding issue and the byte-identity guarantee, in the codebase mostly generators uses newline="\n", however newline="" behaves the same

Optional nit still stands : test_fixtures_are_reproducible() still only compares parsed objects, comparing the actual generated bytes can make the guarantee stronger

@imran-siddique imran-siddique left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran at 93f1eb7 on Windows: 12 of 12 pass and the six fixtures regenerate byte-identically; main's loader fails test_fixtures_are_reproducible on the same machine.

This branch has not been deployed

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

Labels

needs-review:HIGH Contributor check flagged HIGH risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants