Skip to main content
Back to Work

Regulatory AI Case Study

Locally verified reviewer walkthrough · v0.5.0 Azure staging evidence

Analyst-assurance platformHuman approval requiredProduction intentionally unapproved

RegImpact AI — Regulatory Change Impact & Controls Assurance

An evidence-linked regulatory intelligence platform that versions source documents, detects section-level changes, identifies obligation candidates, retrieves relevant controls, and routes uncertain or consequential findings to authorized reviewers.

Python 3.12FastAPINext.jsTypeScriptPostgreSQLpgvectorRedisDramatiqAzure Container AppsBlob StorageKey VaultBicepGitHub ActionsDocker

Problem

Regulatory change is not just a document-search problem.

A useful system must preserve evidence of what changed, show which obligation was inferred, identify which internal controls may be affected, record who reviewed the proposal, and preserve why the final decision was accepted, rejected, deferred, or confirmed unmapped.

RegImpact was therefore designed as an analyst-assurance platform, not a regulatory chatbot, legal-advice service, or autonomous compliance decision-maker.

Product workflow

Architecture Flow

9 stages
  1. 01Stage

    Regulatory sources

    Monitored documents enter through scheduled, guarded retrieval

  2. 02Stage

    Immutable versions

    Normalized content identity and source lineage are preserved

  3. 03Stage

    Section change detection

    Added, modified, and removed sections are identified deterministically

  4. 04Stage

    Obligation analysis

    Evidence-linked candidates expose confidence and source support

  5. 05Stage

    Hybrid retrieval

    Full-text and pgvector signals are fused for control discovery

  6. 06Stage

    Control mapping

    Ranked candidates expose ambiguity, evidence, and lineage

  7. 07Stage

    Policy gates

    Insufficient evidence or consequential actions require explicit review

  8. 08Stage

    Authorized reviewer

    Accepted, rejected, deferred, or unmapped decisions require rationale

  9. 09Stage

    Audit trail

    Decision history remains durable and append-only

Verified local walkthrough

The Docker Compose walkthrough uses synthetic Directive 060 clauses. The sample § 4.2 reporting window changes from 72 to 24 hours and adds a requirement to preserve the submission receipt.

Change register with the modified § 4.2 incident-notification clause selected

Side-by-side clause comparison showing the 72-hour and 24-hour sample windows and one extracted obligation

The Analyst traced the extracted obligation to version 2, page 43, and deferred the proposed mapping to control REG-IR-01 pending confirmation that the control owner could meet the shorter window. The rationale and revision 2 persisted after refresh. The Viewer could read that decision and saw a read-only notice.

Read-only Viewer detail showing the source evidence and saved deferred analyst decision

The authenticated API walkthrough passed five local runs and checked that a Viewer write returns HTTP 403. The v0.5.0 release audit records the earlier Azure staging deployment.

Architecture

RegImpact is a modular monolith with independently executed web, API, worker, dispatcher, scheduler, and migration workloads. The verified v0.5.0 release used five Container Apps; the current staging design keeps API, web, and worker as apps while dispatcher and scheduler run as bounded scheduled Container Apps Jobs.

Architecture Flow

7 stages
  1. 01Stage

    Next.js analyst console

    Reviewer-facing workflows and protected operational views

  2. 02Stage

    FastAPI service

    Typed APIs, domain logic, policy gates, authentication, and workflow state

  3. 03Stage

    PostgreSQL + pgvector

    System of record, lineage, workflow state, audit events, lexical and vector retrieval

  4. 04Stage

    Blob Storage

    Immutable source-document bytes and content-addressed artifacts

  5. 05Stage

    Redis + Dramatiq

    Asynchronous worker queue, retries, leases, and dead-letter handling

  6. 06Stage

    Scheduled control-plane jobs

    Dispatcher and source scheduler run as bounded Container Apps Jobs instead of idle 24/7 containers

  7. 07Stage

    Application Insights + Log Analytics

    Structured operational telemetry and trace correlation

