Commit Graph
318 Commits
Author SHA1 Message Date
Arnaud Dartois 8e14d72a9a chore: remove .opencode submodule, now using global opencode-infra plugin
All shared agents, skills, commands, rules are now provided by the
opencode-infra plugin installed globally at ~/.config/opencode/plugins/.
No per-project configuration needed.
2026-08-01 07:58:35 +00:00
Arnaud Dartois 094567234f fix: disable demo seeding by default and skip in tests
- Change Seed:DemoOnStartup default from true to false (safe upgrade)
- Add Seed:DemoOnStartup=false in appsettings.Testing.json
  (prevents 120 integration test failures due to missing admin password)
- Update diagnostic log message accordingly
2026-07-29 14:48:08 +00:00
Arnaud Dartois afc1b2e032 fix: resolve demo admin seeding, Sentry DSN pass-through, and add startup diagnostics
- Replace IsDevelopment() guard with Seed:DemoOnStartup config flag
  (default: true, disable via SEED__DEMO_ON_STARTUP=false)
- Add Seed:AdminLogin (env SEED__ADMIN_LOGIN) to customize demo admin email
- Add Seed:AdminDisplayName (env SEED__ADMIN_DISPLAYNAME) to customize display name
- Add Sentry__Dsn env var to docker-compose files (matches .env convention)
- Increase Heimdall log level to Debug for startup diagnostics
- Add [DIAG] startup logs for Sentry DSN, Data Protection keys, environment
- Add Data Protection key directory diagnostic in DependencyInjection
2026-07-29 14:21:16 +00:00
Arnaud Dartois 100e230af5 chore: update opencode submodule — auto-pipeline 2026-07-29 04:04:43 +00:00
Arnaud Dartois 64753b9ba6 fix(ci): reparation tests integration + infrastructure
- TestHelpers.CreateAdminClientAsync: bootstrap via register normal
  (first user = admin) + active les flags public-registration et
  admin-registration.enabled
- JwtService.GetUserIdFromExpiredToken: utilise GetJwtRefreshKey()
  (methode appelee avec refresh tokens, signes avec Jwt:RefreshKey)
- AuthDataServiceTests.RevokeRefreshTokenAsync_StoresToken:
  utilise SHA256 hash (nouveau comportement ExtractJti fallback)
2026-07-28 15:14:54 +00:00
Arnaud Dartois 663b872dc2 feat(auth): confirmation email + forgot/reset password
#37: Email confirmation flow:
- Nouveaux endpoints: POST /api/auth/confirm-email
- Register envoie email de confirmation si SMTP configure + flag active
- Login verifie EmailConfirmed si email.confirmation.required = true
- Premier admin auto-confirme (evite chicken-and-egg)
- Setting DB: email.confirmation.required (boolean)

#38: Forgot/Reset password flow:
- Nouveaux endpoints: POST /api/auth/forgot-password, POST /api/auth/reset-password
- ForgotPassword genere token et envoie email via IEmailService
- ResetPassword valide token et change le mot de passe
- Pas de divulgation si l email n'existe pas

Infrastructure email existante (IEmailService + SmtpClient) reutilisee.
2026-07-28 15:03:18 +00:00
Arnaud Dartois ba985ed3c2 fix(auth): RegisterAdmin — [Authorize] + feature flag auth.admin-registration.enabled
#14: Remplacé le guard environment (Testing/Development) par:
- [Authorize(Policy = "AdminUsers")] sur l'endpoint
- Feature flag auth.admin-registration.enabled en DB (default: absent = disabled)
- Suppression de la dependance IWebHostEnvironment du controller
- Test mis a jour: bootstrap via register normal, puis flag, puis RegisterAdmin
2026-07-28 14:57:28 +00:00
Arnaud Dartois 450e019617 feat(infra): intégration Sentry/GlitchTip complète
- Upgrade Sentry.AspNetCore v6.7.0 → v6.8.0
- Ajout Sentry base package à Infrastructure (pour SentryErrorReporter)
- Configuration SDK enrichie dans Web et Agent:
  - AutoSessionTracking=false (GlitchTip ne supporte pas)
  - EnableLogs=true (logs structurés)
  - CaptureBlockingCalls=true (détection .Result/.Wait())
  - CaptureFailedRequests=true (capture 4xx/5xx HttpClient)
  - IncludeActivityData=true (DiagnosticSource)
  - SetBeforeSend pour nettoyage PII (password, token, secret)
  - SetBeforeBreadcrumb pour filtrage breadcrumbs
  - SampleRate, AttachStacktrace, MaxBreadcrumbs configurés
  - Release depuis la config, Environment auto
  - StackTraceMode.Enhanced
  - double.Parse avec CultureInfo.InvariantCulture
  - UseSentry avec type explicite SentryAspNetCoreOptions
