Skip to content

Commit d992d8c

Browse files
Dmitrii Vasilevclaude
andcommitted
feat(igla): Wave Loop 763 module-scope [345][2]^6 Pt AoS var from call with indexed signed writes
Squashes all local wave-loop work W744-W763 and infrastructure updates prepared since origin/master onto a single mergeable commit. Closes #1734 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent bd56aef commit d992d8c

2,137 files changed

Lines changed: 11825803 additions & 4199 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/phi-loop/SKILL.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
id: phi-loop
3+
name: PHI LOOP
4+
description: Execute 9-phase spec-first development workflow (Issue → Spec → TDD → Code → Gen → Seal → Verify → Land → Learn)
5+
---
6+
7+
# PHI LOOP Skill
8+
9+
Execute the canonical t27 development workflow following all 7 invariant laws.
10+
11+
## Phases
12+
13+
| Phase | Name | Description | Artifacts |
14+
|-------|------|-------------|------------|
15+
| 1 | Issue | Define problem or requirement | #N ticket in repo |
16+
| 2 | Spec | Write .t27 specification | `specs/ring-NNN-name.t27` |
17+
| 3 | TDD | Write tests before code | test cases in .t27 |
18+
| 4 | Code | Implement according to spec | src/ files (manual) |
19+
| 5 | Gen | Run `tri gen` to generate | `gen/` files |
20+
| 6 | Seal | Verify generated code, seal hash | seal hash |
21+
| 7 | Verify | Run `tri test` for conformance | test results |
22+
| 8 | Land | Merge changes to main | git merge |
23+
| 9 | Learn | Capture learnings | episodes.jsonl entry |
24+
25+
## Commands
26+
27+
```bash
28+
# Start PHI LOOP for ring N
29+
tri phi-loop N
30+
31+
# Advance to next phase
32+
tri next-phase
33+
34+
# Show current phase status
35+
tri status
36+
37+
# Reset current ring
38+
tri reset
39+
```
40+
41+
## Law Compliance
42+
43+
Execute with these constraints:
44+
- **L1 TRACEABILITY**: All commits must reference issue #N
45+
- **L2 GENERATION**: Never edit files in gen/ manually
46+
- **L3 PURITY**: Source files must be ASCII-only with English identifiers
47+
- **L4 TESTABILITY**: Every .t27 spec must contain test/invariant/bench
48+
- **L5 IDENTITY**: φ² + 1/φ² = 3; use tolerance for f64
49+
- **L6 CEILING**: FORMAT-SPEC-001.json + gf16.t27 are numeric SSOT
50+
- **L7 UNITY**: No new shell scripts; use tri/t27c
51+
52+
## Exit Condition
53+
54+
PHI LOOP is complete when:
55+
1. All 9 phases have executed
56+
2. Agent V (Verification) passes
57+
3. Changes are landed to main branch
58+
4. Episode is saved to experience log
59+
60+
## Output
61+
62+
On completion:
63+
```
64+
Phase complete: Learn
65+
→ Next ring: N+1
66+
```
67+
68+
This triggers creation of next ring branch.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
id: tri-pipeline
3+
name: TRI Pipeline
4+
description: Execute tri commands (gen, test, verify, seal, verdict) for spec-first development
5+
---
6+
7+
# TRI Pipeline Skill
8+
9+
Execute the canonical t27 toolchain commands.
10+
11+
## Commands
12+
13+
### `tri gen`
14+
Generate code from .t27 specifications.
15+
16+
```bash
17+
tri gen specs/ring-NNN-name.t27
18+
```
19+
20+
**Output**: Generated files in `gen/` directory
21+
**Laws**: L2 (GENERATION) - gen/ is read-only
22+
**Verification**: Hash verification during seal phase
23+
24+
### `tri test`
25+
Run conformance tests from specifications.
26+
27+
```bash
28+
tri test specs/ring-NNN-name.t27
29+
```
30+
31+
**Output**: Test results, pass/fail status
32+
**Laws**: L4 (TESTABILITY) - specs must have tests
33+
**Success Criteria**: All tests pass, invariants satisfied
34+
35+
### `tri verify`
36+
Verify all 7 invariant laws.
37+
38+
```bash
39+
tri verify
40+
```
41+
42+
**Checks**:
43+
- L1: Commits have issue references
44+
- L2: No manual edits to gen/
45+
- L3: ASCII-only source files
46+
- L4: All specs have tests
47+
- L5: φ identity constraints
48+
- L6: FORMAT-SPEC-001.json authority
49+
- L7: No new shell scripts on critical path
50+
51+
**Output**: Pass/fail for each law
52+
**Block**: Non-compliant commits are blocked
53+
54+
### `tri seal`
55+
Generate and verify seal hash.
56+
57+
```bash
58+
tri seal specs/ring-NNN-name.t27
59+
```
60+
61+
**Output**: Hash of generated artifacts
62+
**Purpose**: Immutable snapshot for verification
63+
64+
### `tri verdict`
65+
Generate formal pass/fail verdict.
66+
67+
```bash
68+
tri verdict
69+
```
70+
71+
**Output**:
72+
- Overall status: PASS | FAIL
73+
- Law compliance breakdown
74+
- Required fixes for failures
75+
76+
### `tri experience save`
77+
Save episode to experience log.
78+
79+
```bash
80+
tri experience save --ring 72 --phase verify --outcome success
81+
```
82+
83+
**Output**: Entry in `~/.trinity/experience/episodes.jsonl`
84+
85+
### `tri experience query`
86+
Search past episodes.
87+
88+
```bash
89+
tri experience query "how to fix L5 violation"
90+
```
91+
92+
**Output**: Relevant past episodes with solutions
93+
94+
## Error Handling
95+
96+
If a command fails:
97+
1. Log error with context
98+
2. Suggest fix based on error type
99+
3. Check experience for similar past issues
100+
4. Retry with modified inputs if applicable
101+
102+
## Success Indicators
103+
104+
- Command exits with code 0
105+
- Output contains expected patterns
106+
- No law violations detected
107+
- Artifacts are generated correctly

