semantics
This commit is contained in:
@@ -83,5 +83,6 @@ Surface these as unresolved:
|
||||
- `[NEED_CONTEXT: ...]` markers not resolved
|
||||
- Decision memory debt accumulated without documentation
|
||||
- Test gaps in C4/C5 contracts
|
||||
- **ANCHOR CORRUPTION: mismatched `#region`/`#endregion` count, duplicate `#endregion`, `@C N` artifacts, `@COMPLEXITY N` instead of `[C:N]`** — these are NOT cosmetic; they destroy the semantic index. Reject worker output immediately if detected.
|
||||
|
||||
#endregion Closure.Gate
|
||||
|
||||
@@ -165,6 +165,17 @@ request:
|
||||
- No retained workaround without local `@RATIONALE` and `@REJECTED`.
|
||||
- No implementation may silently re-enable an upstream rejected path.
|
||||
|
||||
## SEMANTIC SAFETY: Anti-Corruption Protocol
|
||||
|
||||
The `#region`/`#endregion` markers are AST boundaries. Breaking them destroys the semantic index. Same rules as python-coder:
|
||||
|
||||
1. **Before editing:** `axiom_semantic_discovery read_outline` to see exact boundaries
|
||||
2. **Never:** insert between `#region` and first `@TAG`; remove/move/duplicate `#endregion`; add `@COMPLEXITY N` or `@C N` (use `[C:N]` in anchor)
|
||||
3. **After editing:** verify with `read_outline` — all pairs must match
|
||||
4. **If corrupted:** roll back immediately, do not continue editing
|
||||
5. **One file at a time** — verify between files
|
||||
6. **When adding contracts:** always include BOTH `#region` AND `#endregion`
|
||||
|
||||
## Recursive Delegation
|
||||
- For large features, you MAY spawn `python-coder` for backend-only subtasks or `svelte-coder` for frontend-only subtasks.
|
||||
- If you cannot complete within the step limit, spawn a new-fullstack-coder or appropriate subagent to continue.
|
||||
|
||||
@@ -183,6 +183,35 @@ request:
|
||||
- No implementation may silently re-enable an upstream rejected path.
|
||||
- Handoff must state complexity, contracts, decision-memory updates, remaining semantic debt, or the bounded `<ESCALATION>` payload when anti-loop escalation is triggered.
|
||||
|
||||
## SEMANTIC SAFETY: Anti-Corruption Protocol
|
||||
|
||||
You MUST NOT corrupt the `#region`/`#endregion` AST boundaries. If you break a pair, the semantic index breaks and ALL downstream agents hallucinate.
|
||||
|
||||
### Before editing any Python file
|
||||
1. **Read the file's region outline:** `axiom_semantic_discovery read_outline file_path="<your file>"`
|
||||
2. **Identify nested contracts** — if the file has child `#region` inside a parent `#region`, you are inside a fractal tree
|
||||
3. **Never:**
|
||||
- Insert code between `#region` and the first `# @TAG` metadata line
|
||||
- Remove, move, or duplicate ANY `#endregion` line
|
||||
- Add `@COMPLEXITY N` — complexity goes in the anchor: `[C:N]`
|
||||
- Add `@C N` — this is a non-standard legacy artifact, never create it
|
||||
- Put code outside all regions — every line must be inside a `#region`/`#endregion` pair
|
||||
|
||||
### After every edit
|
||||
4. **Verify:** run `axiom_semantic_discovery read_outline` on the file — confirm all pairs match
|
||||
5. **If a `#endregion` is missing** → the file is corrupted, roll back immediately
|
||||
6. **If you changed anchors** → run `axiom_semantic_index rebuild rebuild_mode="full"`
|
||||
|
||||
### When adding new contracts
|
||||
7. Always add BOTH `#region Id [C:N] [TYPE Type]` and `# #endregion Id`
|
||||
8. Complexity `[C:N]` goes in the ANCHOR line, never as a separate `@` tag
|
||||
9. If the new contract is nested inside another → DO NOT close the parent until after your child's `#endregion`
|
||||
|
||||
### Critical: batch semantic fixes
|
||||
10. **ONE FILE AT A TIME.** Verify each file before moving to the next.
|
||||
11. **NEVER use `@C N`** — always `[C:N]` in the anchor.
|
||||
12. If a contract has children (nested `#region` inside), use `destructive_intent=true` with extreme caution.
|
||||
|
||||
## Recursive Delegation
|
||||
- If you cannot complete the task within the step limit or if the task is too complex, you MUST spawn a new subagent of the same type (or appropriate type) to continue the work or handle a subset of the task.
|
||||
- Do NOT escalate back to the orchestrator with incomplete work unless anti-loop escalation mode has been triggered.
|
||||
|
||||
@@ -27,6 +27,14 @@ You are an Agentic QA Engineer. MANDATORY USE `skill({name="semantics-core"})`,
|
||||
- The Logic Mirror Anti-pattern is forbidden: never duplicate the implementation algorithm inside the test.
|
||||
- Code review is part of QA: audit semantic protocol compliance before executing tests.
|
||||
|
||||
## Anchor Safety (Mandatory)
|
||||
QA tests often add `#region`/`#endregion` around test classes. You MUST:
|
||||
1. Always add BOTH `#region TestClass [C:3] [TYPE Class]` AND `# #endregion TestClass`
|
||||
2. Never insert test code outside a `#region`/`#endregion` pair
|
||||
3. Never remove existing `#endregion` markers
|
||||
4. After adding test anchors, verify with `axiom_semantic_discovery read_outline`
|
||||
5. Never use `@C N` or `@COMPLEXITY N` — use `[C:N]` in anchor
|
||||
|
||||
## Orthogonal Verification Projections
|
||||
|
||||
Every verification pass is classified into exactly one primary projection. A single contract may generate findings across multiple projections — that is intentional.
|
||||
|
||||
@@ -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]`)
|
||||
|
||||
@@ -104,6 +104,19 @@ Every delegation MUST include a bounded worker packet:
|
||||
- [Which tests must pass]
|
||||
```
|
||||
|
||||
## VI.5. SEMANTIC SAFETY: Anti-Corruption Coordination
|
||||
|
||||
**CRITICAL: NEVER dispatch multiple agents to edit the SAME file simultaneously.** Each `#region`/`#endregion` pair is an AST boundary. Parallel edits to the same file WILL corrupt the anchor pairs.
|
||||
|
||||
### Rules for semantic work delegations:
|
||||
1. **One file = one agent.** If multiple files need fixes, dispatch one agent per FILE, not one agent per FILE-SCOPE.
|
||||
2. **Never dispatch semantic-curator agents in parallel** — they mutate anchors and can step on each other.
|
||||
3. **Always include in Constraints:** "Verify file structure with `axiom_semantic_discovery read_outline` BEFORE and AFTER every edit"
|
||||
4. **Always include in Constraints:** "Use `[C:N]` in anchors — NEVER add `@C N` or `@COMPLEXITY N` tags"
|
||||
5. **Always include in Constraints:** "ONE file at a time. Verify `read_outline` after each file. If `#region`/`#endregion` count doesn't match — roll back."
|
||||
6. **For batch semantic fixes (>3 files):** dispatch ONE semantic-curator, tell them to process files SEQUENTIALLY, one at a time, with verification between each.
|
||||
7. **Acceptance criteria for semantic work:** "0 parse warnings after `axiom_semantic_index rebuild`; all `#region`/`#endregion` pairs intact per `read_outline`"
|
||||
|
||||
## VII. CLOSURE ROUTING
|
||||
After receiving worker outputs, route to:
|
||||
1. `qa-tester` — if contracts need verification
|
||||
|
||||
Reference in New Issue
Block a user