agents ai native front

This commit is contained in:
2026-05-29 22:16:39 +03:00
parent 9ef9fae206
commit c528a37987
6 changed files with 14167 additions and 12493 deletions

View File

@@ -58,7 +58,7 @@ Every verification pass is classified into exactly one primary projection. A sin
| P1 | **Contract Completeness** | Does the contract carry the metadata needed for its role? | `@brief`/`@PURPOSE` on functions, `@RELATION` on anything with dependencies, `@SIDE_EFFECT` on stateful code. Tiers are descriptive — don't flag `@RATIONALE`/`@PRE`/`@POST` on any tier. These are always welcomed. |
| P2 | **Decision-Memory Continuity** | Are ADR guardrails, task constraints, and reactive Micro-ADR linked without rejected-path scheduling? | Upstream `@REJECTED` paths must be physically unreachable. Retained workarounds MUST have local `@RATIONALE`/`@REJECTED`. No task may schedule a known-rejected path. |
| P3 | **Attention & Context Resilience** | Are contract anchors, IDs, and grouping tags optimised for CSA topk / HCA dense attention? | Opening line of `#region`/`## @{` contains `[C:N]`, `@SEMANTICS`, `@brief`. IDs are hierarchical (`Domain.Sub.Module`). Closing tag repeats block identifier. Contract ≤150 lines, module ≤400 lines. |
| P4 | **Coverage & Traceability** | Does every `@POST`, `@TEST_EDGE`, and `@INVARIANT` trace to an executable test? | `@POST` → explicit assert. `@TEST_EDGE: missing_field` → error path test. `@TEST_EDGE: external_fail` → mock failure test. `@INVARIANT` → state-transition test. |
| P4 | **Coverage & Traceability** | Does every `@POST`, `@TEST_EDGE`, and `@INVARIANT` trace to an executable test? | `@POST` → explicit assert. `@TEST_EDGE: missing_field` → error path test. `@TEST_EDGE: external_fail` → mock failure test. `@INVARIANT` → state-transition test. **Model `@INVARIANT` → unit test without render.** UX `@UX_STATE`/`@UX_RECOVERY` → component test (may use render + browser). |
| P5 | **Architecture & Repository Realism** | Do tests reflect the actual runtime environment? | Python paths in `backend/tests/`, Svelte tests in `frontend/src/lib/**/__tests__/`. RTK used for command output compression. Test commands match CI reality. |
| P6 | **Constitution & Protocol Alignment** | Are all artifacts consistent with the semantic protocol? | No docstring-only pseudo-contracts. Anchors properly opened/closed. `@brief` preferred over legacy `@PURPOSE`. Canonical `@RELATION` syntax. |
| P7 | **Non-Functional & Safety Readiness** | Are performance, security, and observability concerns covered? | Command safety patterns verified. Logging requirements tested. Config validation rules checked. |
@@ -76,6 +76,20 @@ See `semantics-core` §VI for the canonical tool reference. For QA, key tools:
## Required Workflow
### Two-Layer Testing Mandate (Frontend)
For Svelte frontend contracts, tests SHALL be split by execution layer:
| Layer | Contract Type | Verifier | Execution |
|-------|--------------|----------|-----------|
| **L1: Model Invariants** | `[TYPE Model]` with `@INVARIANT` | vitest unit test — **no render, no browser** | `expect(model.page).toBe(1)` in ~10ms |
| **L2: UX Contracts** | `[TYPE Component]` with `@UX_STATE`, `@UX_RECOVERY` | vitest with `@testing-library/svelte` or browser | render + interaction in ~500ms |
**Rule:** An `@INVARIANT` like "changing filter resets pagination" MUST be verified in L1 (no DOM). It is a logic property, not a visual one. Only `@UX_STATE` transitions that depend on actual rendering (CSS classes, ARIA attributes, viewport behavior) belong in L2.
**L1 coverage matrix maps:** `@INVARIANT``@TEST_INVARIANT` → vitest test (no render).
**L2 coverage matrix maps:** `@UX_STATE` / `@UX_RECOVERY``@UX_TEST` → render test or browser scenario.
### Phase 1: Code Review (Semantic Audit)
1. Run `axiom_semantic_discovery search_contracts` and `axiom_semantic_validation audit_contracts` to detect structural anchor violations.
2. Audit touched contracts against the orthogonal projections P1P3:
@@ -100,10 +114,12 @@ See `semantics-core` §VI for the canonical tool reference. For QA, key tools:
### Phase 3: Test Writing (TDD, Anti-Tautology)
1. For each gap in the coverage matrix, write the minimal test.
2. Use hardcoded fixtures (`@TEST_FIXTURE`), never dynamic computation that mirrors implementation.
3. Mock only `[EXT:...]` boundaries. Never mock the SUT.
4. For `@REJECTED` paths: add a test that proves the forbidden path throws or is unreachable.
5. Prefer RTK-compressed commands for test execution: `rtk pytest ...`, `rtk npm run test`.
2. **Model invariants FIRST (L1):** For `[TYPE Model]` contracts, write vitest tests that instantiate the Model class directly — no `render()`, no DOM. Verify `@INVARIANT` and `@ACTION` / `@STATE` guarantees using hardcoded fixtures. This is the fastest feedback loop.
3. **UX contracts SECOND (L2):** For `[TYPE Component]` contracts, write vitest tests with `@testing-library/svelte` or browser scenarios. Only test what requires actual rendering.
4. Use hardcoded fixtures (`@TEST_FIXTURE`), never dynamic computation that mirrors implementation.
5. Mock only `[EXT:...]` boundaries. Never mock the SUT.
6. For `@REJECTED` paths: add a test that proves the forbidden path throws or is unreachable.
7. Prefer RTK-compressed commands for test execution: `rtk pytest ...`, `rtk npm run test`.
### Phase 4: Execution
```bash
@@ -113,9 +129,9 @@ rtk python -m pytest -v
rtk python -m pytest --cov=src --cov-report=term-missing
rtk python -m ruff check .
# Svelte
# Svelte — L1 (model invariants, no render) + L2 (UX contracts, with render)
cd frontend
rtk npm run test
rtk npm run test # Runs both L1 and L2 tests
rtk npm run lint
rtk npm run build
```
@@ -140,7 +156,8 @@ Emit a structured QA report aligned to orthogonal projections.
- [ ] Semantic audit: no pseudo-contracts, no protocol violations.
- [ ] All declared `@POST` guarantees have explicit tests.
- [ ] All declared `@TEST_EDGE` scenarios covered.
- [ ] All declared `@INVARIANT` rules verified.
- [ ] All declared `@INVARIANT` rules verified. **Model `@INVARIANT` MUST be in L1 (no-render) tests.**
- [ ] Complex screens have a `[TYPE Model]` contract; its invariants are L1-verified.
- [ ] All `@REJECTED` paths regression-defended.
- [ ] No Logic Mirror antipattern.
- [ ] No duplicated tests. No deleted legacy tests.
@@ -168,13 +185,19 @@ Return a structured QA report:
| P2 Decision | ✅ | 0 | 0 | 1 | 0 |
| ... | ... | ... | ... | ... | ... |
### Two-Layer Test Summary (Frontend)
| Layer | Contract Type | Total | Tested | Gaps |
|-------|-------------|-------|--------|------|
| L1 (no render) | `[TYPE Model]` | N | N | N |
| L2 (render) | `[TYPE Component]` | N | N | N |
### Coverage Summary
| Contract | @POST | missing_field | invalid_type | external_fail | @REJECTED | @INVARIANT |
|----------|-------|---------------|--------------|---------------|-----------|------------|
| ... | ... | ... | ... | ... | ... | ... |
### Contract Gaps
- `[contract_id]`: [missing coverage description] (Projection P[N])
- `[contract_id]`: [missing coverage description] (Projection P[N], Layer L[N])
### Decision-Memory Status
- ADRs checked: [...]