EN | DE

Architecture

Deutsch · English

Last updated: 2026-11-30 (D-096: dead code removed, MCP stubs gone, shadow mode and measurement switches removed; before that 2026-11-28: D-093: review rounds with advisors and the final style edit, the shipped way, next to the direct path; additive migration AddReviewRounds; before that 2026-11-27: D-092: one baseline migration, tables and columns of removed parts dropped; second addendum to D-087: "Extra careful" removed, one setup; D-091: stage 8d, document brought to the current state: only the direct path runs, the removed parts are gone from the description; before that 2026-11-26: pointer to the switches of the order features and the page /how-it-works; 2026-11-24, D-067: run warnings, Runs.Outcome, fail-loud start and snapshot handling, preparation timeout, in-process live updates, end-to-end tests; 2026-11-22, D-066: model matrix; 2026-08-04, D-064: model catalog for CLI providers)

Atelier turns a person's request and files into a finished text. The unit the person sees is the order; runs are the technical record underneath (one run per version of an order). Since D-093 the shipped way of working is the path with review rounds (reviewed): a planning advisor, one writer, several separate checks, revisions that are checked again, and a final style edit. The simpler direct path (direct, one writing call with at most one correction) stays as the way back (Review:Mode = Off). The earlier ways (the crew review loop, composed teams, the learning loop, the agentic tool path, the vector knowledge base, specialization packs, finishing steps and the workshop editors) were removed in stage 8d (D-091); the advisors and review rounds of today are a new design, not that code. The git history and the decisions log keep the older descriptions.

Layer diagram

┌──────────────────────────────────────────────────────────────────┐
│                     Frontends (two adapters)                     │
│  ┌──────────────────────────────┐  ┌───────────────────────────┐ │
│  │  Web UI (Blazor Server)      │  │  MCP server (/mcp)        │ │
│  │  /start, /work, /orders/{id} │  │  submit_order,            │ │
│  │  /runs, /runs/{id}           │  │  get_order_status,        │ │
│  │  cookie auth                 │  │  get_order_result, ...    │ │
│  └──────────────┬───────────────┘  └─────────────┬─────────────┘ │
└─────────────────┼────────────────────────────────┼───────────────┘
                  ▼                                ▼
┌──────────────────────────────────────────────────────────────────┐
│  Application layer: IOrderService, IRunService, intake, sources, │
│  profile ("About me"), providers, auth and OAuth                 │
└────────────────────────────────┬─────────────────────────────────┘
                                 ▼
┌──────────────────────────────────────────────────────────────────┐
│  Background services: intake worker, run orchestrator,           │
│  source cleanup, OAuth cleanup, model catalog warm-up            │
└────────────────────────────────┬─────────────────────────────────┘
                                 ▼
┌──────────────────────────────────────────────────────────────────┐
│  Geef SDK pipeline: reviewed (shipped) or direct (way back)      │
│  grounding → plan → write → checks → revise and recheck →        │
│  final style edit → finalize → report                            │
└────────────────────────────────┬─────────────────────────────────┘
                                 ▼
┌──────────────────────────────────────────────────────────────────┐
│  Persistence: Postgres via EF Core; uploaded files on a volume   │
└──────────────────────────────────────────────────────────────────┘

Solution structure

Geef.Atelier.slnx
├── src/
│   ├── Geef.Atelier.Core/           // domain records, rules without LLM or database, configuration
│   │                                // classes, repository contracts
│   ├── Geef.Atelier.Application/    // services: orders, runs, intake, sources, profile, providers,
│   │                                // model assignment, auth, OAuth
│   ├── Geef.Atelier.Infrastructure/ // EF Core, LLM clients, model catalog, both pipelines,
│   │                                // intake worker, research (web search), source extraction,
│   │                                // order export, event sink
│   ├── Geef.Atelier.Web/            // Blazor Server UI, HTTP endpoints, orchestrator, DI composition
│   └── Geef.Atelier.Mcp/            // class library: MCP tools, server instructions, skill;
│                                    // hosted in the Web project
├── tests/
│   └── Geef.Atelier.Tests/          // xUnit; EndToEnd/ = end-to-end tests
└── tools/                           // Eval (Python), IntakeEval, FactCheckEval, ResearchEval,
                                     // HashPassword
  • Core needs no database and no LLM, so its rules are testable on their own.
  • Application holds the use cases and depends only on Core.
  • Infrastructure encapsulates the external dependencies (Postgres, LLM APIs, web search, Geef SDK).
  • Web is the only host. Mcp is a class library without a host of its own: the endpoint /mcp lives in the Web project, shares its DI container and calls the same services, without an HTTP hop in between.

