Skip to content

feat: add Jungian Intelligence Layer service v3.2.0#5

Open
ckaraca wants to merge 1 commit intomainfrom
feature/jungian-intelligence-layer
Open

feat: add Jungian Intelligence Layer service v3.2.0#5
ckaraca wants to merge 1 commit intomainfrom
feature/jungian-intelligence-layer

Conversation

@ckaraca
Copy link
Copy Markdown
Contributor

@ckaraca ckaraca commented Mar 2, 2026

Summary

  • Adds JungianService struct exposed as client.Jungian.*
  • Methods: SearchWithContext(), GetIndividuationScore(), GetIndividuationHistory(), GetSynchronicityPatterns(), GetDreamHistory()

Test plan

  • Run go build ./... to verify compilation
  • Verify all 5 methods call correct API endpoints
  • Run go vet ./... for static analysis

Summary by Sourcery

Add a Jungian Intelligence service to the Go client to expose archetype-aware memory search and Jungian analytics endpoints.

New Features:

  • Expose a JungianService on the client for accessing Jungian Intelligence Layer functionality.
  • Support archetype-enhanced memory search with contextual parameters.
  • Provide APIs to retrieve current individuation score and historical individuation trends.
  • Expose endpoints to list detected synchronicity patterns and dream consolidation history.

Enhancements:

  • Introduce Jungian-related response and model types for individuation scoring, archetyped memory patterns, synchronicity patterns, and dream consolidation records.

Add JungianService with 5 methods: SearchWithContext,
GetIndividuationScore, GetIndividuationHistory,
GetSynchronicityPatterns, GetDreamHistory. Includes 6 new
types for archetypes, individuation, synchronicity, and
dream consolidation.
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 2, 2026

Reviewer's Guide

Introduces 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 flow

sequenceDiagram
    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
Loading

Class diagram for JungianService and related response types

classDiagram
    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
Loading

File-Level Changes

Change Details Files
Add data models for Jungian Intelligence responses used by the new service methods.
  • Define IndividuationComponents and IndividuationResponse to represent individuation scoring details and metadata.
  • Define ArchetypedPattern and ArchetypeSearchResponse for archetype-enhanced search results.
  • Define SynchronicityPattern and DreamConsolidation structs to model synchronicity patterns and dream consolidation records.
types.go
Expose a JungianService on the main client that calls the appropriate Jungian Intelligence Layer endpoints.
  • Extend Client struct to include a Jungian field of type *JungianService.
  • Initialize Jungian in NewClientWithOptions so it is available from constructed clients.
  • Implement JungianService with SearchWithContext, GetIndividuationScore, GetIndividuationHistory, GetSynchronicityPatterns, and GetDreamHistory methods, each delegating to the underlying Client.get/post helpers with the correct URL paths and parameters.
client.go
jungian.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 pluggedinkit API client. It enables interaction with advanced psychological AI features, including archetype-enhanced memory search, individuation score tracking, synchronicity pattern detection, and dream history retrieval. This expansion enhances the client's capabilities by integrating a novel set of cognitive and analytical tools.

Highlights

  • New Jungian Intelligence Layer Service: Introduced a JungianService struct, accessible via client.Jungian.*, providing methods for archetype-enhanced memory search, individuation scores, synchronicity patterns, and dream history.
  • API Client Integration: Integrated the JungianService into the main Client struct and ensured its proper initialization within the NewClientWithOptions function.
  • Data Model Definitions: Defined new Go types (IndividuationComponents, IndividuationResponse, ArchetypedPattern, ArchetypeSearchResponse, SynchronicityPattern, DreamConsolidation) to support the Jungian Intelligence Layer API responses.
Changelog
  • client.go
    • Added JungianService field to the Client struct.
    • Initialized the JungianService in the NewClientWithOptions function.
  • jungian.go
    • Created JungianService struct and its associated methods: SearchWithContext, GetIndividuationScore, GetIndividuationHistory, GetSynchronicityPatterns, and GetDreamHistory.
  • types.go
    • Defined new data structures for Jungian Intelligence Layer responses, including IndividuationComponents, IndividuationResponse, ArchetypedPattern, ArchetypeSearchResponse, SynchronicityPattern, and DreamConsolidation.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +16 to +20
