File size: 2,269 Bytes
4953a87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
||| Clone Gate CLI β€” sovereign integrity enforcement in Idris 2.
|||
||| Usage:
|||   clone_gate seal    -- hash all registered modules, write MANIFEST.seal
|||   clone_gate verify  -- verify all modules against manifest
|||   clone_gate status  -- print per-file seal status
|||
||| Copyright (C) 2026 SNAPKITTYWEST / SnapKitty (Jessica)
||| License: BSL-1.1 / AGPL-3.0 / MPL-2.0
||| Author: Ahmad Ali Parr
||| Linear types: WORM chain is append-only by construction (WORM.idr)
||| Dependent types: Chain n tracks entry count at compile time
module Main

import Data.String
import System
import System.Directory
import Manifest
import WORM
import Hash

-- ── Entry point ────────────────────────────────────────────────────────────

main : IO ()
main = do
  args    <- getArgs
  repoRoot <- case !currentDir of
                Right d => pure d
                Left  _ => pure "."
  case args of
    [_, "seal"] => do
      putStrLn "\n[clone_gate] Sealing all registered modules...\n"
      n <- sealAll repoRoot
      putStrLn $ "\n[clone_gate] Chain length : " ++ show n ++ " entries"
      putStrLn   "[clone_gate] Seal complete."

    [_, "verify"] => do
      putStrLn "\n[clone_gate] Verifying all registered modules...\n"
      ok <- verifyAll repoRoot
      if ok
        then do
          putStrLn "\n[clone_gate] All modules verified β€” chain intact."
          exitSuccess
        else do
          putStrLn "\n[clone_gate] VERIFICATION FAILED β€” chain integrity violated."
          exitFailure

    [_, "status"] => do
      putStrLn "\n[clone_gate] Seal status:\n"
      _ <- verifyAll repoRoot
      pure ()

    _ => putStrLn """
[clone_gate] Reverse Quantum Walk β€” Sovereign Clone Gate (Idris 2)

Usage:
  clone_gate seal     Hash all registered modules, write MANIFEST.seal
  clone_gate verify   Verify all modules against MANIFEST.seal
  clone_gate status   Print per-file status

Linear types enforce append-only WORM invariant at compile time.
Dependent types track chain entry count: Chain n.
SHA-256 via OpenSSL (cbits/hash_shim.c).

Build:
  idris2 --build clone_gate.ipkg
Run:
  ./build/exec/clone_gate seal
"""