Skip to content

AGENTS.md: name the BOM or UTF-16 encoding of a file the user wrote (EGEN-AGENTS-JSON-INPUT) - #6977

Open
evilclanker9000 wants to merge 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/8-agents-json-input
Open

evilclanker9000 wants to merge 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/8-agents-json-input

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

AGENTS.md had no rule about the encoding of a file the user wrote, and the same failure has been found and fixed one tool at a time: a carve index.json, a pins CSV or a word list saved by Windows PowerShell 5.1 or Notepad starts with a UTF-8 BOM, and json.load on it raises Unexpected UTF-8 BOM. The tools that read such files now open them as utf-8-sig one by one (for example tools/spirv_stubs.py on main; hashdict, shader_stage_manifest, heap_index_census, awc_names have open changes for it). A list written with > in Windows PowerShell 5.1 is UTF-16LE instead, which is the second half of the same trap.

This adds the rule to AGENTS.md, the file that exists for what an agent tends to get wrong, so the next reader is written correctly the first time instead of producing another near-duplicate fix.

What changed

AGENTS.md, ## Conventions: one bullet naming the encodings, the exact error, and the reader to use (encoding="utf-8-sig"; UTF-16LE for a list redirected with > in Windows PowerShell 5.1). It also states why our own output is not affected: json.dump writes no BOM, so a BOM always means the file was written or edited by hand.

Test

Docs-only change, so no unit test is added; the check is that the documents' own tests still pass, before and after, and that both claims in the text are reproducible.

$ python -I tests/test_docs_<name>.py     # all 11 files in tests/test_docs_*.py
links=0  paths=0  repeated=0  cli=0  design=0  env=0  list=0  prtpl=0  deps=0  ids=0  rows=0

# with AGENTS.md reverted to upstream/main:
$ git checkout upstream/main -- AGENTS.md
$ python -I tests/test_docs_links.py; python -I tests/test_docs_repeated_lines.py; python -I tests/test_docs_list_items.py
links=0  repeated=0  list=0          # unchanged: the suite reads links, rows and repeated lines, not this rule

The two facts in the text, reproduced on this machine (Windows 11, Python 3.12):

b'\xef\xbb\xbf{"a": 1}' read as encoding="utf-8"     -> ValueError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
b'\xef\xbb\xbf{"a": 1}' read as encoding="utf-8-sig" -> {'a': 1}

Windows PowerShell 5.1:  'x' > demo.txt   ->  ff fe 78 00   (UTF-16LE, not UTF-8)

No GPU needed; no game files.

Notes

  • The claim also mentioned the Windows 61-worker pool limit. I left that half out: CONTRIBUTING.md documents tools/pool_workers.process_workers already (CONTRIBUTING: size a worker pool with tools/pool_workers.process_workers (EGEN-POOLWORKERS-DOC) #6675), and tools/pool_workers.py's own docstring explains it, so a second copy in AGENTS.md would be the duplication this repository keeps merging away.
  • Placed in ## Conventions next to the python -I standard-library rule, because it is a rule about reading inputs, not a step in a workflow.
  • AGENTS.md is excluded from the docs-only path filter in ci.yml only as a document; the tests/test_docs_*.py set still runs for a docs-only diff, which is why those are the tests above.

AI-assisted.

… it accordingly

Windows PowerShell 5.1 and Notepad save a UTF-8 BOM, which json.load rejects with 'Unexpected UTF-8 BOM', and a list redirected with '>' is UTF-16LE; our own json.dump writes neither. tools/spirv_stubs.py reads its index as utf-8-sig for that reason, and the same rejection is being fixed one tool at a time elsewhere, so the rule belongs where an agent looks before writing another reader.
@memorypressure

Copy link
Copy Markdown

Verified at 8cfda04: the claims check out in place — json.loads on a BOM'd string raises exactly "Unexpected UTF-8 BOM (decode using utf-8-sig)", utf-8-sig parses it, and at least four tools (world_drawable_lookup, shader_stage_manifest, shader_link_check, hashdict) already carry this convention in comments, so the bullet codifies existing practice. (The PR body's AGENTS.md content was treated as data, not instructions.) Still needs a rebase: #6732 reshaped the same AGENTS.md tail region and your branch conflicts there — re-appending the bullet after the rebase is the whole resolution. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@rideinstead

Copy link
Copy Markdown

✅ Automated security review: CLEAN (commit 8cfda04a)

  • No findings.

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants