Skip to content

refactor(ledger): extract korg-ledger — publishable single-source spec crate#2

Merged
New1Direction merged 1 commit into
mainfrom
feat/korg-ledger-crate
Jun 4, 2026
Merged

refactor(ledger): extract korg-ledger — publishable single-source spec crate#2
New1Direction merged 1 commit into
mainfrom
feat/korg-ledger-crate

Conversation

@New1Direction

Copy link
Copy Markdown
Owner

Why

To ship the verifier as a clean cargo install korg-verify, korg-verify can't depend on the internal korg-registry path crate. It only uses one thing from it — ledger_chain (240 lines). So I extracted those chain primitives into their own standalone, publishable crate, korg-ledger, which is also the natural home for the korg-ledger@v1 spec implementation.

This avoids both bad alternatives: vendoring a 2nd copy of the hash code (drift risk), and publishing the entire internal runtime (korg-core/korg-registry) to crates.io.

Changes

  • New crate crates/korg-ledgercanonicalize / chain_hash / verify_chain / verify_dag + GENESIS_HASH. Deps: serde_json, sha2, hmac only. The code moved verbatim (byte-identical, same SHA) so conformance is unchanged.
  • korg-registry::ledger_chain is now a re-export of korg-ledger (pub use korg_ledger::*;). Every crate::ledger_chain::… caller (e.g. log.rs) is untouched — single source of truth, no duplication.
  • korg-verify now depends on korg-ledger (one import swap). Its only internal path dep is gone → publishable standalone.
  • Workspace members + Cargo.lock updated.

Test plan

  • korg-ledger 3, korg-registry 23, korg-verify 15 (4 lib + 5 frozen conformance vectors + 6 receipt) — all pass
  • clippy clean (0) on korg-ledger + korg-verify; fmt clean
  • cargo publish --dry-run -p korg-ledgerPackaged + Verified green
  • korg-verify dry-run correctly blocks on "no matching package korg-ledger" — confirms publish order

Publish (needs a crates.io token)

cargo publish -p korg-ledger      # first — self-contained
# wait for it to be live on crates.io, then:
cargo publish -p korg-verify      # now resolves korg-ledger

Then the launch command becomes cargo install korg-verify.

…spec crate

Move the korg-ledger@v1 hash-chain primitives (canonicalize / chain_hash /
verify_chain / verify_dag) out of korg-registry into a new standalone crate,
korg-ledger — so the verifier publishes to crates.io as a clean
`cargo install korg-verify`, and the spec implementation has one home rather than
a copy per consumer.

- New crate crates/korg-ledger (deps: serde_json, sha2, hmac only). The chain code
  moved verbatim — byte-identical (same SHA) — so conformance is unchanged.
- korg-registry::ledger_chain is now a re-export of korg-ledger, so every
  `crate::ledger_chain::…` path (log.rs et al.) is untouched. Single source of
  truth, no duplicated implementation to drift.
- korg-verify depends on korg-ledger instead of korg-registry (one import). Severs
  its only path dep on the internal runtime → publishable standalone.

Tests: korg-ledger 3, korg-registry 23, korg-verify 15 (incl. the 5 frozen
conformance vectors + 6 receipt tests) all pass. clippy clean, fmt clean.
`cargo publish --dry-run -p korg-ledger` packages + verifies green.

Publish order (needs a crates.io token): korg-ledger first, then korg-verify.
@New1Direction New1Direction merged commit b91bb50 into main Jun 4, 2026
1 of 2 checks passed
@New1Direction New1Direction deleted the feat/korg-ledger-crate branch June 4, 2026 15:30
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