Skip to content

[FEATURE] #880 - Inject batch learning context into SpecContextBuilder #912

@stephanj

Description

@stephanj

Parent Issue

Part of #880 — Introduce Batch-Level Learning and Strategy Memory

Context

SpecContextBuilder builds the prompt context for each task but has no awareness of what happened in prior tasks during the current batch run. When LearningMode is BATCH, a summarized learning context should be injected into each task's prompt.

Task

Extend SpecContextBuilder to inject batch learning summaries when learning mode is enabled.

Key Changes

  1. Add buildBatchLearningContext(BatchExecutionMemory memory) method:

    • Renders a structured block, e.g.:
      ## Batch Execution Context
      
      ### Previously Completed Tasks (this run)
      
      **TASK-1: Set up database schema** (SUCCESS, 45s)
      - Files modified: src/db/schema.sql, src/db/migrations/001.sql
      - Strategy: Used existing ORM patterns from project
      - Note: PostgreSQL-specific syntax required
      
      **TASK-2: Create User model** (SUCCESS, 32s)
      - Files modified: src/models/User.java, src/models/UserRepository.java
      - Exports: User, UserRepository
      
      **TASK-3: Add email validation** (FAILED — timeout)
      - Error: Task not marked Done within grace period
      - Note: Consider breaking into smaller subtasks
      
      ### Patterns Observed
      - Project uses Spring Data JPA for repository layer
      - Tests expected in src/test/ mirroring main structure
      
  2. Integrate into buildContext() and buildCliInstruction():

    • Accept BatchExecutionMemory as optional parameter
    • Append learning context when LearningMode == BATCH
    • Respect maxLearningContextLength setting
  3. Wire into SpecTaskRunnerService:

    • Pass BatchExecutionMemory to context builder before each task submission
    • For CLI mode: append learning context to the CLI instruction prompt
    • For LLM mode: append learning context to the system/user message

Files to Modify

  • src/main/java/com/devoxx/genie/service/spec/SpecContextBuilder.java
  • src/main/java/com/devoxx/genie/service/spec/SpecTaskRunnerService.java

Dependencies

Acceptance Criteria

  • Learning context injected when LearningMode is BATCH
  • No learning context injected when LearningMode is OFF
  • Context respects max character limit
  • Failed task notes included to prevent repeating mistakes
  • Pattern observations extracted and included
  • CLI and LLM modes both receive learning context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions