Merged
Conversation
Eliminates the Python agent entirely (claude-agent-sdk, psycopg2, MCP server) in favour of spawning `claude -p` directly from Rails jobs. Claude uses curl via Bash to call Rails API read/write endpoints, and WebFetch (restricted to canada.ca / gc.ca / parl.ca) for government pages. Key changes: - Delete agent/src/ and pyproject.toml - Add GET read endpoints: /api/agent/commitments, /api/agent/bills, /api/agent/entries (with full detail and list/filter support) - Add PATCH /api/agent/commitments/:id/touch_assessed and /api/agent/entries/:id/mark_processed for Stop hooks - Migration: add agent_processed_at to entries - AgentEvaluateCommitmentJob + AgentProcessEntryJob rewritten to spawn claude -p with streamed output, per-job Stop hooks, and explicit RAILS_MASTER_KEY unset - agent/.claude/hooks/on_stop_commitment.sh and on_stop_entry.sh guarantee last_assessed_at + agent_processed_at are updated even if the agent skips record_evaluation_run - agent/CLAUDE.md rewritten as curl-based API reference - CORS: allow all localhost origins for development - Dockerfiles: install claude CLI binary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Auto-correct 226 offenses: trailing commas in hash literals and spacing inside array literal brackets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The bin/brakeman script uses --ensure-latest which fails CI when the installed version is behind the latest release. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agent/src/,pyproject.toml,claude-agent-sdk,psycopg2, and the in-process MCP serverclaude -pdirectly; Claude reads data viacurlto new Rails GET endpoints and writes via existing endpointsWebFetchrestricted to*.canada.ca,*.gc.ca,www.parl.caWhat changed
New Rails API (read endpoints):
GET /api/agent/commitments/:id— full commitment with criteria, matches, events, bills, departments, status_changesGET /api/agent/commitments— list with filters (status, policy_area, stale_days, limit)GET /api/agent/commitments/:id/sourcesGET /api/agent/bills/:id+GET /api/agent/billsGET /api/agent/entries/:id+GET /api/agent/entries?unprocessed=trueNew tracking endpoints (called by Stop hooks):
PATCH /api/agent/commitments/:id/touch_assessed— updateslast_assessed_at; skips if a recentevaluation_runalready existsPATCH /api/agent/entries/:id/mark_processed— setsagent_processed_at; idempotentStop hooks (
agent/.claude/hooks/):on_stop_commitment.sh— fires after every commitment evaluation runon_stop_entry.sh— fires after every entry processing run--settingsJSON, so each job type only loads its own scriptJobs:
claude -poutput to stderr in real time viapopen2eCLAUDE_CODE_OAUTH_TOKENfor auth; explicitly unsetRAILS_MASTER_KEYandSECRET_KEY_BASE--settingsOther:
add_column :entries, :agent_processed_at, :datetimelocalhost:*origins in developmentclaudeCLI binaryTest plan
bundle exec rails db:migrateGET /api/agent/commitments/1returns expected shapeAgentEvaluateCommitmentJoband confirmlast_assessed_atupdatesAgentProcessEntryJoband confirmagent_processed_atis set🤖 Generated with Claude Code