The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.
Write Gate and Sync Lock
SQLite is a single-writer database. If multiple JavaScript operations attempt concurrent transactions, the native bridge throws SQLITE_BUSY or SQLITE_LOCKED errors. CommitT solves this with two complementary systems: a Promise-chain mutex and a Saga-pattern orchestrator.
Sync Lock Mutex (V2)
The SyncLock (lib/sync-lock.ts) is a singleton Promise-chain mutex that serializes ALL database writes and hardware alarm sync triggers across the entire application.
import { syncLock } from '@/lib/sync-lock';// Every database write must go through the lockconst result = await syncLock.execute( "Saga:CreateCommitment", // Source name for diagnostics async () => { await db.withTransactionAsync(async () => { // Write operations here }); }, 15_000 // Timeout: 15 seconds);
How the Queue Works
Operations are chained onto a single Promise. Each new caller waits for all preceding callers to finish before executing:
Timeout Circuit Breaker
Every lock holder has a hard time limit (default: 30 seconds). If an operation exceeds this, the lock is forcibly released via Promise.race:
const result = await Promise.race([ operation(), new Promise<never>((_, reject) => { setTimeout(() => { reject(new Error( `TIMEOUT: "${sourceName}" exceeded ${timeoutMs}ms. ` + `Forcibly releasing lock to prevent system deadlock.` )); }, timeoutMs); })]);
The timeout does NOT abort the underlying operation (you cannot cancel a native SQLite transaction). It simply releases the lock so the next writer does not starve. The timed-out operation’s result is silently discarded.
Manual Resync Awareness
The SyncLock exposes a public isManualResyncActive flag. When set to true, the HydrationSync engine suppresses all reconciliation attempts to avoid fighting the manual resync for the lock:
Manual Resync starts → sets flag → acquires lock → nukes DB → downloads → ingests → clears flag |HydrationSync wakes up → checks flag → sees true → gracefully defers | |Without this flag: HydrationSync sees empty token → panics → "AMNESIA!" → fights for lock
Cold Boot Reset
On app startup, the lock is explicitly reset to clear any stale state from a prior crash:
syncLock.reset(); // Called in SQLiteProvider's onInit
This handles the edge case where Android ROMs (notably Lenovo) keep the process alive after a swipe-kill when an Accessibility Service is active.
Triple-Write Orchestrator
The TripleWriteOrchestrator (lib/triple-write-orchestrator.ts) is a Saga pattern implementation that coordinates multi-step write operations with automatic rollback on failure.
Each step races against its own timeout (default: 15 seconds). If a Convex mutation hangs due to a slow network, the timeout fires, and the orchestrator skips to the rollback phase:
private executeWithTimeout<TResult>(step, previousResults): Promise<TResult> { return Promise.race([ step.execute(this.contextSnapshot, previousResults), new Promise<never>((_, reject) => { setTimeout(() => { reject(new Error(`"${step.name}" timed out after ${step.timeoutMs}ms.`)); }, step.timeoutMs); }) ]);}
Rollback Behavior
If Step 2 (SQLite) fails, the orchestrator automatically runs Step 1’s compensating function to undo the Convex mutation. Steps are rolled back in reverse order:If a compensating function itself fails, the rollbackFailed flag is set to true, signaling the HydrationSync engine to perform a full reconciliation on the next cycle.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"CommitT","colors":{"primary":"#C6613F","light":"#E27E5A","dark":"#080808"},"logo":{"light":"https://mintcdn.com/committ/pABZx5mdqCYj-BCa/logo/light.svg?fit=max\u0026auto=format\u0026n=pABZx5mdqCYj-BCa\u0026q=85\u0026s=b3a687d266213456eb9caaf2b48a73ad","dark":"https://mintcdn.com/committ/pABZx5mdqCYj-BCa/logo/dark.svg?fit=max\u0026auto=format\u0026n=pABZx5mdqCYj-BCa\u0026q=85\u0026s=a157767bfb29dcac82d52bb74951c457"},"favicon":"https://mintcdn.com/committ/pABZx5mdqCYj-BCa/favicon.svg?fit=max\u0026auto=format\u0026n=pABZx5mdqCYj-BCa\u0026q=85\u0026s=d7f7eaf307ac7dad41726ac250abe3fa","navbar":{"links":[{"href":"https://github.com/Maajith9127/CommitT/commits/main","label":"Changelog"}],"primary":{"type":"button","label":"Star Us on GitHub","href":"https://github.com/Maajith9127/CommitT"}},"footer":{"socials":{"x":"https://x.com/Maajith_cmt","linkedin":"https://www.linkedin.com/in/abdul-maajith-99165026b","github":"https://github.com/Maajith9127"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"committ","hasAudioNarration":false,"actualSubdomain":"committ","customDomains":[],"gitSource":{"type":"github","owner":"maajith9127","repo":"mintlify-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":"","_id":"6b10c7d79ffae5051c407ad2"},"entitlements":{},"buildId":"6ae942f7773fefe7111041b0:success","clientVersion":"0.0.4448","searchFilterCounts":[{"language":"default","tag":"Journey","count":215},{"language":"default","tag":"2026 Logs","count":187},{"language":"default","tag":"Home","count":134},{"language":"default","tag":"Guides","count":92},{"language":"default","tag":"Client Side","count":64},{"language":"default","tag":"Platform","count":38},{"language":"default","tag":"January","count":31},{"language":"default","tag":"March","count":31},{"language":"default","tag":"June","count":30},{"language":"default","tag":"May","count":30}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[{"filePath":"index.css","content":"::-webkit-scrollbar{display:none}*{scrollbar-width:none;-ms-overflow-style:none}#mintlify-navbar,[class*=\"Navbar\"],header{border-bottom:1px solid rgba(255, 255, 255, 0.1)!important}#mintlify-sidebar,[class*=\"Sidebar\"],nav[aria-label=\"Main\"]{border-right:1px solid rgba(255, 255, 255, 0.1)!important}[class*=\"TableOfContents\"],aside[aria-label=\"On this page\"],.on-this-page{border-left:1px solid rgba(255, 255, 255, 0.1)!important}#mintlify-sidebar nav [class*=\"pl-\"] a,#mintlify-sidebar nav [class*=\"ml-\"] a,#mintlify-sidebar nav ul ul a,[class*=\"Sidebar\"] nav [class*=\"pl-\"] a,[class*=\"Sidebar\"] nav ul ul a,nav[aria-label=\"Main\"] [class*=\"pl-\"] a,nav[aria-label=\"Main\"] ul ul a{font-size:0.8125rem!important;font-weight:400!important;opacity:0.8!important;margin-top:0.25rem!important;margin-bottom:0.25rem!important}#mintlify-sidebar nav [class*=\"pl-\"] a:hover,#mintlify-sidebar nav ul ul a:hover,[class*=\"Sidebar\"] nav [class*=\"pl-\"] a:hover,[class*=\"Sidebar\"] nav ul ul a:hover{opacity:1!important;color:var(--primary-light)!important}#mintlify-sidebar nav [class*=\"pl-\"] a[class*=\"text-primary\"],#mintlify-sidebar nav [class*=\"pl-\"] a[class*=\"text-slate-900\"],#mintlify-sidebar nav [class*=\"pl-\"] a[class*=\"text-white\"],#mintlify-sidebar nav ul ul a[class*=\"text-primary\"],#mintlify-sidebar nav ul ul a[class*=\"text-white\"],[class*=\"Sidebar\"] nav [class*=\"pl-\"] a[class*=\"text-primary\"],[class*=\"Sidebar\"] nav ul ul a[class*=\"text-primary\"]{font-weight:500!important;opacity:1!important}"}]}
{"page":{"pagePath":"architecture/write-gate","slug":"/architecture/write-gate","pageMetadata":{"title":"Write Gate","description":"The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.","href":"/architecture/write-gate"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,hr:`hr`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,Heading,Mermaid,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Mermaid)_missingMdxReference(`Mermaid`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`1`,id:`write-gate-and-sync-lock`,children:`Write Gate and Sync Lock`}),`\n`,_jsxs(_components.p,{children:[`SQLite is a `,_jsx(_components.strong,{children:`single-writer database`}),`. If multiple JavaScript operations attempt concurrent transactions, the native bridge throws `,_jsx(_components.code,{children:`SQLITE_BUSY`}),` or `,_jsx(_components.code,{children:`SQLITE_LOCKED`}),` errors. CommitT solves this with two complementary systems: a `,_jsx(_components.strong,{children:`Promise-chain mutex`}),` and a `,_jsx(_components.strong,{children:`Saga-pattern orchestrator`}),`.`]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`sync-lock-mutex-v2`,children:`Sync Lock Mutex (V2)`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`SyncLock`}),` (`,_jsx(_components.code,{children:`lib/sync-lock.ts`}),`) is a `,_jsx(_components.strong,{children:`singleton Promise-chain mutex`}),` that serializes ALL database writes and hardware alarm sync triggers across the entire application.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`syncLock`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@/lib/sync-lock'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Every database write must go through the lock`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` syncLock`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`execute`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Saga:CreateCommitment\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Source name for diagnostics`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` db`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`withTransactionAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Write operations here`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 15_000`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Timeout: 15 seconds`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`how-the-queue-works`,children:`How the Queue Works`}),`\n`,_jsx(_components.p,{children:`Operations are chained onto a single Promise. Each new caller waits for all preceding callers to finish before executing:`}),`\n`,_jsx(Mermaid,{chart:`sequenceDiagram\n participant A as Background Hydration\n participant L as SyncLock (Singleton)\n participant B as User Saga (Create Task)\n \n A->>L: execute(\"Engine:Hydrate\", ...)\n Note over L: Lock acquired by \"Engine:Hydrate\"\n B->>L: execute(\"Saga:CreateTask\", ...)\n Note over L: \"Saga:CreateTask\" queued, waiting...\n A-->>L: Operation complete\n Note over L: Lock released\n L->>B: Lock acquired by \"Saga:CreateTask\"\n B-->>L: Operation complete\n Note over L: Lock released, queue empty`}),`\n`,_jsx(Heading,{level:`3`,id:`timeout-circuit-breaker`,children:`Timeout Circuit Breaker`}),`\n`,_jsxs(_components.p,{children:[`Every lock holder has a `,_jsx(_components.strong,{children:`hard time limit`}),` (default: 30 seconds). If an operation exceeds this, the lock is forcibly released via `,_jsx(_components.code,{children:`Promise.race`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Promise`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`race`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`([`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` operation`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Promise`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`never`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>((`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`_`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`reject`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` setTimeout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` reject`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' `TIMEOUT: \"'}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sourceName`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\" exceeded `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`timeoutMs`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"ms. `\"}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `Forcibly releasing lock to prevent system deadlock.`\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ));`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`timeoutMs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` })`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]);`})}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`The timeout does NOT abort the underlying operation (you cannot cancel a native SQLite transaction). It simply releases the lock so the next writer does not starve. The timed-out operation’s result is silently discarded.`})}),`\n`,_jsx(Heading,{level:`3`,id:`manual-resync-awareness`,children:`Manual Resync Awareness`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`SyncLock`}),` exposes a public `,_jsx(_components.code,{children:`isManualResyncActive`}),` flag. When set to `,_jsx(_components.code,{children:`true`}),`, the HydrationSync engine suppresses all reconciliation attempts to avoid fighting the manual resync for the lock:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`6`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Manual Resync starts → sets flag → acquires lock → nukes DB → downloads → ingests → clears flag`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` |`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`HydrationSync wakes up → checks flag → sees true → gracefully defers |`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` |`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Without this flag: HydrationSync sees empty token → panics → \"AMNESIA!\" → fights for lock`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`3`,id:`cold-boot-reset`,children:`Cold Boot Reset`}),`\n`,_jsx(_components.p,{children:`On app startup, the lock is explicitly reset to clear any stale state from a prior crash:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`syncLock`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`reset`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Called in SQLiteProvider's onInit`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`This handles the edge case where Android ROMs (notably Lenovo) keep the process alive after a swipe-kill when an Accessibility Service is active.`}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`triple-write-orchestrator`,children:`Triple-Write Orchestrator`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`TripleWriteOrchestrator`}),` (`,_jsx(_components.code,{children:`lib/triple-write-orchestrator.ts`}),`) is a `,_jsx(_components.strong,{children:`Saga pattern`}),` implementation that coordinates multi-step write operations with automatic rollback on failure.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`17`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` saga`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` TripleWriteOrchestrator`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`saga`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`addStep`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Convex Mutation\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` convexMutation`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` convexRollback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Compensating function`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` )`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`addStep`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Local SQLite Write\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`prev`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` sqliteInsert`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`prev`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` sqliteDelete`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` )`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`addStep`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Hardware Alarm Sync\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` scheduleNextAlarm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // No compensating function — alarms are idempotent`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` );`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`success`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`rollbackFailed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` saga`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`execute`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`per-step-timeouts`,children:`Per-Step Timeouts`}),`\n`,_jsx(_components.p,{children:`Each step races against its own timeout (default: 15 seconds). If a Convex mutation hangs due to a slow network, the timeout fires, and the orchestrator skips to the rollback phase:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`private`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` executeWithTimeout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`TResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`step`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`previousResults`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`): `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`Promise`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`TResult`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` return Promise.race(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`[`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` step.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`execute`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`this`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`.contextSnapshot, previousResults),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Promise`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`never`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`>((`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`_`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`reject`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` setTimeout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`(() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` reject`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:'`\"'}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`step`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\" timed out after `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`step`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`timeoutMs`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"ms.`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`));`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` }, step.timeoutMs);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` })`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ]);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`rollback-behavior`,children:`Rollback Behavior`}),`\n`,_jsxs(_components.p,{children:[`If Step 2 (SQLite) fails, the orchestrator automatically runs Step 1’s `,_jsx(_components.strong,{children:`compensating function`}),` to undo the Convex mutation. Steps are rolled back in reverse order:`]}),`\n`,_jsx(Mermaid,{chart:`flowchart LR\n A[\"Step 1: Convex\"] --> B[\"Step 2: SQLite FAILS\"]\n B --> C[\"ROLLBACK: Undo Step 1\"]\n C --> D{\"Rollback succeeded?\"}\n D -->|Yes| E[\"Return error to user\"]\n D -->|No| F[\"Flag for HydrationSync reconciliation\"]`}),`\n`,_jsxs(_components.p,{children:[`If a compensating function itself fails, the `,_jsx(_components.code,{children:`rollbackFailed`}),` flag is set to `,_jsx(_components.code,{children:`true`}),`, signaling the HydrationSync engine to perform a full reconciliation on the next cycle.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Write Gate","description":"The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.","href":"/architecture/write-gate"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Write Gate and Sync Lock","slug":"write-gate-and-sync-lock","depth":1,"children":[]},{"title":"Sync Lock Mutex (V2)","slug":"sync-lock-mutex-v2","depth":2,"children":[{"title":"How the Queue Works","slug":"how-the-queue-works","depth":3,"children":[]},{"title":"Timeout Circuit Breaker","slug":"timeout-circuit-breaker","depth":3,"children":[]},{"title":"Manual Resync Awareness","slug":"manual-resync-awareness","depth":3,"children":[]},{"title":"Cold Boot Reset","slug":"cold-boot-reset","depth":3,"children":[]}]},{"title":"Triple-Write Orchestrator","slug":"triple-write-orchestrator","depth":2,"children":[{"title":"Per-Step Timeouts","slug":"per-step-timeouts","depth":3,"children":[]},{"title":"Rollback Behavior","slug":"rollback-behavior","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/committ/71728093ab0d9611/generate.js"],"subdomain":"committ","siteName":"CommitT","title":"Write Gate - CommitT","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-05-21T03:40:12.623Z","originalFileLocation":"architecture/write-gate.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.\">\u003cmeta data-mint-head name=\"application-name\" content=\"CommitT\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Write Gate - CommitT\">\u003cmeta data-mint-head property=\"og:description\" content=\"The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"CommitT\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://committ.mintlify.app/architecture/write-gate\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://committ.mintlify.site/_mintlify/api/og/v2?division=Architecture\u0026amp;title=Write+Gate\u0026amp;description=The+global+mutex+that+serializes+all+database+writes+and+the+Saga-pattern+Triple-Write+Orchestrator.\u0026amp;theme=610db50c1022cb18da38a94b\u0026amp;signature=c77e5580f4ace201a301b3f78ae3542c6104e52677cb0b8c3fea8c7e98596a76\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Write Gate - CommitT\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://committ.mintlify.site/_mintlify/api/og/v2?division=Architecture\u0026amp;title=Write+Gate\u0026amp;description=The+global+mutex+that+serializes+all+database+writes+and+the+Saga-pattern+Triple-Write+Orchestrator.\u0026amp;theme=610db50c1022cb18da38a94b\u0026amp;signature=c77e5580f4ace201a301b3f78ae3542c6104e52677cb0b8c3fea8c7e98596a76\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/committ/smE-tXl1zonIRnwv/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"CommitT\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#C6613F\">\u003clink data-mint-head rel=\"canonical\" href=\"https://committ.mintlify.app/architecture/write-gate\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/architecture/write-gate.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://committ.mintlify.app/#organization\",\"name\":\"CommitT\",\"url\":\"https://committ.mintlify.app\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/committ/pABZx5mdqCYj-BCa/logo/light.svg?fit=max\u0026auto=format\u0026n=pABZx5mdqCYj-BCa\u0026q=85\u0026s=b3a687d266213456eb9caaf2b48a73ad\"}},{\"@type\":\"WebSite\",\"@id\":\"https://committ.mintlify.app#website\",\"name\":\"CommitT\",\"url\":\"https://committ.mintlify.app\",\"publisher\":{\"@id\":\"https://committ.mintlify.app/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://committ.mintlify.app/architecture/write-gate#webpage\",\"url\":\"https://committ.mintlify.app/architecture/write-gate\",\"name\":\"Write Gate\",\"description\":\"The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.\",\"dateModified\":\"2026-05-21T03:40:12.623Z\",\"isPartOf\":{\"@id\":\"https://committ.mintlify.app#website\"},\"breadcrumb\":{\"@id\":\"https://committ.mintlify.app/architecture/write-gate#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://committ.mintlify.app/architecture/write-gate#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Guides\",\"item\":\"https://committ.mintlify.app/architecture/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Architecture\",\"item\":\"https://committ.mintlify.app/architecture/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Write Gate\",\"item\":\"https://committ.mintlify.app/architecture/write-gate\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://committ.mintlify.app/architecture/write-gate#article\",\"headline\":\"Write Gate\",\"name\":\"Write Gate\",\"description\":\"The global mutex that serializes all database writes and the Saga-pattern Triple-Write Orchestrator.\",\"url\":\"https://committ.mintlify.app/architecture/write-gate\",\"mainEntityOfPage\":{\"@id\":\"https://committ.mintlify.app/architecture/write-gate#webpage\"},\"dateModified\":\"2026-05-21T03:40:12.623Z\",\"publisher\":{\"@id\":\"https://committ.mintlify.app/#organization\"},\"isPartOf\":{\"@id\":\"https://committ.mintlify.app#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"CommitT\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"CommitT\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/architecture/write-gate.md","siteName":"CommitT","nav":{"global":null,"tabs":[{"tab":"Home","icon":"house","groups":[{"group":"Get Started","pages":[{"title":"Welcome to CommitT","href":""},{"group":"Quick Start","icon":"rocket","pages":[{"title":"Quick Start","href":"/quickstart"},{"title":"Environment Setup","href":"/setup-env"},{"title":"Developing","href":"/start-developing"}]}]},{"group":"Platform","pages":[{"group":"Setup \u0026 Permissions","icon":"shield-halved","pages":[{"title":"OS Permissions","href":"/platform/permissions/audit"},{"title":"Accessibility","href":"/platform/permissions/accessibility"},{"title":"Admin Lock","href":"/platform/permissions/admin-lock"},{"title":"Appear On Top","href":"/platform/permissions/appear-on-top"},{"title":"Battery Bypass","href":"/platform/permissions/battery-opt"},{"title":"Camera","href":"/platform/permissions/camera"},{"title":"Location","href":"/platform/permissions/location"},{"title":"Notifications","href":"/platform/permissions/notifications"},{"title":"Alarms","href":"/platform/permissions/alarms"}]},{"group":"Commitment Wizard","icon":"wand-magic-sparkles","pages":[{"title":"Naming \u0026 Conditions","href":"/platform/wizard/naming-conditions"},{"title":"Time Slots","href":"/platform/wizard/time-slots"},{"title":"Slot Attachments","href":"/platform/wizard/attachments"},{"title":"App \u0026 Web Blocking","href":"/platform/wizard/app-web-blocking"},{"title":"Penalties","href":"/platform/wizard/penalties"},{"title":"Penalty Waivers","href":"/platform/wizard/waivers"},{"title":"Verification Modes","href":"/platform/wizard/verification-modes"},{"title":"Alarm Config","href":"/platform/wizard/alarm-config"},{"title":"The Commit Action","href":"/platform/wizard/commit-action"}]},{"group":"Dashboard","icon":"gauge-high","pages":[{"title":"Active CommitTs","href":"/platform/dashboard/active-commits"},{"title":"Upcoming Card","href":"/platform/dashboard/upcoming-card"},{"title":"Verification Modal","href":"/platform/dashboard/verification-modal"}]},{"group":"Calendar","icon":"calendar-check","pages":[{"title":"Calendar View","href":"/platform/calendar/calendar-view"},{"title":"Event Interaction","href":"/platform/calendar/event-interaction"},{"title":"Drag \u0026 Drop","href":"/platform/calendar/drag-drop"},{"title":"Strict Mode","href":"/platform/calendar/strict-mode"}]},{"group":"Presets \u0026 Planning","icon":"bookmark","pages":[{"title":"Location Presets","href":"/platform/presets/location-presets"},{"title":"Blocklist Presets","href":"/platform/presets/blocklist-presets"},{"title":"Rule Presets","href":"/platform/presets/rule-presets"},{"title":"Day Planning","href":"/platform/presets/day-planning"}]},{"group":"Alerts","icon":"bell","pages":[{"title":"Upcoming","href":"/platform/alerts/upcoming"},{"title":"Waivers","href":"/platform/alerts/waivers"},{"title":"Verified","href":"/platform/alerts/verified"}]},{"group":"Profile \u0026 Account","icon":"user-gear","pages":[{"title":"Block Screen","href":"/platform/profile/block-screen"},{"title":"Notifications","href":"/platform/profile/notifications"},{"title":"Full Resync","href":"/platform/profile/resync"},{"title":"Accounts","href":"/platform/profile/accounts"},{"title":"Device Marriage","href":"/platform/profile/device-marriage"}]},{"group":"Advanced","icon":"puzzle-piece","pages":[{"title":"Combo Conditions","href":"/platform/advanced/combo-conditions"}]}]},{"group":"Guides","pages":[{"group":"Architecture","icon":"sitemap","pages":[{"title":"Overview","href":"/architecture/overview"},{"title":"Sync Engine","href":"/architecture/sync-engine"},{"title":"Local Database","description":"The disposable SQLite cache with Nuke and Pave migrations and Instance-Dependent Architecture.","href":"/architecture/local-database"},{"title":"Write Gate","href":"/architecture/write-gate"},{"title":"State Management","description":"Zustand stores powering the entire client-side state machine.","href":"/architecture/state-management"},{"title":"App Routes","href":"/architecture/app-routes"}]},{"group":"Client Side","icon":"display","pages":[{"title":"Client-Side Overview","icon":"map","href":"/client-side/overview"},{"title":"Folder Structure","href":"/client-side/folder-structure"},{"group":"Routing and Screens","pages":[{"title":"Root Layout and Provider Tree","href":"/client-side/routing/root-layout"},{"title":"Authentication Flow","href":"/client-side/routing/auth-flow"},{"title":"Dashboard and Main Tabs","href":"/client-side/routing/dashboard"},{"title":"Commitment Wizard","href":"/client-side/routing/commitment-wizard"},{"title":"Time and Location Setup","href":"/client-side/routing/time-location"},{"title":"App Blocker Screen","href":"/client-side/routing/app-blocker"},{"title":"Calendar and Schedules","href":"/client-side/routing/calendar-schedules"},{"title":"Penalties Configuration","href":"/client-side/routing/penalties-flow"},{"title":"Penalty Waivers Flow","href":"/client-side/routing/waivers-flow"},{"title":"Settings and Permissions","href":"/client-side/routing/settings-permissions"},{"title":"Strict Mode Setup","href":"/client-side/routing/strict-mode"},{"title":"Preset Editing","href":"/client-side/routing/preset-editing"},{"title":"Verification Flow","href":"/client-side/routing/verification-flow"}]},{"group":"State Management","pages":[{"title":"Task Draft Store","href":"/client-side/state/task-draft-store"},{"title":"Calendar Store","href":"/client-side/state/calendar-store"},{"title":"Preset Store","href":"/client-side/state/preset-store"},{"title":"Commit Store","href":"/client-side/state/commit-store"},{"title":"Verification Store","href":"/client-side/state/verification-store"},{"title":"Heal Store","href":"/client-side/state/heal-store"},{"title":"Preset Edit Store","href":"/client-side/state/preset-edit-store"},{"title":"App Store","href":"/client-side/state/app-store"},{"title":"Task Store","href":"/client-side/state/task-store"},{"title":"Chaos Store","href":"/client-side/state/chaos-store"}]},{"group":"Core Infrastructure","pages":[{"title":"Triple-Write Orchestrator","href":"/client-side/infrastructure/triple-write"},{"title":"Sync Engine","href":"/client-side/infrastructure/sync-engine"},{"title":"Sync Lock Mutex","href":"/client-side/infrastructure/sync-lock"},{"title":"Local Database Schema","href":"/client-side/infrastructure/local-database"},{"title":"Local DB Commits","href":"/client-side/infrastructure/local-db-commits"},{"title":"Local DB Instances","href":"/client-side/infrastructure/local-db-instances"},{"title":"Logger","href":"/client-side/infrastructure/logger"},{"title":"Scheduler Bridge","href":"/client-side/infrastructure/scheduler-bridge"},{"title":"Auth Client","href":"/client-side/infrastructure/auth-client"},{"title":"Time Utilities","href":"/client-side/infrastructure/time-utilities"},{"title":"Validation","href":"/client-side/infrastructure/validation"}]},{"group":"Hooks","pages":[{"title":"useHydrationSync","href":"/client-side/hooks/hydration-sync"},{"title":"usePresetHydration","href":"/client-side/hooks/preset-hydration"},{"title":"useCommitTask","href":"/client-side/hooks/commit-task"},{"title":"useTaskActions","href":"/client-side/hooks/task-actions"},{"title":"useTasks","href":"/client-side/hooks/tasks"},{"title":"useVerificationEngine","href":"/client-side/hooks/verification-engine"},{"title":"useUpcomingVerification","href":"/client-side/hooks/upcoming-verification"},{"title":"useLocation","href":"/client-side/hooks/location"},{"title":"usePermissions","href":"/client-side/hooks/permissions"},{"title":"useCalendarEvents","href":"/client-side/hooks/calendar-events"},{"title":"useCalendarRange","href":"/client-side/hooks/calendar-range"},{"title":"useEventDetail","href":"/client-side/hooks/event-detail"},{"title":"usePenaltySync","href":"/client-side/hooks/penalty-sync"},{"title":"useWaiverSync","href":"/client-side/hooks/waiver-sync"},{"title":"useTaskSelection","href":"/client-side/hooks/task-selection"},{"title":"useAppDiscovery","href":"/client-side/hooks/app-discovery"},{"title":"useAccountabilityPrefill","href":"/client-side/hooks/accountability-prefill"},{"title":"useFreshPhotoUrl","href":"/client-side/hooks/fresh-photo-url"}]},{"group":"Components","pages":[{"title":"HydrationEngine","href":"/client-side/components/hydration-engine"},{"title":"SecurityShield","href":"/client-side/components/security-shield"},{"title":"ConnectionWatchdog","href":"/client-side/components/connection-watchdog"},{"title":"HealOverlay","href":"/client-side/components/heal-overlay"},{"title":"UI Components","href":"/client-side/components/ui-components"},{"title":"Developer Tools","href":"/client-side/components/dev-tools"}]},{"group":"Providers and Contexts","pages":[{"title":"ResurrectionProvider","href":"/client-side/providers/resurrection"},{"title":"ConvexClientWrapper","href":"/client-side/providers/convex-wrapper"},{"title":"App Theme Context","href":"/client-side/providers/app-theme"},{"title":"Tab Context","href":"/client-side/providers/tab-context"}]}]},{"group":"Convex Backend \u0026 Packages","icon":"server","pages":[{"title":"Backend \u0026 Packages Overview","icon":"server","href":"/backend/overview"},{"title":"Schema","href":"/backend/schema"},{"group":"Convex Endpoints","pages":[{"title":"Convex Endpoints (API)","href":"/backend/api/overview"}]},{"group":"Convex Core Logic","pages":[{"title":"Core Business Logic","href":"/backend/core/overview"}]},{"group":"Convex Database","pages":[{"title":"Database \u0026 Schema","href":"/backend/db/overview"}]},{"group":"Convex Execution","pages":[{"title":"Execution \u0026 Cron Jobs","href":"/backend/execution/overview"}]},{"group":"Convex AI","pages":[{"title":"AI \u0026 Computer Vision","href":"/backend/ai/overview"}]},{"group":"Convex Middleware","pages":[{"title":"Middleware \u0026 Auth","href":"/backend/middleware/overview"}]},{"group":"Convex Lib","pages":[{"title":"Shared Lib \u0026 Types","href":"/backend/lib/overview"}]},{"group":"Shared Packages","pages":[{"title":"Config Package","href":"/backend/packages/config"},{"title":"Env Package","href":"/backend/packages/env"},{"title":"Telemetry Package","href":"/backend/packages/telemetry"},{"title":"Monitoring Extension","href":"/backend/packages/extension"},{"title":"Monitoring Mobile","href":"/backend/packages/mobile"}]}]},{"group":"Native Modules","icon":"microchip","pages":[{"title":"Overview","icon":"microchip","href":"/native-modules/overview"},{"title":"Alarm Module","href":"/native-modules/alarm-module"},{"title":"App Lister Module","href":"/native-modules/app-lister-module"},{"title":"Blocker Module","href":"/native-modules/blocker-module"},{"title":"Enforcement Module","href":"/native-modules/enforcement-module"},{"title":"Logcat Module","href":"/native-modules/logcat-module"},{"title":"Recovery \u0026 Alarm Modules","href":"/native-modules/recovery-module"},{"title":"Scheduler Module","href":"/native-modules/scheduler-module"}]}]}]},{"tab":"Journey","icon":"route","pages":[{"title":"Journey","href":"/2025/december/day-04"}]},{"tab":"IG Brand","icon":"instagram","pages":[{"title":"IG Brand","href":"/ig-brand/overview"}]}]},"basePath":"","title":"Write Gate - CommitT","deploymentId":"dpl_XLevHnGPjzxq9mbREha5Faad63Sp","buildId":"dpl_XLevHnGPjzxq9mbREha5Faad63Sp","dynamics":[],"chunks":[]}