Skip to content

fix(agent): match the Python agent in rules refresh, key stamp and stats - #37

Merged
rennf93 merged 1 commit into
mainfrom
fix/agent-parity
Oct 15, 2026
Merged

rennf93 merged 1 commit into
mainfrom
fix/agent-parity

Conversation

@rennf93

@rennf93 rennf93 commented Oct 15, 2026

Copy link
Copy Markdown
Member

Closes #36

I audited guard-agent-php against the Python agent (guard-agent 3.2.4) and fixed every divergence I could reproduce. Each behavior change has a test in bin/test_agent.php (section "reference parity") that failed on main first.

  • start() schedules the rules refresh only when projectId is set (null or empty means none), like client.py:128-129.
  • Persistence keys use a wall-clock epoch nanosecond stamp at microsecond resolution, like time.time_ns() in _buffer_redis.py:54. Reload keeps the reference semantics (keys walked in the order Redis returns them, no sort), and AGENTS.md no longer claims oldest-first.
  • EventBuffer::getStats() gains autoFlushRunning (always false, PHP has no background auto-flush), so the stats key set equals the reference set. The arrays are host-facing only and not serialized anywhere, so I kept camelCase and documented the mapping.
  • Docs: AGENTS.md and CLAUDE.md (identical copies) now state the real version (3.2.4, untagged), the guard-agent-php/ User-Agent, the encryption onError stage, that the Python, TS and Rust agents also sign the uncompressed body, and that persistence at flush, tick or shutdown is a documented deviation from the reference. README and docs/usage.md are corrected the same way.

I did not change the persistence deferral (approved in #33). I did not touch CHANGELOG.md because release prep owns it.

I ran the php -l sweep, composer validate --strict, bin/test_agent.php against Redis (663 passed), bin/test_shutdown.php (9 passed), the coverage runner (100% reachable lines, no waiver line shifted because the edits keep the line numbers above them) and composer audit --locked, on PHP 8.5 locally.

@github-actions github-actions Bot added documentation Docs site, README, governance files area: core Touches the agent lifecycle, config, or buffers tests Test suite changes labels Oct 15, 2026
@rennf93
rennf93 merged commit 6f1ee58 into main Oct 15, 2026
15 checks passed
@rennf93
rennf93 deleted the fix/agent-parity branch October 15, 2026 13:26
rennf93 added a commit that referenced this pull request Oct 15, 2026
The version is already 3.2.4 and no v3.2.4 tag exists, so the fixes merged in #37 go into the same section.

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Touches the agent lifecycle, config, or buffers documentation Docs site, README, governance files tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parity gaps against the Python agent (rules refresh, key stamp, stats, docs)

1 participant