- Abstraction IErrorReporter dans Application (0 dép. Sentry)
- Implémentation SentryErrorReporter dans Infrastructure
- Enregistrement DI dans Infrastructure
- DSN de développement dans appsettings.Development.json
- .env.example avec Sentry__Dsn et Sentry__TracesSampleRate
2026-07-28 14:52:52 +00:00
Arnaud Dartois 63d610c303 chore: update opencode submodule — auto-pipeline 2026-07-28 14:52:29 +00:00
Arnaud Dartois 1b5395b86b fix(test): update LoginHandlerTests to inject IUserRepository
Breaking: LoginHandler constructor now requires IUserRepository pour
l'audit logging des echecs de login. Test mis a jour.
2026-07-28 14:40:55 +00:00
Arnaud Dartois 234c158a69 fix(auth): audit de securite complet - 12 correctifs
# Fix #28: ProtectedLocalStorage -> ProtectedSessionStorage
#   (donnees token jamais exposees au JS client en Blazor Server)
# Fix #3: GetUserIdFromExpiredToken valide maintenant la signature
#   (plus de ReadJwtToken sans validation)
# Fix #5: API Key handler X-API-Key uniquement (plus de Bearer ambiguité)
# Fix #7: MarkUsed() persiste via SaveChangesAsync()
# Fix #8: Hardcoded permissions (documenté — nécessite migration DB)
# Fix #12: Race condition registration — try/catch DbUpdateException
# Fix #13: Public registration DESACTIVEE par defaut (pas de setting = disabled)
# Fix #15/17: Enable2fa genere et retourne shared key + QR code URI
# Fix #16: Rate limiting specifique 2FA (5 req/min) et RegisterAdmin
# Fix #22/23: RevokeRefreshToken stocke jti (pas token brut)
# Fix #24: Rotation refresh token — ancien token revoque apres refresh
# Fix #39: Audit logging des echecs de login (via IUserRepository)

Breaking: Enable2fa retourne maintenant Enable2faResponse au lieu de Ok()
2026-07-28 14:37:52 +00:00
Arnaud Dartois 485842b135 feat: add CanRegister CQRS query 2026-07-28 13:02:16 +00:00
Arnaud Dartois efe28c9c81 chore: update opencode submodule — auto-pipeline 2026-07-28 13:01:32 +00:00
Arnaud Dartois 25f51781d4 feat: add SetSettingValueAsync to IAuthDataService 2026-07-28 12:56:18 +00:00
Arnaud Dartois 6b2e3d8027 docs: add admin bootstrap first-launch design spec 2026-07-28 11:25:31 +00:00
Arnaud Dartois 1bca0e627a chore: update opencode submodule to bb8c5f9 (Sentry config skill + code review checklist) 2026-07-28 10:44:46 +00:00
Arnaud Dartois edc739dffe fix(sentry): use config pipeline for DSN, add MaxRequestBodySize and ProfilesSampleRate
- Heimdall.Web/Program.cs: use Sentry:Dsn from IConfiguration as primary
  source with legacy SENTRY_DSN env var as fallback (no hardcoded DSN)
- Heimdall.Agent/Program.cs: same pattern applied
- Both: add MaxRequestBodySize=Small and ProfilesSampleRate=0.05
  (previously missing); lower TracesSampleRate to 0.05
- appsettings.json: add Sentry:Dsn entry for discoverability

Resolves codify signal: hardcoded-sdk-credentials (C1)
2026-07-28 10:14:34 +00:00
Arnaud Dartois e8bede3d79 add local specialized agent 2026-07-28 10:26:52 +02:00
Arnaud Dartois 219d9b73b6 feat(ui): polish visuel global — Font Awesome, composants partagés, fix MudMenu 2026-07-27 20:11:31 +00:00
Arnaud Dartois b1c25ac0ae chore: update opencode submodule — daily cron 2026-07-27 19:23:47 +00:00
Arnaud Dartois ca6b8a2eb2 chore: update opencode submodule — no-API-key auto-pipeline
Updates submodule with self-contained auto-pipeline.sh:
- Includes Github trending + Arxiv scraping
- Uses opencode run --auto for analysis (no external API key)
- Detects force-run triggers from Forgejo Action
- Full cycle: research → analyze → implement → learn → heal → commit

