examples: add JSON config for payment guard service#148
Conversation
Closes #147 - Add payment_guard_service_config.json with service, audit, mode, require_signed_intent and policy/audit path fields - Update payment_guard_service.py to load --config at startup; config mode is default, request body mode overrides it; require_signed_intent strictness from config is merged with per-request strict_mode (strictest wins); audit limits come from config instead of hardcoded values; invalid config fails fast with a clear error message - Update run_service_check.sh to start service with --config - Update docs/agent-payment-guard-service.md with config startup example and field descriptions
|
PR direction is good and close to merge-ready. The main shape matches #147: JSON config, fail-fast validation, request mode override, config-driven limits, config-based service startup, and no new dependencies. Before merge, please fix these small gaps:
Please add one request without A valid proposal + valid envelope case is enough.
The config sets: "require_signed_intent": truePlease add one request with a valid proposal but without This proves config strictness, not just mode behavior.
Please test at least: If you want to keep it minimal, the clamp test is enough, but invalid-limit coverage would be better.
The code currently says: # Legacy CLI overrides kept for backwards compatibility; config takes precedencebut the actual behavior is that explicit CLI flags override config. Please change it to something like: # Legacy CLI overrides kept for backwards compatibility; explicit CLI flags override config.After these fixes, #148 should be merge-ready. Keep the non-goal boundary as-is: JSON only, no YAML dependency, no wallets, no SDKs, no RPC, no token transfers, no custody, no JWS, no EIP-712. |
- Fix misleading comments in payment_guard_service.py: explicit CLI flags override config (precedence: defaults < config < CLI flags) - Add test: request without 'mode' uses config.mode (enforce) - Add test: require_signed_intent=true blocks valid proposal without envelope -> BLOCK / MISSING_INTENT_ENVELOPE - Add test: audit limit=999 clamped to max (100 from config) - Add test: audit limit=abc returns 400 with JSON error body - Update final audit records count from 4 to 6
Closes #147
What
Makes Agent Payment Guard HTTP service configurable via a JSON config file instead of relying only on CLI defaults.
Changes
New file
examples/agent-payment-guard/payment_guard_service_config.json— config withmode,require_signed_intent,policy_path,audit_path,service.{host,port},audit.{hash_chain, recent_records_default_limit, recent_records_max_limit}Updated files
examples/agent-payment-guard/payment_guard_service.py--config PATHargument; loads and validates config at startup, fails fast on invalid config with a clear errormodeoverrides config mode per-request; omittingmodeusesconfig.moderequire_signed_intent: truein config merges with per-request strict mode — strictest wins → returnsBLOCK / MISSING_INTENT_ENVELOPEwhen envelope absentdefault_limit,max_limit) come from config;GET /v1/audit/recordsclamps and validateslimitquery param deterministically--host,--port,--policy,--audit-path) still work and override config when both providedexamples/agent-payment-guard/run_service_check.sh--configflag; all existing checks (health, enforce ACCEPT, shadow BLOCK, enforce HOLD, shadow HOLD, audit records, hash-chain) still passdocs/agent-payment-guard-service.mdNon-goals (not added)
No YAML, no real wallets, no token transfers, no private keys, no payment SDKs, no RPC, no smart contracts, no KYC/AML, no JWS/EIP-712.
Validation