Orders and sources (D-069, D-070)

Table Content
Orders The person's request word for word, entry (Web/Mcp), state (Analyzing, NeedsInput, Ready, Cancelled), owner, the record of the questions and answers, the research result
Sources One uploaded file: extracted text with page markers ([[page N]]), counts, quality, warnings, path of the kept original, expiry while no order uses it
OrderSources Which source belongs to which order, with role, position and page selection (1-40,55)
RunSourceUsages Which file went into which run, in which mode (FullText, FullTextWithMap) and with how many characters

Runs.OrderId/Runs.OrderVersion link a run to its order. OrderService (Application) validates and creates an order; OrderStateResolver (Core) derives the display state from Orders.State and the current run only. Size limits come from SourceBudgetPlanner.Classify, which the start page, the order service and the source block of the writer (SourceBlockRenderer) share. Text is extracted from uploads in a separate, memory-limited process (Sources:ExtractionMode = Isolated).

From request to run. An order starts either directly with its first run, or, when questions are enabled for it (Orders:IntakeMode = On), in state Analyzing: OrderIntakeWorker lets the clarifier (LlmClarifier) read the request, QuestionGate keeps at most three short questions, and the order waits in NeedsInput until the person answers or skips (or the wait of Intake:NeedsInputAutoStartAfter ends). The questions come only before writing, never during it.

Changing a finished text ("Change something", revise_order) adds a run as the next version. It is seeded with the text of the shown version (Runs.SeedDraftText, Runs.ParentRunId) and carries the person's wish in Runs.RevisionHint.

The pipeline with review rounds (D-093)

The setup reviewed exists only in code (SystemCrew). ReviewedPipelineAssembler builds it with a ledger per run (ReviewLedger), which holds everything that outlives a pass: the standard, the findings per version, the best version and what the style edit delivered. The rules are pure functions in Core/Domain/Review.

Part Code
Rounds, strategy and policy Infrastructure/Pipeline/Review/RoundExecutor.cs, StagedEvaluationStrategy.cs, ReviewRoundsPolicy.cs, StyleRoundSettlement.cs, ChampionFinalizer.cs
Advisors and model checks Pipeline/Review/Advisors/, Pipeline/Review/Reviewers/
Final style edit Pipeline/Review/Style/ (the prompt lektorat.de.md is embedded and hash-checked)
Rules without a model Core/Domain/Review/ (quotes, standard, findings, plan, acceptance, stop rules, budgets, style guard, fallback)

Facts the wiring relies on: the SDK's own choice of the best draft and its advisor advice channel are not used (both live in the ledger); the finalizer makes no model call, never throws and gives the same result twice; the style edit is a pass of the loop; an advisor catches every failure, its own time limit included, and puts a substitute into the ledger. The calls of the advisors, the checks and the style edit pass IModelCallGate (Review:MaxConcurrentCalls; the writer does not), and such a role's time limit starts after the gate. Each gateway role asks for x-cli-proxy-failover: same-model and gets at most one second try with the other provider per call; in a recheck, a model check that still failed gets one more attempt at the end of the round if budget and time allow it. Limits and stop rules: D-093.

The direct path pipeline

The setup direct, only in code (SystemCrew): writer, automatic checks without a model (DeterministicChecksReviewer) and fact check (SourceFactCheckReviewer); at most two passes, that is at most one correction. New runs use it while Review:Mode is Off for the person.

IPipelineAssembler has two production assemblers, ReviewedPipelineAssembler and DirectPipelineAssembler; PipelineAssemblerSelector refuses any run no assembler accepts. AtelierPipelineFactory builds the Geef pipeline from the run's snapshot:

Its steps (the grounding is shared with the path with review rounds):

  1. OrderGroundingStep loads the order and its files, renders the files into the background document, reads the rules the request states, records the RunSourceUsages, prepares the material of the fact check and fixes the fact-check mode of the run (Runs.FactCheckMode). For the first version of an order without files it asks OrderResearchService for passages from the web (Tavily; switch Research:Mode). This order grounding step plus the web research is the only grounding there is.
  2. DirectWriterExecutor writes the text. With a CLI provider it writes into a document (draft.md) and asks the gateway not to switch to another CLI. In a correction pass it gets only the blocking findings of the pass before. Notes of the writer (assumptions, open points) are split off the text. An empty or unchanged answer is never accepted.
  3. Checks run after each pass. Which findings may start the correction depends on the check and on Direct:FactCheckMode (Off, Shadow, Report, On; D-073).
  4. MarkdownFinalizer returns the text. When the checks do not pass within the allowed passes, the best-effort text of the SDK is delivered with its open points.
  5. Report: DirectReportBuilder builds the RunReport (constraints, check results of the delivered text, placeholders, files used, read evidence, notes), stored in Runs.ReportJson before the outcome is recorded. The "What was checked" sentences of the web page and of get_order_result come from it.