Updates .forgejo/workflows/research-improve.yml:
- Now just pushes a trigger file (force-run)
- No API key needed (Action is pure git operations)
2026-07-27 19:19:47 +00:00
Arnaud Dartois 5b8b214d57 feat(ci): add research-improve workflow + auto-pipeline scripts
Adds .forgejo/workflows/research-improve.yml — weekly Forgejo Action
that scrapes AI agent research, generates structured proposals.

Also updates opencode submodule with:
- auto-pipeline.sh (headless processor for Docker host cron)
- research-scrape.sh (Github trending + Arxiv scraper)
- setup-autopipeline-cron.sh (one-shot cron installer)

Architecture:
  Machine A (Forgejo Runner): cron → scrape → commit pipeline signals
  Machine B (Docker Host): cron → docker exec → auto-pipeline.sh → opencode run
2026-07-27 19:13:03 +00:00
Arnaud Dartois 45c6ce82eb perf: add ConfigureAwait(false) to all async calls in library projects
Add ConfigureAwait(false) to all await expressions in Application and
Infrastructure projects (111 files). This follows .NET best practices
for library code to avoid potential deadlocks when consumed from
synchronization contexts (legacy, unit test runners).

Also fix 4 test assertions that check SaveChangesAsync — update to
SaveChangesWithRetryAsync to match the handler changes from Fix 4.
2026-07-27 18:59:12 +00:00
Arnaud Dartois 1635d005cd chore: update opencode submodule to 262ce3e 2026-07-27 18:49:27 +00:00
Arnaud Dartois 03cc53877c chore: update opencode submodule — SkillServer v1.1.0 force-publish + publish-agent fix 2026-07-27 18:49:08 +00:00
Arnaud Dartois 87eb0982a7 refactor: replace URI string concatenation with EndsWith check
Replace new Uri(url.TrimEnd('/') + "/") pattern with explicit
EndsWith('/') check to avoid string concatenation inside URI
construction. Applies to 3 locations:
- Program.cs (Heimdall.Web) - HttpClient base address
- TokenRefreshHandler.cs - raw HttpClient for token refresh
- Program.cs (Heimdall.Agent) - Central service client
2026-07-27 18:43:25 +00:00
Arnaud Dartois 9e58b5bf55 fix: use SaveChangesWithRetryAsync across all handlers
Replace naked SaveChangesAsync(ct) with the project's own
SaveChangesWithRetryAsync(ct: ct) in 5 locations to handle
PostgreSQL serialization conflicts and SQLite SQLITE_BUSY
transient failures:

- UpdateCameraCommand, CreateCameraCommand, DeleteCameraCommand,
  SetCameraCredentialsCommand, AuthDataService
2026-07-27 18:40:23 +00:00
Arnaud Dartois 80b592ba04 fix: remove hardcoded admin seed password from Program.cs
Replace the 'Admin123!Pass' fallback with an InvalidOperationException
that requires Seed:AdminPassword from config or SEED__ADMIN_PASSWORD env
variable. Keeps the env var fallback as second option before throwing.
2026-07-27 18:39:07 +00:00
Arnaud Dartois ec50f6635e fix: remove hardcoded DB password from AppDbContextFactory
The fallback connection string included 'Password=heimdall' as a literal.
Remove the password — the fallback is only for local dev where PostgreSQL
trust authentication is typically used. Production deployments must set
the DATABASE_URL environment variable.
2026-07-27 18:37:54 +00:00
Arnaud Dartois 06927fb9b4 fix: remove stale NtfyToken from migration snapshot
The UserNotificationConfig entity was migrated from Gotify to ntfy
(NtfyUrl replaces GotifyUrl, NtfyEnabled replaces GotifyEnabled).
NtfyToken was never part of the entity but the snapshot still referenced
it, causing PendingModelChangesWarning and 4 integration test failures.

