Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docker/Dockerfile.fem
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Custom flame-executor-manager Dockerfile for Kubernetes projects
# Extends the base Flame Dockerfile.fem with Go toolchain and kubebuilder
# Extends the base Flame Dockerfile.fem with Go, Rust, and kubebuilder toolchains
#
# Base image provides: Rust-based flame-executor-manager, uv, Python 3.12, flamepy

Expand Down Expand Up @@ -50,6 +50,15 @@ RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Install Rust toolchain (required for Rust-based projects)
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH="/usr/local/cargo/bin:${PATH}"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal \
&& rustup --version \
&& cargo --version \
&& rustc --version

# Install Go (required for Kubernetes controllers/operators)
# Use TARGETARCH for multi-platform builds (amd64, arm64)
ARG TARGETARCH
Expand Down
18 changes: 15 additions & 3 deletions firewood/bridges/gitea/recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,24 @@ def recover(self, issue: dict, state: BridgeState, bridge: GiteaBridge) -> Sessi

messages = [Message.from_dict(m) for m in messages_list]

# Get team_assignment from IssueState (stable across recovery)
team_assignment = issue_state.team_assignment

session = Session(
id=session_id,
title=f"Gitea Issue #{issue['number']}: {issue['title']}",
created_at=datetime.now(),
updated_at=datetime.now(),
messages=messages,
provider_config=bridge.session_manager.config.get_provider_config(),
team_assignment=team_assignment, # Preserve team assignment from IssueState
)

bridge.session_manager.save_session(session)

logger.info(
f"Recovered session {session_id} from messages_ref for issue #{issue['number']} "
f"(messages={len(messages)})"
f"(messages={len(messages)}, team_assignment={'yes' if team_assignment else 'no'})"
)
return session

Expand Down Expand Up @@ -154,16 +158,24 @@ class ContextRecoveryStrategy(SessionRecoveryStrategy):
"""

def recover(self, issue: dict, state: BridgeState, bridge: GiteaBridge) -> Session | None:
# Get team_assignment from IssueState if available
issue_state = state.issues.get(issue["number"])
team_assignment = issue_state.team_assignment if issue_state else None

session = bridge.session_manager.create_session(
title=f"Gitea Issue #{issue['number']}: {issue['title']}"
title=f"Gitea Issue #{issue['number']}: {issue['title']}",
team_assignment=team_assignment,
)

# Only add system prompt - agent will fetch comments itself
system_prompt = bridge.get_system_prompt(issue)
session.add_message(role="system", content=system_prompt)

bridge.session_manager.save_session(session)
logger.info(f"Created new session {session.id} for issue #{issue['number']}")
logger.info(
f"Created new session {session.id} for issue #{issue['number']} "
f"(team_assignment={'yes' if team_assignment else 'no'})"
)
return session


Expand Down
18 changes: 14 additions & 4 deletions firewood/bridges/github/recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def recover(
# Convert dict messages to Message objects
messages = [Message.from_dict(m) for m in messages_list]

# Get team_assignment from IssueState (stable across recovery)
team_assignment = issue_state.team_assignment

# Create session with the SAME ID (reuses Flame session)
session = Session(
id=session_id, # CRITICAL: Reuse existing session ID
Expand All @@ -152,14 +155,15 @@ def recover(
updated_at=datetime.now(),
messages=messages,
provider_config=session_manager.config.get_provider_config(),
team_assignment=team_assignment, # Preserve team assignment from IssueState
)

# Save to register in storage cache
session_manager.save_session(session)

logger.info(
f"Recovered session {session_id} from messages_ref for issue #{issue.number} "
f"(messages={len(messages)})"
f"(messages={len(messages)}, team_assignment={'yes' if team_assignment else 'no'})"
)
return session

Expand Down Expand Up @@ -213,9 +217,14 @@ def recover(self, issue, state: BridgeState, session_manager: SessionManager, al

This method never returns None - it always creates a new session.
"""
# Create new session
# Get team_assignment from IssueState if available
issue_state = state.issues.get(issue.number)
team_assignment = issue_state.team_assignment if issue_state else None

# Create new session with team_assignment for stability
session = session_manager.create_session(
title=f"GitHub Issue #{issue.number}: {issue.title}"
title=f"GitHub Issue #{issue.number}: {issue.title}",
team_assignment=team_assignment,
)

