2026-06-09 06:41:28 +03:30
|
|
|
using Microsoft.AspNetCore.Routing;
|
2026-06-09 12:18:30 +03:30
|
|
|
using Microsoft.EntityFrameworkCore;
|
2026-06-09 06:41:28 +03:30
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2026-06-09 12:18:30 +03:30
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
|
|
using TeamUp.Modules.Governance.Auditing;
|
|
|
|
|
using TeamUp.Modules.Governance.Endpoints;
|
2026-06-10 07:45:35 +03:30
|
|
|
using TeamUp.Modules.Governance.Gate;
|
2026-06-09 12:18:30 +03:30
|
|
|
using TeamUp.Modules.Governance.Persistence;
|
2026-06-10 07:45:35 +03:30
|
|
|
using TeamUp.SharedKernel.Ai;
|
2026-06-09 12:18:30 +03:30
|
|
|
using TeamUp.SharedKernel.Auditing;
|
2026-06-09 06:41:28 +03:30
|
|
|
using TeamUp.SharedKernel.Modularity;
|
2026-06-09 12:18:30 +03:30
|
|
|
using TeamUp.SharedKernel.Persistence;
|
2026-06-09 06:41:28 +03:30
|
|
|
|
|
|
|
|
namespace TeamUp.Modules.Governance;
|
|
|
|
|
|
2026-06-09 12:18:30 +03:30
|
|
|
/// <summary>Autonomy dial, the action gate, the review inbox, the audit log (M5). M1 ships the audit log.</summary>
|
2026-06-09 06:41:28 +03:30
|
|
|
public sealed class GovernanceModule : IModule
|
|
|
|
|
{
|
|
|
|
|
public string Name => "governance";
|
|
|
|
|
|
|
|
|
|
public void Register(IServiceCollection services, IConfiguration configuration)
|
|
|
|
|
{
|
2026-06-09 12:18:30 +03:30
|
|
|
var connectionString = configuration.GetConnectionString("Postgres")
|
|
|
|
|
?? throw new InvalidOperationException("Missing connection string 'ConnectionStrings:Postgres'.");
|
2026-06-09 06:41:28 +03:30
|
|
|
|
2026-06-09 12:18:30 +03:30
|
|
|
services.AddDbContext<GovernanceDbContext>(options => options.UseNpgsql(connectionString));
|
|
|
|
|
services.AddScoped<IModuleDbContext>(sp => sp.GetRequiredService<GovernanceDbContext>());
|
|
|
|
|
services.AddScoped<IAuditLog, AuditLog>();
|
2026-06-10 07:45:35 +03:30
|
|
|
services.AddScoped<HeldActionExecutor>();
|
|
|
|
|
services.AddScoped<IActionGate, ActionGate>();
|
2026-06-09 12:18:30 +03:30
|
|
|
services.TryAddSingleton(TimeProvider.System);
|
2026-06-09 06:41:28 +03:30
|
|
|
}
|
2026-06-09 12:18:30 +03:30
|
|
|
|
|
|
|
|
public void MapEndpoints(IEndpointRouteBuilder endpoints) => GovernanceEndpoints.Map(endpoints);
|
2026-06-09 06:41:28 +03:30
|
|
|
}
|