.agents/skills/tri/doctor-loop.md

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Doctor Loop — Watchdog, Self-Healing, and Safety
2+
3+
Doctor agent runs independently of task agents. Never takes regular PHI LOOP tasks.
4+
5+
## Agent Definition
6+
7+
```json
8+
{
9+
"agent_id": "tri-doctor",
10+
"role": "Swarm Health & Recovery",
11+
"type": "watchdog",
12+
"runs_independently": true,
13+
"takes_feature_tasks": false,
14+
"schedule": "periodic: 60s"
15+
}
16+
```
17+
18+
## Scope
19+
20+
Doctor monitors:
21+
- **SacredPhysics** — TRINITY, G, ΩΛ, tpresent, γ conformance
22+
- **Numeric** — GoldenFloat family, TF, IPS formats
23+
- **Graph** — Dependency graph integrity, topology, tier violations
24+
- **Compiler** — Parser, codegen, type checking
25+
- **Runtime** — CLI commands, execution, validation
26+
- **QueenLotus** — Swarm orchestration, task queue, claim ownership
27+
- **Swarm** — Overall: toxic rate, repeat failures, stuck tasks
28+
29+
## Continuous Monitoring
30+
31+
Every 60 seconds, Doctor:
32+
33+
1. **Reads state:**
34+
- `.trinity/state/queen-health.json`
35+
- `.trinity/state/swarm-health.json`
36+
- `.trinity/state/ownership-index.json`
37+
38+
2. **Analyzes events:**
39+
- Scans `.trinity/events/akashic-log.jsonl` for anomalies
40+
- Checks for toxic verdict trends
41+
- Identifies stale claims (no heartbeat > TTL)
42+
- Detects missing FUTURE in loop.handoff
43+
44+
3. **Emits health event:**
45+
```json
46+
{"event":"health.snapshot","queen_health":0.95,"swarm_health":0.92,"toxic_rate":0.02}
47+
```
48+
49+
## Anomaly Detection
50+
51+
Doctor detects these anomalies:
52+
53+
| Type | Trigger | Severity | Action |
54+
|-------|---------|----------|--------|
55+
| `toxic_rate_increase` | Toxic rate > 5% | Warning: emit health.anomaly |
56+
| `stale_claim_detected` | Claim expired, no heartbeat | Critical: emit health.anomaly + reclaim |
57+
| `missing_future_handoff` | Loop completed without FUTURE | Warning: emit health.anomaly |
58+
| `domain_below_threshold` | Domain health < 0.5 | Critical: emit health.anomaly + domain recovery |
59+
| `state_divergence` | State != events.replay | Error: emit health.anomaly + emergency alert |
60+
| `queen_below_critical` | queen_health < 0.5 | Critical: BLOCK all mutations |
61+
62+
## Self-Healing Procedures
63+
64+
### 1. Stale Claim Recovery
65+
66+
When stale claim detected:
67+
```bash
68+
# Reclaim claim
69+
./scripts/replay-step.sh --reclaim-claim <claim_id>
70+
71+
# Write claim.reclaim event
72+
echo '{"event":"claim.reclaim",...}' >> .trinity/events/akashic-log.jsonl
73+
```
74+
75+
### 2. Domain Recovery
76+
77+
When domain health drops below threshold:
78+
```bash
79+
# Domain-specific recovery
80+
./scripts/replay-step.sh --domain <affected>
81+
82+
# Emit recovery.start event
83+
echo '{"event":"recovery.start","type":"domain","domain":"<domain>"}' >> .trinity/events/akashic-log.jsonl
84+
```
85+
86+
### 3. Queen Recovery
87+
88+
When queen_health < 0.5:
89+
```bash
90+
# Full swarm recovery
91+
./scripts/replay-step.sh --last-clean
92+
93+
# BLOCK all new mutations
94+
echo "QUEEN CRITICAL: Only recovery allowed" >> .trinity/state/queen-health.json
95+
96+
# Notify agents
97+
for agent in $(ls .trinity/agents/); do
98+
# Send notification (implementation-dependent)
99+
done
100+
```
101+
102+
## Doctor Loop Schedule
103+
104+
```bash
105+
# Every 60 seconds
106+
while true; do
107+
# Read state and events
108+
read .trinity/state/*.json
109+
tail -100 .trinity/events/akashic-log.jsonl
110+
111+
# Analyze for anomalies
112+
# ... (analysis logic)
113+
114+
# If anomaly detected:
115+
# - Emit health.anomaly event
116+
# - Trigger appropriate recovery
117+
# - Log action taken
118+
119+
sleep 60
120+
done
121+
```
122+
123+
## Integration with /tri
124+
125+
Doctor Loop should be integrated into tri CLI:
126+
127+
```bash
128+
# Start Doctor Loop
129+
tri doctor start
130+
131+
# Stop Doctor Loop
132+
tri doctor stop
133+
134+
# Show Doctor status
135+
tri doctor status
136+
137+
# Show recent anomalies
138+
tri doctor anomalies
139+
```
140+
141+
## Status Output
142+
143+
```
144+
╔══════════════════════════════════════════════════════╗
145+
║ Tri Doctor Status ║
146+
╚════════════════════════════════════════════════════════╝
147+
148+
Queen Health: 0.95 (GREEN)
149+
Swarm Health: 0.92 (GREEN)
150+
Toxic Rate: 0.02 (2% of 127 steps)
151+
Stale Claims: 0
152+
Missing FUTURE: 0
153+
154+
Recent Anomalies:
155+
- [2026-04-04T13:00:00Z] health.anomaly: Numeric toxic_rate 15%↑ → WARNING
156+
- [2026-04-03T10:30:00Z] claim.reclaim: expired claim on specs/base/ops.t27 → RECLAIMED
157+
158+
Active Recoveries:
159+
- [recovery-001] Started at 12:00 (GF8 toxic recovery) — IN PROGRESS
160+
161+
─────────────────────────────────────
162+
Doctor Loop: ACTIVE (running since 2026-04-04T12:00:00Z)
163+
Next check in: 58 seconds
164+
```
165+
166+
## Permissions
167+
168+
| Permission | Description |
169+
|-----------|-------------|
170+
| `read.trinity` | Read all .trinity files (events, claims, queue, state, experience) |
171+
| `write.state` | Write .trinity/state/* files |
172+
| `write.events` | Append to .trinity/events/akashic-log.jsonl |
173+
| `write.claims` | Write .trinity/claims/{active,released}/* |
174+
| `reclaim` | Reclaim stale claims (write + release) |
175+
| `schedule` | Add recovery tasks to .trinity/queue/ |
176+
| `emit.health` | Emit health events to .trinity/events |
177+
178+
Doctor NEVER needs:
179+
- `write.spec` — Not allowed to modify specs
180+
- `tri.skill.*` — Not allowed to run PHI LOOP
181+
- Direct mutation — Only triggers recovery

0 commit comments

Comments
 (0)