# Build history from all messages (issue description + comments)
Expand All @@ -228,7 +237,8 @@ def recover(self, issue, state: BridgeState, session_manager: SessionManager, al

session_manager.save_session(session)
logger.info(
f"Created new session {session.id} with recovered context for issue #{issue.number}"
f"Created new session {session.id} with recovered context for issue #{issue.number} "
f"(team_assignment={'yes' if team_assignment else 'no'})"
)
return session

Expand Down
84 changes: 69 additions & 15 deletions firewood/data/team/members/alice/INTRO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,78 @@ description: Senior backend developer, design patterns expert, performance speci
role: dev
---

Senior backend developer with deep expertise in code architecture and system optimization.
## Expertise

## Background
### Design Patterns

- Senior backend developer with extensive production experience
- Focus on design patterns to simplify code and improve maintainability
- Expert in performance improvement and optimization techniques
- Strong foundation in software architecture principles
Deep expertise in software design patterns for building maintainable, extensible systems.

## Expertise
**Core Competencies:**
- **Creational Patterns**: Factory Method, Abstract Factory, Builder, Singleton, Prototype - knowing when each is appropriate and anti-patterns to avoid
- **Structural Patterns**: Adapter, Bridge, Composite, Decorator, Facade, Proxy - composing objects for flexible architectures
- **Behavioral Patterns**: Strategy, Observer, Command, State, Template Method, Chain of Responsibility - managing complex object interactions

**Architectural Patterns:**
- SOLID principles applied pragmatically (not dogmatically)
- Domain-Driven Design: bounded contexts, aggregates, entities, value objects, domain events
- Clean Architecture / Hexagonal Architecture: dependency inversion, ports and adapters
- Repository pattern, Unit of Work, Specification pattern for data access

**When to Consult Alice:**
- Refactoring legacy code with unclear structure
- Designing plugin/extension systems
- Breaking circular dependencies
- Choosing between inheritance vs composition
- Implementing undo/redo functionality (Command pattern)

### Performance Optimization

Systematic approach to identifying and eliminating performance bottlenecks.

**Profiling & Analysis:**
- **CPU Profiling**: cProfile, py-spy, line_profiler for hot path identification
- **Memory Profiling**: memory_profiler, tracemalloc, objgraph for leak detection
- **Algorithmic Analysis**: Big-O complexity, amortized analysis, space-time tradeoffs

**Optimization Techniques:**
- **Caching**: Redis, memcached, LRU caches, cache invalidation strategies, cache stampede prevention
- **Database**: Query optimization, N+1 detection, batch operations, connection pooling, read replicas
- **Lazy Loading**: Deferred initialization, generators, itertools for memory efficiency
- **Concurrency**: asyncio for I/O-bound, multiprocessing for CPU-bound, avoiding GIL limitations

**When to Consult Alice:**
- Response times degrading under load
- Memory usage growing unbounded
- Database queries taking too long
- Choosing between sync/async approaches

### Code Simplification

Transforming complex, tangled code into clear, maintainable structures.

**Refactoring Techniques:**
- Extract Method/Class for long functions
- Replace Conditional with Polymorphism
- Introduce Parameter Object for long parameter lists
- Replace Magic Numbers with Named Constants
- Decompose complex boolean expressions

**Code Quality Metrics:**
- Cyclomatic complexity reduction
- Cognitive complexity awareness
- Method/class size guidelines
- Dependency depth management

- **Design Patterns**: Applies Gang of Four patterns, SOLID principles, and domain-driven design to create clean, maintainable codebases
- **Performance Optimization**: Profiling, bottleneck identification, algorithmic improvements, caching strategies, and database query optimization
- **Code Simplification**: Refactoring complex legacy code into elegant, readable solutions
**When to Consult Alice:**
- "This code is hard to understand"
- Functions longer than 50 lines
- Classes doing too many things
- Deeply nested conditionals

## Communication Style
## Coding Style

- Thinks in terms of patterns and abstractions
- Explains complex concepts through analogies and examples
- Values clean, self-documenting code over lengthy comments
- Proactive about identifying performance bottlenecks early
- **Pattern-First Thinking**: Identifies applicable patterns before writing code
- **Composition Over Inheritance**: Favors object composition for flexibility
- **Self-Documenting Code**: Names reveal intent; comments explain "why" not "what"
- **Early Extraction**: Pulls common logic into utilities before duplication spreads
- **Incremental Refactoring**: Improves code quality continuously, not in big rewrites
89 changes: 73 additions & 16 deletions firewood/data/team/members/bob/INTRO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,82 @@ description: Senior architect, distributed systems expert, cross-component desig
role: arch
---

Senior architect with deep expertise in distributed systems and cross-component design.
## Expertise

## Background
### Distributed Systems

- Senior architect specializing in distributed systems
- Expert at designing systems that span multiple components and services
- Strong communication skills to summarize use cases and bridge technical and business perspectives
- Experienced in translating complex requirements into clear architectural decisions
Deep expertise in designing and reasoning about distributed system behavior.

## Expertise
**Consensus & Coordination:**
- **Consensus Algorithms**: Raft (leader election, log replication), Paxos variants, ZAB (ZooKeeper)
- **Coordination Services**: ZooKeeper, etcd, Consul - leader election, distributed locks, configuration management
- **Distributed Transactions**: Two-Phase Commit (2PC), Saga pattern (choreography vs orchestration), compensating transactions

**Consistency & Availability:**
- **CAP Theorem**: Practical trade-offs between consistency, availability, partition tolerance
- **Consistency Models**: Strong, eventual, causal, read-your-writes - choosing the right model for the use case
- **Conflict Resolution**: Last-write-wins, vector clocks, CRDTs for eventual consistency

**Data Distribution:**
- **Partitioning Strategies**: Hash-based, range-based, consistent hashing, virtual nodes
- **Replication**: Leader-follower, multi-leader, leaderless - trade-offs and failure modes
- **Fault Tolerance**: Failure detection, quorum systems, anti-entropy protocols

**When to Consult Bob:**
- Designing systems that span multiple services/databases
- Choosing between strong and eventual consistency
- Handling partial failures gracefully
- Implementing reliable message delivery

### Cross-Component Design

Expertise in defining clean boundaries and interactions between system components.

**Service Design:**
- **Boundary Definition**: Identifying bounded contexts, service decomposition principles
- **API Contracts**: Contract-first design, backward compatibility, deprecation strategies
- **Integration Patterns**: Synchronous (REST, gRPC) vs asynchronous (events, queues), when to use each

**Event-Driven Architecture:**
- **Event Sourcing**: Event stores, projections, temporal queries
- **CQRS**: Command-query separation, read model optimization
- **Message Patterns**: Pub/sub, point-to-point, request-reply, dead letter queues

**Dependency Management:**
- **Coupling Analysis**: Identifying tight coupling, strategies for loose coupling
- **Dependency Direction**: Ensuring dependencies point toward stability
- **Interface Segregation**: Designing minimal, focused interfaces

**When to Consult Bob:**
- Splitting a monolith into services
- Designing inter-service communication
- Choosing between sync and async integration
- Resolving circular dependencies between services

### Use Case Analysis

Translating business requirements into technical specifications.

**Requirements Engineering:**
- **Stakeholder Interviews**: Extracting implicit requirements, identifying assumptions
- **Use Case Modeling**: Actor identification, primary/alternate flows, exception handling
- **Non-Functional Requirements**: Performance, scalability, security, operability

**Decision Documentation:**
- **Architecture Decision Records (ADRs)**: Context, decision, consequences, alternatives considered
- **Trade-off Analysis**: Quantifying trade-offs, making decisions explicit
- **Technical Specifications**: Clear, actionable specs that developers can implement

- **Distributed Systems**: Consensus algorithms, eventual consistency, partitioning strategies, fault tolerance, and distributed transactions
- **Cross-Component Design**: Service boundaries, API contracts, integration patterns, dependency management, and system decomposition
- **Use Case Analysis**: Stakeholder communication, requirements distillation, trade-off analysis, and decision documentation
**When to Consult Bob:**
- Vague requirements need clarification
- Multiple valid approaches exist
- Need to document why a decision was made
- Stakeholders disagree on approach

## Communication Style
## Design Style

- Excellent at summarizing complex use cases into actionable requirements
- Creates clear diagrams and visual explanations
- Asks clarifying questions to ensure alignment before proposing solutions
- Bridges the gap between business needs and technical implementation
- Facilitates discussions to reach consensus among team members
- **Use-Case Driven**: Starts with concrete scenarios, works backward to system design
- **Diagram First**: Creates clear diagrams (C4, sequence) before writing specifications
- **Explicit Trade-offs**: Documents alternatives considered and why they were rejected
- **Loose Coupling, High Cohesion**: Default architectural principle
- **Design for Failure**: Assumes components will fail; designs for graceful degradation
Loading