Skip to content

docs(readme): the English README names the authoritative API list too - #318

Merged
argszero merged 1 commit into
mainfrom
docs/readme-en-authoritative-api-list
Sep 27, 2026
Merged

argszero merged 1 commit into
mainfrom
docs/readme-en-authoritative-api-list

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

README.md and README.en.md are one document in two languages — line 3 of each
declares the other as its translation. They had drifted on the sentence that says
where the API list lives.

cabe4c6 (#203, docs(architecture): correct the ops method, the transaction types
and the API list scope
) changed only the Chinese half: README.md now reads

API 一览见 docs/architecture.md,权威清单以 src/routes/mod.rs 的 router() 为准。

while README.en.md kept its pre-#203 wording (Full API reference: [docs/architecture.md](docs/architecture.md).). So the Chinese reader is sent to the
code and the English reader to a document that #203 was downgrading to an overview —
one question, two answers, from one pair of files that claim to be the same document.
git show --name-only cabe4c6 lists no README.en.md.

This PR fixes the value and gives the pair an enforcer.

Related Issue

None — found while scanning the repository's own documentation for cross-carrier
drift; the divergence is traceable to cabe4c6 and is not filed as an issue.

Changes

  • Fix the value: README.en.md now says the same thing as the Chinese half — an
    overview link plus the authoritative source in code (router() in
    src/routes/mod.rs).
  • Add src/readme_gate.rs, a test-only gate (#[cfg(test)] mod readme_gate in
    main.rs, so nothing enters the release binary): the two carriers must hold the
    same facts.
    - Compared positions are the language-independent ones only: inline code
    spans, markdown link targets, bare URLs, numeric literals. Each family is
    compared as a set; the expected value is derived from the files themselves
    on both sides — no snapshot, no hard-coded list.
    - Deliberately not compared (they legitimately differ between languages):
    prose, headings, table headers, emphasis, line order, line count.
    - Positive control: every family must be non-empty on both sides and the four
    together must yield enough items, so an extractor that returns empty sets
    cannot pass vacuously. Teeth: four synthetic arms, one fact dropped per
    family, each reported.
    - Scope, stated in the file: the gate is lexical. It proves the two sides
    carry the same structural positions; it does not prove the translation is
    faithful, and a competing fix that deletes the Chinese sentence would pass it —
    that judgement belongs to review, not to a gate.
  • No configuration / data-structure changes, so config/config.example.toml needs
    no update.

Tests

  • cargo test — 417 passed / 0 failed (baseline 413 on e567fae; +4 new tests)
  • cargo fmt --check — rc 0
  • cargo clippy --all-targets -- -D warnings — rc 0
  • New unit tests added (src/readme_gate.rs)

A/B on the gate, both legs run locally on this branch:

tree readme_gate result
README.en.md as of HEAD~1 (pre-fix) the_two_readmes_carry_the_same_facts FAILED — exactly 2 divergences, both named: `router()` and `src/routes/mod.rs` 仅中文版有; the other 3 gate tests stay green
this branch 4 passed / 0 failed

Checklist

  • Branch naming follows the convention (docs/…)
  • Commit message uses Conventional Commits (docs(readme): …)
  • Single responsibility, minimal diff (3 files, +299/−1; the one-line value fix
    plus one new test-only module and its registration)

`cabe4c6` (#203) changed only the Chinese half of the sentence that says where
the API list lives: `README.md` now reads "API 一览见 docs/architecture.md,
权威清单以 `src/routes/mod.rs` 的 `router()` 为准", while `README.en.md` kept
its pre-#203 wording ("Full API reference: docs/architecture.md."). That sends
the English reader to a document #203 was downgrading to an overview, and the
Chinese reader to the code — two answers to one question, from one document
whose two halves declare each other as translations on line 3.

Fix the value and give the pair an enforcer:

- `README.en.md`: say the same thing as the Chinese half — an overview link
  plus the authoritative source in code (`router()` in `src/routes/mod.rs`).
- `src/readme_gate.rs` (test-only, `#[cfg(test)] mod readme_gate`): assert the
  two carriers hold the same facts. The compared positions are the
  language-independent ones only — inline code spans, markdown link targets,
  bare URLs, numeric literals — compared as sets, with the expected value
  derived from the files on both sides (no snapshot). Prose, headings, table
  headers, emphasis, line order and line count are deliberately not compared.
  Positive control: every family must be non-empty on both sides and the four
  together must yield enough items, so an extractor that returns empty sets
  cannot pass vacuously. Teeth: a fact dropped on one side is reported for each
  of the four families.

Scope, stated where the gate is: it is lexical — it proves the two sides carry
the same structural positions, not that the translation is faithful, and a
"delete the Chinese sentence instead" fix would pass it.

`cargo test`: 417 passed / 0 failed (baseline 413; +4 new).
@argszero

Copy link
Copy Markdown
Owner Author

Self-review (author is also the committer on this repo; allow_self_merge is on, so
GitHub will not accept an approving review from me — recording the review here instead).

Checked, in order:

  1. The pair really is the only one. git ls-files | grep -iE '\.en\.|\.zh\.' returns
    exactly README.en.md, and README.md / README.en.md are both 80 lines and link each
    other on line 3. No other document in the repo has a language twin, so the gate's corpus is
    the whole family — not a sample of it.

  2. The divergence is drift, not a choice. git log -1 -S'权威清单以' -- README.md → cabe4c6
    (docs(architecture): correct the ops method, the transaction types and the API list scope #203); git show --name-only cabe4c6 lists README.md and docs/architecture.md and no
    README.en.md. Pre-docs(architecture): correct the ops method, the transaction types and the API list scope #203 the two halves were aligned ("API 全清单见 …" ↔ "Full API
    reference: …"), so docs(architecture): correct the ops method, the transaction types and the API list scope #203 changed one side of a pair. The English file has never carried the
    authoritative-list sentence.

  3. The fix says the same thing, not the same words. The new English clause keeps the
    overview link and names the authoritative source in code (`router()` in
    `src/routes/mod.rs`) — the two positions the Chinese half adds. It is not a literal
    translation and does not need to be.

  4. The gate's expected value is derived. No list of tokens is written down: both sides are
    extracted from the files, and equality between the two extractions is the assertion. Only
    the language-independent families are compared (inline code, link targets, bare URLs,
    numeric literals); prose, headings, emphasis and line order are excluded by construction.
    A reviewer can therefore change either README freely as long as it stays the same document.

  5. It can't pass vacuously. Four families must each be non-empty on both sides, and the
    four together must yield at least 30 items per file (today 64 across the pair) — an
    extractor that returns empty sets is caught. The four synthetic arms drop one fact per
    family and each is reported.

  6. A/B on the pre-fix tree. Reverting only README.en.md to HEAD~1 makes exactly one
    test fail — the_two_readmes_carry_the_same_facts — naming exactly the two spans
    (`router()`, `src/routes/mod.rs`); the other three gate tests stay green. So the
    gate discriminates on this axis and not on the new code's mere presence.

  7. CI: test / fmt / clippy pass (1m33s), msrv pass (29s) — the msrv job only builds, and
    the new module is #[cfg(test)], so it adds nothing to the release binary or to the
    declared-1.86 build.

Scope, restated so it is not over-read: the gate is lexical. It proves the two carriers
carry the same structural positions; it does not prove the translation is faithful, and a
competing fix that deletes the Chinese sentence would pass it. That is a reviewer's call, not
a gate's — and it is written into src/readme_gate.rs itself.

@argszero
argszero merged commit ad7cce8 into main Sep 27, 2026
2 checks passed
@argszero
argszero deleted the docs/readme-en-authoritative-api-list branch September 27, 2026 23:42
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.

1 participant