Commit Graph
3 Commits
Author SHA1 Message Date
Admin Bot bb7a490f5c fix(sessions): use entities query for list — hybridSearch requires project arg
CI / CI (pull_request) Successful in 2m10s
hybridSearch mandates a project scope, but sessions scatter across
per-session projects (session-<uuid>). The entities query accepts
optional project — omit it to list SESSION entities across all projects.

Also adds projectId to the list response so callers can scope follow-up
queries to the right session project.

Fixes: GET X-Service:sessions X-Resource:sessions returning 502
2026-09-28 18:43:00 +08:00
rockandAdmin Bot 50bcd19634 feat(sessions): switch writes to GraphQL upsertEntity mutation (#53)
CI / CI (push) Successful in 3m17s
Closes #52

## Summary

Migrates all session/milestone writes from REST `/memory/ingest` to GraphQL `upsertEntity` mutation — direct, typed, no LLM extraction lag.

## Changes

- **Removed**: `memoryURL` field, `defaultMemoryURL` const, `ingest()` REST helper, `"io"` import
- **Added**: `upsertEntity()` GraphQL mutation helper
- **Added**: `fetchEntitySummary()` helper — reads current entity before patch for read-modify-write
- **handlePatch**: now fetches current summary, merges patch fields, re-upserts full blob — no data loss on partial updates
- **handleCreate / handleCreateMilestone**: `json.Marshal` error now returns 500 instead of silently ignoring
- 29 tests pass, 85.4% coverage

## Mutation used

```graphql
mutation {
  upsertEntity(input: {
    project: "session-<uuid>"
    name: "<sessionID | milestoneID>"
    entityType: SESSION | MILESTONE
    summary: "{...json blob...}"
  }) { id created }
}
```

## Single upstream

All reads and writes now go through `graphqlURL` (poimen-graphql:8090). `MEMORY_UPSTREAM_URL` env var no longer read by this adapter.

---------

Co-authored-by: Admin Bot <[email protected]>
Reviewed-on: #53
2026-09-28 02:24:11 +00:00
rockandAdmin Bot a24e4f7174 feat(sessions): SessionAdapter — REST CRUD for sessions/milestones/episodes (#51)
CI / CI (push) Successful in 3m15s
Closes #50

## Changes

- `internal/sessions/handler.go` — new Handler; 7 endpoints dispatched via `X-Upstream-Path`; writes to `poimen-memory` via `/memory/ingest`; reads from `poimen-graphql` via GraphQL `hybridSearch`/`entity`
- `internal/serviceadapter/session_adapter.go` — `NewSessionAdapter()` + `GetSessionSpec()` with 5 resources
- `cmd/gateway/main.go` — register sessions adapter after memory adapter
- `internal/serviceadapter/adapters.go` — add `sessions` case to factory
- `internal/sessions/handler_test.go` — 30 tests, all pass

## Design

- `X-Service: sessions` + `X-Resource: <sessions|session|milestones|episodes|episode>`
- IDs via query params (`?session_id=`, `?episode_id=`) — dispatcher does not substitute path params
- `episode_id = sha256(session_id+milestone_id+attempt)` per §4.14 Q6
- Content JSON-encoded (injection-safe)
- `tracing.NewTransport` wired for cross-service trace propagation
- GraphQL `errors` array detected, surfaced as 502
- limit capped at 200

---------

Co-authored-by: Admin Bot <[email protected]>
Reviewed-on: #51
2026-09-28 01:53:20 +00:00