PostgreSQL owns tenants, metadata, lineage, workflow state, and audit events. Blob Storage owns immutable source bytes. Search indexes and embeddings are treated as derived projections that can be rebuilt.

Retrieval and decision design

The current release deliberately favors explainable, testable components for high-consequence decisions.

  • PostgreSQL full-text search provides lexical retrieval.
  • pgvector cosine similarity provides semantic retrieval.
  • Reciprocal-rank fusion combines the two result sets.
  • Results remain tenant-scoped and preserve citation and embedding-model lineage.
  • Obligation candidates expose evidence and explainable confidence features.
  • Control mappings preserve ranked candidates, ambiguity, unmapped states, and evaluation lineage.
  • Low-confidence or policy-sensitive outcomes route to authorized human review.

The design principle is:

Models propose; policy gates constrain; authorized people decide.

Human review and governance

Human authority is not an optional UI layer. It is part of the workflow contract.

Review decisions support:

  • accepted
  • rejected
  • deferred
  • confirmed unmapped

Rationale is mandatory, stale-update protection prevents silently overwriting newer decisions, and creator/approver separation prevents one actor from unilaterally proposing and approving a consequential change.

Built

Persisted policy-gated workflowAuthorized reviewer decisionsMandatory rationaleCreator / approver separationTenant-aware RBACAppend-only audit historyInsufficient-evidence blocking

Planned

Enterprise workforce identityPrivate production networkingFormal production operating approval

Security and reliability

The implemented security boundary includes:

  • database-backed users with admin, analyst, and viewer roles
  • scrypt password hashing
  • short-lived signed tokens
  • HTTP-only cookies
  • tenant isolation
  • server-validated actor and tenant identity
  • controlled URL retrieval with SSRF-oriented protections
  • signature-verified PDF/HTML intake and strict document limits
  • non-development fail-closed malware-scanning boundary

The reliability model includes:

  • transactional outbox
  • Redis/Dramatiq workers
  • idempotent jobs
  • retries and leases
  • dead-letter state
  • startup, liveness, and readiness probes
  • structured JSON logs
  • request, trace, tenant, and actor correlation
  • W3C trace context
  • metrics, Application Insights, and Log Analytics

Azure delivery architecture

Architecture Flow

8 stages
  1. 01Stage

    GitHub Actions + OIDC

    Passwordless deployment identity into protected staging

  2. 02Stage

    Bicep validation and deployment

    Infrastructure is compiled and deployed from versioned code

  3. 03Stage

    Commit-addressed container images

    API and web images are published immutably and reused by worker/jobs

  4. 04Stage

    Zero-replica staging

    Application workloads are staged before database promotion

  5. 05Stage

    Migration job

    regimpact-staging-migrate must succeed before application promotion

  6. 06Stage

    Runtime validation

    API, web, worker, dispatcher job, scheduler job, and dependencies are verified

  7. 07Stage

    Evidence retention

    Deployment evidence and pre-delete resource inventory are retained as GitHub artifacts

  8. 08Stage

    Automatic teardown

    Staging is deleted after successful validation unless an operator explicitly keeps it online

Cloud cost & staging architecture

The first verified Azure release proved that the system could be deployed repeatably, but it also exposed an operational issue: a production-shaped staging environment can accumulate cost even when nobody is actively using it.

Azure cost analysis showed a continuous-spend pattern across always-on Container Apps, managed Redis, PostgreSQL, and telemetry. Instead of treating that as a billing-only problem, I changed the execution and deployment model.

Architecture Flow

5 stages
  1. 01Stage

    Provision temporary staging

    Create the full Azure resource group from Bicep only when validation is needed

  2. 02Stage

    Run migrations

    Database schema changes complete before application promotion

  3. 03Stage

    Validate the complete system

    Exercise public readiness, internal API dependencies, background workloads, and version checks

  4. 04Stage

    Capture evidence

    Retain immutable deployment evidence and a pre-delete resource inventory

  5. 05Stage

    Tear down by default

    Delete the staging resource group unless keep_staging_online=true is explicitly selected

The current cost-aware design also changes how background control-plane work runs:

  • Scheduler: a bounded Container Apps Job runs every 15 minutes, matching the minimum supported source polling interval.
  • Dispatcher: a bounded Container Apps Job runs every minute and drains a limited number of transactional-outbox batches before exiting.
  • Worker: remains a Redis/Dramatiq queue consumer because that execution model is still correct for asynchronous jobs.
  • PostgreSQL: staging stays on the Burstable B1ms profile with no high availability or geo-redundant backup, and the server is deleted with the temporary environment.
  • Redis: remains Basic C0 only for short-lived staging because Dramatiq currently depends on Redis.
  • Observability: high-volume Container Apps console/system log streaming is disabled in ephemeral staging while application telemetry remains available.
  • Frontend: remains a Container App because Next.js performs server-side calls to an internal-only FastAPI endpoint; moving it to static hosting would require a larger security and runtime redesign.

The objective was not simply to make Azure cheaper. It was to preserve real deployment evidence, migration safety, background processing, observability, and internal API boundaries while removing idle infrastructure that had no portfolio or operational value.

FinOps result

Ephemeral by default

Staging now follows provision → migrate → validate → preserve evidence → teardown. Keeping Azure staging online is an explicit operator decision rather than the default.

Verified v0.5.0 release

v0.5.0

Released version

5

Healthy application workloads

76

API tests passed

ready

Final readiness status

The verified v0.5.0 release evidence records:

  • successful GitHub Actions run 33695340705
  • immutable deployment commit 3b3d90ade4b75c845395a390b00cd3d0ba20d1d0
  • protected GitHub staging environment
  • Azure region Canada Central
  • successful regimpact-staging-migrate job
  • healthy API, web, worker, dispatcher, and scheduler Container Apps in the historical v0.5.0 topology
  • public readiness response {"status":"ready","version":"0.5.0"}
  • retained artifact deployment-evidence-3b3d90ade4b75c845395a390b00cd3d0ba20d1d0

The post-release cost-control redesign is intentionally described separately from that immutable release evidence. Current main uses three Container Apps plus scheduled dispatcher/scheduler jobs and tears down staging by default after validation.

Release boundary

Verified staging, not production

The release validates repeatable Azure delivery and operational readiness. Production remains intentionally unapproved pending additional identity, networking, malware-scanning, recovery, and Kubernetes validation.

Deployment lessons

The successful release was reached by fixing several independent Azure integration failures rather than treating deployment as one opaque event.

Log Analytics retention

The original staging retention value was unsupported for the selected workspace contract. The configuration was aligned to the supported SKU and retention requirements.

Key Vault purge protection

Azure does not allow purge protection to be reverted from enabled to disabled. Non-production deployment logic was changed to omit the property instead of trying to write false.

OIDC token lifetime

A long infrastructure deployment exhausted the original Azure session before registry operations. The workflow now refreshes the Azure session immediately before ACR login.

pgvector enablement

PostgreSQL Flexible Server requires the VECTOR extension to be allow-listed before Alembic can create pgvector objects.

Two-phase promotion

Reapplying PostgreSQL configuration during workload promotion caused a ServerIsBusy collision. The two-phase deployment now applies extension configuration during the foundation phase only.

These fixes are encoded in infrastructure and workflow code, making the successful result repeatable rather than a one-off console procedure.

Product visuals

Fresh sanitized v0.5.0 staging captures are intentionally still pending.

The repository already defines the approved capture sequence:

  1. operations overview
  2. source registry
  3. old-versus-new change evidence
  4. obligation review
  5. control mapping
  6. reviewer decision and audit history
  7. Azure release evidence

The capture standard requires synthetic demonstration records, removal of credentials and tenant/subscription identifiers, consistent 1440×900 framing, and optimized PNG or WebP assets. Until those files exist, this case study does not render broken or invented screenshots.

Built vs planned

Built

Versioned regulatory ingestionDeterministic section-level change detectionEvidence-linked obligation candidatesSentence-transformer embeddingsHybrid lexical + vector retrievalControl mapping and rankingPolicy-gated human reviewRBAC and tenant isolationTransactional outbox and async workersStructured logs, metrics, and tracingAzure Container Apps stagingScheduled Container Apps JobsEphemeral staging teardownBicep infrastructure as codeGitHub OIDC deliveryImmutable deployment evidence

Planned

Genuine fine-tuned regulatory-clause classifier training and promotionLangGraph orchestration in v0.7Backup / restore / rollback and failure-injection exercises in v0.8AKS / Kubernetes runtime validation in v1.0Enterprise workforce identity and private production networking

Capability boundary

The repository deliberately separates delivered engineering from roadmap items.

CapabilityCurrent status
Sentence-transformer embeddings and hybrid retrievalImplemented
Evaluated deterministic obligation extractionImplemented
Persisted policy-gated workflow with human approvalImplemented
Fine-tuned regulatory-clause classifierGoverned corpus and human-label evaluation tooling implemented; model training and promotion remain gated
Controlled impact-workflow evaluationImplemented: citations, tenant isolation, policy blocks, and approval enforcement; deterministic, not open-ended LLM tool use
Separate MCP companionPlanned; integration audit precedes implementation
LangGraph orchestrationPlanned for v0.7; not implemented
AKS / Kubernetes runtimePlanned for v1.0; not implemented

Human-label evaluation and next agent work

The repository now includes human-evaluation packaging and a governed multi-human adjudication workflow. A single-human evidence package is available; independent second-reviewer annotation and completed adjudication are still pending. Implementing that workflow is not evidence of completed independent review, nor authorization to train or promote a classifier.

The controlled agent workflow is a tenant-scoped state machine that gathers evidence and proposes an impact assessment. Its evaluation checks citations, isolation, approval enforcement, and policy blocks. It does not execute actions or provide an open-ended LLM agent. The separate MCP companion remains planned, beginning with an audit of API and authorization contracts.

Controlled workflow evaluation · Workflow implementation · Human-evaluation packaging

Current limitations

RegImpact is not approved for production use.

Current production boundaries include:

  • private networking still required
  • enterprise malware scanning still required
  • Entra workforce identity still required
  • restore drills and broader recovery validation still required
  • Azure Managed Redis remains a production consideration
  • Kubernetes runtime validation is not yet complete
  • fresh sanitized staging screenshots are still pending
  • the future classifier is not yet a trained and promoted production model

These are deliberate boundaries, not hidden gaps.

What this project demonstrates

RegImpact demonstrates applied AI engineering beyond a notebook or chatbot:

  • evidence-linked regulatory intelligence
  • deterministic and semantic retrieval
  • asynchronous backend workflows
  • human-authority design
  • security and tenant boundaries
  • observability
  • infrastructure as code
  • OIDC-based cloud delivery
  • migration-gated release engineering
  • cost-aware ephemeral staging and automatic teardown
  • immutable deployment evidence
  • explicit separation of implemented and planned capabilities

The strongest engineering result is not a single model metric. It is the end-to-end system boundary: evidence is preserved, automation is constrained, authorized people remain accountable, cloud delivery is independently inspectable, and staging infrastructure is now lifecycle-managed rather than left running by default.

Inspect the implementation

Regulatory intelligence, human review, and cloud release engineering—open for inspection.

Review the source code, release audit, architecture, operational documentation, and immutable Azure deployment evidence.

Chintan Patel

Applied AI Engineer · ML · RAG · Full-Stack AI Systems

Privacy