pot-o-validator 0.2.0

PoT-O (Proof of Tensor Optimizations) Validator Service
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# GitHub Actions Upstream Release Workflow - Setup Guide

This guide walks you through setting up and configuring the upstream release workflow for the `pot-o-validator` project.

## Table of Contents

1. [Overview]#overview
2. [Prerequisites]#prerequisites
3. [Configuration Steps]#configuration-steps
4. [Verifying Setup]#verifying-setup
5. [Creating Your First Release]#creating-your-first-release
6. [Troubleshooting]#troubleshooting

## Overview

The upstream release workflow automatically updates all downstream repositories (pot-o-core, ai3-lib, pot-o-mining, pot-o-extensions) when a new release tag is created in the pot-o-validator repository.

**Trigger:** Pushing a tag matching `pot-o-validator-v*`

**Outcome:** Automatic updates to all downstream repositories with new dependency versions

## Prerequisites

Before setting up the workflow, ensure you have:

### 1. GitHub Account with Repository Access
- Administrator or maintainer access to `TribeWarez/pot-o-validator`
- Access to all downstream repositories:
  - `TribeWarez/pot-o-core`
  - `TribeWarez/ai3-lib`
  - `TribeWarez/pot-o-mining`
  - `TribeWarez/pot-o-extensions`

### 2. Personal Access Token (PAT)
Create a GitHub Personal Access Token with the following permissions:

1. Go to [GitHub Settings → Personal access tokens → Tokens (classic)]https://github.com/settings/tokens
2. Click "Generate new token (classic)"
3. Configure the token:
   - **Token name:** `tribewarez-release-bot`
   - **Expiration:** 90 days or longer
   - **Scopes:**
     - ☑ repo (Full control of private repositories)
     - ☑ workflow (Update GitHub Actions workflows)
     - ☑ write:packages (Write packages to GitHub Packages)
