grantstamp 0.1.0__tar.gz

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 (65) hide show
  1. grantstamp-0.1.0/.gitignore +13 -0
  2. grantstamp-0.1.0/LICENSE +177 -0
  3. grantstamp-0.1.0/NOTICE +23 -0
  4. grantstamp-0.1.0/PKG-INFO +141 -0
  5. grantstamp-0.1.0/README.md +107 -0
  6. grantstamp-0.1.0/docs/01-problem.md +55 -0
  7. grantstamp-0.1.0/docs/02-solutions.md +120 -0
  8. grantstamp-0.1.0/docs/03-architecture.md +101 -0
  9. grantstamp-0.1.0/docs/04-implementation.md +175 -0
  10. grantstamp-0.1.0/docs/05-integrations.md +142 -0
  11. grantstamp-0.1.0/docs/DISPUTES.md +25 -0
  12. grantstamp-0.1.0/docs/PRIVACY.md +31 -0
  13. grantstamp-0.1.0/docs/TERMS.md +14 -0
  14. grantstamp-0.1.0/docs/threat-model.md +26 -0
  15. grantstamp-0.1.0/pyproject.toml +57 -0
  16. grantstamp-0.1.0/spec/grantstamp-protocol-v0.1.md +210 -0
  17. grantstamp-0.1.0/src/grantstamp/__init__.py +12 -0
  18. grantstamp-0.1.0/src/grantstamp/brand.py +46 -0
  19. grantstamp-0.1.0/src/grantstamp/cli.py +578 -0
  20. grantstamp-0.1.0/src/grantstamp/client.py +201 -0
  21. grantstamp-0.1.0/src/grantstamp/crypto.py +157 -0
  22. grantstamp-0.1.0/src/grantstamp/fingerprint/__init__.py +7 -0
  23. grantstamp-0.1.0/src/grantstamp/fingerprint/background.py +116 -0
  24. grantstamp-0.1.0/src/grantstamp/fingerprint/background_chunks_v1.u64 +0 -0
  25. grantstamp-0.1.0/src/grantstamp/fingerprint/background_strings_v1.u64 +0 -0
  26. grantstamp-0.1.0/src/grantstamp/fingerprint/bundle.py +340 -0
  27. grantstamp-0.1.0/src/grantstamp/fingerprint/cdc.py +138 -0
  28. grantstamp-0.1.0/src/grantstamp/fingerprint/filetypes.py +56 -0
  29. grantstamp-0.1.0/src/grantstamp/fingerprint/image.py +47 -0
  30. grantstamp-0.1.0/src/grantstamp/fingerprint/sampling.py +48 -0
  31. grantstamp-0.1.0/src/grantstamp/fingerprint/strings.py +104 -0
  32. grantstamp-0.1.0/src/grantstamp/fingerprint/winnow.py +63 -0
  33. grantstamp-0.1.0/src/grantstamp/hook.py +186 -0
  34. grantstamp-0.1.0/src/grantstamp/httpsig.py +242 -0
  35. grantstamp-0.1.0/src/grantstamp/manifest.py +76 -0
  36. grantstamp-0.1.0/src/grantstamp/markers.py +84 -0
  37. grantstamp-0.1.0/src/grantstamp/mcp_server.py +149 -0
  38. grantstamp-0.1.0/src/grantstamp/policy.py +144 -0
  39. grantstamp-0.1.0/src/grantstamp/pow.py +66 -0
  40. grantstamp-0.1.0/src/grantstamp/site/assets/check-page.js +85 -0
  41. grantstamp-0.1.0/src/grantstamp/site/assets/config.js +7 -0
  42. grantstamp-0.1.0/src/grantstamp/site/assets/favicon.svg +5 -0
  43. grantstamp-0.1.0/src/grantstamp/site/assets/fonts/OFL-LibreCaslonText.txt +93 -0
  44. grantstamp-0.1.0/src/grantstamp/site/assets/fonts/OFL-PublicSans.txt +93 -0
  45. grantstamp-0.1.0/src/grantstamp/site/assets/fonts/libre-caslon-text-latin-400-italic.woff2 +0 -0
  46. grantstamp-0.1.0/src/grantstamp/site/assets/fonts/libre-caslon-text-latin-400-normal.woff2 +0 -0
  47. grantstamp-0.1.0/src/grantstamp/site/assets/fonts/libre-caslon-text-latin-700-normal.woff2 +0 -0
  48. grantstamp-0.1.0/src/grantstamp/site/assets/fonts/public-sans-latin-400-normal.woff2 +0 -0
  49. grantstamp-0.1.0/src/grantstamp/site/assets/fonts/public-sans-latin-600-normal.woff2 +0 -0
  50. grantstamp-0.1.0/src/grantstamp/site/assets/fonts/public-sans-latin-700-normal.woff2 +0 -0
  51. grantstamp-0.1.0/src/grantstamp/site/assets/grantstamp-check.js +224 -0
  52. grantstamp-0.1.0/src/grantstamp/site/assets/style.css +135 -0
  53. grantstamp-0.1.0/src/grantstamp/site/check.html +48 -0
  54. grantstamp-0.1.0/src/grantstamp/site/index.html +165 -0
  55. grantstamp-0.1.0/src/grantstamp/site/spec.html +31 -0
  56. grantstamp-0.1.0/src/grantstamp/tokens.py +87 -0
  57. grantstamp-0.1.0/src/grantstamp/util.py +115 -0
  58. grantstamp-0.1.0/tests/conftest.py +99 -0
  59. grantstamp-0.1.0/tests/test_crypto_httpsig.py +76 -0
  60. grantstamp-0.1.0/tests/test_fingerprint.py +108 -0
  61. grantstamp-0.1.0/tests/test_hook_mcp.py +64 -0
  62. grantstamp-0.1.0/tests/test_js_parity.py +62 -0
  63. grantstamp-0.1.0/tests/test_policy_tokens.py +42 -0
  64. grantstamp-0.1.0/tests/test_postgres.py +93 -0
  65. grantstamp-0.1.0/tests/test_server.py +228 -0
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ .pytest_cache/
6
+ dist/
7
+ build/
8
+ *.db
9
+ *.db-wal
10
+ *.db-shm
11
+ .env
12
+ .DS_Store
13
+ bench/work/
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,23 @@
1
+ Grantstamp
2
+ Copyright 2026 The Grantstamp Authors
3
+
4
+ This product includes software developed by the Grantstamp project
5
+ (https://grantstamp.io).
6
+
7
+ Licensing is by directory:
8
+ - server/ (the registry server, Python package grantstamp-server) is
9
+ licensed under the GNU Affero General Public License, version 3 only
10
+ (AGPL-3.0-only). See server/LICENSE.
11
+ - spec/ (the protocol specification text) is licensed under the Creative
12
+ Commons Attribution 4.0 International licence (CC BY 4.0).
13
+ - Everything else, including the client library, command-line tool, MCP
14
+ server, agent hook and website (Python package grantstamp), is licensed
15
+ under the Apache License, Version 2.0. See LICENSE.
16
+
17
+ "Grantstamp", the Grantstamp seal and "Agents ask first" are trademarks of
18
+ the project owner. See TRADEMARK.md. None of the licences above grants
19
+ trademark rights.
20
+
21
+ Bundled fonts (src/grantstamp/site/assets/fonts) are licensed under the
22
+ SIL Open Font License 1.1: Public Sans (The Public Sans Project Authors)
23
+ and Libre Caslon Text (Pablo Impallari). License texts are included there.
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.5
2
+ Name: grantstamp
3
+ Version: 0.1.0
4
+ Summary: Open ownership registry and check protocol for AI agents: owners publish fingerprints and policies, agents check before they touch a file.
5
+ Project-URL: Homepage, https://grantstamp.io
6
+ Project-URL: Documentation, https://github.com/grantstamp/grantstamp/tree/main/docs
7
+ Project-URL: Source, https://github.com/grantstamp/grantstamp
8
+ Project-URL: Issues, https://github.com/grantstamp/grantstamp/issues
9
+ Author: Grantstamp contributors
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: ai-agents,copyright,fingerprinting,licensing,mcp,ownership,provenance,registry
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Topic :: Security
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: cryptography>=42
22
+ Requires-Dist: httpx>=0.27
23
+ Requires-Dist: mcp>=1.2
24
+ Requires-Dist: numpy>=1.24
25
+ Provides-Extra: all
26
+ Requires-Dist: pillow>=10; extra == 'all'
27
+ Provides-Extra: dev
28
+ Requires-Dist: pillow>=10; extra == 'dev'
29
+ Requires-Dist: pytest>=8; extra == 'dev'
30
+ Provides-Extra: images
31
+ Requires-Dist: pillow>=10; extra == 'images'
32
+ Provides-Extra: mcp
33
+ Description-Content-Type: text/markdown
34
+
35
+ # Grantstamp
36
+
37
+ **Agents ask first.** Grantstamp™ is an open ownership registry and check protocol for AI agents. Owners publish fingerprints and a policy for their software and game builds, but never the files themselves. Before an agent decompiles, ports, modifies or redistributes a file, it checks the registry. It gets back who owns the file, what the owner allows for that exact use, a confidence band and a signed receipt.
38
+
39
+ <!-- mcp-name: io.github.grantstamp/grantstamp -->
40
+
41
+ > Status: prototype 0.1. This version works end to end and is tested and benchmarked, but it is not production-hardened yet, and interfaces may change before 1.0.
42
+
43
+ ## Why
44
+
45
+ AI coding agents now compress weeks of reverse-engineering and porting work into hours. Owners have no machine-readable way to tell those agents "this is mine, and this is what I allow." Today's safeguards are blunt rules: they cannot tell a pirate from the owner's own contractor. Grantstamp gives agents precise, owner-supplied data. It flags copies and unblocks licensees, and it alerts the owner within seconds. Read [docs/01-problem.md](docs/01-problem.md).
46
+
47
+ ## How it works
48
+
49
+ ```mermaid
50
+ sequenceDiagram
51
+ participant O as Owner (CLI, local)
52
+ participant R as Grantstamp registry
53
+ participant A as AI agent (MCP / hook / API)
54
+ O->>O: fingerprint build locally (hashes only)
55
+ O->>R: register stamp: fingerprints + policy (signed)
56
+ A->>A: fingerprint the user's file locally
57
+ A->>R: POST /v1/check {digests, use: "port", licence tokens?}
58
+ R-->>A: owner, policy decision, band, guidance, signed receipt
59
+ R-->>O: alert (match / probing / conflict) via webhook
60
+ ```
61
+
62
+ Every file gets a **layered identity**. No single fingerprint survives everything, so Grantstamp combines several:
63
+
64
+ | Layer | What it survives |
65
+ | --- | --- |
66
+ | `sha256` | nothing; exact copies only, zero false positives |
67
+ | `chunks`, content-defined chunking | patches, edits, embedding in a bigger file |
68
+ | `strings`, printable strings and code literals | recompiling, other compilers, stripping, porting, decompiling |
69
+ | `symbols`, identifier-like strings | weak evidence on its own, so stricter thresholds |
70
+ | `winnow`, normalised code k-grams | reformatting and renaming in source code |
71
+ | `dhash`, perceptual image hash | re-encoding and resizing of textures and art |
72
+ | `markers`, embedded notice or signed `grantstamp.json` | anything that keeps strings; also visible to agents reading the file |
73
+
74
+ Matches are graded **exact > high > medium > low**. Only high and exact can produce a hard *deny*. A medium-confidence match turns the owner's *deny* into *ask*.
75
+
76
+ ## Quick start
77
+
78
+ ```bash
79
+ pip install grantstamp # client, CLI, MCP server, agent hook (Apache-2.0)
80
+ pip install grantstamp-server # only to run a registry (AGPL-3.0)
81
+ python examples/demo.py # the whole story, locally, in ~10 seconds (needs both)
82
+ ```
83
+
84
+ ### Owners
85
+
86
+ ```bash
87
+ grantstamp keygen # your identity: ~/.grantstamp/owner.key
88
+ grantstamp owner create --name "Starfall Studio" --url https://starfall.example
89
+ grantstamp owner domain starfall.example # prints a DNS TXT record / .well-known file
90
+ grantstamp owner verify starfall.example
91
+ grantstamp register ./build --title "Starfall Courier" --version 0.9.4 \
92
+ --preset standard --contact legal@starfall.example --manifest
93
+ grantstamp marker stamp_… --lang cpp # notice to compile into the next build
94
+ grantstamp owner webhook https://hooks.slack.com/services/… --format slack
95
+ grantstamp token issue --stamp stamp_… --to "PortCo" --uses port,modify --days 90
96
+ grantstamp alerts
97
+ ```
98
+
99
+ ### AI agents and tools
100
+
101
+ - **MCP server** (Claude Desktop, Claude Code, Cursor, VS Code): run `pip install grantstamp`, then point your client at the `grantstamp-mcp` command. See [integrations/](integrations/).
102
+ - **Claude Code hook**: `grantstamp-hook` runs before Read, Edit and Bash on binaries and game files. It denies, asks or allows based on the owner's policy. See [integrations/claude-code](integrations/claude-code/README.md).
103
+ - **HTTP API**: `POST /v1/check`. Sign requests with RFC 9421 HTTP Message Signatures (Web Bot Auth compatible) for higher limits. See [spec/grantstamp-protocol-v0.1.md](spec/grantstamp-protocol-v0.1.md).
104
+ - **Command line**: `grantstamp check path/to/file --use port --exit-code`.
105
+ - **Browser**: the website's check page fingerprints a file in the browser; the file never leaves it.
106
+
107
+ ### Run a registry
108
+
109
+ ```bash
110
+ pip install "grantstamp-server[postgres]"
111
+ grantstamp serve --host 0.0.0.0 --port 8000 --db sqlite:///grantstamp.db --public-url https://registry.example
112
+ # or: docker compose up -d (Caddy + HTTPS), or render.yaml + a free Neon Postgres: docs/05-integrations.md
113
+ ```
114
+
115
+ ## Benchmark (prototype scale)
116
+
117
+ The full results are in [bench/RESULTS.md](bench/RESULTS.md), reproducible with `python bench/run_bench.py`.
118
+
119
+ - **Detection.** A toy game was recompiled with gcc and clang at -O0 to -O3 with LTO, stripped, byte-patched, given half-rewritten strings, ported as a folder, or turned into synthetic decompiler output. Every variant matched **high** or **exact**.
120
+ - **Cross-matches.** 400 Linux system executables were checked against 60 others registered under 60 owners. There were **0 medium-or-higher matches across different source packages**. All 21 medium or high matches were programs from the same source package, which really do share code.
121
+
122
+ ## Documentation
123
+
124
+ | | |
125
+ | --- | --- |
126
+ | [01 Problem](docs/01-problem.md) | What happened, why speed matters, where safeguards fail |
127
+ | [02 Solutions](docs/02-solutions.md) | Each original idea, what breaks, the fix that holds |
128
+ | [03 Architecture](docs/03-architecture.md) | Components, data flow, security boundaries |
129
+ | [04 Implementation](docs/04-implementation.md) | Algorithms, scoring, API and CLI reference |
130
+ | [05 Integrations](docs/05-integrations.md) | Every account and service needed, step by step |
131
+ | [Threat model](docs/threat-model.md) · [Spec](spec/grantstamp-protocol-v0.1.md) | Attacks and mitigations; the protocol |
132
+
133
+ ## What Grantstamp is not
134
+
135
+ It is not DRM and not a court. It does not stop leaks, make anything uncrackable or decide what is legal. It puts the owner's signed claim and policy in front of a cooperating agent at the moment it is about to act, and tells the owner fast.
136
+
137
+ ## License
138
+
139
+ The client library, CLI, MCP server, agent hook and website are Apache-2.0 ([LICENSE](LICENSE)). The registry server in [server/](server/) (`grantstamp-server`) is AGPL-3.0-only ([server/LICENSE](server/LICENSE)): anyone who runs a modified copy for others must publish their changes. Agents and tools that only check the registry need only the Apache-2.0 client. The protocol specification is CC BY 4.0.
140
+
141
+ Copyright 2026 The Grantstamp Authors. "Grantstamp" and the Grantstamp seal are trademarks of the project owner; neither licence grants trademark rights. See [TRADEMARK.md](TRADEMARK.md).
@@ -0,0 +1,107 @@
1
+ # Grantstamp
2
+
3
+ **Agents ask first.** Grantstamp™ is an open ownership registry and check protocol for AI agents. Owners publish fingerprints and a policy for their software and game builds, but never the files themselves. Before an agent decompiles, ports, modifies or redistributes a file, it checks the registry. It gets back who owns the file, what the owner allows for that exact use, a confidence band and a signed receipt.
4
+
5
+ <!-- mcp-name: io.github.grantstamp/grantstamp -->
6
+
7
+ > Status: prototype 0.1. This version works end to end and is tested and benchmarked, but it is not production-hardened yet, and interfaces may change before 1.0.
8
+
9
+ ## Why
10
+
11
+ AI coding agents now compress weeks of reverse-engineering and porting work into hours. Owners have no machine-readable way to tell those agents "this is mine, and this is what I allow." Today's safeguards are blunt rules: they cannot tell a pirate from the owner's own contractor. Grantstamp gives agents precise, owner-supplied data. It flags copies and unblocks licensees, and it alerts the owner within seconds. Read [docs/01-problem.md](docs/01-problem.md).
12
+
13
+ ## How it works
14
+
15
+ ```mermaid
16
+ sequenceDiagram
17
+ participant O as Owner (CLI, local)
18
+ participant R as Grantstamp registry
19
+ participant A as AI agent (MCP / hook / API)
20
+ O->>O: fingerprint build locally (hashes only)
21
+ O->>R: register stamp: fingerprints + policy (signed)
22
+ A->>A: fingerprint the user's file locally
23
+ A->>R: POST /v1/check {digests, use: "port", licence tokens?}
24
+ R-->>A: owner, policy decision, band, guidance, signed receipt
25
+ R-->>O: alert (match / probing / conflict) via webhook
26
+ ```
27
+
28
+ Every file gets a **layered identity**. No single fingerprint survives everything, so Grantstamp combines several:
29
+
30
+ | Layer | What it survives |
31
+ | --- | --- |
32
+ | `sha256` | nothing; exact copies only, zero false positives |
33
+ | `chunks`, content-defined chunking | patches, edits, embedding in a bigger file |
34
+ | `strings`, printable strings and code literals | recompiling, other compilers, stripping, porting, decompiling |
35
+ | `symbols`, identifier-like strings | weak evidence on its own, so stricter thresholds |
36
+ | `winnow`, normalised code k-grams | reformatting and renaming in source code |
37
+ | `dhash`, perceptual image hash | re-encoding and resizing of textures and art |
38
+ | `markers`, embedded notice or signed `grantstamp.json` | anything that keeps strings; also visible to agents reading the file |
39
+
40
+ Matches are graded **exact > high > medium > low**. Only high and exact can produce a hard *deny*. A medium-confidence match turns the owner's *deny* into *ask*.
41
+
42
+ ## Quick start
43
+
44
+ ```bash
45
+ pip install grantstamp # client, CLI, MCP server, agent hook (Apache-2.0)
46
+ pip install grantstamp-server # only to run a registry (AGPL-3.0)
47
+ python examples/demo.py # the whole story, locally, in ~10 seconds (needs both)
48
+ ```
49
+
50
+ ### Owners
51
+
52
+ ```bash
53
+ grantstamp keygen # your identity: ~/.grantstamp/owner.key
54
+ grantstamp owner create --name "Starfall Studio" --url https://starfall.example
55
+ grantstamp owner domain starfall.example # prints a DNS TXT record / .well-known file
56
+ grantstamp owner verify starfall.example
57
+ grantstamp register ./build --title "Starfall Courier" --version 0.9.4 \
58
+ --preset standard --contact legal@starfall.example --manifest
59
+ grantstamp marker stamp_… --lang cpp # notice to compile into the next build
60
+ grantstamp owner webhook https://hooks.slack.com/services/… --format slack
61
+ grantstamp token issue --stamp stamp_… --to "PortCo" --uses port,modify --days 90
62
+ grantstamp alerts
63
+ ```
64
+
65
+ ### AI agents and tools
66
+
67
+ - **MCP server** (Claude Desktop, Claude Code, Cursor, VS Code): run `pip install grantstamp`, then point your client at the `grantstamp-mcp` command. See [integrations/](integrations/).
68
+ - **Claude Code hook**: `grantstamp-hook` runs before Read, Edit and Bash on binaries and game files. It denies, asks or allows based on the owner's policy. See [integrations/claude-code](integrations/claude-code/README.md).
69
+ - **HTTP API**: `POST /v1/check`. Sign requests with RFC 9421 HTTP Message Signatures (Web Bot Auth compatible) for higher limits. See [spec/grantstamp-protocol-v0.1.md](spec/grantstamp-protocol-v0.1.md).
70
+ - **Command line**: `grantstamp check path/to/file --use port --exit-code`.
71
+ - **Browser**: the website's check page fingerprints a file in the browser; the file never leaves it.
72
+
73
+ ### Run a registry
74
+
75
+ ```bash
76
+ pip install "grantstamp-server[postgres]"
77
+ grantstamp serve --host 0.0.0.0 --port 8000 --db sqlite:///grantstamp.db --public-url https://registry.example
78
+ # or: docker compose up -d (Caddy + HTTPS), or render.yaml + a free Neon Postgres: docs/05-integrations.md
79
+ ```
80
+
81
+ ## Benchmark (prototype scale)
82
+
83
+ The full results are in [bench/RESULTS.md](bench/RESULTS.md), reproducible with `python bench/run_bench.py`.
84
+
85
+ - **Detection.** A toy game was recompiled with gcc and clang at -O0 to -O3 with LTO, stripped, byte-patched, given half-rewritten strings, ported as a folder, or turned into synthetic decompiler output. Every variant matched **high** or **exact**.
86
+ - **Cross-matches.** 400 Linux system executables were checked against 60 others registered under 60 owners. There were **0 medium-or-higher matches across different source packages**. All 21 medium or high matches were programs from the same source package, which really do share code.
87
+
88
+ ## Documentation
89
+
90
+ | | |
91
+ | --- | --- |
92
+ | [01 Problem](docs/01-problem.md) | What happened, why speed matters, where safeguards fail |
93
+ | [02 Solutions](docs/02-solutions.md) | Each original idea, what breaks, the fix that holds |
94
+ | [03 Architecture](docs/03-architecture.md) | Components, data flow, security boundaries |
95
+ | [04 Implementation](docs/04-implementation.md) | Algorithms, scoring, API and CLI reference |
96
+ | [05 Integrations](docs/05-integrations.md) | Every account and service needed, step by step |
97
+ | [Threat model](docs/threat-model.md) · [Spec](spec/grantstamp-protocol-v0.1.md) | Attacks and mitigations; the protocol |
98
+
99
+ ## What Grantstamp is not
100
+
101
+ It is not DRM and not a court. It does not stop leaks, make anything uncrackable or decide what is legal. It puts the owner's signed claim and policy in front of a cooperating agent at the moment it is about to act, and tells the owner fast.
102
+
103
+ ## License
104
+
105
+ The client library, CLI, MCP server, agent hook and website are Apache-2.0 ([LICENSE](LICENSE)). The registry server in [server/](server/) (`grantstamp-server`) is AGPL-3.0-only ([server/LICENSE](server/LICENSE)): anyone who runs a modified copy for others must publish their changes. Agents and tools that only check the registry need only the Apache-2.0 client. The protocol specification is CC BY 4.0.
106
+
107
+ Copyright 2026 The Grantstamp Authors. "Grantstamp" and the Grantstamp seal are trademarks of the project owner; neither licence grants trademark rights. See [TRADEMARK.md](TRADEMARK.md).
@@ -0,0 +1,55 @@
1
+ # 1. The problem
2
+
3
+ AI coding agents compress the engineering work of reverse engineering and porting from months or years into hours or days. Owners have no machine-readable way to tell those agents "this is mine, and this is what I allow." So the agents either help everyone, pirates included, or fall back on blunt rules that also block the owner's own people.
4
+
5
+ ## What happened with GTA VI (as of November 26, 2026)
6
+
7
+ | Date (2026) | Event |
8
+ | --- | --- |
9
+ | Nov 25 | Surviving forks report menus and world loading at very low frame rates; no verified playable build ([XDA](https://www.xda-developers.com/new-frontrunner-race-to-unofficially-bring-gta6-to-pc-already-hitting-5-7fps/)) |
10
+ | Nov 24 | GitHub processes Take-Two's DMCA notice and disables the Leonida project and its network of 3,007 repositories ([MLQ](https://mlq.ai/news/take-twos-dmca-notice-takes-down-gta-vi-pc-port-and-3007-github-repos/)) |
11
+ | Nov 23 | The leaked build's main executable appears. Within about three hours an unofficial build reaches the settings and legal screens ([TweakTown](https://www.tweaktown.com/news/114839/gta-6-boots-on-pc-only-3-hours-after-xbox-executable-leaked/index.html)) |
12
+ | Nov 21 | The Leonida recompilation repository opens |
13
+ | Nov 20 | A leaker posts an Xbox build without its executable. Take-Two's notice later calls these stolen game files ([TweakTown](https://www.tweaktown.com/news/114877/gta-6-pc-port-takedown-confirmed-take-two-cites-rockstars-ban-on-reverse-engineering/index.html)) |
14
+ | Nov 19 | GTA VI launches on PS5 and Xbox Series X\|S with no PC date |
15
+
16
+ PC Gamer described AI coding tools turning static-recompilation work that used to take months or years into hours or days ([PC Gamer](https://www.pcgamer.com/games/grand-theft-auto/gta-6-recomp-explained/)).
17
+
18
+ Three corrections keep the story honest:
19
+
20
+ 1. **The trigger was a leak of a stolen build.** AI did not break console security; it sped up the engineering after the theft.
21
+ 2. **Nobody has shown a playable port, and no revenue loss has been measured.**
22
+ 3. **The owner did respond**, three days after the repository opened, but only after the work was public and forked thousands of times.
23
+
24
+ ## Why speed is the real issue
25
+
26
+ A study of 86 Denuvo-protected Steam games found about a 20% average revenue loss when protection was cracked very early, and almost none when it held for twelve weeks ([Notebookcheck on Volckmann's study](https://www.notebookcheck.net/Decoding-Denuvo-s-impact-How-DRM-shields-early-game-revenue-by-up-to-20-percent.901313.0.html)). The money is lost in the window before an owner can respond. AI shrinks the attacker's time; nothing has shrunk the owner's.
27
+
28
+ ## Why today's AI safeguards are not enough
29
+
30
+ In late October 2026 Anthropic added a Claude Code rule steering the model away from recreating specific existing games. Developers then reported refusals on their own and on commissioned work ([Tom's Hardware](https://www.tomshardware.com/tech-industry/artificial-intelligence/anthropic-confirms-new-claude-code-limits-to-prevent-game-cloning-users-report-opus-5-5-is-also-actively-blocking-reverse-engineering-tasks)). A rule that cannot see the owner has two failures at once:
31
+
32
+ - it blocks licensees, contractors and the owner's own developers;
33
+ - it misses renamed or lightly disguised copies.
34
+
35
+ Providers need precise, owner-supplied data: who owns this, what do they allow, and is this user a licensee?
36
+
37
+ ## The gap
38
+
39
+ Rights infrastructure exists for media and for AI training. Examples are ISCC (ISO 24138), C2PA content credentials, RSL licensing terms, IETF AI preferences, Liccium's TDM·AI registry and the EU's opt-out registry study. None of it lets an agent ask, at task time and about a user-supplied executable or game build, "may I work on this file?" Grantstamp fills that column:
40
+
41
+ | Content type | Training | Inference / retrieval | **Agent operating on user-supplied files** | Output |
42
+ | --- | --- | --- | --- | --- |
43
+ | Text, images, audio, video | served | partly | not served | served |
44
+ | Source code | partly | partly | blunt rules only | partly |
45
+ | **Executables, game builds, firmware** | not served | not served | **not served (Grantstamp)** | after-the-fact takedowns |
46
+
47
+ ## What Grantstamp does and does not do
48
+
49
+ Grantstamp is not DRM and not a court. It does not stop leaks or decide what is legal. It does three things:
50
+
51
+ 1. Lets owners publish a signed claim and a per-use policy, without publishing content.
52
+ 2. Lets cooperating agents check quickly and privately before they act, and lets licensees through.
53
+ 3. Tells the owner within seconds when their content shows up in an agent's workflow, including someone probing for what no longer matches.
54
+
55
+ The goal is to give the owner back the response window that AI took away.
@@ -0,0 +1,120 @@
1
+ # 2. Issues and solutions that hold
2
+
3
+ The original idea has six parts:
4
+
5
+ - owners publish a fingerprint of their content;
6
+ - LLMs resolve ownership before working on a file;
7
+ - nobody can bypass it;
8
+ - a math puzzle tells LLMs from humans;
9
+ - owners sign in with LinkedIn;
10
+ - pricing is per identity.
11
+
12
+ Each part was tested against how it would fail. Where it holds, it stays. Where it breaks, it is replaced with something that holds. Everything below is implemented in this repository.
13
+
14
+ ## 2.1 "One fingerprint that can never be changed"
15
+
16
+ **What breaks.** No such fingerprint exists. Recompiling, porting to another platform, stripping symbols or patching changes the bytes. Embedded watermarks can be removed. Published research shows fuzzy hashes and ML binary-similarity models are attackable or generalise poorly.
17
+
18
+ **What holds: a layered identity with graded evidence.** Each file gets several independent fingerprints, each surviving a different kind of change:
19
+
20
+ | Layer | Survives | Weakness |
21
+ | --- | --- | --- |
22
+ | SHA-256 | nothing (exact copies) | any byte change |
23
+ | Content-defined chunks | patches, insertions, embedding in a larger file | recompiling |
24
+ | Strings (sentences, paths, format strings, literals) | recompiling, other compilers, stripping, porting, **decompiling** (decompiled C still contains the literals) | deliberate rewriting of all text |
25
+ | Symbols (identifier-like strings) | the same | shared by everything linking the same library, so stricter thresholds |
26
+ | Code winnowing (MOSS-style) | reformatting, renaming variables | rewriting the logic |
27
+ | Image dHash | re-encoding, resizing | heavy edits |
28
+ | Embedded marker / signed manifest | anything that keeps strings | deliberate removal |
29
+
30
+ Evidence is graded into bands: **exact > high > medium > low**. The registry never says "owned"; it says how strong the evidence is. On the benchmark, every recompiled, stripped, patched, ported and decompiled variant scored high or exact ([bench/RESULTS.md](../bench/RESULTS.md)).
31
+
32
+ ## 2.2 "No user can bypass it"
33
+
34
+ **What breaks.** Only cooperating agents check. An open-weight model running offline will never query a registry.
35
+
36
+ **What holds: make checking the easy default where it matters, and give owners speed.**
37
+ - An MCP server, a Claude Code hook, a Python client and an HTTP API, so any mainstream agent can check in a single step.
38
+ - An **AI-readable notice** compiled into the owner's builds. Agents reading the file see a plain-language instruction to check first, and cooperating agents follow it.
39
+ - **Alerts within seconds** when the owner's content appears in a check, including probing patterns. That is the response window the owner lacked.
40
+ - A value proposition for AI providers: precise allow/deny data reduces their false refusals. That gives them a reason to integrate.
41
+
42
+ ## 2.3 "A math problem proves the caller is an LLM"
43
+
44
+ **What breaks.** A puzzle proves someone spent compute, not that the caller is an LLM. Scripts solve puzzles faster than LLMs do, and humans can run scripts.
45
+
46
+ **What holds: tiered access by identity, plus the puzzle repurposed as a cost.**
47
+ - *Anonymous* callers get coarse answers and low rate limits.
48
+ - *Registered agents* sign every request with Ed25519 (RFC 9421 HTTP Message Signatures; Web Bot Auth compatible) and get higher limits.
49
+ - *Trusted providers*, approved by the operator, see full evidence.
50
+ - **Your puzzle idea survives as proof-of-work quota relief.** An anonymous caller who hits the limit can solve a short hashcash challenge (about a second) for extra quota. Bulk probing becomes expensive while occasional users are not blocked. Challenges are stateless, HMAC-signed and single-use.
51
+
52
+ ## 2.4 "Answer every lookup in full detail"
53
+
54
+ **What breaks.** A detailed answer turns the registry into an oracle. An attacker edits a file and re-checks until it stops matching.
55
+
56
+ **What holds:**
57
+ - anonymous callers see bands only (no scores, no per-layer evidence), and low bands are hidden from them;
58
+ - fingerprints are stored server-side and never downloadable;
59
+ - rate limits per caller, with proof-of-work for anonymous relief;
60
+ - **probing alerts**: five near-miss checks against one stamp from one caller within an hour alert the owner;
61
+ - every check is an event the owner can see, with the caller stored as a salted hash.
62
+
63
+ ## 2.5 "Sign in with LinkedIn to prove ownership"
64
+
65
+ **What breaks.** LinkedIn proves an account, not ownership of content.
66
+
67
+ **What holds:**
68
+ - **Owner key pairs.** The owner's Ed25519 key is their identity, and every management request is signed with it.
69
+ - **Domain verification.** The owner proves control of the domain that publishes the content, with a DNS TXT record or a `.well-known` file. Verified owners are shown as verified and rank first.
70
+ - **Conflict detection.** Registering content that already matches another owner's stamp at high or exact marks the new stamp as a *conflict* and alerts both owners.
71
+ - **Disputes** have a public form, and every decision is logged.
72
+ - Planned: code-signing certificate challenges and store-publisher proof.
73
+
74
+ ## 2.6 "Refuse if the content is owned"
75
+
76
+ **What breaks.** Ownership is not permission. Licensees, porting partners, security researchers and interoperability work are often lawful or explicitly allowed. A blanket refusal blocks them; that is exactly the false-refusal problem providers already have.
77
+
78
+ **What holds: policies, purposes and licence tokens.**
79
+ - A policy per use (analyze, decompile, modify, port, extract, redistribute, train), each set to allow, ask or deny, with presets.
80
+ - **Accepted purposes**: the owner can allow interoperability, security research, preservation, accessibility, education or personal backup even where a use is otherwise denied. The caller declares the purpose and the receipt records it.
81
+ - **Licence tokens**: the owner signs a token for a licensee, naming the stamps, uses and expiry. Agents send it, and *deny* becomes *allow (licensed)*. Tokens can be revoked.
82
+ - **Evidence-proportional enforcement**: only high or exact matches can produce a hard deny. A medium match turns deny into ask, because shared engines and libraries can cause overlap.
83
+ - The registry reports the owner's claim and policy. It does not decide legality, and the guidance text says so.
84
+
85
+ ## 2.7 "Keep the identity secure, even from frontier LLMs"
86
+
87
+ **What holds:**
88
+ - No LLM in the registry path. Storage, scoring, policy decisions and keys are deterministic code.
89
+ - Fingerprints are never served back.
90
+ - Every answer carries a **receipt signed by the registry**, so agents can keep evidence of diligence.
91
+ - A **hash-chained transparency log** covers every registration, policy change, revocation and dispute, with a signed head. A daily GitHub Action commits the head to the public repository, so history cannot be quietly rewritten.
92
+
93
+ ## 2.8 "Price per identity"
94
+
95
+ **What breaks.** One game build is tens of thousands of files and many versions. Per-file pricing punishes the customers who need it most.
96
+
97
+ **What holds.** A **stamp** covers a whole title or release, with all its files (uploads are split automatically). Registration is free at launch. When billing comes, price per stamp or per catalogue tier, not per file.
98
+
99
+ ## 2.9 Privacy of the people checking
100
+
101
+ - Clients send only digests computed locally. Content is never uploaded, and the website's check runs in the browser.
102
+ - Callers are stored as salted hashes, and query bundles are not stored (only a digest).
103
+ - Exact hashes can be checked by a 5-character prefix (k-anonymity, as Have I Been Pwned does).
104
+
105
+ ## 2.10 Cold start
106
+
107
+ Owners get value on day one, before any AI provider integrates:
108
+ - a timestamped, signed, publicly witnessed registration;
109
+ - an embedded notice that agents read;
110
+ - alerts from the MCP server, the hook and the website;
111
+ - an open spec and open-source client that others can adopt.
112
+
113
+ AI providers get a free API that reduces false refusals.
114
+
115
+ ## Known limits (stated plainly)
116
+
117
+ - A clean-room rewrite with new text, new assets and new code will not match, and is often lawful anyway.
118
+ - Two products built on the same engine can match at medium until engine "background packs" exist; owners should also exclude third-party files (done by default for common runtimes).
119
+ - The background lists in v0.1 were built from Linux system binaries plus a curated Windows list; Windows, console and engine corpora come next.
120
+ - A determined attacker who controls the whole pipeline can always avoid checking. Grantstamp raises the cost and shortens the owner's response time; it does not make anything uncrackable.