Repository navigation
feat(addresses): one address page per network, rendered at build time from the canonical book - #48
Conversation
…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]>
…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
left a comment
There was a problem hiding this comment.
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:resolveBookrefuses a book whose bytes' sha256 differs fromnetworks.json's pin, and one whosegenesisHashdiffers from the registry. The getCode snapshot is refused on a deployedAt, genesis or chainId mismatch. The registry needs exactly onecurrentnetwork, 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.jsonhas sha2562f92030a…dfed8andgenesisHash0xa3651a27…cdd4, which equal the r1006 entry innetworks.json. - The vendored
content/chain/address-books/r1005.json(sha2564194dcc1…337c) is byte-identical to citrate-chain maincontracts/addresses/r1005/40204.json.
- I downloaded
- r1005 page.
addresses-r1005.mdcarriesnetwork_status: archivedand 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.tomlextends 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.mjsnow flags a hand-written page that cites a retired-only address. The workflow installs withnpm 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.
resolveBookdoes not comparebook.chainIdwithnetworks.json'schainId(only the snapshot's). Add it, so a book for another chain id is refused even if someone re-pins its sha.- For r1005
genesisHashisnull, 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
left a comment
There was a problem hiding this comment.
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.jsonhas sha2562f92030a…dfed8and genesisHash0xa3651a27…cdd4, matchingnetworks.json. - The npm package:
npm pack @citratelabs/[email protected]givessrc/addresses.40204.json(exported as./40204.json) with the same sha2562f92030a…dfed8. - The archived book:
contracts/addresses/r1005/40204.jsonhas sha2564194dcc1…337c, matching the r1005 entry.
Can the generator publish a wrong book?
-
The deploy path.
prebuildrunsgen-addresses.mjswith no chain, so the deployed page is guarded by:resolveBook: the book's bytes must hash to the registry'ssha256, and itsgenesisHashmust 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 atchainPath. A book that is not the chain's book fails there, and that includes flippingcurrentbefore 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
pathslimit, so a 0x-prefixed 40-hex secret anywhere in the repo would pass. Rare, but it costs one line to scope.
P3
- Require
genesisHashfor the current network inloadRegistry. TodayresolveBookskips the genesis comparison when the registry entry hasgenesisHash: null. That is right for the archived r1005, but a current network should never be allowed to skip it. - Scope the gitleaks allowlist with
pathstocontent/chain/address-books/andcontent/chain/_generated/. - 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 notmain. - Make chain-sync a required status check on
main, if it is not already. The wrong-book guard depends on it.
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.jsonlists each network (current or archived), where its book comes from, the sha256 of the book's bytes and its block-0 hash.@citratelabs/[email protected], installed under the aliascitrate-book-r1006. It is byte-identical tocitrate-chain/contracts/addresses/40204.json(sha2562f92030a…). r1005 was retired before the package existed, so its page uses a frozen copy of the chain'scontracts/addresses/r1005/40204.json.prebuildandpredevrunscripts/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.--check --chain <dir>(thechain-syncjob) 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-lintfails a hand-written page that cites a retired network's address that the current book does not carry.2979a157to312a0c2f).At r1007 the change is one alias install (
citrate-book-r1007@npm:@citratelabs/[email protected]), one registry edit (r1007 current, r1006 archived) andnpm 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 becausescripts/lib/addresses.mjsdid not exist yet.npm test: 150 passed, 4 skipped (133 before this change).npm run typecheck,node scripts/content-lint.mjs --strictandnpm run build(prebuild generation plus every postbuild gate) are green.node scripts/gen-addresses.mjs --chain <chain origin/main> --checkandgen-precompiles --checkare green.truth-lintagainst chain main (fetch mode) is green.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