fix
This commit is contained in:
@@ -9,6 +9,8 @@ description: Reference manual for GRACE-Poly v2.6 — syntax formats, complexity
|
||||
@RELATION DISPATCHES -> [Std.Semantics.Python]
|
||||
@RELATION DISPATCHES -> [Std.Semantics.Svelte]
|
||||
@RELATION DISPATCHES -> [Std.Semantics.Testing]
|
||||
@RATIONALE GRACE-Poly exists because autoregressive Transformers suffer from four architectural defects that make them unreliable at scale: (1) KV-cache eviction — after ~8K tokens early context is lost, so decisions from file #1 are forgotten by file #4; (2) attention sink — in files >400 LOC attention weights diffuse, making nested structures invisible; (3) hallucination by design — when a dependency is missing the model confabulates a plausible one instead of signaling uncertainty; (4) copy-paste regression — similar code is duplicated including rejected patterns. The protocol's anchors, relations, and decision-memory tags form an external cognitive exoskeleton that survives context compression and provides structured navigation where raw prose fails.
|
||||
@REJECTED Trusting natural language comments for navigation was rejected — they lack syntactic density and are the first to be evicted under CSA compression. Docstring-only contracts were rejected — they are invisible to the semantic index and cannot be verified structurally. Ad-hoc conventions per agent were rejected — 44% orphan rate in this project proves that without a dedicated curator, the semantic graph degenerates within 3-4 sessions.
|
||||
|
||||
## 0. SSOT DECLARATION
|
||||
|
||||
@@ -152,4 +154,84 @@ All agents use Axiom MCP for GRACE-semantic operations. This is the canonical to
|
||||
- `skill({name="semantics-svelte"})` — Svelte 5 (Runes), UX state machines, Tailwind
|
||||
- `skill({name="semantics-testing"})` — pytest/vitest test constraints, external ontology
|
||||
|
||||
## VIII. ATTENTION ARCHITECTURE & OPTIMIZATION RULES
|
||||
|
||||
The GRACE anchor format is not arbitrary — it is optimized for the specific attention compression mechanisms in the underlying model (MLA → CSA → HCA → DSA → sliding window). Understanding these mechanisms is critical: a contract that violates these rules becomes invisible to the model after context compression, causing downstream hallucination.
|
||||
|
||||
### Attention Compression Pipeline
|
||||
|
||||
| Layer | Compression | Mechanism | What Survives | What Dies |
|
||||
|-------|:----------:|-----------|---------------|-----------|
|
||||
| **MLA** | 3.5× | KV vectors compressed to 576d latent codes. Information density per token is paramount. | Dense tokens (symbols, brackets, semantic tags). | Verbose prose, long descriptions. |
|
||||
| **CSA** | 4× + top‑k sparse | Every ~4 tokens pooled into 1 KV record. Only top‑k records selected per query. | Contracts in 1-2 anchor lines. | Contracts spread across 15+ lines — details lost in pooling. |
|
||||
| **HCA** | 128× | Aggressive pooling over distant context. Dense attention computed on compressed records. | Statistical signatures: hierarchical IDs (`Core.Auth.Login`), repeated `@SEMANTICS` keywords. | Flat IDs (`LoginFunction`) — become noise. One-off tag values. |
|
||||
| **DSA** | Lightning Indexer | Fast linear scorer estimates relevance of each compressed record to query keywords. | Records whose `@SEMANTICS` match query keywords. | Records with different naming than the query. |
|
||||
| **Sliding window** | None (preserved) | Small window of recent uncompressed tokens for local detail. | Contracts ≤150 lines fit entirely in the window. | Contracts >150 lines partially invisible. |
|
||||
|
||||
### ATTN_1 — FIRST-LINE DENSITY (CSA + MLA)
|
||||
|
||||
The opening anchor MUST pack maximum signal into one line:
|
||||
|
||||
```
|
||||
#region Domain.Sub.ContractId [C:N] [TYPE TypeName] [SEMANTICS tag1,tag2,tag3]
|
||||
```
|
||||
|
||||
- ID, complexity, type, and semantic tags on ONE line → survives CSA 4× pooling as a single KV record.
|
||||
- `@BRIEF` on line 2 is secondary — it may be pooled separately.
|
||||
- **NEVER** spread the anchor signature across multiple lines in a CSA-sensitive context.
|
||||
|
||||
### ATTN_2 — HIERARCHICAL IDS (HCA 128×)
|
||||
|
||||
Contract IDs MUST use dot-separated domain prefixes with 2-3 levels of hierarchy:
|
||||
|
||||
- `Core.Auth.Login` → after HCA 128×, `Core.Auth` survives as a statistical signature.
|
||||
- `Core.Auth.Session` → same domain group; `Auth` signature reinforced.
|
||||
- `users_login` → **dies** at 128×, indistinguishable from noise.
|
||||
|
||||
**Rule:** Every non-C1 contract ID carries at least 2 levels: `Domain.Name`. C1 contracts (DTOs, constants) inside a hierarchical parent module may use single-level IDs — the parent provides the domain context.
|
||||
|
||||
**Good:** `Core.Auth.Login`, `Migration.RunTask`, `Users.ListModel`, `Tasks.TaskCard`, `Test.Migration.RunTask`
|
||||
**Bad:** `login_handler`, `migrate`, `format_timestamp`, `UserListModel` (missing domain prefix)
|
||||
|
||||
**Stack disambiguation:** Use domain prefix, not stack prefix. The file path already encodes the stack (`backend/src/` vs `frontend/src/`):
|
||||
- Backend: `Core.Auth.Login`, `Api.Dashboards.List`, `Plugin.Translate.Execute`
|
||||
- Frontend: `Users.ListModel`, `Tasks.TaskCard`, `Dashboards.Hub`
|
||||
- Tests: `Test.Core.Auth`, `Test.Users.ListModel`
|
||||
|
||||
### ATTN_3 — SEMANTIC GROUPING (DSA Lightning Indexer)
|
||||
|
||||
The DSA Indexer scores compressed records by keyword match against the query. `@SEMANTICS` keywords are your index keys:
|
||||
|
||||
- All contracts in the `auth` domain MUST share `[SEMANTICS auth, ...]`.
|
||||
- `grep "@SEMANTICS.*auth"` → Indexer scores all auth records high.
|
||||
- If one auth contract uses `@SEMANTICS login` and another `@SEMANTICS authentication`, the Indexer may fail to group them.
|
||||
|
||||
**Rule:** Identical domain = identical primary keyword in `@SEMANTICS`. Secondary keywords can vary.
|
||||
|
||||
### ATTN_4 — FRACTAL BOUNDARIES (Sliding Window)
|
||||
|
||||
The sliding window preserves recent tokens without compression. A contract ≤150 lines fits entirely in the window and is fully visible to the attention mechanism:
|
||||
|
||||
- Contract ≤150 lines → guaranteed full visibility.
|
||||
- Module ≤400 lines → manageable in a few attention passes.
|
||||
- INV_7 (Module < 400 lines, CC ≤ 10) is not just a style rule — it ensures the model can physically see the entire contract structure.
|
||||
|
||||
### Grep Heuristics (Zombie Mode — when MCP tools are unavailable)
|
||||
|
||||
When Axiom MCP is down, these grep patterns exploit the DSA Indexer's keyword sensitivity:
|
||||
|
||||
```bash
|
||||
# Find all contracts in a domain (Indexer matches @SEMANTICS keywords)
|
||||
grep -r "@SEMANTICS.*<domain>" src/
|
||||
|
||||
# Find API type binding (cross-stack traceability)
|
||||
grep -r "@DATA_CONTRACT.*<ModelName>" src/
|
||||
|
||||
# Extract full contract body (awk, respecting fractal boundaries)
|
||||
awk '/#region <ContractID>/,/#endregion <ContractID>/' file.py
|
||||
|
||||
# Find all contracts BIND_TO a store
|
||||
grep -r "BINDS_TO.*\[<StoreId>\]" src/
|
||||
```
|
||||
|
||||
#endregion Std.Semantics.Core
|
||||
|
||||
Reference in New Issue
Block a user