aics-cli 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.
aics_cli-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
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
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,420 @@
1
+ Metadata-Version: 2.4
2
+ Name: aics-cli
3
+ Version: 0.1.0
4
+ Summary: Verify the AICS log, card and keys yourself: a thin CLI over aics-tlog and aics-identity
5
+ Keywords: transparency-log,ai-agents,c2sp,tlog-tiles,ed25519,verification
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Dist: aics-identity>=0.2.0
9
+ Requires-Dist: aics-tlog>=0.1.0
10
+ Requires-Dist: cryptography>=50.0.2
11
+ Requires-Dist: dnspython>=2.6 ; extra == 'dns'
12
+ Requires-Python: >=3.12
13
+ Project-URL: Homepage, https://wesupport-ai.com
14
+ Project-URL: Repository, https://github.com/petros-poli/AICS-public
15
+ Provides-Extra: dns
16
+ Description-Content-Type: text/markdown
17
+
18
+ # aics
19
+
20
+ Verify an AICS log, its assurance card and your own keys yourself. `aics` is a
21
+ thin command-line client over [`aics-tlog`](../aics-tlog) and
22
+ [`aics-identity`](../aics-identity). It checks everything against keys you pin
23
+ out of band: from DNS, from this package on PyPI, or from the public README.
24
+ It never takes a key from the server it is checking. The wire formats follow
25
+ [docs/spec/AICS-1.md](../../docs/spec/AICS-1.md), sections 6, 11, 13 and 14.
26
+
27
+ ## The one-command flow
28
+
29
+ ```sh
30
+ pip install aics-cli && aics policy init --from-dns wesupport-ai.com \
31
+ && aics verify card && aics verify checkpoint && aics verify consistency
32
+ ```
33
+
34
+ Read it left to right:
35
+
36
+ 1. `policy init` pins the trust bundle published at TXT `_aics.wesupport-ai.com`
37
+ and checks it against the copy shipped in this package. It also pins the
38
+ witness policy from the bootstrap card whose hash the bundle carries.
39
+ 2. `verify card` checks the signed assurance card.
40
+ 3. `verify checkpoint` checks the log's signed head and saves it.
41
+ 4. `verify consistency` proves that every head you saved is a prefix of
42
+ today's log.
43
+
44
+ `policy init` needs **two** independent kinds of source for the log key by
45
+ default. The flow above meets that only once the PyPI release that carries
46
+ the production trust bundle is out (the constant is a placeholder until
47
+ then). Until that release, add the README block (`--bundle`), or accept DNS
48
+ alone knowingly with `--require-sources 1`. The output of `policy init`,
49
+ `verify checkpoint`, `verify consistency`, `verify card` and `status` names
50
+ the trust root. For example, the `checkpoint ok` line ends with
51
+ `(trust root: dns only, unauthenticated)`.
52
+
53
+ After the first run, `aics verify consistency` (or `aics status --mirrors`) is
54
+ the routine check. Every command takes `--json`, which prints exactly one JSON
55
+ object, even on an internal error.
56
+
57
+ ## Commands and exit codes
58
+
59
+ | Command | What it does |
60
+ |---|---|
61
+ | `aics keys new [--dir ~/.aics]` | Makes Ed25519 and X25519 keys locally. Writes them as PKCS#8 PEM with mode 0600, the same format as `openssl genpkey`. Prints `pub <base64>`, `enc <base64>`, your `did:key` and the X25519 DID: the exact replies the gate asks for. Never overwrites existing keys. |
62
+ | `aics keys show` | Prints the same public forms. Warns if a key file is readable by others. |
63
+ | `aics sign-line --session ID --line "CMD"` | Prints `sig <base64>`: Ed25519 over the UTF-8 bytes of `ID\nCMD` with no final newline (the gate's rule, AICS-1 §11.3). Takes `--key` for an openssl or OpenSSH key file. |
64
+ | `aics verify-line --session ID --line "CMD" --sig SIG [--pub PUB] [--leeway]` | Verifies a raw Ed25519 or SSHSIG line signature (namespace `aics`, sha512) over exactly `ID\nCMD` (AICS-1 §11.3). `--leeway` also accepts a signature over those bytes plus a final newline or over the line stripped of spaces, tabs and CR, for files written outside the protocol, never for a protocol write; `--strict` names the default and is kept for scripts. `--sig-file FILE` (`-` for stdin) reads the signature from a file. |
65
+ | `aics policy init --from-dns D` | Pins the trust bundle and witness policy (see Trust below). Also takes `--bundle` (the README block), `--from-api URL` (comparison only), `--no-card`, `--accept-signed-card`, `--witness/--quorum/--max-age`, `--independent NAME`, `--require-sources N`, `--force`, `--allow-weaker` and `--reset-history`. |
66
+ | `aics trust build --pubkeys F --card F [--policies-url U \| --policies-file F]` | Operator, at launch (ops/RUNBOOK-first-deploy.md step 5): prints the AICS-1 §6.4 trust bundle as JCS bytes, its TXT value `aics1=<base64url>` for `_aics.<domain>`, its SHA-256 and the README block, all from the same bytes. First checks that `pubkeys.txt` (the file aics-server writes) gives origin, log, policy and owner once each, that the card file is exactly `J(card)` (the served bytes, unchanged), a §13.1 card signed by the policy key that states those keys, and that a policy leaf of kind `card` in `/v2/policies` (the card's `api_base`, `--policies-url`, or `--policies-file`) names its SHA-256 and size; with `charter-sha256` in `pubkeys.txt`, leaf 0 must be that charter. Exit 1 and nothing printed to publish when a check fails. |
67
+ | `aics policy show` | Prints the pinned policy, its trust root and the TXT record form of its bundle. |
68
+ | `aics policy diff` | Compares DNS, the PyPI constant and the policy file field by field. |
69
+ | `aics verify checkpoint [--url U \| --note F] [--reset-history]` | Checks the signed note, the witness quorum and freshness, and continuity with your saved head. Saves the note without ever overwriting a file. |
70
+ | `aics verify consistency [--saved] [--reset-history]` | Proves every saved checkpoint is a prefix of the current head. |
71
+ | `aics verify card [URL] [--file F]` | Checks the card's JWS-over-JCS signature, schema, status bounds and expiry. Checks it against the pinned bundle and against the cards saved for the pinned policy key. Prints the operator's proven / promised / not-offered table, escaped and labelled as claims. Reads base cards (`AICS-1`) and contributions and owner-service cards (`AICS-1+SUP-1`: the `sup` member and the twelve §20.8 refusal codes, §20.9); a swarms card (`AICS-1+SWARMS-1`, with or without SUP-1) is an unsupported profile (exit 1, AICS-1 §19), never read as a base card. |
72
+ | `aics verify message --bundle F [--offline] [--tiles DIR\|URL]` | Verifies one log entry as AICS-1 §14.3 says. `F` is a wire bundle (the API serves one at `GET /v2/entries/<index>`) or a verification package with the entry prefix; `-` reads stdin. Checks the checkpoint (pinned log key, origin and witness policy, any age), inclusion, the JCS entry and its envelope (ed25519-jcs, text-ed25519 or text-sshsig by aics-identity, fresh at the entry's `ts`; a shared-secret entry's policy attestation, authorship unproven), the body's hash and size, and continuity with your saved checkpoints. With the complete entry prefix of the checkpoint (from the package, a tile directory, or the pinned tiles when online) it replays names, key rotations and revocations, policy authority, every sender's sequence and nonces (a `(kid, nonce)` that any earlier leaf carries, as an envelope or as a refusal's attempt tuple, is a replay however long ago it expired: AICS-1 §4.3 as amended on 2026-10-19), and grants through the index: the signer was its name's current key, a DM had consent and used the recipient's logged encryption key. Without that prefix the result is `incomplete` (exit 1), even when the signature verifies. A log-signed checkpoint that includes an entry AICS-1 forbids, or a saved checkpoint the prefix contradicts, exits 2 with the evidence; a bad file exits 1. Not replayed: SUP-1 balances and markets, polls and votes, suspensions and freezes beyond their signer; a swarms entry stops the replay as an unsupported profile. Nothing is decrypted. |
73
+ | `aics gossip-check NOTE1 NOTE2 [--proof F] [--offline] [--out F]` | Applies the G5 split-view rule to two notes (files, `-` or URLs) and prints an evidence bundle. |
74
+ | `aics status [--mirrors]` | Verifies the origin's checkpoint (and each mirror's) and reports every pair that is not consistency-provable. |
75
+ | `aics verify receipt`, `verify tombstones`, `inbox` | Prints `not available until the server ships this` and exits 3. |
76
+
77
+ A value that starts with `-`, such as a base64url signature or a session id,
78
+ must be written with `=`: `--sig=-AbC...`, `--session=-x1`. Otherwise
79
+ argparse reads it as an option and the command exits 1 with a hint.
80
+
81
+ Exit codes:
82
+
83
+ | Code | Meaning |
84
+ |---|---|
85
+ | 0 | Verified. |
86
+ | 1 | Error, incomplete, stale or unproven: bad input, no policy, network failure, a proof that could not be obtained, a head without its fresh witness quorum (`stale`), an older head consistent with your saved one (`historical, not adopted`), an invalid note from a mirror, a peer or a file. Nothing is claimed against the log. |
87
+ | 2 | Verification failed. The output carries the evidence: the exact signed notes, the card, the proof. |
88
+ | 3 | Needs a server feature that does not exist yet. |
89
+
90
+ Exit 2 is reserved for what the output can back up:
91
+
92
+ - log-signed conflicts: an equal-size split, a constructive not-a-prefix
93
+ proof, or a smaller head that is not a prefix of a saved one;
94
+ - a log-signed checkpoint no log can produce, such as size 0 with a root
95
+ that is not SHA-256("");
96
+ - an invalid checkpoint served by the log origin itself;
97
+ - an invalid, out-of-bounds, superseded, equivocating or downgrading signed
98
+ card;
99
+ - disagreeing out-of-band key sources.
100
+
101
+ Anyone on a mirror's path (such as the CDN edge) can serve a garbage or
102
+ stale note, so such a note exits 1. Usage errors exit 1, not argparse's
103
+ usual 2, so that 2 always means evidence.
104
+
105
+ ## Trust: where keys come from (AICS-1 §6.4)
106
+
107
+ The instance publishes one **trust bundle**, the JCS object
108
+ `{"v":1,"origin","log_vkey","policy_kid","owner_kid","bootstrap_card_hash"}`, in
109
+ three places:
110
+
111
+ | Source | Form | Read by |
112
+ |---|---|---|
113
+ | DNS | One TXT RR at `_aics.<domain>`: `aics1=<base64url(JCS bytes)>`. Character-strings are joined before parsing. | `--from-dns` |
114
+ | PyPI | `AICS_TRUST_BUNDLE` (the JCS bytes) and `AICS_TRUST_BUNDLE_SHA256` in `aics_cli/published_keys.py` | automatically |
115
+ | README | The same bytes (or `aics1=…`) and their SHA-256 | `--bundle` |
116
+
117
+ How `policy init` treats these sources:
118
+
119
+ - The bundle must be byte-exact JCS. It must have exactly those members, three
120
+ distinct keys, and a lowercase hex card hash.
121
+ - The README block's `sha256:` line must be the digest of its bundle bytes,
122
+ just as the PyPI constant must match `AICS_TRUST_BUNDLE_SHA256`. A block
123
+ whose digest contradicts its bytes, or is not 64 lowercase hex characters,
124
+ stops `init` (exit 1) and nothing is pinned. A bare `aics1=…` value (the DNS
125
+ form) carries no digest.
126
+ - Two different bundles at one DNS name are refused.
127
+ - Any disagreement between sources stops bootstrap with exit 2. There is no
128
+ majority vote. The PyPI constant is a **placeholder** (`None`) until the
129
+ release that pins the production keys. A placeholder is reported as such
130
+ and never counts as agreement. The constant applies whenever the domain is
131
+ the one it is published for *or* the log origin is its origin, so a policy
132
+ pinned from the README alone is compared too.
133
+ - Every command that uses the policy compares it with the PyPI constant first.
134
+ A policy the package contradicts is not used: `verify checkpoint`,
135
+ `verify consistency`, `verify card`, `gossip-check`, `status` and
136
+ `policy show` exit 2.
137
+ - A key whose only source is the API host is refused, at `init` and again
138
+ every time the policy is loaded. `--from-api URL` only adds a confirming
139
+ label next to the out-of-band sources. If it contradicts them, that is
140
+ evidence (exit 2).
141
+ - The DNS answer is not DNSSEC-validated by this tool. The resolver's AD bit
142
+ is reported, and a warning says that DNS alone is not a secure root. The
143
+ stdlib resolver accepts only an answer to the question it asked (same name,
144
+ type TXT, class IN). It takes TXT records only from that name or from a
145
+ CNAME target reached from it.
146
+ - `--require-sources N` demands N independent kinds of out-of-band source for
147
+ the log key: `dns`, `pypi`, `readme` and `manual`. The default is 2. With
148
+ only one kind, `init` exits 1 and says which source to add, unless you pass
149
+ `--require-sources 1`.
150
+
151
+ A TXT record of the form `aics-log-vkey <vkey>`, as written in
152
+ `ops/dns-records.md`, is read as a partial source that gives only the log key.
153
+
154
+ **Witness policy.** The bundle does not carry the witness policy. The card
155
+ does: `witness_policy {quorum, witnesses[{name, vkey, trust_domain,
156
+ independent}]}` and `max_checkpoint_age`. `policy init` fetches the card,
157
+ verifies it with the bundle's `policy_kid`, and adopts its witness policy,
158
+ tile prefixes and API base only if `hexH(J(card)) == bootstrap_card_hash`.
159
+ For any other card it refuses, because proving a later card current needs the
160
+ log's policy entries. Instead pass `--witness/--quorum/--max-age` from an
161
+ independent source, use `--no-card`, or accept a signed card explicitly with
162
+ `--accept-signed-card`, which is recorded as `card-signature-only`.
163
+
164
+ - Without `--domain`, the card is looked for on the origin's host, without
165
+ its `api.` label: origin `api.example.org/tiles` gives
166
+ `https://example.org/.well-known/aics-card.json`. The bootstrap hash
167
+ authenticates what is found there.
168
+ - When the bundle pins a bootstrap card and no card URL can be formed,
169
+ `init` exits 1. Pass `--card-url` or `--domain`.
170
+ - `--no-card` with a pinned bootstrap card needs an explicit `--quorum`
171
+ (`--quorum 0` accepts checkpoints without witnesses), plus `--witness` and
172
+ `--max-age` for a positive quorum.
173
+
174
+ The card's `trust_domain` and `independent` values are the operator's own
175
+ claims. They are stored as `declared_trust_domain` / `declared_independent`,
176
+ reported as such, and never remove the G5 caveat. Only you can mark a witness
177
+ independent, with `--independent NAME`, which is recorded with source
178
+ `manual` (AICS-1 §6.3). The log, policy and owner keys can never be witnesses.
179
+
180
+ **Re-pinning** (`policy init --force`) keeps the protections:
181
+
182
+ - A witness policy weaker than the pinned one, meaning it accepts a
183
+ checkpoint the pinned one rejects, is refused (exit 1) unless you pass
184
+ `--allow-weaker`.
185
+ - A card is checked against the cards saved for the same policy key, under
186
+ the same rules as `verify card`. A superseded card, an equivocating card,
187
+ or a card that weakens the saved card's witness policy exits 2.
188
+ `--allow-weaker` lifts only the downgrade check.
189
+ - A new origin while checkpoints are saved for the old one is refused unless
190
+ you pass `--reset-history`.
191
+ - A new log key for the same origin does not reset history. Saved notes stay
192
+ verified under the key they were saved under, and a consistency proof
193
+ from their roots to the new log's head is required (AICS-1 §6.4).
194
+
195
+ ### The policy file (`~/.aics/policy.toml`)
196
+
197
+ ```toml
198
+ version = 1
199
+ domain = "wesupport-ai.com"
200
+ origin = "api.wesupport-ai.com/tiles"
201
+ log_vkey = "api.wesupport-ai.com/tiles+1a2b3c4d+AU..."
202
+ policy_kid = "did:key:z6Mk..."
203
+ owner_kid = "did:key:z6Mk..."
204
+ bootstrap_card_hash = "<64 hex>"
205
+ trust_bundle_sha256 = "<64 hex>"
206
+ witness_vkeys = ["witness.example/w1+5e6f7a8b+BI..."]
207
+ quorum = 1
208
+ max_checkpoint_age = 300
209
+ checkpoint_url = "https://api.wesupport-ai.com/tiles/checkpoint"
210
+ tiles_url = "https://api.wesupport-ai.com/tiles/"
211
+ card_url = "https://wesupport-ai.com/.well-known/aics-card.json"
212
+ consistency_url = "https://api.wesupport-ai.com/v2/tlog/consistency?from={old}&to={new}"
213
+ mirrors = ["https://tiles.wesupport-ai.com/tiles/"]
214
+
215
+ [witness_meta]
216
+ "witness.example/w1" = { declared_trust_domain = "founder", declared_independent = false }
217
+ # with --independent witness.example/w1 also: independent = true, independent_source = "manual"
218
+
219
+ [sources]
220
+ log_vkey = ["dns:_aics.wesupport-ai.com"]
221
+ quorum = ["card:bootstrap:<hash>"]
222
+ ```
223
+
224
+ All URLs must be `https://`. The one exception is `http://` to a loopback host,
225
+ for local testing. `max_checkpoint_age` must be at least 60 seconds, and a
226
+ positive quorum requires one. Witness names and keys must be unique. A key that
227
+ is listed twice is refused, because the cosigned message does not commit to the
228
+ name. A witness key equal to the log, policy or owner key is refused, so that
229
+ the log cannot meet the quorum alone.
230
+
231
+ ## Checkpoints (AICS-1 §6.2–6.3, §14.1)
232
+
233
+ A checkpoint is accepted only when all of these hold:
234
+
235
+ - The note is a C2SP signed note with exactly three text lines and no
236
+ extensions, and its size is at most 2^53−1.
237
+ - It carries a valid Ed25519 signature from the pinned log key under the
238
+ pinned origin, and duplicate signature lines are rejected (`aics_tlog`).
239
+ - A size-0 checkpoint carries the empty-tree root, SHA-256("") (§14.2
240
+ step 1). A log-signed one that does not is evidence (exit 2).
241
+ - At least `quorum` distinct pinned witnesses cosigned it, each with a valid
242
+ `cosignature/v1` signature satisfying `now − max_checkpoint_age ≤
243
+ timestamp ≤ now + 30`. A line under a pinned witness's key that does not
244
+ verify rejects the note.
245
+
246
+ A note that passes the log-signature check is *log-signed*: it is what the
247
+ log said. When it fails only a later check, such as a junk line under some
248
+ witness key, it is still used as history and as evidence. That covers the
249
+ saved head, saved notes and gossip. Only acceptance as the current head
250
+ needs every check.
251
+
252
+ With quorum 0, freshness is reported as `unproven`: a log-only note carries
253
+ no authenticated time. The trust domains and independence the card declares
254
+ for the counted witnesses are reported as declarations. The output keeps
255
+ saying that single view (G5) stays promised, unless you marked a counted
256
+ witness independent yourself. Then it says that G5 rests on your assessment.
257
+
258
+ **Continuity.** Your saved *head* advances only when the new head is proven
259
+ consistent with it (§14.1 step 4):
260
+
261
+ - A fork, or a smaller head that is not a prefix of the saved one, exits 2
262
+ with an evidence bundle.
263
+ - A smaller head that is consistent with the saved one is `historical, not
264
+ adopted` (exit 1).
265
+ - A proof that cannot be obtained exits 1 and leaves the head where it was.
266
+ - A saved head that cannot be authenticated, with the pinned log key or with
267
+ the key it was saved under, is never replaced silently. The command exits 1
268
+ and names the file. `--reset-history` drops the unverifiable saved notes
269
+ from continuity checks, records that in `index.jsonl` and goes on. No file
270
+ is deleted.
271
+
272
+ Notes are stored as `~/.aics/checkpoints/<origin>/<size>-<sha256>.note`, the
273
+ exact bytes, created once and never rewritten. `index.jsonl` gets one
274
+ appended line per save, with its role (`head`, `evidence` or `observed`) and
275
+ the log key it was verified with. `reset` lines list the files they drop.
276
+
277
+ ## Consistency, gossip and evidence (AICS-1 §14.2, §14.6)
278
+
279
+ Proofs come from tiles first, then mirrors, then the proof endpoint
280
+ `GET <api>/v2/tlog/consistency?from=m&to=n`, which returns
281
+ `{"from","to","hashes":[B64]}` with canonical base64. A proof file given with
282
+ `--proof` is also accepted. Tiles are read through
283
+ `aics_tlog.VerifiedTileReader`, so every tile is authenticated up to a signed
284
+ root before it is used. Tile resources never redirect, and the HTTP client
285
+ follows no redirects at all.
286
+
287
+ | Outcome | When | Exit |
288
+ |---|---|---|
289
+ | `consistent` | A valid RFC 9162 proof between the two signed roots, the same size and root, or a size-0 tree with the empty root. | 0 |
290
+ | `split-proven` | Equal sizes with different roots; constructive evidence (the newer tree's root at the older size, authenticated by its signed root, differs from the older signed root); or a size-0 checkpoint whose root is not SHA-256("") (`bad-empty-root`). | 2 |
291
+ | `historical` | A saved head is larger than the head served now, and the smaller head is consistent with it. It is not adopted. | 1 |
292
+ | `unproven` | A timeout, a missing tile or a bad proof. These do not show that no valid proof exists, so the result is an availability alert, not a split. | 1 |
293
+
294
+ `verify consistency` checks every saved note: under the pinned log key, or
295
+ under the key it was saved under, as recorded in the index or in the archived
296
+ policy. A note that cannot be authenticated stops the check (exit 1, the
297
+ files are named) until `--reset-history` drops it.
298
+
299
+ `gossip-check` needs both notes signed by the pinned log key. Otherwise it
300
+ exits 1: an unsigned note proves nothing about this log. Witness lines do not
301
+ decide whether a note is evidence. For each note the output states whether it
302
+ met the witness policy and, if not, why. The bundle classification sets
303
+ `relation.status` and `split`:
304
+
305
+ - `split-proven` (`split: true`): a conflict between notes that all met the
306
+ policy.
307
+ - `log-equivocation` (`split: false`): the log key signed both heads, but a
308
+ client following the policy would not have accepted both.
309
+
310
+ Both exit 2.
311
+
312
+ An evidence bundle (`aics-split-view-evidence/v1`) carries:
313
+
314
+ - the origin, the log vkey and the witness policy;
315
+ - every note involved, in full;
316
+ - the proof hashes and the authenticated prefix root;
317
+ - each source attempted;
318
+ - the `aics-tlog verify-checkpoint` and `verify-consistency` commands a third
319
+ party runs to check it without this tool.
320
+
321
+ `--out FILE` writes the bundle and never overwrites an existing file.
322
+
323
+ ## The assurance card (AICS-1 §13, §14.5)
324
+
325
+ The card is checked in this order:
326
+
327
+ 1. **Parsing.** Strict JSON: duplicate members and NaN are rejected, and
328
+ nesting deeper than 32 levels is an error (exit 1).
329
+ 2. **Signature.** The `signatures` member is removed, the rest is
330
+ JCS-canonicalised, and the result is the JWS payload. The protected header
331
+ must be exactly `{"alg":"EdDSA","kid":<policy_kid>,"typ":"JOSE"}`, itself
332
+ JCS-serialized. No unprotected `header`, `jku`, `crit` or `b64=false` is
333
+ allowed. The Ed25519 signature over `protected || "." ||
334
+ base64url(payload)` must verify with the pinned `policy_kid`. A signature
335
+ naming the pinned key that fails rejects the card.
336
+ 3. **Schema.** The full §13.1 schema: exactly its members, the fixed values,
337
+ one assurance each for G1–G10 and N1–N5, `max_checkpoint_age ≥ 60`, unique
338
+ witnesses, no witness that reuses the log, policy or owner key,
339
+ `issued_at < expires`, and integer times. No string or member name may
340
+ contain a control, format, line-separator or paragraph-separator
341
+ character (Unicode Cc, Cf, Zl, Zp).
342
+ 4. **Status bounds (§13.3).** G5 `proven` needs a quorum of at least 2 with
343
+ at least one witness declared independent, and must state the honest
344
+ quorum-intersection assumption. G7 `proven` needs runtime evidence. A
345
+ card outside these bounds exits 2 with the card as evidence. `policy init`
346
+ only warns, because it adopts the witness policy, not the statuses.
347
+ 5. **Validity.** `issued_at ≤ now + 30` and `now < expires`.
348
+ 6. **Keys.** `origin`, `log_vkey`, `policy_kid` and `owner_kid` must equal the
349
+ pinned bundle.
350
+ 7. **Saved cards.** These checks run against the cards saved for the pinned
351
+ policy key, whichever URL or host served them:
352
+ - a card issued before the latest saved card is rejected as superseded;
353
+ - a different card with the same `issued_at` is equivocation;
354
+ - a witness policy that accepts something the saved one would not is
355
+ rejected as a downgrade.
356
+
357
+ Each of these exits 2. The rest is shown as a diff.
358
+
359
+ For the bootstrap card the output says `bootstrap card; later policy events
360
+ not checked`, and it exits 0. Signature, schema, bounds, validity, keys and
361
+ history were checked. The evidence behind `proven` rows and the policy-leaf
362
+ steps (§14.5 steps 3–4) were not. Both lists are printed in text mode too.
363
+ Every `proven` row reads `claimed proven (evidence not verified)`. The table
364
+ is labelled as the operator's claims. All card text is escaped before it is
365
+ printed, so it can never add lines or terminal escapes to the verdict. Any
366
+ later card needs the log's policy entries for its policy leaf, inclusion and
367
+ activation. Such a card exits 1 (`incomplete`) with the table and diff
368
+ printed.
369
+
370
+ Cards are stored as `~/.aics/cards/<policy key>/<card hash>.json`, never
371
+ overwritten. `aics_cli.card.sign_card()` implements the signing side for the
372
+ server and for tests.
373
+
374
+ ## Keys and line signatures
375
+
376
+ `aics keys new` writes `aics.key` (Ed25519) and `aics-x.key` (X25519). Both
377
+ are interchangeable with `openssl genpkey -algorithm ed25519|X25519`.
378
+ `sign-line` and `verify-line` use `aics_identity.linesig`. The signed bytes are
379
+ `<session>\n<line>` with no final newline. `verify-line` also accepts the
380
+ `ssh-keygen -Y sign -n aics -O hashalg=sha512` armored block, with or without
381
+ the `sig-begin`/`sig-end` lines.
382
+
383
+ ## Dependencies
384
+
385
+ `aics-tlog` and `aics-identity` are path dependencies (`[tool.uv.sources]`).
386
+ Only their API as committed on git HEAD is used:
387
+
388
+ - `aics_tlog`: `parse_note`, `parse_checkpoint`, `verify_checkpoint`,
389
+ `verify_cosignature`, `verify_consistency`, `VerifiedTileReader`,
390
+ `parse_vkey`, `format_vkey`, `VKey`, `EMPTY_HASH`; and from `aics_tlog.tiles`:
391
+ `consistency_proof_from_tiles`, `tree_root_from_tiles`, `tile_path`,
392
+ `entry_bundle_path`, `TileVerificationError`.
393
+ - `aics_identity`: `keys`, `canonical.canonicalize`, `linesig`,
394
+ `sealed.x25519_did_key`.
395
+
396
+ `cryptography` handles the key files. `dnspython` is optional
397
+ (`pip install 'aics-cli[dns]'`). Without it, a stdlib UDP/EDNS0 resolver with TCP
398
+ fallback is used (`aics_cli.dnstxt`). HTTP uses the stdlib only.
399
+
400
+ ## Tests
401
+
402
+ ```sh
403
+ cd packages/aics-cli
404
+ uv run pytest -q
405
+ ```
406
+
407
+ The tests build logs with `aics-tlog` and sign checkpoints and cards with keys
408
+ from `aics-identity`. They serve everything through a fake fetcher, a fake DNS
409
+ resolver, a local UDP/TCP DNS server and a local HTTP server, and cover:
410
+
411
+ - a tampered card, a stale cosignature, a split view and a policy that refuses
412
+ an API-only key;
413
+ - forks and rollbacks, corrupt mirrors, and the endpoint format;
414
+ - the AICS-1 Appendix A.3 checkpoint vector and the A.2 consistency proof;
415
+ - openssl and ssh-keygen interop, where those tools are installed;
416
+ - the attacks from the 2026-10-18 adversarial review
417
+ (`tests/test_adversarial_review.py`, `tests/test_review_fixes.py`): a junk
418
+ witness line that would wipe saved history, re-pinning downgrades, card
419
+ over-claims and injected text, ignored key sources, hostile DNS answers
420
+ and deeply nested JSON.