body := map[string]interface{}{
"query": query,
"tool_name": toolName,
"outcome": outcome,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For converting an integer to a string, strconv.Itoa is generally more idiomatic and can be more performant than fmt.Sprintf. You will need to add "strconv" to your imports.

Suggested change
params.Set("days", fmt.Sprintf("%d", days))
params.Set("days", strconv.Itoa(days))

SourceCount int `json:"sourceCount"`
TokenSavings int `json:"tokenSavings"`
ClusterSimilarity float64 `json:"clusterSimilarity"`
CreatedAt string `json:"createdAt"`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
CreatedAt string `json:"createdAt"`
CreatedAt time.Time `json:"createdAt"`

@claude
Copy link
Copy Markdown

claude bot commented Mar 2, 2026

Code Review: feat: add Jungian Intelligence Layer service v3.2.0

The 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 rag.go.


🐛 Bug: Query parameters mangled in URL construction

jungian.go:39 (and mirrored in the existing rag.go:104)

path := fmt.Sprintf("/api/memory/individuation?%s", params.Encode())
err := s.client.get(ctx, path, &result)

In client.go, request() does:

u, err := url.Parse(c.baseURL)
u.Path = path  // path now contains "?history=true&days=30"

Assigning a string that contains ? to u.Path causes Go's url.URL.EscapedPath() to percent-encode the ? as %3F, producing a broken URL:

https://plugged.in/api/memory/individuation%3Fhistory=true&days=30

The fix is to keep the path and query string separate. Either enhance client.get() to accept url.Values, or parse and reconstruct the URL properly in the service method. Note: this same bug exists in rag.go:104 and both should be fixed together.


⚠️ Inconsistent error return pattern

jungian.go:22-23 and GetIndividuationScore() both do:

return &result, err  // returns &zero-value struct on error

This matches agents.go but conflicts with rag.go, which returns nil, err on failure. Returning a non-nil pointer to a zero-value struct alongside an error can mask bugs where callers forget to check err before using the result. The safer convention is return nil, err.


⚠️ No input validation for days parameter

jungian.go:34:

func (s *JungianService) GetIndividuationHistory(ctx context.Context, days int) ([]IndividuationResponse, error) {

A days <= 0 value is silently forwarded to the API. Compare with rag.go:97 which validates userID != "" before making the request. Consider:

if days <= 0 {
    return nil, fmt.Errorf("days must be greater than 0")
}

🔍 DreamConsolidation.CreatedAt type inconsistency

types.go:387:

CreatedAt string `json:"createdAt"`

Every other timestamp field in this codebase uses time.Time (Document.CreatedAt, ClipboardEntry.CreatedAt, etc.). Using string loses type safety and forces callers to parse the timestamp themselves. Prefer time.Time if the API returns RFC3339.


🔍 Minor: Use strconv.Itoa for int-to-string conversion

jungian.go:37:

params.Set("days", fmt.Sprintf("%d", days))

strconv.Itoa(days) is the idiomatic Go alternative and avoids pulling in fmt solely for this.


🔍 Minor: Struct field alignment

types.go:349WeeklyTrend field tag is not aligned with surrounding fields. Running gofmt will fix this automatically.


💡 Naming concern: SearchWithContext calls an inject endpoint

jungian.go:22 calls /api/memory/archetype/inject but the method is named SearchWithContext. "Inject" implies a mutation/write operation. If this method has write-through side effects, the godoc comment should note them — or the method name should better reflect the behaviour (e.g., ArchetypeSearch or InjectMemoryAndSearch).


📋 No tests

There are no *_test.go files in the repository currently, so this PR doesn't regress coverage. That said, a unit test using httptest.NewServer for GetIndividuationHistory would directly catch the URL bug above and prevent future regressions. Suggested as a follow-up.


Summary

Severity Issue
🐛 Bug Query params percent-encoded in URL path — GetIndividuationHistory cannot work correctly
⚠️ Medium &zero-value, err return on error is inconsistent and can mask caller bugs
⚠️ Medium 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.

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