@stream44.studio/t44-blockchaincommons.com 0.1.0-rc.2

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.
Files changed (37) hide show
  1. package/.dco-signatures +9 -0
  2. package/.github/workflows/dco.yml +12 -0
  3. package/.github/workflows/gordian-open-integrity.yml +13 -0
  4. package/.o/GordianOpenIntegrity-CurrentLifehash.svg +1026 -0
  5. package/.o/GordianOpenIntegrity-InceptionLifehash.svg +1026 -0
  6. package/.o/GordianOpenIntegrity.yaml +25 -0
  7. package/DCO.md +34 -0
  8. package/README.md +210 -0
  9. package/action.yml +47 -0
  10. package/bin/oi +152 -0
  11. package/caps/GordianOpenIntegrity.test.ts +879 -0
  12. package/caps/GordianOpenIntegrity.ts +821 -0
  13. package/caps/XidDocumentLedger.test.ts +687 -0
  14. package/caps/XidDocumentLedger.ts +545 -0
  15. package/caps/__snapshots__/XidDocumentLedger.test.ts.snap +11 -0
  16. package/caps/__snapshots__/XidLedger.test.ts.snap +11 -0
  17. package/caps/lifehash.test.ts +302 -0
  18. package/caps/lifehash.ts +142 -0
  19. package/caps/open-integrity-js.test.ts +252 -0
  20. package/caps/open-integrity-js.ts +485 -0
  21. package/caps/open-integrity-sh.test.ts +188 -0
  22. package/caps/open-integrity-sh.ts +187 -0
  23. package/caps/open-integrity.test.ts +259 -0
  24. package/caps/provenance-mark-cli.test.ts +387 -0
  25. package/caps/provenance-mark-cli.ts +174 -0
  26. package/caps/provenance-mark.test.ts +233 -0
  27. package/caps/provenance-mark.ts +223 -0
  28. package/caps/xid.test.ts +828 -0
  29. package/caps/xid.ts +565 -0
  30. package/examples/01-XID-DocumentLedger/__snapshots__/main.test.ts.snap +10 -0
  31. package/examples/01-XID-DocumentLedger/main.test.ts +182 -0
  32. package/examples/02-XID-Rotate-InceptionKey/__snapshots__/main.test.ts.snap +53 -0
  33. package/examples/02-XID-Rotate-InceptionKey/main.test.ts +232 -0
  34. package/examples/03-GordianOpenIntegrity/main.test.ts +176 -0
  35. package/examples/04-GordianOpenIntegrityCli/main.test.ts +119 -0
  36. package/package.json +37 -0
  37. package/tsconfig.json +28 -0
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "envelope": "ur:envelope/lrtpsotanshdhdcxhsbtonkiisgrhegyaxdamowmherhoemodnhpurylgysocnattsgdlylksrykvymhoyaylftpsohdgltansgylftanshfhdcxwmfzjehtcmnygspaladssskkvlbgjppkbniezthsptemmocntktiwefdgrfzeysttansgrhdcxeyhtdaayjyutmsqzketorhnyetfyaokovtgdinfdrlkpdarkoyvtmutastjnkiasoycsfncsfgoycsfztpsohdjktngdgmgwhflfaxhdimyawzaxjtlddndnlecyqzvdclkskotksafsskdmlgwpbgdszmrerncmuofpaxmkkeahluwnmoidbsiypedmaozsneykjpplurloolghesjedwjtbzstimswwladghiartmkonaauogyfefnmnwzzsdratguaaoekkkipkmsecfykefwbkjldytpwmnlueyahpssfristkahtniecttihyoytpsojyfljljpieinhsjtgwjoihjtgajtjyihiojpinjykktpsokshnjkjkisdpihieeyececehescxfpfpfpfpfxeoglknhsfxehjzhtfygaehglghfeecfpfpfpfpgagdjtgoknhkfxgokpkkgmflgmgleogsdniofdemksksghgaidhdethfjnjegtecfxfphfeeflkphdkkjzkogwfecxjyeeeedpjkiniojtinjtiodpjeihkkaytyoxwl",
4
+ "mark": "946be460",
5
+ "$defs": {
6
+ "envelope": {
7
+ "$ref": "https://datatracker.ietf.org/doc/draft-mcnally-envelope/"
8
+ },
9
+ "mark": {
10
+ "$ref": "https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2025-001-provenance-mark.md"
11
+ }
12
+ }
13
+ }
14
+ ---
15
+ # Repository DID: did:repo:c8f51118b7dca6f9d7303c240b6a683d85e28dab
16
+ # Current Mark: 946be460 (🅑 MEOW JADE VIBE HORN)
17
+ # Inception Mark: 931e4bf4 (🅑 MENU COOK GEAR WORK)
18
+ # XID(610da57d) [
19
+ # 'key': Bytes(78) [
20
+ # 'allow': 'All'
21
+ # ]
22
+ # 'provenance': Bytes(115)
23
+ # "GordianOpenIntegrity": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPnUzYCUuyRGRN3L+gH7xxTIbX8VmkM5CAV4GuXylvOE t44-signing-key"
24
+ # ]
25
+ # Trust established using https://github.com/Stream44/t44-BlockchainCommons.com
package/DCO.md ADDED
@@ -0,0 +1,34 @@
1
+ Developer Certificate of Origin
2
+ Version 1.1
3
+
4
+ Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
5
+
6
+ Everyone is permitted to copy and distribute verbatim copies of this
7
+ license document, but changing it is not allowed.
8
+
9
+
10
+ Developer's Certificate of Origin 1.1
11
+
12
+ By making a contribution to this project, I certify that:
13
+
14
+ (a) The contribution was created in whole or in part by me and I
15
+ have the right to submit it under the open source license
16
+ indicated in the file; or
17
+
18
+ (b) The contribution is based upon previous work that, to the best
19
+ of my knowledge, is covered under an appropriate open source
20
+ license and I have the right under that license to submit that
21
+ work with modifications, whether created in whole or in part
22
+ by me, under the same open source license (unless I am
23
+ permitted to submit under a different license), as indicated
24
+ in the file; or
25
+
26
+ (c) The contribution was provided directly to me by some other
27
+ person who certified (a), (b) or (c) and I have not modified
28
+ it.
29
+
30
+ (d) I understand and agree that this project and the contribution
31
+ are public and that a record of the contribution (including all
32
+ personal information I submit with it, including my sign-off) is
33
+ maintained indefinitely and may be redistributed consistent with
34
+ this project or the open source license(s) involved.
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ ⚠️ **WARNING:** This repository may get squashed and force-pushed if the [GordianOpenIntegrity](https://github.com/Stream44/t44-blockchaincommons.com) implementation must change in incompatible ways. Keep your diffs until the **GordianOpenIntegrity** system is stable.
2
+
3
+ 🔷 **Open Development Project:** The implementation is a preview release for community feedback.
4
+
5
+ ⚠️ **Disclaimer:** Under active development. Code has not been audited, APIs and interfaces are subject to change.
6
+
7
+ `t44` Capsules for Blockchain Commons
8
+ ===
9
+
10
+ This project [encapsulates](https://github.com/Stream44/encapsulate) the [javascript APIs](https://github.com/leonardocustodio/bcts/tree/main) of the incredible [Gordian Stack](https://developer.blockchaincommons.com/) by [Blockchain Commons](https://www.blockchaincommons.com/) for use in [t44](https://github.com/Stream44/t44).
11
+ Blockchain Commons low-level libraries are wrapped into capsules and combined into new higher order capsules. Standalone use is also possible.
12
+
13
+ ### TODO
14
+
15
+ - **GordianOpenIntegrity**
16
+ - [ ] Review terminology and choices with Blockchain Commons.
17
+ - [ ] Validate or Verify
18
+ - [ ] Audit logic to ensure all integrity requirements are met and validations make sense.
19
+ - [ ] JSON Schemas for Gordian Envelope and Provenance Mark properties in `.o/GordianOpenIntegrity.yaml`. Blockchain Commons should define schema on URL so we can link.
20
+ - [ ] Review `.o/GordianOpenIntegrity.yaml` Gordian Envelope predicate/subject/object structure with Blockchain Commons to ensure compliance.
21
+ - [ ] Minimal audit script hand coded by third party to validate integrity.
22
+ - [ ] Third party review of `GordianOpenIntegrity` other than Blockchain Commons.
23
+ - [ ] Declare `GordianOpenIntegrity` foundation as stable once Blockchain Commons agrees.
24
+
25
+ Capsules: Higher Order
26
+ ---
27
+
28
+ ### `XidDocumentLedger` (XID Document Ledger)
29
+
30
+ A utility to author a verifiable chain of xid documents.
31
+
32
+ Combines the `xid` and `provenance-mark` capsules to provide a verifiable ledger according to the [Revisions with Provenance Marks](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2024-010-xid.md#revisions-with-provenance-marks) approach.
33
+
34
+ Compatible with `provenance-mark-cli` storage format.
35
+
36
+ ### `GordianOpenIntegrity` (Gordian Open Integrity Project)
37
+
38
+ A utility to record decisions **about** a git repository, **in** the git repository, in a cryptographically rigerous way leveraging XID Documents.
39
+
40
+ ```
41
+ # Initialize a git repository
42
+ bunx @stream44.studio/t44-blockchaincommons.com init [GordianOpenIntegrity] --inception-key ~/.ssh/key
43
+
44
+ # Validate a git repository
45
+ bunx @stream44.studio/t44-blockchaincommons.com validate [GordianOpenIntegrity]
46
+ ```
47
+
48
+ Github Actions validation workflow: `.github/workflows/gordian-open-integrity.yml`
49
+ ```
50
+ name: Validate Gordian Open Integrity
51
+
52
+ on: [push, pull_request]
53
+
54
+ jobs:
55
+ gordian-open-integrity:
56
+ name: Validate Gordian Open Integrity
57
+ runs-on: ubuntu-latest
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+ with:
61
+ fetch-depth: 0
62
+ - uses: Stream44/t44-blockchaincommons.com@main
63
+ ```
64
+
65
+ The [Open Integrity Project](https://github.com/OpenIntegrityProject) is focused on `git` and its ecosystem and is proposing a `.repo/` directory to store decisions (signed config files). More details here: https://github.com/OpenIntegrityProject/core/blob/main/docs/Open_Integrity_Repo_Directory_Structure.md
66
+
67
+ The `GordianOpenIntegrity` capsule takes a different *alternative and parallel* approach in that it provides an **open namespace to record all kinds of decisions for all kinds of purposes**.
68
+
69
+ The inception commit is tied to a XID Document stored in git at `.o/GordianOpenIntegrity.yaml` with the provenance mark generator file kept at `.git/o/GordianOpenIntegrity-generator.yaml`. From there, the Gordian Envelope system is used to **introduce** new decision assets that may be stored at `.o/<domain.tld>/my/path/doc.yaml` and `.git/o/<domain.tld>/my/path/doc-generator.yaml`. Implementers can design their own URI layouts and **Gordian Envelope Spaces**.
70
+
71
+ The capsule uses a `XidDocumentLedger` per document (across commits) and provides a minimal abstraction for `provenance-mark` enforced ledgers of XID Documents in git repositories tied cryptographically to the Open Integrity repository inception commit. `lifehash` is used to store the inception and current provenance mark at `.o/GordianOpenIntegrity-InceptionLifehash.svg` and `.o/GordianOpenIntegrity-CurrentLifehash.svg` respectively. See *[Provenance](#provenance)* footer below for the lifehash marks for this repository.
72
+
73
+ Given the latest provenance mark via a publishing channel, users are able to verify the integrity of all decisions recorded against the repository with complete confidence. This verification includes the repository code thus allowing for distribution via public peer-to-peer networks. This is stable foundation for transparent distributed governance and the exploration of cryptographic decision making and relationship building.
74
+
75
+ `.o/GordianOpenIntegrity.yaml` example from `examples/03-GordianOpenIntegrity/main.test.ts`:
76
+ ```
77
+ {
78
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
79
+ "envelope": "ur:envelope/lptpsotanshdhdcxesvdmtwlnlrfvevwayoygaberyvtjendqdtewljspsbwpmvsrpjymtrldkvwmubzoytpsojyfljljpieinhsjtgwjoihjtgajtjyihiojpinjykktpsokshnjkjkisdpihieeyececehescxfpfpfpfpfxeoglknhsfxehjzhtfygaehglghfeecfpfpfpfpgafweohtjyjkflengogdksjljyglingafphdhdhdhdieghjoeegdglgteegyimhteogojndykoehhkfyfxetgdhfcxjkiniojtinjtioheihieeyececehesoytpsoksckfljljpieinhsjtgwjoihjtgajtjyihiojpinjykkdmfyjliakpjnihjtjyjktpsoksehkgcpdmjldlihkshsjnjojzihdmiajljndljojljziniakkdlkoehdmkkhsjnjzcpftcphdgafydeieiaidehenetehiadtcpkioyaylftpsohdgltansgylftanshfhdcxolkiwytlsoehmshholmorhfgksladslfptsrwdgabkmdwlghbnbtuofrheoyosfstansgrhdcxdyhymubwbarffpotzcbajtstrfktlnpdbgrlwnoxgsctvofsledkfmckskldjzjsoycsfncsfgoycsfztpsohdjktngdgmgwhflfaxhdimdiwnmwrsemasflkitadwisswtbbemwtifgfdhtwdtlaeaavwkpongsatktvycapefhvapmlgselnqzaetnrdqdhnlpdnhlhgcertndrdrdwdtbaayalopsdiihmuontoiejomybtsthydpoemozckkmwltyannvdhtcmbbbswnfmwneoeyftmocxkszetsvdeycxkpguyaaabbfzenbtsaimwswe",
80
+ "mark": "a9ea4602",
81
+ "$defs": {
82
+ "envelope": {
83
+ "$ref": "https://datatracker.ietf.org/doc/draft-mcnally-envelope/"
84
+ },
85
+ "mark": {
86
+ "$ref": "https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2025-001-provenance-mark.md"
87
+ }
88
+ }
89
+ }
90
+ ---
91
+ # Repository DID: did:repo:72749389d090c2e6af2b14508df28aef74efeac8
92
+ # Current Mark: a9ea4602 (🅑 PART WAND FROG ALSO)
93
+ # Inception Mark: eb05b660 (🅑 WARM ARCH RAMP HORN)
94
+ # XID(39e796e9) [
95
+ # "GordianOpenIntegrity": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB3ZtsG6UPxotNiIAXXXXdTp4PNM4QjZ3Um0v1YDC8PV signing_ed25519"
96
+ # "GordianOpenIntegrity.Documents": "{".o/example.com/policy/v1.yaml":"XID(dcb1681c)"}"
97
+ # 'key': Bytes(78) [
98
+ # 'allow': 'All'
99
+ # ]
100
+ # 'provenance': Bytes(115)
101
+ # ]
102
+ # Root of trust established using https://github.com/Stream44/t44-blockchaincommons.com
103
+ ```
104
+
105
+ Commits that lead to this document:
106
+ ```
107
+ % git log
108
+ commit 233ddac0b263a68f590c984e3ad27cb6e9db300c (HEAD -> main)
109
+ Author: Author <author@example.com>
110
+ Date: Fri Feb 13 13:22:02 2026 -0500
111
+
112
+ [GordianOpenIntegrity] Introduce new Gordian Envelope at: .o/example.com/policy/v1.yaml
113
+
114
+ Signed-off-by: Author <author@example.com>
115
+
116
+ commit c7757c183fc7013fc4f51f25b86e88a45c736d17
117
+ Author: Author <author@example.com>
118
+ Date: Fri Feb 13 13:22:02 2026 -0500
119
+
120
+ [GordianOpenIntegrity] Establish inception Gordian Envelope at: .o/GordianOpenIntegrity.yaml
121
+
122
+ Trust established using https://github.com/Stream44/t44-BlockchainCommons.com
123
+
124
+ Signed-off-by: Author <author@example.com>
125
+
126
+ commit bb1408b6ccf40108866a8119d21a8f025a106078
127
+ Author: Author <author@example.com>
128
+ Date: Fri Feb 13 18:22:02 2026 +0000
129
+
130
+ [GordianOpenIntegrity] Establish a SHA-1 root of trust for origin and future commit verification.
131
+
132
+ Signed-off-by: Author <author@example.com>
133
+
134
+ Trust established using https://github.com/Stream44/t44-BlockchainCommons.com
135
+ ```
136
+
137
+
138
+ Capsules: Low Level
139
+ ---
140
+
141
+ These capsules wrap Blockchain Commons [Gordian Stack](https://developer.blockchaincommons.com/) [javascript](https://github.com/leonardocustodio/bcts/tree/main) libraries.
142
+
143
+ **NOTE:** Some capsules add additional functionality!
144
+
145
+ ### `xid` (XID: Extensible Identifiers)
146
+
147
+ An eXtensible IDentifier (XID) is a stable decentralized identifier generated from the hash of an inception key. XIDs resolve to an [envelope](https://developer.blockchaincommons.com/envelope/)-based controller document for managing keys, credentials, and other assertions, and leverage provenance chains for key rotation and revocation without changing the identifier. It does not necessarily to the [DID spec](https://www.w3.org/TR/did-core/), but it is inspired by the same needs and desires.
148
+
149
+ * Introduction: https://www.blockchaincommons.com/musings/XIDs-True-SSI/
150
+ * Project Home: https://developer.blockchaincommons.com/xid/
151
+ * Research Paper: https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2024-010-xid.md
152
+
153
+ ### `provenance-mark` (Provenance Marks)
154
+
155
+ A Provenance Mark is a forward-commitment hash chain to establish cryptographic sequential ordering for linked digital objects. Each mark in the chain commits to preceding and subsequent content, preventing retroactive insertion or modification without requiring timestamps or trusted witnesses. This enables tracking of editions, state changes, and histories for controller documents, credentials, and evolving structures.
156
+
157
+ * Project Home: https://developer.blockchaincommons.com/provemark/
158
+ * Research Paper: https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2025-001-provenance-mark.md
159
+
160
+ ### `provenance-mark-cli` (Provenance Mark CLI)
161
+
162
+ A command line tool for creating and managing Provenance Mark chains.
163
+
164
+ * JavaScipt Implementation: https://github.com/leonardocustodio/bcts/tree/main/tools/provenance-mark-cli
165
+ * Research Paper: https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2025-001-provenance-mark.md
166
+
167
+ ### `open-integrity` (Open Integrity Project)
168
+
169
+ Open Integrity is an initiative by Blockchain Commons to integrate cryptographic trust mechanisms into Git repositories. By leveraging Git's native SSH signing capabilities and structured verification processes, we ensure transparency, provenance, and immutability for software projects.
170
+
171
+ * Project Home: https://github.com/OpenIntegrityProject/core
172
+
173
+ ### `lifehash` (LifeHash)
174
+
175
+ LifeHash is a method of hash visualization based on Conway’s Game of Life that creates beautiful icons that are deterministic, yet distinct and unique given the input data. It is part of the [OIB](https://developer.blockchaincommons.com/oib/).
176
+
177
+ * Introduction: https://developer.blockchaincommons.com/oib/
178
+ * Project Home: https://developer.blockchaincommons.com/lifehash/
179
+
180
+
181
+ Projects
182
+ ===
183
+
184
+ The following projects use `GordianOpenIntegrity`:
185
+
186
+ - [t44](https://github.com/Stream44/t44) - A web3 + AI ready workspace
187
+ - [Stream44.Studio](https://stream44.studio) - A **full-stack IDE** for building **embodied distributed systems**
188
+
189
+
190
+ Provenance
191
+ ===
192
+
193
+ Repository DID: `did:repo:c8f51118b7dca6f9d7303c240b6a683d85e28dab`
194
+
195
+ <table>
196
+ <tr>
197
+ <td><strong>Inception Mark</strong></td>
198
+ <td><img src=".o/GordianOpenIntegrity-InceptionLifehash.svg" width="64" height="64"></td>
199
+ <td><strong>Current Mark</strong></td>
200
+ <td><img src=".o/GordianOpenIntegrity-CurrentLifehash.svg" width="64" height="64"></td>
201
+ <td>Trust established using<br/><a href="https://github.com/Stream44/t44-blockchaincommons.com">Stream44/t44-BlockchainCommons.com</a></td>
202
+ </tr>
203
+ </table>
204
+
205
+ (c) 2026 [Christoph.diy](https://christoph.diy) • Code: `BSD-2-Clause-Patent` • Text: `CC-BY` • Created with [Stream44.Studio](https://Stream44.Studio)
206
+
207
+ ### Credits & Thank You!
208
+
209
+ * [@ChristopherA](https://github.com/ChristopherA), [@WolfMcNally](https://github.com/wolfmcnally) and [@shannona](https://github.com/shannona) of [Blockchain Commons](https://www.blockchaincommons.com/) for **all original work** on the [The Gordian Stack](https://developer.blockchaincommons.com/).
210
+ * [Leonardo Custodio](https://github.com/leonardocustodio) for porting *The Gordian Stack* **Rust** implementations to **TypeScript**.
package/action.yml ADDED
@@ -0,0 +1,47 @@
1
+ name: 'Gordian Open Integrity Validation'
2
+ description: 'Validate Gordian Open Integrity provenance and commit signatures on a repository'
3
+ author: 'Stream44'
4
+
5
+ inputs:
6
+ mark:
7
+ description: 'Published provenance mark to verify against'
8
+ required: false
9
+ default: ''
10
+
11
+ branding:
12
+ icon: 'shield'
13
+ color: 'blue'
14
+
15
+ runs:
16
+ using: 'composite'
17
+ steps:
18
+ - name: Setup Bun
19
+ uses: oven-sh/setup-bun@v2
20
+
21
+ - name: Install dependencies
22
+ shell: bash
23
+ run: |
24
+ cd ${{ github.action_path }}
25
+ bun install --frozen-lockfile
26
+
27
+ - name: Read current mark
28
+ id: read-mark
29
+ shell: bash
30
+ run: |
31
+ MARK="${{ inputs.mark }}"
32
+ if [[ -z "$MARK" ]]; then
33
+ PROVENANCE_FILE=".o/GordianOpenIntegrity.yaml"
34
+ if [[ -f "$PROVENANCE_FILE" ]]; then
35
+ MARK=$(grep -oP '"mark":\s*"\K[^"]+' "$PROVENANCE_FILE" || true)
36
+ fi
37
+ fi
38
+ echo "mark=$MARK" >> "$GITHUB_OUTPUT"
39
+
40
+ - name: Validate Gordian Open Integrity
41
+ shell: bash
42
+ run: |
43
+ MARK_FLAG=""
44
+ if [[ -n "${{ steps.read-mark.outputs.mark }}" ]]; then
45
+ MARK_FLAG="--mark ${{ steps.read-mark.outputs.mark }}"
46
+ fi
47
+ bun ${{ github.action_path }}/bin/oi validate GordianOpenIntegrity $MARK_FLAG
package/bin/oi ADDED
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env bun
2
+ /// <reference types="bun" />
3
+ /// <reference types="node" />
4
+
5
+ import { resolve } from 'path'
6
+ import { Command } from 'commander'
7
+ import chalk from 'chalk'
8
+ import { CapsuleSpineFactory } from "@stream44.studio/encapsulate/spine-factories/CapsuleSpineFactory.v0"
9
+ import { CapsuleSpineContract } from "@stream44.studio/encapsulate/spine-contracts/CapsuleSpineContract.v0/Membrane.v0"
10
+
11
+ const SUPPORTED_SYSTEMS = ['GordianOpenIntegrity']
12
+
13
+ async function bootCapsule() {
14
+ const { encapsulate, freeze, CapsulePropertyTypes, makeImportStack, hoistSnapshot } = await CapsuleSpineFactory({
15
+ spineFilesystemRoot: resolve(import.meta.dir, '..'),
16
+ capsuleModuleProjectionRoot: import.meta.dir,
17
+ enableCallerStackInference: false,
18
+ spineContracts: {
19
+ ['#' + CapsuleSpineContract['#']]: CapsuleSpineContract
20
+ },
21
+ })
22
+
23
+ const spine = await encapsulate({
24
+ '#@stream44.studio/encapsulate/spine-contracts/CapsuleSpineContract.v0': {
25
+ '#@stream44.studio/encapsulate/structs/Capsule': {},
26
+ '#': {
27
+ oi: {
28
+ type: CapsulePropertyTypes.Mapping,
29
+ value: '@stream44.studio/t44-blockchaincommons.com/caps/GordianOpenIntegrity'
30
+ },
31
+ }
32
+ }
33
+ }, {
34
+ importMeta: import.meta,
35
+ importStack: makeImportStack(),
36
+ capsuleName: '@stream44.studio/t44-blockchaincommons.com/bin/oi'
37
+ })
38
+
39
+ const snapshot = await freeze()
40
+ const { run } = await hoistSnapshot({ snapshot })
41
+
42
+ return { spine, run }
43
+ }
44
+
45
+ function validateSystem(system: string) {
46
+ if (!SUPPORTED_SYSTEMS.includes(system)) {
47
+ console.error(chalk.red(`Unsupported system: ${system}`))
48
+ console.error(chalk.white(`Supported systems: ${SUPPORTED_SYSTEMS.join(', ')}`))
49
+ process.exit(1)
50
+ }
51
+ }
52
+
53
+ const program = new Command()
54
+ .name('@stream44.studio/t44-blockchaincommons.com')
55
+ .description('Gordian Open Integrity CLI')
56
+ .version('0.0.1')
57
+
58
+ program
59
+ .command('init')
60
+ .description('Initialize a Gordian Open Integrity repository in the current directory')
61
+ .argument('<system>', `Integrity system to initialize (${SUPPORTED_SYSTEMS.join(', ')})`)
62
+ .requiredOption('--inception-key <path>', 'Path to the SSH private key for inception signing')
63
+ .option('--author-name <name>', 'Author name for git commits', 'Author')
64
+ .option('--author-email <email>', 'Author email for git commits', 'author@example.com')
65
+ .action(async (system, opts) => {
66
+ validateSystem(system)
67
+
68
+ const repoDir = resolve(process.cwd())
69
+ const inceptionKeyPath = resolve(opts.inceptionKey)
70
+
71
+ const { spine, run } = await bootCapsule()
72
+
73
+ await run({}, async ({ apis }) => {
74
+ const oi = apis[spine.capsuleSourceLineRef].oi
75
+
76
+ console.log(chalk.blue('Creating identity...'))
77
+ const author = await oi.createIdentity({
78
+ privateKeyPath: inceptionKeyPath,
79
+ authorName: opts.authorName,
80
+ authorEmail: opts.authorEmail,
81
+ })
82
+
83
+ console.log(chalk.blue('Creating repository...'))
84
+ const result = await oi.createRepository({
85
+ repoDir,
86
+ author,
87
+ })
88
+
89
+ const markId = await oi.getMarkIdentifier({ mark: result.mark })
90
+
91
+ console.log()
92
+ console.log(chalk.green('✓ Gordian Open Integrity repository initialized'))
93
+ console.log(chalk.white(` DID: ${result.did}`))
94
+ console.log(chalk.white(` Mark: ${markId}`))
95
+ console.log(chalk.white(` Dir: ${repoDir}`))
96
+ })
97
+ })
98
+
99
+ program
100
+ .command('validate')
101
+ .description('Validate a Gordian Open Integrity repository in the current directory')
102
+ .argument('<system>', `Integrity system to validate (${SUPPORTED_SYSTEMS.join(', ')})`)
103
+ .option('--mark <mark>', 'Published provenance mark to verify against')
104
+ .action(async (system, opts) => {
105
+ validateSystem(system)
106
+
107
+ const repoDir = resolve(process.cwd())
108
+
109
+ const { spine, run } = await bootCapsule()
110
+
111
+ await run({}, async ({ apis }) => {
112
+ const oi = apis[spine.capsuleSourceLineRef].oi
113
+
114
+ console.log(chalk.blue('Validating repository...'))
115
+ const result = await oi.verify({
116
+ repoDir,
117
+ mark: opts.mark,
118
+ })
119
+
120
+ console.log()
121
+ if (result.valid) {
122
+ console.log(chalk.green('✓ Repository integrity verified'))
123
+ } else {
124
+ console.log(chalk.red('✗ Repository integrity verification failed'))
125
+ }
126
+
127
+ console.log(chalk.white(` XID: ${result.xid || 'N/A'}`))
128
+ console.log(chalk.white(` DID: ${result.did || 'N/A'}`))
129
+ console.log(chalk.white(` Commits: ${result.totalCommits} total, ${result.validSignatures} valid, ${result.invalidSignatures} invalid`))
130
+ console.log(chalk.white(` Provenance versions: ${result.provenanceVersions}`))
131
+ console.log(chalk.white(` Marks monotonic: ${result.marksMonotonic ? 'yes' : 'no'}`))
132
+ console.log(chalk.white(` XID stable: ${result.xidStable ? 'yes' : 'no'}`))
133
+
134
+ if (opts.mark) {
135
+ console.log(chalk.white(` Mark matches latest: ${result.markMatchesLatest ? 'yes' : 'no'}`))
136
+ }
137
+
138
+ if (result.issues.length > 0) {
139
+ console.log()
140
+ console.log(chalk.red('Issues:'))
141
+ for (const issue of result.issues) {
142
+ console.log(chalk.red(` - ${issue}`))
143
+ }
144
+ }
145
+
146
+ if (!result.valid) {
147
+ process.exit(1)
148
+ }
149
+ })
150
+ })
151
+
152
+ program.parse(process.argv)