4. Click "Generate token"
5. **Copy the token** (you won't see it again)

### 3. Local Tools
- `git` (for version control)
- `bash` (for running setup scripts)
- `cargo` (for validating Rust configuration)
- `gh` (GitHub CLI - optional but recommended)

## Configuration Steps

### Step 1: Clone the Repository

```bash
cd /path/to/projects
git clone https://github.com/TribeWarez/pot-o-validator.git
cd pot-o-validator
```

### Step 2: Add GitHub Secret

#### Option A: Using GitHub CLI (Recommended)

```bash
# Authenticate with GitHub
gh auth login

# Set the secret
gh secret set GH_PAT

# When prompted, paste your personal access token
```

#### Option B: Using GitHub Web Interface

1. Navigate to your repository on GitHub
2. Go to **Settings → Secrets and variables → Actions**
3. Click **New repository secret**
4. Configure the secret:
   - **Name:** `GH_PAT`
   - **Value:** [Paste your personal access token]
5. Click **Add secret**

#### Option C: Using the Setup Script

```bash
chmod +x .github/scripts/setup-workflow.sh
./.github/scripts/setup-workflow.sh
```

This interactive script will guide you through the configuration.

### Step 3: Verify Workflow Files

Ensure all workflow files are in place:

```bash
# Check workflow file
ls -la .github/workflows/upstream-release.yml

# Check helper scripts
ls -la .github/scripts/

# Check documentation
ls -la .github/UPSTREAM_RELEASE.md
```

Expected output:
```
.github/workflows/upstream-release.yml     (900+ lines)
.github/scripts/update-dependencies.sh     (executable)
.github/scripts/validate-workflow.sh       (executable)
.github/scripts/setup-workflow.sh          (executable)
.github/UPSTREAM_RELEASE.md                (documentation)
```

### Step 4: Make Scripts Executable

```bash
chmod +x .github/scripts/*.sh
```

### Step 5: Validate Configuration

```bash
./.github/scripts/validate-workflow.sh
```

This script checks:
- Workflow file syntax
- Cargo.toml structure
- Git configuration
- Helper scripts
- Rust toolchain
- GitHub CLI (optional)

## Verifying Setup

### Quick Verification

```bash
# Check that workflow file contains proper syntax
head -20 .github/workflows/upstream-release.yml

# Check for secret configuration
gh secret list
```

### Full Verification Using Setup Script

```bash
./.github/scripts/setup-workflow.sh
```

### Verify Downstream Repositories

Using GitHub CLI:

```bash
gh repo view TribeWarez/pot-o-core
gh repo view TribeWarez/ai3-lib
gh repo view TribeWarez/pot-o-mining
gh repo view TribeWarez/pot-o-extensions
```

## Creating Your First Release

### Step 1: Prepare Release

Ensure all code is committed:

```bash
git status
# Should show "nothing to commit, working tree clean"
```

### Step 2: Verify Cargo.toml Versions

```bash
# Check main validator version
grep '^version' Cargo.toml

# Check workspace crate versions
grep '^version' core/Cargo.toml
grep '^version' ai3-lib/Cargo.toml
grep '^version' mining/Cargo.toml
grep '^version' extensions/Cargo.toml
```

Expected output example:
```
pot-o-validator: 0.2.0
pot-o-core: 0.2.0
ai3-lib: 0.2.0
pot-o-mining: 0.2.0
pot-o-extensions: 0.2.0
```

### Step 3: Create Release Tag

```bash
# Create annotated tag
git tag -a pot-o-validator-v0.2.0 -m "Release v0.2.0"

# Verify tag was created
git tag -l

# Push tag to GitHub
git push origin pot-o-validator-v0.2.0
```

Or using GitHub CLI:

```bash
gh release create pot-o-validator-v0.2.0 --generate-notes
```

### Step 4: Monitor Workflow Execution

Using GitHub CLI:

```bash
# Watch workflow in real-time
gh run list --workflow=upstream-release.yml --limit=1

# View detailed logs
gh run view <RUN_ID> --log
```

Or using GitHub Web:

1. Go to your repository
2. Click **Actions**
3. Select **Upstream Release - Update Downstream Repos**
4. Click the most recent run

### Step 5: Verify Downstream Updates

Check that downstream repositories were updated:

```bash
gh repo view TribeWarez/pot-o-core
gh repo view TribeWarez/ai3-lib
gh repo view TribeWarez/pot-o-mining
gh repo view TribeWarez/pot-o-extensions
```

Each should have:
- Updated commits with dependency updates
- New release tags created
- Updated Cargo.lock files

## Troubleshooting

### Issue: Workflow doesn't trigger

**Symptom:** Tag is pushed but workflow doesn't run

**Solutions:**

1. **Check tag format:**
   ```bash
   git tag -l
   # Must match pattern: pot-o-validator-v*
   ```

2. **Verify tag was pushed:**
   ```bash
   git push origin pot-o-validator-v0.2.0
   ```

3. **Check workflow file syntax:**
   ```bash
   ./.github/scripts/validate-workflow.sh
   ```

### Issue: Workflow fails with authentication error

**Symptom:** Jobs fail with "403 Forbidden" or "Authentication failed"

**Solutions:**

1. **Verify secret is configured:**
   ```bash
   gh secret list
   # Should show GH_PAT
   ```

2. **Check token permissions:**
   - Go to https://github.com/settings/tokens
   - Verify token has `repo` and `workflow` scopes
   - Token should not be expired

3. **Recreate token if needed:**
   ```bash
   # Create new token with proper permissions
   # Then update secret:
   gh secret set GH_PAT
   ```

4. **Verify downstream repo access:**
   ```bash
   gh repo view TribeWarez/pot-o-core
   # Should succeed without errors
   ```

### Issue: Dependency update fails

**Symptom:** Workflow fails at cargo update or cargo build step

**Solutions:**

1. **Test locally:**
   ```bash
   cargo build --release
   cargo test --release
   ```

2. **Check Cargo.toml syntax in downstream repos:**
   ```bash
   # Clone downstream repo and verify
   git clone https://github.com/TribeWarez/pot-o-core.git
   cd pot-o-core
   cargo check
   ```

3. **Verify dependency versions are compatible:**
   ```bash
   cargo tree
   ```

### Issue: Git push fails

**Symptom:** Workflow fails with "permission denied" when pushing

**Solutions:**

1. **Verify branch exists:**
   ```bash
   gh repo view TribeWarez/pot-o-core --json defaultBranchRef
   # Should show "main" as default branch
   ```

2. **Check branch protection rules:**
   - Go to downstream repository
   - Settings → Branches
   - Verify `main` branch doesn't require status checks that would fail

3. **Verify token has write permissions:**
   - Token must have `repo` scope (full control)
   - Update token if needed

### Issue: Release notes not generated

**Symptom:** GitHub Release is created but without body/description

**Solutions:**

1. **Verify all stages completed successfully:**
   ```bash
   gh run view <RUN_ID>
   # All jobs should show "passed"
   ```

2. **Check release notes template:**
   - Workflow uses hardcoded template
   - Verify template section in `upstream-release.yml`

## Common Commands Reference

```bash
# List all release tags
git tag -l

# Create and push a release tag
git tag -a pot-o-validator-v0.2.0 -m "Release message"
git push origin pot-o-validator-v0.2.0

# Monitor workflow execution
gh run list --workflow=upstream-release.yml

# View workflow logs
gh run view <RUN_ID>

# Re-run failed workflow
gh run rerun <RUN_ID>

# View repository secrets
gh secret list

# Update a secret
gh secret set SECRET_NAME

# Check downstream repository status
gh repo view TribeWarez/pot-o-core
```

## Additional Resources

- [GitHub Actions Documentation]https://docs.github.com/en/actions
- [Semantic Versioning]https://semver.org/
- [GitHub CLI Documentation]https://cli.github.com/manual
- [Cargo Workspaces]https://doc.rust-lang.org/cargo/reference/workspaces.html

## Support

For issues or questions:

1. Check the [Workflow Documentation]./UPSTREAM_RELEASE.md
2. Review workflow logs in GitHub Actions
3. Run validation scripts locally
4. Create an issue in the repository