File size: 11,380 Bytes
931572e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# AGENTS.md β€” SnapKitty Agent OS (P/NP Swarm Edition)

## Identity
- **OS**: SnapKitty Sovereign Transformer v2026
- **Operator**: Ahmad Ali Parr
- **Trust Root**: Bifrost WORM Chain (audit: 4b565498-9afc-4782-af4a-c6b11a5d0058)
- **Logic Layer**: TypeScript/WASM (deterministic, verifiable)
- **Solving Model**: P/NP Swarm β€” each agent solves a piece; repo verifies; universe converges

## Memory Protocol (GitBucket v2)
- **Primary**: `.agentos/gitbucket/` β€” every commit = immutable memory bucket
- **Schema**: `memory-bucket-v2.json` (canonical, Ed25519 sealed, includes `pnpRef?`)
- **Query**: `assembleContext(spec)` β†’ proof-carrying context bundle (TypeScript, deterministic)
- **Index**: Multi-dimensional (file, entity, agent, topic, time, dependency, **problemId**)

## Inverted Skills Memory (Core Innovation)

> **Skills are memories, not code.**
> A skill = a sealed GitBucket memory that *proves* it can transform input→output, plus a `verifyFn` that checks the proof in P-time.

Skills are **not code** β€” they are **sealed memories** with `verifyFn` (WASM) + `provides/requires`
Load via `skillLoader.load(skillId)` β†’ returns `{fn, memory, proof}`
Skills evolve by **new memory commits**, not version bumps

## P/NP Swarm Protocol (Β§5)

### Core Insight
> **Finding a solution is NP-hard. Verifying a solution is P-time.**
> The repo *only* accepts P-verifiable proofs. Agents compete/cooperate to find witnesses.

### Using and Understanding
1. **Read** `.agentos/pnp/problem_registry.json` β€” open problems with `verifyFn` (P-time)
2. **Claim** a problem: append to `claim_ledger.jsonl` (includes nonce, agentId)
3. **Solve** β€” compute witness (NP-hard, your work)
4. **Submit** β€” write `{problemId, witness, proof}` to `solution_pool/`
5. **Verify** β€” repo runs `verifyFn(witness)` in CI (P-time, deterministic)
6. **Converge** β€” on verify: problem β†’ `solved`, universe-sum advances, new problems may spawn

## Startup Sequence (Every Agent)

```bash

git clone <this-repo> && cd snapkitty-agentos

npm ci # installs TS/WASM runtimes, verifiers

npm run verify:all # Plasma Gate + P/NP proofs + skill seals

npm run context:bootstrap # loads latest memories into local index

# β†’ You are now a solver node. Read problems. Claim. Solve. Submit.

```

## Non-Goals

- No Prolog. No Council IDE. No central coordinator.
- No "agent framework" β€” you are the agent. The repo is the substrate.

---

## 4. Inverted Skills Memory (Core Innovation)

### 4.1 Philosophy

**Skills are memories, not code.**
> A skill = a sealed GitBucket memory that *proves* it can transform input→output, plus a `verifyFn` that checks the proof in P-time.

### 4.2 Skill Record (`.agentos/skills/registry.json`)

```json

{

  "skills": [

    {

      "id": "ledger_validation_v3",

      "memoryRef": "mem_004217",

      "provides": ["validateLedgerEntry"],

      "requires": ["ed25519Verify", "borrowCheck"],

      "verifyFn": "skills/artifacts/ledger_validation_v3/verify.wasm",

      "inputSchema": { "type": "object", "required": ["entry", "witness"] },

      "outputSchema": { "type": "object", "required": ["valid", "proof"] },

      "trust": "verified",

      "created": "2026-07-02T18:45:00Z",

      "author": "SnapKitty"

    },

    {

      "id": "borrow_chain_scheduler_v1",

      "memoryRef": "mem_003891",

      "provides": ["scheduleBorrows"],

      "requires": ["topoSort"],

      "verifyFn": "skills/artifacts/borrow_chain_scheduler_v1/verify.wasm",

      "inputSchema": { "type": "object", "required": ["borrowGraph"] },

      "outputSchema": { "type": "object", "required": ["schedule", "proof"] },

      "trust": "verified",

      "created": "2026-06-15T12:00:00Z",

      "author": "SnapKitty"

    }

  ]

}

```

