Commit Graph

383 Commits

Author SHA1 Message Date
e79ed8da2b docs(orchestration): Update tracking for issue 147 completion
Updated orchestration tracking documents:
- Issue 147 completed: 60K tokens, -4% variance
- Phase 3 progress: 1/3 complete (33%)
- Overall progress: 13/21 issues (62%)
- Total tokens used: 678K of 936K (72%)

Phase 3 (Quality Layer) is now in progress.
2026-02-01 18:30:57 -06:00
38da576b69 fix(#147): Fix linting violations in quality gate tests
Fixed code review findings:
- Removed unused mock_run variables (6 instances)
- Fixed line length violations (3 instances)
- All ruff checks now pass

All 36 tests still passing after fixes.
Quality gates: BuildGate, LintGate, TestGate, CoverageGate ready for use.
2026-02-01 18:29:13 -06:00
f45dbac7b4 feat(#147): Implement core quality gates (TDD - GREEN phase)
Implement four quality gates enforcing non-negotiable quality standards:

1. BuildGate: Runs mypy type checking
   - Detects compilation/type errors
   - Uses strict mode from pyproject.toml
   - Returns GateResult with pass/fail status

2. LintGate: Runs ruff linting
   - Treats warnings as failures (non-negotiable)
   - Checks code style and quality
   - Enforces rules from pyproject.toml

3. TestGate: Runs pytest tests
   - Requires 100% test pass rate (non-negotiable)
   - Runs without coverage (separate gate)
   - Detects test failures and missing tests

4. CoverageGate: Measures test coverage
   - Enforces 85% minimum coverage (non-negotiable)
   - Extracts coverage from JSON and output
   - Handles edge cases gracefully

All gates implement QualityGate protocol with check() method.
All gates return GateResult with passed/message/details.
All implementations achieve 100% test coverage.

Files created:
- src/gates/quality_gate.py: Protocol and result model
- src/gates/build_gate.py: Type checking enforcement
- src/gates/lint_gate.py: Linting enforcement
- src/gates/test_gate.py: Test execution enforcement
- src/gates/coverage_gate.py: Coverage enforcement
- src/gates/__init__.py: Module exports

Related to #147

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 18:25:16 -06:00
0af93d1ef4 test(#147): Add tests for quality gates (TDD - RED phase)
Implement comprehensive test suite for four core quality gates:
- BuildGate: Tests mypy type checking enforcement
- LintGate: Tests ruff linting with warnings as failures
- TestGate: Tests pytest execution requiring 100% pass rate
- CoverageGate: Tests coverage enforcement with 85% minimum

All tests follow TDD methodology - written before implementation.
Total: 36 tests covering success, failure, and edge cases.

Related to #147

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 18:25:02 -06:00
f48b358cec docs(orchestration): M4.1-Coordinator autonomous execution report
Comprehensive tracking documents for M4.1-Coordinator milestone orchestration:
- Orchestration plan with all 21 issues and dependencies
- Token tracking (estimates vs actuals) for all completed issues
- Final status report: 12/21 issues complete (57%), 3 phases done
- Issue 140 verification: documentation 85% complete

Key achievements:
- Phase 0 (Foundation): 6/6 complete
- Phase 1 (Context Management): 3/3 complete
- Phase 2 (Agent Assignment): 3/3 complete
- 100% quality gate pass rate
- 95%+ average test coverage
- ~618K tokens used of 936K estimated (66%)

Remaining: Phases 3-4 (Quality Layer + Advanced Orchestration)
2026-02-01 18:17:59 -06:00
9f3c76d43b test(#146): Validate assignment cost optimization
Add comprehensive cost optimization test scenarios and validation report.

Test Scenarios Added (10 new tests):
- Low difficulty assigns to MiniMax/GLM (free agents)
- Medium difficulty assigns to GLM when within capacity
- High difficulty assigns to Opus (only capable agent)
- Oversized issues rejected with actionable error
- Boundary conditions at capacity limits
- Aggregate cost optimization across all scenarios

Results:
- All 33 tests passing (23 existing + 10 new)
- 100% coverage of agent_assignment.py (36/36 statements)
- Cost savings validation: 50%+ in aggregate scenarios
- Real-world projection: 70%+ savings with typical workload

Documentation:
- Created cost-optimization-validation.md with detailed analysis
- Documents cost savings for each scenario
- Validates all acceptance criteria from COORD-006

Completes Phase 2 (M4.1-Coordinator) testing requirements.

Fixes #146

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 18:13:53 -06:00
67da5370e2 feat(ci): Add branch-aware tagging and retention policy docs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Tagging Strategy:
- main branch: {sha} + 'latest'
- develop branch: {sha} + 'dev'
- git tags: {sha} + version (e.g., v1.0.0)

Also added docs/harbor-tag-retention-policy.md with:
- Recommended retention rules for Harbor
- Garbage collection schedule
- Cleanup commands and scripts
- Monitoring commands

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 18:10:16 -06:00
10ecbd63f1 test(#161): Add comprehensive E2E integration test for coordinator
Implements complete end-to-end integration test covering:
- Webhook receiver → parser → queue → orchestrator flow
- Signature validation in full flow
- Dependency blocking and unblocking logic
- Multi-issue processing with correct ordering
- Error handling (malformed issues, agent failures)
- Performance requirement (< 10 seconds)

Test suite includes 7 test cases:
1. test_full_flow_webhook_to_orchestrator - Main critical path
2. test_full_flow_with_blocked_dependency - Dependency management
3. test_full_flow_with_multiple_issues - Queue ordering
4. test_webhook_signature_validation_in_flow - Security
5. test_parser_handles_malformed_issue_body - Error handling
6. test_orchestrator_handles_spawn_agent_failure - Resilience
7. test_performance_full_flow_under_10_seconds - Performance

All tests pass (182 total including 7 new).
Performance verified: Full flow completes in < 1 second.
100% of critical integration path covered.

Completes #161 (COORD-005) and validates Phase 0.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 18:08:10 -06:00
9b1a1c0b8a feat(#145): Build assignment algorithm
Implement intelligent agent assignment algorithm that selects the optimal
agent for each issue based on context capacity, difficulty, and cost.

Algorithm:
1. Filter agents that meet context capacity (50% rule - agent needs 2x context)
2. Filter agents that can handle difficulty level
3. Sort by cost (prefer self-hosted when capable)
4. Return cheapest qualifying agent

Features:
- NoCapableAgentError raised when no agent can handle requirements
- Difficulty mapping: easy/low->LOW, medium->MEDIUM, hard/high->HIGH
- Self-hosted preference (GLM, minimax cost=0)
- Comprehensive test coverage (100%, 23 tests)

Test scenarios:
- Assignment for low/medium/high difficulty issues
- Context capacity filtering (50% rule enforcement)
- Cost optimization logic (prefers self-hosted)
- Error handling for impossible assignments
- Edge cases (zero context, negative context, invalid difficulty)

Quality gates:
- All 23 tests passing
- 100% code coverage (exceeds 85% requirement)
- Lint: passing (ruff)
- Type check: passing (mypy)

Refs #145

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 18:07:58 -06:00
88953fc998 feat(#160): Implement basic orchestration loop
Implements the Coordinator class with main orchestration loop:
- Async loop architecture with configurable poll interval
- process_queue() method gets next ready issue and spawns agent (stub)
- Graceful shutdown handling with stop() method
- Error handling that allows loop to continue after failures
- Logging for all actions (start, stop, processing, errors)
- Integration with QueueManager from #159
- Active agent tracking for future agent management

Configuration settings added:
- COORDINATOR_POLL_INTERVAL (default: 5.0s)
- COORDINATOR_MAX_CONCURRENT_AGENTS (default: 10)
- COORDINATOR_ENABLED (default: true)

Tests: 27 new tests covering all acceptance criteria
Coverage: 92% overall (100% for coordinator.py)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 18:03:12 -06:00
f0fd0bed41 feat(#144): Implement agent profiles
- Add Capability enum (HIGH, MEDIUM, LOW) for agent difficulty levels
- Add AgentName enum for all 5 agents (opus, sonnet, haiku, glm, minimax)
- Implement AgentProfile data structure with validation
  - context_limit: max tokens for context window
  - cost_per_mtok: cost per million tokens (0 for self-hosted)
  - capabilities: list of difficulty levels the agent handles
  - best_for: description of optimal use cases
- Define profiles for all 5 agents with specifications:
  - Anthropic models (opus, sonnet, haiku): 200K context, various costs
  - Self-hosted models (glm, minimax): 128K context, free
- Implement get_agent_profile() function for profile lookup
- Add comprehensive test suite (37 tests, 100% coverage)
  - Profile data structure validation
  - All 5 predefined profiles exist and are correct
  - Capability enum and AgentName enum tests
  - Best_for validation and capability matching
  - Consistency checks across profiles

Fixes #144
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 18:00:19 -06:00
a1b911d836 test(#143): Validate 50% rule prevents context exhaustion
Following TDD (Red-Green-Refactor):
- RED: Created comprehensive test suite with 12 test cases
- GREEN: Implemented validation logic that passes all tests
- All quality gates passed

Test Coverage:
- Oversized issue (120K) correctly rejected
- Properly sized issue (80K) correctly accepted
- Edge case at exactly 50% (100K) correctly accepted
- Sequential issues validated individually
- All agent types tested (opus, sonnet, haiku, glm, minimax)
- Edge cases covered (zero, very small, boundaries)

Implementation:
- src/validation.py: Pure validation function
- tests/test_fifty_percent_rule.py: 12 comprehensive tests
- docs/50-percent-rule-validation.md: Validation report
- 100% test coverage (14/14 statements)
- Type checking: PASS (mypy)
- Linting: PASS (ruff)

The 50% rule ensures no single issue exceeds 50% of target
agent's context limit, preventing context exhaustion while
allowing efficient capacity utilization.

Fixes #143

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:56:04 -06:00
72321f5fcd feat(#159): Implement queue manager
Implements QueueManager with full dependency tracking, persistence, and status management.

Key features:
- QueueItem dataclass with status, metadata, and ready flag
- QueueManager with enqueue, dequeue, get_next_ready, mark_complete
- Dependency resolution (blocked_by → not ready)
- JSON persistence with auto-save on state changes
- Automatic reload on startup
- Graceful handling of circular dependencies
- Status transitions (pending → in_progress → completed)

Test coverage:
- 26 comprehensive tests covering all operations
- Dependency chain resolution
- Persistence and reload scenarios
- Edge cases (circular deps, missing items)
- 100% code coverage on queue module
- 97% total project coverage

Quality gates passed:
✓ All tests passing (88 total)
✓ Type checking (mypy) passing
✓ Linting (ruff) passing
✓ Coverage ≥85% (97% achieved)

This unblocks #160 (orchestrator needs queue).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:55:48 -06:00
dad4b68f66 feat(#158): Implement issue parser agent
Add AI-powered issue metadata parser using Anthropic Sonnet model.
- Parse issue markdown to extract: estimated_context, difficulty,
  assigned_agent, blocks, blocked_by
- Implement in-memory caching to avoid duplicate API calls
- Graceful fallback to defaults on parse failures
- Add comprehensive test suite (9 test cases)
- 95% test coverage (exceeds 85% requirement)
- Add ANTHROPIC_API_KEY to config
- Update documentation and add .env.example

Fixes #158

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:50:35 -06:00
d54c65360a feat(#155): Build basic context monitor
Implements ContextMonitor class with real-time token usage tracking:
- COMPACT_THRESHOLD at 0.80 (80% triggers compaction)
- ROTATE_THRESHOLD at 0.95 (95% triggers rotation)
- Poll Claude API for context usage
- Return appropriate ContextAction based on thresholds
- Background monitoring loop (10-second polling)
- Log usage over time
- Error handling and recovery

Added ContextUsage model for tracking agent token consumption.

Tests:
- 25 test cases covering all functionality
- 100% coverage for context_monitor.py and models.py
- Mocked API responses for different usage levels
- Background monitoring and threshold detection
- Error handling verification

Quality gates:
- Type checking: PASS (mypy)
- Linting: PASS (ruff)
- Tests: PASS (25/25)
- Coverage: 100% for new files, 95.43% overall

Fixes #155

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:49:09 -06:00
5639d085b4 feat(#154): Implement context estimator
Implements formula-based context estimation for predicting token
usage before issue assignment.

Formula:
  base = (files × 7000) + complexity + tests + docs
  total = base × 1.3  (30% safety buffer)

Features:
- EstimationInput/Result data models with validation
- ComplexityLevel, TestLevel, DocLevel enums
- Agent recommendation (haiku/sonnet/opus) based on tokens
- Validation against actual usage with tolerance checking
- Convenience function for quick estimations
- JSON serialization support

Implementation:
- issue_estimator.py: Core estimator with formula
- models.py: Data models and enums (100% coverage)
- test_issue_estimator.py: 35 tests, 100% coverage
- ESTIMATOR.md: Complete API documentation
- requirements.txt: Python dependencies
- .coveragerc: Coverage configuration

Test Results:
- 35 tests passing
- 100% code coverage (excluding __main__)
- Validates against historical issues
- All edge cases covered

Acceptance Criteria Met:
 Context estimation formula implemented
 Validation suite tests against historical issues
 Formula includes all components (files, complexity, tests, docs, buffer)
 Unit tests for estimator (100% coverage, exceeds 85% requirement)
 All components tested (low/medium/high levels)
 Agent recommendation logic validated

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:42:59 -06:00
e23c09f1f2 feat(#157): Set up webhook receiver endpoint
Implement FastAPI webhook receiver for Gitea issue assignment events
with HMAC SHA256 signature verification and event routing.

Implementation details:
- FastAPI application with /webhook/gitea POST endpoint
- HMAC SHA256 signature verification in security.py
- Event routing for assigned, unassigned, closed actions
- Comprehensive logging for all webhook events
- Health check endpoint at /health
- Docker containerization with health checks
- 91% test coverage (exceeds 85% requirement)

TDD workflow followed:
- Wrote 16 tests first (RED phase)
- Implemented features to pass tests (GREEN phase)
- All tests passing with 91% coverage
- Type checking with mypy: success
- Linting with ruff: success

Files created:
- apps/coordinator/src/main.py - FastAPI application
- apps/coordinator/src/webhook.py - Webhook handlers
- apps/coordinator/src/security.py - HMAC verification
- apps/coordinator/src/config.py - Configuration management
- apps/coordinator/tests/ - Comprehensive test suite
- apps/coordinator/Dockerfile - Production container
- apps/coordinator/pyproject.toml - Python project config

Configuration:
- Updated .env.example with GITEA_WEBHOOK_SECRET
- Updated docker-compose.yml with coordinator service

Testing:
- 16 unit and integration tests
- Security tests for signature verification
- Event handler tests for all supported actions
- Health check endpoint tests
- All tests passing with 91% coverage

This unblocks issue #158 (issue parser).

Fixes #157

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:41:46 -06:00
658ec0774d fix(ci): Switch to Kaniko for daemonless container builds
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
docker:dind requires privileged mode and a running daemon.
Kaniko builds containers without needing Docker daemon:
- Runs unprivileged
- Reads credentials from /kaniko/.docker/config.json
- Designed for CI environments like Woodpecker

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:34:50 -06:00
de3f3b9204 feat(#156): Create coordinator bot user documentation and setup scripts
Add comprehensive documentation and automated scripts for setting up the mosaic
coordinator bot user in Gitea. This enables the coordinator system to manage
issue assignments, comments, and orchestration.

Changes:
- docs/1-getting-started/3-configuration/4-gitea-coordinator.md: Complete setup guide
  * Step-by-step bot user creation via UI and API
  * Repository permission configuration
  * API token generation and storage
  * Comprehensive testing procedures
  * Security best practices and troubleshooting

- scripts/coordinator/create-gitea-bot.sh: Automated bot creation script
  * Creates mosaic bot user with proper configuration
  * Sets up repository permissions
  * Generates API token
  * Tests authentication
  * Provides credential output for secure storage

- scripts/coordinator/test-gitea-bot.sh: Bot functionality test suite
  * Tests authentication
  * Verifies repository access
  * Tests issue operations (read, list, assign, comment)
  * Validates label management
  * Confirms all required permissions

- scripts/coordinator/README.md: Scripts usage documentation
  * Workflow guides
  * Configuration reference
  * Troubleshooting section
  * Token rotation procedures

- .env.example: Added Gitea coordinator configuration template
  * GITEA_URL, GITEA_BOT_USERNAME, GITEA_BOT_TOKEN
  * GITEA_BOT_PASSWORD, GITEA_REPO_OWNER, GITEA_REPO_NAME
  * Security notes for credential storage

All acceptance criteria met:
✓ Documentation for bot user creation
✓ Automated setup script
✓ Testing procedures and scripts
✓ Configuration templates
✓ Security best practices
✓ Troubleshooting guide

Addresses Milestone: M4.1-Coordinator
Relates to: #140, #157, #158

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:32:03 -06:00
32c35d327b fix(ci): Use docker:dind with manual login instead of buildx plugin
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
The buildx plugin's credential handling doesn't work properly with
Harbor. The docker-auth-test step proved that standard docker login
works, so we switch to:
- docker:dind image
- Manual docker login before build
- Standard docker build and docker push

This bypasses buildx's separate credential store issue.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:31:05 -06:00
211c532fb0 fix(ci): Add auth debug step, switch back to buildx
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Added a docker-auth-test step that:
- Shows credential lengths (for debugging)
- Tests docker login directly with Harbor

This will help identify if the issue is with secrets injection
or with how buildx handles authentication.

Reverted to woodpeckerci/plugin-docker-buildx since plugins/docker
requires server-side WOODPECKER_PLUGINS_PRIVILEGED config.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:24:51 -06:00
b1be63edd6 fix(ci): Correct repo path format for plugins/docker
The repo setting should NOT include the registry prefix - the
registry setting handles that separately.

Changed repo: reg.mosaicstack.dev/mosaic/api -> repo: mosaic/api

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:23:49 -06:00
da038d3df2 fix(ci): Switch from buildx to plugins/docker for Harbor auth
The woodpeckerci/plugin-docker-buildx plugin was failing with
"insufficient_scope: authorization failed" when pushing to Harbor,
even though the same credentials worked locally.

Switched to the standard plugins/docker which uses traditional
docker login authentication that may work better with Harbor.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 17:13:58 -06:00
e1ed98b038 fix: Remove privileged flag (not allowed), keep debug
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 16:18:42 -06:00
55b2ddb58a fix: Add privileged and debug flags to docker-buildx steps
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 16:18:15 -06:00
8ca0b45fcb fix: Allow docker builds on manual pipeline triggers
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/manual/woodpecker Pipeline failed
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:10:59 -06:00
cd727f619f feat: Add debug output to Dockerfiles and .dockerignore
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/manual/woodpecker Pipeline was successful
- Add .dockerignore to exclude node_modules, dist, and build artifacts
- Add pre/post build directory listings to diagnose dist not found issue
- Disable turbo cache temporarily with --force flag
- Add --verbosity=2 for more detailed turbo output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:50:13 -06:00
763409cbb4 fix: Remove registry prefix from repo paths in Woodpecker
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
The docker-buildx plugin automatically prepends registry to repo,
so having the full URL caused doubled paths:
reg.mosaicstack.dev/reg.mosaicstack.dev/mosaic/api

Changed from: repo: reg.mosaicstack.dev/mosaic/api
Changed to:   repo: mosaic/api

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:45:29 -06:00
45483934c3 Merge branch 'fix/harbor-registry-url' into develop
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-02-01 13:39:38 -06:00
442c2f7de2 fix: Dockerfile COPY order - node_modules must come after source
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Docker COPY replaces directory contents, so copying source code
after node_modules was wiping the deps. Reordered to:
1. Copy source code first
2. Copy node_modules second (won't be overwritten)

Fixes API build failure: "dist not found"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:39:25 -06:00
728f68f877 Merge pull request 'fix(ci): Update Harbor registry URL to reg.mosaicstack.dev' (#178) from fix/harbor-registry-url into develop
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-02-01 19:26:17 +00:00
365975d76e fix(ci): Update Harbor registry URL to reg.mosaicstack.dev
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
Changed from reg.diversecanvas.com to reg.mosaicstack.dev

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:25:55 -06:00
1bfdd57f04 Merge pull request 'Release: CI/CD Pipeline & Architecture Updates' (#177) from develop into main
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Reviewed-on: #177
2026-02-01 19:18:47 +00:00
4b943fb997 feat: Add Docker build & push to Woodpecker CI pipeline
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
- Add docker-build-api, docker-build-web, docker-build-postgres steps
- Images pushed to reg.diversecanvas.com/mosaic/* on main/develop
- Create docker-compose.prod.yml for production deployments
- Add .env.prod.example with production configuration

Requires Harbor secrets in Woodpecker:
- harbor_username
- harbor_password

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 01:50:02 -06:00
9246f56687 fix(api): Add AuthModule import to modules using AuthGuard
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Modules using AuthGuard in their controllers need to import AuthModule
to make AuthService available for dependency injection.

Fixed:
- ActivityModule
- WorkspaceSettingsModule

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 01:48:09 -06:00
fb0f6b5b62 fix(docker): Fix module resolution and healthcheck syntax
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Issues fixed:
1. Module not found: Added missing copy of apps/{api,web}/node_modules
   which contains pnpm symlinks to the root node_modules

2. Healthcheck syntax: Fixed broken quoting from prettier reformatting
   Changed to CMD-SHELL with proper escaping

3. Removed obsolete version: "3.9" from docker-compose.yml

The apps need their own node_modules directories because pnpm uses
symlinks that point from apps/*/node_modules to node_modules/.pnpm/*

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 01:37:30 -06:00
aa17b9cb3b fix(docker): Make port configuration consistent and dynamic
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Fixed the mismatch between environment variables:
- docker-compose now passes PORT (what NestJS/Next.js read) instead of API_PORT
- API_PORT/WEB_PORT control host mapping, PORT controls container

Changes:
- docker-compose: Pass PORT=${API_PORT} and PORT=${WEB_PORT} to containers
- docker-compose: Dynamic port mapping on both host and container sides
- docker-compose: Traefik labels use ${API_PORT}/${WEB_PORT} variables
- docker-compose: Healthchecks use PORT env var
- Dockerfiles: Removed hardcoded port values
- Dockerfiles: Healthchecks read PORT at runtime

This allows changing ports via API_PORT/WEB_PORT environment variables
and have all components (app, healthcheck, Traefik) use the correct port.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 01:29:15 -06:00
8f63b3e1dc docs: Add Mosaic Component Architecture and Guard Rails design docs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- mosaic-component-architecture.md: OpenClaw wrapper pattern, component naming,
  job tracking, chat integration, database schema
- guard-rails-capability-permissions.md: Capability-based permission model

Related: #162 (M4.2 Infrastructure Epic)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 01:26:01 -06:00
e045cb5a45 perf(docker): Add BuildKit cache mounts for faster builds
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Added cache mounts for:
- pnpm store: Caches downloaded packages between builds
- TurboRepo: Caches build outputs between builds

This significantly speeds up subsequent builds:
- First build: Full download and compile
- Subsequent builds: Only changed packages are re-downloaded/rebuilt

Requires Docker BuildKit (default in Docker 23+).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 01:22:51 -06:00
353f04f950 fix(docker): Ensure public directory exists in web builder
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
The production stage was failing because it tried to copy the public
directory which doesn't exist in the source. Added mkdir -p to ensure
the directory exists (even if empty) before the production stage
tries to copy it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 01:15:34 -06:00
38f22f0b4e fix(scripts): Improve base URL configuration display clarity
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
When detecting existing configuration, the setup script now shows a
detailed breakdown instead of just "Current base URL: ...":

  Mode:    Traefik reverse proxy

  Web URL: https://app.mosaicstack.dev
  API URL: https://api.mosaicstack.dev
  Auth:    https://auth.mosaicstack.dev

This makes it clear:
- What access mode is configured (localhost/IP/domain/Traefik)
- What each URL is used for (Web UI, API, Authentication)
- Whether to change the configuration

Added helper functions:
- detect_access_mode(): Determines mode from existing .env values
- display_access_config(): Formats the URL breakdown display

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 00:57:23 -06:00
0495c48418 fix(docker): Copy node_modules from builder instead of reinstalling
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
pnpm stores the Prisma client in the content-addressable store at
node_modules/.pnpm/.../.prisma, not at apps/api/node_modules/.prisma.
The production stage was trying to copy from the wrong location.

Additionally, running `pnpm install --prod` in production failed because:
1. The husky prepare script runs but husky is a devDependency
2. The Prisma client postinstall can't run without the prisma CLI

Fixed by copying the full node_modules from the builder stage, which
already has all dependencies properly installed and the Prisma client
generated in the correct pnpm store location.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 00:42:34 -06:00
7ee08865fd fix(docker): Use TurboRepo to build workspace dependencies
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
The Docker builds were failing because they ran `pnpm build` directly
in the app directories without first building workspace dependencies
(@mosaic/shared, @mosaic/ui). CI passed because it runs TurboRepo
from the root which respects the dependency graph.

Changed both Dockerfiles to use `pnpm turbo build --filter=@mosaic/{app}`
which ensures dependencies are built in the correct order:
- Web: @mosaic/config → @mosaic/shared → @mosaic/ui → @mosaic/web
- API: @mosaic/config → @mosaic/shared → prisma:generate → @mosaic/api

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 00:37:34 -06:00
a84d06815e fix(docker): Make prepare script work in production builds
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
The husky prepare script was failing during Docker production builds
because husky is a devDependency and isn't available when running
`pnpm install --prod --frozen-lockfile`.

Changed from `husky install` (deprecated in v9+) to `husky || true`
which gracefully handles the case when husky isn't installed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 00:30:37 -06:00
8c8d065cc2 feat(arch): Add Guard Rails capability-based permission system design
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Guard Rails complement Quality Rails by controlling what agents can do:
- Capability-based permissions (resource:action pattern)
- Read/organize/draft allowed by default
- Execute/admin require explicit grants
- Human-in-the-loop approval for sensitive actions

Examples: email (read/draft , send ), git (commit , force push )

Also:
- Add .admin-credentials and .env.bak.* to .gitignore

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 00:25:53 -06:00
98f80eaf51 fix(scripts): Fix awk env parsing for POSIX compatibility
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Use index() instead of regex capture groups for key extraction
- More portable across different awk implementations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 00:24:31 -06:00
e63c19d158 chore: Cleanup QA reports and improve setup scripts
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Scripts:
- common.sh: Fix select_option to use /dev/tty for interactive prompts
- common.sh: Improve check_docker with detailed error messages
- setup.sh: Add Traefik configuration options
- setup.sh: Add argument validation for --mode, --external-authentik, etc.
- setup.sh: Add fun taglines

QA Reports:
- Remove stale remediation reports
- Keep current pending reports

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 22:53:47 -06:00
cb0948214e feat(auth): Configure Authentik OIDC integration with better-auth
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Add genericOAuth plugin to auth.config.ts with Authentik provider
- Fix LoginButton to use /auth/signin/authentik (not /auth/callback/)
- Add production URLs to trustedOrigins
- Update .env.example with correct redirect URI documentation

Redirect URI for Authentik: https://api.mosaicstack.dev/auth/callback/authentik

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:11:32 -06:00
f2b25079d9 fix(#27): address security issues in intent classification
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Add input sanitization to prevent LLM prompt injection
  (escapes quotes, backslashes, replaces newlines)
- Add MaxLength(500) validation to DTO to prevent DoS
- Add entity validation to filter malicious LLM responses
- Add confidence validation to clamp values to 0.0-1.0
- Make LLM model configurable via INTENT_CLASSIFICATION_MODEL env var
- Add 12 new security tests (total: 72 tests, from 60)

Security fixes identified by code review:
- CVE-mitigated: Prompt injection via unescaped user input
- CVE-mitigated: Unvalidated entity data from LLM response
- CVE-mitigated: Missing input length validation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 16:50:32 -06:00
fd93be6032 feat: Add comprehensive setup wizard foundation
Modeled after Calibr setup.sh pattern (~/src/calibr/scripts/setup.sh).

Implemented (Foundation):
- Platform detection (Ubuntu, Arch, macOS, Fedora)
- Dependency checking and installation
- Mode selection (Docker vs Native)
- Interactive + non-interactive modes
- Comprehensive logging (clean console + full trace to log file)
- Common utility functions library (450+ lines)

Features in common.sh:
- Output formatting (colors, headers, success/error/warning)
- User input (confirm, select_option)
- Platform detection
- Dependency checking (Docker, Node, pnpm, PostgreSQL)
- Package installation (apt, pacman, dnf, brew)
- Validation (URL, email, port, domain)
- Secret generation (cryptographically secure)
- .env file parsing and management
- Port conflict detection
- File backup with timestamps

To Be Implemented (See scripts/README.md):
- Complete configuration collection
- .env generation with smart preservation
- Port conflict detection
- Password/secret generation
- Authentik blueprint auto-configuration
- Docker deployment execution
- Post-install instructions

Usage:
  ./scripts/setup.sh                    # Interactive
  ./scripts/setup.sh --help             # Show options
  ./scripts/setup.sh --dry-run          # Preview
  ./scripts/setup.sh --non-interactive  # CI/CD

Refs: Setup wizard issue (created)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 16:45:56 -06:00