| 开发者 | ibrahimhajjaj |
|---|---|
| 更新时间 | 2026年5月12日 22:20 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 6.9 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
wp_register_ability() and want snapshot capture, audit logging, approval workflows, and one-click rollback for every invocation across REST, MCP, internal PHP, and WP-CLI without building it themselves.
Declare what state your ability touches; Tessera handles the safety wrapper.
What you get out of the box
full_content strategy.safety.requires_approval is set, the wrapper blocks execution and returns a 202 pending response. A human approves or rejects via wp-admin, WP-CLI, or REST. Multi-stage sequential or parallel approval chains are supported.wp_<N>_abilityguard_* tables, with auto-install on wp_initialize_site and auto-drop on wpmu_drop_tables.wp_register_ability( $name, [ ..., 'safety' => [...] ] ) and helpers abilityguard_rollback, abilityguard_snapshot_meta, abilityguard_snapshot_options./abilityguard/v1/log, /log/<id>, /log/export, /rollback/<id>, /rollback/bulk, /approval, /approval/<id>/approve, /approval/<id>/reject, /approval/bulk, /approval/export, /retention, /retention/prune, /health.wp abilityguard log list/show, wp abilityguard rollback <id>, wp abilityguard approval list/approve/reject <id>, wp abilityguard prune.wp_register_ability( 'my-plugin/update-product-price', array( 'label' => 'Update product price', 'description' => 'Updates the price on a WooCommerce product.', 'category' => 'woocommerce', 'input_schema' => array( /* ... */ ), 'permission_callback' => fn() => current_user_can( 'manage_woocommerce' ), 'execute_callback' => fn( $args ) => update_post_meta( $args['product_id'], '_price', $args['price'] ), 'safety' => array( 'destructive' => true, 'requires_approval' => false, 'snapshot' => fn( $input ) => array( 'post_meta' => array( $input['product_id'] => array( '_price', '_regular_price' ) ), 'options' => array( 'woocommerce_last_price_change' ), ), ), ) );
Documentation
Full plugin-author documentation lives at the GitHub repo: https://github.com/ibrahimhajjaj/abilityguard
abilityguard-mcp folder to /wp-content/plugins/.wp_register_ability() with a safety config.It will activate without registered abilities, but it only does work when other plugins register abilities with a safety config via wp_register_ability().
post_meta, options, taxonomy term assignments, user roles + caps, and files (with five tiered strategies from mtime to full content rollback).
Yes. Each subsite gets its own set of wp_<N>_abilityguard_* tables. New subsites are auto-installed via wp_initialize_site; deleted subsites have their tables dropped via wpmu_drop_tables.
Per-surface MySQL advisory locks (GET_LOCK) serialise capture + execute so simultaneous invocations do not capture each other's mid-states.
Yes. Redaction uses AES-256-GCM envelopes so rollback can still restore the original value when the encryption key is intact.
composer/installers and its unused installer adapters. Cuts the published zip from 909K to 824K and 206 files to 98.vendor/autoload.php so the plugin actually boots on a fresh install. (1.3.3 zip was missing the autoloader and fatal'd on activation.)error_log() calls in the rate-limiter and concurrency lock are now gated behind WP_DEBUG, so production hosts no longer accumulate noise from fail-open paths.readme.txt gains a Source Code section documenting the GitHub repository, the esbuild-based build pipeline, and the npm run build command used to regenerate assets/admin.js.abilityguard-mcp for the WordPress.org directory.wp-uploads/abilityguard-mcp/ instead of wp-content/abilityguard-staging/.<script>/<style> echoes.$_SERVER['REMOTE_ADDR'] is unslashed and sanitized before being hashed for IP-keyed rate-limit principals.safety.dry_run previews a destructive ability, persists the diff, auto-rolls-back, and surfaces details via /dry-run/<id> REST endpoint and abilityguard_get_dry_run_result() helper. Result returns untouched so it validates against output_schema.approval_roles) and separation-of-duties enforcement across the chain.abilityguard_retention_days_by_status./stats REST endpoint and admin dashboard widget (counts, p50/p95, top abilities).wp_before_execute_ability / wp_after_execute_ability plus an enforcement seam (abilityguard_pre_execute_decision filter) for plugin extensions.meta.annotations.destructive directly from core (WP 6.9 surface), no parallel safety metadata./health REST endpoint and a pending-approvals badge in the admin bar.log show --diff, approval show, prune --all-sites.safety.snapshot.files.strategy = 'full_content' (AES-256-GCM, content-addressed sidecar staging dir, atomic writes, 256 KB per-file cap).parent_invocation_id and an admin-side invocation chain navigator.log_meta table for extensible per-row metadata.