From 441d7f664c287f570323523d75e0d67fc88c6b3f Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:17:43 +0000 Subject: [PATCH 01/44] chore(decispher): update .decispher/decisions.md --- .decispher/decisions.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.decispher/decisions.md b/.decispher/decisions.md index 3e3b20e..f9fe996 100644 --- a/.decispher/decisions.md +++ b/.decispher/decisions.md @@ -1,3 +1,21 @@ + +## Decision: Standardization on iPhones for mobile communication + +**Status**: Active +**Date**: 2026-05-05 +**Severity**: Info + +**Files**: +- `**/*` + +### Context + +**Decision:** The team will use iPhones to perform mobile calls. + +**Rationale:** The team aligned on a single mobile device platform for communication consistency. + +--- + ## Decision: Use RFC 307895 for JSON theme validation From 54b13f27cde78cb7dc5fa12634d0e59870910a6f Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:17:45 +0000 Subject: [PATCH 02/44] chore(decispher): update .cursorrules --- .cursorrules | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cursorrules b/.cursorrules index 1b06f9e..b8e4c98 100644 --- a/.cursorrules +++ b/.cursorrules @@ -1,6 +1,12 @@ # Project Decisions & Conventions # Auto-generated by Decispher — Do not edit manually +## Mobile + +- The team will use iPhones to perform mobile calls. + Rationale: The team aligned on a single mobile device platform for communication consistency. + Files: * + ## Validation - Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. From d54749bd7e903bdfe74137803d799e7318b3881c Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:17:47 +0000 Subject: [PATCH 03/44] chore(decispher): update CLAUDE.md --- CLAUDE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index bf29da2..1d9b1b0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,6 +8,10 @@ Violating these decisions requires explicit approval. ## Active Decisions +### Standardization on iPhones for mobile communication (LOW) +- **Decision:** The team will use iPhones to perform mobile calls. +- **Rationale:** The team aligned on a single mobile device platform for communication consistency. + ### Use RFC 307895 for JSON theme validation (MEDIUM) - **Decision:** Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. - **Rationale:** Adopting an existing RFC provides a standardized, well-documented approach to input validation, ensuring consistency and security for custom theme data handling. From 97e7cd62c43e12fa3982b4a41eac6a32021e1d2d Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:17:50 +0000 Subject: [PATCH 04/44] chore(decispher): update .github/copilot-instructions.md --- .github/copilot-instructions.md | 59 +++++++++++++++++---------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 6cd654d..6280aa7 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -3,32 +3,33 @@ When generating code for this project, follow these rules: -1. Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. -2. Migrate the core decision storage from PostgreSQL to MongoDB, utilizing MongoDB Atlas for vector search capabilities. -3. Migrate all email services to Zoho and update the SMTP server infrastructure, including the implementation of new routing rules to block any traffic to the legacy SMTP server. -4. Switch from the third-party Shipsy provider to an in-house developed mapping event system. -5. We have decided to officially discontinue the use of RFC 7807 (Problem Details for HTTP APIs) for all API error responses moving forward. -6. All new vector indexes must be created using the HNSW algorithm. Existing IVFFlat indexes (specifically in the llm_cache table) are to be migrated to HNSW in Sprint 16. -7. Adopt the HIGH severity specification as the authoritative version for the RFC 7807 error format, which includes fields: type, title, status, detail, and instance. -8. Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. -9. Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. -10. The team will migrate from AWS ECS to AWS EKS for container orchestration. -11. We have standardized on cosine distance (using the <=> operator in pgvector) for all similarity search operations. -12. MongoDB is strictly prohibited for use in core pipeline services (including the core decision pipeline, authentication, and the context store). These services must exclusively use PostgreSQL 16 and Redis. Any deviation requires a formal ADR. -13. The core pipeline must exclusively use PostgreSQL 16 with pgvector and Redis; the use of MongoDB is strictly prohibited. -14. Use PostgreSQL with pgvector and HNSW indexes as the standard solution for primary datastore and vector search operations. -15. Use MongoDB Atlas specifically for the analytics event ingestion pipeline, while keeping all other core application data in PostgreSQL. -16. The team decided to discontinue the use of EventStoreDB and removed event sourcing as an architectural pattern following the migration back to a monorepo. -17. All internal API routes must adhere to the RFC 7807 error format, consistent with public-facing API routes. -18. We will use MongoDB for the analytics events pipeline, provisioning a MongoDB Atlas cluster to handle the data. -19. Each LLM pipeline step (detection, extraction, formatting) has its own provider configuration managed via environment variables. An 'effort mode' concept allows overriding these configurations per company at request time, defining specific LLM models for different quality/cost tiers: Saver uses gemini-flash, Balanced mixes gemini-flash, claude-haiku, and gpt-4o-mini, Pro uses claude-sonnet for extraction, and Super uses claude-opus. -20. After evaluating MongoDB, DynamoDB, and PostgreSQL, we chose PostgreSQL 16 with pgvector HNSW indexes. Reason: vector similarity search, ACID guarantees, and single DB for both structured data and embeddings. -21. We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. -22. Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. -23. MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. -24. The trigger metric for initiating the AWS migration has been adjusted from 20 paying customers to 30 paying customers. The Q3 2026 timeline for the migration still holds. -25. We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. -26. The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. -27. MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. -28. The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. -29. We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. +1. The team will use iPhones to perform mobile calls. +2. Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. +3. Migrate the core decision storage from PostgreSQL to MongoDB, utilizing MongoDB Atlas for vector search capabilities. +4. Migrate all email services to Zoho and update the SMTP server infrastructure, including the implementation of new routing rules to block any traffic to the legacy SMTP server. +5. Switch from the third-party Shipsy provider to an in-house developed mapping event system. +6. We have decided to officially discontinue the use of RFC 7807 (Problem Details for HTTP APIs) for all API error responses moving forward. +7. All new vector indexes must be created using the HNSW algorithm. Existing IVFFlat indexes (specifically in the llm_cache table) are to be migrated to HNSW in Sprint 16. +8. Adopt the HIGH severity specification as the authoritative version for the RFC 7807 error format, which includes fields: type, title, status, detail, and instance. +9. Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. +10. Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. +11. The team will migrate from AWS ECS to AWS EKS for container orchestration. +12. We have standardized on cosine distance (using the <=> operator in pgvector) for all similarity search operations. +13. MongoDB is strictly prohibited for use in core pipeline services (including the core decision pipeline, authentication, and the context store). These services must exclusively use PostgreSQL 16 and Redis. Any deviation requires a formal ADR. +14. The core pipeline must exclusively use PostgreSQL 16 with pgvector and Redis; the use of MongoDB is strictly prohibited. +15. Use PostgreSQL with pgvector and HNSW indexes as the standard solution for primary datastore and vector search operations. +16. Use MongoDB Atlas specifically for the analytics event ingestion pipeline, while keeping all other core application data in PostgreSQL. +17. The team decided to discontinue the use of EventStoreDB and removed event sourcing as an architectural pattern following the migration back to a monorepo. +18. All internal API routes must adhere to the RFC 7807 error format, consistent with public-facing API routes. +19. We will use MongoDB for the analytics events pipeline, provisioning a MongoDB Atlas cluster to handle the data. +20. Each LLM pipeline step (detection, extraction, formatting) has its own provider configuration managed via environment variables. An 'effort mode' concept allows overriding these configurations per company at request time, defining specific LLM models for different quality/cost tiers: Saver uses gemini-flash, Balanced mixes gemini-flash, claude-haiku, and gpt-4o-mini, Pro uses claude-sonnet for extraction, and Super uses claude-opus. +21. After evaluating MongoDB, DynamoDB, and PostgreSQL, we chose PostgreSQL 16 with pgvector HNSW indexes. Reason: vector similarity search, ACID guarantees, and single DB for both structured data and embeddings. +22. We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. +23. Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. +24. MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. +25. The trigger metric for initiating the AWS migration has been adjusted from 20 paying customers to 30 paying customers. The Q3 2026 timeline for the migration still holds. +26. We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. +27. The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. +28. MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. +29. The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. +30. We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. From aebd0172c9953c539a873a06ea70360cb84c2a19 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:17:52 +0000 Subject: [PATCH 05/44] chore(decispher): update AGENTS.md --- AGENTS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index a6de045..edb100e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -49,3 +49,9 @@ Any code change that violates these decisions MUST be flagged. | We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. | Cosine distance is invariant to vector magnitude, meaning it only considers the direction of vectors. This property is precisely what is desired for semantic similarity of text embeddings, as it allows for accurate comparison of semantic meaning regardless of variations in embedding vector norms. L2 (Euclidean) distance, on the other hand, would incorrectly penalize vectors with different magnitudes, even if they share the same semantic direction. | * | | Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. | Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. | * | | The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. | This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. | packages/api/src/billing/ | + +### LOW + +| Decision | Rationale | Files | +|----------|-----------|-------| +| The team will use iPhones to perform mobile calls. | The team aligned on a single mobile device platform for communication consistency. | * | From a62b8cccf4c155798f69748b563b151244ba0e5b Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:17:54 +0000 Subject: [PATCH 06/44] chore(decispher): update .decispher/context-rules.json --- .decispher/context-rules.json | 51 ++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/.decispher/context-rules.json b/.decispher/context-rules.json index bdc8dd1..0118f52 100644 --- a/.decispher/context-rules.json +++ b/.decispher/context-rules.json @@ -1,12 +1,12 @@ { "$schema": "https://decispher.dev/schemas/context-rules/v1.json", "specVersion": "1.0.0", - "generatedAt": "2026-05-05T10:03:57.578Z", + "generatedAt": "2026-05-05T12:17:28.883Z", "companyId": "1489dcdc-ef7f-4cc5-b0cb-b453efa059f4", "meta": { - "totalRules": 28, + "totalRules": 29, "rulesByType": { - "decision": 19, + "decision": 20, "convention": 2, "constraint": 3, "rationale": 0, @@ -18,11 +18,54 @@ "CRITICAL": 3, "HIGH": 15, "MEDIUM": 10, - "LOW": 0 + "LOW": 1 }, "generator": "decispher-ai-blocker@1.0.0" }, "rules": [ + { + "id": "606e27a4-4b72-485e-94dd-7a2008e80874", + "type": "decision", + "title": "Standardization on iPhones for mobile communication", + "problem": null, + "decision": "The team will use iPhones to perform mobile calls.", + "rationale": "The team aligned on a single mobile device platform for communication consistency.", + "severity": "LOW", + "status": "active", + "confidence": 0.45, + "affectedFiles": [], + "tags": [ + "mobile", + "iphone", + "communication" + ], + "alternatives": [], + "sources": [ + { + "type": "slack", + "confidence": 0.45, + "ref": { + "priority": "high", + "threadTs": "1777983344.187829", + "channelId": "C0ALKBAGZQS", + "sourceUrl": "https://newworkspace-zdx9462.slack.com/archives/C0ALKBAGZQS/p1777983344187829?thread_ts=1777983344.187829&cid=C0ALKBAGZQS", + "channelName": "bot-test-1", + "slackTeamId": null, + "triggeredBy": "U05F9P78LTG", + "detectionMethod": "explicit", + "triggeredByName": "Ali Abbas" + }, + "snippet": "The team will use iPhones to perform mobile calls." + } + ], + "supersededBy": null, + "enforcement": null, + "createdAt": "2026-05-05T12:16:07.372Z", + "updatedAt": "2026-05-05T12:17:28.718Z", + "version": 1, + "createdBy": "U05F9P78LTG", + "reviewedBy": "U05F9P78LTG" + }, { "id": "1fbd69ae-f638-48bd-869d-cd54a993f0b0", "type": "decision", From fc8b72dd484892c9386c4ad9e0312d6c8b8e867e Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:17:55 +0000 Subject: [PATCH 07/44] chore(decispher): update .windsurfrules --- .windsurfrules | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.windsurfrules b/.windsurfrules index b009c79..612ec06 100644 --- a/.windsurfrules +++ b/.windsurfrules @@ -114,3 +114,8 @@ Cascade MUST respect these rules when generating or modifying code. - The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. Reason: This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. Files: packages/api/src/billing/ + +## [LOW] + +- The team will use iPhones to perform mobile calls. + Reason: The team aligned on a single mobile device platform for communication consistency. From 65756e415c86105b8da662544c9be87b58280d8a Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:17:58 +0000 Subject: [PATCH 08/44] chore(decispher): update .clinerules --- .clinerules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.clinerules b/.clinerules index 9ed355e..daebec1 100644 --- a/.clinerules +++ b/.clinerules @@ -109,3 +109,6 @@ Before writing or modifying code, review these rules and do not violate them. 29. 🟡 **[MEDIUM]** The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. - **Why:** This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. - **Files:** `packages/api/src/billing/` + +30. 🟢 **[LOW]** The team will use iPhones to perform mobile calls. + - **Why:** The team aligned on a single mobile device platform for communication consistency. From abb422f4596dd0b4c4620982603bb8827c3e2ed3 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:18:00 +0000 Subject: [PATCH 09/44] chore(decispher): update .aider/conventions.md --- .aider/conventions.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.aider/conventions.md b/.aider/conventions.md index 9dff479..02497ef 100644 --- a/.aider/conventions.md +++ b/.aider/conventions.md @@ -4,6 +4,14 @@ These are the active engineering decisions for this repository. Aider should follow all of these conventions when making changes. +## Mobile + +### Standardization on iPhones for mobile communication + +**Convention:** The team will use iPhones to perform mobile calls. + +**Why:** The team aligned on a single mobile device platform for communication consistency. + ## Validation ### Use RFC 307895 for JSON theme validation From a8d91c9ac23ffcbf5167caac6614f17c9f9bc549 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:18:02 +0000 Subject: [PATCH 10/44] chore(decispher): update .devin/rules.md --- .devin/rules.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.devin/rules.md b/.devin/rules.md index 1554e5d..4bcbf08 100644 --- a/.devin/rules.md +++ b/.devin/rules.md @@ -281,3 +281,10 @@ Devin MUST follow all rules below. Do not deviate without explicit instruction. - **Rationale:** This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. - **Scope:** packages/api/src/billing/ - **Tags:** billing, ownership, team + +### Standardization on iPhones for mobile communication + +- **Severity:** LOW +- **Rule:** The team will use iPhones to perform mobile calls. +- **Rationale:** The team aligned on a single mobile device platform for communication consistency. +- **Tags:** mobile, iphone, communication From 0897aa0c8ff3d41af023565fb1a13f916be409e3 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:18:04 +0000 Subject: [PATCH 11/44] chore(decispher): update .roo/rules.md --- .roo/rules.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.roo/rules.md b/.roo/rules.md index 6d596c2..af96a26 100644 --- a/.roo/rules.md +++ b/.roo/rules.md @@ -73,6 +73,9 @@ ## General Conventions +- **Standardization on iPhones for mobile communication:** The team will use iPhones to perform mobile calls. + *(The team aligned on a single mobile device platform for communication consistency.)* + - **Use RFC 307895 for JSON theme validation:** Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. *(Adopting an existing RFC provides a standardized, well-documented approach to input validation, ensuring consistency and security for custom theme data handling.)* From 2863567912886656c952bda54c5ee2ad1767be30 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:03 +0000 Subject: [PATCH 12/44] chore(decispher): update .decispher/decisions.md --- .decispher/decisions.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/.decispher/decisions.md b/.decispher/decisions.md index f9fe996..789db0a 100644 --- a/.decispher/decisions.md +++ b/.decispher/decisions.md @@ -1,3 +1,44 @@ + +## Decision: Replace awk with sed in src/payment.ts bash scripts + +**Status**: Active +**Date**: 2026-05-05 +**Severity**: Info + +**Files**: +- `src/payment.ts` + +**Rules**: +```json +{ + "conditions": [ + { + "type": "file", + "pattern": "src/payment.ts", + "content_rules": [ + { + "mode": "string", + "patterns": [ + "awk" + ] + } + ] + } + ], + "match_mode": "all" +} +``` + +### Context + +**Problem:** Current awk commands used within the bash script in src/payment.ts are causing performance delays. + +**Decision:** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. + +**Rationale:** The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. + +--- + ## Decision: Standardization on iPhones for mobile communication From 3a5786b7d71b53339244204650fa968c5e7b7448 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:05 +0000 Subject: [PATCH 13/44] chore(decispher): update .cursorrules --- .cursorrules | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cursorrules b/.cursorrules index b8e4c98..8e21b96 100644 --- a/.cursorrules +++ b/.cursorrules @@ -1,6 +1,12 @@ # Project Decisions & Conventions # Auto-generated by Decispher — Do not edit manually +## Performance + +- Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. + Rationale: The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. + Files: src/payment.ts + ## Mobile - The team will use iPhones to perform mobile calls. From 66abef39a145b767f0271c920a54aeca5a640e1f Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:07 +0000 Subject: [PATCH 14/44] chore(decispher): update CLAUDE.md --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 1d9b1b0..7b9aaeb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,6 +8,11 @@ Violating these decisions requires explicit approval. ## Active Decisions +### Replace awk with sed in src/payment.ts bash scripts (LOW) +- **Decision:** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. +- **Rationale:** The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. +- **Affected files:** `src/payment.ts` + ### Standardization on iPhones for mobile communication (LOW) - **Decision:** The team will use iPhones to perform mobile calls. - **Rationale:** The team aligned on a single mobile device platform for communication consistency. From 8b5da2f5826a70b36eab77038fc70b40569631f1 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:09 +0000 Subject: [PATCH 15/44] chore(decispher): update .github/copilot-instructions.md --- .github/copilot-instructions.md | 61 +++++++++++++++++---------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 6280aa7..b20965c 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -3,33 +3,34 @@ When generating code for this project, follow these rules: -1. The team will use iPhones to perform mobile calls. -2. Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. -3. Migrate the core decision storage from PostgreSQL to MongoDB, utilizing MongoDB Atlas for vector search capabilities. -4. Migrate all email services to Zoho and update the SMTP server infrastructure, including the implementation of new routing rules to block any traffic to the legacy SMTP server. -5. Switch from the third-party Shipsy provider to an in-house developed mapping event system. -6. We have decided to officially discontinue the use of RFC 7807 (Problem Details for HTTP APIs) for all API error responses moving forward. -7. All new vector indexes must be created using the HNSW algorithm. Existing IVFFlat indexes (specifically in the llm_cache table) are to be migrated to HNSW in Sprint 16. -8. Adopt the HIGH severity specification as the authoritative version for the RFC 7807 error format, which includes fields: type, title, status, detail, and instance. -9. Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. -10. Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. -11. The team will migrate from AWS ECS to AWS EKS for container orchestration. -12. We have standardized on cosine distance (using the <=> operator in pgvector) for all similarity search operations. -13. MongoDB is strictly prohibited for use in core pipeline services (including the core decision pipeline, authentication, and the context store). These services must exclusively use PostgreSQL 16 and Redis. Any deviation requires a formal ADR. -14. The core pipeline must exclusively use PostgreSQL 16 with pgvector and Redis; the use of MongoDB is strictly prohibited. -15. Use PostgreSQL with pgvector and HNSW indexes as the standard solution for primary datastore and vector search operations. -16. Use MongoDB Atlas specifically for the analytics event ingestion pipeline, while keeping all other core application data in PostgreSQL. -17. The team decided to discontinue the use of EventStoreDB and removed event sourcing as an architectural pattern following the migration back to a monorepo. -18. All internal API routes must adhere to the RFC 7807 error format, consistent with public-facing API routes. -19. We will use MongoDB for the analytics events pipeline, provisioning a MongoDB Atlas cluster to handle the data. -20. Each LLM pipeline step (detection, extraction, formatting) has its own provider configuration managed via environment variables. An 'effort mode' concept allows overriding these configurations per company at request time, defining specific LLM models for different quality/cost tiers: Saver uses gemini-flash, Balanced mixes gemini-flash, claude-haiku, and gpt-4o-mini, Pro uses claude-sonnet for extraction, and Super uses claude-opus. -21. After evaluating MongoDB, DynamoDB, and PostgreSQL, we chose PostgreSQL 16 with pgvector HNSW indexes. Reason: vector similarity search, ACID guarantees, and single DB for both structured data and embeddings. -22. We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. -23. Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. -24. MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. -25. The trigger metric for initiating the AWS migration has been adjusted from 20 paying customers to 30 paying customers. The Q3 2026 timeline for the migration still holds. -26. We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. -27. The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. -28. MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. -29. The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. -30. We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. +1. Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. +2. The team will use iPhones to perform mobile calls. +3. Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. +4. Migrate the core decision storage from PostgreSQL to MongoDB, utilizing MongoDB Atlas for vector search capabilities. +5. Migrate all email services to Zoho and update the SMTP server infrastructure, including the implementation of new routing rules to block any traffic to the legacy SMTP server. +6. Switch from the third-party Shipsy provider to an in-house developed mapping event system. +7. We have decided to officially discontinue the use of RFC 7807 (Problem Details for HTTP APIs) for all API error responses moving forward. +8. All new vector indexes must be created using the HNSW algorithm. Existing IVFFlat indexes (specifically in the llm_cache table) are to be migrated to HNSW in Sprint 16. +9. Adopt the HIGH severity specification as the authoritative version for the RFC 7807 error format, which includes fields: type, title, status, detail, and instance. +10. Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. +11. Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. +12. The team will migrate from AWS ECS to AWS EKS for container orchestration. +13. We have standardized on cosine distance (using the <=> operator in pgvector) for all similarity search operations. +14. MongoDB is strictly prohibited for use in core pipeline services (including the core decision pipeline, authentication, and the context store). These services must exclusively use PostgreSQL 16 and Redis. Any deviation requires a formal ADR. +15. The core pipeline must exclusively use PostgreSQL 16 with pgvector and Redis; the use of MongoDB is strictly prohibited. +16. Use PostgreSQL with pgvector and HNSW indexes as the standard solution for primary datastore and vector search operations. +17. Use MongoDB Atlas specifically for the analytics event ingestion pipeline, while keeping all other core application data in PostgreSQL. +18. The team decided to discontinue the use of EventStoreDB and removed event sourcing as an architectural pattern following the migration back to a monorepo. +19. All internal API routes must adhere to the RFC 7807 error format, consistent with public-facing API routes. +20. We will use MongoDB for the analytics events pipeline, provisioning a MongoDB Atlas cluster to handle the data. +21. Each LLM pipeline step (detection, extraction, formatting) has its own provider configuration managed via environment variables. An 'effort mode' concept allows overriding these configurations per company at request time, defining specific LLM models for different quality/cost tiers: Saver uses gemini-flash, Balanced mixes gemini-flash, claude-haiku, and gpt-4o-mini, Pro uses claude-sonnet for extraction, and Super uses claude-opus. +22. After evaluating MongoDB, DynamoDB, and PostgreSQL, we chose PostgreSQL 16 with pgvector HNSW indexes. Reason: vector similarity search, ACID guarantees, and single DB for both structured data and embeddings. +23. We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. +24. Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. +25. MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. +26. The trigger metric for initiating the AWS migration has been adjusted from 20 paying customers to 30 paying customers. The Q3 2026 timeline for the migration still holds. +27. We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. +28. The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. +29. MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. +30. The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. +31. We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. From ec606616aa62063a4703517c82f4be20c3857c2b Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:11 +0000 Subject: [PATCH 16/44] chore(decispher): update AGENTS.md --- AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AGENTS.md b/AGENTS.md index edb100e..ef9f2bb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -54,4 +54,5 @@ Any code change that violates these decisions MUST be flagged. | Decision | Rationale | Files | |----------|-----------|-------| +| Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. | The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. | src/payment.ts | | The team will use iPhones to perform mobile calls. | The team aligned on a single mobile device platform for communication consistency. | * | From ba5c5a4f2685a69b464c0a565e7184b59af3f71d Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:13 +0000 Subject: [PATCH 17/44] chore(decispher): update .decispher/context-rules.json --- .decispher/context-rules.json | 61 ++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/.decispher/context-rules.json b/.decispher/context-rules.json index 0118f52..310984e 100644 --- a/.decispher/context-rules.json +++ b/.decispher/context-rules.json @@ -1,12 +1,12 @@ { "$schema": "https://decispher.dev/schemas/context-rules/v1.json", "specVersion": "1.0.0", - "generatedAt": "2026-05-05T12:17:28.883Z", + "generatedAt": "2026-05-05T12:20:51.663Z", "companyId": "1489dcdc-ef7f-4cc5-b0cb-b453efa059f4", "meta": { - "totalRules": 29, + "totalRules": 30, "rulesByType": { - "decision": 20, + "decision": 21, "convention": 2, "constraint": 3, "rationale": 0, @@ -18,11 +18,64 @@ "CRITICAL": 3, "HIGH": 15, "MEDIUM": 10, - "LOW": 1 + "LOW": 2 }, "generator": "decispher-ai-blocker@1.0.0" }, "rules": [ + { + "id": "0170331f-f276-46d6-a601-54093718039f", + "type": "decision", + "title": "Replace awk with sed in src/payment.ts bash scripts", + "problem": "Current awk commands used within the bash script in src/payment.ts are causing performance delays.", + "decision": "Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands.", + "rationale": "The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues.", + "severity": "LOW", + "status": "active", + "confidence": 0.48, + "affectedFiles": [ + "src/payment.ts" + ], + "tags": [ + "performance", + "bash", + "refactoring", + "scripting" + ], + "alternatives": [], + "sources": [ + { + "type": "slack", + "confidence": 0.48, + "ref": { + "priority": "high", + "threadTs": "1777983539.585479", + "channelId": "C0ALKBAGZQS", + "sourceUrl": "https://newworkspace-zdx9462.slack.com/archives/C0ALKBAGZQS/p1777983539585479?thread_ts=1777983539.585479&cid=C0ALKBAGZQS", + "channelName": "bot-test-1", + "slackTeamId": null, + "triggeredBy": "U05F9P78LTG", + "detectionMethod": "explicit", + "triggeredByName": "Ali Abbas" + }, + "snippet": "Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands." + } + ], + "supersededBy": null, + "enforcement": { + "blockOnViolation": false, + "requiresExplicitOverride": false, + "filePatterns": [ + "src/payment.ts" + ], + "exemptPatterns": [] + }, + "createdAt": "2026-05-05T12:19:32.050Z", + "updatedAt": "2026-05-05T12:20:51.371Z", + "version": 1, + "createdBy": "U05F9P78LTG", + "reviewedBy": "U05F9P78LTG" + }, { "id": "606e27a4-4b72-485e-94dd-7a2008e80874", "type": "decision", From 3b6f203632386332eeac8ba9b1e791d1637166f9 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:15 +0000 Subject: [PATCH 18/44] chore(decispher): update .windsurfrules --- .windsurfrules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.windsurfrules b/.windsurfrules index 612ec06..eabf6ef 100644 --- a/.windsurfrules +++ b/.windsurfrules @@ -117,5 +117,9 @@ Cascade MUST respect these rules when generating or modifying code. ## [LOW] +- Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. + Reason: The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. + Files: src/payment.ts + - The team will use iPhones to perform mobile calls. Reason: The team aligned on a single mobile device platform for communication consistency. From dbb7c819af29662e0308a912fc3c08cf206827c7 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:17 +0000 Subject: [PATCH 19/44] chore(decispher): update .clinerules --- .clinerules | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.clinerules b/.clinerules index daebec1..a2515ca 100644 --- a/.clinerules +++ b/.clinerules @@ -110,5 +110,9 @@ Before writing or modifying code, review these rules and do not violate them. - **Why:** This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. - **Files:** `packages/api/src/billing/` -30. 🟢 **[LOW]** The team will use iPhones to perform mobile calls. +30. 🟢 **[LOW]** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. + - **Why:** The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. + - **Files:** `src/payment.ts` + +31. 🟢 **[LOW]** The team will use iPhones to perform mobile calls. - **Why:** The team aligned on a single mobile device platform for communication consistency. From d8156b34237ed91dc9917a3e14cc521ec753a9c3 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:18 +0000 Subject: [PATCH 20/44] chore(decispher): update .aider/conventions.md --- .aider/conventions.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.aider/conventions.md b/.aider/conventions.md index 02497ef..b4adb85 100644 --- a/.aider/conventions.md +++ b/.aider/conventions.md @@ -4,6 +4,16 @@ These are the active engineering decisions for this repository. Aider should follow all of these conventions when making changes. +## Performance + +### Replace awk with sed in src/payment.ts bash scripts + +**Convention:** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. + +**Why:** The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. + +**Relevant files:** `src/payment.ts` + ## Mobile ### Standardization on iPhones for mobile communication From 44fdfa13d19a8ae85406796f0d47454b57f58f93 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:21 +0000 Subject: [PATCH 21/44] chore(decispher): update .devin/rules.md --- .devin/rules.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.devin/rules.md b/.devin/rules.md index 4bcbf08..4f63015 100644 --- a/.devin/rules.md +++ b/.devin/rules.md @@ -282,6 +282,14 @@ Devin MUST follow all rules below. Do not deviate without explicit instruction. - **Scope:** packages/api/src/billing/ - **Tags:** billing, ownership, team +### Replace awk with sed in src/payment.ts bash scripts + +- **Severity:** LOW +- **Rule:** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. +- **Rationale:** The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. +- **Scope:** src/payment.ts +- **Tags:** performance, bash, refactoring, scripting + ### Standardization on iPhones for mobile communication - **Severity:** LOW From 89205f6bb3d4b13e49732ea84063121f36b79ad2 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:21:22 +0000 Subject: [PATCH 22/44] chore(decispher): update .roo/rules.md --- .roo/rules.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.roo/rules.md b/.roo/rules.md index af96a26..b37b885 100644 --- a/.roo/rules.md +++ b/.roo/rules.md @@ -73,6 +73,9 @@ ## General Conventions +- **Replace awk with sed in src/payment.ts bash scripts:** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. + *(The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues.)* + - **Standardization on iPhones for mobile communication:** The team will use iPhones to perform mobile calls. *(The team aligned on a single mobile device platform for communication consistency.)* From 4e9d1ab1d745edb640e5db89d3a68683f476e8ca Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:25 +0000 Subject: [PATCH 23/44] chore(decispher): update .decispher/decisions.md --- .decispher/decisions.md | 106 +++------------------------------------- 1 file changed, 6 insertions(+), 100 deletions(-) diff --git a/.decispher/decisions.md b/.decispher/decisions.md index 789db0a..b85b99c 100644 --- a/.decispher/decisions.md +++ b/.decispher/decisions.md @@ -354,10 +354,11 @@ "content_rules": [ { "mode": "regex", - "start": 1, - "pattern": "(credit_ledger|DrizzleCreditRepository|EFFORT_MODE_CONFIGS)" + "start": 0, + "pattern": "number|double" } - ] + ], + "content_match_mode": "any" } ], "match_mode": "all" @@ -368,9 +369,9 @@ **Problem:** Uncertainty regarding ownership of the billing module and the requirements for implementing new effort modes. -**Decision:** Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. +**Decision:** Replace all usage of the double type for money representations with the string type in src/billing.ts. -**Rationale:** To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized. +**Rationale:** Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. --- @@ -1056,101 +1057,6 @@ --- - -## Decision: Ownership of Billing Module - -**Status**: Active -**Date**: 2026-04-18 -**Severity**: Warning - -**Files**: -- `packages/api/src/billing/` - -**Rules**: -```json -{ - "conditions": [ - { - "type": "file", - "pattern": "packages/api/src/billing/**", - "content_rules": [ - { - "mode": "string", - "patterns": [ - "stripe", - "credit", - "ledger", - "invoice", - "payment", - "billing" - ] - } - ], - "content_match_mode": "any" - } - ], - "match_mode": "any" -} -``` - -### Context - -**Decision:** The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. - -**Rationale:** This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. - ---- - - -## Decision: Standardize on PostgreSQL and Redis; Prohibit MongoDB - -**Status**: Active -**Date**: 2026-04-18 -**Severity**: Critical - -**Rules**: -```json -{ - "conditions": [ - { - "type": "file", - "exclude": [ - "**/node_modules/**", - "**/vendor/**", - "**/*.lock", - "**/*.md" - ], - "pattern": "**/*", - "content_rules": [ - { - "mode": "string", - "patterns": [ - "mongodb", - "mongo", - "mongoose" - ] - } - ], - "content_match_mode": "any" - } - ], - "match_mode": "any" -} -``` - -### Context - -**Problem:** Ensure ACID compliance for critical billing and user data, and standardize data storage technologies to maintain data integrity and consistency. - -**Decision:** MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. - -**Rationale:** ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements. - -**Alternatives Considered:** -- **MongoDB**: MongoDB was rejected because it does not provide the necessary ACID compliance required for critical billing and user data, which is a non-negotiable architectural requirement for data integrity. - ---- - ## Decision: Define LLM Model Combinations for Saver, Balanced, Pro, and Super Effort Modes From 2d5fdd953a10f35fd075cfd4cc97d391d241cbad Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:26 +0000 Subject: [PATCH 24/44] chore(decispher): update .cursorrules --- .cursorrules | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.cursorrules b/.cursorrules index 8e21b96..8339426 100644 --- a/.cursorrules +++ b/.cursorrules @@ -73,14 +73,10 @@ ## Billing -- Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. - Rationale: To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized. +- Replace all usage of the double type for money representations with the string type in src/billing.ts. + Rationale: Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. Files: packages/api/src/routes/credits.ts, packages/decision-store/src/repositories/credit-repository.ts, packages/common/src/types/credits.ts -- The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. - Rationale: This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. - Files: packages/api/src/billing/ - ## Llm - Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. @@ -160,9 +156,3 @@ - We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. Rationale: Automating the verification of architectural decisions during the review process helps maintain consistency and ensures that developers adhere to established guidelines. Files: * - -## Database - -- MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. - Rationale: ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements. - Files: * From f384da5527fbd5081c1e9db52c89c71b0f2ccaaf Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:28 +0000 Subject: [PATCH 25/44] chore(decispher): update CLAUDE.md --- CLAUDE.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 7b9aaeb..cf3565a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -57,8 +57,8 @@ Violating these decisions requires explicit approval. - **Do NOT:** MEDIUM severity specification (The HIGH severity version was explicitly selected as the authoritative and canonical standard.) ### Establish ownership and modification constraints for credits and billing system (HIGH) -- **Decision:** Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. -- **Rationale:** To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized. +- **Decision:** Replace all usage of the double type for money representations with the string type in src/billing.ts. +- **Rationale:** Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. - **Affected files:** `packages/api/src/routes/credits.ts`, `packages/decision-store/src/repositories/credit-repository.ts`, `packages/common/src/types/credits.ts` ### Define Model Fallback Ordering Strategy for API Rate Limits (HIGH) @@ -150,16 +150,6 @@ Violating these decisions requires explicit approval. - **Rationale:** Automating the verification of architectural decisions during the review process helps maintain consistency and ensures that developers adhere to established guidelines. - **Do NOT:** Adopt a microservices architecture by splitting recorder and analyzer into separate gRPC services. (The previous attempt in Phase 1 led to brutal deployment complexity for a 3-person team, consuming 40% of their time debugging inter-service authentication and network failures.) -### Ownership of Billing Module (MEDIUM) -- **Decision:** The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. -- **Rationale:** This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. -- **Affected files:** `packages/api/src/billing/` - -### Standardize on PostgreSQL and Redis; Prohibit MongoDB (CRITICAL) -- **Decision:** MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. -- **Rationale:** ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements. -- **Do NOT:** MongoDB (MongoDB was rejected because it does not provide the necessary ACID compliance required for critical billing and user data, which is a non-negotiable architectural requirement for data integrity.) - ### Define LLM Model Combinations for Saver, Balanced, Pro, and Super Effort Modes (HIGH) - **Decision:** The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. - **Rationale:** The chosen LLM model combinations for each effort mode (Saver, Balanced, Pro, Super) were selected to provide different performance and cost profiles, aligning with the multi-provider strategy. Cost analysis confirmed that the proposed combinations, ranging from ~$0.08/1M tokens for Saver to ~$4.50/1M tokens for Super, ensure fine margins at current credit pricing. From 80fc6662c9a0c59f8ec2cfb99e0afd74c5faa8e1 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:29 +0000 Subject: [PATCH 26/44] chore(decispher): update .github/copilot-instructions.md --- .github/copilot-instructions.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index b20965c..dddfd22 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -12,7 +12,7 @@ When generating code for this project, follow these rules: 7. We have decided to officially discontinue the use of RFC 7807 (Problem Details for HTTP APIs) for all API error responses moving forward. 8. All new vector indexes must be created using the HNSW algorithm. Existing IVFFlat indexes (specifically in the llm_cache table) are to be migrated to HNSW in Sprint 16. 9. Adopt the HIGH severity specification as the authoritative version for the RFC 7807 error format, which includes fields: type, title, status, detail, and instance. -10. Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. +10. Replace all usage of the double type for money representations with the string type in src/billing.ts. 11. Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. 12. The team will migrate from AWS ECS to AWS EKS for container orchestration. 13. We have standardized on cosine distance (using the <=> operator in pgvector) for all similarity search operations. @@ -30,7 +30,5 @@ When generating code for this project, follow these rules: 25. MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. 26. The trigger metric for initiating the AWS migration has been adjusted from 20 paying customers to 30 paying customers. The Q3 2026 timeline for the migration still holds. 27. We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. -28. The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. -29. MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. -30. The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. -31. We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. +28. The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. +29. We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. From 9279900d6dedb688e1e2ba21ae178f86933328ec Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:31 +0000 Subject: [PATCH 27/44] chore(decispher): update AGENTS.md --- AGENTS.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ef9f2bb..66c6dbb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,7 +13,6 @@ Any code change that violates these decisions MUST be flagged. | The core pipeline must exclusively use PostgreSQL 16 with pgvector and Redis; the use of MongoDB is strictly prohibited. | Enforcing a specific database stack ensures architectural consistency, simplifies maintenance, and leverages existing infrastructure and expertise with PostgreSQL and pgvector. | infrastructure/database, src/db/config.ts | | After evaluating MongoDB, DynamoDB, and PostgreSQL, we chose PostgreSQL 16 with pgvector HNSW indexes. Reason: vector similarity search, ACID guarantees, and single DB for both structured data and embeddings. | After evaluating MongoDB, DynamoDB, and PostgreSQL, we chose PostgreSQL 16 with pgvector HNSW indexes. Reason: vector similarity search, ACID guarantees, and single DB for both structured data and embeddings. | * | | MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. | There is an active and non-negotiable architectural constraint against MongoDB in the stack due to the critical requirement for ACID compliance across all billing and user data. MongoDB does not satisfy this fundamental requirement. | * | -| MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. | ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements. | * | ### HIGH @@ -23,7 +22,7 @@ Any code change that violates these decisions MUST be flagged. | Migrate all email services to Zoho and update the SMTP server infrastructure, including the implementation of new routing rules to block any traffic to the legacy SMTP server. | The team decided to move to Zoho to consolidate mailing services and address the limitations or overhead associated with the existing legacy SMTP infrastructure. | infrastructure/mail, services/smtp, config/email_routing | | Switch from the third-party Shipsy provider to an in-house developed mapping event system. | The team identified that the Shipsy service was negatively impacting the platform's scalability, and moving to an internal solution reduces external dependencies. | services/shipping-integration, infrastructure/event-bus | | We have decided to officially discontinue the use of RFC 7807 (Problem Details for HTTP APIs) for all API error responses moving forward. | The team determined that the RFC 7807 specification is outdated and no longer aligns with the current requirements and standards of the API architecture. | api/responses, api/error-handling | -| Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. | To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized. | packages/api/src/routes/credits.ts, packages/decision-store/src/repositories/credit-repository.ts, packages/common/src/types/credits.ts | +| Replace all usage of the double type for money representations with the string type in src/billing.ts. | Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. | packages/api/src/routes/credits.ts, packages/decision-store/src/repositories/credit-repository.ts, packages/common/src/types/credits.ts | | Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. | To maintain system reliability and avoid task failure when individual LLM providers hit rate limits, a hierarchical fallback mechanism ensures work is diverted to alternative models before resorting to the Dead Letter Queue (DLQ) after retries. | src/llm/client_factory.py, src/llm/fallback_logic.py | | The team will migrate from AWS ECS to AWS EKS for container orchestration. | EKS provides superior orchestration flexibility, including native Horizontal Pod Autoscaler and improved multi-AZ/multi-region failover capabilities, which are necessary for the current scale, outweighing the operational overhead of Kubernetes. | infrastructure/terraform, infrastructure/k8s | | Use PostgreSQL with pgvector and HNSW indexes as the standard solution for primary datastore and vector search operations. | PostgreSQL with pgvector provides the ability to manage both SQL-based relational data and vector search capabilities within a single system, simplifying the architecture compared to managing separate databases. | * | @@ -48,7 +47,6 @@ Any code change that violates these decisions MUST be flagged. | All internal API routes must adhere to the RFC 7807 error format, consistent with public-facing API routes. | Inconsistent error formats, specifically plain strings from internal routes, prevent AI tools from reliably parsing and analyzing errors, leading to broken analysis workflows. | packages/api/src/routes/internal/ | | We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. | Cosine distance is invariant to vector magnitude, meaning it only considers the direction of vectors. This property is precisely what is desired for semantic similarity of text embeddings, as it allows for accurate comparison of semantic meaning regardless of variations in embedding vector norms. L2 (Euclidean) distance, on the other hand, would incorrectly penalize vectors with different magnitudes, even if they share the same semantic direction. | * | | Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. | Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. | * | -| The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. | This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. | packages/api/src/billing/ | ### LOW From 9d66d61248ef4eb3e9fc6cf907e00db20f1b18b8 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:35 +0000 Subject: [PATCH 28/44] chore(decispher): update .decispher/context-rules.json --- .decispher/context-rules.json | 136 +++++++--------------------------- 1 file changed, 26 insertions(+), 110 deletions(-) diff --git a/.decispher/context-rules.json b/.decispher/context-rules.json index 310984e..33aaa37 100644 --- a/.decispher/context-rules.json +++ b/.decispher/context-rules.json @@ -1,23 +1,23 @@ { "$schema": "https://decispher.dev/schemas/context-rules/v1.json", "specVersion": "1.0.0", - "generatedAt": "2026-05-05T12:20:51.663Z", + "generatedAt": "2026-05-05T12:33:13.125Z", "companyId": "1489dcdc-ef7f-4cc5-b0cb-b453efa059f4", "meta": { - "totalRules": 30, + "totalRules": 28, "rulesByType": { "decision": 21, "convention": 2, - "constraint": 3, + "constraint": 2, "rationale": 0, - "ownership": 2, + "ownership": 1, "history": 1, "plan": 1 }, "rulesBySeverity": { - "CRITICAL": 3, + "CRITICAL": 2, "HIGH": 15, - "MEDIUM": 10, + "MEDIUM": 9, "LOW": 2 }, "generator": "decispher-ai-blocker@1.0.0" @@ -539,8 +539,8 @@ "type": "ownership", "title": "Establish ownership and modification constraints for credits and billing system", "problem": "Uncertainty regarding ownership of the billing module and the requirements for implementing new effort modes.", - "decision": "Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements.", - "rationale": "To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized.", + "decision": "Replace all usage of the double type for money representations with the string type in src/billing.ts.", + "rationale": "Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations.", "severity": "HIGH", "status": "active", "confidence": 0.43, @@ -575,6 +575,22 @@ "triggeredByName": null }, "snippet": "Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must st…" + }, + { + "type": "slack", + "confidence": 0.48, + "ref": { + "priority": "high", + "threadTs": "1777984088.950089", + "channelId": "C0ALKBAGZQS", + "sourceUrl": "https://newworkspace-zdx9462.slack.com/archives/C0ALKBAGZQS/p1777984088950089?thread_ts=1777984088.950089&cid=C0ALKBAGZQS", + "channelName": "bot-test-1", + "slackTeamId": null, + "triggeredBy": "U05F9P78LTG", + "detectionMethod": "explicit", + "triggeredByName": "Ali Abbas" + }, + "snippet": "Replace all usage of the double type for money representations with the string type in src/billing.ts." } ], "supersededBy": null, @@ -589,8 +605,8 @@ "exemptPatterns": [] }, "createdAt": "2026-04-22T06:14:04.546Z", - "updatedAt": "2026-04-22T11:43:40.979Z", - "version": 1, + "updatedAt": "2026-05-05T12:33:12.799Z", + "version": 2, "createdBy": "U_SARA", "reviewedBy": "df51fb32-47a2-48b2-ac32-3887a582a966" }, @@ -1499,106 +1515,6 @@ "createdBy": "U05F9P78LTG", "reviewedBy": "df51fb32-47a2-48b2-ac32-3887a582a966" }, - { - "id": "43a78d92-5543-412c-9be3-00596ee8ce65", - "type": "ownership", - "title": "Ownership of Billing Module", - "problem": null, - "decision": "The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review.", - "rationale": "This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance.", - "severity": "MEDIUM", - "status": "active", - "confidence": 0.38, - "affectedFiles": [ - "packages/api/src/billing/" - ], - "tags": [ - "billing", - "ownership", - "team" - ], - "alternatives": [], - "sources": [ - { - "type": "slack", - "confidence": 0.38, - "ref": { - "priority": "high", - "threadTs": "1776518686.983299", - "channelId": "C0ANM3QAQMN", - "channelName": "decispher-live-test", - "triggeredBy": "U05F9P78LTG", - "detectionMethod": "explicit" - } - } - ], - "supersededBy": null, - "enforcement": { - "blockOnViolation": false, - "requiresExplicitOverride": false, - "filePatterns": [ - "packages/api/src/billing/" - ], - "exemptPatterns": [] - }, - "createdAt": "2026-04-18T13:24:50.857Z", - "updatedAt": "2026-04-18T13:25:43.024Z", - "version": 1, - "createdBy": "U05F9P78LTG", - "reviewedBy": "U05F9P78LTG" - }, - { - "id": "3998d8e6-48a3-4161-860b-be094e4feb87", - "type": "constraint", - "title": "Standardize on PostgreSQL and Redis; Prohibit MongoDB", - "problem": "Ensure ACID compliance for critical billing and user data, and standardize data storage technologies to maintain data integrity and consistency.", - "decision": "MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes.", - "rationale": "ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements.", - "severity": "CRITICAL", - "status": "active", - "confidence": 0.74, - "affectedFiles": [], - "tags": [ - "database", - "postgresql", - "redis", - "mongodb", - "data-storage", - "acid" - ], - "alternatives": [ - { - "option": "MongoDB", - "reasonRejected": "MongoDB was rejected because it does not provide the necessary ACID compliance required for critical billing and user data, which is a non-negotiable architectural requirement for data integrity." - } - ], - "sources": [ - { - "type": "slack", - "confidence": 0.5, - "ref": { - "priority": "high", - "threadTs": "1776518248.102319", - "channelId": "C0ANM3QAQMN", - "channelName": "decispher-live-test", - "triggeredBy": "U05F9P78LTG", - "detectionMethod": "explicit" - } - } - ], - "supersededBy": null, - "enforcement": { - "blockOnViolation": false, - "requiresExplicitOverride": false, - "filePatterns": [], - "exemptPatterns": [] - }, - "createdAt": "2026-04-18T13:17:48.935Z", - "updatedAt": "2026-04-18T23:32:02.232Z", - "version": 1, - "createdBy": "U05F9P78LTG", - "reviewedBy": "U05F9P78LTG" - }, { "id": "b6869b8c-7d43-47d4-9cd6-dddb0f9f92b9", "type": "decision", From 9f5ee3d8831765cebcba1c35c02794d3bac53cf1 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:36 +0000 Subject: [PATCH 29/44] chore(decispher): update .windsurfrules --- .windsurfrules | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.windsurfrules b/.windsurfrules index eabf6ef..2b8e10d 100644 --- a/.windsurfrules +++ b/.windsurfrules @@ -17,9 +17,6 @@ Cascade MUST respect these rules when generating or modifying code. - MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. Reason: There is an active and non-negotiable architectural constraint against MongoDB in the stack due to the critical requirement for ACID compliance across all billing and user data. MongoDB does not satisfy this fundamental requirement. -- MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. - Reason: ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements. - ## [HIGH] - Migrate the core decision storage from PostgreSQL to MongoDB, utilizing MongoDB Atlas for vector search capabilities. @@ -38,8 +35,8 @@ Cascade MUST respect these rules when generating or modifying code. Reason: The team determined that the RFC 7807 specification is outdated and no longer aligns with the current requirements and standards of the API architecture. Files: api/responses, api/error-handling -- Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. - Reason: To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized. +- Replace all usage of the double type for money representations with the string type in src/billing.ts. + Reason: Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. Files: packages/api/src/routes/credits.ts, packages/decision-store/src/repositories/credit-repository.ts, packages/common/src/types/credits.ts - Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. @@ -111,10 +108,6 @@ Cascade MUST respect these rules when generating or modifying code. - Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. Reason: Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. -- The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. - Reason: This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. - Files: packages/api/src/billing/ - ## [LOW] - Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. From ea2d1032ec156f9c8f62c7c2f1d223a8cf8704ad Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:38 +0000 Subject: [PATCH 30/44] chore(decispher): update .clinerules --- .clinerules | 61 ++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/.clinerules b/.clinerules index a2515ca..16bf205 100644 --- a/.clinerules +++ b/.clinerules @@ -16,103 +16,96 @@ Before writing or modifying code, review these rules and do not violate them. 3. 🔴 **[CRITICAL]** MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. - **Why:** There is an active and non-negotiable architectural constraint against MongoDB in the stack due to the critical requirement for ACID compliance across all billing and user data. MongoDB does not satisfy this fundamental requirement. -4. 🔴 **[CRITICAL]** MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. - - **Why:** ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements. - -5. 🟠 **[HIGH]** Migrate the core decision storage from PostgreSQL to MongoDB, utilizing MongoDB Atlas for vector search capabilities. +4. 🟠 **[HIGH]** Migrate the core decision storage from PostgreSQL to MongoDB, utilizing MongoDB Atlas for vector search capabilities. - **Why:** MongoDB was chosen to accommodate high-write volume scenarios and to provide a flexible schema structure that the previous relational model failed to support efficiently. - **Files:** `context-store/`, `package.json` -6. 🟠 **[HIGH]** Migrate all email services to Zoho and update the SMTP server infrastructure, including the implementation of new routing rules to block any traffic to the legacy SMTP server. +5. 🟠 **[HIGH]** Migrate all email services to Zoho and update the SMTP server infrastructure, including the implementation of new routing rules to block any traffic to the legacy SMTP server. - **Why:** The team decided to move to Zoho to consolidate mailing services and address the limitations or overhead associated with the existing legacy SMTP infrastructure. - **Files:** `infrastructure/mail`, `services/smtp`, `config/email_routing` -7. 🟠 **[HIGH]** Switch from the third-party Shipsy provider to an in-house developed mapping event system. +6. 🟠 **[HIGH]** Switch from the third-party Shipsy provider to an in-house developed mapping event system. - **Why:** The team identified that the Shipsy service was negatively impacting the platform's scalability, and moving to an internal solution reduces external dependencies. - **Files:** `services/shipping-integration`, `infrastructure/event-bus` -8. 🟠 **[HIGH]** We have decided to officially discontinue the use of RFC 7807 (Problem Details for HTTP APIs) for all API error responses moving forward. +7. 🟠 **[HIGH]** We have decided to officially discontinue the use of RFC 7807 (Problem Details for HTTP APIs) for all API error responses moving forward. - **Why:** The team determined that the RFC 7807 specification is outdated and no longer aligns with the current requirements and standards of the API architecture. - **Files:** `api/responses`, `api/error-handling` -9. 🟠 **[HIGH]** Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. - - **Why:** To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized. +8. 🟠 **[HIGH]** Replace all usage of the double type for money representations with the string type in src/billing.ts. + - **Why:** Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. - **Files:** `packages/api/src/routes/credits.ts`, `packages/decision-store/src/repositories/credit-repository.ts`, `packages/common/src/types/credits.ts` -10. 🟠 **[HIGH]** Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. +9. 🟠 **[HIGH]** Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. - **Why:** To maintain system reliability and avoid task failure when individual LLM providers hit rate limits, a hierarchical fallback mechanism ensures work is diverted to alternative models before resorting to the Dead Letter Queue (DLQ) after retries. - **Files:** `src/llm/client_factory.py`, `src/llm/fallback_logic.py` -11. 🟠 **[HIGH]** The team will migrate from AWS ECS to AWS EKS for container orchestration. +10. 🟠 **[HIGH]** The team will migrate from AWS ECS to AWS EKS for container orchestration. - **Why:** EKS provides superior orchestration flexibility, including native Horizontal Pod Autoscaler and improved multi-AZ/multi-region failover capabilities, which are necessary for the current scale, outweighing the operational overhead of Kubernetes. - **Files:** `infrastructure/terraform`, `infrastructure/k8s` -12. 🟠 **[HIGH]** Use PostgreSQL with pgvector and HNSW indexes as the standard solution for primary datastore and vector search operations. +11. 🟠 **[HIGH]** Use PostgreSQL with pgvector and HNSW indexes as the standard solution for primary datastore and vector search operations. - **Why:** PostgreSQL with pgvector provides the ability to manage both SQL-based relational data and vector search capabilities within a single system, simplifying the architecture compared to managing separate databases. -13. 🟠 **[HIGH]** Use MongoDB Atlas specifically for the analytics event ingestion pipeline, while keeping all other core application data in PostgreSQL. +12. 🟠 **[HIGH]** Use MongoDB Atlas specifically for the analytics event ingestion pipeline, while keeping all other core application data in PostgreSQL. - **Why:** MongoDB Atlas provides the necessary horizontal sharding and schemaless structure to handle the required 50k write operations per second, whereas PostgreSQL performance degrades under this load. - **Files:** `services/analytics-webhook-handler`, `infrastructure/database-clusters` -14. 🟠 **[HIGH]** We will use MongoDB for the analytics events pipeline, provisioning a MongoDB Atlas cluster to handle the data. +13. 🟠 **[HIGH]** We will use MongoDB for the analytics events pipeline, provisioning a MongoDB Atlas cluster to handle the data. - **Why:** MongoDB offers 10x the write throughput compared to PostgreSQL for high-cardinality event data, which is essential to meet the current scale requirements. The previous constraint was established before these new scale demands emerged. - **Files:** `packages/api/src/analytics/` -15. 🟠 **[HIGH]** Each LLM pipeline step (detection, extraction, formatting) has its own provider configuration managed via environment variables. An 'effort mode' concept allows overriding these configurations per company at request time, defining specific LLM models for different quality/cost tiers: Saver uses gemini-flash, Balanced mixes gemini-flash, claude-haiku, and gpt-4o-mini, Pro uses claude-sonnet for extraction, and Super uses claude-opus. +14. 🟠 **[HIGH]** Each LLM pipeline step (detection, extraction, formatting) has its own provider configuration managed via environment variables. An 'effort mode' concept allows overriding these configurations per company at request time, defining specific LLM models for different quality/cost tiers: Saver uses gemini-flash, Balanced mixes gemini-flash, claude-haiku, and gpt-4o-mini, Pro uses claude-sonnet for extraction, and Super uses claude-opus. - **Why:** The strategy is designed to provide flexibility and optimization across different pipeline steps and 'effort modes'. By configuring providers per step and allowing overrides based on company effort modes, the system can balance cost, performance, and model quality according to specific requirements, from 'Saver' (likely cost-optimized) to 'Super' (likely highest quality/cost). The multi-provider abstraction facilitates this dynamic selection. - **Files:** `packages/analyzer/` -16. 🟠 **[HIGH]** The trigger metric for initiating the AWS migration has been adjusted from 20 paying customers to 30 paying customers. The Q3 2026 timeline for the migration still holds. +15. 🟠 **[HIGH]** The trigger metric for initiating the AWS migration has been adjusted from 20 paying customers to 30 paying customers. The Q3 2026 timeline for the migration still holds. - **Why:** This adjustment is due to Railway costs being more predictable than initially expected. Additionally, the VPC isolation requirement, which was a significant factor, only applies to enterprise customers, a segment we are targeting at a later stage. -17. 🟠 **[HIGH]** We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. +16. 🟠 **[HIGH]** We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. - **Why:** Automating the verification of architectural decisions during the review process helps maintain consistency and ensures that developers adhere to established guidelines. -18. 🟠 **[HIGH]** The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. +17. 🟠 **[HIGH]** The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. - **Why:** The chosen LLM model combinations for each effort mode (Saver, Balanced, Pro, Super) were selected to provide different performance and cost profiles, aligning with the multi-provider strategy. Cost analysis confirmed that the proposed combinations, ranging from ~$0.08/1M tokens for Saver to ~$4.50/1M tokens for Super, ensure fine margins at current credit pricing. -19. 🟠 **[HIGH]** We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. +18. 🟠 **[HIGH]** We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. - **Why:** This approach allows companies with high context volume (Tier 3+) to pay extra for Claude-Sonnet's accuracy where needed, while companies with tighter budgets can use more cost-effective options like Gemini-Flash for all steps. It also decouples our infrastructure from individual LLM vendor stability and enables independent contract negotiations with different providers (Anthropic, OpenAI, Google). -20. 🟡 **[MEDIUM]** Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. +19. 🟡 **[MEDIUM]** Use RFC 307895 as the standard for validating user input when adding custom themes through the form at /addCustomTheme. - **Why:** Adopting an existing RFC provides a standardized, well-documented approach to input validation, ensuring consistency and security for custom theme data handling. - **Files:** `assets/theme` -21. 🟡 **[MEDIUM]** All new vector indexes must be created using the HNSW algorithm. Existing IVFFlat indexes (specifically in the llm_cache table) are to be migrated to HNSW in Sprint 16. +20. 🟡 **[MEDIUM]** All new vector indexes must be created using the HNSW algorithm. Existing IVFFlat indexes (specifically in the llm_cache table) are to be migrated to HNSW in Sprint 16. - **Why:** HNSW is the current architectural standard for vector indexing. The previous rejection of the migration to HNSW was due to operational risks in production, not a lack of performance or technical suitability of HNSW. - **Files:** `db/schema/vector_indexes`, `db/migrations/sprint_16/migrate_llm_cache_to_hnsw` -22. 🟡 **[MEDIUM]** Adopt the HIGH severity specification as the authoritative version for the RFC 7807 error format, which includes fields: type, title, status, detail, and instance. +21. 🟡 **[MEDIUM]** Adopt the HIGH severity specification as the authoritative version for the RFC 7807 error format, which includes fields: type, title, status, detail, and instance. - **Why:** The team identified that two existing conventions were redundant. Designating the HIGH severity entry as canonical while allowing the fusion engine to merge duplicate references ensures consistency across documentation and API implementations. - **Files:** `packages/api/src/plugins/error-handler.ts` -23. 🟡 **[MEDIUM]** We have standardized on cosine distance (using the <=> operator in pgvector) for all similarity search operations. +22. 🟡 **[MEDIUM]** We have standardized on cosine distance (using the <=> operator in pgvector) for all similarity search operations. - **Why:** Cosine distance provides significantly better recall (12% improvement) on normalized text embeddings compared to L2 distance. Furthermore, L2 distance is overly sensitive to embedding magnitude, making it less reliable for our specific use case. -24. 🟡 **[MEDIUM]** MongoDB is strictly prohibited for use in core pipeline services (including the core decision pipeline, authentication, and the context store). These services must exclusively use PostgreSQL 16 and Redis. Any deviation requires a formal ADR. +23. 🟡 **[MEDIUM]** MongoDB is strictly prohibited for use in core pipeline services (including the core decision pipeline, authentication, and the context store). These services must exclusively use PostgreSQL 16 and Redis. Any deviation requires a formal ADR. - **Why:** To maintain architectural integrity and prevent fragmentation in the core tech stack. Previous attempts to introduce MongoDB for event queues nearly caused instability, highlighting the need for a hard, enforceable constraint. - **Files:** `analytics/storage`, `infrastructure/database-policy` -25. 🟡 **[MEDIUM]** The team decided to discontinue the use of EventStoreDB and removed event sourcing as an architectural pattern following the migration back to a monorepo. +24. 🟡 **[MEDIUM]** The team decided to discontinue the use of EventStoreDB and removed event sourcing as an architectural pattern following the migration back to a monorepo. - **Why:** The complexity of maintaining three separate runbooks for EventStoreDB operations outweighed the benefits of its auditability features for the current team size and system scale. -26. 🟡 **[MEDIUM]** All internal API routes must adhere to the RFC 7807 error format, consistent with public-facing API routes. +25. 🟡 **[MEDIUM]** All internal API routes must adhere to the RFC 7807 error format, consistent with public-facing API routes. - **Why:** Inconsistent error formats, specifically plain strings from internal routes, prevent AI tools from reliably parsing and analyzing errors, leading to broken analysis workflows. - **Files:** `packages/api/src/routes/internal/` -27. 🟡 **[MEDIUM]** We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. +26. 🟡 **[MEDIUM]** We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. - **Why:** Cosine distance is invariant to vector magnitude, meaning it only considers the direction of vectors. This property is precisely what is desired for semantic similarity of text embeddings, as it allows for accurate comparison of semantic meaning regardless of variations in embedding vector norms. L2 (Euclidean) distance, on the other hand, would incorrectly penalize vectors with different magnitudes, even if they share the same semantic direction. -28. 🟡 **[MEDIUM]** Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. +27. 🟡 **[MEDIUM]** Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. - **Why:** Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. -29. 🟡 **[MEDIUM]** The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. - - **Why:** This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. - - **Files:** `packages/api/src/billing/` - -30. 🟢 **[LOW]** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. +28. 🟢 **[LOW]** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. - **Why:** The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. - **Files:** `src/payment.ts` -31. 🟢 **[LOW]** The team will use iPhones to perform mobile calls. +29. 🟢 **[LOW]** The team will use iPhones to perform mobile calls. - **Why:** The team aligned on a single mobile device platform for communication consistency. From 03f5a6844ba174b5ccc7cf052e4c693b157d7f23 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:41 +0000 Subject: [PATCH 31/44] chore(decispher): update .aider/conventions.md --- .aider/conventions.md | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.aider/conventions.md b/.aider/conventions.md index b4adb85..52bf011 100644 --- a/.aider/conventions.md +++ b/.aider/conventions.md @@ -140,22 +140,14 @@ Aider should follow all of these conventions when making changes. ### Establish ownership and modification constraints for credits and billing system -**Convention:** Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. +**Convention:** Replace all usage of the double type for money representations with the string type in src/billing.ts. -**Why:** To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized. +**Why:** Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. > ⚠️ This is a **HIGH** priority rule — do not violate it. **Relevant files:** `packages/api/src/routes/credits.ts`, `packages/decision-store/src/repositories/credit-repository.ts`, `packages/common/src/types/credits.ts` -### Ownership of Billing Module - -**Convention:** The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. - -**Why:** This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. - -**Relevant files:** `packages/api/src/billing/` - ## Llm ### Define Model Fallback Ordering Strategy for API Rate Limits @@ -295,13 +287,3 @@ Aider should follow all of these conventions when making changes. **Why:** Automating the verification of architectural decisions during the review process helps maintain consistency and ensures that developers adhere to established guidelines. > ⚠️ This is a **HIGH** priority rule — do not violate it. - -## Database - -### Standardize on PostgreSQL and Redis; Prohibit MongoDB - -**Convention:** MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. - -**Why:** ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements. - -> ⚠️ This is a **CRITICAL** priority rule — do not violate it. From c2f5266e9cd31ae1ba0ee4750da8f8fb65c958d1 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:44 +0000 Subject: [PATCH 32/44] chore(decispher): update .devin/rules.md --- .devin/rules.md | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.devin/rules.md b/.devin/rules.md index 4f63015..d847b97 100644 --- a/.devin/rules.md +++ b/.devin/rules.md @@ -36,16 +36,6 @@ Devin MUST follow all rules below. Do not deviate without explicit instruction. **Alternatives considered (rejected):** - ~~MongoDB for analytics events~~ — It violates an active architectural constraint due to its lack of native ACID compliance, which is non-negotiable for billing and user data within our stack. -### Standardize on PostgreSQL and Redis; Prohibit MongoDB - -- **Severity:** CRITICAL -- **Rule:** MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. -- **Rationale:** ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements. -- **Tags:** database, postgresql, redis, mongodb, data-storage, acid - -**Alternatives considered (rejected):** -- ~~MongoDB~~ — MongoDB was rejected because it does not provide the necessary ACID compliance required for critical billing and user data, which is a non-negotiable architectural requirement for data integrity. - ### Migrate core decision store from PostgreSQL to MongoDB - **Severity:** HIGH @@ -87,8 +77,8 @@ Devin MUST follow all rules below. Do not deviate without explicit instruction. ### Establish ownership and modification constraints for credits and billing system - **Severity:** HIGH -- **Rule:** Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. -- **Rationale:** To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized. +- **Rule:** Replace all usage of the double type for money representations with the string type in src/billing.ts. +- **Rationale:** Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. - **Scope:** packages/api/src/routes/credits.ts, packages/decision-store/src/repositories/credit-repository.ts, packages/common/src/types/credits.ts - **Tags:** billing, ownership, credits, compliance @@ -274,14 +264,6 @@ Devin MUST follow all rules below. Do not deviate without explicit instruction. - **Rationale:** Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. - **Tags:** redis, caching, llm, embeddings, performance, optimization -### Ownership of Billing Module - -- **Severity:** MEDIUM -- **Rule:** The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. -- **Rationale:** This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance. -- **Scope:** packages/api/src/billing/ -- **Tags:** billing, ownership, team - ### Replace awk with sed in src/payment.ts bash scripts - **Severity:** LOW From 3c9a51d311bd19ed658dd7672ebb754f52f99a3c Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:33:46 +0000 Subject: [PATCH 33/44] chore(decispher): update .roo/rules.md --- .roo/rules.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.roo/rules.md b/.roo/rules.md index b37b885..94d2fa3 100644 --- a/.roo/rules.md +++ b/.roo/rules.md @@ -19,8 +19,8 @@ *(The team determined that the RFC 7807 specification is outdated and no longer aligns with the current requirements and standards of the API architecture.)* Files: api/responses, api/error-handling -- **Establish ownership and modification constraints for credits and billing system:** Sara is the primary owner of the billing module; all changes to the credit_ledger schema, DrizzleCreditRepository, and the EFFORT_MODE_CONFIGS require specific approvals from Sara and Ali. Furthermore, the system must strictly adhere to the append-only ledger constraint per ADR-019 and maintain SERIALIZABLE transaction requirements. - *(To ensure accountability and maintain architectural integrity of the financial ledger and billing configuration, specific code ownership and structural constraints have been formalized.)* +- **Establish ownership and modification constraints for credits and billing system:** Replace all usage of the double type for money representations with the string type in src/billing.ts. + *(Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations.)* Files: packages/api/src/routes/credits.ts, packages/decision-store/src/repositories/credit-repository.ts, packages/common/src/types/credits.ts - **Define Model Fallback Ordering Strategy for API Rate Limits:** Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. @@ -62,9 +62,6 @@ - **Defer Microservices Adoption, Maintain Monorepo Architecture:** We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. *(Automating the verification of architectural decisions during the review process helps maintain consistency and ensures that developers adhere to established guidelines.)* -- **Standardize on PostgreSQL and Redis; Prohibit MongoDB:** MongoDB is strictly prohibited in this stack due to its lack of ACID compliance. PostgreSQL will be used as the primary datastore for all persistent data, especially critical billing and user data. Redis will be used exclusively for caching purposes. - *(ACID compliance is a non-negotiable requirement for billing and user data to guarantee data integrity and consistency. PostgreSQL provides robust ACID transaction support. Adopting a standardized approach with PostgreSQL and Redis simplifies the technology stack and enforces critical data integrity requirements.)* - - **Define LLM Model Combinations for Saver, Balanced, Pro, and Super Effort Modes:** The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. *(The chosen LLM model combinations for each effort mode (Saver, Balanced, Pro, Super) were selected to provide different performance and cost profiles, aligning with the multi-provider strategy. Cost analysis confirmed that the proposed combinations, ranging from ~$0.08/1M tokens for Saver to ~$4.50/1M tokens for Super, ensure fine margins at current credit pricing.)* @@ -105,6 +102,3 @@ - **Implement Redis Semantic Caching for LLM Embedding Calls:** Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. *(Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests.)* - -- **Ownership of Billing Module:** The billing module, including Stripe integration, credit ledger, credit deduction logic, and Stripe webhook handlers, is owned by U05F9P78LTG. All changes to billing flows require their review. - *(This statement clarifies responsibility for the billing module and its components to ensure proper review and maintenance.)* From 726c5193b5731663b0dad78b15ab168b5dd17b47 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:06 +0000 Subject: [PATCH 34/44] chore(decispher): update .decispher/decisions.md --- .decispher/decisions.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.decispher/decisions.md b/.decispher/decisions.md index b85b99c..6033240 100644 --- a/.decispher/decisions.md +++ b/.decispher/decisions.md @@ -1057,6 +1057,44 @@ --- + +## Decision: Ownership of Billing Module + +**Status**: Active +**Date**: 2026-04-18 +**Severity**: Warning + +**Files**: +- `packages/api/src/billing/` + +**Rules**: +```json +{ + "conditions": [ + { + "type": "file", + "pattern": "packages/api/src/billing/**/*.ts", + "content_rules": [ + { + "mode": "regex", + "start": 0, + "pattern": "number\\s*[:=]\\s*double|double\\s+\\w+" + } + ] + } + ], + "match_mode": "all" +} +``` + +### Context + +**Decision:** Replace all usages of double with string to represent money transactions in src/billing.ts. + +**Rationale:** Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations. + +--- + ## Decision: Define LLM Model Combinations for Saver, Balanced, Pro, and Super Effort Modes From 11008299611e9259af3f967ee46f1367ada49798 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:08 +0000 Subject: [PATCH 35/44] chore(decispher): update .cursorrules --- .cursorrules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.cursorrules b/.cursorrules index 8339426..636daff 100644 --- a/.cursorrules +++ b/.cursorrules @@ -77,6 +77,10 @@ Rationale: Using floating-point numbers (doubles) for currency leads to rounding errors and precision issues due to IEEE 754 binary representation. Using strings ensures that exact decimal precision is maintained during financial calculations. Files: packages/api/src/routes/credits.ts, packages/decision-store/src/repositories/credit-repository.ts, packages/common/src/types/credits.ts +- Replace all usages of double with string to represent money transactions in src/billing.ts. + Rationale: Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations. + Files: packages/api/src/billing/ + ## Llm - Establish explicit provider fallback orderings: For extraction, use Anthropic → DeepSeek → OpenAI. For detection, use Google → OpenAI → DeepSeek. From 171be16dfdaaff158a374fabe317e20a01c06119 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:10 +0000 Subject: [PATCH 36/44] chore(decispher): update CLAUDE.md --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index cf3565a..d9821aa 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -150,6 +150,11 @@ Violating these decisions requires explicit approval. - **Rationale:** Automating the verification of architectural decisions during the review process helps maintain consistency and ensures that developers adhere to established guidelines. - **Do NOT:** Adopt a microservices architecture by splitting recorder and analyzer into separate gRPC services. (The previous attempt in Phase 1 led to brutal deployment complexity for a 3-person team, consuming 40% of their time debugging inter-service authentication and network failures.) +### Ownership of Billing Module (MEDIUM) +- **Decision:** Replace all usages of double with string to represent money transactions in src/billing.ts. +- **Rationale:** Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations. +- **Affected files:** `packages/api/src/billing/` + ### Define LLM Model Combinations for Saver, Balanced, Pro, and Super Effort Modes (HIGH) - **Decision:** The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. - **Rationale:** The chosen LLM model combinations for each effort mode (Saver, Balanced, Pro, Super) were selected to provide different performance and cost profiles, aligning with the multi-provider strategy. Cost analysis confirmed that the proposed combinations, ranging from ~$0.08/1M tokens for Saver to ~$4.50/1M tokens for Super, ensure fine margins at current credit pricing. From 601f22c3ef21d58cb8ddf5786f88d9783957f1bc Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:11 +0000 Subject: [PATCH 37/44] chore(decispher): update .github/copilot-instructions.md --- .github/copilot-instructions.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index dddfd22..6d8afa1 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -30,5 +30,6 @@ When generating code for this project, follow these rules: 25. MongoDB is strictly prohibited from being integrated into the current technology stack, including for analytics events. 26. The trigger metric for initiating the AWS migration has been adjusted from 20 paying customers to 30 paying customers. The Q3 2026 timeline for the migration still holds. 27. We will integrate decision-guardian into our PR pipeline to enforce and track architectural decisions. -28. The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. -29. We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. +28. Replace all usages of double with string to represent money transactions in src/billing.ts. +29. The specific LLM model combinations for the multi-provider effort modes were finalized: Saver mode uses `gemini-flash` for detection, extraction, and format. Balanced mode uses `gemini-flash` for detection, `claude-haiku` for extraction, and `gpt-4o-mini` for format. Pro mode uses `gemini-flash` for detection, `claude-sonnet` for extraction, and `gpt-4o-mini` for format. Super mode uses `gemini-flash` for detection, `claude-opus` for extraction, and `claude-sonnet` for format. +30. We will implement a multi-provider abstraction where each pipeline step (detection, extraction, enrichment, formatting) has its own LLM provider configuration via environment variables. At request time, an 'effort mode' can override the provider selection on a per-company basis. From e673b9dbd85eec297b3ea327fa54e6334531e1fa Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:13 +0000 Subject: [PATCH 38/44] chore(decispher): update AGENTS.md --- AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AGENTS.md b/AGENTS.md index 66c6dbb..b2d4c8f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -47,6 +47,7 @@ Any code change that violates these decisions MUST be flagged. | All internal API routes must adhere to the RFC 7807 error format, consistent with public-facing API routes. | Inconsistent error formats, specifically plain strings from internal routes, prevent AI tools from reliably parsing and analyzing errors, leading to broken analysis workflows. | packages/api/src/routes/internal/ | | We decided to use cosine distance for semantic similarity search of text embeddings with pgvector HNSW for deduplication. | Cosine distance is invariant to vector magnitude, meaning it only considers the direction of vectors. This property is precisely what is desired for semantic similarity of text embeddings, as it allows for accurate comparison of semantic meaning regardless of variations in embedding vector norms. L2 (Euclidean) distance, on the other hand, would incorrectly penalize vectors with different magnitudes, even if they share the same semantic direction. | * | | Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. | Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. | * | +| Replace all usages of double with string to represent money transactions in src/billing.ts. | Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations. | packages/api/src/billing/ | ### LOW From f7cc61ff0f79fd43a899b3f34a335259a51c5f92 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:16 +0000 Subject: [PATCH 39/44] chore(decispher): update .decispher/context-rules.json --- .decispher/context-rules.json | 72 +++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/.decispher/context-rules.json b/.decispher/context-rules.json index 33aaa37..4ad173d 100644 --- a/.decispher/context-rules.json +++ b/.decispher/context-rules.json @@ -1,23 +1,23 @@ { "$schema": "https://decispher.dev/schemas/context-rules/v1.json", "specVersion": "1.0.0", - "generatedAt": "2026-05-05T12:33:13.125Z", + "generatedAt": "2026-05-05T12:33:53.121Z", "companyId": "1489dcdc-ef7f-4cc5-b0cb-b453efa059f4", "meta": { - "totalRules": 28, + "totalRules": 29, "rulesByType": { "decision": 21, "convention": 2, "constraint": 2, "rationale": 0, - "ownership": 1, + "ownership": 2, "history": 1, "plan": 1 }, "rulesBySeverity": { "CRITICAL": 2, "HIGH": 15, - "MEDIUM": 9, + "MEDIUM": 10, "LOW": 2 }, "generator": "decispher-ai-blocker@1.0.0" @@ -1515,6 +1515,70 @@ "createdBy": "U05F9P78LTG", "reviewedBy": "df51fb32-47a2-48b2-ac32-3887a582a966" }, + { + "id": "43a78d92-5543-412c-9be3-00596ee8ce65", + "type": "ownership", + "title": "Ownership of Billing Module", + "problem": null, + "decision": "Replace all usages of double with string to represent money transactions in src/billing.ts.", + "rationale": "Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations.", + "severity": "MEDIUM", + "status": "active", + "confidence": 0.38, + "affectedFiles": [ + "packages/api/src/billing/" + ], + "tags": [ + "billing", + "ownership", + "team" + ], + "alternatives": [], + "sources": [ + { + "type": "slack", + "confidence": 0.38, + "ref": { + "priority": "high", + "threadTs": "1776518686.983299", + "channelId": "C0ANM3QAQMN", + "channelName": "decispher-live-test", + "triggeredBy": "U05F9P78LTG", + "detectionMethod": "explicit" + } + }, + { + "type": "slack", + "confidence": 0.48, + "ref": { + "priority": "high", + "threadTs": "1777984088.950089", + "channelId": "C0ALKBAGZQS", + "sourceUrl": null, + "channelName": null, + "slackTeamId": null, + "triggeredBy": null, + "detectionMethod": "explicit", + "triggeredByName": null + }, + "snippet": "Replace all usages of double with string to represent money transactions in src/billing.ts." + } + ], + "supersededBy": null, + "enforcement": { + "blockOnViolation": false, + "requiresExplicitOverride": false, + "filePatterns": [ + "packages/api/src/billing/" + ], + "exemptPatterns": [] + }, + "createdAt": "2026-04-18T13:24:50.857Z", + "updatedAt": "2026-05-05T12:33:52.890Z", + "version": 2, + "createdBy": "U05F9P78LTG", + "reviewedBy": "df51fb32-47a2-48b2-ac32-3887a582a966" + }, { "id": "b6869b8c-7d43-47d4-9cd6-dddb0f9f92b9", "type": "decision", From 20f4474a44e37d49323c5a18a1e9b902436e8080 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:17 +0000 Subject: [PATCH 40/44] chore(decispher): update .windsurfrules --- .windsurfrules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.windsurfrules b/.windsurfrules index 2b8e10d..4c1a2c9 100644 --- a/.windsurfrules +++ b/.windsurfrules @@ -108,6 +108,10 @@ Cascade MUST respect these rules when generating or modifying code. - Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. Reason: Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. +- Replace all usages of double with string to represent money transactions in src/billing.ts. + Reason: Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations. + Files: packages/api/src/billing/ + ## [LOW] - Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. From 7876a279d61b2ed9394f3bdda617785bc298d074 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:21 +0000 Subject: [PATCH 41/44] chore(decispher): update .clinerules --- .clinerules | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.clinerules b/.clinerules index 16bf205..d3301ba 100644 --- a/.clinerules +++ b/.clinerules @@ -103,9 +103,13 @@ Before writing or modifying code, review these rules and do not violate them. 27. 🟡 **[MEDIUM]** Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. - **Why:** Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. -28. 🟢 **[LOW]** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. +28. 🟡 **[MEDIUM]** Replace all usages of double with string to represent money transactions in src/billing.ts. + - **Why:** Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations. + - **Files:** `packages/api/src/billing/` + +29. 🟢 **[LOW]** Remove all awk commands from the bash script in src/payment.ts and replace them with functionally equivalent sed commands. - **Why:** The team identified that the existing awk implementations are causing unnecessary performance bottlenecks; transitioning to sed is expected to resolve these latency issues. - **Files:** `src/payment.ts` -29. 🟢 **[LOW]** The team will use iPhones to perform mobile calls. +30. 🟢 **[LOW]** The team will use iPhones to perform mobile calls. - **Why:** The team aligned on a single mobile device platform for communication consistency. From a3205645bcea344ae1c771b69d4ddf965070d2d8 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:23 +0000 Subject: [PATCH 42/44] chore(decispher): update .aider/conventions.md --- .aider/conventions.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.aider/conventions.md b/.aider/conventions.md index 52bf011..df5694e 100644 --- a/.aider/conventions.md +++ b/.aider/conventions.md @@ -148,6 +148,14 @@ Aider should follow all of these conventions when making changes. **Relevant files:** `packages/api/src/routes/credits.ts`, `packages/decision-store/src/repositories/credit-repository.ts`, `packages/common/src/types/credits.ts` +### Ownership of Billing Module + +**Convention:** Replace all usages of double with string to represent money transactions in src/billing.ts. + +**Why:** Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations. + +**Relevant files:** `packages/api/src/billing/` + ## Llm ### Define Model Fallback Ordering Strategy for API Rate Limits From 69c94db13e9bbfd5d32725c5dfdb3dbb38555caf Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:26 +0000 Subject: [PATCH 43/44] chore(decispher): update .devin/rules.md --- .devin/rules.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.devin/rules.md b/.devin/rules.md index d847b97..2115f19 100644 --- a/.devin/rules.md +++ b/.devin/rules.md @@ -264,6 +264,14 @@ Devin MUST follow all rules below. Do not deviate without explicit instruction. - **Rationale:** Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests. - **Tags:** redis, caching, llm, embeddings, performance, optimization +### Ownership of Billing Module + +- **Severity:** MEDIUM +- **Rule:** Replace all usages of double with string to represent money transactions in src/billing.ts. +- **Rationale:** Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations. +- **Scope:** packages/api/src/billing/ +- **Tags:** billing, ownership, team + ### Replace awk with sed in src/payment.ts bash scripts - **Severity:** LOW From ba675d0b4cee664d974973c6466cbc6afe4b6471 Mon Sep 17 00:00:00 2001 From: "decispher[bot]" <276004941+decispher[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 12:34:29 +0000 Subject: [PATCH 44/44] chore(decispher): update .roo/rules.md --- .roo/rules.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.roo/rules.md b/.roo/rules.md index 94d2fa3..3b44832 100644 --- a/.roo/rules.md +++ b/.roo/rules.md @@ -102,3 +102,6 @@ - **Implement Redis Semantic Caching for LLM Embedding Calls:** Implemented Redis semantic caching for LLM embedding calls. The cache key is a hash of the input text, model, and provider. The cache entries have a Time-To-Live (TTL) of 1 hour. *(Redis was a natural extension since it is already in use for BullMQ and session caching. This implementation reduced redundant embedding calls by approximately 40% in tests.)* + +- **Ownership of Billing Module:** Replace all usages of double with string to represent money transactions in src/billing.ts. + *(Using string types for monetary values prevents floating-point arithmetic errors inherent in the double type, ensuring accuracy for financial calculations.)*