Convergence policy: DefaultConvergencePolicy built from the Convergence section (ConvergenceOptions) and overridden by the setup (two passes, no abort on a critical finding, no regression detection). A reviewer that fails for technical reasons does not block; the run records a warning.

Run orchestrator

RunOrchestratorService (hosted in Web) polls the database every Orchestrator:PollingInterval (2 s), runs at most Orchestrator:MaxConcurrentRuns (5) runs at once and takes only Pending runs with a snapshot, claiming each with one atomic update to Running. It assumes a single instance: the crash recovery at start resets every Running run.

For each run it reads the snapshot strictly, selects the assembler, runs the pipeline with PostgresEventSink (events, iterations, findings, status and text; live updates through IRunNotifier), stores the costs, lets the assembler write the report and then records the outcome. A watcher polls Runs.CancellationRequested; a cancellation or a service stop ends the run as Aborted. An unexpected error ends it as Failed with one of a few fixed plain sentences; the details go to the log only. When a run with review rounds already has a best version at that point, that text is delivered instead (status Failed, outcome DeliveredWithOpenPoints, warning run.stopped_early).

Crash recovery at start: every run still Running becomes Failed ("Service restarted"); Pending runs without a snapshot that are older than this instance become Failed; runs with a terminal status but without Outcome (stopped while their result was being stored) get an outcome and a warning (see below).

Setups, snapshots and models

Each run stores a CrewSnapshot (JSON in Runs.CrewSnapshot): schema version, setup name, the full writer profile, the check profiles, the evaluation strategy and the convergence override. It is built by ICrewService from the code-only profiles: the model matrix (ModelMatrix, IModelAssignmentService, D-066) assigns a model to every role with a slot, and model aliases are resolved to concrete ids. There are two setups, reviewed and direct; the review switch picks one when the run is created, and the snapshot of reviewed also holds the role profiles of the advisors, the style editor and the two checks of the style edit. There are no user-editable profiles or templates any more.

Data model

One migration, Baseline (D-092), builds the whole schema from an empty database and inserts the rows a fresh installation needs (system providers, placeholder of the site settings). Later migrations are added on top of it (AddReviewRounds, D-093, adds nullable columns, so an older image still runs on the database). At start, EnsureStartsFromBaselineAsync refuses a database that does not start from the baseline (entries in the migration history but not the baseline, or tables without a history) before anything is written; a database with the baseline plus later migrations still starts. The EF Core model maps these tables, and the database holds no others:

Group Tables
Orders and files Orders, Sources, OrderSources, RunSourceUsages, UploadTickets, SourceRefusals
Runs Runs, Iterations, Findings, Events, RunWarnings, IterationActorCosts
Intake and profile UserProfiles; OrderIntakeShadows is still in the model but no code writes or reads it any more (D-096), a later migration drops it
Accounts and settings Users, Providers, SiteSettings
OAuth 2.1 OAuthClients, OAuthAuthorizationCodes, OAuthAccessTokens, OAuthRefreshTokens, OAuthAuditLog

Runs

Column Type Note
Id uuid (PK)
CreatedAt / StartedAt / CompletedAt timestamptz the last two nullable
Status varchar(50) Pending / Running / Completed / Failed / Aborted
BriefingText text the briefing the writer gets
FinalText text nullable; the delivered text
WordCount int nullable; words of FinalText
ErrorMessage text nullable; a fixed plain sentence for the user
TokensTotal int accumulated over the LLM calls
TotalCostEur, LlmCostEur numeric nullable; cost tracking
CachedInputTokens, ReasoningTokens int nullable; subsets of the tokens
CancellationRequested bool set when the user wants to cancel
CreatedByUser text nullable; owner (run isolation, D-042)
CrewTemplateName varchar(200) nullable; setup name (reviewed, direct)
CrewSnapshot jsonb nullable; the snapshot of the setup
ParentRunId uuid nullable; the run this one resumes or changes
SeedDraftText text nullable; text the first pass starts from
RevisionHint text nullable; the change the person asked for
Outcome int nullable; 0 = Converged, 1 = DeliveredWithOpenPoints, 2 = Failed, 3 = Aborted. See Run outcome
DeliveredIteration int nullable; the pass whose text was delivered
ReportJson text nullable; the RunReport (schema 3 with review for runs with review rounds)
OrderId uuid (FK→Orders) nullable; ON DELETE CASCADE. Every run the application creates has an order
OrderVersion int nullable; unique per order (UX_Runs_OrderId_OrderVersion, which also serves lookups by order)
FactCheckMode varchar(20) nullable; the fact-check mode of the run

