Skip to content

feat(scripts): clause summary, merkle progress and snapshot provenance (#652, #653, #654) - #666

Open
Justice989810 wants to merge 3 commits into
Refract-Protocol:mainfrom
Justice989810:feature/script-reporting-and-snapshot-provenance
Open

Justice989810 wants to merge 3 commits into
Refract-Protocol:mainfrom
Justice989810:feature/script-reporting-and-snapshot-provenance

Conversation

@Justice989810

@Justice989810 Justice989810 commented Nov 25, 2026 •

Copy link
Copy Markdown

Closes #652
Closes #653
Closes #654
Closes #651

Three of the four were real. #651 describes behaviour the script already has — evidence at the bottom.

#652 — a passing run says what it checked

check_clauses.py printed "all mapped to existing tests" with no count, so a green result read the same whether it had verified ninety clauses or zero. An empty or mis-pathed mapping file would have looked like success.

The summary now names the number of clauses and the documents they came from (SPEC.md and the clause mapping, as repository-relative paths). Failure behaviour is untouched.

#653 — progress while building a batch

merkle_batch.py build hashed every leaf, built the tree and wrote every proof before printing anything, so a large batch was indistinguishable from a hang.

It now reports every --progress-every leaves (1000 by default, 0 to stay silent), and again when the tree is built and when proofs are being written — the two phases after hashing that also take real time on a big batch.

Progress goes to stderr, so stdout stays the single machine-readable summary line it already was and anything parsing it is unaffected.

#654 — which node the snapshot came from

A snapshot recorded network but not the endpoint. Two fixtures of the same network can disagree because they were read from different RPC nodes with different retention or lag, and nothing in the file said so. rpc_endpoint now sits beside network.

It is redacted before it is written. Userinfo, query string and fragment are dropped, leaving scheme, host, port and path:

https://user:key@rpc.example.com:8000/soroban/rpc?api_key=secret
  ->  https://rpc.example.com:8000/soroban/rpc

These snapshots are committed as fixtures, so a private RPC's API key must not travel with one. That is the difference between recording provenance and leaking a credential.

Not solved — #651 already exits non-zero

scripts/check_links.py already fails the run on a broken link. At the end of main():

if broken_links:
    print(f"\nFound {len(broken_links)} broken link(s):")
    for src, target, reason in broken_links:
        print(f"  {src} -> {target} ({reason})")
    sys.exit(1)
else:
    ...
    sys.exit(0)

A clean run exits 0 and a broken link exits 1, which is exactly what the issue asks for.

There is a related real problem, though, and it may be what was actually seen. check_external_link treats a DNS failure as success:

if "getaddrinfo failed" in str(e.reason) or "Name or service not known" in str(e.reason):
    return True, f"Skipped (DNS/Network unavailable: {e.reason})"

In a network-isolated CI runner every external link is "Skipped", nothing lands in broken_links, and the job passes green while printing a wall of [URL] ... Skipped lines — "the report scrolls past unnoticed", precisely. That is a deliberate offline affordance rather than a bug in the exit code, so I have not changed it here. If you want it surfaced, the fix is to count the skips and either summarise them at the end or fail under a --require-network flag. Say the word and I will open that as its own issue.

A note on the batch

main was last committed on 24 October; these four issues were drafted on 24 November, and #651 describes work that was already in the tree when it was written.

Not run here: written without a build environment. python3 -m ast parses all three changed scripts, and the redaction helper was executed against the examples above, but the repo's own checks are what to apply.

A passing run printed "all mapped to existing tests" with no count, so a green
result read the same whether it had verified ninety clauses or zero — an empty
or mis-pathed mapping file would have looked like success.

The summary now gives the number of clauses and the documents they came from,
SPEC.md and the clause mapping, both as repository-relative paths.

Failure behaviour is unchanged.

Closes Refract-Protocol#652
`build` hashed every leaf, built the tree and wrote every proof before
printing anything, so a large batch looked indistinguishable from a hang.

It now reports every `--progress-every` leaves (1000 by default, 0 to stay
silent), and again when the tree is built and when proofs are being written —
the two phases after hashing that also take time on a big batch.

Progress goes to stderr, so stdout stays the single machine-readable summary
line it already was and anything parsing it is unaffected.

Closes Refract-Protocol#653
A snapshot recorded the network but not the node. Two fixtures of the same
network can disagree because they came from different RPC nodes with different
retention or lag, and nothing in the file said so.

`rpc_endpoint` now sits beside `network`. It is redacted before it is written:
userinfo, query string and fragment are dropped, leaving scheme, host, port and
path. A snapshot is committed to the repository, so the endpoint of a private
RPC must not carry its API key in with it — that is the difference between
recording provenance and leaking a credential.

Closes Refract-Protocol#654
@drips-wave

drips-wave Bot commented Nov 25, 2026

Copy link
Copy Markdown

@Justice989810 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant