Assentt Finance AI Agentic by Imad DhinAssentt Finance AI Agentic by Imad Dhin

Assentt Finance AI Agentic

Imad Dhin

Imad Dhin

Verified

Assentt Finance AI: Engineering a Hardened, Deep Agentic Financial Automation System

A technical case study in resolving five interconnected failures across app attestation, authentication, database authorization, and native iOS UI—restoring autonomous financial workflows without compromising a single security control.
Core Tech Stack: SwiftUI & UIKit (AuthenticationServices), Firebase App Check (App Attest & DeviceCheck), Firebase Authentication, Cloud Functions (2nd Gen Agentic Orchestration), Cloud Firestore (Named Database).
THE ARCHITECTURAL CHALLENGE
Assentt Finance AI pairs a native iOS client with a deep agentic financial automation engine backed by a dedicated, multi-tenant Cloud Firestore architecture. Rather than acting as a passive chatbot, the system operates as an autonomous financial orchestrator: continuously analyzing connected accounts, generating predictive insights, managing dynamic budgets, tracking recurring liabilities, and queuing executable financial actions.
When an AI agent is trusted to synthesize bank connectors, propose ledger actions, and mutate budget states, every operational layer must enforce strict zero-trust boundaries. However, defense-in-depth means a single upstream misconfiguration can cascade across the pipeline, surfacing as multiple unrelated-looking errors across the client and agent runtime.
⚬ Broken Agentic Loops: The AI finance agent repeatedly halted execution, demanding that authenticated users sign in again. ⚬ Data Starvation: Real-time financial dashboards and agent context streams failed to load user subcollections (insights, actions, budgets, recurring items, and connectors). ⚬ UI Constraint Failures: The native authentication gateway flooded the diagnostic console with AutoLayout constraint violations on wide-screen viewports.
The Objective: Trace these disparate symptoms back to their architectural root causes, restore end-to-end agentic automation and real-time ledger synchronization, and keep every zero-trust security control strictly enforced.
THE ZERO-TRUST AGENTIC REQUEST PIPELINE
Every autonomous action or data synchronization request traverses five sequential security checkpoints. Tracing the request lifecycle exposed exactly where the pipeline fractured:
Native iOS Client Layer: Constructs the payload, manages view layouts, and attaches environment credentials. Two defects originated here: an unexpanded Xcode debug token placeholder and an unconstrained Apple Sign-In UI boundary.
Firebase App Check Attestation: Cryptographically verifies that the request originates from an authentic, unmodified binary. This was the root cause of the primary system outage—without a valid attestation token, every downstream layer rejected the request immediately.
Firebase Authentication: Validates user identity and session tokens. This layer operated flawlessly throughout; user sessions were never actually invalidated.
Cloud Functions (2nd Gen) & Firestore Gateway: The execution boundary for the AI agent and real-time database streams. It enforces valid App Check tokens prior to invoking agent logic or evaluating security rules. This is where the "sign in again" prompts and permission-denied errors surfaced.
Firestore Security Rules Engine: Evaluates fine-grained, document- and collection-level access for financial records. This layer harbored a subtle static-analysis failure on collection-wide listeners.
ROOT CAUSE ANALYSIS & ENGINEERING RESOLUTIONS
Issue 1: AI Agent Loops Halted by False-Positive Authentication Prompts
⚬ What Users Saw: When triggered to analyze accounts or execute financial actions, the AI agent replied "Please sign in again to continue," despite the user holding an active, valid session token. ⚬ Why It Happened: The 2nd Gen Cloud Function hosting the AI agent enforces strict App Check attestation before spinning up the agent runtime. When attestation failed, the gateway rejected the call with an UNAUTHENTICATED status code. The iOS client's error handler conflated gateway-level attestation rejection with user-level authentication expiration, misdirecting the user to re-authenticate. ⚬ Engineering Resolution: Restored cryptographic attestation at the client source (see Issue 3), allowing verified client requests to pass the Cloud Functions gateway and initialize the agentic workflow without false session interrupts.
Issue 2: Total Blackout of Financial Subcollections & Context Streams
⚬ What Users Saw: Immediate "Missing or insufficient permissions" errors across all real-time Firestore listeners—starving both the UI and the AI agent of insights, actions, budgets, and device registrations. ⚬ Why It Happened: App Check enforcement was active at the Firestore project gateway. Because the gateway validates device attestation before invoking the Firestore Security Rules engine, requests lacking a valid App Check token were dropped at the perimeter before owner-level authorization could even be evaluated. ⚬ Engineering Resolution: Provisioned and registered a valid iOS App Check token scoped to the native client. Real-time read and write streams immediately recovered across all financial collections under the existing owner-only access controls.
Issue 3: Unexpanded Xcode Environment Placeholders Breaking Debug Attestation
⚬ What Users Saw: Development builds consistently failed attestation checks even though a debug token had already been configured in the Firebase console. ⚬ Why It Happened: Two platform mechanics collided. First, App Check debug tokens are strictly scoped to a single App ID; a token registered for the Web or Android target does not authorize the native iOS binary. Second, the Xcode run scheme passed the debug token via an environment placeholder. When left unexpanded by the build system, the literal placeholder text was injected into the runtime instead of a valid UUID. Because the string was non-empty, the Firebase SDK skipped generating a new token and sent the literal placeholder text to Google's attestation servers, which rejected it. ⚬ Engineering Resolution: Registered a dedicated debug token explicitly against the iOS App ID. Engineered startup sanitization code that detects and strips unexpanded or empty environment strings prior to SDK initialization, forcing a clean fallback to a valid debug token. Added a launch-time token exchange check that prints a clear diagnostic registration link to the console if a token is ever missing.
Issue 4: Blocked Real-Time Listeners on Financial Account Connectors
⚬ What Users Saw: Even after App Check was restored, subscribing to a live collection listener on the connectors collection failed with permission errors—even though fetching a single connector document succeeded. ⚬ Why It Happened: Firestore security rules are not runtime filters; the database must be able to authorize a query from the path alone before execution. The ruleset grouped subcollections under a wildcard match paired with a dynamic condition. While single-document reads succeeded because every path segment was known, collection-level queries could not be deterministically verified in advance and were rejected. ⚬ Engineering Resolution: Eliminated wildcard subcollection matching. Every financial domain—connectors, actions, recurring, budgets, and insights—now has its own explicit rule block enforcing a strict owner UID check. The rules were compiled, verified, and deployed to the application's dedicated named Firestore database.
Issue 5: Native Sign in with Apple AutoLayout Constraint Violations
⚬ What Developers Saw: AutoLayout constraint warnings flooded the Xcode console every time the authentication screen appeared on wider iOS devices and iPad simulators. ⚬ Why It Happened: Apple's native Sign in with Apple button (ASAuthorizationAppleIDButton) enforces an internal maximum width of 375 points. Stretching the control to fill a wider responsive container forced the layout solver to break the button's internal system constraints. ⚬ Engineering Resolution: Capped the button's maximum width at 375 points and centered it within its parent container. It now sits cleanly inside wider layouts while fully respecting Apple's native layout contract.
SYSTEM STATE: BEFORE & AFTER REMEDIATION
⚬ Deep Agentic Runtime ⚬ Before: Halted by misleading "sign in again" prompts during valid user sessions. ⚬ After: Requests pass gateway attestation and autonomous financial workflows execute seamlessly. ⚬ Financial Data Streams ⚬ Before: Permission denied across all user subcollections. ⚬ After: Real-time reads, writes, and live listeners succeed under strict owner-only rules. ⚬ Development Attestation ⚬ Before: Unexpanded Xcode placeholder tokens rejected by Google attestation servers. ⚬ After: Startup sanitization ensures clean fallback to a valid token, paired with a launch-time diagnostic check. ⚬ Account Connectors ⚬ Before: Collection-wide real-time listeners denied by static rule analysis. ⚬ After: Explicit per-subcollection security rules authorize live collection queries. ⚬ Authentication UI ⚬ Before: AutoLayout constraint warnings on wide-screen iOS devices and simulators. ⚬ After: Centered native button constrained within Apple's 375-point maximum width limit. ⚬ Zero-Trust Security Posture ⚬ Before: All security protections switched on, rendering the app unusable due to cascading blocks. ⚬ After: All security protections remain switched on, with 100% system and agent functionality restored.
ARCHITECTURAL PRINCIPLES FOR AGENTIC FINTECH SYSTEMS
Separate Attestation, Authentication, and Authorization in Error Telemetry: A zero-trust pipeline asks three distinct questions: Is the client binary genuine? (Attestation), Who is the user? (Authentication), and What data may they access? (Authorization). Client error handling must distinguish between these layers rather than folding gateway attestation failures into generic "sign in again" prompts.
Scope Credentials Strictly Per App ID: Debug tokens and cryptographic credentials belong to a single platform binary. Web, Android, and iOS targets each require isolated credential provisioning.
Never Trust Unexpanded Build Variables: Sanitize environment values at launch and verify token exchange early. Catching an unexpanded Xcode scheme placeholder at startup produces a clear developer diagnostic instead of a mysterious runtime failure.
Design Firestore Paths for Advance Query Authorization: Deep agentic systems rely heavily on collection-wide listeners to build context windows. Explicit collection rules cost only a few extra lines of configuration and eliminate an entire class of unexpected query denials.
Respect the Layout Contract of Native Components: System controls like Sign in with Apple have built-in geometric limits. Designing responsive containers that work within those limits keeps layouts stable across all device form factors.
TECHNOLOGY AT A GLANCE
⚬ Apple iOS, SwiftUI & UIKit: Native client runtime, responsive AutoLayout management, and biometric/Apple ID onboarding via AuthenticationServices. ⚬ Firebase App Check: Hardware-backed binary attestation utilizing DeviceCheck and App Attest in production, paired with a sanitized debug provider in development. ⚬ Firebase Authentication: User session lifecycle management, JWT issuance, and secure credential exchange. ⚬ Cloud Functions (2nd Gen): Serverless backend hosting the AI finance agent orchestration engine, enforcing mandatory App Check attestation on every invocation. ⚬ Cloud Firestore (Named Database): Multi-tenant NoSQL ledger storing per-user financial insights, executable actions, budgets, recurring items, and bank connectors under explicit collection-level and document-level security rules.
Like this project

Posted Oct 4, 2026

Assentt Finance coming to superset your financial resources to a whole new experience thought AI Agent.