RunWarnings

Problems a run worked around instead of stopping (D-067). Deleted together with the run.

Column Type Note
Id uuid (PK)
RunId uuid (FK→Runs) indexed
Iteration int nullable; pass in which the problem occurred
Source varchar(100) grounding, review, model-assignment, llm, run, intake, advisor or style (RunWarningSources)
Code varchar(100) stable machine-readable code, e.g. grounding.research_failed, grounding.source_warning, review.reviewer_failed, llm.failover, writer.partial_read, run.result_not_saved, run.restarted_while_finishing, run.stopped_early, advisor.plan_failed, review.not_fully_checked, style.not_applied (RunWarningCodes, DirectWarningCodes).
Message text short plain-English explanation for the user
CreatedAt timestamptz

Iterations, Findings, Events

  • Iterations: RunId, IterationNumber, ArtifactText (the text after the pass), cost and token columns of writer and checks; for runs with review rounds Kind (Draft, Revision, Repair, StylePass), Decision (for example accepted, rejected, repair, style_applied, style_not_used) and AdvisorsCostEur (migration AddReviewRounds, additive).
  • Findings: IterationId, ReviewerName, Severity, Message, optional Category, Code and Quote; for review rounds CriterionId and Disposition (Blocking, Hint, Unverified).
  • Events: RunId, EventType (from the Geef event-sink vocabulary), PayloadJson.

LLM provider layer

