Skip to content

Jira backend refactor#172

Merged
Gkrumbach07 merged 32 commits intoambient-code:mainfrom
sallyom:jira-backend-refactor
Oct 12, 2025
Merged

Jira backend refactor#172
Gkrumbach07 merged 32 commits intoambient-code:mainfrom
sallyom:jira-backend-refactor

Conversation

@sallyom
Copy link
Copy Markdown
Contributor

@sallyom sallyom commented Oct 12, 2025

@Gkrumbach07 @cooktheryan don't be scared - this is a beautiful thing & it works!! The jira integration isn't quite there yet but I'd like to merge this first and keep working on that. I've added Gage to all commits since this is a huge refactor moving our code around.

Summary:

  components/backend/
  ├── crd/                    # Custom Resource Definition helpers
  │   └── rfe.go             # RFE workflow CR operations
  ├── git/                    # Git operations
  │   └── operations.go      # Clone, push, diff, GitHub integration
  ├── github/                 # GitHub authentication
  │   ├── app.go            # GitHub App integration
  │   └── token.go          # Token management
  ├── handlers/               # HTTP request handlers (organized by domain)
  │   ├── content.go        # Content service endpoints
  │   ├── github_auth.go    # GitHub OAuth handlers
  │   ├── health.go         # Health check endpoint
  │   ├── helpers.go        # Shared handler utilities
  │   ├── middleware.go     # Authentication & context middleware
  │   ├── permissions.go    # RBAC permission management
  │   ├── projects.go       # Project CRUD operations
  │   ├── repo.go           # Repository operations
  │   ├── rfe.go            # RFE workflow handlers
  │   ├── secrets.go        # Secret management
  │   └── sessions.go       # Agentic session lifecycle
  ├── jira/                   # Jira integration
  │   └── integration.go    # Jira API client & publishing
  ├── k8s/                    # Kubernetes resource definitions
  │   └── resources.go      # GVR definitions for CRDs
  ├── server/                 # Server initialization
  │   ├── k8s.go           # K8s client setup & config
  │   └── server.go        # HTTP server & routing
  ├── types/                  # Shared type definitions
  │   ├── common.go        # Common types & utilities
  │   ├── project.go       # Project-related types
  │   ├── rfe.go           # RFE workflow types
  │   └── session.go       # Session types
  ├── websocket/              # WebSocket messaging
  │   ├── handlers.go      # WebSocket HTTP handlers
  │   └── hub.go           # WebSocket hub & message persistence
  ├── main.go                 # Application entry point
  ├── go.mod                  # Go module definition
  ├── go.sum                  # Dependency checksums
  ├── Makefile                # Build & development tasks
  ├── Dockerfile              # Production container image
  ├── Dockerfile.dev          # Development container image
  ├── JIRA_NOTES.md          # Jira integration documentation
  └── REFACTOR_NOTES.md      # Refactor progress tracking


  Key improvements from refactor:
  - Organized handlers by domain (was 3906-line monolith)
  - Extracted packages: crd, git, github, jira, k8s, server, types, websocket
  - Separated concerns: routing, initialization, business logic
  - Improved testability and maintainability
  - No functional changes (except Jira enhancements)

sallyom and others added 30 commits October 11, 2025 21:41
Signed-off-by: sallyom <somalley@redhat.com>
- Document successful rebase and conflict resolution
- Note current state: build clean, ready for handlers refactor
- List pending refactor tasks for continuing after compact

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Created server/ package to organize initialization and server setup:
- server/k8s.go: K8s client initialization and config
- server/server.go: Server setup, middleware, and routing logic

main.go now follows Go convention:
- Clean main() function (initialization + run)
- Moved ~150 lines of setup code to server package
- Route registration via callbacks
- Maintained backward compatibility with global variables

Line count: 497 → 353 lines
Build: ✅ Verified clean

Part of Phase 1 of backend refactor (see REFACTOR_NOTES.md)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
- Created handlers/content.go with 6 content service handlers:
  * ContentGitPush - Git push endpoint
  * ContentGitAbandon - Git abandon endpoint
  * ContentGitDiff - Git diff endpoint
  * ContentWrite - File write endpoint
  * ContentRead - File read endpoint
  * ContentList - Directory listing endpoint

- Removed duplicate handlers from handlers.go (lines 1657-1876)
- Fixed unused imports: removed 'reflect' from handlers/content.go
- Fixed unused imports: removed 'path/filepath' from handlers.go
- Fixed unused variable 'summary' in ContentGitDiff handler
- Build verified clean with zero errors

