Skip to content

feat(cli): align energy purchase, security, and agent output - #2

Merged
mixiaowu2023 merged 12 commits into
justlend:mainfrom
BlackChar92:feat/energy-direct-purchase
Aug 28, 2026
Merged

feat(cli): align energy purchase, security, and agent output#2
mixiaowu2023 merged 12 commits into
justlend:mainfrom
BlackChar92:feat/energy-direct-purchase

Conversation

@BlackChar92

@BlackChar92 BlackChar92 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Scope

This is the single CLI PR for the coordinated open-source release. It combines energy direct purchase, security remediation, and AI readability in one review.

1. Energy direct purchase

  • add energy purchase config, quote, order, history, risk, and buy
  • use the app's trusted production endpoint by default: https://tegrow.ablesdxd.link
  • enforce the mainnet-only production-host boundary on every command, including buy --dry-run and explicit production URL overrides
  • normalize live config/quote fields and revalidate the payer, receivers, duration, payment address, and amount before signing
  • expose public payer history for in-progress and settled orders
  • return tokenless idempotent orders immediately instead of polling without credentials; retain recovery state until history confirms the payment/order

2. Security audit remediation

  • serialize payer intents and payment-risk persistence across processes
  • protect signer and recovery state with owner-only permissions and atomic replacement
  • reject redirects for credential-bearing energy requests
  • redact backend credentials and signed-payment material from normal output
  • require explicit --yes for non-interactive writes and preserve fail-closed recovery state
  • document that an ambiguous result may retain the exact signed request in the local mode-0600 risk file until reconciliation
  • refresh dependency pins; production and development audits are clean

3. AI readability

  • publish a versioned JSON success/error envelope with schemaVersion: "1.0.0"
  • provide stable error codes, retryability, remediation hints, and stdout/stderr separation
  • preserve native energy-purchase error codes and retry semantics at the process boundary
  • ship schemas/output-v1.schema.json in the v1.0.1 package
  • document command side effects, public history recovery, dry-run behavior, confirmation boundaries, and automation use

Validation

  • npm run check — typecheck, 136 tests, and build passed
  • energy regressions cover the Nile/production-host guard, public history pagination, redirect rejection, and tokenless idempotent recovery
  • live read-only production smoke — config, current price, pool health, and a 65,000-energy quote passed
  • Nile real E2E — order 98c3a0df-22ad-4090-bfd2-d09abfd23864 delivered; payment 89e9afd2…b2645 solidified; EnergyLimit +65,000; 0 unresolved risks
  • npm audit --audit-level=high — 0 vulnerabilities
  • npm pack --dry-run — v1.0.1 package includes the JSON schema

No mainnet payment was signed or broadcast during self-test.

Runtime boundary

The CLI signs the native TRX payment but never broadcasts it locally. The configured backend validates and may broadcast it. Economic limits, price, payment address, and pool capacity always come from live responses. Custom/test endpoints require explicit configuration and trust opt-in; the production endpoint is rejected with non-mainnet networks.

Coordinated rollout

Surface PR Candidate
CLI justlend-cli#2 v1.0.1
MCP mcp-server-justlend#30 v1.1.3
Skills justlend-skills#8 v1.1.1
Docs justlend-docs#102 coordinated docs

Docs may merge first. The CLI, MCP, and Skills PRs should follow in the same release window so public contracts do not remain ahead of implementation.

- add config, quote, order, history, risk, and buy commands
- require explicit trusted API config and payer-visible confirmation
- retry only the same signed payment and persist reconciliation markers
- acquire per-payer process and filesystem intent locks before signing
- fail closed on invalid risk state and require exact quote confirmation
- add regression coverage and document the hardened purchase flow
- Lock shared risk-store mutations across processes.
- Preserve independent payer records under write contention.
- align the purchase flow with the authoritative API and memo contract\n- retain ambiguous signed payments for exact replay across process restarts\n- bind network, payment recipient, and signer output before submission\n- redact order credentials and sanitize terminal output
- Observe FullNode receipts before checking SolidityNode finality
- Persist chain status without reopening ambiguous payment risks
- Expose the staged result and cover reconciliation with tests
- Protect local signer state with owner-only permissions and atomic replacement.
- Reject automatic redirects for token-bearing energy API requests.
- emit one schema-versioned envelope for successes and parser errors\n- add retry metadata, a published JSON Schema, and process-level tests\n- correct package entry points and bump the source release to 1.0.1
# Conflicts:
#	README.md
#	src/lib/output.ts
@BlackChar92 BlackChar92 changed the title feat(energy): add secure direct-purchase commands feat(cli): add secure energy purchases and stable JSON output Aug 19, 2026
@BlackChar92 BlackChar92 changed the title feat(cli): add secure energy purchases and stable JSON output feat(cli): align energy purchase, security, and agent output Aug 20, 2026
- propagate stable purchase codes, retryability, and HTTP status\n- cover structured JSON output for ambiguous payment results
- default to the app release's trusted production endpoint\n- normalize live config, quote, and purchase payload fields\n- guard non-mainnet usage and cover the production contract
- enforce the mainnet-only production host on every buy path
- recover tokenless orders through public payer history
- retain and document signed recovery state until reconciliation
- retain the signer IPC token in daemon memory\n- reject HTTP redirects by default in the shared request helper\n- stop Moolah writes when token precision cannot be verified
@mixiaowu2023
mixiaowu2023 merged commit 1390741 into justlend:main Aug 28, 2026
2 checks passed
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.

2 participants