Repository navigation
chore: add NUT spec quotes (greatspectations Layer 1) - #327
Conversation
Local test evidenceMethod: Built from PR branch, tested against mock Cashu mint + Go backend via Results:
Ready for review. |
felixfelix-bot
left a comment
There was a problem hiding this comment.
All three quotes verified verbatim against cashubtc/nuts main (NUT-00 token format, NUT-00 verification, NUT-05 melt-quote). One placement question and one process note:
-
The NUT-05 melt-quote comment sits above
TollWallet.Send(). Melt (NUT-05) is the Lightning-payment path. IfSend()is doing a P2PK transfer via swap, the relevant spec is NUT-03, not NUT-05. Can you confirmSend()actually drives a melt? If so, a one-line comment in the function body pointing at the melt call site would make the connection obvious. -
The config is only useful if something runs it. The header documents a manual
spectate checkinvocation, but there's no Makefile target or CI step. Suggest adding at minimum amake specchecktarget so it's discoverable, even if CI is added separately.
Re-tested against latest main (Jul 29)
|
felixfelix-bot feedback: NUT-05 (melt) quote was above Send(), but Send() does a NUT-03 swap, not a melt. Moved NUT-05 quote above MeltToLightning() which is the actual melt path. Added NUT-03 quote above Send() to match the swap operation.
Re: NUT-05 quote placement — fixedYou were correct: Fixed:
// NUT #03: Alice requests swapping proofs she holds for new proofs...
func (w *TollWallet) Send(...) {
// NUT #05: To request a melt quote, the wallet of Alice makes a POST /v1/melt/quote/{method}...
func (w *TollWallet) MeltToLightning(...) {Pushed. |
felixfelix-bot feedback1. Send() / NUT-05 question:
2. Not yet added. Will add in a follow-up commit: speccheck:
@greatspectations check . |
Adds make/speccheck.sh for local greatspectations spec checking. Adds docs/ai-audit/ with three AI audit prompt templates: - nut-compliance.md, security.md, dependency-drift.md Addresses felixfelix-bot review feedback requesting discoverability. Note: CI workflow changes (.github/workflows/test.yml) require workflow scope to push. Suggested additions documented in PR OpenTollGate#327 description.
Requested by @felixfelix-bot — makes the greatspectations check discoverable via standard make target.
felixfelix-bot feedback — both items addressed1. Send() / NUT-05 → NUT-03: The NUT-05 quote was moved to 2. speccheck:
@greatspectations check .@felixfelix-bot — ready for re-review. |
CI Integration (requires maintainer with workflow scope)Added Suggested additions to test.yml dep-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: src/go.mod
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Dependency sync check
run: python3 tests/contract/check-deps-sync.py
spec-drift:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install greatspectations
run: pip install git+https://github.com/rustyrussell/greatspectations.git
- name: Clone NUT specs
run: git clone --depth=1 https://github.com/cashubtc/nuts.git nuts
- name: Check spec quotes
run: spectate check --config specquotes.toml --comment-start '//' --comment-continue '//' "src/**/*.go" |
…03 above Send felixfelix-bot feedback: NUT-05 (melt) quote was above Send(), but Send() does a NUT-03 swap, not a melt. Moved NUT-05 quote above MeltToLightning() which is the actual melt path. Added NUT-03 quote above Send() to match the swap operation.
Adds make/speccheck.sh for local greatspectations spec checking. Adds docs/ai-audit/ with three AI audit prompt templates: - nut-compliance.md, security.md, dependency-drift.md Addresses felixfelix-bot review feedback requesting discoverability. Note: CI workflow changes (.github/workflows/test.yml) require workflow scope to push. Suggested additions documented in PR OpenTollGate#327 description.
49c6eaa to
7b416cd
Compare
greatspectations audit complete ✅All 9 spec quotes verified against NUT specs. What was fixed
Coverage
Total: 9 verified spec quotes across 3 files. How to run locallymake/speccheck.shInstalls greatspectations, clones NUT specs, runs check + coverage report. PR marked ready for review. |
Adds verbatim NUT spec text as comments at key code locations: - NUT #00: Token format prefix (cashu[version][token]) above extractCashuToken - NUT #00: Verification flow above tollwallet.Receive - NUT #5: Melt quote flow above tollwallet.Send Adds specquotes.toml for greatspectations CI drift detection. See: https://github.com/OpenTollGate/cashu-audit (Layer 1 framework)
…03 above Send felixfelix-bot feedback: NUT-05 (melt) quote was above Send(), but Send() does a NUT-03 swap, not a melt. Moved NUT-05 quote above MeltToLightning() which is the actual melt path. Added NUT-03 quote above Send() to match the swap operation.
- Fixed comment-start: '// ' (with space) per greatspectations requirement - Fixed speccheck.sh: correct command name + glob expansion - Fixed 6 quote texts to match NUT spec verbatim - Added blank lines between quotes and docstrings - Added 5 new NUT quotes across main.go, tollwallet.go, merchant.go All 9 quotes verified: greatspectate check exit 0.
7b416cd to
1240589
Compare
|
Cold-review items + rebuild: resolved, and the PR is now much smaller. Rebuilt from current main keeping only the quotes work — now +35/−2 across 5 files (
Quote verification history is preserved (9/9 verified, NUT-05→ |
felixfelix-bot
left a comment
There was a problem hiding this comment.
Cold review — new findings only (3 issues previously raised, not repeated).
3 minor:
-
NUT-03 quote in tollwallet.go:155 is truncated — drops the final sentence "These are then used by the wallet to generate new Proofs (see [NUT-00][00])." For a verbatim spec-quote tool, this is incomplete
-
src/main.go has unrelated gofmt alignment changes (redirect_url/auth_delay field alignment) mixed into a spec-quote PR
-
The NUT-00 verification quote is duplicated verbatim in both merchant.go:445 and tollwallet.go:119 — the greatspectations tool may flag duplicate quotes against the same spec section
All quotes verified accurate against NUT-00 through NUT-05 specs. No blockers — mergeable with follow-up if desired.
…only diff
- NUT-03 quote above TollWallet.Send gains the spec's final sentence
("These are then used by the wallet to generate new Proofs").
- The NUT-00 verification quote appeared verbatim above both
Merchant.PurchaseSession and TollWallet.Receive; keeping the
wallet-level one (verification is the mint-side swap check) and
leaving a pointer at the merchant site — duplicate quotes against
the same spec section flag in speccheck.
- Dropped the unrelated gofmt field-alignment change in main.go; the
file now matches main byte-for-byte outside the quotes (main's
existing gofmt dirt is OpenTollGate#341's scope).
Review findings: cold review 2026-08-18 (3 minors).
|
Cold-review response — all 3 minors fixed in
|
felixfelix-bot
left a comment
There was a problem hiding this comment.
Re-reviewed at 3e20040: NUT-03 quote completed, NUT-00 deduped (kept at Receive, pointer at PurchaseSession), gofmt hunks dropped — diff is quotes-only. All findings resolved. Good to merge.
Fresh gofmt pass over main after the #299/#312/#327/#342/#343/#348/ #349/#351 merge wave (the wave brought new unformatted code in its wake — scanner.go struct alignment from #312, test files across modules, config_schema.go). Includes the validator.go import regrouping from the previous round of this PR (7b124b0, originally Felix's fix): stdlib and third-party groups separated with a blank line — that file came to main via #337 carrying the misgrouping. Supersedes the pre-wave branch; rebuilt fresh from current main. gofmt -l: clean across src/. Builds + tests green in touched modules (wgm, tollgate_protocol); import-paths (117) and deps-sync (125) contract checks pass.
…post-wave main) Content-first rebuild after the merge wave made a straight rebase impossible (the tool files historically rode inside an unrelated 'SSID comment' commit; skipping it during rebase deleted them — same mislabeled-commit pathology this branch line had with the ELF binary). Rebuilt directly from the reviewed tip's content (3ca91f5) onto current main. Carries both cold-review fix rounds: unspent-only recovery (PENDING → retry-later, never double-spend), single lazily-loaded wallet per run, no proof secrets in output (also fixes the short-secret panic), dry-run recoverables counted separately — and the 30s per-mint checkstate timeout (a hung mint cannot stall recovery). Tool builds + vets clean standalone; speccheck is the exit-0-on-drift version and is functional now that specquotes.toml is on main (#327). gitignore guard for the built binary included. CHANGELOG entry added. No src/ changes — main's vendor_element_manager supersedes the old branch copy.
* chore: add NUT spec quotes (Layer 1 greatspectations adoption) Adds verbatim NUT spec text as comments at key code locations: - NUT #00: Token format prefix (cashu[version][token]) above extractCashuToken - NUT #00: Verification flow above tollwallet.Receive - NUT #5: Melt quote flow above tollwallet.Send Adds specquotes.toml for greatspectations CI drift detection. See: https://github.com/OpenTollGate/cashu-audit (Layer 1 framework) * fix(OpenTollGate#327): move NUT-05 quote to MeltToLightning, add NUT-03 above Send felixfelix-bot feedback: NUT-05 (melt) quote was above Send(), but Send() does a NUT-03 swap, not a melt. Moved NUT-05 quote above MeltToLightning() which is the actual melt path. Added NUT-03 quote above Send() to match the swap operation. * fix: verify all spec quotes pass greatspectations - Fixed comment-start: '// ' (with space) per greatspectations requirement - Fixed speccheck.sh: correct command name + glob expansion - Fixed 6 quote texts to match NUT spec verbatim - Added blank lines between quotes and docstrings - Added 5 new NUT quotes across main.go, tollwallet.go, merchant.go All 9 quotes verified: greatspectate check exit 0. * fix: spec-quote polish — complete NUT-03 quote, dedupe NUT-00, scope-only diff - NUT-03 quote above TollWallet.Send gains the spec's final sentence ("These are then used by the wallet to generate new Proofs"). - The NUT-00 verification quote appeared verbatim above both Merchant.PurchaseSession and TollWallet.Receive; keeping the wallet-level one (verification is the mint-side swap check) and leaving a pointer at the merchant site — duplicate quotes against the same spec section flag in speccheck. - Dropped the unrelated gofmt field-alignment change in main.go; the file now matches main byte-for-byte outside the quotes (main's existing gofmt dirt is OpenTollGate#341's scope). Review findings: cold review 2026-08-18 (3 minors). --------- Co-authored-by: Amperstrand <amperstrand@localhost> Co-authored-by: amperstand <atlas@oh-my-opencode.com> Co-authored-by: c03rad0r <1100745+c03rad0r@users.noreply.github.com>
What
Adds verbatim NUT specification quotes as comments at key Cashu code locations, enabling CI-enforced spec drift detection via greatspectations.
Quotes Added
main.goaboveextractCashuTokencashu[version][token]tollwallet.goaboveReceivek*hash_to_curve(x) == Ctollwallet.goaboveSendPOST /v1/melt/quote/{method}Config
specquotes.tomlconfigured for greatspectations:Context
Part of the cashu-audit framework — Layer 1 adoption. The gonuts-tollgate library already has 85 spec quotes. This adds TollGate's own Cashu handling code to the same framework.
Verification
go buildpassesgofmtclean