lighthouse-cli 0.17.2__tar.gz → 0.18.1__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 (73) hide show
  1. {lighthouse_cli-0.17.2/lighthouse_cli.egg-info → lighthouse_cli-0.18.1}/PKG-INFO +1 -1
  2. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/README.md +1 -0
  3. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/__init__.py +1 -1
  4. lighthouse_cli-0.18.1/lighthouse/commands/verify.py +275 -0
  5. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/ar.json +23 -1
  6. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/de.json +23 -1
  7. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/en.json +23 -1
  8. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/es.json +23 -1
  9. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/fr.json +23 -1
  10. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/ga.json +23 -1
  11. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/it.json +23 -1
  12. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/ja.json +23 -1
  13. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/nl.json +23 -1
  14. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/pt.json +23 -1
  15. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/zh-Hans.json +23 -1
  16. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/locales/zh-Hant.json +23 -1
  17. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/main.py +2 -1
  18. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1/lighthouse_cli.egg-info}/PKG-INFO +1 -1
  19. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse_cli.egg-info/SOURCES.txt +2 -0
  20. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/pyproject.toml +1 -1
  21. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_commands.py +60 -0
  22. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_golden.py +4 -0
  23. lighthouse_cli-0.18.1/tests/test_verify.py +197 -0
  24. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/LICENSE +0 -0
  25. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/NOTICE +0 -0
  26. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/__main__.py +0 -0
  27. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/__init__.py +0 -0
  28. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/agents.py +0 -0
  29. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/builds.py +0 -0
  30. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/collectors.py +0 -0
  31. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/connect.py +0 -0
  32. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/connections.py +0 -0
  33. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/evals.py +0 -0
  34. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/kb.py +0 -0
  35. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/language.py +0 -0
  36. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/limits.py +0 -0
  37. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/login.py +0 -0
  38. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/models.py +0 -0
  39. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/offline.py +0 -0
  40. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/runs.py +0 -0
  41. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/spend.py +0 -0
  42. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/stack.py +0 -0
  43. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/terms.py +0 -0
  44. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/commands/whoami.py +0 -0
  45. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/config.py +0 -0
  46. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/credentials.py +0 -0
  47. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/device.py +0 -0
  48. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/exits.py +0 -0
  49. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/flags.py +0 -0
  50. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/http.py +0 -0
  51. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/i18n.py +0 -0
  52. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/out.py +0 -0
  53. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/py.typed +0 -0
  54. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse/sealing.py +0 -0
  55. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse_cli.egg-info/dependency_links.txt +0 -0
  56. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse_cli.egg-info/entry_points.txt +0 -0
  57. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse_cli.egg-info/requires.txt +0 -0
  58. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/lighthouse_cli.egg-info/top_level.txt +0 -0
  59. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/setup.cfg +0 -0
  60. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_ci_credential.py +0 -0
  61. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_collectors.py +0 -0
  62. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_connect_erp_hr.py +0 -0
  63. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_connect_finav.py +0 -0
  64. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_connect_library.py +0 -0
  65. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_dev_surface.py +0 -0
  66. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_fixtures.py +0 -0
  67. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_i18n.py +0 -0
  68. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_installers.py +0 -0
  69. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_offline.py +0 -0
  70. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_plumbing.py +0 -0
  71. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_sealing.py +0 -0
  72. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_stack.py +0 -0
  73. {lighthouse_cli-0.17.2 → lighthouse_cli-0.18.1}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lighthouse-cli
3
- Version: 0.17.2
3
+ Version: 0.18.1
4
4
  Summary: The LightHouse command line: sign in, connect your estate, deploy agents, watch runs
5
5
  License-Expression: Apache-2.0
6
6
  Classifier: Programming Language :: Python :: 3
@@ -160,6 +160,7 @@ a terminal, and when `CI`, `NO_COLOR` or `TERM=dumb` is set.
160
160
  | `spend` | spend by day, model, pack, agent or connection; the forecast; the estimated savings |
161
161
  | `limits` | the limits in force, and whether the engines applied them |
162
162
  | `terms` | the commercial terms in force |
163
+ | `verify-answer <receipt.json> [--answer file] [--keys URL or file]` | check that an answer from Octy was signed and is unchanged: the receipt's Ed25519 signature, and with `--answer`, the answer text against its hash. A public Octy's receipt (documentation, company site) is checked against the keys published at `https://ask.atlanticagenticlabs.com/.well-known/octy-keys.json` (never a URL the receipt names), with no sign-in; a client Octy's receipt (portal or deployment) against the tenant's published keys, `GET /api/v1/octy/keys` (a portal receipt with LightHouse's key, a deployment receipt with that deployment's own) |
163
164
 
164
165
  ### A release gate in CI
165
166
 
@@ -3,4 +3,4 @@
3
3
  """The `lighthouse-ai` command line for LightHouse."""
4
4
  from __future__ import annotations
5
5
 