Remove NtfyToken from the Designer.cs and ModelSnapshot.cs to align
the snapshot with the actual entity model.
2026-07-27 18:36:45 +00:00
Arnaud Dartois 9429568fb2 fix(ci): fetch RENOVATE_TOKEN from Vault instead of secrets 2026-07-27 12:08:13 +00:00
Arnaud Dartois a6b2a21ebc fix: corriger les issues mineures du review
🟡 SnapshotUrl: validation sécurité SSRF (scheme + loopback)
🟡 Integration tests: skip graceful sans PostgreSQL (TestContainers)
2026-07-27 09:09:14 +00:00
Arnaud Dartois fba29b3eb4 chore: remove embedded templates repo from tracking 2026-07-27 05:33:58 +00:00
Arnaud Dartois c1eac5431b fix: corriger les 8 issues du code review notifications
🔴 EmailService: implémentation SMTP réelle (System.Net.Mail)
🔴 GetNotificationConfigHandler: CQS — retourne DTO par défaut sans écrire en DB
🟠 NotificationRateLimiter: increment atomique (Interlocked)
🟠 DailyDigestJob/WeeklyDigestJob: comptes événements user-specific
🟠 docker-compose.prod: auth ntfy via NTFY_AUTH_FILE
🟠 Namespace: Heimdall.Web.Controllers (consistant)
🟠 Commentaire 'gotify' → 'ntfy'
🟠 Tests: NotificationsControllerTests (7 tests)
2026-07-27 05:33:53 +00:00
Arnaud Dartois f800103239 feat: remplacer Gotify par ntfy — push notifications multi-utilisateur avec isolation par topic
- Nouveau NtfyService: topic isolé par user (heimdall_{userId})
- Configuration globale Ntfy:BaseUrl + Ntfy:Token (plus de token par user)
- Renommage UserNotificationConfig: Gotify* → Ntfy*
- Migration des colonnes DB: gotify_enabled/url/token → ntfy_enabled/url
- Ajout service ntfy dans docker-compose (binwiederhier/ntfy)
- Mise à jour .env.example avec NTFY__BASE_URL et NTFY__TOKEN
- Suppression GotifyService et IGotifyService
2026-07-27 04:56:16 +00:00
Arnaud Dartois 1080f26591 chore: cleanup gitignore - coverage reports, core dumps, embedded repo 2026-07-26 20:46:04 +00:00
Arnaud Dartois f9be0f1e0d feat: implémenter SignalR hubs (Monitoring, Notifications, Admin) + système de notifications complet
SignalR Hubs:
- MonitoringHub (/hubs/monitoring) — statuts agents/caméras/stockage/GPU jobs
- NotificationsHub (/hubs/notifications) — notifications in-app badge temps réel
- AdminHub (/hubs/admin) — broadcast changements config (Admin only)

Notification System:
- Nouvelles entités: Notification, NotificationTemplate, UserNotificationConfig
- CQRS/MediatR: 6 handlers (list, unread, mark-read, mark-all, config get/update)
- Infrastructure: NotificationService orchestrator + EmailService + GotifyService
- Rate limiter IMemoryCache (20 events/min/camera/type)
- Hangfire jobs: SendNotification, DailyDigest, WeeklyDigest
- NotificationsController API (6 endpoints)
- Blazor UI: NotificationsPage + NotificationBadge
- Migration AddNotifications (3 nouvelles tables)
- 644 nouveaux tests (Domain: 131, Application: 321, Infra: 151, Integration: 120, +autres)
2026-07-26 20:45:35 +00:00
Arnaud Dartois ef3ea9d1ca fix: resolve 7 code quality issues from audit
- Add CancellationTokenSource timeout to DB migration loop (5 min)
- Make seed admin password configurable via env/config
- Improve ExceptionFilter with typed exception handling (409/499/500)
- Document Hangfire.PostgreSql CS0618 pragma with upgrade link
- Narrow CredentialProtector fallback catch to non-empty ciphertext
- Fix ApiBaseUrl in appsettings.json (:5000 -> :8080) for Docker consistency
- Improve HTTPS reverse proxy comment in middleware config

