rooted-sbr 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.
@@ -0,0 +1,75 @@
1
+ # --- Secrets (NEVER commit) ---
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+ *.pem
6
+ *.key
7
+ # Public C2PA conformance TEST trust anchors (no private key; the certs are marked FOR TESTING_ONLY).
8
+ # Whitelisted past the blanket *.pem rule so the trusted-path demo can ship them.
9
+ !packages/provenance/rooted_provenance/conformance/anchors.pem
10
+ !web/public/c2pa-trust/anchors.pem
11
+ id_rsa
12
+ service-account*.json
13
+ .npmrc
14
+ .pypirc
15
+
16
+ # --- Local working material (strategy, private framework, third-party content) ---
17
+ # research/ holds strategy PDFs, the private methodology, the nk.studio crawl, and the idea
18
+ # writeup. None of it belongs in a public repo (internal-process + third-party content rules).
19
+ research/
20
+
21
+ # --- Claude Code local ---
22
+ .claude/settings.local.json
23
+ .claude/worktrees/
24
+
25
+ # --- Python ---
26
+ __pycache__/
27
+ *.py[cod]
28
+ *.egg-info/
29
+ .venv/
30
+ venv/
31
+ .pytest_cache/
32
+ .mypy_cache/
33
+ .ruff_cache/
34
+ .hypothesis/
35
+ .coverage
36
+ htmlcov/
37
+ .python-version
38
+
39
+ # --- Node / Next.js / Turborepo ---
40
+ node_modules/
41
+ .next/
42
+ out/
43
+ dist/
44
+ build/
45
+ .turbo/
46
+ *.tsbuildinfo
47
+ .vercel/
48
+
49
+ # --- Playwright MCP scratch output (screenshots, snapshots, console logs) ---
50
+ .playwright-mcp/
51
+
52
+ # --- Local demo/beat screenshots (kept local for the submission gallery, never committed) ---
53
+ /beat-*.png
54
+
55
+ # --- Model weights / large binaries (use external hosting, not git) ---
56
+ *.pt
57
+ *.pth
58
+ *.onnx
59
+ *.safetensors
60
+ trustmark_weights/
61
+
62
+ # --- OS / IDE ---
63
+ .DS_Store
64
+ .AppleDouble
65
+ ._*
66
+ .vscode/
67
+ .idea/
68
+ *.swp
69
+
70
+ # --- Logs / temp ---
71
+ *.log
72
+ tmp/
73
+ .cache/
74
+
75
+ # DO commit lockfiles: uv.lock, pnpm-lock.yaml are tracked on purpose.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works.
111
+
112
+ You may add Your own copyright statement to Your modifications and
113
+ may provide additional or different license terms and conditions
114
+ for use, reproduction, or distribution of Your modifications, or
115
+ for any such Derivative Works as a whole, provided Your use,
116
+ reproduction, and distribution of the Work otherwise complies with
117
+ the conditions stated in this License.
118
+
119
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
120
+ any Contribution intentionally submitted for inclusion in the Work
121
+ by You to the Licensor shall be under the terms and conditions of
122
+ this License, without any additional terms or conditions.
123
+ Notwithstanding the above, nothing herein shall supersede or modify
124
+ the terms of any separate license agreement you may have executed
125
+ with Licensor regarding such Contributions.
126
+
127
+ 6. Trademarks. This License does not grant permission to use the trade
128
+ names, trademarks, service marks, or product names of the Licensor,
129
+ except as required for reasonable and customary use in describing the
130
+ origin of the Work and reproducing the content of the NOTICE file.
131
+
132
+ 7. Disclaimer of Warranty. Unless required by applicable law or
133
+ agreed to in writing, Licensor provides the Work (and each
134
+ Contributor provides its Contributions) on an "AS IS" BASIS,
135
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
136
+ implied, including, without limitation, any warranties or conditions
137
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
138
+ PARTICULAR PURPOSE. You are solely responsible for determining the
139
+ appropriateness of using or redistributing the Work and assume any
140
+ risks associated with Your exercise of permissions under this License.
141
+
142
+ 8. Limitation of Liability. In no event and under no legal theory,
143
+ whether in tort (including negligence), contract, or otherwise,
144
+ unless required by applicable law (such as deliberate and grossly
145
+ negligent acts) or agreed to in writing, shall any Contributor be
146
+ liable to You for damages, including any direct, indirect, special,
147
+ incidental, or consequential damages of any character arising as a
148
+ result of this License or out of the use or inability to use the
149
+ Work (including but not limited to damages for loss of goodwill,
150
+ work stoppage, computer failure or malfunction, or any and all
151
+ other commercial damages or losses), even if such Contributor
152
+ has been advised of the possibility of such damages.
153
+
154
+ 9. Accepting Warranty or Additional Liability. While redistributing
155
+ the Work or Derivative Works thereof, You may choose to offer,
156
+ and charge a fee for, acceptance of support, warranty, indemnity,
157
+ or other liability obligations and/or rights consistent with this
158
+ License. However, in accepting such obligations, You may act only
159
+ on Your own behalf and on Your sole responsibility, not on behalf
160
+ of any other Contributor, and only if You agree to indemnify,
161
+ defend, and hold each Contributor harmless for any liability
162
+ incurred by, or claims asserted against, such Contributor by reason
163
+ of your accepting any such warranty or additional liability.
164
+
165
+ END OF TERMS AND CONDITIONS
166
+
167
+ APPENDIX: How to apply the Apache License to your work.
168
+
169
+ To apply the Apache License to your work, attach the following
170
+ boilerplate notice, with the fields enclosed by brackets "[]"
171
+ replaced with your own identifying information. (Don't include
172
+ the brackets!) The text should be enclosed in the appropriate
173
+ comment syntax for the file format. We also recommend that a
174
+ file or class name and description of purpose be included on the
175
+ same "printed page" as the copyright notice for easier
176
+ identification within third-party archives.
177
+
178
+ Copyright 2026 The Rooted Authors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: rooted-sbr
3
+ Version: 0.1.0
4
+ Summary: Rooted SBR CLI: recover C2PA provenance for stripped media from the command line
5
+ Project-URL: Homepage, https://rooted-web-phi.vercel.app
6
+ Project-URL: Repository, https://github.com/StephenSook/rooted
7
+ Project-URL: Live API, https://rooted-api-ubvc.onrender.com
8
+ Author: Stephen Sookra
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: ai,c2pa,content-credentials,provenance,sbr,soft-binding,watermark
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Multimedia :: Graphics
18
+ Classifier: Topic :: Security
19
+ Requires-Python: <3.14,>=3.11
20
+ Requires-Dist: httpx>=0.27
21
+ Requires-Dist: typer>=0.12
22
+ Description-Content-Type: text/markdown
23
+
24
+ # rooted-sbr
25
+
26
+ Recover stripped C2PA provenance for AI-generated media from your terminal.
27
+
28
+ `rooted-sbr` is the command-line client for [Rooted](https://github.com/StephenSook/rooted), an
29
+ open, vendor-neutral C2PA Soft Binding Resolution (SBR) server backed by Backblaze B2. When an image
30
+ loses its embedded C2PA manifest (after a screenshot or a re-encode), Rooted recovers the signed
31
+ provenance by matching an invisible watermark or a perceptual-hash fingerprint, and returns it with
32
+ a tamper-evident transparency-log proof.
33
+
34
+ The CLI talks to the same public SBR API the web client and the MCP server use. It defaults to the
35
+ live deploy; nothing is mocked, every command hits the real service.
36
+
37
+ ## Install
38
+
39
+ ```
40
+ pip install rooted-sbr
41
+ ```
42
+
43
+ ## Use
44
+
45
+ ```
46
+ # recover the provenance of a (possibly stripped) image
47
+ rooted recover stripped.jpg
48
+
49
+ # fetch a recovered manifest by id (system provenance only; personal provenance withheld)
50
+ rooted manifest urn:c2pa:demo-0000-0000-0000-000000000001
51
+
52
+ # the transparency-log inclusion proof for a manifest
53
+ rooted proof urn:c2pa:demo-0000-0000-0000-000000000001
54
+
55
+ # the advertised soft-binding algorithms, and the live service status
56
+ rooted algorithms
57
+ rooted status
58
+ ```
59
+
60
+ Point it at your own Rooted instance with `--api-url` or the `ROOTED_API_URL` environment variable.
61
+
62
+ Provenance proves origin, not truth.
63
+
64
+ ## License
65
+
66
+ Apache-2.0.
@@ -0,0 +1,43 @@
1
+ # rooted-sbr
2
+
3
+ Recover stripped C2PA provenance for AI-generated media from your terminal.
4
+
5
+ `rooted-sbr` is the command-line client for [Rooted](https://github.com/StephenSook/rooted), an
6
+ open, vendor-neutral C2PA Soft Binding Resolution (SBR) server backed by Backblaze B2. When an image
7
+ loses its embedded C2PA manifest (after a screenshot or a re-encode), Rooted recovers the signed
8
+ provenance by matching an invisible watermark or a perceptual-hash fingerprint, and returns it with
9
+ a tamper-evident transparency-log proof.
10
+
11
+ The CLI talks to the same public SBR API the web client and the MCP server use. It defaults to the
12
+ live deploy; nothing is mocked, every command hits the real service.
13
+
14
+ ## Install
15
+
16
+ ```
17
+ pip install rooted-sbr
18
+ ```
19
+
20
+ ## Use
21
+
22
+ ```
23
+ # recover the provenance of a (possibly stripped) image
24
+ rooted recover stripped.jpg
25
+
26
+ # fetch a recovered manifest by id (system provenance only; personal provenance withheld)
27
+ rooted manifest urn:c2pa:demo-0000-0000-0000-000000000001
28
+
29
+ # the transparency-log inclusion proof for a manifest
30
+ rooted proof urn:c2pa:demo-0000-0000-0000-000000000001
31
+
32
+ # the advertised soft-binding algorithms, and the live service status
33
+ rooted algorithms
34
+ rooted status
35
+ ```
36
+
37
+ Point it at your own Rooted instance with `--api-url` or the `ROOTED_API_URL` environment variable.
38
+
39
+ Provenance proves origin, not truth.
40
+
41
+ ## License
42
+
43
+ Apache-2.0.
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "rooted-sbr"
3
+ version = "0.1.0"
4
+ description = "Rooted SBR CLI: recover C2PA provenance for stripped media from the command line"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11,<3.14"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "Stephen Sookra" }]
10
+ keywords = ["c2pa", "provenance", "watermark", "soft-binding", "sbr", "ai", "content-credentials"]
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Environment :: Console",
14
+ "Intended Audience :: Developers",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3",
17
+ "Topic :: Multimedia :: Graphics",
18
+ "Topic :: Security",
19
+ ]
20
+ dependencies = [
21
+ "httpx>=0.27",
22
+ "typer>=0.12",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://rooted-web-phi.vercel.app"
27
+ Repository = "https://github.com/StephenSook/rooted"
28
+ "Live API" = "https://rooted-api-ubvc.onrender.com"
29
+
30
+ [project.scripts]
31
+ rooted = "rooted_cli.main:main"
32
+
33
+ [build-system]
34
+ requires = ["hatchling"]
35
+ build-backend = "hatchling.build"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["rooted_cli"]
@@ -0,0 +1 @@
1
+ """Rooted SBR CLI: recover C2PA provenance for stripped media from the command line."""
@@ -0,0 +1,132 @@
1
+ """Rooted SBR CLI: recover C2PA provenance for stripped media from your terminal.
2
+
3
+ Wraps the public Rooted Soft Binding Resolution API (the same spec endpoints the web client and the
4
+ MCP server use). Defaults to the live deploy; override with --api-url or the ROOTED_API_URL env var.
5
+
6
+ pip install ./cli
7
+ rooted recover stripped.jpg
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import mimetypes
14
+ from pathlib import Path
15
+ from typing import Annotated, Any
16
+
17
+ import httpx
18
+ import typer
19
+
20
+ DEFAULT_API = "https://rooted-api-ubvc.onrender.com"
21
+
22
+ app = typer.Typer(
23
+ help="Recover stripped C2PA provenance via the Rooted SBR API.",
24
+ no_args_is_help=True,
25
+ add_completion=False,
26
+ )
27
+
28
+ _state: dict[str, str] = {"api_url": DEFAULT_API}
29
+
30
+
31
+ @app.callback()
32
+ def _root(
33
+ api_url: Annotated[
34
+ str, typer.Option("--api-url", envvar="ROOTED_API_URL", help="SBR API base URL")
35
+ ] = DEFAULT_API,
36
+ ) -> None:
37
+ _state["api_url"] = api_url.rstrip("/")
38
+
39
+
40
+ def _client() -> httpx.Client:
41
+ return httpx.Client(base_url=_state["api_url"], timeout=30.0)
42
+
43
+
44
+ def _print_json(label: str, data: Any) -> None:
45
+ typer.echo(f"{label}: {json.dumps(data, indent=2)}")
46
+
47
+
48
+ @app.command()
49
+ def recover(
50
+ image: Annotated[Path, typer.Argument(exists=True, dir_okay=False, readable=True)],
51
+ ) -> None:
52
+ """Recover the signed provenance manifest for a (possibly stripped) image, by fingerprint."""
53
+ mime = mimetypes.guess_type(image.name)[0] or "image/jpeg"
54
+ try:
55
+ with _client() as c:
56
+ r = c.post("/matches/byContent", files={"file": (image.name, image.read_bytes(), mime)})
57
+ r.raise_for_status()
58
+ matches = r.json().get("matches", [])
59
+ if not matches:
60
+ typer.secho("No provenance recovered: this asset is not in the registry.", fg="red")
61
+ raise typer.Exit(1)
62
+ match = matches[0]
63
+ manifest_id = match["manifestId"]
64
+ score = match.get("similarityScore")
65
+ tail = f" (similarity {score}/100)" if score is not None else ""
66
+ typer.secho(f"RECOVERED {manifest_id}{tail}", fg="green")
67
+ details = c.get(f"/manifests/{manifest_id}")
68
+ details.raise_for_status()
69
+ body = details.json()
70
+ provenance = body.get("systemProvenance", {})
71
+ typer.echo(f" created: {body.get('createdAt')}")
72
+ typer.echo(f" model: {provenance.get('model')}")
73
+ typer.echo(f" provider: {provenance.get('provider')}")
74
+ typer.echo(f" generator: {provenance.get('generator')}")
75
+ except httpx.HTTPError as exc:
76
+ typer.secho(f"request failed: {exc}", fg="red")
77
+ raise typer.Exit(2) from exc
78
+
79
+
80
+ @app.command()
81
+ def manifest(manifest_id: str) -> None:
82
+ """Fetch a recovered manifest by id (system provenance only; personal provenance withheld)."""
83
+ with _client() as c:
84
+ r = c.get(f"/manifests/{manifest_id}")
85
+ if r.status_code == 404:
86
+ typer.secho("manifest not found", fg="red")
87
+ raise typer.Exit(1)
88
+ r.raise_for_status()
89
+ _print_json("manifest", r.json())
90
+
91
+
92
+ @app.command()
93
+ def proof(manifest_id: str) -> None:
94
+ """Fetch the transparency-log inclusion proof for a manifest."""
95
+ with _client() as c:
96
+ r = c.get(f"/transparency/proof/{manifest_id}")
97
+ if r.status_code == 404:
98
+ typer.secho("no proof for that manifest", fg="red")
99
+ raise typer.Exit(1)
100
+ r.raise_for_status()
101
+ _print_json("proof", r.json())
102
+
103
+
104
+ @app.command()
105
+ def algorithms() -> None:
106
+ """List the advertised soft-binding algorithms (the registered watermark; PDQ is internal)."""
107
+ with _client() as c:
108
+ r = c.get("/services/supportedAlgorithms")
109
+ r.raise_for_status()
110
+ _print_json("supportedAlgorithms", r.json())
111
+
112
+
113
+ @app.command()
114
+ def status() -> None:
115
+ """Show the live SBR service status (recovery index, transparency tree, self-test)."""
116
+ with _client() as c:
117
+ r = c.get("/status")
118
+ r.raise_for_status()
119
+ body = r.json()
120
+ tx = body.get("transparency", {})
121
+ st = body.get("recoverySelfTest", {})
122
+ typer.echo(f"recovery index: {body.get('recoveryIndex')}")
123
+ typer.echo(f"transparency: {tx.get('treeSize')} leaves, key {tx.get('keySource')}")
124
+ typer.echo(f"self-test: recovered={st.get('recovered')} sim={st.get('similarityScore')}")
125
+
126
+
127
+ def main() -> None:
128
+ app()
129
+
130
+
131
+ if __name__ == "__main__":
132
+ main()
File without changes
@@ -0,0 +1,68 @@
1
+ """The Rooted SBR CLI, with the API mocked (respx) so tests are deterministic and network-free."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ import respx
8
+ from httpx import Response
9
+ from typer.testing import CliRunner
10
+
11
+ from rooted_cli.main import DEFAULT_API, app
12
+
13
+ runner = CliRunner()
14
+
15
+
16
+ @respx.mock
17
+ def test_recover_renders_verified(tmp_path: Path) -> None:
18
+ img = tmp_path / "x.jpg"
19
+ img.write_bytes(b"\xff\xd8jpeg")
20
+ respx.post(f"{DEFAULT_API}/matches/byContent").mock(
21
+ return_value=Response(
22
+ 200, json={"matches": [{"manifestId": "urn:c2pa:demo", "similarityScore": 100}]}
23
+ )
24
+ )
25
+ respx.get(f"{DEFAULT_API}/manifests/urn:c2pa:demo").mock(
26
+ return_value=Response(
27
+ 200,
28
+ json={
29
+ "createdAt": "2026-06-27T00:00:00Z",
30
+ "systemProvenance": {"model": "seedream-5.0-lite"},
31
+ },
32
+ )
33
+ )
34
+ result = runner.invoke(app, ["recover", str(img)])
35
+ assert result.exit_code == 0, result.output
36
+ assert "RECOVERED" in result.output
37
+ assert "similarity 100/100" in result.output
38
+ assert "seedream-5.0-lite" in result.output
39
+
40
+
41
+ @respx.mock
42
+ def test_recover_no_match_exits_1(tmp_path: Path) -> None:
43
+ img = tmp_path / "x.jpg"
44
+ img.write_bytes(b"\xff\xd8")
45
+ respx.post(f"{DEFAULT_API}/matches/byContent").mock(
46
+ return_value=Response(200, json={"matches": []})
47
+ )
48
+ result = runner.invoke(app, ["recover", str(img)])
49
+ assert result.exit_code == 1
50
+ assert "not in the registry" in result.output
51
+
52
+
53
+ @respx.mock
54
+ def test_status_shows_recovery_index() -> None:
55
+ respx.get(f"{DEFAULT_API}/status").mock(
56
+ return_value=Response(
57
+ 200,
58
+ json={
59
+ "recoveryIndex": "postgres+hnsw",
60
+ "transparency": {"treeSize": 12, "keySource": "configured"},
61
+ "recoverySelfTest": {"recovered": True, "similarityScore": 100},
62
+ },
63
+ )
64
+ )
65
+ result = runner.invoke(app, ["status"])
66
+ assert result.exit_code == 0, result.output
67
+ assert "postgres+hnsw" in result.output
68
+ assert "12 leaves" in result.output