Skip to content

Add Session Message API for Agor MCP - #758

Draft
danimcgoo wants to merge 5 commits into
preset-io:mainfrom
danimcgoo:session-message-api
Draft

Add Session Message API for Agor MCP#758
danimcgoo wants to merge 5 commits into
preset-io:mainfrom
danimcgoo:session-message-api

Conversation

@danimcgoo

Copy link
Copy Markdown
Contributor

Summary

Add MCP endpoints to read session messages with worktree-scoped permissions.

Key Innovation: Worktree-scoped access control enables Agor Assistants to read results from worktrees they manage.

Changes

Design Documents

  • specs/agor-session-message-api.md - Complete API specification
  • specs/product-reasoning.md - Problem analysis and architecture
  • specs/DESIGN_REVIEW.md - Comprehensive design review
  • specs/DESIGN_REVIEW_GUIDELINES.md - Quality standards for future reviews
  • specs/REVIEW_SUMMARY.md - Quick reference

Key Design Points

Permission Model:

  • Sessions can read messages from: same session, same worktree, managed worktrees
  • Operates independently of worktree RBAC (agent coordination vs user access)
  • Single schema change: worktrees.created_by_worktree_id

Implementation Phases:

  1. Fix message_count bug (compute on read, no schema changes)
  2. Add worktree tracking schema
  3. Implement agor_messages_list endpoint
  4. Implement agor_sessions_get_result endpoint

Timeline: 5-6 days, low risk

Test Plan

  • Design review complete (status: Approved with Minor Revisions)
  • Address minor revisions (migration scripts, queued message docs)
  • Unit tests for permission logic and message counting
  • Integration tests for MCP endpoints
  • Performance testing with large message histories

Status

Design Review: Approved with Minor Revisions

Minor revisions needed:

  • Migration scripts finalized
  • Queued message behavior documented
  • Test acceptance criteria defined

🤖 Generated with Claude Code

danimcgoo and others added 5 commits March 7, 2026 15:37
Reviewed proposed Session Message API design against codebase alignment,
architecture patterns, and implementation feasibility. Key findings:

Critical issues identified:
- Permission model overengineered (descendant-based access too complex)
- Schema changes (created_by_session_id) need reconsideration
- message_count fix should use computed-on-read, not materialized
- API design has usability issues (confusing defaults, binary flags)
- Missing migration scripts, error handling specs, testing strategy

Recommendations:
- Simplify to same-session-only or user-based permissions
- Compute message_count via MessagesRepository.countBySessionId()
- Make sessionId parameter required
- Start with minimal viable implementation, validate, then iterate

Status updated to NEEDS REVISION in specs.

Files added:
- specs/DESIGN_REVIEW.md (detailed 12k word analysis)
- specs/REVIEW_SUMMARY.md (quick reference)
- specs/agor-session-message-api.md (status updated)
- specs/product-reasoning.md (review findings added)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Revised Session Message API design based on product requirement clarity:
Agor Assistants need to read results from worktrees they manage.

Key changes:
- Permission model: worktree-scoped (not session-to-session)
- Schema: single change to worktrees.created_by_worktree_id
- Cleaner semantics: "worktree creates worktree" vs mixed relationships
- No circular dependencies, stable scope

Design now approved with minor revisions:
- Migration scripts needed (SQLite + PostgreSQL)
- Queued message behavior documentation
- Error response examples
- Test acceptance criteria

Benefits over original design:
✅ Simpler (no session-to-session circular refs)
✅ All sessions in assistant worktree can access managed worktrees
✅ Heartbeats can debug their own worktree
✅ Clear mental model (worktrees manage worktrees)

Timeline: 5-6 days, risk: low

Status: APPROVED WITH MINOR REVISIONS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Capture quality standards and expectations for design documentation:

**Documentation Principles:**
- Targeted and succinct (no historical thinking or rejected alternatives)
- Complete implementation details upfront (migrations, errors, edge cases)
- Explicit integration with existing systems
- Practical examples with real numbers

**Design Quality Criteria:**
1. Choose the right abstraction (match complexity to requirements)
2. Integration over isolation (enhance existing architecture)
3. Performance by default (no "optimize later")
4. Error handling as first-class design

**Review Process:**
- Pre-review checklist (architecture, implementation, quality)
- 8 review criteria (interfaces, alignment, API, UX, errors, extensibility, complexity, completeness)
- Clear outcomes (approved, minor revisions, needs revision, redesign)

**Anti-Patterns to Avoid:**
- "Figure it out during implementation"
- "It's like X but different" (without clear integration docs)
- "Multiple ways to do the same thing"
- Schema changes without migration SQL
- Vague performance handwaving

**Spec Structure Template:**
Standard sections for consistent, complete design docs.

These guidelines codify lessons from Session Message API review
(worktree-scoped vs session-scoped, computed vs materialized, etc.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added additional review documentation:
- CRITICAL_ISSUES.md - Integration with existing RBAC system
- FINAL_DESIGN_REVIEW.md - Detailed review with RBAC considerations
- REVIEW_OUTCOME.md - Summary of review status
- Updated agor-session-message-api.md with RBAC integration notes

Key clarification: Message reading permissions operate independently
of worktree RBAC (others_can, worktree_owners). This is agent-to-agent
coordination, not user access control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removed document bloat:
- 8 redundant files → 1 clear spec
- Removed: DESIGN_REVIEW.md, product-reasoning.md, REVIEW_SUMMARY.md, etc.
- Kept: session-message-api.md (complete, succinct)

Single spec contains:
- Problem and solution
- API design (2 endpoints)
- Implementation (4 phases, 5-6 days)
- Migration SQL (SQLite + PostgreSQL)
- Error handling, testing, performance
- Integration notes (RBAC independence)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danimcgoo

danimcgoo commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

@mistercrunch - would love your feedback on this.

I'm trying to use the Agor Assistants in a meta way, have them review and assess the work they are managing to identify patterns, and reflect on how we can improve how we're working.

As we discussed in the other issue - I'm using the Agor Assistant to create the zones and prompts, and the heartbeats to move work trees through. But the Agor Assistant has no visibility of what's actually happening within the work trees other than the status. That is limiting its ability to introspect and improve.

The key complexity seems to be interactions with the existing permission model, particularly if we see the assistant as a first class entity. Is it a human proxy?

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.

1 participant