Reduces handlers.go from 3835 to 3614 lines (-221 lines)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
- Created handlers/sessions.go with 16 session handlers
- Session CRUD: ListSessions, CreateSession, GetSession, UpdateSession, DeleteSession
- Session lifecycle: CloneSession, StartSession, StopSession, UpdateSessionStatus
- Session workspace: ListSessionWorkspace, GetSessionWorkspaceFile, PutSessionWorkspaceFile
- Session GitHub: PushSessionRepo, AbandonSessionRepo, DiffSessionRepo
- Special: MintSessionGitHubToken
- Helper functions: provisionRunnerTokenForSession, UpdateSessionDisplayName, setRepoStatus, parseSpec, stringPtr, contentListItem
- Updated main.go to initialize session handler dependencies and route registration
- Updated handlers.go to remove extracted code and add shared helper functions
- Build verified clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
- Extract RFE workflow handlers from handlers.go to handlers/rfe.go
- Created handlers/rfe.go (652 lines, 11 handlers)
- Reduced handlers.go from 1,058 to 441 lines
- Updated main.go to initialize RFE handler dependencies
- Kept rfeFromUnstructured and extractTitleFromContent in main package for jira.go
- Build verified clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
- Added Phase 3 commits for organizing remaining files into packages
- Commit 11: git package for git operations
- Commit 12: jira package for Jira integration
- Commit 13: websocket package
- Commit 14: github package for GitHub integration
- Commit 15: final cleanup

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Signed-off-by: sallyom <somalley@redhat.com>

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Brings in AUTO_PUSH_ON_COMPLETE environment variable from upstream/main
(commit a73d482) that was missing after rebase. This ensures sessions
created from RFE workflows automatically push changes on completion.

Changes:
- Add AUTO_PUSH_ON_COMPLETE env var to interactive ideate sessions
- Add AUTO_PUSH_ON_COMPLETE env var to non-interactive phase sessions

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
The GetWorkflowJira function was using hardcoded Bearer token
authentication for all Jira instances, which fails for Jira Cloud
that requires Basic auth with base64-encoded credentials.

This commit adds authentication detection logic that automatically
selects the correct auth method based on the Jira instance URL:
- Jira Cloud (atlassian.net): Basic auth with base64-encoded token
- Jira Server/Data Center: Bearer token auth

This matches the authentication logic already present in the
PublishWorkflowFileToJira function in the jira package, ensuring
consistent behavior across POST and GET endpoints.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
fix: add Jira Cloud authentication support to GetWorkflowJira
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Update from Ambient session
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Signed-off-by: sallyom <somalley@redhat.com>

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
sallyom and others added 2 commits October 12, 2025 09:11
Signed-off-by: sallyom <somalley@redhat.com>

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Gage Krumbach <gkrumbach@gmail.com>
Signed-off-by: sallyom <somalley@redhat.com>
@Gkrumbach07
Copy link
Copy Markdown
Contributor

Trust the process

/approve

Y'all get ready for the frontend version

@Gkrumbach07 Gkrumbach07 merged commit 2aaf4be into ambient-code:main Oct 12, 2025
10 of 11 checks passed
sallyom added a commit that referenced this pull request Oct 15, 2025
Co-authored-by: Gage Krumbach <gkrumbach@gmail.com>
Signed-off-by: sallyom <somalley@redhat.com>
@sallyom sallyom deleted the jira-backend-refactor branch October 17, 2025 02:07
@bobbravo2 bobbravo2 added this to the v0.0.3 milestone Jan 30, 2026
jeremyeder added a commit that referenced this pull request Apr 10, 2026
## Summary

- Bump `next` 16.2.2 → 16.2.3 — fixes DoS via Server Components (alert
#173)
- Bump `aiohttp` ≥3.13.3 → ≥3.13.4 — fixes 9 CVEs: header injection,
SSRF, DoS, credential leak, CRLF injection (alerts #149–158)
- Bump `cryptography` 46.0.5 → 46.0.7 (transitive) — fixes buffer
overflow (alert #172)
- Bump `lupa` 2.6 → 2.7 (transitive) — fixes sandbox escape / RCE (alert
#168)

### Remaining alerts (3)

Alerts #144, #145, #146 (`fastmcp` 2.14.3 → 3.2.0) are **blocked on
upstream**: `mcp-atlassian` 0.21.1 pins `fastmcp<2.15.0,>=2.13.0`. The
CVEs affect fastmcp's OpenAPI provider and OAuth proxy — not in our code
path, but the alerts will stay open until `mcp-atlassian` releases a
version compatible with fastmcp 3.x.

## Test plan

- [x] Frontend: 614 tests pass (`npx vitest run`)
- [x] Runner: 543 tests pass (`uv run pytest tests/`)
- [ ] CI passes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Bumped frontend and runtime dependency minimums to newer patch
releases.

* **Refactor**
* Code formatting and parameter/layout reflows across several modules
for readability.

* **Tests**
* Cleaned up and reformatted unit tests, removing unused imports and
improving fixture readability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ambient Code Bot <bot@ambient-code.local>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

3 participants