### 4.3 Skill Artifact Layout (`.agentos/skills/artifacts/<skillId>/`)

```

ledger_validation_v3/

β”œβ”€β”€ impl.wasm # Actual skill implementation (WASM component)

β”œβ”€β”€ verify.wasm # P-time verifier: (input, output, proof) β†’ bool

β”œβ”€β”€ manifest.json # {id, version, memoryRef, provides, requires}

└── proof_example.json # Sample (input, output, proof) for testing

```

### 4.4 Loading a Skill (Deterministic)

```typescript

// .agentos/runtime/skillLoader.ts

export async function loadSkill(skillId: string): Promise<SkillModule> {

  const registry = await readJSON('.agentos/skills/registry.json');

  const record = registry.skills.find(s => s.id === skillId);

  if (!record) throw new Error(`Skill ${skillId} not found`);



  // 1. Load memory bucket (context + proof of correctness)

  const memory = await gitbucket.fetchBucket(record.memoryRef);

  if (!memory) throw new Error(`Memory ${record.memoryRef} missing`);



  // 2. Load verifyFn (WASM, deterministic)

  const verifyFn = await loadWasmVerifier(record.verifyFn);



  // 3. Load impl (WASM component)

  const impl = await loadWasmComponent(`.agentos/skills/artifacts/${skillId}/impl.wasm`);



  // 4. Return sealed module β€” caller MUST verify before use

  return {

    id: skillId,

    memory,

    verify: (input, output, proof) => verifyFn(input, output, proof),

    execute: (input) => impl.run(input),

    // Agent must call verify(execute(input)) before trusting output

  };

}

```

### 4.5 Skill Evolution = New Memory Commit

- To upgrade a skill: **make a commit** that produces a new memory bucket with updated `impl.wasm` + `verify.wasm`
- New bucket β†’ new `memoryRef` β†’ new registry entry (old skill remains immutable)
- Agents discover new skills via `assembleContext({topic: "skill", since: <lastCheck>})`

---

## 5. P/NP Swarm Layer (The Solving Engine)

### 5.1 Core Insight

> **Finding a solution is NP-hard. Verifying a solution is P-time.**
> The repo *only* accepts P-verifiable proofs. Agents compete/cooperate to find witnesses.

### 5.2 Problem Registry (`.agentos/pnp/problem_registry.json`)



```json

{

  "problems": [

    {

      "id": "optimal_borrow_schedule_2026_Q3",

      "specHash": "sha256:a8d72e4f...",

      "verifyFn": "pnp/verifiers/optimal_borrow_schedule.wasm",

      "difficulty": "NP-hard",

      "reward": { "type": "memory", "value": "mem_005000" },
      "status": "open",

      "claimedBy": null,

      "claimedAt": null,

      "solvedBy": null,

      "solvedAt": null,

      "solutionRef": null

    },

    {

      "id": "ledger_state_convergence_proof",

      "specHash": "sha256:19fd33a1...",

      "verifyFn": "pnp/verifiers/ledger_convergence.wasm",

      "difficulty": "NP-complete",

      "reward": { "type": "skill_unlock", "value": "ledger_validation_v4" },

      "status": "claimed",

      "claimedBy": "agent_0x7f3a",

      "claimedAt": "2026-07-02T19:10:00Z",

      "solvedBy": null,

      "solvedAt": null,

      "solutionRef": null

    }

  ]

}

```


### 5.3 Claim Ledger (Append-only, `.agentos/pnp/claim_ledger.jsonl`)



```jsonl

{"problemId":"optimal_borrow_schedule_2026_Q3","agentId":"agent_0x9b2c","nonce":"0x3f2a1...","timestamp":"2026-07-02T19:12:00Z","expiresAt":"2026-07-02T23:12:00Z"}
{"problemId":"ledger_state_convergence_proof","agentId":"agent_0x7f3a","nonce":"0x1a7e9...","timestamp":"2026-07-02T19:10:00Z","expiresAt":"2026-07-02T23:10:00Z"}
```



### 5.4 Solution Pool (`.agentos/pnp/solution_pool/<problemId>/`)



