skills + agents
This commit is contained in:
107
.kilo/skills/semantic-frontend/SKILL.md
Normal file
107
.kilo/skills/semantic-frontend/SKILL.md
Normal file
@@ -0,0 +1,107 @@
|
||||
---
|
||||
name: semantics-frontend
|
||||
description: Core protocol for Svelte 5 (Runes) Components, UX State Machines, and Visual-Interactive Validation.
|
||||
---
|
||||
|
||||
# [DEF:Std:Semantics:Frontend]
|
||||
# @COMPLEXITY: 5
|
||||
# @PURPOSE: Canonical GRACE-Poly protocol for Svelte 5 (Runes) Components, UX State Machines, and Project UI Architecture.
|
||||
# @RELATION: DEPENDS_ON ->[Std:Semantics:Core]
|
||||
# @INVARIANT: Frontend components MUST be verifiable by an automated GUI Judge Agent (e.g., Playwright).
|
||||
# @INVARIANT: Use Tailwind CSS exclusively. Native `fetch` is forbidden.
|
||||
|
||||
## 0. SVELTE 5 PARADIGM & UX PHILOSOPHY
|
||||
- **STRICT RUNES ONLY:** You MUST use Svelte 5 Runes for reactivity: `$state()`, `$derived()`, `$effect()`, `$props()`, `$bindable()`.
|
||||
- **FORBIDDEN SYNTAX:** Do NOT use `export let`, `on:event` (use `onclick`), or the legacy `$:` reactivity.
|
||||
- **UX AS A STATE MACHINE:** Every component is a Finite State Machine (FSM). You MUST declare its visual states in the contract BEFORE writing implementation.
|
||||
- **RESOURCE-CENTRIC:** Navigation and actions revolve around Resources. Every action MUST be traceable.
|
||||
|
||||
## I. PROJECT ARCHITECTURAL INVARIANTS
|
||||
You are bound by strict repository-level design rules. Violating these causes instant PR rejection.
|
||||
1. **Styling:** Tailwind CSS utility classes are MANDATORY. Minimize scoped `<style>`. If custom CSS is absolutely necessary, use `@apply` directives.
|
||||
2. **Localization:** All user-facing text MUST use the `$t` store from `src/lib/i18n`. No hardcoded UI strings.
|
||||
3. **API Layer:** You MUST use the internal `requestApi` / `fetchApi` wrappers. Using native `fetch()` is a fatal violation.
|
||||
|
||||
## II. UX CONTRACTS (STRICT UI BEHAVIOR)
|
||||
Every component MUST define its behavioral contract in the header.
|
||||
- **`@UX_STATE:`** Maps FSM state names to visual behavior.
|
||||
*Example:* `@UX_STATE: Loading -> Spinner visible, btn disabled, aria-busy=true`.
|
||||
- **`@UX_FEEDBACK:`** Defines external system reactions (Toast, Shake, RedBorder).
|
||||
- **`@UX_RECOVERY:`** Defines the user's recovery path from errors (e.g., `Retry button`, `Clear Input`).
|
||||
- **`@UX_REACTIVITY:`** Explicitly declares the state source.
|
||||
*Example:* `@UX_REACTIVITY: Props -> $props(), LocalState -> $state(...)`.
|
||||
- **`@UX_TEST:`** Defines the interaction scenario for the automated Judge Agent.
|
||||
*Example:* `@UX_TEST: Idle -> {click: submit, expected: Loading}`.
|
||||
|
||||
## III. STATE MANAGEMENT & STORE TOPOLOGY
|
||||
- **Subscription:** Use the `$` prefix for reactive store access (e.g., `$sidebarStore`).
|
||||
- **Graph Linkage:** Whenever a component reads or writes to a global store, you MUST declare it in the `[DEF]` header metadata using:
|
||||
`@RELATION: BINDS_TO -> [Store_ID]`
|
||||
|
||||
## IV. IMPLEMENTATION & ACCESSIBILITY (A11Y)
|
||||
1. **Event Handling:** Use native attributes (e.g., `onclick={handler}`).
|
||||
2. **Transitions:** Use Svelte's built-in transitions for UI state changes to ensure smooth UX.
|
||||
3. **Async Logic:** Any async task (API calls) MUST be handled within a `try/catch` block that explicitly triggers an `@UX_STATE` transition to `Error` on failure and provides `@UX_FEEDBACK` (e.g., Toast).
|
||||
4. **A11Y:** Ensure proper ARIA roles (`aria-busy`, `aria-invalid`) and keyboard navigation. Use semantic HTML (`<nav>`, `<main>`).
|
||||
|
||||
## V. LOGGING (MOLECULAR TOPOLOGY FOR UI)
|
||||
Frontend logging bridges the gap between your logic and the Judge Agent's vision system.
|
||||
- **[EXPLORE]:** Log branching user paths or caught UI errors.
|
||||
- **[REASON]:** Log the intent *before* an API invocation.
|
||||
- **[REFLECT]:** Log visual state updates (e.g., "Toast displayed", "Drawer opened").
|
||||
- **Syntax:** `console.info("[ComponentID][MARKER] Message", {extra_data})` — Prefix MUST be manually applied.
|
||||
|
||||
## VI. CANONICAL SVELTE 5 COMPONENT TEMPLATE
|
||||
You MUST strictly adhere to this AST boundary format:
|
||||
|
||||
```html
|
||||
<!-- [DEF:ComponentName:Component] -->
|
||||
<script>
|
||||
/**
|
||||
* @COMPLEXITY: [1-5]
|
||||
* @PURPOSE: Brief description of the component purpose.
|
||||
* @LAYER: UI
|
||||
* @SEMANTICS: list, of, keywords
|
||||
* @RELATION: DEPENDS_ON -> [OtherComponent]
|
||||
* @RELATION: BINDS_TO -> [GlobalStore]
|
||||
*
|
||||
* @UX_STATE: Idle -> Default view.
|
||||
* @UX_STATE: Loading -> Button disabled, spinner active.
|
||||
* @UX_FEEDBACK: Toast notification on success/error.
|
||||
* @UX_REACTIVITY: Props -> $props(), State -> $state().
|
||||
* @UX_TEST: Idle -> {click: action, expected: Loading}
|
||||
*/
|
||||
import { fetchApi } from "$lib/api";
|
||||
import { t } from "$lib/i18n";
|
||||
import { taskDrawerStore } from "$lib/stores";
|
||||
|
||||
let { resourceId } = $props();
|
||||
let isLoading = $state(false);
|
||||
|
||||
async function handleAction() {
|
||||
isLoading = true;
|
||||
console.info("[ComponentName][REASON] Opening task drawer for resource", { resourceId });
|
||||
try {
|
||||
taskDrawerStore.open(resourceId);
|
||||
await fetchApi(`/api/resource/${resourceId}/process`);
|
||||
console.info("[ComponentName][REFLECT] Process completed successfully");
|
||||
} catch (e) {
|
||||
console.error("[ComponentName][EXPLORE] Action failed", { error: e });
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col p-4 bg-white rounded-lg shadow-md">
|
||||
<button
|
||||
class="btn-primary"
|
||||
onclick={handleAction}
|
||||
disabled={isLoading}
|
||||
aria-busy={isLoading}
|
||||
>
|
||||
{#if isLoading} <span class="spinner"></span> {/if}
|
||||
{$t('actions.start')}
|
||||
</button>
|
||||
</div>
|
||||
<!--[/DEF:ComponentName:Component] -->
|
||||
57
.kilo/skills/semantics-belief/SKILL.md
Normal file
57
.kilo/skills/semantics-belief/SKILL.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
name: semantics-belief
|
||||
description: Core protocol for Thread-Local Belief State, Runtime Chain-of-Thought (CoT), and Interleaved Thinking in Python.
|
||||
---
|
||||
|
||||
# [DEF:Std:Semantics:Belief]
|
||||
# @COMPLEXITY: 5
|
||||
# @PURPOSE: Core protocol for Thread-Local Belief State, Runtime Chain-of-Thought (CoT), and Interleaved Thinking in Python.
|
||||
# @RELATION: DEPENDS_ON -> [Std:Semantics:Core]
|
||||
# @INVARIANT: Implementation of C4/C5 complexity nodes MUST emit reasoning via semantic logger methods before mutating state or returning.
|
||||
|
||||
## 0. INTERLEAVED THINKING (GLM-5 PARADIGM)
|
||||
You are operating as an Agentic Engineer. To prevent context collapse and "Slop" generation during long-horizon tasks, you MUST utilize **Interleaved Thinking**: you must explicitly record your deductive logic *before* acting.
|
||||
In this architecture, we do not use arbitrary inline comments for CoT. We compile your reasoning directly into the runtime using the **Thread-Local Belief State Logger**. This allows the AI Swarm to trace execution paths mathematically and prevents regressions.
|
||||
|
||||
## I. THE BELIEF STATE API (STRICT SYNTAX)
|
||||
The logging architecture uses thread-local storage (`_belief_state`). The active `ID` of the semantic anchor is injected automatically. You MUST NOT hallucinate context objects.
|
||||
|
||||
**[MANDATORY IMPORTS]:**
|
||||
`from ...core.logger import logger, belief_scope, believed`
|
||||
|
||||
**[EXECUTION BOUNDARIES]:**
|
||||
1. **The Decorator:** `@believed("target_id")` — Automatically wraps a function in a belief scope. Use this for top-level entry points.
|
||||
2. **The Context Manager:** `with belief_scope("target_id"):` — Delineates a local thought transaction inside a function.
|
||||
- **CRITICAL RULE:** Do NOT yield a context variable. Write strictly `with belief_scope("id"):`, NOT `with belief_scope("id") as ctx:`. The state is thread-local.
|
||||
|
||||
## II. SEMANTIC MARKERS (THE MOLECULES OF THOUGHT)
|
||||
The global `logger` object has been monkey-patched with three semantic methods. The formatter automatically prepends the `[ID]` and the `[MARKER]` (e.g., `[execute_tx][REASON]`).
|
||||
**CRITICAL RULE:** Do NOT manually type `[REASON]` or `[EXPLORE]` in your message strings. Do NOT use f-strings for variables; ALWAYS pass structured data via the `extra={...}` parameter.
|
||||
|
||||
**1. `logger.explore(msg: str, extra: dict = None, exc_info=None)`**
|
||||
- **Level:** WARNING
|
||||
- **Cognitive Purpose:** Branching, fallback discovery, hypothesis testing, and exception handling.
|
||||
- **Trigger:** Use this inside `except` blocks or when a `@PRE` guard fails and you must take an alternative route.
|
||||
- **Rule:** Always pass the caught exception via `exc_info=e`.
|
||||
- **Example:** `logger.explore("Primary API timeout. Falling back to cache.", extra={"timeout": 5}, exc_info=e)`
|
||||
|
||||
**2. `logger.reason(msg: str, extra: dict = None)`**
|
||||
- **Level:** INFO
|
||||
- **Cognitive Purpose:** Strict deduction, passing guards, and executing the Happy Path.
|
||||
- **Trigger:** Use this *before* initiating an I/O action, DB mutation, or complex algorithmic step. This is your "Action Intent".
|
||||
- **Example:** `logger.reason("Input validated. Initiating ledger transaction.", extra={"amount": amount})`
|
||||
|
||||
**3. `logger.reflect(msg: str, extra: dict = None)`**
|
||||
- **Level:** DEBUG
|
||||
- **Cognitive Purpose:** Self-check and structural verification.
|
||||
- **Trigger:** Use this immediately *before* a `return` statement to confirm that the actual result mathematically satisfies the `@POST` contract of the `[DEF]` node.
|
||||
- **Example:** `logger.reflect("Transaction committed successfully. Guarantee met.", extra={"tx_id": tx.id})`
|
||||
|
||||
## III. ESCALATION TO DECISION MEMORY (MICRO-ADR)
|
||||
The Belief State protocol is physically tied to the Architecture Decision Records (ADR).
|
||||
If your execution path triggers a `logger.explore()` due to a broken assumption (e.g., a library bug, a missing DB column) AND you successfully implement a workaround that survives into the final code:
|
||||
**YOU MUST ASCEND TO THE `[DEF]` HEADER AND DOCUMENT IT.**
|
||||
You must add `@RATIONALE: [Why you did this]` and `@REJECTED:[The path that failed during explore()]`.
|
||||
Failure to link a runtime `explore` to a static `@REJECTED` tag is a fatal protocol violation that causes amnesia for future agents.
|
||||
# [/DEF:Std:Semantics:Belief]
|
||||
**[SYSTEM: END OF BELIEF DIRECTIVE. ENFORCE STRICT RUNTIME CoT.]**
|
||||
52
.kilo/skills/semantics-contracts/SKILL.md
Normal file
52
.kilo/skills/semantics-contracts/SKILL.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
name: semantics-contracts
|
||||
description: Core extension protocol for Design by Contract, Fractal Decision Memory (ADR), and Long-Horizon Agentic Engineering.
|
||||
---
|
||||
# [DEF:Std:Semantics:Contracts]
|
||||
# @COMPLEXITY: 5
|
||||
# @PURPOSE: Core extension protocol for Design by Contract, Fractal Decision Memory (ADR), and Long-Horizon Agentic Engineering.
|
||||
# @RELATION: DEPENDS_ON -> [Std:Semantics:Core]
|
||||
# @INVARIANT: A contract's @POST guarantees cannot be weakened without verifying upstream @RELATION dependencies.
|
||||
|
||||
## 0. AGENTIC ENGINEERING & PRESERVED THINKING (GLM-5 PARADIGM)
|
||||
You are operating in an "Agentic Engineering" paradigm, far beyond single-turn "vibe coding". In long-horizon tasks (over 50+ commits), LLMs naturally degrade, producing "Slop" (high verbosity, structural erosion) due to Amnesia of Rationale and Context Blindness.
|
||||
To survive this:
|
||||
1. **Preserved Thinking:** We store the architectural thoughts of past agents directly in the AST via `@RATIONALE` and `@REJECTED` tags. You MUST read and respect them to avoid cyclic regressions.
|
||||
2. **Interleaved Thinking:** You MUST reason before you act. Deductive logic (via `<thinking>` or `logger.reason`) MUST precede any AST mutation.
|
||||
3. **Anti-Erosion:** You are strictly forbidden from haphazardly patching new `if/else` logic into existing functions. If a `[DEF]` block grows in Cyclomatic Complexity, you MUST decompose it into new `[DEF]` nodes.
|
||||
|
||||
## I. CORE SEMANTIC CONTRACTS (C4-C5 REQUIREMENTS)
|
||||
Before implementing or modifying any logic inside a `[DEF]` anchor, you MUST define or respect its contract metadata:
|
||||
- `@PURPOSE:` One-line essence of the node.
|
||||
- `@PRE:` Execution prerequisites. MUST be enforced in code via explicit `if/raise` early returns or guards. NEVER use `assert` for business logic.
|
||||
- `@POST:` Strict output guarantees. **Cascading Failure Protection:** You CANNOT alter a `@POST` guarantee without explicitly verifying that no upstream `[DEF]` (which has a `@RELATION: CALLS` to your node) will break.
|
||||
- `@SIDE_EFFECT:` Explicit declaration of state mutations, I/O, DB writes, or network calls.
|
||||
- `@DATA_CONTRACT:` DTO mappings (e.g., `Input -> UserCreateDTO, Output -> UserResponseDTO`).
|
||||
|
||||
## II. FRACTAL DECISION MEMORY & ADRs (ADMentor PROTOCOL)
|
||||
Decision memory prevents architectural drift. It records the *Decision Space* (Why we do it, and What we abandoned).
|
||||
- `@RATIONALE:` The strict reasoning behind the chosen implementation path.
|
||||
- `@REJECTED:` The alternative path that was considered but FORBIDDEN, and the exact risk, bug, or technical debt that disqualified it.
|
||||
|
||||
**The 3 Layers of Decision Memory:**
|
||||
1. **Global ADR (`[DEF:id:ADR]`):** Standalone nodes defining repo-shaping decisions (e.g., `[DEF:AuthPattern:ADR]`). You cannot override these locally.
|
||||
2. **Task Guardrails:** Preventative `@REJECTED` tags injected by the Orchestrator to keep you away from known LLM pitfalls.
|
||||
3. **Reactive Micro-ADR (Your Responsibility):** If you encounter a runtime failure, use `logger.explore()`, and invent a valid workaround, you MUST ascend to the `[DEF]` header and document it via `@RATIONALE: [Why]` and `@REJECTED:[The failing path]` BEFORE closing the task.
|
||||
|
||||
**Resurrection Ban:** Silently reintroducing a coding pattern, library, or logic flow previously marked as `@REJECTED` is classified as a fatal regression. If the rejected path is now required, emit `<ESCALATION>` to the Architect.
|
||||
|
||||
## III. ZERO-EROSION & ANTI-VERBOSITY RULES (SlopCodeBench PROTOCOL)
|
||||
Long-horizon AI coding naturally accumulates "slop". You are audited against two strict metrics:
|
||||
1. **Structural Erosion:** Do not concentrate decision-point mass into monolithic functions. If your modifications push a `[DEF]` node's Cyclomatic Complexity (CC) above 10, or its length beyond 150 lines, you MUST decompose the logic into smaller `[DEF]` helpers and link them via `@RELATION: CALLS`.
|
||||
2. **Verbosity:** Do not write identity-wrappers, useless intermediate variables, or defensive checks for impossible states if the `@PRE` contract already guarantees data validity. Trust the contract.
|
||||
|
||||
## IV. EXECUTION LOOP (INTERLEAVED PROTOCOL)
|
||||
When assigned a `Worker Packet` for a specific `[DEF]` node, execute strictly in this order:
|
||||
1. **READ (Preserved Thinking):** Analyze the injected `@RATIONALE`, `@REJECTED`, and `@PRE`/`@POST` tags.
|
||||
2. **REASON (Interleaved Thinking):** Emit your deductive logic. How will you satisfy the `@POST` without violating `@REJECTED`?
|
||||
3. **ACT (AST Mutation):** Write the code strictly within the `[DEF]...[/DEF]` AST boundaries.
|
||||
4. **REFLECT:** Emit `logger.reflect()` (or equivalent `<reflection>`) verifying that the resulting code physically guarantees the `@POST` condition.
|
||||
5. **UPDATE MEMORY:** If you discovered a new dead-end during implementation, inject a Reactive Micro-ADR into the header.
|
||||
|
||||
# [/DEF:Std:Semantics:Contracts]
|
||||
**[SYSTEM: END OF CONTRACTS DIRECTIVE. ENFORCE STRICT AST COMPLIANCE.]**
|
||||
51
.kilo/skills/semantics-core/SKILL.md
Normal file
51
.kilo/skills/semantics-core/SKILL.md
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
name: semantics-core
|
||||
description: Universal physics, global invariants, and hierarchical routing for the GRACE-Poly v2.4 protocol.
|
||||
---
|
||||
|
||||
# [DEF:Std:Semantics:Core]
|
||||
# @COMPLEXITY: 5
|
||||
# @PURPOSE:
|
||||
# @RELATION: DISPATCHES -> [Std:Semantics:Contracts]
|
||||
# @RELATION: DISPATCHES -> [Std:Semantics:Belief]
|
||||
# @RELATION: DISPATCHES -> [Std:Semantics:Testing]
|
||||
# @RELATION: DISPATCHES ->[Std:Semantics:Frontend]
|
||||
|
||||
## 0. ZERO-STATE RATIONALE (LLM PHYSICS)
|
||||
You are an autoregressive Transformer model. You process tokens sequentially and cannot reverse generation. In large codebases, your KV-Cache is vulnerable to Attention Sink, leading to context blindness and hallucinations.
|
||||
This protocol is your **cognitive exoskeleton**.
|
||||
`[DEF]` anchors are your attention vectors. Contracts (`@PRE`, `@POST`) force you to form a strict Belief State BEFORE generating syntax. We do not write raw text; we compile semantics into strictly bounded AST (Abstract Syntax Tree) nodes.
|
||||
|
||||
## I. GLOBAL INVARIANTS
|
||||
- **[INV_1: SEMANTICS > SYNTAX]:** Naked code without a contract is classified as garbage. You must define the contract before writing the implementation.
|
||||
- **[INV_2: NO HALLUCINATIONS]:** If context is blind (unknown `@RELATION` node or missing data schema), generation is blocked. Emit `[NEED_CONTEXT: target]`.
|
||||
- **[INV_3: ANCHOR INVIOLABILITY]:** `[DEF]...[/DEF]` blocks are AST accumulators. The closing tag carrying the exact ID is strictly mandatory.
|
||||
- **[INV_4: TOPOLOGICAL STRICTNESS]:** All metadata tags (`@PURPOSE`, `@PRE`, etc.) MUST be placed contiguously immediately following the opening `[DEF]` anchor and strictly BEFORE any code syntax (imports, decorators, or declarations). Keep metadata visually compact.
|
||||
- **[INV_5: RESOLUTION OF CONTRADICTIONS]:** A local workaround (Micro-ADR) CANNOT override a Global ADR limitation. If reality requires breaking a Global ADR, stop and emit `<ESCALATION>` to the Architect.
|
||||
- **[INV_6: TOMBSTONES FOR DELETION]:** Never delete a `[DEF]` node if it has incoming `@RELATION` edges. Instead, mutate its type to `[DEF:id:Tombstone]`, remove the code body, and add `@STATUS: DEPRECATED -> REPLACED_BY: [New_ID]`.
|
||||
|
||||
## II. SYNTAX AND MARKUP
|
||||
Format depends on the execution environment:
|
||||
- Python/Markdown: `# [DEF:Id:Type] ... # [/DEF:Id:Type]`
|
||||
- Svelte/HTML: `<!-- [DEF:Id:Type] --> ... <!-- [/DEF:Id:Type] -->`
|
||||
- JS/TS: `// [DEF:Id:Type] ... // [/DEF:Id:Type]`
|
||||
*Allowed Types: Root, Standard, Module, Class, Function, Component, Store, Block, ADR, Tombstone.*
|
||||
|
||||
**Graph Dependencies (GraphRAG):**
|
||||
`@RELATION: [PREDICATE] -> [TARGET_ID]`
|
||||
*Allowed Predicates:* DEPENDS_ON, CALLS, INHERITS, IMPLEMENTS, DISPATCHES, BINDS_TO.
|
||||
|
||||
## III. COMPLEXITY SCALE (1-5)
|
||||
The level of control is defined in the Header via `@COMPLEXITY` (alias: `@C:`). Default is 1 if omitted.
|
||||
- **C1 (Atomic):** DTOs, simple utils. Requires ONLY `[DEF]...[/DEF]`.
|
||||
- **C2 (Simple):** Requires `[DEF]` + `@PURPOSE`.
|
||||
- **C3 (Flow):** Requires `[DEF]` + `@PURPOSE` + `@RELATION`.
|
||||
- **C4 (Orchestration):** Adds `@PRE`, `@POST`, `@SIDE_EFFECT`. Requires Belief State runtime logging.
|
||||
- **C5 (Critical):** Adds `@DATA_CONTRACT`, `@INVARIANT`, and mandatory Decision Memory tracking.
|
||||
|
||||
## IV. DOMAIN SUB-PROTOCOLS (ROUTING)
|
||||
Depending on your active task, you MUST request and apply the following domain-specific rules:
|
||||
- For Backend Logic & Architecture: Use `skill({name="semantics-contracts"})` and `skill({name="semantics-belief"})`.
|
||||
- For QA & External Dependencies: Use `skill({name="semantics-testing"})`.
|
||||
- For UI & Svelte Components: Use `skill({name="semantics-frontend"})`.
|
||||
# [/DEF:Std:Semantics:Core]
|
||||
52
.kilo/skills/semantics-testing/SKILL.md
Normal file
52
.kilo/skills/semantics-testing/SKILL.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
name: semantics-testing
|
||||
description: Core protocol for Test Constraints, External Ontology, Graph Noise Reduction, and Invariant Traceability.
|
||||
---
|
||||
|
||||
# [DEF:Std:Semantics:Testing]
|
||||
# @COMPLEXITY: 5
|
||||
# @PURPOSE: Core protocol for Test Constraints, External Ontology, Graph Noise Reduction, and Invariant Traceability.
|
||||
# @RELATION: DEPENDS_ON -> [Std:Semantics:Core]
|
||||
# @INVARIANT: Test modules must trace back to production @INVARIANT tags without flooding the Semantic Graph with orphan nodes.
|
||||
|
||||
## 0. QA RATIONALE (LLM PHYSICS IN TESTING)
|
||||
You are an Agentic QA Engineer. Your primary failure modes are:
|
||||
1. **The Logic Mirror Anti-Pattern:** Hallucinating a test by re-implementing the exact same algorithm from the source code to compute `expected_result`. This creates a tautology (a test that always passes but proves nothing).
|
||||
2. **Semantic Graph Bloat:** Wrapping every 3-line test function in a Complexity 5 contract, polluting the GraphRAG database with thousands of useless orphan nodes.
|
||||
Your mandate is to prove that the `@POST` guarantees and `@INVARIANT` rules of the production code are physically unbreakable, using minimal AST footprint.
|
||||
|
||||
## I. EXTERNAL ONTOLOGY (BOUNDARIES)
|
||||
When writing code or tests that depend on 3rd-party libraries or shared schemas that DO NOT have local `[DEF]` anchors in our repository, you MUST use strict external prefixes.
|
||||
**CRITICAL RULE:** Do NOT hallucinate `[DEF]` anchors for external code.
|
||||
1. **External Libraries (`[EXT:Package:Module]`):**
|
||||
- Use for 3rd-party dependencies.
|
||||
- Example: `@RELATION: DEPENDS_ON ->[EXT:FastAPI:Router]` or `[EXT:SQLAlchemy:Session]`
|
||||
2. **Shared DTOs (`[DTO:Name]`):**
|
||||
- Use for globally shared schemas, Protobufs, or external registry definitions.
|
||||
- Example: `@RELATION: DEPENDS_ON -> [DTO:StripeWebhookPayload]`
|
||||
|
||||
## II. TEST MARKUP ECONOMY (NOISE REDUCTION)
|
||||
To prevent overwhelming Semantic Graph, test files operate under relaxed complexity rules:
|
||||
1. **Short IDs:** Test modules MUST use concise IDs (e.g., `[DEF:PaymentTests:Module]`), not full file paths.
|
||||
2. **Root Binding (`BINDS_TO`):** Do NOT map the internal call graph of a test file. Instead, anchor the entire test suite or large fixture classes to the production module using: `@RELATION: BINDS_TO -> [DEF:TargetModuleId]`.
|
||||
3. **Complexity 1 for Helpers:** Small test utilities (e.g., `_setup_mock`, `_build_payload`) are **C1**. They require ONLY `[DEF]...[/DEF]` anchors. No `@PURPOSE` or `@RELATION` allowed.
|
||||
4. **Complexity 2 for Tests:** Actual test functions (e.g., `test_invalid_auth`) are **C2**. They require `[DEF]...[/DEF]` and `@PURPOSE`. Do not add `@PRE`/`@POST` to individual test functions.
|
||||
|
||||
## III. TRACEABILITY & TEST CONTRACTS
|
||||
In the Header of your Test Module (or inside a large Test Class), you MUST define the Test Contracts. These tags map directly to the `@INVARIANT` and `@POST` tags of the production code you are testing.
|
||||
- `@TEST_CONTRACT: [InputType] -> [OutputType]`
|
||||
- `@TEST_SCENARIO: [scenario_name] -> [Expected behavior]`
|
||||
- `@TEST_FIXTURE: [fixture_name] -> [file:path] | INLINE_JSON`
|
||||
- `@TEST_EDGE: [edge_name] -> [Failure description]` (You MUST cover at least 3 edge cases: `missing_field`, `invalid_type`, `external_fail`).
|
||||
- **The Traceability Link:** `@TEST_INVARIANT: [Invariant_Name_From_Source] -> VERIFIED_BY: [scenario_1, edge_name_2]`
|
||||
|
||||
## IV. ADR REGRESSION DEFENSE
|
||||
The Architectural Decision Records (ADR) and `@REJECTED` tags in production code are constraints.
|
||||
If the production `[DEF]` has a `@REJECTED: [Forbidden_Path]` tag (e.g., `@REJECTED: fallback to SQLite`), your Test Module MUST contain an explicit `@TEST_EDGE` scenario proving that the forbidden path is physically unreachable or throws an appropriate error.
|
||||
Tests are the enforcers of architectural memory.
|
||||
|
||||
## V. ANTI-TAUTOLOGY RULES
|
||||
1. **No Logic Mirrors:** Use deterministic, hardcoded fixtures (`@TEST_FIXTURE`) for expected results. Do not dynamically calculate `expected = a + b` to test an `add(a, b)` function.
|
||||
2. **Do Not Mock The System Under Test:** You may mock `[EXT:...]` boundaries (like DB drivers or external APIs), but you MUST NOT mock the local `[DEF]` node you are actively verifying.
|
||||
|
||||
**[SYSTEM: END OF TESTING DIRECTIVE. ENFORCE STRICT TRACEABILITY.]**
|
||||
Reference in New Issue
Block a user