feat: add Jungian Intelligence Layer service v3.2.0#5
Conversation
Add JungianService with 5 methods: SearchWithContext, GetIndividuationScore, GetIndividuationHistory, GetSynchronicityPatterns, GetDreamHistory. Includes 6 new types for archetypes, individuation, synchronicity, and dream consolidation.
Reviewer's GuideIntroduces a new JungianService on the API client to access the Jungian Intelligence Layer, adding supporting response types and wiring five new methods to specific Jungian-related backend endpoints. Sequence diagram for JungianService.SearchWithContext request flowsequenceDiagram
actor Caller
participant JungianService
participant Client
participant HTTPClient
participant JungianAPI
Caller->>JungianService: SearchWithContext(ctx, query, toolName, outcome)
JungianService->>JungianService: build body map
JungianService->>Client: post(ctx, /api/memory/archetype/inject, body, &result)
Client->>HTTPClient: POST /api/memory/archetype/inject
HTTPClient->>JungianAPI: HTTP POST request
JungianAPI-->>HTTPClient: JSON ArchetypeSearchResponse
HTTPClient-->>Client: HTTP response
Client-->>JungianService: unmarshal into result, return error
JungianService-->>Caller: *ArchetypeSearchResponse, error
Class diagram for JungianService and related response typesclassDiagram
class Client {
+JungianService Jungian
}
class JungianService {
-Client client
+SearchWithContext(ctx context.Context, query string, toolName string, outcome string) ArchetypeSearchResponse, error
+GetIndividuationScore(ctx context.Context) IndividuationResponse, error
+GetIndividuationHistory(ctx context.Context, days int) IndividuationResponse[], error
+GetSynchronicityPatterns(ctx context.Context) SynchronicityPattern[], error
+GetDreamHistory(ctx context.Context) DreamConsolidation[], error
}
class IndividuationComponents {
+int MemoryDepth
+int LearningVelocity
+int CollectiveContribution
+int SelfAwareness
}
class IndividuationResponse {
+int Total
+string Level
+string WeeklyTrend
+string Tip
+IndividuationComponents Components
}
class ArchetypedPattern {
+string UUID
+string Archetype
+string ArchetypeLabel
+float ArchetypeWeight
+string PatternType
+string Description
+string Pattern
+float Confidence
+float Similarity
}
class ArchetypeSearchResponse {
+ArchetypedPattern[] Patterns
}
class SynchronicityPattern {
+string UUID
+string PatternType
+string Description
+float Confidence
+int UniqueProfiles
}
class DreamConsolidation {
+string UUID
+int SourceCount
+int TokenSavings
+float ClusterSimilarity
+string CreatedAt
}
Client --> JungianService : has
JungianService --> ArchetypeSearchResponse : uses
JungianService --> IndividuationResponse : uses
JungianService --> SynchronicityPattern : uses
JungianService --> DreamConsolidation : uses
IndividuationResponse --> IndividuationComponents : has
ArchetypeSearchResponse --> ArchetypedPattern : has
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new "Jungian Intelligence Layer" service to the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The JungianService methods mix pointer and value returns (e.g., *IndividuationResponse vs []IndividuationResponse); consider standardizing the return types across the service for a more consistent and predictable API surface.
- In GetIndividuationHistory, consider validating the days argument (e.g., enforcing a minimum of 1 and reasonable upper bound) before constructing the request to avoid sending obviously invalid values to the API.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The JungianService methods mix pointer and value returns (e.g., *IndividuationResponse vs []IndividuationResponse); consider standardizing the return types across the service for a more consistent and predictable API surface.
- In GetIndividuationHistory, consider validating the days argument (e.g., enforcing a minimum of 1 and reasonable upper bound) before constructing the request to avoid sending obviously invalid values to the API.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request introduces a new JungianService to the Go client, exposing several new API endpoints related to the Jungian Intelligence Layer. The implementation includes the service definition, methods for API interaction, and corresponding data types. The changes are well-structured and follow the existing patterns in the client. I've provided a few suggestions to improve type safety, consistency, and adherence to Go idioms.
| body := map[string]interface{}{ | ||
| "query": query, | ||
| "tool_name": toolName, | ||
| "outcome": outcome, | ||
| } |
There was a problem hiding this comment.
For improved type safety and readability, consider using a struct for the request body instead of map[string]interface{}. This makes the request structure explicit and less error-prone. You could use an anonymous struct here:
body := struct {
Query string `json:"query"`
ToolName string `json:"tool_name"`
Outcome string `json:"outcome"`
}{
Query: query,
ToolName: toolName,
Outcome: outcome,
}| func (s *JungianService) GetIndividuationHistory(ctx context.Context, days int) ([]IndividuationResponse, error) { | ||
| params := url.Values{} | ||
| params.Set("history", "true") | ||
| params.Set("days", fmt.Sprintf("%d", days)) |
There was a problem hiding this comment.
| SourceCount int `json:"sourceCount"` | ||
| TokenSavings int `json:"tokenSavings"` | ||
| ClusterSimilarity float64 `json:"clusterSimilarity"` | ||
| CreatedAt string `json:"createdAt"` |
There was a problem hiding this comment.
The CreatedAt field is of type string, while other structs in this file (like Document, SearchResult, ClipboardEntry) use time.Time for timestamp fields. To maintain consistency and leverage Go's type system for time-related operations, it's recommended to use time.Time here as well. The encoding/json package can automatically parse RFC3339 formatted date strings into time.Time fields.
| CreatedAt string `json:"createdAt"` | |
| CreatedAt time.Time `json:"createdAt"` |
Code Review: feat: add Jungian Intelligence Layer service v3.2.0The PR follows existing codebase patterns well overall, but there are a few issues worth addressing — one of which is a bug that also exists in 🐛 Bug: Query parameters mangled in URL construction
path := fmt.Sprintf("/api/memory/individuation?%s", params.Encode())
err := s.client.get(ctx, path, &result)In u, err := url.Parse(c.baseURL)
u.Path = path // path now contains "?history=true&days=30"Assigning a string that contains The fix is to keep the path and query string separate. Either enhance
|
| Severity | Issue |
|---|---|
| 🐛 Bug | Query params percent-encoded in URL path — GetIndividuationHistory cannot work correctly |
&zero-value, err return on error is inconsistent and can mask caller bugs |
|
No validation of days parameter |
|
| 🔍 Minor | DreamConsolidation.CreatedAt should be time.Time |
| 🔍 Minor | Use strconv.Itoa instead of fmt.Sprintf("%d", ...) |
| 🔍 Minor | Struct field alignment (run gofmt) |
| 📋 Info | No tests (existing repo gap — follow-up suggested) |
The URL bug is the critical fix needed before merging — everything else can be addressed iteratively.
Summary
JungianServicestruct exposed asclient.Jungian.*SearchWithContext(),GetIndividuationScore(),GetIndividuationHistory(),GetSynchronicityPatterns(),GetDreamHistory()Test plan
go build ./...to verify compilationgo vet ./...for static analysisSummary by Sourcery
Add a Jungian Intelligence service to the Go client to expose archetype-aware memory search and Jungian analytics endpoints.
New Features:
Enhancements: