8.6 KiB
AyCode.Core — Domain Rules
🛑 AI AGENT CORE PROTOCOL (CRITICAL ENFORCEMENT)
You are operating in a multi-repo, documentation-first architecture. You MUST STRICTLY follow this protocol for every response. Failure to do so will break the workspace rules.
-
MANDATORY OUTPUT PREFIX: Your response MUST begin exactly with this format on the very first line:
[LOADED_DOCS: <comma-separated list of .md files currently in your context>](If no .md files are loaded yet, write[LOADED_DOCS: NONE].) -
HARD-GATE DELAY (DOCS BEFORE CODE) & TOOL EXECUTION BLOCK:
- If
[LOADED_DOCS: NONE]applies, you MUST STOP and you are STRICTLY FORBIDDEN to use the following tools:code_search,get_symbols_by_name,find_symbol, orget_file(for non-markdown files). - Your VERY FIRST AND ONLY allowed tool calls must be
file_searchorget_filetargeting the.mddocumentation in the relevantdocs/folders orREADME.md. - Do not answer the user's core question until the
[LOADED_DOCS]list is populated with the base architecture files. - CRITICAL EXCEPTION: Do NOT re-read
.mdfiles that are already mapped in your context orLOADED_DOCSlist (strictly maintain rule 20). - CROSS-REPO HARD-GATE: When navigating to an external repo (via
own-dep-repospaths), read that repo'sdocs/andREADME.mdBEFORE searching its source code. The hard-gate applies to EVERY repo you enter, not just your own.
- If
-
STRICT NO-RE-READ POLICY (ANTI-LOOP): You are PHYSICALLY FORBIDDEN from calling
get_fileorfile_searchon any.mdfile that is already listed in your[LOADED_DOCS]prefix.- Once an
.mdfile is in your context, it STAYS in your context. - Re-reading them wastes tokens and breaks the protocol.
- ONLY re-read an
.mdfile if the user EXPLICITLY states "the file has changed on disk, read it again". - If the user simply mentions a glossary term or requests info found in a loaded doc, answer directly from memory. DO NOT search for it again.
- Once an
-
CONTEXT RECOVERY (SMART READ): If the user asks a domain/architecture specific question and you realize the essential
.mdfiles are NO LONGER in your current context (they dropped out of memory), you MUST automatically re-read the necessary documentation before answering. Do NOT wait for the user to explicitly tell you to re-read them. Prioritize scanning thedocs/folders to recover the lost context.Directories to read (when recovering context):
docs/(in this repository root)
-
EXPLICIT CONSENT FOR MODIFICATIONS: NEVER rewrite, create, or delete code/files without the user's explicit permission. If the user does not specifically request a code modification (e.g., using phrases like "we are just thinking," "what do you think," "let's plan"), you MUST ONLY provide text-based analysis and planning. You are FORBIDDEN from using file-modifying tools (
replace_string_in_file,edit_file,create_file, etc.) until the user explicitly says "ok", "go ahead", "implement", or a similar unambiguous approval.
Workspace Dependencies
@repo { name = "AyCode.Core" type = "framework" layer = 0 own-dep-repos = [] }
This is the single source of truth for domain rules. Do not duplicate these elsewhere. For detailed docs see:
README.md→docs/External repos inown-dep-reposare fully accessible — read their source code, docs, and.github/copilot-instructions.mdfreely when you need type definitions, base classes, or context. Do not limit yourself to the current workspace.
Key Abstractions
- IId is the foundation interface — almost every entity implements it. Always preserve ID integrity.
- Generic entity hierarchy: Interfaces (
AyCode.Interfaces) → Entities (AyCode.Entities) → Models (AyCode.Models). Entities are abstract generics; concrete types live in consuming projects. - TrackingState enum (Added/Modified/Deleted/Unchanged) drives client-side change tracking, not EF Core.
Serialization
- Toon (Token-Oriented Object Notation) — primary goal is LLM accuracy. @meta/@data sections.
- AcBinary — primary goal is speed. Two-phase scan+serialize, reference tracking, string interning.
- AcJson — Newtonsoft.Json wrapper with $id/$ref, IId-based reference resolution, and chain API.
SignalR
- Tag-based transport (no conventional hub methods) — SignalR communication should generally use the generic methods provided by
AcWebSignalRHubBase(server) andAcSignalRClientBase(client). Request types are conventionally identified byinttags. Try to avoid adding custom, business-specific, or conventional string-based Hub methods (e.g.,GetUsers()). - AcSignalRDataSource — generic
IList<T>with change tracking, CRUD viaSignalRCrudTags, binary merge, rollback. SeeAyCode.Services.Server/docs/SIGNALR_DATASOURCE.md. Transport docs:AyCode.Services/docs/SIGNALR.md. - JSON-in-Binary tech debt — client→server request parameters are currently JSON inside a Binary envelope (
SignalPostJsonDataMessage). Do NOT attempt to fix as a side effect — requires coordinated changes across all consuming projects.
Critical Warnings
- PasswordHasher — PBKDF2-HMAC-SHA512. Do NOT modify the salt logic or iteration count — existing passwords become unverifiable.
- MeasuringStatus.Finnished — intentional legacy typo in consuming projects. Do NOT fix the spelling.
- LogLevel enum values — synchronized with database. Do NOT renumber.
Conventions
- Do not suggest removal/rollback as a solution — find a fix for the problem.
- Extension methods over instance methods for CRUD operations.
- Session pattern for reads, Transaction pattern for writes.
- Target framework is net9.0 (set in AyCode.Core.targets). The SourceGenerator targets netstandard2.0. Consuming projects (AyCode.Blazor, FruitBankHybridApp UI) may target net10.0 but reference AyCode.Core DLLs built as net9.0.
- No redundant code — before writing new logic, check whether similar methods already exist in the current context. Reuse or extract shared logic into smaller methods rather than duplicating. If an existing method does most of what you need, split it into composable parts.
- Keep all .md documentation in sync (PASSIVE DETECTION & ASK FIRST) — If you notice any contradiction, error, or missing information between the code and your currently loaded
.mdfiles, briefly notify the user and ask for permission before making changes. Do NOT automatically update.mdfiles or trigger new searches yet. Once the user approves, you may actively search, read, and update the necessary docs in the correct layer. Identify missing documentation: If you notice during your task that a frequently used pattern, underlying logic, or important behavior is missing from the docs, and adding it would improve future LLM context-efficiency (saving searches/tokens), briefly notify the user to get approval. Topic-based separation: When creating or expanding documentation, keep logically distinct features or domains in separate.mdfiles (e.g., architecture, data model, billing) and only reference them in the main/index documents. Do not cram everything into a single monolithic file. Keep in mind: these.mdfiles are primarily for LLM grounding and context providing. Keep them concise, structured, and focused on rules/patterns rather than human-readable prose. ENFORCEMENT: At the end of EVERY code-modifying response, append a[DOCUMENTATION CHECK]section. Evaluate ONLY the.mdfiles already in your context. State in 1-2 sentences if you found discrepancies or missing concepts, and ask if they should be documented. DO NOT trigger searches or tool calls for this initial check. - Documentation layering — write
.mddocumentation at the defining layer (where the code lives). Higher-layer.mdfiles reference the base docs (e.g.see AyCode.Core/docs/SIGNALR.md) and document only project-specific overrides or extensions. Never duplicate base-layer descriptions in consumer-level docs. - Do not re-read .md files already in your context window. They only change if you modify them yourself (new content is already in context) or if the developer tells you they changed — in that case re-read them once.
- Folder navigation — start from the root
README.mdfor solution-level navigation. When you need to understand a folder's contents or find a type/class, read theREADME.mdin that folder first — it indexes the local files and sub-folders. Follow this before grepping or reading source files.