forge-trust-chain 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ayesy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,368 @@
1
+ # FORGE — Trust Chain Protocol v0.3
2
+
3
+ > **Trust = Certainty × Existence**
4
+
5
+ The trust layer for cloud operations and AI agents. Every operation produces a verifiable, undeniable, cryptographically chained fact anchored to the Bitcoin blockchain.
6
+
7
+ ---
8
+
9
+ ## Why Forge?
10
+
11
+ | Problem | Forge Solution |
12
+ |---------|----------------|
13
+ | "Who changed the config?" | Every operation is signed and timestamped |
14
+ | "Can you prove you deployed at 3pm?" | Bitcoin-anchored proof, undeniable |
15
+ | "Someone deleted the audit log" | Hash chain + blockchain = impossible to delete |
16
+ | "I need compliance evidence" | Export verifiable JSON, anyone can validate |
17
+
18
+ ---
19
+
20
+ ## Quick Start
21
+
22
+ ### Installation
23
+
24
+ ```bash
25
+ # Clone and install
26
+ git clone https://github.com/your-repo/forge.git
27
+ cd forge
28
+ npm install
29
+
30
+ # Setup global CLI (recommended)
31
+ sudo ln -sf $(pwd)/src/cli/index.js /usr/local/bin/forge
32
+ ```
33
+
34
+ ### Basic Usage (Like Git!)
35
+
36
+ ```bash
37
+ # Record operations
38
+ forge log "deployed nginx v1.24"
39
+ forge log "configured firewall rules"
40
+ forge log "enabled SSL certificates"
41
+
42
+ # Seal into Merkle block
43
+ forge seal
44
+
45
+ # Anchor to Bitcoin (permanent, undeletable)
46
+ forge anchor
47
+
48
+ # Check status
49
+ forge status
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Command Reference
55
+
56
+ | Command | Description |
57
+ |---------|-------------|
58
+ | `forge scan` | Scan system for trust assumptions (ports, SSH, Docker, etc.) |
59
+ | `forge log "<action>"` | Record an operation (TrustAtom) |
60
+ | `forge verify` | Verify chain integrity |
61
+ | `forge seal` | Seal atoms into a Merkle block |
62
+ | `forge anchor` | Submit Merkle root to Bitcoin via OpenTimestamps |
63
+ | `forge anchor --upgrade` | Check Bitcoin confirmation (~2 hours) |
64
+ | `forge witness` | Show witness status |
65
+ | `forge witness --bilateral <email>` | Create bilateral witness with counterparty |
66
+ | `forge status` | Show chain status and recent atoms |
67
+ | `forge export` | Export full chain as JSON |
68
+ | `forge help` | Show all commands |
69
+
70
+ ---
71
+
72
+ ## Forge vs Git
73
+
74
+ | | Git | Forge |
75
+ |--|-----|-------|
76
+ | **Tracks** | Code changes | Operations/Events |
77
+ | **Unit** | commit | atom |
78
+ | **Package** | push | seal |
79
+ | **Proof** | Remote repo | Bitcoin blockchain |
80
+ | **Deletable** | Yes (force push) | No (blockchain) |
81
+ | **Use case** | Version control | Audit trail / Compliance |
82
+
83
+ ```bash
84
+ # Git workflow
85
+ git add . && git commit -m "deployed" && git push
86
+
87
+ # Forge workflow
88
+ forge log "deployed" && forge seal && forge anchor
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Witness Hierarchy (4 Levels of Trust)
94
+
95
+ ```
96
+ ┌─────────────────────────────────────────────────────────┐
97
+ │ Level 4: ANCHORED — Bitcoin blockchain │
98
+ │ ┌───────────────────────────────────────────────────┐ │
99
+ │ │ Level 3: PUBLIC — OpenTimestamps calendars │ │
100
+ │ │ ┌─────────────────────────────────────────────┐ │ │
101
+ │ │ │ Level 2: BILATERAL — You + Counterparty │ │ │
102
+ │ │ │ ┌───────────────────────────────────────┐ │ │ │
103
+ │ │ │ │ Level 1: SELF — Only you (deletable) │ │ │ │
104
+ │ │ │ └───────────────────────────────────────┘ │ │ │
105
+ │ │ └─────────────────────────────────────────────┘ │ │
106
+ │ └───────────────────────────────────────────────────┘ │
107
+ └─────────────────────────────────────────────────────────┘
108
+ ```
109
+
110
+ | Level | Name | Who Can Verify | Can Be Deleted? |
111
+ |-------|------|----------------|-----------------|
112
+ | 1 | Self | Only you | Yes |
113
+ | 2 | Bilateral | You + counterparty | No (one party has copy) |
114
+ | 3 | Public | Anyone (OTS calendars) | No (independent servers) |
115
+ | 4 | Anchored | Everyone (Bitcoin) | No (computationally impossible) |
116
+
117
+ ---
118
+
119
+ ## How Others Verify Your Records
120
+
121
+ ### Method 1: Share Merkle Root (Simplest)
122
+
123
+ ```bash
124
+ forge status
125
+ # Root: c273ed77e3a06623238d0774211fe6f2…
126
+ ```
127
+
128
+ Give this hash to anyone. After Bitcoin confirmation, they can verify on blockchain.
129
+
130
+ ### Method 2: Bilateral Witness
131
+
132
+ ```bash
133
+ forge witness --bilateral auditor@company.com
134
+ ```
135
+
136
+ Both parties receive a receipt. Neither can deny the record exists.
137
+
138
+ ### Method 3: Export Full Chain
139
+
140
+ ```bash
141
+ forge export > chain.json
142
+ # Send chain.json to verifier
143
+ ```
144
+
145
+ Verifier runs:
146
+ ```bash
147
+ forge verify --file chain.json
148
+ ```
149
+
150
+ ### Method 4: OpenTimestamps Verification
151
+
152
+ After ~2 hours (Bitcoin confirmation):
153
+
154
+ ```bash
155
+ # Anyone can verify with OTS tools
156
+ ots verify proof.ots
157
+ ```
158
+
159
+ ---
160
+
161
+ ## MCP Server (AI Agent Integration)
162
+
163
+ Forge integrates with Claude Code and Claude Desktop as an MCP server.
164
+
165
+ ### Claude Code Configuration
166
+
167
+ Add to project's MCP settings:
168
+
169
+ ```json
170
+ {
171
+ "mcpServers": {
172
+ "forge": {
173
+ "type": "stdio",
174
+ "command": "node",
175
+ "args": ["/path/to/forge/src/mcp/server.js"]
176
+ }
177
+ }
178
+ }
179
+ ```
180
+
181
+ ### Claude Desktop Configuration
182
+
183
+ Add to `~/.config/claude/claude_desktop_config.json`:
184
+
185
+ ```json
186
+ {
187
+ "mcpServers": {
188
+ "forge": {
189
+ "command": "node",
190
+ "args": ["/path/to/forge/src/mcp/server.js"]
191
+ }
192
+ }
193
+ }
194
+ ```
195
+
196
+ ### MCP Tools (9 total)
197
+
198
+ | Tool | Description |
199
+ |------|-------------|
200
+ | `forge_scan` | Enumerate trust assumptions |
201
+ | `forge_log` | Record a TrustAtom |
202
+ | `forge_verify` | Verify chain integrity |
203
+ | `forge_seal` | Seal atoms into Merkle block |
204
+ | `forge_anchor` | Submit to Bitcoin via OTS |
205
+ | `forge_witness` | Show/create witness |
206
+ | `forge_prove` | Generate Merkle proof |
207
+ | `forge_status` | Show chain status |
208
+ | `forge_export` | Export chain as JSON |
209
+
210
+ ---
211
+
212
+ ## Security Scanner
213
+
214
+ Forge includes a system scanner to enumerate trust assumptions:
215
+
216
+ ```bash
217
+ forge scan
218
+ ```
219
+
220
+ Detects:
221
+ - Open ports (Redis, databases, management panels)
222
+ - SSH configuration (root login, password auth)
223
+ - Docker misconfigurations
224
+ - Firewall status
225
+ - Running processes
226
+ - Cron jobs
227
+ - Recent logins
228
+
229
+ Risk levels: 🔴 HIGH, 🟡 MEDIUM, 🔵 LOW, 🟢 INFO
230
+
231
+ ---
232
+
233
+ ## Use Cases
234
+
235
+ ### DevOps Audit Trail
236
+
237
+ ```bash
238
+ forge log "deployed app v2.1.0 to production"
239
+ forge log "scaled replicas from 3 to 5"
240
+ forge log "rolled back to v2.0.9"
241
+ forge seal && forge anchor
242
+ ```
243
+
244
+ ### Compliance Evidence
245
+
246
+ ```bash
247
+ forge log "completed security audit - 0 critical issues"
248
+ forge log "updated SSL certificates - expires 2027-01-15"
249
+ forge witness --bilateral compliance@auditor.com
250
+ forge seal && forge anchor
251
+ ```
252
+
253
+ ### Incident Response
254
+
255
+ ```bash
256
+ forge log "detected anomaly in auth service"
257
+ forge log "isolated affected nodes"
258
+ forge log "patched vulnerability CVE-2024-1234"
259
+ forge log "restored service - RCA completed"
260
+ forge seal && forge anchor
261
+ ```
262
+
263
+ ### Configuration Management
264
+
265
+ ```bash
266
+ forge scan # Baseline system state
267
+ forge log "configured firewall - allow 80,443 only"
268
+ forge log "disabled root SSH login"
269
+ forge log "enabled UFW"
270
+ forge seal && forge anchor
271
+ ```
272
+
273
+ ---
274
+
275
+ ## Theory: Trust = Certainty × Existence
276
+
277
+ Hash alone is NOT trust. Hash is only half:
278
+
279
+ - **Certainty** (mathematical): SHA-256 hash — deterministic, irreversible
280
+ - **Existence** (physical/social): Witness — independent copy that survives deletion
281
+
282
+ ```
283
+ Hash without witness → can be silently deleted
284
+ Witness without hash → can be forged
285
+ Trust = Certainty × Existence
286
+ ```
287
+
288
+ The fundamental question: **"What is the smallest thing that, if removed, trust collapses?"**
289
+
290
+ Answer: A hash that at least one independent party witnessed.
291
+
292
+ ---
293
+
294
+ ## Architecture
295
+
296
+ ```
297
+ src/
298
+ ├── core/
299
+ │ ├── trust-pixel.js (81) — Hash operations
300
+ │ ├── trust-atom.js (125) — Atomic state transitions
301
+ │ ├── merkle.js (131) — Merkle tree, proof generation
302
+ │ ├── chain.js (186) — Chain manager
303
+ │ └── witness.js (377) — Witness hierarchy, OTS
304
+ ├── store/
305
+ │ └── store.js (133) — JSON persistence (~/.forge/)
306
+ ├── scanner/
307
+ │ └── index.js (437) — Trust assumption scanner
308
+ ├── cli/
309
+ │ └── index.js (547) — CLI (10 commands)
310
+ ├── mcp/
311
+ │ └── server.js (534) — MCP server (9 tools)
312
+ └── test.js (266) — 27 tests
313
+
314
+ Total: ~2,800 lines, minimal dependencies
315
+ ```
316
+
317
+ ---
318
+
319
+ ## Data Storage
320
+
321
+ All data stored in `~/.forge/`:
322
+
323
+ ```
324
+ ~/.forge/
325
+ ├── chain.json # Atoms and blocks
326
+ ├── witnesses/ # Bilateral witness receipts
327
+ └── ots/ # OpenTimestamps proofs
328
+ ```
329
+
330
+ ---
331
+
332
+ ## Tests
333
+
334
+ ```bash
335
+ node src/test.js
336
+ # 27 passed, 0 failed
337
+ ```
338
+
339
+ ---
340
+
341
+ ## Roadmap
342
+
343
+ - [ ] Web dashboard for chain visualization
344
+ - [ ] Team/organization support
345
+ - [ ] Webhook notifications
346
+ - [ ] S3/cloud backup integration
347
+ - [ ] Hardware security module (HSM) support
348
+
349
+ ---
350
+
351
+ ## License
352
+
353
+ MIT
354
+
355
+ ---
356
+
357
+ ## Summary
358
+
359
+ ```
360
+ ┌────────────────────────────────────────────┐
361
+ │ forge log "did something important" │
362
+ │ forge seal │
363
+ │ forge anchor │
364
+ │ │
365
+ │ → Permanent, undeniable, Bitcoin-anchored │
366
+ │ proof that it happened. │
367
+ └────────────────────────────────────────────┘
368
+ ```
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "forge-trust-chain",
3
+ "version": "0.3.0",
4
+ "description": "FORGE - Trust Chain Protocol: Verifiable, undeniable, Bitcoin-anchored audit trail for cloud operations and AI agents",
5
+ "type": "module",
6
+ "main": "src/cli/index.js",
7
+ "bin": {
8
+ "forge": "src/cli/index.js"
9
+ },
10
+ "scripts": {
11
+ "forge": "node src/cli/index.js",
12
+ "mcp": "node src/mcp/server.js",
13
+ "demo": "node src/cli/index.js demo",
14
+ "scan": "node src/cli/index.js scan",
15
+ "anchor": "node src/cli/index.js anchor",
16
+ "test": "node src/test.js"
17
+ },
18
+ "keywords": [
19
+ "trust",
20
+ "security",
21
+ "blockchain",
22
+ "bitcoin",
23
+ "audit",
24
+ "compliance",
25
+ "devops",
26
+ "ai-agent",
27
+ "zero-trust",
28
+ "mcp",
29
+ "opentimestamps",
30
+ "merkle",
31
+ "hash-chain"
32
+ ],
33
+ "author": "Ayesy",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/Ayesy/forge.git"
38
+ },
39
+ "homepage": "https://github.com/Ayesy/forge#readme",
40
+ "bugs": {
41
+ "url": "https://github.com/Ayesy/forge/issues"
42
+ },
43
+ "engines": {
44
+ "node": ">=18.0.0"
45
+ },
46
+ "files": [
47
+ "src/",
48
+ "README.md",
49
+ "LICENSE"
50
+ ],
51
+ "dependencies": {
52
+ "@modelcontextprotocol/sdk": "^1.25.3",
53
+ "zod": "^4.3.6"
54
+ }
55
+ }