countersign-cli 0.2.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.
- countersign_cli-0.2.0/LICENSE +202 -0
- countersign_cli-0.2.0/NOTICE +5 -0
- countersign_cli-0.2.0/PKG-INFO +152 -0
- countersign_cli-0.2.0/README.md +131 -0
- countersign_cli-0.2.0/countersign/__init__.py +8 -0
- countersign_cli-0.2.0/countersign/__main__.py +4 -0
- countersign_cli-0.2.0/countersign/claims.py +245 -0
- countersign_cli-0.2.0/countersign/claimsdiff.py +134 -0
- countersign_cli-0.2.0/countersign/cli.py +411 -0
- countersign_cli-0.2.0/countersign/config.py +213 -0
- countersign_cli-0.2.0/countersign/engine.py +309 -0
- countersign_cli-0.2.0/countersign/jsscan.py +422 -0
- countersign_cli-0.2.0/countersign/pack.py +243 -0
- countersign_cli-0.2.0/countersign/plain.py +111 -0
- countersign_cli-0.2.0/countersign/receipt.py +255 -0
- countersign_cli-0.2.0/countersign/register.py +205 -0
- countersign_cli-0.2.0/countersign/reportclaims.py +182 -0
- countersign_cli-0.2.0/countersign/reproduce.py +167 -0
- countersign_cli-0.2.0/countersign/starter.py +242 -0
- countersign_cli-0.2.0/countersign/stubscan.py +257 -0
- countersign_cli-0.2.0/countersign_cli.egg-info/PKG-INFO +152 -0
- countersign_cli-0.2.0/countersign_cli.egg-info/SOURCES.txt +35 -0
- countersign_cli-0.2.0/countersign_cli.egg-info/dependency_links.txt +1 -0
- countersign_cli-0.2.0/countersign_cli.egg-info/entry_points.txt +2 -0
- countersign_cli-0.2.0/countersign_cli.egg-info/top_level.txt +1 -0
- countersign_cli-0.2.0/pyproject.toml +32 -0
- countersign_cli-0.2.0/setup.cfg +4 -0
- countersign_cli-0.2.0/tests/test_claims.py +168 -0
- countersign_cli-0.2.0/tests/test_claimsdiff.py +97 -0
- countersign_cli-0.2.0/tests/test_config.py +89 -0
- countersign_cli-0.2.0/tests/test_gate.py +306 -0
- countersign_cli-0.2.0/tests/test_init.py +164 -0
- countersign_cli-0.2.0/tests/test_jsscan.py +96 -0
- countersign_cli-0.2.0/tests/test_plain.py +94 -0
- countersign_cli-0.2.0/tests/test_register.py +110 -0
- countersign_cli-0.2.0/tests/test_reportclaims.py +108 -0
- countersign_cli-0.2.0/tests/test_stubscan.py +218 -0
|
@@ -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,152 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: countersign-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Your agent signs. Countersign proves it. Deterministic verification of agent completion claims, with tamper-evident receipts.
|
|
5
|
+
Author: Krishna
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Keywords: ai-agents,verification,ci,developer-tools,evidence
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
License-File: NOTICE
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
<!-- audited on 20260903 -->
|
|
23
|
+
# Countersign
|
|
24
|
+
|
|
25
|
+
**Your agent signs. Countersign proves it.**
|
|
26
|
+
|
|
27
|
+
Agents report work as done that was never done. A plausible final message becomes the record of what was verified, and nobody can tell the difference between "the tests passed" and "the agent said the tests passed". Countersign is the difference: a deterministic gate that makes every completion claim falsifiable, runs the disproof commands itself, and writes a tamper-evident receipt.
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
$ countersign verify
|
|
31
|
+
|
|
32
|
+
Countersign run 20260902T104512-a3f8c21e
|
|
33
|
+
commit 4a1b09f0c3d2e1f4a5b6c7d8e9f0a1b2c3d4e5f6 · 214 files scanned · 8120 ms
|
|
34
|
+
|
|
35
|
+
✗ marker scan: 3 finding(s)
|
|
36
|
+
src/app/page.tsx:41 [unfinished-marker] // TODO: wire this to the real API
|
|
37
|
+
src/lib/pricing.ts:12 [fabricated-data] return 49.99 // fake data until billing lands
|
|
38
|
+
src/lib/notify.py:8 [empty-body] def send_invoice(order_id: str) -> None:
|
|
39
|
+
✗ claim tests-pass: The full test suite passes
|
|
40
|
+
command: npm test
|
|
41
|
+
output ends: 2 failing
|
|
42
|
+
– note: test files were excluded from the marker scan by policy (exclude_tests = true)
|
|
43
|
+
|
|
44
|
+
NOT COUNTERSIGNED · 3 finding(s), 1 failed claim(s)
|
|
45
|
+
The work did not pass its own declared checks. Fix the code or the claims.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Why this exists
|
|
49
|
+
|
|
50
|
+
Three things became true at once in 2026:
|
|
51
|
+
|
|
52
|
+
1. Most new code is written by agents, and agents report success for work that was never finished, plausibly and at scale.
|
|
53
|
+
2. Teams ship that code anyway, because "looks done" and "is done" stopped being distinguishable by reading a pull request.
|
|
54
|
+
3. Vendors bolted self-verification onto their own agents, which is the fox counting the chickens. An audit trail written by the system being audited proves what the system says it did. Independence is structural, not a feature.
|
|
55
|
+
|
|
56
|
+
Countersign is independent by construction: it runs outside the agent, checks deterministically, records everything to a hash-chained register, and refuses to countersign work that did not pass its own declared checks. No model judgement participates in any verdict.
|
|
57
|
+
|
|
58
|
+
## The claims protocol
|
|
59
|
+
|
|
60
|
+
An agent (or a human) declares what is true about the work in `claims.toml`. Each claim carries the command that fails if the claim is false:
|
|
61
|
+
|
|
62
|
+
```toml
|
|
63
|
+
[[claim]]
|
|
64
|
+
id = "tests-pass"
|
|
65
|
+
statement = "The full test suite passes"
|
|
66
|
+
command = "npm test"
|
|
67
|
+
expect = "exit 0"
|
|
68
|
+
|
|
69
|
+
[[claim]]
|
|
70
|
+
id = "pricing-is-live"
|
|
71
|
+
statement = "The pricing endpoint returns real numbers, not seed data"
|
|
72
|
+
command = "curl -sf http://localhost:8000/api/pricing"
|
|
73
|
+
expect = "output contains"
|
|
74
|
+
needle = "unit_price"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If nobody can say what command would disprove the claim, the claim was not a claim. Three expectations are supported: `exit 0`, `nonzero exit` (negative tests), and `output contains`. A claim that runs past its timeout is killed together with everything it spawned and recorded as timed out, which fails the gate.
|
|
78
|
+
|
|
79
|
+
Claim commands run through your shell, in the repository root, with your privileges. Treat `claims.toml` like any other executable file in the repository: review changes to it the way you review changes to CI configuration.
|
|
80
|
+
|
|
81
|
+
## Who guards the claims
|
|
82
|
+
|
|
83
|
+
The agent that wrote the code can also write the claims, and the quiet way past a gate is not to fix the code but to soften the claim. Three things make that visible:
|
|
84
|
+
|
|
85
|
+
- **Required claims.** `required = ["tests-pass"]` in `countersign.toml` names claim ids that must be declared. A required claim nobody wrote is recorded as `MISSING` and fails the gate, so deleting the claim is not a way out.
|
|
86
|
+
- **Claims diff.** `countersign verify --claims-base origin/main` (the GitHub action does this on every pull request) compares `claims.toml` with the base branch and names every change. A removed claim, a changed expectation or a changed needle is a weakening and fails the gate (`fail_on_weakened = true`); a changed command is listed for the reviewer. `countersign claims diff --base origin/main` prints the same diff on its own.
|
|
87
|
+
- **Claims from the agent's own report.** `countersign claims from-report done.md` (or `-` for standard input) turns the checkable sentences of an agent's completion message into proposed claims: "all tests pass" becomes the repository's test command, "created src/pricing.ts" becomes a file check, a URL becomes a request that must succeed. The agent's own sentence is kept as the statement, so the receipt later says which promise held. Deterministic English patterns; a sentence whose command cannot be derived from the repository is reported as unresolved, never guessed. `--write` appends them to `claims.toml`.
|
|
88
|
+
- **Starter claims.** `countersign init` reads the build files that are actually there (package.json scripts, pytest or ruff configuration, go.mod, Cargo.toml) and writes a `claims.toml` with the stack's own test, lint and type-check commands, marking `tests-pass` as required. Nothing is guessed; a repository with no recognised build files gets a commented example.
|
|
89
|
+
|
|
90
|
+
## The marker scan
|
|
91
|
+
|
|
92
|
+
Eleven rules ported from a gate that ran daily on a production tree of more than 500 source files, reviewed file by file, with zero false positives, plus a structural check for functions whose body does nothing and explains nothing, which catches unfinished work that forgot to advertise itself. A bare `pass`, `...` or `{}` is a stub; the same body with a docstring or a comment is a documented decision (an irreversible migration's `downgrade`, a `close()` with nothing to close) and is not reported. Python is checked through the parser (overloads, abstract and Protocol methods are exempt). TypeScript and JavaScript are checked by a comment-and-string-aware scan of function declarations, class and object methods, and exported arrow functions (constructors, Angular lifecycle hooks, unexported callbacks, `.d.ts` and minified files are exempt). The eleven marker rules apply to every language in scope.
|
|
93
|
+
|
|
94
|
+
Point `paths` at production source (the original gate covered `src/`, the dashboard and the clients, not seed scripts or migrations); prose about stubs in a seed script is not a stub. Test files are excluded by policy: test code legitimately fabricates data, and the receipt says so. A genuine false positive is exempted in the source itself, on the line, where a reviewer sees it. Every exemption that suppressed a finding is counted on the receipt; a marker that suppresses nothing is reported as inert so a stale one cannot hide.
|
|
95
|
+
|
|
96
|
+
## Receipts, register, reproduce
|
|
97
|
+
|
|
98
|
+
- Every run appends to `.countersign/register.jsonl`: an append-only, hash-chained log. Edit any earlier line and `countersign check` says so. Appends are locked, so two runs on one checkout cannot break the chain by racing.
|
|
99
|
+
- What the register proves, exactly: that no entry was altered after it was written by anyone who did not also rewrite every entry after it. It lives on the machine that ran the checks, so on its own it is evidence against accident and against third parties, not against the machine's owner. Tamper evidence against the owner requires the register head to be anchored outside the machine, which is what a hosted anchoring service is for.
|
|
100
|
+
- Every run writes a JSON receipt and, unless asked not to, a single-file HTML evidence pack: what was checked, how, what was found, what was not covered. The pack and the Markdown summary open with the result in plain words, written for the person who asked the agent for the feature rather than for the engineer reading the tables. Receipts name the git commit and say whether the working tree had uncommitted changes when it was scanned.
|
|
101
|
+
- `countersign reproduce --run <id>` re-derives a recorded run from the same inputs and compares, result for result. The run recorded the SHA-256 of the config and claims files it read; if they changed, you are told.
|
|
102
|
+
|
|
103
|
+
Exit codes: 0 countersigned or reproduced, 1 not countersigned (or the register is damaged, or the run did not reproduce), 2 usage error including a config or claims file that cannot be honoured as written, 130 interrupted.
|
|
104
|
+
|
|
105
|
+
## Install and run
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install countersign-cli
|
|
109
|
+
countersign init # writes countersign.toml, a starter claims.toml and, on GitHub, the workflow
|
|
110
|
+
countersign verify # scan + claims gate; writes receipt, pack, register
|
|
111
|
+
countersign check # the register's hash chain
|
|
112
|
+
countersign reproduce --run <id>
|
|
113
|
+
countersign claims diff --base origin/main
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The user guide, with screenshots of every command and the evidence pack, is in [docs/guide.md](docs/guide.md).
|
|
117
|
+
|
|
118
|
+
Requires Python 3.11+. Zero dependencies, standard library only, on purpose: it has to run inside any CI runner, any locked-down laptop, any air-gapped environment, with no supply-chain conversation. It also runs without installing: `PYTHONPATH=/path/to/countersign python3 -m countersign verify`.
|
|
119
|
+
|
|
120
|
+
## CI usage (GitHub Actions)
|
|
121
|
+
|
|
122
|
+
When the repository's origin is on github.com, `countersign init` also writes `.github/workflows/countersign.yml`. Commit it and push; from then on every push to the default branch and every pull request runs Countersign, and pull requests get the claims diff against their base branch. The file it writes is this:
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
- uses: krishnaflipprr/countersign@v0.2
|
|
126
|
+
with:
|
|
127
|
+
config: countersign.toml
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The action runs Countersign straight from its checkout (no pip install, nothing fetched from PyPI). The verdict lands in the job step summary; receipts upload as artifacts. Set `fail-on: warn` to record without failing. If your config moves the receipts directory, set `receipts-dir` to match. Set `attest: true` to sign the receipt with GitHub Artifact Attestations; that is free for public repositories on every plan, while private repositories need GitHub Enterprise Cloud, and the job must grant `id-token: write` and `attestations: write`. Workflows run on the account that owns the repository, on its Actions minutes.
|
|
131
|
+
|
|
132
|
+
## What Countersign is not
|
|
133
|
+
|
|
134
|
+
Not a security scanner, not a code review, not a statement of fitness for any purpose. It verifies declared claims deterministically and scans for unfinished-work markers. The evidence pack states its own limits on every page.
|
|
135
|
+
|
|
136
|
+
## Try the demo
|
|
137
|
+
|
|
138
|
+
The `demo/` directory is a small accounts service with defects planted in it: a marker comment, fabricated return data, a function that raises instead of doing work, a body that does nothing, plus one true claim and one false one.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
countersign verify --config demo/countersign.toml
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Expected outcome: NOT COUNTERSIGNED, four findings listed, the false claim caught.
|
|
145
|
+
|
|
146
|
+
## Status and roadmap
|
|
147
|
+
|
|
148
|
+
v0.1. Working: marker scan, structural empty-body check (Python, TypeScript, JavaScript), claims protocol with required claims and claims diff, register, receipts, evidence packs, reproduce, CI action, starter config and workflow from `init`. Next: wiring cross-checks (frontend fields against the backend endpoints that feed them), agent-report parsing (verify the claims in an agent's own completion message), public receipt badges, hosted receipt verification. The register and evidence-pack engine is shared with Gaigentic Verify, which applies it to regulated finance decisions; Countersign itself makes no regulatory claim.
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
Apache License 2.0 (see LICENSE and NOTICE). The command line tool, every scan rule, the claims protocol, the register, receipts, packs and reproduce are open source in full and stay fully functional offline. Hosted anchoring, badges and organisation features are a separate service.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<!-- audited on 20260903 -->
|
|
2
|
+
# Countersign
|
|
3
|
+
|
|
4
|
+
**Your agent signs. Countersign proves it.**
|
|
5
|
+
|
|
6
|
+
Agents report work as done that was never done. A plausible final message becomes the record of what was verified, and nobody can tell the difference between "the tests passed" and "the agent said the tests passed". Countersign is the difference: a deterministic gate that makes every completion claim falsifiable, runs the disproof commands itself, and writes a tamper-evident receipt.
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
$ countersign verify
|
|
10
|
+
|
|
11
|
+
Countersign run 20260902T104512-a3f8c21e
|
|
12
|
+
commit 4a1b09f0c3d2e1f4a5b6c7d8e9f0a1b2c3d4e5f6 · 214 files scanned · 8120 ms
|
|
13
|
+
|
|
14
|
+
✗ marker scan: 3 finding(s)
|
|
15
|
+
src/app/page.tsx:41 [unfinished-marker] // TODO: wire this to the real API
|
|
16
|
+
src/lib/pricing.ts:12 [fabricated-data] return 49.99 // fake data until billing lands
|
|
17
|
+
src/lib/notify.py:8 [empty-body] def send_invoice(order_id: str) -> None:
|
|
18
|
+
✗ claim tests-pass: The full test suite passes
|
|
19
|
+
command: npm test
|
|
20
|
+
output ends: 2 failing
|
|
21
|
+
– note: test files were excluded from the marker scan by policy (exclude_tests = true)
|
|
22
|
+
|
|
23
|
+
NOT COUNTERSIGNED · 3 finding(s), 1 failed claim(s)
|
|
24
|
+
The work did not pass its own declared checks. Fix the code or the claims.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Why this exists
|
|
28
|
+
|
|
29
|
+
Three things became true at once in 2026:
|
|
30
|
+
|
|
31
|
+
1. Most new code is written by agents, and agents report success for work that was never finished, plausibly and at scale.
|
|
32
|
+
2. Teams ship that code anyway, because "looks done" and "is done" stopped being distinguishable by reading a pull request.
|
|
33
|
+
3. Vendors bolted self-verification onto their own agents, which is the fox counting the chickens. An audit trail written by the system being audited proves what the system says it did. Independence is structural, not a feature.
|
|
34
|
+
|
|
35
|
+
Countersign is independent by construction: it runs outside the agent, checks deterministically, records everything to a hash-chained register, and refuses to countersign work that did not pass its own declared checks. No model judgement participates in any verdict.
|
|
36
|
+
|
|
37
|
+
## The claims protocol
|
|
38
|
+
|
|
39
|
+
An agent (or a human) declares what is true about the work in `claims.toml`. Each claim carries the command that fails if the claim is false:
|
|
40
|
+
|
|
41
|
+
```toml
|
|
42
|
+
[[claim]]
|
|
43
|
+
id = "tests-pass"
|
|
44
|
+
statement = "The full test suite passes"
|
|
45
|
+
command = "npm test"
|
|
46
|
+
expect = "exit 0"
|
|
47
|
+
|
|
48
|
+
[[claim]]
|
|
49
|
+
id = "pricing-is-live"
|
|
50
|
+
statement = "The pricing endpoint returns real numbers, not seed data"
|
|
51
|
+
command = "curl -sf http://localhost:8000/api/pricing"
|
|
52
|
+
expect = "output contains"
|
|
53
|
+
needle = "unit_price"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If nobody can say what command would disprove the claim, the claim was not a claim. Three expectations are supported: `exit 0`, `nonzero exit` (negative tests), and `output contains`. A claim that runs past its timeout is killed together with everything it spawned and recorded as timed out, which fails the gate.
|
|
57
|
+
|
|
58
|
+
Claim commands run through your shell, in the repository root, with your privileges. Treat `claims.toml` like any other executable file in the repository: review changes to it the way you review changes to CI configuration.
|
|
59
|
+
|
|
60
|
+
## Who guards the claims
|
|
61
|
+
|
|
62
|
+
The agent that wrote the code can also write the claims, and the quiet way past a gate is not to fix the code but to soften the claim. Three things make that visible:
|
|
63
|
+
|
|
64
|
+
- **Required claims.** `required = ["tests-pass"]` in `countersign.toml` names claim ids that must be declared. A required claim nobody wrote is recorded as `MISSING` and fails the gate, so deleting the claim is not a way out.
|
|
65
|
+
- **Claims diff.** `countersign verify --claims-base origin/main` (the GitHub action does this on every pull request) compares `claims.toml` with the base branch and names every change. A removed claim, a changed expectation or a changed needle is a weakening and fails the gate (`fail_on_weakened = true`); a changed command is listed for the reviewer. `countersign claims diff --base origin/main` prints the same diff on its own.
|
|
66
|
+
- **Claims from the agent's own report.** `countersign claims from-report done.md` (or `-` for standard input) turns the checkable sentences of an agent's completion message into proposed claims: "all tests pass" becomes the repository's test command, "created src/pricing.ts" becomes a file check, a URL becomes a request that must succeed. The agent's own sentence is kept as the statement, so the receipt later says which promise held. Deterministic English patterns; a sentence whose command cannot be derived from the repository is reported as unresolved, never guessed. `--write` appends them to `claims.toml`.
|
|
67
|
+
- **Starter claims.** `countersign init` reads the build files that are actually there (package.json scripts, pytest or ruff configuration, go.mod, Cargo.toml) and writes a `claims.toml` with the stack's own test, lint and type-check commands, marking `tests-pass` as required. Nothing is guessed; a repository with no recognised build files gets a commented example.
|
|
68
|
+
|
|
69
|
+
## The marker scan
|
|
70
|
+
|
|
71
|
+
Eleven rules ported from a gate that ran daily on a production tree of more than 500 source files, reviewed file by file, with zero false positives, plus a structural check for functions whose body does nothing and explains nothing, which catches unfinished work that forgot to advertise itself. A bare `pass`, `...` or `{}` is a stub; the same body with a docstring or a comment is a documented decision (an irreversible migration's `downgrade`, a `close()` with nothing to close) and is not reported. Python is checked through the parser (overloads, abstract and Protocol methods are exempt). TypeScript and JavaScript are checked by a comment-and-string-aware scan of function declarations, class and object methods, and exported arrow functions (constructors, Angular lifecycle hooks, unexported callbacks, `.d.ts` and minified files are exempt). The eleven marker rules apply to every language in scope.
|
|
72
|
+
|
|
73
|
+
Point `paths` at production source (the original gate covered `src/`, the dashboard and the clients, not seed scripts or migrations); prose about stubs in a seed script is not a stub. Test files are excluded by policy: test code legitimately fabricates data, and the receipt says so. A genuine false positive is exempted in the source itself, on the line, where a reviewer sees it. Every exemption that suppressed a finding is counted on the receipt; a marker that suppresses nothing is reported as inert so a stale one cannot hide.
|
|
74
|
+
|
|
75
|
+
## Receipts, register, reproduce
|
|
76
|
+
|
|
77
|
+
- Every run appends to `.countersign/register.jsonl`: an append-only, hash-chained log. Edit any earlier line and `countersign check` says so. Appends are locked, so two runs on one checkout cannot break the chain by racing.
|
|
78
|
+
- What the register proves, exactly: that no entry was altered after it was written by anyone who did not also rewrite every entry after it. It lives on the machine that ran the checks, so on its own it is evidence against accident and against third parties, not against the machine's owner. Tamper evidence against the owner requires the register head to be anchored outside the machine, which is what a hosted anchoring service is for.
|
|
79
|
+
- Every run writes a JSON receipt and, unless asked not to, a single-file HTML evidence pack: what was checked, how, what was found, what was not covered. The pack and the Markdown summary open with the result in plain words, written for the person who asked the agent for the feature rather than for the engineer reading the tables. Receipts name the git commit and say whether the working tree had uncommitted changes when it was scanned.
|
|
80
|
+
- `countersign reproduce --run <id>` re-derives a recorded run from the same inputs and compares, result for result. The run recorded the SHA-256 of the config and claims files it read; if they changed, you are told.
|
|
81
|
+
|
|
82
|
+
Exit codes: 0 countersigned or reproduced, 1 not countersigned (or the register is damaged, or the run did not reproduce), 2 usage error including a config or claims file that cannot be honoured as written, 130 interrupted.
|
|
83
|
+
|
|
84
|
+
## Install and run
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install countersign-cli
|
|
88
|
+
countersign init # writes countersign.toml, a starter claims.toml and, on GitHub, the workflow
|
|
89
|
+
countersign verify # scan + claims gate; writes receipt, pack, register
|
|
90
|
+
countersign check # the register's hash chain
|
|
91
|
+
countersign reproduce --run <id>
|
|
92
|
+
countersign claims diff --base origin/main
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The user guide, with screenshots of every command and the evidence pack, is in [docs/guide.md](docs/guide.md).
|
|
96
|
+
|
|
97
|
+
Requires Python 3.11+. Zero dependencies, standard library only, on purpose: it has to run inside any CI runner, any locked-down laptop, any air-gapped environment, with no supply-chain conversation. It also runs without installing: `PYTHONPATH=/path/to/countersign python3 -m countersign verify`.
|
|
98
|
+
|
|
99
|
+
## CI usage (GitHub Actions)
|
|
100
|
+
|
|
101
|
+
When the repository's origin is on github.com, `countersign init` also writes `.github/workflows/countersign.yml`. Commit it and push; from then on every push to the default branch and every pull request runs Countersign, and pull requests get the claims diff against their base branch. The file it writes is this:
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
- uses: krishnaflipprr/countersign@v0.2
|
|
105
|
+
with:
|
|
106
|
+
config: countersign.toml
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The action runs Countersign straight from its checkout (no pip install, nothing fetched from PyPI). The verdict lands in the job step summary; receipts upload as artifacts. Set `fail-on: warn` to record without failing. If your config moves the receipts directory, set `receipts-dir` to match. Set `attest: true` to sign the receipt with GitHub Artifact Attestations; that is free for public repositories on every plan, while private repositories need GitHub Enterprise Cloud, and the job must grant `id-token: write` and `attestations: write`. Workflows run on the account that owns the repository, on its Actions minutes.
|
|
110
|
+
|
|
111
|
+
## What Countersign is not
|
|
112
|
+
|
|
113
|
+
Not a security scanner, not a code review, not a statement of fitness for any purpose. It verifies declared claims deterministically and scans for unfinished-work markers. The evidence pack states its own limits on every page.
|
|
114
|
+
|
|
115
|
+
## Try the demo
|
|
116
|
+
|
|
117
|
+
The `demo/` directory is a small accounts service with defects planted in it: a marker comment, fabricated return data, a function that raises instead of doing work, a body that does nothing, plus one true claim and one false one.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
countersign verify --config demo/countersign.toml
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Expected outcome: NOT COUNTERSIGNED, four findings listed, the false claim caught.
|
|
124
|
+
|
|
125
|
+
## Status and roadmap
|
|
126
|
+
|
|
127
|
+
v0.1. Working: marker scan, structural empty-body check (Python, TypeScript, JavaScript), claims protocol with required claims and claims diff, register, receipts, evidence packs, reproduce, CI action, starter config and workflow from `init`. Next: wiring cross-checks (frontend fields against the backend endpoints that feed them), agent-report parsing (verify the claims in an agent's own completion message), public receipt badges, hosted receipt verification. The register and evidence-pack engine is shared with Gaigentic Verify, which applies it to regulated finance decisions; Countersign itself makes no regulatory claim.
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
Apache License 2.0 (see LICENSE and NOTICE). The command line tool, every scan rule, the claims protocol, the register, receipts, packs and reproduce are open source in full and stay fully functional offline. Hosted anchoring, badges and organisation features are a separate service.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# audited on 20260903
|
|
2
|
+
"""Countersign: deterministic verification of agent completion claims.
|
|
3
|
+
|
|
4
|
+
The agent signs (claims the work is done). Countersign only countersigns
|
|
5
|
+
after the claim survived deterministic checks it can re-run later.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.2.0"
|