diff --git a/.agent/workflows/audit-test.md b/.agent/workflows/audit-test.md index 5e20c37..737a3d5 100644 --- a/.agent/workflows/audit-test.md +++ b/.agent/workflows/audit-test.md @@ -6,7 +6,7 @@ description: Audit AI-generated unit tests. Your goal is to aggressively search **OBJECTIVE:** Audit AI-generated unit tests. Your goal is to aggressively search for "Test Tautologies", "Logic Echoing", and "Contract Negligence". You are the final gatekeeper. If a test is meaningless, you MUST reject it. **INPUT:** -1. SOURCE CODE (with GRACE-Poly `[DEF]` Contract: `@PRE`, `@POST`, `@TEST_DATA`). +1. SOURCE CODE (with GRACE-Poly `[DEF]` Contract: `@PRE`, `@POST`, `@TEST_`). 2. GENERATED TEST CODE. ### I. CRITICAL ANTI-PATTERNS (REJECT IMMEDIATELY IF FOUND): @@ -17,7 +17,7 @@ description: Audit AI-generated unit tests. Your goal is to aggressively search 2. **The Logic Mirror (Echoing):** - *Definition:* The test re-implements the exact same algorithmic logic found in the source code to calculate the `expected_result`. If the original logic is flawed, the test will falsely pass. - - *Rule:* Tests must assert against **static, predefined outcomes** (from `@TEST_DATA` or explicit constants), NOT dynamically calculated outcomes using the same logic as the source. + - *Rule:* Tests must assert against **static, predefined outcomes** (from `@TEST_` or explicit constants), NOT dynamically calculated outcomes using the same logic as the source. 3. **The "Happy Path" Illusion:** - *Definition:* The test suite only checks successful executions but ignores the `@PRE` conditions (Negative Testing). @@ -31,7 +31,7 @@ description: Audit AI-generated unit tests. Your goal is to aggressively search Evaluate the test code against these criteria: 1. **Target Invocation:** Does the test actually import and call the function/component declared in the `@RELATION: VERIFIES` tag? 2. **Contract Alignment:** Does the test suite cover 100% of the `@PRE` (negative tests) and `@POST` (assertions) conditions from the source contract? -3. **Data Usage:** Does the test use the exact scenarios defined in `@TEST_DATA`? +3. **Data Usage:** Does the test use the exact scenarios defined in `@TEST_`? 4. **Mocking Sanity:** Are external dependencies mocked correctly WITHOUT mocking the system under test itself? ### III. OUTPUT FORMAT diff --git a/.ai/PERSONA.md b/.ai/PERSONA.md index 78cb86f..c73972f 100644 --- a/.ai/PERSONA.md +++ b/.ai/PERSONA.md @@ -26,7 +26,7 @@ 4. **ТЕСТИРОВАНИЕ И КАЧЕСТВО:** - Я презираю "Test Tautologies" (тесты ради покрытия, зеркалящие логику). - Тесты должны быть Contract-Driven. Если есть `@PRE`, я ожидаю тест на его нарушение. - - Тесты обязаны использовать `@TEST_DATA` из контрактов. + - Тесты обязаны использовать `@TEST_` из контрактов. 5. **ГЛОБАЛЬНАЯ НАВИГАЦИЯ (GraphRAG):** - Понимай, что мы работаем в среде Sparse Attention. diff --git a/.ai/shots/critical_module.py b/.ai/shots/critical_module.py index 309f03e..490b25d 100644 --- a/.ai/shots/critical_module.py +++ b/.ai/shots/critical_module.py @@ -5,12 +5,75 @@ # @LAYER: Domain (Core) # @RELATION: DEPENDS_ON -> [DEF:Infra:PostgresDB] # @RELATION: DEPENDS_ON -> [DEF:Infra:AuditLog] +# # @INVARIANT: Total system balance must remain constant (Double-Entry Bookkeeping). # @INVARIANT: Negative transfers are strictly forbidden. +# @INVARIANT: No partial commit must occur under failure (ACID Atomicity). + +# @TEST_CONTRACT: TransferInput -> +# { +# required_fields: { +# sender_id: str, +# receiver_id: str, +# amount: Decimal +# }, +# invariants: [ +# "amount > 0", +# "sender_id != receiver_id" +# ], +# constraints: [ +# "sender must exist", +# "receiver must exist" +# ] +# } + +# @TEST_CONTRACT: TransferResult -> +# { +# required_fields: { +# tx_id: str, +# status: str, +# new_balance: Decimal +# }, +# invariants: [ +# "status == COMPLETED implies balance mutation occurred" +# ] +# } + +# @TEST_FIXTURE: sufficient_funds -> +# { +# sender_balance: 500.00, +# receiver_balance: 100.00, +# amount: 100.00 +# } + +# @TEST_EDGE: insufficient_funds -> +# { +# sender_balance: 50.00, +# receiver_balance: 100.00, +# amount: 100.00 +# } +# +# @TEST_EDGE: negative_amount -> +# { +# sender_balance: 500.00, +# receiver_balance: 100.00, +# amount: -10.00 +# } +# +# @TEST_EDGE: self_transfer -> +# { +# sender_id: "acc_A", +# receiver_id: "acc_A", +# amount: 10.00 +# } + +# @TEST_EDGE: audit_failure -> raises Exception +# @TEST_EDGE: concurrency_conflict -> special: concurrent_execution + +# @TEST_INVARIANT: total_balance_constant -> verifies: [sufficient_funds, concurrency_conflict] +# @TEST_INVARIANT: no_partial_commit -> verifies: [audit_failure] +# @TEST_INVARIANT: negative_transfer_forbidden -> verifies: [negative_amount] -# @TEST_DATA: sufficient_funds -> {"from": "acc_A", "to": "acc_B", "amt": 100.00} -# @TEST_DATA: insufficient_funds -> {"from": "acc_empty", "to": "acc_B", "amt": 1000.00} -# @TEST_DATA: concurrency_lock -> {./fixtures/transactions.json#race_condition} from decimal import Decimal from typing import NamedTuple diff --git a/.ai/shots/frontend_component.svelte b/.ai/shots/frontend_component.svelte index 0f87cc1..d5d18e1 100644 --- a/.ai/shots/frontend_component.svelte +++ b/.ai/shots/frontend_component.svelte @@ -1,24 +1,67 @@ - +