Commit Graph
225 Commits
Author SHA1 Message Date
Arnaud Dartois c1b3b3d3b4 feat(cqrs): migrate Events, Agents, Assignments, Discovery, Others to CQRS
- Events: CRUD commands/queries + EventCreatedNotification for SignalR
- Agents: Register (with API key gen), Heartbeat, queries
- Assignments: Assign, Failover, Release commands + queries
- Discovery: 10 handlers delegating to existing probes/services
- Groups/Persons/Settings/Audit/Stats: full CQRS for remaining domains
- Extend IApplicationDbContext with all DbSets
2026-07-22 19:48:16 +00:00
Arnaud Dartois 11f7fd8d20 feat(cqrs): migrate Sites, Auth, Users, Cameras to CQRS
- Sites: CreateSite, UpdateSite, DeleteSite, GenerateToken commands + handlers
- Auth: Login, Register, RefreshToken, 2FA, ChangePassword, Logout commands
- Users: CRUD, roles, sites, lock/unlock, reset-password commands + queries
- Cameras: CRUD, SetCredentials commands + queries
- Add IApplicationDbContext abstraction for Clean Architecture
- Add ICredentialProtector, IJwtService interfaces to Application layer
- 0 build errors, 0 warnings
2026-07-22 19:43:13 +00:00
Arnaud Dartois 649af93f56 feat(cqrs): add MediatR, AutoMapper and pipeline infrastructure
- Add MediatR 12.5.0, AutoMapper 13.0.1 packages
- Create ValidationBehavior (FluentValidation pipeline)
- Create LoggingBehavior (structured logging pipeline)
- Create MappingProfile with IMapFrom<T> convention
- Make ServiceResult properties public for pipeline use
- Update Application DI with MediatR + AutoMapper registration
2026-07-22 19:31:51 +00:00
Arnaud Dartois 31794c86c0 chore: update opencode submodule to publish-agent scripts 2026-07-22 15:43:03 +00:00
Arnaud Dartois 416a5971ae chore: update opencode submodule to 3690405 (skillServer cleanup) 2026-07-22 15:28:26 +00:00
Arnaud Dartois eea8813307 chore: install superpowers plugin, update opencode submodule to 136706e 2026-07-22 15:15:36 +00:00
Arnaud Dartois 9c424f1011 chore: update opencode submodule to 65a57d4 (agents from SkillServer) 2026-07-22 15:08:22 +00:00
Arnaud Dartois 71a9145cf5 refactor(ci): use docker-images list (image + dockerfile per line) 2026-07-22 14:41:21 +00:00
Arnaud Dartois 4d4ae955d9 refactor(ci): add release + renovate workflows (identical across all projects)
All 3 projects share exact same 3 workflows:
- ci.yml (ci-full)     → build, test, coverage, docker, trivy
- release.yml (ci-release) → version, publish, release, docker
- renovate.yml (ci-renovate) → dependency updates
2026-07-22 14:20:14 +00:00
Arnaud Dartois ff65c73724 refactor(ci): use ci-full mega-action (identical across all projects)
All 3 projects now share the exact same CI pipeline via
nonobis/templates/.forgejo/actions/ci-full. Only params differ.
2026-07-22 13:52:59 +00:00
Arnaud Dartois cd7bdea66c chore: update opencode submodule to 0e4b768 (skills removed, agents English) 2026-07-22 13:50:38 +00:00
Arnaud Dartois ef2f3886e3 fix(tests): use Coverlet msbuild props instead of --collect (quoting issue)
Vault auth now working! Tests failed due to bad --collect quoting.
Switched to -p:CollectCoverage=true (Cleaner syntax).
2026-07-22 13:48:29 +00:00
Arnaud Dartois 390c7430e8 chore: update opencode submodule to 3efb503 (agents on skill.tordais.cc) 2026-07-22 13:44:04 +00:00
Arnaud Dartois 29eecf869b fix(ci): sonar secrets from Vault env (not forgejo secrets) 2026-07-22 11:14:26 +00:00
Arnaud Dartois f88d9e52d6 fix(ci): enable Vault (VAULT_URL=https://vault.tordais.cc) 2026-07-22 10:28:46 +00:00
Arnaud Dartois 6fc89d18c6 chore: update opencode submodule to c63c04c (skills metadata) 2026-07-22 10:14:25 +00:00
Arnaud Dartois 61613155d2 chore: update opencode submodule to ebda7d8 (merge perf agents) 2026-07-22 10:06:35 +00:00
Arnaud Dartois 9f35da2bc2 chore: update opencode submodule to 299307a (OCP dispatch via registry) 2026-07-22 09:58:01 +00:00
Arnaud Dartois 3741a9367c chore: update opencode submodule to db3adaf (ISP dynamic instruction loading) 2026-07-22 09:51:40 +00:00
Arnaud Dartois 3a317cb9fe chore: update opencode submodule to 69f97c0 (archive research + dedup) 2026-07-22 09:46:50 +00:00
Arnaud Dartois 4364578de1 fix(ci): Vault is mandatory — no fallback to Forgejo secrets
- enable-openid-connect: true
- Vault steps sont OBLIGATOIRES si VAULT_URL défini
- fallback: 'false' sur vault-auth + vault-secrets
- Docker push utilise uniquement env vars Vault (plus secrets.*)
2026-07-22 09:37:32 +00:00
Arnaud Dartois 923bc196a0 feat(ci): add Vault OIDC auth with fallback to Forgejo secrets
- Vault auth via OIDC JWT (enable-openid-connect)
- Fallback silencieux si Vault pas dispo
- VAULT_URL à renseigner dans les env du workflow
- TEMPLATES_PAT reste seul secret Forgejo nécessaire
2026-07-22 09:35:52 +00:00
Arnaud Dartois 2bbbce797f chore: update opencode submodule to 1af6761 (split enforcement.md) 2026-07-22 09:30:13 +00:00
Arnaud Dartois 519ba6466c chore: update opencode submodule to d007d19 (kiss-solid skill + output template) 2026-07-22 09:15:50 +00:00
Arnaud Dartois 6d075e37a4 feat(ci): unified pipeline with all features (coverage, sonar, e2e, trivy, gitversion, cleanup)
All features controlled by env vars. Same structure across all projects.
2026-07-22 09:15:16 +00:00
Arnaud Dartois 91d932f4d3 chore: update opencode submodule to f360772 (agent tags + KISS/SOLID) 2026-07-22 09:03:36 +00:00
Arnaud Dartois e4d6d22e31 fix(ci): checkout templates via PAT + composite actions
Forgejo ne supporte pas le workflow_call cross-repo privé.
Solution: checkout du repo templates via PAT (secret TEMPLATES_PAT)
+ utilisation des actions composites depuis .ci/.forgejo/actions/

Le PAT doit être configuré dans Settings → Actions → Secrets → TEMPLATES_PAT
2026-07-22 08:52:08 +00:00
Arnaud Dartois c8827b63e6 chore: update opencode submodule to fd20d5e (peer-referral overhaul)
20 files changed in submodule: mandatory peer-referral & deliberation
council for all agents. See submodule commit for details.
2026-07-22 08:34:21 +00:00
Arnaud Dartois 1e96fcc025 chore: update opencode submodule (cicd-pipeline templates docs) 2026-07-22 08:25:48 +00:00
Arnaud Dartois d1c98bb7e2 fix: use remote nonobis/templates workflow_call (submodule not supported by Forgejo Actions)
- Remove .forgejo/templates submodule (incompatible with workflow_call resolution)
- Use remote uses: nonobis/templates/.forgejo/workflows/dotnet-ci.yml@main
- Update opencode submodule with cicd-pipeline skill update
2026-07-22 08:24:13 +00:00
Arnaud Dartois 1ffa5de28c fix: add ./ prefix to local workflow_call path (Forgejo requirement) 2026-07-22 08:11:49 +00:00
Arnaud Dartois d4981eda17 feat: migrate CI to shared templates submodule
- Add .forgejo/templates submodule (nonobis/templates)
- Replace 187-line CI with 41-line workflow_call using dotnet-ci.yml
- All patterns (PostgreSQL LXC, Docker multi-image, coverage, cleanup)
  now come from shared templates
- CI size reduction: -78%
2026-07-22 08:08:31 +00:00
Arnaud Dartois b727e5b672 fix(ci): add disk cleanup, replace sudo with su for LXC runner
LXC runner lacks sudo — use su - postgres instead.
Runner disks accumulate Docker images and temp files from prior CI
runs. Add pre-build and post-build cleanup steps (docker system prune,
apt-get clean, rm -rf /tmp /var/tmp) to both build-and-test and
docker-build jobs, with if: always() on post steps.
2026-07-22 07:20:22 +00:00
Arnaud Dartois 716eaf0470 fix(ci): store postgres data on tmpfs to avoid LXC disk limits
The LXC runner has very limited disk space. PostgreSQL's EnsureCreated()
and Migrate() calls in tests create table files per test class, quickly
exhausting the available space with "No space left on device" errors.

Move PostgreSQL data directory to /dev/shm (tmpfs backed by RAM) so
table creation during tests uses memory instead of disk. Use direct
initdb/pg_ctl binary paths instead of pg_ctlcluster to control data
location precisely.
2026-07-21 21:00:50 +00:00
Arnaud Dartois 4d79f416a7 fix(ci): replace postgres service with apt-get for LXC runner
The Forgejo runner uses a Debian 12 LXC auto-scaler that does not
support Docker service containers. PostgreSQL was defined as a
services container in ci.yml but never started, causing all
DB-dependent tests to fail with "Connection refused to 127.0.0.1:5432".

Remove the services section and add a Start PostgreSQL step that
installs PostgreSQL via apt-get, configures pg_hba.conf for password
auth, starts the cluster, creates the heimdall user and database, and
verifies connectivity with pg_isready.
2026-07-21 20:08:55 +00:00
Arnaud Dartois 0ef4642f6d fix(tests): restore DATABASE_URL fallback for CI in shared PostgreSqlContainerFixture
The shared fixture (Heimdall.TestCommon) was refactored from per-project
fixtures but lost the DATABASE_URL env var check. Without it, the fixture
always starts a Testcontainers PostgreSQL container, which fails in CI
when Docker disk space is exhausted (initdb: No space left on device).

Now checks DATABASE_URL first — if set (CI mode), skips Testcontainers
and uses the CI-provided PostgreSQL service. Falls back to Testcontainers
for local development.
2026-07-21 19:59:27 +00:00
Arnaud Dartois 2d0202b706 chore: update opencode submodule 2026-07-21 19:41:26 +00:00
Arnaud Dartois a44bb4be4b chore: update opencode submodule to f3a3032 — integrate all agents/scripts/MCP into active workflow 2026-07-21 19:28:26 +00:00
Arnaud Dartois 513cb508f6 chore(submodule): update opencode submodule to 1b113fb (codify test pattern) 2026-07-21 19:12:07 +00:00
Arnaud Dartois 6825880b52 fix: share single PostgreSQL container across test projects via static ref-count
Use a static PostgreSqlContainer with reference counting so both
Infrastructure and Integration test projects share one PostgreSQL
container instead of each starting their own. Fixes resource
conflict in CI where only the first test project could connect.
2026-07-21 19:05:54 +00:00
Arnaud Dartois b167c2afcf fix: share one PostgreSQL Testcontainer across all test projects
Create Heimdall.TestCommon project with a single PostgreSqlContainerFixture
shared by both Infrastructure and Integration tests. This prevents Docker
resource conflicts from starting two PostgreSQL containers and ensures
both test suites connect to the same database instance.

- Move shared fixture to tests/Heimdall.TestCommon
- Remove duplicate fixtures from each test project
- Keep test isolation (truncation) and FK fix from previous commit
- Revert DATABASE_URL env var check (Testcontainers works in CI)
2026-07-21 18:48:39 +00:00
Arnaud Dartois 53e0d4c199 fix: resolve CI test failures after InMemory->Testcontainers migration
Three issues fixed:
- Camera.AssignAgent(Guid.Empty) violated FK constraint; changed to
  nullable Guid? and pass null on camera release
- Test fixtures now check DATABASE_URL env var first, falling back to
  Testcontainers locally (CI has no Docker socket)
- Added database truncation before each test via IAsyncLifetime to
  prevent shared state between test methods (InMemory was fresh per test,
  real PostgreSQL persists data)
2026-07-21 17:46:32 +00:00
Arnaud Dartois 58a3ce5b1b chore: vire toute trace d'InMemory, remplace par Testcontainers PostgreSQL
- Supprime InMemory de tous les .csproj (Infrastructure, Domain.Tests, IntegrationTests)\n- Supprime le branchement Database:Provider=InMemory de DependencyInjection.cs\n  (plus que du PostgreSQL natif)\n- Infrastructure.Tests: CameraAssignment + CameraEvent tests -> Testcontainers\n- PostgreSqlContainerFixture ajoute aux Infrastructure.Tests\n- appsettings.Testing.json: retire Database:Provider et Hangfire:Enabled\n- 4 tests echouent encore: bugs pre-existants masques par InMemory\n  (FK non respectees, donnees de test erronees)\n\nTests: 222/226 passed (4 pre-existants lies aux FK)
2026-07-21 12:19:43 +00:00
Arnaud Dartois ee7894646f test: remplace InMemory par Testcontainers PostgreSQL
- Ajoute Testcontainers.PostgreSql v4.13.0\n- PostgreSqlContainerFixture: collection fixture xUnit avec postgres:17-alpine\n- HeimdallWebApplicationFactory: accepte connectionString pour vrai PostgreSQL\n- PostgresTestBase: classe de base pour tous les tests integration\n- Ajoute [Collection("Postgres")] aux 9 classes de test\n- Database:MigrateOnStartup active quand PostgreSQL est utilise\n- Programme le Hangfire (skip en test via isTesting)\n\nAvant: InMemory (pas de contraintes, comportement different)\nApres: Vrai PostgreSQL dans un container temporaire\n\nTests: 226/226 passed (61 integration avec vrai PostgreSQL)
2026-07-21 10:24:11 +00:00
Arnaud Dartois e309611f80 fix(ci): skip Hangfire en Testing pour eviter crash PostgreSQL
- Ajout isTesting = builder.Environment.IsEnvironment("Testing")\n  Les tests WebApplicationFactory n'ont pas de PostgreSQL\n- Hangfire DI + recurring jobs skips si isTesting\n- Compatible avec appsettings.Testing.json (Hangfire:Enabled=false retire)\n\nFix le CI qui plantait: 'Failed to connect to 127.0.0.1:5432'\nTests: 226/226 passed
2026-07-21 10:16:19 +00:00
Arnaud Dartois 27b6025565 fix(startup): Hangfire toujours actif en prod, migrations auto, crash boucle corrige
- Hangfire: retire le flag Hangfire:Enabled (toujours actif si DATABASE_URL\n  est defini, skip automatiquement en test sans config)\n- Database:MigrateOnStartup: default true en Production (.IsProduction())\n  Plus besoin de variable d'env pour que les migrations s'executent\n- Recurring jobs registers dans if(connectionString) pour eviter le\n  crash 'No service for IRecurringJobManager' quand Hangfire est skip\n- Corrige le crash boucle 'relation roles does not exist' apres reset DB\n\nBuild: 0 errors, 0 warnings\nTests: 226/226 passed
2026-07-21 09:57:22 +00:00
Arnaud Dartois 7a02a87e4c fix(startup): migration automatique en Production meme sans config
- Database:MigrateOnStartup default now true in Production\n  (GetValue<bool?> null-coalesce app.Environment.IsProduction())\n  Evite le crash 'relation roles does not exist' apres reset DB\n- En Testing: reste false (comportement inchange)
2026-07-21 09:46:33 +00:00
Arnaud Dartois 7be5d42e85 fix(identity): DB refresh tokens, auto-refresh handler, 2FA endpoints, JWT fix
- DB-backed RevokedRefreshToken entity + migration (remplace ConcurrentDictionary\n  en memoire, fonctionne en multi-instance et survive aux redemarrages)\n- TokenRefreshHandler: auto-refresh des JWT 401 via DelegatingHandler\n  (avec SemaphoreSlim pour eviter les refresh storms)\n- Fix: GenerateRefreshToken genere maintenant un JWT valide au lieu de\n  bytes aleatoires (ValidateRefreshToken attendait un JWT - flux casse)\n- Fix: Login.razor gere Requires2fa correctement (affiche champ code 2FA)\n- Ajout: endpoints POST /api/auth/2fa/enable et /2fa/disable\n- Ajout: Disable2faAsync dans IAuthService\n- Fix: GenerateTemporaryPassword garantit les 4 categories de charactere\n  (uppercase, lowercase, digit, non-alphanumeric)\n- Fix: TestFactory ajoute Jwt:RefreshKey manquant\n\nBuild: 0 errors, 0 warnings\nTests: 226/226 passed
2026-07-21 08:57:53 +00:00
Arnaud Dartois 940e826865 fix(identity): corrige JWT role claims, password policy, et consistency
- JWT role claims: string.Join -> ClaimTypes.Role individuels (debloque [Authorize(Roles)])\n- Password policy: RequireUppercase=true, RequireNonAlphanumeric=true\n- JWT validation params extraits en methode partagee (anti-duplication)\n- Retours 401 uniformises avec body structure\n- Champ Langue ajoute dans le dialog d'edition utilisateur\n\nBuild: 0 errors, 0 warnings\nTests: 226/226 passed
2026-07-21 08:47:24 +00:00
Arnaud Dartois af8c7aa037 chore: update opencode submodule to 5aaef7b — identity + UI mega upgrade
New identity skill (2448 lines), agent (616 lines), rule.
Enhanced UI skills: mudblazor-agent, ux-ui-agent, qa-automation,
dotnet-frontend-razor, 28-ui-frontend-patterns.
Registered in 14-enforcement.md.
2026-07-21 08:02:46 +00:00