Skip to content

Comments

feat: Agent Ping Confirmation Callback API#309

Open
saraichinwag wants to merge 1 commit intoExtra-Chill:mainfrom
Sarai-Chinwag:feature/agent-ping-callback
Open

feat: Agent Ping Confirmation Callback API#309
saraichinwag wants to merge 1 commit intoExtra-Chill:mainfrom
Sarai-Chinwag:feature/agent-ping-callback

Conversation

@saraichinwag
Copy link
Contributor

Implements REST endpoints for agent ping confirmation callbacks. Closes #308

Implements REST endpoints for agent ping confirmation callbacks:
- POST /datamachine/v1/agent-ping/confirm - Receive completion status
- GET /datamachine/v1/agent-ping/callback/{id} - Poll for status

Features:
- Bearer token authentication (or localhost fallback)
- Duplicate detection (idempotent callbacks)
- Action hooks for downstream processing
- Comprehensive error handling

Closes Extra-Chill#308
Copy link
Member

@chubes4 chubes4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature is needed but implementation has issues:

  1. wp_options as callback storage. Every ping creates an option (datamachine_agent_ping_callback_{id}). Options table isn't designed for high-volume transient data. No cleanup mechanism — these accumulate forever. Should use a transient with TTL, a custom table, or at minimum a scheduled cleanup.

  2. Missing \ prefix in data-machine.php: DataMachine\Api\AgentPing::register() should be \DataMachine\Api\AgentPing::register(); with leading backslash and consistent indentation.

  3. Localhost auth bypass is fragile. $_SERVER['REMOTE_ADDR'] fallback is unreliable behind proxies/Cloudflare. The x-real-ip header check is good but the $_SERVER fallback should be removed or hardened.

  4. No callback TTL/expiry. Callbacks can be confirmed days later with no rejection window. Should expire after a reasonable period (1 hour? configurable?).

  5. Formatting: Line ~248 has tabs mixed with spaces in the response array.

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.

Feature: Agent Ping Confirmation via Polling

2 participants