# Line endings are load-bearing in this repository.
#
# `crates/l2-mods/rulesets/core/rules/*.toml` are *generated* documents, and
# `crates/l2-mods/tests/core.rs` compares them byte for byte against the
# renderer that produced them. The renderer emits "\n".
#
# GitHub's Windows runners default to `core.autocrlf=true`, so a fresh checkout
# there rewrote those files with CRLF and the comparison failed - green on
# Linux, red on Windows, and passing on every developer machine configured with
# `autocrlf=input`. Normalising here fixes it for every checkout on every
# platform, which a per-test workaround would not: a test that shrugged off
# line endings would also stop noticing real drift in the generated files.
#
# `eol=lf` (not just `text=auto`) is the part that matters - it pins the
# *working tree*, overriding whatever core.autocrlf the machine has.
* text=auto eol=lf

# Windows-only scripts that people may open in tools which insist on CRLF.
# Nothing compares these byte-for-byte.
*.ps1 text eol=crlf
*.cmd text eol=crlf
*.bat text eol=crlf

# Never touch these, whatever heuristics would otherwise guess.
# The asset types are gitignored and must never be committed (CLAUDE.md rule 1);
# they are listed anyway so that a force-add cannot silently corrupt one.
*.pl8  binary
*.256  binary
*.smk  binary
*.wav  binary
*.saf  binary
*.sav  binary
*.dat  binary
*.exe  binary
*.dll  binary
*.png  binary
*.bmp  binary
*.jpg  binary
*.bundle binary

# **The symbol databases merge by key, never by line.**
#
# `docs/symbols.json` once produced nine conflict hunks in which the `ours` body
# of every hunk sat under the *wrong entry's* `name` — git had aligned two
# arrays that were ordered differently, so the diff paired unrelated records and
# offered `County_PlaceBlacksmith`'s comment as a candidate body for
# `Move_BuildCostMap`. Nothing was wrong with the data: the two branches had
# touched different addresses and only the order differed. A textual resolution
# would have produced a symbol database that parses, reads plausibly, and lies.
#
# What caught it was `JSON.parse` failing on the union — a syntactic check
# catching a semantic disaster by luck, which is not a defence to rely on twice.
# `docs/agents.md`, *A file that looks like data is usually a claim*.
#
# The driver also honours a DELETION on one side, which is what
# `docs/hypotheses.json` needs: promotion is a move, not a copy, and a naive
# union turns every promotion back into a copy — it did, four times, in one
# evening.
#
# `merge=l2json` needs the driver registered per clone; git will not run a
# driver a repository merely asks for. `tools/symbols/install-merge-driver.sh`
# does it. WITHOUT that registration git falls back to the ordinary text merge,
# which is safe because it is loud: the conflict markers appear as before.
docs/symbols.json    merge=l2json
docs/hypotheses.json merge=l2json
docs/records.json    merge=l2json
#
# `docs/arms.json` is here for a sharper reason than the others: THREE agents are
# writing it concurrently, and it carries both `id` and `addr` with 42 records
# across 23 addresses, because one function can hold several input arms. Keyed on
# `addr` the driver would have collapsed 42 records into 23 and thrown 19 away in
# silence -- so `id` outranks `addr` in KEY_FIELDS, and `merge-json.js --check`
# refuses any array whose chosen key is not unique.
docs/arms.json       merge=l2json
#
# `docs/audio.json` is registered here at the same moment it is created, which is
# the half of the mechanism that was missed last time: the driver had been built,
# tested and falsified the day before `docs/arms.json` landed, and the newest and
# most exposed file of that shape was outside it. `docs/agents.md`, *the worked
# example*. Keyed by `id` (`<caller>#<n>`) rather than `addr`, because one
# function holds several trigger sites -- `Msg_DrawWindow` holds twenty-four --
# so an `addr` key would collapse 143 records into 70 and discard 73 in silence.
docs/audio.json      merge=l2json
#
# `docs/work.json` is the work ledger, and the first keyed file whose records are
# not the whole file: they sit under `items`, beside `about`, `states` and
# `tracks`, which merge as members. Keyed by `id`. Two things differ from every
# file above, and both are stated in FILE_POLICY in merge-json.js rather than
# inferred from the entries: the rows keep THE FILE'S order instead of being
# sorted, because the order is intent -- the merge queue reads top to bottom, and
# sorting by id would destroy it -- and each row stays on one line, so the driver
# writes the file back in the shape the lead wrote it. One record per line is also
# what keeps a text merge honest when the driver is not registered: a misaligned
# hunk can only pair whole rows, never one row's field under another row's id.
docs/work.json       merge=l2json
#
# `docs/stored-fields.json`, registered in the commit that creates it for the
# same reason. Keyed by `id` (`County+0x0C0`): an offset is unique per record, and
# the file's whole purpose is that no row may silently disappear. It is one row
# per line, because `stored_fields.rs` scans it by line -- and on the C164 merge
# the driver pretty-printed it from 274 lines to 1,617 and called the merge clean.
# FILE_POLICY in merge-json.js now states that layout, `--check` holds the file to
# it, and the driver refuses any merge that would change it.
docs/stored-fields.json merge=l2json
#
# The gate census record, one `file gate count` line per entry, sorted. `union`
# is built into git (no driver to register): two branches adding gated tests
# merge with no conflict and no edit. A line both sides changed comes out twice,
# and the census refuses the duplicate and prints the true record.
crates/l2-testkit/tests/census/gated.txt merge=union