6
- __version__ = "0.17.2"
6
+ __version__ = "0.18.1"
@@ -0,0 +1,275 @@
1
+ # Copyright 2026 Atlantic Agentic Labs. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """`lighthouse-ai verify-answer`: check an answer from Octy against its signed receipt.
4
+
5
+ lighthouse-ai verify-answer octy-receipt-oar_xyz.json
6
+ lighthouse-ai verify-answer octy-receipt-oar_xyz.json --answer answer.txt
7
+ lighthouse-ai verify-answer receipt.json --keys octy-keys.json
8
+
9
+ Every answer Octy gives on Atlantic's documentation and company site comes
10
+ with a receipt, downloadable from the answer's evidence panel: hashes of the
11
+ question and the answer, each cited passage's URL and SHA-256, the corpus
12
+ version, how the answer was produced, the time, and the id of the Ed25519 key
13
+ that signed it. This command checks the signature against Atlantic's
14
+ published keys and, with `--answer`, that the answer text is the one signed.
15
+
16
+ **Which keys.** For a public Octy's receipt (`profile` docs or site, or an
17
+ Octy profile's), the keys are read by default from Atlantic's well-known URL,
18
+ `https://ask.atlanticagenticlabs.com/.well-known/octy-keys.json`, and never
19
+ from a URL the receipt names: a forged receipt could name its forger's keys.
20
+ A receipt whose issuer is not Atlantic's is refused unless `--keys` is given.
21
+ For a client Octy's receipt (`profile` portal or deployment, #48) the keys
22
+ are the tenant's, `GET /api/v1/octy/keys` read with this CLI's credential:
23
+ a portal receipt must verify with LightHouse's key, a deployment receipt
24
+ with that deployment's own. `--keys` takes another URL (https only) or a
25
+ saved copy of the keys file, and needs no sign-in.
26
+
27
+ **Versions.** A version 1 receipt (#47, #48) and a version 2 receipt
28
+ (0.18.1, contract 1.41) both verify. Version 2 also signs the display name of
29
+ the model that decided the answer, the tokens, the escalations and the
30
+ recorded cost (US dollars, and euros at the ECB rate of the day it was
31
+ issued), which this command prints. A version 2 receipt without those fields,
32
+ or with one of the wrong type, is refused as malformed.
33
+
34
+ **Rotation.** A receipt verifies while the key that signed it is listed,
35
+ current or retired. A key taken off the list no longer verifies anything.
36
+
37
+ **The signed bytes** are the receipt without `sig`, as canonical JSON: keys
38
+ sorted, no whitespace, UTF-8 with non-ASCII characters literal (RFC 8785 for
39
+ the values a receipt holds).
40
+
41
+ No credential is needed for a public receipt, and nothing is sent anywhere
42
+ but the keys URL (or, for a client receipt, the tenant's keys route).
43
+ Exit 0 when the receipt verifies (and the answer matches, if given); exit 1
44
+ otherwise, with a reason.
45
+ """
46
+ from __future__ import annotations
47
+
48
+ import argparse
49
+ import base64
50
+ import hashlib
51
+ import json
52
+ import re
53
+ import sys
54
+ from decimal import Decimal
55
+ from pathlib import Path
56
+ from typing import Any
57
+
58
+ import httpx
59
+ from cryptography.exceptions import InvalidSignature
60
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
61
+
62
+ from lighthouse.exits import FAILED, USAGE, CliError
63
+ from lighthouse.i18n import t
64
+ from lighthouse.main import Command, Context
65
+ from lighthouse.out import Out
66
+
67
+ ISSUER = "https://ask.atlanticagenticlabs.com"
68
+ CLIENT = ("portal", "deployment")
69
+ KEYS_URL = f"{ISSUER}/.well-known/octy-keys.json"
70
+ MAX_BYTES = 1024 * 1024
71
+ V2_FIELDS = ("model", "tokens_in", "tokens_out", "escalations", "cost_usd_nano", "cost_eur_nano", "fx_date")
72
+ _LABEL = re.compile(r"^[^\x00-\x1f\x7f]{1,80}$")
73
+ _DATE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
74
+
75
+
76
+ def _configure(ap: argparse.ArgumentParser) -> None:
77
+ ap.add_argument("receipt", metavar="RECEIPT",
78
+ help="the receipt file from the answer's evidence panel ('-' for standard input)")
79
+ ap.add_argument("--answer", metavar="FILE",
80
+ help="a file holding the answer's text, to check that it is the answer signed")
81
+ ap.add_argument("--keys", metavar="URL_OR_FILE",
82
+ help="the published keys, as an https URL or a saved file (default: Atlantic's well-known URL)")
83
+
84
+
85
+ def _b64u(text: str) -> bytes:
86
+ return base64.urlsafe_b64decode(text + "=" * (-len(text) % 4))
87
+
88
+
89
+ def _integers_only(value: Any) -> None:
90
+ """A receipt holds no floats (its canonical form is defined for integers only)."""
91
+ if isinstance(value, float):
92
+ raise ValueError("float")
93
+ for v in value.values() if isinstance(value, dict) else value if isinstance(value, list) else ():
94
+ _integers_only(v)
95
+
96
+
97
+ def canonical(value: Any) -> bytes:
98
+ return json.dumps(value, sort_keys=True, separators=(",", ":"), ensure_ascii=False,
99
+ allow_nan=False).encode("utf-8")
100
+
101
+
102
+ def _count(v: Any) -> bool:
103
+ return isinstance(v, int) and not isinstance(v, bool) and v >= 0
104
+
105
+
106
+ def _well_formed(receipt: dict[str, Any]) -> bool:
107
+ """Version 1 carries none of version 2's fields; version 2 carries all
108
+ seven with their types (contract 1.41)."""
109
+ v = receipt.get("v")
110
+ if isinstance(v, bool) or v not in (1, 2):
111
+ return False
112
+ if v == 1:
113
+ return not any(k in receipt for k in V2_FIELDS)
114
+ if any(k not in receipt for k in V2_FIELDS):
115
+ return False
116
+ m = receipt["model"]
117
+ if m is not None and not (isinstance(m, dict) and set(m) == {"provider", "name"}
118
+ and all(isinstance(m[k], str) and _LABEL.fullmatch(m[k]) for k in m)):
119
+ return False
120
+ if not all(_count(receipt[k]) for k in ("tokens_in", "tokens_out", "escalations", "cost_usd_nano")):
121
+ return False
122
+ eur, day = receipt["cost_eur_nano"], receipt["fx_date"]
123
+ if eur is None or day is None:
124
+ return eur is None and day is None
125
+ return _count(eur) and isinstance(day, str) and _DATE.fullmatch(day) is not None
126
+
127
+
128
+ def _amount(nanos: int) -> str:
129
+ """Billionths as a decimal, trailing zeros trimmed."""
130
+ if nanos == 0:
131
+ return "0"
132
+ return format(Decimal(nanos).scaleb(-9), "f").rstrip("0").rstrip(".")
133
+
134
+
135
+ def _read(ctx: Context, name: str) -> bytes:
136
+ try:
137
+ if name == "-":
138
+ stream = ctx.stdin or sys.stdin
139
+ raw = stream.buffer.read(MAX_BYTES + 1) if hasattr(stream, "buffer") else stream.read(MAX_BYTES + 1)
140
+ data = raw.encode() if isinstance(raw, str) else raw
141
+ else:
142
+ with Path(name).open("rb") as fh:
143
+ data = fh.read(MAX_BYTES + 1)
144
+ except OSError:
145
+ raise CliError(t("err.file_unreadable", name=name), code=USAGE, error="file_unreadable") from None
146
+ if len(data) > MAX_BYTES:
147
+ raise CliError(t("err.file_unreadable", name=name), code=USAGE, error="file_unreadable")
148
+ return data
149
+
150
+
151
+ def _load_receipt(ctx: Context, name: str) -> dict[str, Any]:
152
+ try:
153
+ doc = json.loads(_read(ctx, name))
154
+ except ValueError:
155
+ raise CliError(t("err.receipt_unreadable"), code=USAGE, error="receipt_unreadable") from None
156
+ # A saved response or fixture holds the receipt under "receipt".
157
+ if isinstance(doc, dict) and isinstance(doc.get("receipt"), dict):
158
+ doc = doc["receipt"]
159
+ if not isinstance(doc, dict) or doc.get("alg") != "Ed25519" or not isinstance(doc.get("sig"), str) \
160
+ or not isinstance(doc.get("kid"), str):
161
+ raise CliError(t("err.receipt_unreadable"), code=USAGE, error="receipt_unreadable")
162
+ if not _well_formed(doc):
163
+ raise CliError(t("err.receipt_malformed"), code=FAILED, error="receipt_malformed")
164
+ return doc
165
+
166
+
167
+ def _load_keys(ctx: Context, given: str | None, receipt: dict[str, Any]) -> tuple[dict[str, Any], str]:
168
+ if given is None and receipt.get("profile") in CLIENT:
169
+ doc = ctx.client().get("/api/v1/octy/keys")
170
+ if not isinstance(doc, dict) or not isinstance(doc.get("keys"), list):
171
+ raise CliError(t("err.keys_unavailable"), code=FAILED, error="keys_unavailable")
172
+ return dict(doc), "tenant"
173
+ if given is None and receipt.get("iss") != ISSUER:
174
+ raise CliError(t("err.receipt_issuer"), code=FAILED, error="receipt_issuer")
175
+ source = given or KEYS_URL
176
+ if source.startswith("https://"):
177
+ timeout = float(getattr(ctx.args, "timeout", None) or 20)
178
+ try:
179
+ with httpx.Client(transport=ctx.transport, timeout=timeout, follow_redirects=False) as h:
180
+ r = h.get(source, headers={"Accept": "application/json"})
181
+ if r.status_code != 200:
182
+ raise CliError(t("err.keys_unavailable"), code=FAILED, error="keys_unavailable")
183
+ doc = r.json()
184
+ except (httpx.HTTPError, ValueError):
185
+ raise CliError(t("err.keys_unavailable"), code=FAILED, error="keys_unavailable") from None
186
+ kind = "url"
187
+ elif "://" in source:
188
+ raise CliError(t("err.keys_unavailable"), code=USAGE, error="keys_unavailable")
189
+ else:
190
+ try:
191
+ doc = json.loads(_read(ctx, source))
192
+ except ValueError:
193
+ raise CliError(t("err.keys_unavailable"), code=FAILED, error="keys_unavailable") from None
194
+ kind = "file"
195
+ if not isinstance(doc, dict) or not isinstance(doc.get("keys"), list):
196
+ raise CliError(t("err.keys_unavailable"), code=FAILED, error="keys_unavailable")
197
+ return doc, kind
198
+
199
+
200
+ def verify_answer(ctx: Context) -> dict[str, Any]:
201
+ receipt = _load_receipt(ctx, ctx.args.receipt)
202
+ keys, source = _load_keys(ctx, ctx.args.keys, receipt)
203
+ candidates = [k for k in keys["keys"] if isinstance(k, dict) and k.get("kid") == receipt["kid"]]
204
+ # A client receipt names who signed it: LightHouse for the portal, the
205
+ # deployment itself for a deployment's answer. Any other key is refused.
206
+ if receipt.get("profile") == "portal":
207
+ candidates = [k for k in candidates if k.get("issuer") == "lighthouse"]
208
+ elif receipt.get("profile") == "deployment":
209
+ candidates = [k for k in candidates if k.get("issuer") == "deployment"
210
+ and k.get("deployment") == receipt.get("deployment")]
211
+ key = next((k for k in candidates if k.get("kty") == "OKP" and k.get("crv") == "Ed25519"), None)
212
+ if key is None:
213
+ raise CliError(t("err.receipt_key_unknown"), code=FAILED, error="receipt_key_unknown")
214
+ try:
215
+ _integers_only(receipt)
216
+ Ed25519PublicKey.from_public_bytes(_b64u(str(key["x"]))).verify(
217
+ _b64u(receipt["sig"]), canonical({k: v for k, v in receipt.items() if k != "sig"}))
218
+ except (InvalidSignature, ValueError, TypeError):
219
+ raise CliError(t("err.receipt_invalid"), code=FAILED, error="receipt_invalid") from None
220
+ answer = "not_checked"
221
+ if ctx.args.answer is not None:
222
+ data = _read(ctx, ctx.args.answer)
223
+ # Exactly the answer, or the answer and the one newline an editor adds.
224
+ texts = {data, data[:-1] if data.endswith(b"\n") else data}
225
+ if receipt.get("answer_sha256") not in {hashlib.sha256(c).hexdigest() for c in texts}:
226
+ raise CliError(t("err.receipt_answer_mismatch"), code=FAILED, error="receipt_answer_mismatch")
227
+ answer = "matches"
228
+ body = {
229
+ "ok": True, "verified": True, "kid": receipt["kid"], "key_status": key.get("status") or "current",
230
+ "keys": source, "keys_url": (ctx.args.keys or KEYS_URL) if source == "url" else None,
231
+ "answer": answer,
232
+ "receipt": {"v": receipt["v"], "id": receipt.get("id"), "issuer": receipt.get("iss"),
233
+ "profile": receipt.get("profile"),
234
+ "kind": receipt.get("kind"), "produced": receipt.get("produced"),
235
+ "issued_at": receipt.get("issued_at"), "passages": len(receipt.get("passages") or []),
236
+ "reads": len(receipt.get("reads") or []), "corpus": receipt.get("corpus"),
237
+ "tenant": receipt.get("tenant"), "deployment": receipt.get("deployment")},
238
+ }
239
+ if receipt["v"] == 2:
240
+ eur = receipt["cost_eur_nano"]
241
+ # Signed with the rest: the model's display name, tokens, escalations and cost.
242
+ body["receipt"].update({
243
+ "model": receipt["model"], "tokens_in": receipt["tokens_in"], "tokens_out": receipt["tokens_out"],
244
+ "escalations": receipt["escalations"], "cost_usd": _amount(receipt["cost_usd_nano"]),
245
+ "cost_eur": _amount(eur) if eur is not None else None, "fx_date": receipt["fx_date"]})
246
+ return body
247
+
248
+
249
+ def _show(out: Out, body: dict[str, Any]) -> None:
250
+ r = body["receipt"]
251
+ # A deployment's answer is signed with the deployment's own key, not Atlantic's.
252
+ out.done(t("verify.verified_deployment") if r["profile"] == "deployment" else t("verify.verified"))
253
+ out.pairs([("receipt", r["id"]),
254
+ ("issued", r["issued_at"]),
255
+ ("kind", r["kind"]),
256
+ ("passages", r["passages"]),
257
+ *(_signed_v2(r) if r.get("v") == 2 else []),
258
+ ("signed with key", f"{body['kid']} ({body['key_status']})"),
259
+ ("answer", t("verify.answer_matches") if body["answer"] == "matches"
260
+ else t("verify.answer_not_checked"))])
261
+
262
+
263
+ def _signed_v2(r: dict[str, Any]) -> list[tuple[str, Any]]:
264
+ m = r["model"]
265
+ cost = f"US${r['cost_usd']}"
266
+ if r["cost_eur"] is not None:
267
+ cost = f"€{r['cost_eur']} ({cost}, ECB {r['fx_date']})"
268
+ return [("model", f"{m['name']} · {m['provider']}" if m else None),
269
+ ("tokens in/out", f"{r['tokens_in']:,} / {r['tokens_out']:,}"),
270
+ ("escalations", r["escalations"]),
271
+ ("cost", cost)]
272
+
273
+
274
+ COMMANDS = (Command("verify-answer", "check that an answer from Octy was signed by Atlantic Agentic and is unchanged",
275
+ _configure, verify_answer, _show, anonymous=True),)
@@ -364,5 +364,27 @@
364
364
  "label.missing": "المفقود",
365
365
  "label.records_stored": "السجلات المخزنة",
366
366
  "label.records_already_held": "السجلات المحفوظة مسبقًا",
367
- "label.spans": "الامتدادات"
367
+ "label.spans": "الامتدادات",
368
+ "help.verify-answer._help": "التحقق من أن إجابة من Octy موقّعة من Atlantic Agentic ولم تُغيَّر",
369
+ "help.verify-answer.receipt": "ملف الإيصال من لوحة الأدلة الخاصة بالإجابة ('-' للإدخال القياسي)",
370
+ "help.verify-answer.answer": "ملف يحتوي على نص الإجابة، للتحقق من أنها الإجابة الموقّعة",
371
+ "help.verify-answer.keys": "المفاتيح المنشورة، كعنوان https أو ملف محفوظ (الافتراضي: عنوان Atlantic المعروف)",
372
+ "err.file_unreadable": "تعذّرت قراءة {name}",
373
+ "err.receipt_unreadable": "هذا ليس إيصالًا من Octy",
374
+ "err.receipt_issuer": "لم تُصدر Atlantic Agentic هذا الإيصال؛ استخدم --keys للتحقق منه بمفاتيح أخرى",
375
+ "err.keys_unavailable": "تعذّرت قراءة المفاتيح المنشورة",
376
+ "err.receipt_key_unknown": "المفتاح الذي وقّع هذا الإيصال غير منشور",
377
+ "err.receipt_invalid": "التوقيع غير مطابق: تم تغيير الإيصال أو لم توقّعه Atlantic Agentic",
378
+ "err.receipt_answer_mismatch": "الإجابة لا تطابق إيصالها",
379
+ "verify.verified": "موقّع من Atlantic Agentic · تم التحقق",
380
+ "verify.answer_matches": "مطابقة للإيصال",
381
+ "verify.answer_not_checked": "لم يتم التحقق (استخدم --answer)",
382
+ "label.receipt": "الإيصال",
383
+ "label.passages": "المقاطع",
384
+ "label.signed_with_key": "موقّع بالمفتاح",
385
+ "label.answer": "الإجابة",
386
+ "verify.verified_deployment": "الإيصال صالح: توقيع Octy صحيح.",
387
+ "err.receipt_malformed": "يجب أن يتضمن إيصال الإصدار 2 النموذج والرموز وعدد التصعيدات والتكلفة، كلٌّ بالنوع الصحيح",
388
+ "label.escalations": "التصعيدات",
389
+ "label.cost": "التكلفة"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "fehlend",
365
365
  "label.records_stored": "gespeicherte Datensätze",
366
366
  "label.records_already_held": "bereits gehaltene Datensätze",
367
- "label.spans": "Spans"
367
+ "label.spans": "Spans",
368
+ "help.verify-answer._help": "prüfen, ob eine Antwort von Octy von Atlantic Agentic signiert und unverändert ist",
369
+ "help.verify-answer.receipt": "die Belegdatei aus dem Nachweisbereich der Antwort ('-' für die Standardeingabe)",
370
+ "help.verify-answer.answer": "eine Datei mit dem Text der Antwort, um zu prüfen, dass es die signierte Antwort ist",
371
+ "help.verify-answer.keys": "die veröffentlichten Schlüssel als https-URL oder gespeicherte Datei (Standard: die bekannte URL von Atlantic)",
372
+ "err.file_unreadable": "{name} konnte nicht gelesen werden",
373
+ "err.receipt_unreadable": "dies ist kein Octy-Beleg",
374
+ "err.receipt_issuer": "der Beleg wurde nicht von Atlantic Agentic ausgestellt; geben Sie --keys an, um ihn mit anderen Schlüsseln zu prüfen",
375
+ "err.keys_unavailable": "die veröffentlichten Schlüssel konnten nicht gelesen werden",
376
+ "err.receipt_key_unknown": "der Schlüssel, der diesen Beleg signiert hat, ist nicht veröffentlicht",
377
+ "err.receipt_invalid": "die Signatur stimmt nicht: der Beleg wurde geändert oder nicht von Atlantic Agentic signiert",
378
+ "err.receipt_answer_mismatch": "die Antwort stimmt nicht mit ihrem Beleg überein",
379
+ "verify.verified": "Signiert von Atlantic Agentic · geprüft",
380
+ "verify.answer_matches": "stimmt mit dem Beleg überein",
381
+ "verify.answer_not_checked": "nicht geprüft (--answer angeben)",
382
+ "label.receipt": "Beleg",
383
+ "label.passages": "Passagen",
384
+ "label.signed_with_key": "signiert mit Schlüssel",
385
+ "label.answer": "Antwort",
386
+ "verify.verified_deployment": "Die Quittung ist gültig: Octys Signatur ist korrekt.",
387
+ "err.receipt_malformed": "ein Beleg der Version 2 muss Modell, Tokens, Eskalationen und Kosten im richtigen Typ enthalten",
388
+ "label.escalations": "Eskalationen",
389
+ "label.cost": "Kosten"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "missing",
365
365
  "label.records_stored": "records stored",
366
366
  "label.records_already_held": "records already held",
367
- "label.spans": "spans"
367
+ "label.spans": "spans",
368
+ "help.verify-answer._help": "check that an answer from Octy was signed by Atlantic Agentic and is unchanged",
369
+ "help.verify-answer.receipt": "the receipt file from the answer's evidence panel ('-' for standard input)",
370
+ "help.verify-answer.answer": "a file holding the answer's text, to check that it is the answer signed",
371
+ "help.verify-answer.keys": "the published keys, as an https URL or a saved file (default: Atlantic's well-known URL)",
372
+ "err.file_unreadable": "{name} could not be read",
373
+ "err.receipt_unreadable": "this is not an Octy receipt",
374
+ "err.receipt_issuer": "the receipt was not issued by Atlantic Agentic; give --keys to check it against other keys",
375
+ "err.keys_unavailable": "the published keys could not be read",
376
+ "err.receipt_key_unknown": "the key that signed this receipt is not published",
377
+ "err.receipt_invalid": "the signature does not match: the receipt has been changed or was not signed by Atlantic Agentic",
378
+ "err.receipt_answer_mismatch": "the answer does not match its receipt",
379
+ "verify.verified": "Signed by Atlantic Agentic · verified",
380
+ "verify.answer_matches": "matches the receipt",
381
+ "verify.answer_not_checked": "not checked (give --answer)",
382
+ "label.receipt": "receipt",
383
+ "label.passages": "passages",
384
+ "label.signed_with_key": "signed with key",
385
+ "label.answer": "answer",
386
+ "verify.verified_deployment": "The receipt verifies: Octy's signature is valid.",
387
+ "err.receipt_malformed": "a version 2 receipt must carry the model, tokens, escalations and cost, each of the right type",
388
+ "label.escalations": "escalations",
389
+ "label.cost": "cost"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "faltan",
365
365
  "label.records_stored": "registros almacenados",
366
366
  "label.records_already_held": "registros ya conservados",
367
- "label.spans": "spans"
367
+ "label.spans": "spans",
368
+ "help.verify-answer._help": "comprobar que una respuesta de Octy fue firmada por Atlantic Agentic y no ha cambiado",
369
+ "help.verify-answer.receipt": "el archivo de recibo del panel de evidencias de la respuesta ('-' para la entrada estándar)",
370
+ "help.verify-answer.answer": "un archivo con el texto de la respuesta, para comprobar que es la respuesta firmada",
371
+ "help.verify-answer.keys": "las claves publicadas, como URL https o archivo guardado (por defecto: la URL conocida de Atlantic)",
372
+ "err.file_unreadable": "no se pudo leer {name}",
373
+ "err.receipt_unreadable": "esto no es un recibo de Octy",
374
+ "err.receipt_issuer": "el recibo no lo emitió Atlantic Agentic; indique --keys para comprobarlo con otras claves",
375
+ "err.keys_unavailable": "no se pudieron leer las claves publicadas",
376
+ "err.receipt_key_unknown": "la clave que firmó este recibo no está publicada",
377
+ "err.receipt_invalid": "la firma no coincide: el recibo se ha modificado o no lo firmó Atlantic Agentic",
378
+ "err.receipt_answer_mismatch": "la respuesta no coincide con su recibo",
379
+ "verify.verified": "Firmado por Atlantic Agentic · verificado",
380
+ "verify.answer_matches": "coincide con el recibo",
381
+ "verify.answer_not_checked": "sin comprobar (indique --answer)",
382
+ "label.receipt": "recibo",
383
+ "label.passages": "pasajes",
384
+ "label.signed_with_key": "firmado con la clave",
385
+ "label.answer": "respuesta",
386
+ "verify.verified_deployment": "El recibo es válido: la firma de Octy es correcta.",
387
+ "err.receipt_malformed": "un recibo de la versión 2 debe incluir el modelo, los tokens, las escalaciones y el coste, cada uno con el tipo correcto",
388
+ "label.escalations": "escalaciones",
389
+ "label.cost": "coste"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "manquants",
365
365
  "label.records_stored": "enregistrements stockés",
366
366
  "label.records_already_held": "enregistrements déjà détenus",
367
- "label.spans": "spans"
367
+ "label.spans": "spans",
368
+ "help.verify-answer._help": "vérifier qu'une réponse d'Octy a été signée par Atlantic Agentic et n'a pas été modifiée",
369
+ "help.verify-answer.receipt": "le fichier de reçu du panneau de preuves de la réponse ('-' pour l'entrée standard)",
370
+ "help.verify-answer.answer": "un fichier contenant le texte de la réponse, pour vérifier qu'il s'agit de la réponse signée",
371
+ "help.verify-answer.keys": "les clés publiées, sous forme d'URL https ou de fichier enregistré (par défaut : l'URL bien connue d'Atlantic)",
372
+ "err.file_unreadable": "{name} n'a pas pu être lu",
373
+ "err.receipt_unreadable": "ce n'est pas un reçu d'Octy",
374
+ "err.receipt_issuer": "le reçu n'a pas été émis par Atlantic Agentic ; indiquez --keys pour le vérifier avec d'autres clés",
375
+ "err.keys_unavailable": "les clés publiées n'ont pas pu être lues",
376
+ "err.receipt_key_unknown": "la clé qui a signé ce reçu n'est pas publiée",
377
+ "err.receipt_invalid": "la signature ne correspond pas : le reçu a été modifié ou n'a pas été signé par Atlantic Agentic",
378
+ "err.receipt_answer_mismatch": "la réponse ne correspond pas à son reçu",
379
+ "verify.verified": "Signé par Atlantic Agentic · vérifié",
380
+ "verify.answer_matches": "correspond au reçu",
381
+ "verify.answer_not_checked": "non vérifiée (indiquez --answer)",
382
+ "label.receipt": "reçu",
383
+ "label.passages": "passages",
384
+ "label.signed_with_key": "signé avec la clé",
385
+ "label.answer": "réponse",
386
+ "verify.verified_deployment": "Le reçu est valide : la signature d'Octy est correcte.",
387
+ "err.receipt_malformed": "un reçu de version 2 doit contenir le modèle, les jetons, les escalades et le coût, chacun du bon type",
388
+ "label.escalations": "escalades",
389
+ "label.cost": "coût"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "in easnamh",
365
365
  "label.records_stored": "taifid stóráilte",
366
366
  "label.records_already_held": "taifid ar coimeád cheana",
367
- "label.spans": "réisí"
367
+ "label.spans": "réisí",
368
+ "help.verify-answer._help": "seiceáil gur shínigh Atlantic Agentic freagra ó Octy agus nár athraíodh é",
369
+ "help.verify-answer.receipt": "comhad na hadmhála ó phainéal fianaise an fhreagra ('-' don ionchur caighdeánach)",
370
+ "help.verify-answer.answer": "comhad ina bhfuil téacs an fhreagra, chun a sheiceáil gurb é an freagra sínithe é",
371
+ "help.verify-answer.keys": "na heochracha foilsithe, mar URL https nó comhad sábháilte (réamhshocrú: URL aitheanta Atlantic)",
372
+ "err.file_unreadable": "níorbh fhéidir {name} a léamh",
373
+ "err.receipt_unreadable": "ní admháil Octy í seo",
374
+ "err.receipt_issuer": "níor eisigh Atlantic Agentic an admháil; tabhair --keys chun í a sheiceáil le heochracha eile",
375
+ "err.keys_unavailable": "níorbh fhéidir na heochracha foilsithe a léamh",
376
+ "err.receipt_key_unknown": "níl an eochair a shínigh an admháil seo foilsithe",
377
+ "err.receipt_invalid": "ní mheaitseálann an síniú: athraíodh an admháil nó níor shínigh Atlantic Agentic í",
378
+ "err.receipt_answer_mismatch": "ní mheaitseálann an freagra a admháil",
379
+ "verify.verified": "Sínithe ag Atlantic Agentic · fíoraithe",
380
+ "verify.answer_matches": "meaitseálann sé an admháil",
381
+ "verify.answer_not_checked": "gan seiceáil (tabhair --answer)",
382
+ "label.receipt": "admháil",
383
+ "label.passages": "sleachta",
384
+ "label.signed_with_key": "sínithe leis an eochair",
385
+ "label.answer": "freagra",
386
+ "verify.verified_deployment": "Tá an admháil bailí: tá síniú Octy ceart.",
387
+ "err.receipt_malformed": "caithfidh an tsamhail, na comharthaí, na géaruithe agus an costas a bheith in admháil leagan 2, gach ceann den chineál ceart",
388
+ "label.escalations": "géaruithe",
389
+ "label.cost": "costas"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "mancanti",
365
365
  "label.records_stored": "record archiviati",
366
366
  "label.records_already_held": "record già conservati",
367
- "label.spans": "span"
367
+ "label.spans": "span",
368
+ "help.verify-answer._help": "verificare che una risposta di Octy sia stata firmata da Atlantic Agentic e non sia stata modificata",
369
+ "help.verify-answer.receipt": "il file della ricevuta dal pannello delle evidenze della risposta ('-' per l'input standard)",
370
+ "help.verify-answer.answer": "un file con il testo della risposta, per verificare che sia la risposta firmata",
371
+ "help.verify-answer.keys": "le chiavi pubblicate, come URL https o file salvato (predefinito: l'URL noto di Atlantic)",
372
+ "err.file_unreadable": "impossibile leggere {name}",
373
+ "err.receipt_unreadable": "questa non è una ricevuta di Octy",
374
+ "err.receipt_issuer": "la ricevuta non è stata emessa da Atlantic Agentic; indicare --keys per verificarla con altre chiavi",
375
+ "err.keys_unavailable": "impossibile leggere le chiavi pubblicate",
376
+ "err.receipt_key_unknown": "la chiave che ha firmato questa ricevuta non è pubblicata",
377
+ "err.receipt_invalid": "la firma non corrisponde: la ricevuta è stata modificata o non è stata firmata da Atlantic Agentic",
378
+ "err.receipt_answer_mismatch": "la risposta non corrisponde alla sua ricevuta",
379
+ "verify.verified": "Firmato da Atlantic Agentic · verificato",
380
+ "verify.answer_matches": "corrisponde alla ricevuta",
381
+ "verify.answer_not_checked": "non verificata (indicare --answer)",
382
+ "label.receipt": "ricevuta",
383
+ "label.passages": "passaggi",
384
+ "label.signed_with_key": "firmata con la chiave",
385
+ "label.answer": "risposta",
386
+ "verify.verified_deployment": "La ricevuta è valida: la firma di Octy è corretta.",
387
+ "err.receipt_malformed": "una ricevuta della versione 2 deve riportare modello, token, escalation e costo, ciascuno del tipo corretto",
388
+ "label.escalations": "escalation",
389
+ "label.cost": "costo"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "欠落",
365
365
  "label.records_stored": "保存したレコード",
366
366
  "label.records_already_held": "保持済みのレコード",
367
- "label.spans": "スパン"
367
+ "label.spans": "スパン",
368
+ "help.verify-answer._help": "Octy の回答が Atlantic Agentic によって署名され、変更されていないことを確認します",
369
+ "help.verify-answer.receipt": "回答のエビデンスパネルから取得したレシートファイル(標準入力は '-')",
370
+ "help.verify-answer.answer": "回答のテキストを含むファイル。署名された回答であることを確認します",
371
+ "help.verify-answer.keys": "公開鍵(https URL または保存したファイル。既定: Atlantic の well-known URL)",
372
+ "err.file_unreadable": "{name} を読み取れませんでした",
373
+ "err.receipt_unreadable": "これは Octy のレシートではありません",
374
+ "err.receipt_issuer": "このレシートは Atlantic Agentic が発行したものではありません。他の鍵で確認するには --keys を指定してください",
375
+ "err.keys_unavailable": "公開鍵を読み取れませんでした",
376
+ "err.receipt_key_unknown": "このレシートに署名した鍵は公開されていません",
377
+ "err.receipt_invalid": "署名が一致しません。レシートが変更されたか、Atlantic Agentic が署名したものではありません",
378
+ "err.receipt_answer_mismatch": "回答がレシートと一致しません",
379
+ "verify.verified": "Atlantic Agentic による署名 · 検証済み",
380
+ "verify.answer_matches": "レシートと一致",
381
+ "verify.answer_not_checked": "未確認(--answer を指定)",
382
+ "label.receipt": "レシート",
383
+ "label.passages": "パッセージ",
384
+ "label.signed_with_key": "署名鍵",
385
+ "label.answer": "回答",
386
+ "verify.verified_deployment": "レシートは有効です: Octy の署名は正しいです。",
387
+ "err.receipt_malformed": "バージョン 2 のレシートには、モデル、トークン、エスカレーション、コストを正しい型で含める必要があります",
388
+ "label.escalations": "エスカレーション",
389
+ "label.cost": "コスト"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "ontbrekend",
365
365
  "label.records_stored": "opgeslagen records",
366
366
  "label.records_already_held": "al bewaarde records",
367
- "label.spans": "spans"
367
+ "label.spans": "spans",
368
+ "help.verify-answer._help": "controleren of een antwoord van Octy door Atlantic Agentic is ondertekend en ongewijzigd is",
369
+ "help.verify-answer.receipt": "het ontvangstbewijs uit het bewijspaneel van het antwoord ('-' voor standaardinvoer)",
370
+ "help.verify-answer.answer": "een bestand met de tekst van het antwoord, om te controleren dat het het ondertekende antwoord is",
371
+ "help.verify-answer.keys": "de gepubliceerde sleutels, als https-URL of opgeslagen bestand (standaard: de bekende URL van Atlantic)",
372
+ "err.file_unreadable": "{name} kon niet worden gelezen",
373
+ "err.receipt_unreadable": "dit is geen ontvangstbewijs van Octy",
374
+ "err.receipt_issuer": "het ontvangstbewijs is niet door Atlantic Agentic uitgegeven; geef --keys op om het met andere sleutels te controleren",
375
+ "err.keys_unavailable": "de gepubliceerde sleutels konden niet worden gelezen",
376
+ "err.receipt_key_unknown": "de sleutel die dit ontvangstbewijs ondertekende, is niet gepubliceerd",
377
+ "err.receipt_invalid": "de handtekening klopt niet: het ontvangstbewijs is gewijzigd of niet door Atlantic Agentic ondertekend",
378
+ "err.receipt_answer_mismatch": "het antwoord komt niet overeen met het ontvangstbewijs",
379
+ "verify.verified": "Ondertekend door Atlantic Agentic · geverifieerd",
380
+ "verify.answer_matches": "komt overeen met het ontvangstbewijs",
381
+ "verify.answer_not_checked": "niet gecontroleerd (geef --answer op)",
382
+ "label.receipt": "ontvangstbewijs",
383
+ "label.passages": "passages",
384
+ "label.signed_with_key": "ondertekend met sleutel",
385
+ "label.answer": "antwoord",
386
+ "verify.verified_deployment": "Het ontvangstbewijs is geldig: de handtekening van Octy klopt.",
387
+ "err.receipt_malformed": "een ontvangstbewijs van versie 2 moet het model, de tokens, de escalaties en de kosten bevatten, elk van het juiste type",
388
+ "label.escalations": "escalaties",
389
+ "label.cost": "kosten"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "em falta",
365
365
  "label.records_stored": "registos guardados",
366
366
  "label.records_already_held": "registos já guardados",
367
- "label.spans": "spans"
367
+ "label.spans": "spans",
368
+ "help.verify-answer._help": "verificar que uma resposta do Octy foi assinada pela Atlantic Agentic e não foi alterada",
369
+ "help.verify-answer.receipt": "o ficheiro do recibo do painel de evidências da resposta ('-' para a entrada padrão)",
370
+ "help.verify-answer.answer": "um ficheiro com o texto da resposta, para verificar que é a resposta assinada",
371
+ "help.verify-answer.keys": "as chaves publicadas, como URL https ou ficheiro guardado (por omissão: o URL conhecido da Atlantic)",
372
+ "err.file_unreadable": "não foi possível ler {name}",
373
+ "err.receipt_unreadable": "isto não é um recibo do Octy",
374
+ "err.receipt_issuer": "o recibo não foi emitido pela Atlantic Agentic; indique --keys para o verificar com outras chaves",
375
+ "err.keys_unavailable": "não foi possível ler as chaves publicadas",
376
+ "err.receipt_key_unknown": "a chave que assinou este recibo não está publicada",
377
+ "err.receipt_invalid": "a assinatura não corresponde: o recibo foi alterado ou não foi assinado pela Atlantic Agentic",
378
+ "err.receipt_answer_mismatch": "a resposta não corresponde ao seu recibo",
379
+ "verify.verified": "Assinado pela Atlantic Agentic · verificado",
380
+ "verify.answer_matches": "corresponde ao recibo",
381
+ "verify.answer_not_checked": "não verificada (indique --answer)",
382
+ "label.receipt": "recibo",
383
+ "label.passages": "passagens",
384
+ "label.signed_with_key": "assinado com a chave",
385
+ "label.answer": "resposta",
386
+ "verify.verified_deployment": "O recibo é válido: a assinatura da Octy está correta.",
387
+ "err.receipt_malformed": "um recibo da versão 2 tem de incluir o modelo, os tokens, as escalações e o custo, cada um do tipo correto",
388
+ "label.escalations": "escalações",
389
+ "label.cost": "custo"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "缺失",
365
365
  "label.records_stored": "已存储的记录",
366
366
  "label.records_already_held": "已保存过的记录",
367
- "label.spans": "跨度"
367
+ "label.spans": "跨度",
368
+ "help.verify-answer._help": "检查 Octy 的回答是否由 Atlantic Agentic 签名且未被更改",
369
+ "help.verify-answer.receipt": "来自回答证据面板的回执文件('-' 表示标准输入)",
370
+ "help.verify-answer.answer": "包含回答文本的文件,用于检查它是否为已签名的回答",
371
+ "help.verify-answer.keys": "已发布的密钥,可为 https URL 或已保存的文件(默认:Atlantic 的 well-known URL)",
372
+ "err.file_unreadable": "无法读取 {name}",
373
+ "err.receipt_unreadable": "这不是 Octy 回执",
374
+ "err.receipt_issuer": "该回执并非由 Atlantic Agentic 签发;请使用 --keys 以其他密钥进行检查",
375
+ "err.keys_unavailable": "无法读取已发布的密钥",
376
+ "err.receipt_key_unknown": "签署此回执的密钥未发布",
377
+ "err.receipt_invalid": "签名不匹配:回执已被更改或并非由 Atlantic Agentic 签署",
378
+ "err.receipt_answer_mismatch": "回答与其回执不匹配",
379
+ "verify.verified": "由 Atlantic Agentic 签名 · 已验证",
380
+ "verify.answer_matches": "与回执一致",
381
+ "verify.answer_not_checked": "未检查(请提供 --answer)",
382
+ "label.receipt": "回执",
383
+ "label.passages": "段落",
384
+ "label.signed_with_key": "签名密钥",
385
+ "label.answer": "回答",
386
+ "verify.verified_deployment": "回执有效:Octy 的签名正确。",
387
+ "err.receipt_malformed": "第 2 版回执必须包含模型、令牌、升级次数和费用,且类型正确",
388
+ "label.escalations": "升级次数",
389
+ "label.cost": "费用"
368
390
  }
@@ -364,5 +364,27 @@
364
364
  "label.missing": "缺少",
365
365
  "label.records_stored": "已儲存的記錄",
366
366
  "label.records_already_held": "已保存過的記錄",
367
- "label.spans": "跨度"
367
+ "label.spans": "跨度",
368
+ "help.verify-answer._help": "檢查 Octy 的回答是否由 Atlantic Agentic 簽署且未被更改",
369
+ "help.verify-answer.receipt": "來自回答證據面板的回執檔案('-' 表示標準輸入)",
370
+ "help.verify-answer.answer": "包含回答文字的檔案,用於檢查它是否為已簽署的回答",
371
+ "help.verify-answer.keys": "已發布的金鑰,可為 https URL 或已儲存的檔案(預設:Atlantic 的 well-known URL)",
372
+ "err.file_unreadable": "無法讀取 {name}",
373
+ "err.receipt_unreadable": "這不是 Octy 回執",
374
+ "err.receipt_issuer": "此回執並非由 Atlantic Agentic 簽發;請使用 --keys 以其他金鑰進行檢查",
375
+ "err.keys_unavailable": "無法讀取已發布的金鑰",
376
+ "err.receipt_key_unknown": "簽署此回執的金鑰未發布",
377
+ "err.receipt_invalid": "簽章不符:回執已被更改或並非由 Atlantic Agentic 簽署",
378
+ "err.receipt_answer_mismatch": "回答與其回執不符",
379
+ "verify.verified": "由 Atlantic Agentic 簽署 · 已驗證",
380
+ "verify.answer_matches": "與回執一致",
381
+ "verify.answer_not_checked": "未檢查(請提供 --answer)",
382
+ "label.receipt": "回執",
383
+ "label.passages": "段落",
384
+ "label.signed_with_key": "簽署金鑰",
385
+ "label.answer": "回答",
386
+ "verify.verified_deployment": "收據有效:Octy 的簽章正確。",
387
+ "err.receipt_malformed": "第 2 版回執必須包含模型、權杖、升級次數和費用,且類型正確",
388
+ "label.escalations": "升級次數",
389
+ "label.cost": "費用"
368
390
  }
@@ -137,11 +137,12 @@ def commands() -> dict[str, Command]:
137
137
  spend,
138
138
  stack,
139
139
  terms,
140
+ verify,
140
141
  whoami,
141
142
  )
142
143
  out: dict[str, Command] = {}
143
144
  for module in (login, whoami, connect, connections, collectors, models, kb, agents, builds, evals,
144
- runs, spend, limits, terms, stack, language, offline):
145
+ runs, spend, limits, terms, stack, language, offline, verify):
145
146
  for command in module.COMMANDS:
146
147
  out[command.name] = command
147
148
  return out
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lighthouse-cli
3
- Version: 0.17.2
3
+ Version: 0.18.1
4
4
  Summary: The LightHouse command line: sign in, connect your estate, deploy agents, watch runs
5
5
  License-Expression: Apache-2.0
6
6
  Classifier: Programming Language :: Python :: 3
@@ -32,6 +32,7 @@ lighthouse/commands/runs.py
32
32
  lighthouse/commands/spend.py
33
33
  lighthouse/commands/stack.py
34
34
  lighthouse/commands/terms.py
35
+ lighthouse/commands/verify.py
35
36
  lighthouse/commands/whoami.py
36
37
  lighthouse/locales/ar.json
37
38
  lighthouse/locales/de.json
@@ -66,4 +67,5 @@ tests/test_offline.py
66
67
  tests/test_plumbing.py
67
68
  tests/test_sealing.py
68
69
  tests/test_stack.py
70
+ tests/test_verify.py
69
71
  tests/test_version.py
@@ -18,7 +18,7 @@ build-backend = "setuptools.build_meta"
18
18
 
19
19
  [project]
20
20
  name = "lighthouse-cli"
21
- version = "0.17.2"
21
+ version = "0.18.1"
22
22
  description = "The LightHouse command line: sign in, connect your estate, deploy agents, watch runs"
23
23
  requires-python = ">=3.11"
24
24
  license = "Apache-2.0"
@@ -1183,3 +1183,63 @@ def test_builds_show_reads_one_proposal_and_checks_its_id(run: Runner):
1183
1183
  assert "estimated per month" in result.stdout and "passed (red team 1/1)" in result.stdout
1184
1184
  bad = run(f"--host={HOST}", "builds", "show", "not-an-id", "--json")
1185
1185
  assert bad.code == exits.USAGE and bad.json["error"] == "usage"
1186
+
1187
+
1188
+ # -- verify-answer (#48) ------------------------------------------------------------------
1189
+
1190
+ def _octy(run: Runner, tmp_path: Any, receipt: dict[str, Any]) -> str:
1191
+ from tests.api_fixtures import load
1192
+ run.keyring.set_password("lighthouse", HOST, json.dumps({
1193
+ "access_token": assembled("lhat"), "refresh_token": None, "expires_at": "2099-01-01T00:00:00+00:00",
1194
+ "email": "ops@example.test", "scopes": []}))
1195
+ run.config.remember(HOST)
1196
+ run.transport = routes({("GET", "/api/v1/octy/keys"): load("octy-keys")})
1197
+ path = tmp_path / "receipt.json"
1198
+ path.write_text(json.dumps(receipt))
1199
+ return str(path)
1200
+
1201
+
1202
+ def _fixture_receipt() -> dict[str, Any]:
1203
+ from pathlib import Path
1204
+ return json.loads((Path(__file__).parent / "fixtures" / "octy" / "portal-receipt.json").read_text())
1205
+
1206
+
1207
+ def test_verify_answer_accepts_a_portal_receipt_and_its_answer(run: Runner, tmp_path: Any):
1208
+ from pathlib import Path
1209
+ path = _octy(run, tmp_path, _fixture_receipt())
1210
+ answer = Path(__file__).parent / "fixtures" / "octy" / "portal-answer.txt"
1211
+ result = run(f"--host={HOST}", "verify-answer", path, "--answer", str(answer), "--json")
1212
+ assert result.code == 0, result.stderr
1213
+ assert result.json["verified"] is True and result.json["kid"] == "octy-test-2026-11"
1214
+
1215
+
1216
+ @pytest.mark.parametrize("change,error,code", [
1217
+ ({"answer_sha256": "0" * 64}, "receipt_invalid", 1),
1218
+ ({"reads": []}, "receipt_invalid", 1),
1219
+ ({"kid": "octy-other"}, "receipt_key_unknown", 1),
1220
+ ({"profile": "deployment", "deployment": "example-org-prod"}, "receipt_key_unknown", 1),
1221
+ ({"alg": "RS256"}, "receipt_unreadable", exits.USAGE),
1222
+ ])
1223
+ def test_verify_answer_refuses_a_tampered_receipt(run: Runner, tmp_path: Any, change: dict[str, Any], error: str,
1224
+ code: int):
1225
+ path = _octy(run, tmp_path, {**_fixture_receipt(), **change})
1226
+ result = run(f"--host={HOST}", "verify-answer", path, "--json")
1227
+ assert result.code == code and result.json["error"] == error
1228
+
1229
+
1230
+ def test_verify_answer_refuses_an_answer_that_is_not_the_signed_one(run: Runner, tmp_path: Any):
1231
+ path = _octy(run, tmp_path, _fixture_receipt())
1232
+ other = tmp_path / "answer.txt"
1233
+ other.write_text("Nothing failed.")
1234
+ result = run(f"--host={HOST}", "verify-answer", path, "--answer", str(other), "--json")
1235
+ assert result.code == 1 and result.json["error"] == "receipt_answer_mismatch"
1236
+
1237
+
1238
+ def test_verify_answer_reads_keys_from_a_file_without_signing_in(run: Runner, tmp_path: Any):
1239
+ from tests.api_fixtures import load
1240
+ receipt = tmp_path / "receipt.json"
1241
+ receipt.write_text(json.dumps(_fixture_receipt()))
1242
+ keys = tmp_path / "keys.json"
1243
+ keys.write_text(json.dumps(load("octy-keys")))
1244
+ result = run(f"--host={HOST}", "verify-answer", str(receipt), "--keys", str(keys), "--json")
1245
+ assert result.code == 0, result.stderr
@@ -34,6 +34,7 @@ from tests.api_fixtures import load
34
34
  from tests.conftest import HOST, Runner, assembled, routes
35
35
 
36
36
  GOLDEN = Path(__file__).parent / "golden"
37
+ OCTY = Path(__file__).parent / "fixtures" / "octy"
37
38
  UPDATE = os.environ.get("LIGHTHOUSE_GOLDEN") == "update"
38
39
 
39
40
  # One answer per route the commands below read, each of them a fixture built
@@ -96,6 +97,9 @@ CASES: dict[str, list[str]] = {
96
97
  "stack": ["stack", "--cloud", "onprem"],
97
98
  "telemetry-status": ["telemetry", "status", "--deployment", "example-org-prod"],
98
99
  "commands-export": ["commands", "export", "--deployment", "example-org-prod", "--out", "-"],
100
+ # A receipt signed by the service's own test, checked against its saved keys (tests/fixtures/octy).
101
+ "verify-answer": ["verify-answer", str(OCTY / "receipt.json"), "--keys", str(OCTY / "keys.json"),
102
+ "--answer", str(OCTY / "answer.txt")],
99
103
  }
100
104
  STREAMING = {"runs-tail-stream": ["runs", "tail", "--for", "0"]}
101
105
  SECRET_SHAPES = ("lhat-", "lhrt-", "aalcp-", "ghp_", "glpat-", "AKIA", "sk-")
@@ -0,0 +1,197 @@
1
+ """`lighthouse-ai verify-answer`: an Octy receipt checked against the published keys.
2
+
3
+ `tests/fixtures/octy/` holds a receipt signed by the LightHouse service's own
4
+ test (service/tests/test_site_ask.py, a throwaway key), its keys and its
5
+ answer: the CLI verifies what the service signs, not only what this file signs.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import base64
10
+ import hashlib
11
+ import json
12
+ from pathlib import Path
13
+ from typing import Any
14
+
15
+ import httpx
16
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
17
+ from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
18
+
19
+ from lighthouse.commands.verify import ISSUER, KEYS_URL, canonical
20
+ from tests.conftest import Runner, routes
21
+
22
+ FIX = Path(__file__).parent / "fixtures" / "octy"
23
+ RECEIPT, KEYS, ANSWER = FIX / "receipt.json", FIX / "keys.json", FIX / "answer.txt"
24
+
25
+
26
+ def b64u(raw: bytes) -> str:
27
+ return base64.urlsafe_b64encode(raw).rstrip(b"=").decode()
28
+
29
+
30
+ def signed(key: Ed25519PrivateKey, kid: str, **fields: Any) -> dict[str, Any]:
31
+ r = {"v": 1, "id": "oar_" + "a" * 22, "iss": ISSUER, "profile": "docs", "kind": "explained",
32
+ "produced": "explained", "question_sha256": hashlib.sha256(b"q").hexdigest(),
33
+ "answer_sha256": hashlib.sha256(b"Connect the connector first [1].").hexdigest(),
34
+ "passages": [{"n": 1, "collection": "docs", "url": "https://docs.example.test/x", "sha256": "0" * 64}],
35
+ "corpus": {"docs": "0.17.0+abcdefabcdef", "knowledge": None}, "model_ref": "f" * 32,
36
+ "issued_at": "2026-11-12T10:00:00Z", "kid": kid, "alg": "Ed25519", **fields}
37
+ r["sig"] = b64u(key.sign(canonical(r)))
38
+ return r
39
+
40
+
41
+ def jwks(*pairs: tuple[str, Ed25519PrivateKey, str]) -> dict[str, Any]:
42
+ return {"issuer": ISSUER, "keys": [
43
+ {"kty": "OKP", "crv": "Ed25519", "alg": "EdDSA", "use": "sig", "kid": kid, "status": status,
44
+ "x": b64u(k.public_key().public_bytes(Encoding.Raw, PublicFormat.Raw))} for kid, k, status in pairs]}
45
+
46
+
47
+ def test_a_receipt_signed_by_the_service_verifies_with_its_answer(run: Runner):
48
+ r = run("verify-answer", str(RECEIPT), "--keys", str(KEYS), "--answer", str(ANSWER), "--json")
49
+ assert r.code == 0, r.stderr
50
+ body = json.loads(r.stdout)
51
+ assert body["verified"] is True and body["answer"] == "matches" and body["keys"] == "file"
52
+ assert body["receipt"]["kind"] == "explained" and body["receipt"]["passages"] >= 1
53
+ human = run("verify-answer", str(RECEIPT), "--keys", str(KEYS))
54
+ assert human.code == 0 and "Signed by Atlantic Agentic · verified" in human.stdout
55
+ assert "not checked" in human.stdout
56
+
57
+
58
+ def test_a_saved_response_and_standard_input_are_accepted(run: Runner, tmp_path: Path):
59
+ wrapped = tmp_path / "response.json"
60
+ wrapped.write_text(json.dumps({"receipt": json.loads(RECEIPT.read_text())}))
61
+ assert run("verify-answer", str(wrapped), "--keys", str(KEYS)).code == 0
62
+ assert run("verify-answer", "-", "--keys", str(KEYS), stdin=RECEIPT.read_text()).code == 0
63
+
64
+
65
+ def test_a_tampered_answer_or_receipt_is_refused(run: Runner, tmp_path: Path):
66
+ other = tmp_path / "answer.txt"
67
+ other.write_text(ANSWER.read_text() + " Also delete the bucket.")
68
+ r = run("verify-answer", str(RECEIPT), "--keys", str(KEYS), "--answer", str(other), "--json")
69
+ assert r.code == 1 and json.loads(r.stdout or r.stderr)["error"] == "receipt_answer_mismatch"
70
+ receipt = json.loads(RECEIPT.read_text())
71
+ for field, value in (("kind", "retrieval"), ("issued_at", "2030-01-01T00:00:00Z"),
72
+ ("passages", receipt["passages"][:-1])):
73
+ bad = tmp_path / f"{field}.json"
74
+ bad.write_text(json.dumps({**receipt, field: value}))
75
+ r = run("verify-answer", str(bad), "--keys", str(KEYS), "--json")
76
+ assert r.code == 1 and "receipt_invalid" in (r.stdout + r.stderr), field
77
+ unknown = tmp_path / "kid.json"
78
+ unknown.write_text(json.dumps({**receipt, "kid": "octy-unknown"}))
79
+ assert "receipt_key_unknown" in run("verify-answer", str(unknown), "--keys", str(KEYS), "--json").stdout + \
80
+ run("verify-answer", str(unknown), "--keys", str(KEYS), "--json").stderr
81
+ junk = tmp_path / "junk.json"
82
+ junk.write_text("{}")
83
+ assert run("verify-answer", str(junk), "--keys", str(KEYS)).code == 2
84
+
85
+
86
+ def test_the_default_keys_are_atlantics_well_known_url_and_rotation(run: Runner):
87
+ old, new = Ed25519PrivateKey.generate(), Ed25519PrivateKey.generate()
88
+ seen: list[str] = []
89
+
90
+ def keys(req: httpx.Request) -> Any:
91
+ seen.append(str(req.url))
92
+ return jwks(("octy-2026-11", new, "current"), ("octy-2026-10", old, "retired"))
93
+ run.transport = routes({("GET", "/.well-known/octy-keys.json"): keys})
94
+ tmp = Path(run.config.path).parent
95
+ for kid, key in (("octy-2026-10", old), ("octy-2026-11", new)):
96
+ f = tmp / f"{kid}.json"
97
+ f.write_text(json.dumps(signed(key, kid)))
98
+ r = run("verify-answer", str(f), "--json")
99
+ assert r.code == 0, r.stderr
100
+ body = json.loads(r.stdout)
101
+ assert body["kid"] == kid and body["keys_url"] == KEYS_URL
102
+ assert body["key_status"] == ("retired" if kid == "octy-2026-10" else "current")
103
+ assert seen and all(u == KEYS_URL for u in seen)
104
+ # A key taken off the list verifies nothing.
105
+ run.transport = routes({("GET", "/.well-known/octy-keys.json"): jwks(("octy-2026-11", new, "current"))})
106
+ assert run("verify-answer", str(tmp / "octy-2026-10.json"), "--json").code == 1
107
+
108
+
109
+ def test_a_receipt_naming_another_issuer_needs_explicit_keys(run: Runner):
110
+ forger = Ed25519PrivateKey.generate()
111
+ tmp = Path(run.config.path).parent
112
+ f = tmp / "forged.json"
113
+ f.write_text(json.dumps(signed(forger, "octy-x", iss="https://ask.attacker.example")))
114
+ called: list[str] = []
115
+ run.transport = routes({("GET", "/.well-known/octy-keys.json"): lambda r: called.append(str(r.url)) or {}})
116
+ r = run("verify-answer", str(f), "--json")
117
+ assert r.code == 1 and "receipt_issuer" in r.stdout + r.stderr and called == []
118
+ assert run("verify-answer", str(f), "--keys", "http://ask.attacker.example/keys.json").code == 2
119
+
120
+
121
+ def test_the_keys_unreachable_is_a_clear_failure(run: Runner):
122
+ run.transport = routes({("GET", "/.well-known/octy-keys.json"): httpx.Response(503)})
123
+ tmp = Path(run.config.path).parent
124
+ f = tmp / "r.json"
125
+ f.write_text(json.dumps(signed(Ed25519PrivateKey.generate(), "octy-2026-11")))
126
+ r = run("verify-answer", str(f), "--json")
127
+ assert r.code == 1 and "keys_unavailable" in r.stdout + r.stderr
128
+
129
+
130
+ # -- receipt version 2 (contract 1.41) -----------------------------------------------------------
131
+
132
+ V2 = json.loads((FIX / "receipt-v2-fixture.json").read_text())
133
+
134
+
135
+ def _v2_files(tmp: Path, receipt: dict[str, Any] | None = None) -> tuple[Path, Path]:
136
+ r, k = tmp / "v2.json", tmp / "v2-keys.json"
137
+ r.write_text(json.dumps(receipt if receipt is not None else V2["receipt"]))
138
+ k.write_text(json.dumps(V2["keys"]))
139
+ return r, k
140
+
141
+
142
+ def test_a_v2_receipt_verifies_and_prints_what_it_signs(run: Runner, tmp_path: Path):
143
+ r, k = _v2_files(tmp_path)
144
+ answer = tmp_path / "a.txt"
145
+ answer.write_text(V2["answer"])
146
+ out = run("verify-answer", str(r), "--keys", str(k), "--answer", str(answer), "--json")
147
+ assert out.code == 0, out.stderr
148
+ body = json.loads(out.stdout)["receipt"]
149
+ assert body["v"] == 2 and body["model"] == {"provider": "Amazon Bedrock", "name": "Amazon Nova Micro"}
150
+ assert (body["tokens_in"], body["tokens_out"], body["escalations"]) == (1834, 61, 0)
151
+ assert body["cost_usd"] == "0.00007277" and body["cost_eur"] == "0.000062624" and body["fx_date"] == "2026-11-12"
152
+ human = run("verify-answer", str(r), "--keys", str(k))
153
+ assert human.code == 0
154
+ for shown in ("Amazon Nova Micro · Amazon Bedrock", "1,834 / 61", "€0.000062624", "US$0.00007277",
155
+ "ECB 2026-11-12", "escalations"):
156
+ assert shown in human.stdout, shown
157
+
158
+
159
+ def test_a_v2_receipt_without_a_model_or_rate_prints_dollars_only(run: Runner, tmp_path: Path):
160
+ key = Ed25519PrivateKey.generate()
161
+ receipt = signed(key, "octy-2026-11", v=2, model=None, tokens_in=0, tokens_out=0, escalations=0,
162
+ cost_usd_nano=0, cost_eur_nano=None, fx_date=None)
163
+ f = tmp_path / "r.json"
164
+ f.write_text(json.dumps(receipt))
165
+ keys = tmp_path / "k.json"
166
+ keys.write_text(json.dumps(jwks(("octy-2026-11", key, "current"))))
167
+ out = run("verify-answer", str(f), "--keys", str(keys))
168
+ assert out.code == 0 and "US$0" in out.stdout and "€" not in out.stdout
169
+
170
+
171
+ def test_the_v1_receipt_still_verifies_and_prints_no_v2_lines(run: Runner, tmp_path: Path):
172
+ r, k = tmp_path / "v1.json", tmp_path / "v1-keys.json"
173
+ r.write_text(json.dumps(V2["v1_receipt"]))
174
+ k.write_text(json.dumps(V2["v1_keys"]))
175
+ out = run("verify-answer", str(r), "--keys", str(k), "--json")
176
+ assert out.code == 0 and "model" not in json.loads(out.stdout)["receipt"]
177
+ assert "escalations" not in run("verify-answer", str(r), "--keys", str(k)).stdout
178
+
179
+
180
+ def test_a_tampered_v2_receipt_is_refused(run: Runner, tmp_path: Path):
181
+ r, k = _v2_files(tmp_path, V2["tampered_receipt"])
182
+ out = run("verify-answer", str(r), "--keys", str(k), "--json")
183
+ assert out.code == 1 and "receipt_invalid" in out.stdout + out.stderr
184
+
185
+
186
+ def test_a_malformed_v2_receipt_is_refused_as_malformed(run: Runner, tmp_path: Path):
187
+ good = V2["receipt"]
188
+ for change in ({"tokens_in": "1834"}, {"cost_eur_nano": None}, {"model": {"name": "x"}}, {"v": 3},
189
+ {k: v for k, v in good.items() if k != "escalations"}):
190
+ bad = {**good, **change} if "id" not in change else change
191
+ r, k = _v2_files(tmp_path, bad)
192
+ out = run("verify-answer", str(r), "--keys", str(k), "--json")
193
+ assert out.code == 1 and "receipt_malformed" in out.stdout + out.stderr, change
194
+ # A version 1 receipt carrying a version 2 field is malformed too.
195
+ r, k = _v2_files(tmp_path, {**V2["v1_receipt"], "tokens_in": 1})
196
+ assert "receipt_malformed" in "".join(
197
+ (lambda o: o.stdout + o.stderr)(run("verify-answer", str(r), "--keys", str(k), "--json")))
File without changes
File without changes