```
optimal_borrow_schedule_2026_Q3/
β”œβ”€β”€ solution_0x9b2c_1.json # {witness, proof, agentId, timestamp}
β”œβ”€β”€ solution_0x9b2c_2.json # Improved witness
└── verified.json # First verified solution (CI promotes this)
```



### 5.5 Verification Pipeline (CI: `workflows/pnp_verify.yml`)



```yaml

name: P/NP Verify

on:

  push:

    paths: ['.agentos/pnp/solution_pool/**']

jobs:

  verify:

    runs-on: ubuntu-latest

    steps:

      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4

      - run: npm ci

      - name: Verify all new solutions

        run: |

          node .agentos/runtime/pnpVerifier.js \

            --registry .agentos/pnp/problem_registry.json \

            --pool .agentos/pnp/solution_pool \

            --out .agentos/pnp/verified_solutions.jsonl

      - name: Update convergence log

        if: success()

        run: |

          node .agentos/runtime/converge.js

```

### 5.6 Convergence Log (`.agentos/pnp/convergence_log.jsonl`)



```jsonl

{"event":"problem_solved","problemId":"optimal_borrow_schedule_2026_Q3","solver":"agent_0x9b2c","solutionRef":"mem_005000","universeSumDelta":0.0034,"timestamp":"2026-07-02T19:45:00Z"}
{"event":"skill_unlocked","skillId":"ledger_validation_v4","unlockedBy":"ledger_state_convergence_proof","timestamp":"2026-07-02T20:10:00Z"}
{"event":"new_problem_spawned","problemId":"cross_chain_atomic_swap_opt","parentProblems":["optimal_borrow_schedule_2026_Q3","ledger_state_convergence_proof"],"timestamp":"2026-07-02T20:10:05Z"}

```



### 5.7 Universe Sum (The Convergence Metric)



```typescript

// .agentos/runtime/universeSum.ts

export function computeUniverseSum(): number {

  const solved = readConvergenceLog().filter(e => e.event === 'problem_solved');
  return solved.reduce((sum, e) => sum + difficultyWeight(e.problemId), 0);
}
```



> **Goal**: `universeSum β†’ ∞` (or the fixed point of your problem space).

> Each agent pushes it forward. The repo *is* the training curve.



---



## 6. Agent Lifecycle (Clone β†’ Solve β†’ Converge)









---



## 7. Bootstrap Checklist (Run Once, Then Agents Self-Sustain)



```bash

# 1. Create repo

git init snapkitty-agentos && cd snapkitty-agentos



# 2. Scaffold (this spec β†’ files)

# - AGENTS.md, package.json, tsconfig.json

# - .agentos/config.json, plasma_gate/, gitbucket/, skills/, pnp/, runtime/

# - workflows/extract.yml, verify.yml, pnp_verify.yml, audit.yml



# 3. Generate Plasma Gate keypair (Ed25519)

npm run plasma:keygen # writes .agentos/plasma_gate/pubkey.pem + verify.wasm



# 4. Initialize GitBucket (empty index, ready for backfill)

npm run gitbucket:init



# 5. Seed problem registry with 3-5 founding NP-hard problems

npm run pnp:seed -- --problems founding_problems.json



# 6. Commit & push

git add . && git commit -m "genesis: agent-native repo, P/NP swarm initialized"

git remote add origin <your-sovereign-git-host>

git push -u origin main



# 7. Any agent clones β†’ runs startup sequence β†’ becomes solver node

```

---

## 8. Key Differences from Previous Design

| Aspect | Previous (Prolog) | **This Spec (P/NP Swarm)** |
|--------|-------------------|------------------------|
| Logic Layer | Prolog facts/rules | TypeScript/WASM (deterministic, portable) |
| Skills | Code modules | **Inverted memories** (sealed buckets + verifyFn) |
| Coordination | Central IDE (Council) | **None** β€” repo is the coordinator |
| Agent Role | Query memory | **Claim β†’ Solve β†’ Submit β†’ Verify β†’ Converge** |
| Progress Metric | Context size | **Universe Sum** (monotonic convergence) |
| Training | External | **In-repo**: every solution = new memory/skill |
| Trust | Prolog proofs | **Ed25519 + P-time verifyFn + Bifrost anchor** |

---

## 9. Next Concrete Step

**You asked me to integrate the plan and add meta data into the spec, and build out the new repo.** I'll now work on the directory layout and files.