Build: 0 errors, 0 warnings | Tests: 799/799 passed
2026-07-26 19:49:42 +00:00
Arnaud Dartois e426897449 chore: update opencode submodule to f5cb597 2026-07-26 19:34:45 +00:00
Arnaud Dartois 117172adb8 chore: update opencode submodule to 89ad88b
Pins parent to submodule with COG patterns:
- Worker /tmp/ cost optimization
- Graceful MCP dependency levels
- Braindump skill for structured capture
2026-07-26 19:27:58 +00:00
Arnaud Dartois 6c1defb4eb chore: update opencode submodule to 61efbd4
Pins parent to submodule with:
- Use Cases Library (templates/use-cases/)
- CLI Dashboard (scripts/dashboard.sh)
- DAG Workflow Engine (scripts/workflow.sh + skills/dag-workflow/)
2026-07-26 19:23:52 +00:00
Arnaud Dartois 851a3d0686 chore: update opencode submodule to 1013fad
Parent project pins the updated opencode submodule with:
- MCP Runtime Contract rule
- Typed IPC protocol with JSON Schema validation
- Terminal Design System skill
- Secure Execution Boundary (§43)
- Grill Mode for deliberation (§50.10)
- ADR Workflow (§51) with template
2026-07-26 18:03:22 +00:00
Arnaud Dartois 9dd503f305 chore: update opencode submodule — remove agents, SkillServer-only
- Remove 43 agent .md files from submodule (served from skill.tordais.cc)
- Fix opencode.template.json with coordinator primary declaration
- Update INTEGRATION.md, clean agent-registry.yaml
- Fix deprecated agent names in rules
- Update global config prompt to ~/.config/opencode/agents/
- Publish fixed agents to SkillServer (coordinator mode: primary, load_rules/load_skills cleanup)
2026-07-26 17:46:06 +00:00
Arnaud Dartois ae6c5ebfe6 chore: update opencode submodule
- Add all 43 agents to submodule agents/ directory
- Fix YAML frontmatter (UTF-8 special chars, long descriptions)
- Remove hidden: true from all agents for @ menu visibility
- Configure coordinator-agent as primary agent in global config
2026-07-25 19:40:15 +00:00
Arnaud Dartois 3ab27aa9fe chore: update opencode submodule to 85dd8cb
Added shared agent boilerplate rule (29-agent-boilerplate.md):
- Journal Entry format, IPC Protocol, Structured Output
- Self-Verification Checklist, Cross-Domain Peer Referral
- Token savings: ~1,783 lines (15% reduction across all agents)

Removed deprecated agents (perf-agent, dotnet-optimizer-agent)
from local cache — merged into perf-optimizer-agent
2026-07-25 18:58:37 +00:00
Arnaud Dartois 3ddc8f3006 chore: update opencode submodule to 0aa33b8
Massive optimization: 4 agents reduced by 68% average
- mudblazor-agent: 1643 → 203 lines (−88%)
- coordinator-agent: 966 → 304 lines (−68%)
- identity-agent: 649 → 228 lines (−65%)
- ux-ui-agent: 991 → 327 lines (−67%)

Created 6 new skills extracted from agents:
- mudblazor-theming, mudblazor-forms, mudblazor-performance, mudblazor-e2e, mudblazor-migration
- dotnet-identity-authentication

All optimized agents published to SkillServer v2.0.0
Total token savings: ~40-60% per agent dispatch
2026-07-25 18:53:29 +00:00
Arnaud Dartois 5213c0fb25 chore: update opencode submodule 2026-07-25 18:42:55 +00:00
Arnaud Dartois ec4deeaf9f chore(ci): add workflow_dispatch trigger for manual CI runs 2026-07-25 18:38:52 +00:00
Arnaud Dartois 70512e3ab0 chore: update opencode submodule to d567469
Massive cleanup: removed 21 redundant rules (−45% context size)
- Deleted 13 'see skill' pointers (duplicated by auto-loading)
- Deleted 7 research docs (moved to memorizer)
- Extracted ui-frontend-patterns to skill
- Cleaned cross-references in remaining rules
- Updated sync-agents.sh to fetch latest version
- Published coordinator-agent v1.1.0 on SkillServer
2026-07-25 18:29:57 +00:00
Arnaud Dartois 810900cd3e fix(auth): add JWT__RefreshKey config and env var fallback in JwtService
- Add JWT__RefreshKey to .env.example with documentation
- Add JWT__RefreshKey to docker-compose.yml and docker-compose.prod.yml
- Fix JwtService to check both IConfiguration and env vars (JWT__REFRESHKEY)
  for access token key and refresh token key, matching Program.cs pattern
- Fixes 'Jwt:RefreshKey is not configured' 500 error on register/login
2026-07-25 18:02:43 +00:00