Providers are rows of the Providers table (system providers such as openrouter, claude-cli and codex-cli plus CLI providers that an administrator adds). For HTTP providers the row holds the connection; for any other name (the CLI providers such as claude-cli and codex-cli, or a name the provider service does not know) it comes from Llm:ProvidersFallback in the configuration. ILlmClientResolver returns an ILlmClient: OpenAiResponsesClient for endpoints on api.openai.com, otherwise OpenAiCompatibleClient. The cli-proxy side container (FastAPI, Python) offers the subscription CLIs behind OpenAI-compatible endpoints, one per CLI (for example http://cli-proxy:8090/v1/claude). A call that must not move to another CLI asks the gateway for x-cli-proxy-failover: same-model (D-090).

The final style edit uses its own HTTP client llm-style without automatic retries (a repeated request would be billed and slow); it sends OpenRouter's provider object with zdr and data_collection: deny and reads the answering provider and the cost from the answer. Reviews of the writer's text deliberately run on other models than the writer where the matrix allows it. The writer's token usage goes through the pipeline context into Runs.TokensTotal; with CostTracking:Enabled the costs per actor and pass are stored in IterationActorCosts and summed on the run, and Runs.TokensTotal then becomes the sum over all recorded calls. API keys come from environment variables; names that editable configuration may reference are limited by an allow list (EnvReference:Allowed on top of a built-in list and the prefix ATELIER_SECRET_*).

Run safeguards (D-067)

Run outcome and RunStatus

Runs.Status keeps its meaning. A run that stops without all checks passing ends as Failed even when it delivers a text. Runs.Outcome is the additional signal for what the run delivered:

Outcome Meaning
Converged The checks passed; text and report are stored.
DeliveredWithOpenPoints The run stopped with open points and delivered its best available draft.
Failed The run ended without a usable text, or its result could not be stored completely (warning run.result_not_saved). A text may still be present; it is not guaranteed to be complete.
Aborted Cancelled by the user or stopped by the service. A text stored before the stop stays readable.

Outcome means finished and stored: it is set after the final text and the report are in the database. The first value wins. Status and Outcome can briefly disagree, because the event sink sets the status first; clients therefore wait until the order is done and an outcome is set (as scripts/atelier-smoke.sh does). If the service is stopped hard in between, the crash recovery sets the outcome: with a text Converged (status Completed) or DeliveredWithOpenPoints. Without a stored text, a run with review rounds delivers its best version (DeliveredWithOpenPoints) and any other run is Failed. Each of these runs gets the warning run.restarted_while_finishing.

Warnings at the run

A run records every problem it works around in RunWarnings: for example a web research that failed, a warning from reading a file, a check that could not be completed in a pass, a model that could not be assigned as planned or a failover in the LLM client. IRunWarningSink writes each warning in its own short-lived database scope; a failed write is logged and never stops the run. It is a required dependency, so a missing registration fails at start. The LLM client reports failovers through the ambient RunWarningScope, which the orchestrator opens per run.

Warnings appear on the technical run page and in the warnings field of get_order_status and get_order_result. Warning and error texts stored at a run are fixed, short, plain sentences; technical details go only to the log. Before anything technical is logged, SecretRedactionExtensions (Core) replaces credential-like fragments with [redacted].

Fail loud instead of silent

Situation Behaviour
A database migration fails at start-up The start aborts with a critical log entry (MigrateDatabaseOrFailAsync). The health check pending-migrations reports pending migrations.
The database does not start from the baseline EnsureStartsFromBaselineAsync throws IncompatibleDatabaseException before anything is written; the start aborts (D-092).
A run's snapshot is missing, unreadable, empty, of another format version, or lacks writer or checks CrewSnapshot.DeserializeForRun throws InvalidCrewSnapshotException; the run ends Failed with a clear message. There is no fallback setup; the tolerant Deserialize is for display only.
A snapshot has no checks, or names an unknown check AtelierPipelineFactory refuses to build the pipeline; the run ends Failed with a message.
A run has a setup no assembler accepts It fails with "This task was set up in a way this version cannot run. Please start it again."
A saved reviewed setup lacks a check or a role of the review rounds ReviewedPipelineAssembler throws InvalidCrewSnapshotException; the run ends Failed with a message, so no round is left out silently.
Unusable review or style-edit settings: Review:MaxVersions below 1, Review:MaxModelCalls below 8, StylePass:ReasoningEffort empty or max, or (while review rounds are on for anyone) time limits that allow a run longer than 55 minutes The settings are validated at start and the start aborts.
The style edit is on but its provider has no key A warning with the variable name at start (StylePassStartupCheck); runs with review rounds end without the style edit and say so.
A run without a usable snapshot is resumed RunService.ResumeRunAsync refuses with RunNotResumableException instead of creating a run that can never start.
The search key is missing A warning with the key name at start (ResearchKeyGuard); values are never logged.

Preparation timeout for runs with attachments

Run attachments were removed in stage 8d (D-091); the files of an order are read before its run is created. The safeguard itself remains: the orchestrator picks up only Pending runs with a snapshot, and a Pending run that still has none after Orchestrator:PreparationTimeout (default 15 minutes) is set to Failed with a message asking the user to submit it again; a restart cleans up the same way.

MCP server

The MCP server (Geef.Atelier.Mcp) is served at /mcp over stateless Streamable HTTP with bearer authentication. It offers ten tools: submit_order, answer_order, get_order_status, get_order_result, list_orders, cancel_order, revise_order, export_order, prepare_attachment (only while Uploads:Tickets is On) and profile. The tools call IOrderService, the same service as the web pages. McpToolCatalog registers the tools one by one, and McpToolBindingCheck stops the start when a tool parameter that is a service has no registration. Details: MCP integration and endpoint reference.

Configuration

Settings come from appsettings.json and environment variables (__ instead of :) and are read at start.

Section Content
ConnectionStrings Postgres connection (DefaultConnection)
Llm, CliProxy, ModelCatalog fallback providers, access to the CLI gateway, model lists
Orchestrator polling, parallel runs, cancellation polling, preparation timeout
Convergence defaults of the convergence policy (direct path)
Review the switch of the review rounds, per person too, and their limits, time limits, reasoning efforts and gates
StylePass the switch of the final style edit, its providers, time and token limits and guard thresholds
Sources, Uploads limits and retention of files; upload tickets
Orders request limits and waits, questions (IntakeMode), changing a text (Revise), TellOnce
Intake the clarifier and its questions
Direct writer notes, arithmetic of totals in files, fact check
Research, Tavily web research and its limits; Tavily:Endpoint and Tavily:ApiKey
Mcp Skills and Elicitation (D-088)
Ui WorkshopForAdminsOnly
AtelierUser, AtelierMcp, OAuth first administrator, static MCP token and its user, OAuth server
Pricing, CostTracking price table and cost tracking
EnvReference additional allowed environment-variable names
Logging, AllowedHosts ASP.NET Core defaults

The switches of the order features, their shipped values and their exceptions per person are listed in the admin guide. The public page /how-it-works reads the same switches.

Ui:WorkshopForAdminsOnly (default true) hides the workshop menu from non-administrators; the menu holds only "Runs" and, for administrators, "Providers". It changes what is shown, not access rights.

Testing and measuring

End-to-end tests (tests/Geef.Atelier.Tests/EndToEnd/)

AtelierEndToEndHost starts the real application through WebApplicationFactory<Program> against its own database per test on the Testcontainers Postgres of PostgresFixture. Migration, DI wiring, intake, orchestrator, pipeline, event sink and the MCP endpoint are the production code. Only external HTTP is replaced: ScriptedLlmEndpoint stands in for the cli-proxy and for the style edit's client llm-style and answers per role, LlmTrafficRecorder records the request bodies, FakeTavilyEndpoint and FakeCliProxyModelsEndpoint serve web search and model list, and every other named HTTP client is blocked.

export MSBUILDNODEREUSE=0 DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet test tests/Geef.Atelier.Tests/Geef.Atelier.Tests.csproj --filter "FullyQualifiedName~Geef.Atelier.Tests.EndToEnd"

The tests need Docker and run in their own collection without parallelism. A new path through the system should get its own end-to-end test, from the entry point to the stored result.

Measuring tools and operations scripts

tools/Eval compares the Atelier with other ways of producing a text by blind pairwise comparison (tools/Eval/README.md); real tasks stay outside Git. IntakeEval, FactCheckEval and ResearchEval measure the clarifier, the fact check and the research.

scripts/atelier-smoke.sh (a mini order through MCP after each deploy: submit_order, one skip of questions if asked, get_order_status until done with an outcome, get_order_result; it passes only with review rounds and an applied style edit that shortened the text) and scripts/atelier-watch.sh (alarm for stuck runs, an unhealthy cli-proxy or container, and repeated problems of runs with review rounds such as a failing or unchanged style edit, a failing planning step or failing checks, or missing credit for the style edit) are described in ops/atelier-smoke.md and ops/atelier-watch.md.

UI architecture

Blazor Server. The same .NET stack as the Geef SDK and live status without a separate client application.

Main pages

Route Function
/start New order: request, files with receipts
/work, /orders "My work": the person's orders
/orders/{id} Order page: questions, progress, text, open points, versions, changes, export
/about-me "About me" (the profile used in texts)
/runs, /runs/{id} Technical run list and run page
/crew/providers… Provider management (administrators)
/admin/users, /admin/oauth-clients, /admin/site-settings Administration

The full list, including public pages, is in the endpoint reference.

Live updates

Pages subscribe to the in-process IRunUpdateFeed (Web/Notifications/, InProcessRunUpdateFeed, registered by AddRunLiveUpdates()); there is no SignalR hub of the application's own.

  • The topic is derived on the server from the signed-in user (RunUpdateTopics). A run or order topic is granted only to the owner or an administrator; list topics carry the user's own entries, or all entries for administrators.
  • Every subscriber has its own queue; handlers run one after another, identical pending updates are merged, and publishing never waits for subscribers.
  • Access is decided when subscribing; a subscription lasts as long as the page's circuit.

LiveRunNotifier implements the Core contracts IRunNotifier and IOrderNotifier and publishes into the feed; a run of an order also updates the order topics. Notifications are best-effort.

CircuitDataGate (scoped per circuit): all components of a circuit share one DbContext, so every database access of a page that receives live updates runs through DataGate.RunAsync(...). Calls must not be nested.

Auth strategy

Multi-user since Step20 (D-041 timeframe): originally single-user from environment variables; now DB-based multi-user management (table Users, BCrypt). The admin account is seeded/synchronized at startup from ATELIER_USER/ATELIER_PASSWORD_HASH; further accounts are managed by the admin at /admin/users (IUserAdminService). IUserAuthenticator has since returned an AtelierUser? (instead of just bool). The cookie configuration below applies unchanged.

The BCrypt hash (work factor 11) is generated via tools/HashPassword/.

Cookie configuration:

Option Value
Cookie name Atelier.Auth
HttpOnly true
SameSite Strict (production) / Lax (test env)
SecurePolicy SameAsRequest (dev) / Always (prod)
ExpireTimeSpan 30 days
SlidingExpiration true
LoginPath /login

Login flow (static SSR):

Anonymous browser → /runs → [Authorize] → RedirectToLogin
  → NavigationManager.NavigateTo("/login?ReturnUrl=%2Fruns")
  → Login.razor (static SSR, no @rendermode)
  → POST /login (Blazor static SSR form handler, @formname="login-form")
  → IUserAuthenticator.ValidateCredentialsAsync (BCrypt.Verify)
  → HttpContext.SignInAsync → cookie set → redirect to /runs

Important: the login page must stay static SSR. @rendermode InteractiveServer would handle the form POST in a WebSocket context without an HttpContext → SignInAsync would not be callable. The @formname="login-form" attribute on the <form> element is mandatory for Blazor static SSR form routing.

Logout: POST /auth/logout (Minimal API) with <AntiforgeryToken /> in the UserMenu component. A GET logout would be a CSRF attack vector.

IUserAuthenticator layer:

Geef.Atelier.Core/Configuration/AtelierUserOptions.cs   → POCO for username/password hash
Geef.Atelier.Application/Auth/IUserAuthenticator.cs     → interface (Application, not Infrastructure)
Geef.Atelier.Application/Auth/AtelierUserAuthenticator.cs → user lookup + BCrypt.Verify
Geef.Atelier.Application/Auth/ApplicationAuthExtensions.cs → AddAtelierAuth(IServiceCollection, IConfiguration)

AtelierUserAuthenticator is internal sealed. The env-var fallback (ATELIER_USER/ATELIER_PASSWORD_HASH) is resolved in ApplicationAuthExtensions — docker-compose users do not need to know the ASP.NET Core double-underscore convention.

Timing protection: AtelierUserAuthenticator looks the user up and checks the password with BCrypt.Verify. An unknown or deactivated account is checked against a throwaway hash with the same work factor, so the rejection takes about as long as for a wrong password. Only the reason of a rejection is logged (Login attempt rejected: …), never a name or a hash.

Lazy-fail on missing configuration: the service starts even without ATELIER_USER/ATELIER_PASSWORD_HASH; it then creates no administrator, so signing in works only for accounts that already exist. The health check stays anonymous (.AllowAnonymous() on MapHealthChecks).

ForwardedHeaders before UseAuthentication:

app.UseForwardedHeaders();   // FIRST — so that Request.IsHttps is correct
app.UseAuthentication();
app.UseAuthorization();

Traefik terminates TLS and forwards HTTP. Without UseForwardedHeaders, SecurePolicy.Always would block cookies in production. KnownIPNetworks.Clear() opens it for all proxy IPs (Docker-network invariant).

Test auth bypass

TestAuthenticationHandler (in tests/Geef.Atelier.Tests/Web/E2E/, internal sealed) marks every request as pre-authenticated with ClaimTypes.Name = "test-user". WebTestHost.StartAsync(authenticated: true/false) — true activates the test handler, false starts real cookie auth with a BCrypt-wf=4 hash for LoginFlow/LogoutFlow tests. The handler must never be referenced in Program.cs or the Web project.

MCP server — bearer token / multi-auth (implemented in step 9, see D-022)

Multi-auth scheme setup: the application uses two parallel authentication schemes.

Scheme Name Purpose
Cookie CookieAuthenticationDefaults.AuthenticationScheme Web UI, default scheme
Bearer "Bearer" MCP endpoint /mcp, explicitly via McpPolicy

Default scheme: cookie (all Blazor routes, [Authorize] without an argument).

MCP endpoint: explicitly protected with RequireAuthorization("McpPolicy"). The McpPolicy sets the authentication scheme to "Bearer" so the MCP path never attempts cookie auth.

ITokenValidator / BearerTokenHandler (state after D-041 OAuth 2.1):

ITokenValidator.ValidateTokenAsync has returned, since D-041, a rich result TokenValidationOutcome { IsValid, Kind, Subject, ClientId, Scope } (no longer just bool).

Geef.Atelier.Application/Auth/ITokenValidator.cs           → interface (application layer)
Geef.Atelier.Application/Auth/StaticTokenValidator.cs      → static ATELIER_MCP_TOKEN
                                                              (FixedTimeEquals); Kind="static-bearer"
Geef.Atelier.Application/Auth/OAuthAccessTokenValidator.cs → OAuth access token via DB lookup
                                                              (SHA-256 hash); Subject = OAuth user
Geef.Atelier.Application/Auth/CompositeTokenValidator.cs   → registered as ITokenValidator:
                                                              checks static, then OAuth
Geef.Atelier.Web/Auth/BearerTokenHandler.cs                → AuthenticationHandler; builds claims
                                                              from the outcome (Name/NameIdentifier/Role)

BearerTokenHandler maps the outcome onto claims: ClaimTypes.Name ← Subject, ClaimTypes.NameIdentifier ← ClientId ?? Subject, and for the static bearer token ClaimTypes.Role = "admin". Run-user isolation (D-042) therefore also applies over MCP: OAuth orders belong to the authorizing user, static-token orders to AtelierMcp:StaticTokenUser or the configured administrator. ICurrentUserService/HttpContextCurrentUserService expose Username/IsAdmin for the service and MCP layers.

OAuth 2.1 has been fully implemented since D-041 (no more "after the skeleton"): a self-hosted authorization server with mandatory PKCE/S256, opaque tokens (only SHA-256 in the DB), refresh rotation + reuse detection. Endpoint and flow details see 04-mcp-integration.md and 09-endpoint-reference.md; rationale in the decisions log D-041. Both auth paths (static bearer token for Claude Code CLI, OAuth 2.1 for Claude Desktop/Claude.ai) coexist without a configuration change.

Production deployment

Traefik flow

Browser → HTTPS:443 → Traefik (TLS via Let's Encrypt, cert-resolver 'le') → HTTP:8080 → geef-atelier-web container → ASP.NET

Traefik terminates TLS and forwards HTTP (port 8080) to the container, which exposes no port to the outside.

Parameter Value
External network proxy
Cert resolver le (HTTP challenge via the web entry point)
Entry point (HTTPS) websecure
HTTP→HTTPS redirect Global in traefik.yml (no app-side redirect router)
Middleware chain chain@file (secure headers, compression, rate limit)
traefik.docker.network proxy (mandatory when a container is in multiple networks)

ASPNETCORE_ENVIRONMENT=Production enables CookieSecurePolicy.Always. ForwardedHeaders (before UseAuthentication) reads X-Forwarded-Proto=https; without it the cookies would be blocked. Cookie auth and bearer auth work the same way behind the proxy.

Postgres and backup

The compose file runs its own Postgres container (image pgvector/pgvector:pg16; the schema needs no extension). The postgres-backup service (prodrigestivill/postgres-backup-local:16) writes a gzip-compressed SQL dump daily at 03:00 UTC into the volume geef-atelier-backups (7 daily, 4 weekly, 6 monthly). Restore: scripts/restore-backup.sh <file.sql.gz>. Uploaded originals live on the volume geef-atelier-sources, outside the database dump.

Reviewer calibration

06-reviewer-calibration.md keeps the former severity taxonomy (marked as historical) and the current convergence values.

Deployment procedure

  1. Create the .env file (openssl rand, tools/HashPassword); it is gitignored and never goes into the repository.
  2. Build the images and start the compose stack; the migration runs at start (D-010) and a failed migration stops the start (D-067).
  3. Traefik detects the container through its labels and issues the certificate.
  4. After every deploy, run scripts/atelier-smoke.sh (ops/atelier-smoke.md).

The nightly cli-proxy self-update (scripts/cli-proxy-selfupdate.sh) builds only from the committed state; with uncommitted changes under cli-proxy/ it pauses and sends an alarm instead of building (D-067). It builds and replaces the running gateway only when a read-only query shows no run Pending or Running and no order still being clarified, checked before the build and before the swap; otherwise the gateway stays and the next run of the script tries again (D-093). If the database of Atelier does not answer, nothing is replaced either.

Model catalog for CLI providers (D-064)

CLI providers do not carry their model list in the Atelier. ModelCatalog reads it from the cli-proxy through ICliModelSource / CliProxyModelSource (GET /v1/cli/{providerName}/models). The gateway reports where the list came from (x_source: live, static or degraded) and, for claude, an x_aliases map from claude-<family>-latest to the concrete model.

  • Provenance is three-state. ModelCatalogSource distinguishes Live, StaticByDesign and Fallback.
  • The live list is merged with the curated one, never replaced.
  • The model matrix holds *-latest aliases, run snapshots hold concrete ids. The alias is resolved once when the snapshot is built (CrewSnapshotModelResolver), so new runs follow new releases while a resumed run keeps the model of its parent.

Caching: 24 h for a successful CLI lookup, 1 h for HTTP providers, 5 minutes for any failure. ModelCatalogWarmUpService warms every active CLI provider shortly after start and every night; ModelCatalog:CliLiveCatalogEnabled switches back to the configured lists.

Observability

  • PostgresEventSink (an IGeefEventSink) writes pipeline events to the database and triggers live updates.
  • System.Diagnostics.ActivitySource("Geef.Sdk") for distributed tracing; the pipeline uses the SDK's exception-handling and tracing middleware.
  • Logging through Microsoft.Extensions.Logging to the console.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.