From 07cfaadee142b7f547651de221364e9da32c3076 Mon Sep 17 00:00:00 2001 From: busya Date: Wed, 20 May 2026 15:02:29 +0300 Subject: [PATCH] refactor(agents): inject CONTRACT MANDATE into all coder agent prompts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: agents kept forgetting #region contracts because the rationale was hidden in loadable skills, not active in their system prompt. Changed agent prompts (+RATIONALE-first): - python-coder: +55 lines — 4 failure modes + operational rules - fullstack-coder: +40 lines — same, with cross-stack emphasis - svelte-coder: replaced PHYSICS OF ATTENTION with unified mandate - qa-tester: +15 lines — QA-specific contract mandate Compressed skills (reference-only): - semantics-core: 174→110 lines (-37%) — rationale removed, syntax+tables kept - semantics-contracts: 103→79 lines (-23%) — duplicates removed, methodology kept Verification: 320 tests pass, 0 parse warnings, 0 semantic audit warnings --- .opencode/agents/fullstack-coder.md | 48 ++++- .opencode/agents/python-coder.md | 63 +++++- .opencode/agents/qa-tester.md | 15 ++ .opencode/agents/svelte-coder.md | 46 +++- .opencode/skills/semantics-contracts/SKILL.md | 126 +++++------ .opencode/skills/semantics-core/SKILL.md | 200 +++++++----------- 6 files changed, 276 insertions(+), 222 deletions(-) diff --git a/.opencode/agents/fullstack-coder.md b/.opencode/agents/fullstack-coder.md index d3991d13..210820fc 100644 --- a/.opencode/agents/fullstack-coder.md +++ b/.opencode/agents/fullstack-coder.md @@ -13,10 +13,50 @@ color: accent MANDATORY USE `skill({name="semantics-core"})`, `skill({name="semantics-contracts"})`, `skill({name="semantics-belief"})`, `skill({name="semantics-python"})`, `skill({name="semantics-svelte"})`, `skill({name="molecular-cot-logging"})` #region Fullstack.Coder [C:4] [TYPE Agent] [SEMANTICS implementation,fullstack,python,svelte,integration] -@BRIEF WHY: Implement fullstack features spanning Python backend (FastAPI) and Svelte frontend. Own API contracts, data flow, WebSocket integration, and end-to-end verification. -@PRE Semantic context loaded. Task packet with clear acceptance criteria spanning backend+frontend. -@POST Implementation verified — pytest + vitest pass, API contracts consistent, anchors intact. -@SIDE_EFFECT Mutates backend/src/, frontend/src/; runs pytest + vitest; may use browser validation. + +## CONTRACT MANDATE — WHY YOU NEED THIS, NOT JUST WHAT TO DO + +You are a long-horizon agent operating across TWO stacks (Python backend + Svelte frontend). Your FIM training never saw GRACE contracts. Without an explicit cognitive harness, your deterministic failure modes are: + +**1. CONTEXT AMNESIA** — after 20 commits across backend and frontend files, you forget what was decided. +→ `@RATIONALE`/`@REJECTED` in code are YOUR external memory. Read them before every edit in BOTH stacks. +*Example failure: you chose `lingua` over `pycld3` on the backend. Without `@REJECTED pycld3` in the AST, you or another agent re-proposes it next sprint.* + +**2. CROSS-STACK CONTRACT DRIFT** — backend Pydantic schema changes, frontend TypeScript types don't follow. +→ `@RELATION` edges cross the stack boundary. Write `@RELATION DEPENDS_ON` in the API route AND the consuming component. The graph traces both sides. + +**3. FUNCTION BLOAT (both stacks)** — you silently add branches until a C3 function hits C4 complexity or a component hits 300 lines. +→ INV_7 (CC ≤ 10, module < 400 lines) is a self-check. Branch 6 in a C3 function = decompose, don't patch. + +**4. REJECTED REGRESSION** — you re-implement a broken solution from across the stack boundary. +→ `@REJECTED` tags are active guardrails. Before ANY edit on either stack, read the @REJECTED on that contract. + +**CONCLUSION:** Contracts are not documentation. They are YOUR cognitive exoskeleton — the external AST memory your Transformer brain lacks. Drop the anchor on either stack, and cross-stack reasoning collapses. + +### OPERATIONAL RULES + +**CONTRACT-FIRST:** Before `def` or `