Repository navigation
feat(docs): validate network commands and environment variables in docs - #175
Senatormike001 wants to merge 2 commits into
Conversation
Add scripts/check-network-docs.ts to extract documented environment variables, connection-table passphrases/URLs and shell commands from the network guides and validate them against a canonical Stellar NETWORK_REGISTRY. Commands are only parsed with `bash -n`, never executed, so no real transaction can be sent from CI. Multi-line quoted payloads are kept as one logical command and documented placeholders are normalised before the syntax check. Wire the check into `npm test` and the snippet-check workflow, with 19 node:test cases covering the extraction, validation and reporting helpers.
|
@Senatormike001 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! 🚀 |
|
The mainnet deployment URL and passphrase block is marked NETWORK_UNDECLARED and only logged as info, so its values are never checked. Please infer the network from the guide or require STELLAR_NETWORK and fail when required values cannot be validated. |
1 similar comment
|
The mainnet deployment URL and passphrase block is marked NETWORK_UNDECLARED and only logged as info, so its values are never checked. Please infer the network from the guide or require STELLAR_NETWORK and fail when required values cannot be validated. |
Resolves merge conflicts against wraith-protocol/docs@aadf24b (7 commit(s) behind) so the PR is mergeable.
Overview
Adds an automated validator for the Stellar network guides so documented network commands and environment variables can no longer drift from the deployment registry.
scripts/check-network-docs.tsdiscovers every network guide, extracts documented environment variables, connection-table values and shell commands, then checks them against a canonical registry of Stellar passphrases and endpoints. Commands are only parsed (bash -n) and never executed, so no real transaction can be sent from CI.Related Issue
Closes #158
Changes
Network documentation validator
[ADD]
scripts/lib/network-docs.tsNETWORK_REGISTRY— canonical passphrase, Horizon, Soroban RPC and Friendbot values fortestnet,futurenetandmainnet, plusKNOWN_ENV_VARS.extractSection()— pullsKEY=valueassignments, non-assignment commands and| Property | Value |connection-table rows out of fencedbash/sh/shellblocks. Multi-line commands are kept as one logical command when they end in\or leave a quote open, so acurl -d '{ ... }'payload is not split.validateEnvNames()— errors on malformed names, warns on well-formedSTELLAR_*names outside the core registry.validateAgainstRegistry()— resolves the network declared by the surrounding block and comparesSTELLAR_NETWORK_PASSPHRASE,STELLAR_HORIZON_URLandSTELLAR_RPC_URLagainst it; also validates passphrases quoted in connection tables. Placeholders (CPLACEHOLDER_*,<YOUR_API_KEY>) are skipped.normalisePlaceholders()+checkCommandSyntax()— neutralises documented placeholders so<API_KEY>is not mistaken for a shell redirection, then syntax-checks each command through an injected checker.findConflicts()— reports the same variable documented with different values, scoped per network so testnet and mainnet guides never collide.findStaleStamps()— flags<!-- Last verified: ... -->stamps older than 120 days.looksLikeNetworkDoc(),formatFinding(),summarise()— discovery and reporting helpers.[ADD]
scripts/check-network-docs.ts.git,node_modules,.agents,.claude,assets).bashSyntaxCheck()runsbash -n -c— parse only, never execution.[ADD]
scripts/tests/network-docs.test.tsnode:testcases covering placeholder detection, extraction (including the multi-line quoted-payload case), name validation, registry mismatches, placeholder tolerance, unknown networks, conflict scoping, syntax-check wiring and stale stamps.[MODIFY]
package.jsoncheck:network-docsandtest:network-docs; the existingtestscript now also runs the network-docs check.[MODIFY]
.github/workflows/snippets.ymlVerification Results
The checker was run against the current
developtree of this repository and passes with zero errors, so it is safe to enable in CI.tsc --noEmit --strictis clean for all three new files.extractSection()+validateEnvNames()— 21 variables validated across 5 guidesvalidateAgainstRegistry()againstNETWORK_REGISTRY, including connection tablesbash -nparse-only over 21 commands; placeholders normalised firstfindConflicts()(per network) +findStaleStamps()(120-day limit)