Skip to content

feat(addresses): one address page per network, rendered at build time from the canonical book - #48

Merged
SaulBuilds merged 2 commits into
mainfrom
docs/addresses-per-network
Nov 11, 2026
Merged

SaulBuilds merged 2 commits into
mainfrom
docs/addresses-per-network

Conversation

@SaulBuilds

Copy link
Copy Markdown
Contributor

Why

docs.citrate.ai/chain/addresses still serves the r1005 book (85 r1005-only addresses on the live page, checked 2026-11-11 08:08Z), although citrate-chain main moved its root book to r1006 at 312a0c2f (#454). The page was a committed copy that someone had to regenerate by hand after each new genesis. r1007 moves the block-0 addresses that embed rotated keys and every one of the 28 post-genesis addresses, so this has to become mechanical before the cut. Plan of record: fed ops/r1007-ceremony/ADDRESS_PROPAGATION.md.

What

  • content/chain/networks.json lists each network (current or archived), where its book comes from, the sha256 of the book's bytes and its block-0 hash.
  • The current network's book is the published @citratelabs/[email protected], installed under the alias citrate-book-r1006. It is byte-identical to citrate-chain/contracts/addresses/40204.json (sha256 2f92030a…). r1005 was retired before the package existed, so its page uses a frozen copy of the chain's contracts/addresses/r1005/40204.json.
  • prebuild and predev run scripts/gen-addresses.mjs, so the deployed pages always come from the pinned books. Pages:
    • /chain/addresses: the current network (the stable URL);
    • /chain/addresses/r1006;
    • /chain/addresses/r1005, which carries a retired-network banner and a do-not-send warning.
  • The generator refuses a book whose bytes or genesis hash differ from the registry, and a getCode snapshot taken for another book.
  • --check --chain <dir> (the chain-sync job) now also fails when a registered book or snapshot differs from the chain's copy. When r1007 lands on chain main, the job turns red until the registry follows.
  • truth-lint fails a hand-written page that cites a retired network's address that the current book does not carry.
  • The precompile page is regenerated against chain main. Only its commit line changed (2979a157 to 312a0c2f).

At r1007 the change is one alias install (citrate-book-r1007@npm:@citratelabs/[email protected]), one registry edit (r1007 current, r1006 archived) and npm run docs:addresses -- --sync --chain ../citrate-chain (see the README, "Chain-generated pages").

Tests

  • test/gen-addresses.test.ts: 17 new tests, written first. The red run failed because scripts/lib/addresses.mjs did not exist yet.
  • npm test: 150 passed, 4 skipped (133 before this change).
  • npm run typecheck, node scripts/content-lint.mjs --strict and npm run build (prebuild generation plus every postbuild gate) are green.
  • node scripts/gen-addresses.mjs --chain <chain origin/main> --check and gen-precompiles --check are green.
  • truth-lint against chain main (fetch mode) is green.
  • The local pre-push gate passed after the local citrate-chain checkout was fast-forwarded to origin/main.

Deploy

Not deployed. Merging to main triggers the Vercel production build of citrate-atlas, which serves docs.citrate.ai. That build moves the live page from r1005 to r1006.

🤖 Generated with Claude Code

…al book at build time

The contract-address page was a committed copy that needed a hand-run regeneration
after every new genesis; docs.citrate.ai still served the r1005 book after the chain
moved to r1006. Now:

- content/chain/networks.json registers each network (current or archived), where its
  book comes from, the sha256 of the book's bytes and its block-0 hash.
- The current network's book comes from the published @citratelabs/chain-config
  release under an npm alias (citrate-book-r1006 = 0.2.0, byte-identical to
  citrate-chain contracts/addresses/40204.json). r1005, retired before the package
  existed, is a frozen copy of the chain's archived book.
- prebuild and predev run scripts/gen-addresses.mjs, so the deployed pages always come
  from the pinned books: /chain/addresses (current), /chain/addresses/r1006 and
  /chain/addresses/r1005 (marked retired, with a do-not-send banner).
- The generator refuses a book whose bytes or genesis hash differ from the registry,
  and a getCode snapshot taken for another book.
- --check with a chain checkout also fails when a registered book or snapshot differs
  from the chain's copy, so a new genesis on chain main turns chain-sync red.
- truth-lint fails a hand-written page that cites an address of a retired network
  that the current book does not carry.
- Regenerated the precompile page against chain main (312a0c2f; commit line only).

Tests: test/gen-addresses.test.ts, 17 new (red first: the module did not exist).
npm test 150 passed, 4 skipped; typecheck, content-lint --strict, npm run build green.

Signed-off-by: Larry Klosowski <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@SaulBuilds
SaulBuilds requested a review from a team as a code owner November 11, 2026 08:21
…M addresses

- chain-sync-check: the address pages now come from the @citratelabs/chain-config
  releases installed under npm aliases, so the job runs `npm ci --ignore-scripts`
  before gen-addresses --check (it failed with "Cannot find module
  citrate-book-r1006/40204.json").
- .gitleaks.toml: the default ruleset plus the same exact-value allowlist as
  citrate-chain. The archived r1005 book lists public addresses under names such as
  "ModelAccessControl", which generic-api-key misreads as credentials. Only a value
  that is exactly 0x + 40 hex is allowed; every other format is still reported.
  `gitleaks git --log-opts origin/main..HEAD`: no leaks found.

Signed-off-by: Larry Klosowski <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@Matr0xshka Matr0xshka left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MAC independent reviewer agent, not Codex, not DGX. Reviewed head 4fe711d.

Verdict: approve, no P1 or P2. CI is green: build, ci, chain-sync, check, secret-scan, guardrail and CodeQL.

What I checked.

  • scripts/lib/addresses.mjs: resolveBook refuses a book whose bytes' sha256 differs from networks.json's pin, and one whose genesisHash differs from the registry. The getCode snapshot is refused on a deployedAt, genesis or chainId mismatch. The registry needs exactly one current network, which must come from the published package. Nothing reaches the network.
  • Pins verified independently.
    • I downloaded @citratelabs/[email protected] from the npm registry. src/addresses.40204.json has sha256 2f92030a…dfed8 and genesisHash 0xa3651a27…cdd4, which equal the r1006 entry in networks.json.
    • The vendored content/chain/address-books/r1005.json (sha256 4194dcc1…337c) is byte-identical to citrate-chain main contracts/addresses/r1005/40204.json.
  • r1005 page. addresses-r1005.md carries network_status: archived and the "Retired network. … retired 2026-11-10 … Do not send to them on the live chain" banner, and says the live RPC no longer serves r1005.
  • Secret-scan exception is narrow. .gitleaks.toml extends the default ruleset with one allowlist entry, regexTarget = "secret", ^0x[0-9a-fA-F]{40}$. It is anchored, exactly 40 hex, and a 64-hex private key or any token still matches. It is the same as citrate-chain's.
  • truth-lint.mjs now flags a hand-written page that cites a retired-only address. The workflow installs with npm ci --ignore-scripts.

P3:

  • "Checksum" here is the book's sha256, not EIP-55. If the pages are meant to be copy-safe, render addresses in EIP-55 form (the book is lowercase). A reader pasting into a wallet then gets checksum protection.
  • resolveBook does not compare book.chainId with networks.json's chainId (only the snapshot's). Add it, so a book for another chain id is refused even if someone re-pins its sha.
  • For r1005 genesisHash is null, so the genesis check is skipped and only the sha256 pin protects it. That is acceptable for a frozen archive. If the hash is known, fill it.

@BerryManifold BerryManifold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAC independent reviewer agent, not Codex, not DGX. Reviewed head 4fe711d.

Verdict: approve. No P1 or P2; P3s below. CI is green: guardrail, check, chain-sync, build, secret-scan, ci and CodeQL. The PR is BLOCKED only on the required review.

Pins verified independently:

  • The live book: citrate-chain main contracts/addresses/40204.json has sha256 2f92030a…dfed8 and genesisHash 0xa3651a27…cdd4, matching networks.json.
  • The npm package: npm pack @citratelabs/[email protected] gives src/addresses.40204.json (exported as ./40204.json) with the same sha256 2f92030a…dfed8.
  • The archived book: contracts/addresses/r1005/40204.json has sha256 4194dcc1…337c, matching the r1005 entry.

Can the generator publish a wrong book?

  • The deploy path. prebuild runs gen-addresses.mjs with no chain, so the deployed page is guarded by:

    • resolveBook: the book's bytes must hash to the registry's sha256, and its genesisHash must equal the registry's;
    • the getCode snapshot: it must be for the same book (deployedAt), genesis and chain;
    • loadRegistry: exactly one current network, which must come from the published package;
    • the npm lockfile integrity hash.

    A wrong book therefore needs a PR that changes both the registry and the alias consistently.

  • The chain cross-check. That PR is caught by --check --chain (the chain-sync job), which compares every registered book and snapshot against the chain's copy at chainPath. A book that is not the chain's book fails there, and that includes flipping current before chain main moves. The guard holds as long as chain-sync is required for merge; I could not read the branch protection to confirm that.

Is the secret-scan exception too wide? Narrow in content, global in scope (P3).

  • What it allows. The allowlist only allows a detected secret whose whole value is ^0x[0-9a-fA-F]{40}$, which is an EVM address. Private keys (64 hex), tokens and every other format are still reported, and it matches citrate-chain's.
  • Where it applies. It has no paths limit, so a 0x-prefixed 40-hex secret anywhere in the repo would pass. Rare, but it costs one line to scope.

P3

  1. Require genesisHash for the current network in loadRegistry. Today resolveBook skips the genesis comparison when the registry entry has genesisHash: null. That is right for the archived r1005, but a current network should never be allowed to skip it.
  2. Scope the gitleaks allowlist with paths to content/chain/address-books/ and content/chain/_generated/.
  3. The chain-sync job honours CITRATE_CHAIN_REF. If that repo variable is left pinned to an old genesis commit after a reroll (the README tells operators to set it), the cross-check compares against a stale chain and a stale book passes. Have the job print the chain ref and its root book's genesis, and warn when the ref is not main.
  4. Make chain-sync a required status check on main, if it is not already. The wrong-book guard depends on it.

@SaulBuilds
SaulBuilds merged commit 3f1a1f6 into main Nov 11, 2026
10 checks passed
@SaulBuilds
SaulBuilds deleted the docs/addresses-per-network branch November 11, 2026 18:27
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