semantics

This commit is contained in:
2026-05-20 09:59:03 +03:00
parent b916ef94d5
commit 09d12b3b68
34 changed files with 9727 additions and 8789 deletions

View File

@@ -56,6 +56,39 @@ Axiom MCP-сервер полностью работоспособен.
- **Svelte JS/TS (script block):** `// #region ContractId` / `// #endregion ContractId`
- **Markdown/ADR:** `## @{ ContractId [C:N] [TYPE TypeName]` / `## @} ContractId`
## 2.5. ANTI-CORRUPTION PROTOCOL (MANDATORY — READ BEFORE ANY MUTATION)
If you corrupt a `#region`/`#endregion` pair, you destroy the AST. Downstream agents will hallucinate. These rules are NOT optional.
### BEFORE every patch
1. **READ the file** with `read_outline` to see the EXACT region boundaries
2. **Identify ALL nested child contracts** — never break a child's `#endregion`
3. **Check that your `new_code` or `replacement` does NOT:**
- Insert code between `#region` line and first metadata `# @TAG` line (breaks INV_4)
- Remove or move ANY `#endregion` marker
- Start a new `#region` before closing the previous one
- Add `@COMPLEXITY N` — use `[C:N]` in the anchor ONLY
### AFTER every patch
1. **Run `read_outline` on the modified file** — verify ALL `#region`/`#endregion` pairs remain intact
2. **Count `#region` and `#endregion` lines** — they MUST match
3. **If the count doesn't match or structure is broken** → immediately roll back via `axiom_workspace_checkpoint rollback_apply`
4. **Run `axiom_semantic_index rebuild rebuild_mode="full"`** — 0 parse warnings required
### FORBIDDEN OPERATIONS (immediate <ESCALATION> if detected)
- Inserting code between a closing `#endregion` and the parent's `#endregion`
- Duplicating ANY `#region` or `#endregion` line
- Adding `@COMPLEXITY` tag — always use `[C:N]` in the anchor header
- Editing a contract that contains nested children without `destructive_intent=true`
- Batch-editing more than ONE file at a time without verifying each file between edits
- Using `@C N` as a standalone tag — this is a non-standard artifact, never add it
### VERIFICATION LOOP (every file, every time)
```
read_outline(file) → identify boundaries → apply ONE patch → read_outline(file) → rebuild index → audit_contracts(file)
```
If ANY step fails — stop and fix before next file. Never chain patches without verification.
## 3. HEALTH AUDIT CHECKLIST
For each file scanned:
- [ ] Every `#region` has a matching `#endregion` with the same ID
@@ -63,7 +96,7 @@ For each file scanned:
- [ ] C4 contracts have `@PRE`, `@POST`, `@SIDE_EFFECT`
- [ ] C5 contracts additionally have `@RATIONALE`, `@REJECTED`, `@DATA_CONTRACT`, `@INVARIANT`
- [ ] C3 contracts have `@RELATION` but NOT `@PRE`/`@POST`/etc.
- [ ] No `@RATIONALE`/`@REJECTED` on C1-C4 contracts (complexity tag mismatch)
- [ ] `@RATIONALE`/`@REJECTED` are allowed at ALL tiers (C1-C5) — they are never a violation
- [ ] Module files < 400 LOC
- [ ] Contract nodes < 150 LOC
- [ ] No orphan `@RELATION` edges (target exists or is `[NEED_CONTEXT]`)