stampcheck 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Noah Berry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,278 @@
1
+ Metadata-Version: 2.4
2
+ Name: stampcheck
3
+ Version: 0.1.0
4
+ Summary: Check whether your human approval step still filters anything, or has become a rubber stamp.
5
+ Author: Noah Berry
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/noahberry01123/stampcheck
8
+ Project-URL: Repository, https://github.com/noahberry01123/stampcheck
9
+ Project-URL: Issues, https://github.com/noahberry01123/stampcheck/issues
10
+ Project-URL: Discussions, https://github.com/noahberry01123/stampcheck/discussions
11
+ Keywords: human-in-the-loop,human review,approval,rubber stamp,automation bias,audit
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Quality Assurance
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Provides-Extra: postgres
20
+ Requires-Dist: psycopg[binary]>=3.1; extra == "postgres"
21
+ Provides-Extra: yaml
22
+ Requires-Dist: PyYAML>=6; extra == "yaml"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # stampcheck
28
+
29
+ **Find out whether the human approval step in your system still checks anything, or has quietly become a rubber stamp.**
30
+
31
+ ```bash
32
+ pip install stampcheck
33
+ stampcheck demo
34
+ ```
35
+
36
+ Until the first PyPI release is out, install from GitHub instead:
37
+
38
+ ```bash
39
+ pip install "git+https://github.com/noahberry01123/stampcheck.git"
40
+ ```
41
+
42
+ ![The report from stampcheck demo](https://raw.githubusercontent.com/noahberry01123/stampcheck/main/docs/screenshot.png)
43
+
44
+ `stampcheck demo` builds 8 weeks of synthetic refund approvals, checks them, prints a summary, and writes `report.html`. It takes a few seconds and needs no setup.
45
+
46
+ ## Why this exists
47
+
48
+ - Many systems send automated decisions (refunds, account locks, takedowns) to a person for approval.
49
+ - Over a few months, reviewers learn that the software is usually right, so they start approving almost everything, in seconds.
50
+ - The log still says "approved by sam", whether sam read the case or not.
51
+ - Existing tools record **that** a review happened. Nothing checks **whether** it was real.
52
+ - This tool reads the review data you already have and tells you, in plain language, when a review step has stopped filtering anything.
53
+
54
+ It is read-only. It never blocks, gates, or changes a decision. Nothing leaves your machine except an optional Slack alert. If it breaks, nothing in production breaks.
55
+
56
+ ## What the demo shows
57
+
58
+ The demo uses one scenario throughout: an AI support agent recommends whether to refund a customer, and human reviewers approve or reject. Refunds are split into three approval steps by size (under €50, €50 to €500, over €500). All names and data are synthetic. This is the real output:
59
+
60
+ ```text
61
+ Approval steps
62
+ RED refund_50_to_500 Drifted into the rubber-stamp zone: time per case went from 1 min 32 s to
63
+ 6 s and disagreement fell from 9.6% to 0% (the last 2 weeks vs the 4
64
+ weeks before). 25 cases nobody reviewed before the deadline were approved
65
+ anyway, between 2026-10-14 00:49 and 2026-10-14 02:58 UTC.
66
+ RED refund_under_50 1 of 2 reviewers matches the rubber-stamp pattern. 1 approval was used
67
+ for more than one action (case R-10937 ran 3 times); often a retry or
68
+ idempotency bug.
69
+ GREEN refund_over_500 No problems found.
70
+
71
+ Reviewers
72
+ RED sam Looks like rubber-stamping: agreed with the system on 218 of 219 decided cases,
73
+ median 4 s from opening to decision.
74
+ RED taylor Drifted into the rubber-stamp zone: time per case went from 1 min 32 s to 6 s and
75
+ disagreement fell from 9.6% to 0% (the last 2 weeks vs the 4 weeks before).
76
+ AMBER jordan One warning sign: fast (median 12 s per case), but still disagrees with the system
77
+ on 13% of cases.
78
+ GREEN alex Engaged: disagrees with the system on 10% of cases, median 2 min 33 s per case.
79
+ GREY kim Only 12 decided cases; at least 30 are needed to judge.
80
+ ```
81
+
82
+ Taylor is the interesting one: over the whole 8 weeks taylor's numbers look fine. Only the drift check, which compares the last 2 weeks with the 4 weeks before, catches the slide.
83
+
84
+ ## Start logging the one field you are probably missing
85
+
86
+ Most systems log when a reviewer **decided**. Very few log when the reviewer **opened** the case. Without `opened_at` you cannot tell a reviewer who read the case for two minutes from one who clicked approve two seconds after it appeared, so the rubber-stamp check cannot run. `record_review` is a one-line way to log it:
87
+
88
+ ```python
89
+ import stampcheck
90
+
91
+ stampcheck.record_review(
92
+ case_id="R-1001",
93
+ recommended="approve", # what the system proposed: "approve" or "reject"
94
+ decision="approve", # what the human did: "approve", "reject" or "escalate"
95
+ reviewer="sam",
96
+ opened_at=opened_at, # when the reviewer opened the case <- the important one
97
+ decided_at=decided_at, # when they decided
98
+ notified_at=queued_at, # optional: when the case entered the queue
99
+ category="refund_under_50", # optional: the approval step; each gets its own verdict
100
+ executed=1, # optional: how many times the approved action ran
101
+ )
102
+ ```
103
+
104
+ It writes to `./stampcheck.db` (SQLite). Pass `path="reviews.jsonl"` for JSON lines, or set `STAMPCHECK_PATH`. Timestamps can be datetimes, ISO strings, or epoch seconds. It never raises: if something goes wrong it logs a warning on the `stampcheck` logger and your approval flow carries on.
105
+
106
+ If nobody acted before a deadline and the system applied a default, log `decision="timeout_approve"` or `"timeout_reject"`.
107
+
108
+ When the human decides inside one function call (a CLI, a notebook, an agent loop), the context manager records both timestamps for you:
109
+
110
+ ```python
111
+ with stampcheck.review(case_id, recommended="approve", reviewer=user_id, category="refund_under_50") as r:
112
+ r.decision = ask_human(case) # opened_at was recorded on enter
113
+ r.executed = 1 if r.decision == "approve" else 0
114
+ # decided_at is recorded on exit
115
+ ```
116
+
117
+ ### FastAPI approval endpoint
118
+
119
+ In a web app, opening and deciding are two requests. Record `opened_at` when the case is served, and pass it at decision time. Full file: [examples/fastapi_endpoint.py](https://github.com/noahberry01123/stampcheck/blob/main/examples/fastapi_endpoint.py).
120
+
121
+ ```python
122
+ @app.get("/refunds/{case_id}")
123
+ def open_case(case_id: str, reviewer: str):
124
+ OPENED.setdefault((case_id, reviewer), datetime.now(timezone.utc)) # store this in your DB
125
+ return CASES[case_id]
126
+
127
+ @app.post("/refunds/{case_id}/decision")
128
+ def decide(case_id: str, body: Decision):
129
+ case = CASES[case_id]
130
+ executed = 0
131
+ if body.decision == "approve":
132
+ issue_refund(case)
133
+ executed = 1
134
+ stampcheck.record_review(case_id, case["recommended"], body.decision, body.reviewer,
135
+ opened_at=OPENED.get((case_id, body.reviewer)),
136
+ decided_at=datetime.now(timezone.utc), notified_at=case["created_at"],
137
+ category=refund_band(case["amount_eur"]), executed=executed)
138
+ ```
139
+
140
+ ### Human approval step in an LLM-agent workflow
141
+
142
+ The agent proposes a tool call, a person approves it, and the tool runs only after approval. Full file: [examples/agent_approval.py](https://github.com/noahberry01123/stampcheck/blob/main/examples/agent_approval.py).
143
+
144
+ ```python
145
+ proposal = agent_propose(ticket) # e.g. {"tool": "issue_refund", "recommendation": "approve", ...}
146
+ with stampcheck.review(ticket["id"], proposal["recommendation"], reviewer=current_user) as r:
147
+ show_to_human(proposal)
148
+ r.decision = wait_for_human() # "approve" / "reject" / "escalate"
149
+ r.executed = 0
150
+ if r.decision == "approve":
151
+ run_tool(proposal)
152
+ r.executed = 1
153
+ ```
154
+
155
+ Then, once you have a few weeks of reviews:
156
+
157
+ ```bash
158
+ stampcheck check --source stampcheck.db
159
+ ```
160
+
161
+ ## Reading your existing data
162
+
163
+ You don't need `record_review` to start. Point the check at what you already have.
164
+
165
+ ```bash
166
+ stampcheck check --source reviews.csv # CSV or TSV, delimiter detected
167
+ stampcheck check --source reviews.jsonl # JSON lines
168
+ stampcheck check --source app.db --query "SELECT * FROM approvals" # SQLite
169
+ pip install "stampcheck[postgres]"
170
+ stampcheck check --source "postgresql://readonly@db/app" --query "SELECT * FROM refund_reviews"
171
+ ```
172
+
173
+ The check needs one row per reviewed case with these fields:
174
+
175
+ | Field | Required | Meaning |
176
+ |---|---|---|
177
+ | `case_id` | yes | ID of the case or approval request |
178
+ | `recommended` | yes | What the system proposed: `approve` or `reject` |
179
+ | `decision` | yes | What happened: `approve`, `reject`, `escalate`, `timeout_approve`, `timeout_reject` |
180
+ | `decided_at` | yes | When the decision was made (for timeouts: when the deadline passed) |
181
+ | `opened_at` | for the rubber-stamp check | When the reviewer opened the case |
182
+ | `reviewer` | for per-reviewer checks | Who decided |
183
+ | `category` | no | The approval step, e.g. refund size band. Each one gets its own verdict |
184
+ | `notified_at` | no | When the case entered the queue. Shown for context only, never used for verdicts |
185
+ | `executed` | for the duplicate check | How many times the approved action ran. Several rows per case are summed |
186
+
187
+ Common column names are recognised automatically (`id`, `ticket_id`, `reviewed_by`, `first_viewed_at`, `closed_at`, `outcome`, and more). The check always prints the mapping it used. If your names differ, write a mapping file:
188
+
189
+ ```bash
190
+ stampcheck init # writes a commented stampcheck.yaml with every threshold and mapping option
191
+ ```
192
+
193
+ ```yaml
194
+ # stampcheck.yaml (or pass any file with --mapping)
195
+ columns:
196
+ case_id: Ref
197
+ recommended: AI Suggestion
198
+ reviewer: Handled By
199
+ opened_at: First Opened
200
+ decided_at: Closed At
201
+ category: Refund Band
202
+ values:
203
+ recommended:
204
+ REFUND: approve
205
+ NO_REFUND: reject
206
+ decision:
207
+ AUTO_APPROVED_SLA: timeout_approve
208
+ AUTO_REJECTED_SLA: timeout_reject
209
+ timezone: Europe/Berlin # for timestamps without an offset
210
+ ```
211
+
212
+ A worked example with semicolons, renamed columns, local time offsets, and a few garbage rows:
213
+
214
+ ```bash
215
+ stampcheck check --source examples/messy.csv --mapping examples/mapping.yaml
216
+ ```
217
+
218
+ Values are never guessed. Common spellings (`approved`, `Rejected`, `denied`, `ESCALATED`) are accepted and shown in the output. Anything else is listed with a count, and those rows are skipped until you map the value. Rows with no case ID or an unreadable `decided_at` are skipped and counted too.
219
+
220
+ The mapping file is YAML or JSON. PyYAML is optional (`pip install "stampcheck[yaml]"`); without it a built-in reader handles the simple format above.
221
+
222
+ ## The checks
223
+
224
+ Each check gives a verdict (GREEN, AMBER, RED, or GREY for "not enough data") and one sentence explaining why. GREY never means pass.
225
+
226
+ | Check | RED / AMBER when | What it usually means |
227
+ |---|---|---|
228
+ | Rubber-stamping | RED: at least 30 decided cases, the 95% upper bound on the disagreement rate is under 5%, **and** the median time from opened to decided is under 30 s. AMBER: only one of the two | Reviewers click through. The step filters nothing |
229
+ | Drift | RED: the last 2 weeks are in the rubber-stamp zone and the 4 weeks before were not. AMBER: time per case fell by half or more, or disagreement fell clearly | A careful reviewer or team is sliding toward rubber-stamping |
230
+ | Silent timeout approvals | RED: any case nobody reviewed before the deadline that still ended in approval | A timeout default that fails open |
231
+ | Duplicate execution | RED: one approval used for more than one action | A retry or idempotency bug |
232
+ | Suspicious logging | AMBER: `recommended` or `decision` has one value on 99% or more of rows, or the second value appears fewer than 5 times | The column may be hard-coded. Findings built on it are not trusted |
233
+ | Queue overload | AMBER: more than 200 decided cases per reviewer per working day | Shown as the likely cause next to a rubber-stamp finding |
234
+
235
+ Disagreement means the human did something other than what the system recommended (escalating counts). The upper bound is the Wilson 95% interval: with few cases, a 0% rate is weak evidence, so the check asks how high the true rate could plausibly be. Time per case always comes from `opened_at`, never `notified_at`, because time since notification includes time waiting in the queue.
236
+
237
+ Every threshold lives in the config file (`stampcheck init` writes them all with comments), and every report prints the values it used.
238
+
239
+ ## Output, exit codes, CI
240
+
241
+ `stampcheck check` prints a summary and writes two files to `--out` (default: the current folder):
242
+
243
+ - `report.html`: self-contained (no network). Verdict per approval step, a scatter of time per case against disagreement with the danger zone shaded, weekly trends, how verdicts are decided, and a data-quality section (rows read, rows skipped and why, missing columns, checks that could not run).
244
+ - `result.json`: the same results for scripts.
245
+
246
+ Exit codes: `0` nothing is RED, `1` something is RED, `2` input error. That makes it usable from cron or CI.
247
+
248
+ To get a Slack message only when something is RED or newly drifting:
249
+
250
+ ```bash
251
+ stampcheck check --source "$DB_URL" --query "SELECT * FROM refund_reviews" --alert "slack:$SLACK_WEBHOOK_URL"
252
+ ```
253
+
254
+ "Newly" is judged against the previous `result.json` in the output folder. A ready-to-copy weekly GitHub Actions workflow is in [examples/github-actions/stampcheck.yml](https://github.com/noahberry01123/stampcheck/blob/main/examples/github-actions/stampcheck.yml).
255
+
256
+ ## Reviewers are people
257
+
258
+ Alerts are team-level and step-level by default: they say "1 of 2 reviewers matches the rubber-stamp pattern", not who. Add `--per-reviewer` to name reviewers in alerts, and `--pseudonymize` to replace reviewer IDs with salted hashes everywhere (set `pseudonymize_salt` in the config so hashes stay stable between runs). The terminal output and the local report show reviewer IDs, because you already have that data.
259
+
260
+ A rubber-stamp pattern usually points to a system problem: queues that are too long, a model that is right so often that checking feels pointless, or a timeout default that fails open. Patterns in review data are evidence to look into, not proof that anyone did anything wrong.
261
+
262
+ In some countries, monitoring individual employees needs agreement first. In Germany, for example, it usually needs the works council's (Betriebsrat) agreement. Start at team level.
263
+
264
+ ## Development
265
+
266
+ ```bash
267
+ pip install -e ".[dev,yaml]"
268
+ pytest
269
+ python tests/make_messy.py # regenerate examples/messy.csv after changing the demo
270
+ ```
271
+
272
+ Python 3.10 or newer. No runtime dependencies. MIT licence.
273
+
274
+ ## Compliance
275
+
276
+ These checks relate to GDPR Art. 22, which covers decisions based solely on automated processing (official guidance says human involvement only counts if it is meaningful, not a token rubber stamp), and to EU AI Act Art. 14, which requires effective human oversight of high-risk AI systems from December 2027. The tool gives you evidence about your review step. It isn't legal advice.
277
+
278
+ Using this at work and need something for your DPO, auditor or a customer audit? Tell us what you need in [GitHub Discussions](https://github.com/noahberry01123/stampcheck/discussions).
@@ -0,0 +1,252 @@
1
+ # stampcheck
2
+
3
+ **Find out whether the human approval step in your system still checks anything, or has quietly become a rubber stamp.**
4
+
5
+ ```bash
6
+ pip install stampcheck
7
+ stampcheck demo
8
+ ```
9
+
10
+ Until the first PyPI release is out, install from GitHub instead:
11
+
12
+ ```bash
13
+ pip install "git+https://github.com/noahberry01123/stampcheck.git"
14
+ ```
15
+
16
+ ![The report from stampcheck demo](https://raw.githubusercontent.com/noahberry01123/stampcheck/main/docs/screenshot.png)
17
+
18
+ `stampcheck demo` builds 8 weeks of synthetic refund approvals, checks them, prints a summary, and writes `report.html`. It takes a few seconds and needs no setup.
19
+
20
+ ## Why this exists
21
+
22
+ - Many systems send automated decisions (refunds, account locks, takedowns) to a person for approval.
23
+ - Over a few months, reviewers learn that the software is usually right, so they start approving almost everything, in seconds.
24
+ - The log still says "approved by sam", whether sam read the case or not.
25
+ - Existing tools record **that** a review happened. Nothing checks **whether** it was real.
26
+ - This tool reads the review data you already have and tells you, in plain language, when a review step has stopped filtering anything.
27
+
28
+ It is read-only. It never blocks, gates, or changes a decision. Nothing leaves your machine except an optional Slack alert. If it breaks, nothing in production breaks.
29
+
30
+ ## What the demo shows
31
+
32
+ The demo uses one scenario throughout: an AI support agent recommends whether to refund a customer, and human reviewers approve or reject. Refunds are split into three approval steps by size (under €50, €50 to €500, over €500). All names and data are synthetic. This is the real output:
33
+
34
+ ```text
35
+ Approval steps
36
+ RED refund_50_to_500 Drifted into the rubber-stamp zone: time per case went from 1 min 32 s to
37
+ 6 s and disagreement fell from 9.6% to 0% (the last 2 weeks vs the 4
38
+ weeks before). 25 cases nobody reviewed before the deadline were approved
39
+ anyway, between 2026-10-14 00:49 and 2026-10-14 02:58 UTC.
40
+ RED refund_under_50 1 of 2 reviewers matches the rubber-stamp pattern. 1 approval was used
41
+ for more than one action (case R-10937 ran 3 times); often a retry or
42
+ idempotency bug.
43
+ GREEN refund_over_500 No problems found.
44
+
45
+ Reviewers
46
+ RED sam Looks like rubber-stamping: agreed with the system on 218 of 219 decided cases,
47
+ median 4 s from opening to decision.
48
+ RED taylor Drifted into the rubber-stamp zone: time per case went from 1 min 32 s to 6 s and
49
+ disagreement fell from 9.6% to 0% (the last 2 weeks vs the 4 weeks before).
50
+ AMBER jordan One warning sign: fast (median 12 s per case), but still disagrees with the system
51
+ on 13% of cases.
52
+ GREEN alex Engaged: disagrees with the system on 10% of cases, median 2 min 33 s per case.
53
+ GREY kim Only 12 decided cases; at least 30 are needed to judge.
54
+ ```
55
+
56
+ Taylor is the interesting one: over the whole 8 weeks taylor's numbers look fine. Only the drift check, which compares the last 2 weeks with the 4 weeks before, catches the slide.
57
+
58
+ ## Start logging the one field you are probably missing
59
+
60
+ Most systems log when a reviewer **decided**. Very few log when the reviewer **opened** the case. Without `opened_at` you cannot tell a reviewer who read the case for two minutes from one who clicked approve two seconds after it appeared, so the rubber-stamp check cannot run. `record_review` is a one-line way to log it:
61
+
62
+ ```python
63
+ import stampcheck
64
+
65
+ stampcheck.record_review(
66
+ case_id="R-1001",
67
+ recommended="approve", # what the system proposed: "approve" or "reject"
68
+ decision="approve", # what the human did: "approve", "reject" or "escalate"
69
+ reviewer="sam",
70
+ opened_at=opened_at, # when the reviewer opened the case <- the important one
71
+ decided_at=decided_at, # when they decided
72
+ notified_at=queued_at, # optional: when the case entered the queue
73
+ category="refund_under_50", # optional: the approval step; each gets its own verdict
74
+ executed=1, # optional: how many times the approved action ran
75
+ )
76
+ ```
77
+
78
+ It writes to `./stampcheck.db` (SQLite). Pass `path="reviews.jsonl"` for JSON lines, or set `STAMPCHECK_PATH`. Timestamps can be datetimes, ISO strings, or epoch seconds. It never raises: if something goes wrong it logs a warning on the `stampcheck` logger and your approval flow carries on.
79
+
80
+ If nobody acted before a deadline and the system applied a default, log `decision="timeout_approve"` or `"timeout_reject"`.
81
+
82
+ When the human decides inside one function call (a CLI, a notebook, an agent loop), the context manager records both timestamps for you:
83
+
84
+ ```python
85
+ with stampcheck.review(case_id, recommended="approve", reviewer=user_id, category="refund_under_50") as r:
86
+ r.decision = ask_human(case) # opened_at was recorded on enter
87
+ r.executed = 1 if r.decision == "approve" else 0
88
+ # decided_at is recorded on exit
89
+ ```
90
+
91
+ ### FastAPI approval endpoint
92
+
93
+ In a web app, opening and deciding are two requests. Record `opened_at` when the case is served, and pass it at decision time. Full file: [examples/fastapi_endpoint.py](https://github.com/noahberry01123/stampcheck/blob/main/examples/fastapi_endpoint.py).
94
+
95
+ ```python
96
+ @app.get("/refunds/{case_id}")
97
+ def open_case(case_id: str, reviewer: str):
98
+ OPENED.setdefault((case_id, reviewer), datetime.now(timezone.utc)) # store this in your DB
99
+ return CASES[case_id]
100
+
101
+ @app.post("/refunds/{case_id}/decision")
102
+ def decide(case_id: str, body: Decision):
103
+ case = CASES[case_id]
104
+ executed = 0
105
+ if body.decision == "approve":
106
+ issue_refund(case)
107
+ executed = 1
108
+ stampcheck.record_review(case_id, case["recommended"], body.decision, body.reviewer,
109
+ opened_at=OPENED.get((case_id, body.reviewer)),
110
+ decided_at=datetime.now(timezone.utc), notified_at=case["created_at"],
111
+ category=refund_band(case["amount_eur"]), executed=executed)
112
+ ```
113
+
114
+ ### Human approval step in an LLM-agent workflow
115
+
116
+ The agent proposes a tool call, a person approves it, and the tool runs only after approval. Full file: [examples/agent_approval.py](https://github.com/noahberry01123/stampcheck/blob/main/examples/agent_approval.py).
117
+
118
+ ```python
119
+ proposal = agent_propose(ticket) # e.g. {"tool": "issue_refund", "recommendation": "approve", ...}
120
+ with stampcheck.review(ticket["id"], proposal["recommendation"], reviewer=current_user) as r:
121
+ show_to_human(proposal)
122
+ r.decision = wait_for_human() # "approve" / "reject" / "escalate"
123
+ r.executed = 0
124
+ if r.decision == "approve":
125
+ run_tool(proposal)
126
+ r.executed = 1
127
+ ```
128
+
129
+ Then, once you have a few weeks of reviews:
130
+
131
+ ```bash
132
+ stampcheck check --source stampcheck.db
133
+ ```
134
+
135
+ ## Reading your existing data
136
+
137
+ You don't need `record_review` to start. Point the check at what you already have.
138
+
139
+ ```bash
140
+ stampcheck check --source reviews.csv # CSV or TSV, delimiter detected
141
+ stampcheck check --source reviews.jsonl # JSON lines
142
+ stampcheck check --source app.db --query "SELECT * FROM approvals" # SQLite
143
+ pip install "stampcheck[postgres]"
144
+ stampcheck check --source "postgresql://readonly@db/app" --query "SELECT * FROM refund_reviews"
145
+ ```
146
+
147
+ The check needs one row per reviewed case with these fields:
148
+
149
+ | Field | Required | Meaning |
150
+ |---|---|---|
151
+ | `case_id` | yes | ID of the case or approval request |
152
+ | `recommended` | yes | What the system proposed: `approve` or `reject` |
153
+ | `decision` | yes | What happened: `approve`, `reject`, `escalate`, `timeout_approve`, `timeout_reject` |
154
+ | `decided_at` | yes | When the decision was made (for timeouts: when the deadline passed) |
155
+ | `opened_at` | for the rubber-stamp check | When the reviewer opened the case |
156
+ | `reviewer` | for per-reviewer checks | Who decided |
157
+ | `category` | no | The approval step, e.g. refund size band. Each one gets its own verdict |
158
+ | `notified_at` | no | When the case entered the queue. Shown for context only, never used for verdicts |
159
+ | `executed` | for the duplicate check | How many times the approved action ran. Several rows per case are summed |
160
+
161
+ Common column names are recognised automatically (`id`, `ticket_id`, `reviewed_by`, `first_viewed_at`, `closed_at`, `outcome`, and more). The check always prints the mapping it used. If your names differ, write a mapping file:
162
+
163
+ ```bash
164
+ stampcheck init # writes a commented stampcheck.yaml with every threshold and mapping option
165
+ ```
166
+
167
+ ```yaml
168
+ # stampcheck.yaml (or pass any file with --mapping)
169
+ columns:
170
+ case_id: Ref
171
+ recommended: AI Suggestion
172
+ reviewer: Handled By
173
+ opened_at: First Opened
174
+ decided_at: Closed At
175
+ category: Refund Band
176
+ values:
177
+ recommended:
178
+ REFUND: approve
179
+ NO_REFUND: reject
180
+ decision:
181
+ AUTO_APPROVED_SLA: timeout_approve
182
+ AUTO_REJECTED_SLA: timeout_reject
183
+ timezone: Europe/Berlin # for timestamps without an offset
184
+ ```
185
+
186
+ A worked example with semicolons, renamed columns, local time offsets, and a few garbage rows:
187
+
188
+ ```bash
189
+ stampcheck check --source examples/messy.csv --mapping examples/mapping.yaml
190
+ ```
191
+
192
+ Values are never guessed. Common spellings (`approved`, `Rejected`, `denied`, `ESCALATED`) are accepted and shown in the output. Anything else is listed with a count, and those rows are skipped until you map the value. Rows with no case ID or an unreadable `decided_at` are skipped and counted too.
193
+
194
+ The mapping file is YAML or JSON. PyYAML is optional (`pip install "stampcheck[yaml]"`); without it a built-in reader handles the simple format above.
195
+
196
+ ## The checks
197
+
198
+ Each check gives a verdict (GREEN, AMBER, RED, or GREY for "not enough data") and one sentence explaining why. GREY never means pass.
199
+
200
+ | Check | RED / AMBER when | What it usually means |
201
+ |---|---|---|
202
+ | Rubber-stamping | RED: at least 30 decided cases, the 95% upper bound on the disagreement rate is under 5%, **and** the median time from opened to decided is under 30 s. AMBER: only one of the two | Reviewers click through. The step filters nothing |
203
+ | Drift | RED: the last 2 weeks are in the rubber-stamp zone and the 4 weeks before were not. AMBER: time per case fell by half or more, or disagreement fell clearly | A careful reviewer or team is sliding toward rubber-stamping |
204
+ | Silent timeout approvals | RED: any case nobody reviewed before the deadline that still ended in approval | A timeout default that fails open |
205
+ | Duplicate execution | RED: one approval used for more than one action | A retry or idempotency bug |
206
+ | Suspicious logging | AMBER: `recommended` or `decision` has one value on 99% or more of rows, or the second value appears fewer than 5 times | The column may be hard-coded. Findings built on it are not trusted |
207
+ | Queue overload | AMBER: more than 200 decided cases per reviewer per working day | Shown as the likely cause next to a rubber-stamp finding |
208
+
209
+ Disagreement means the human did something other than what the system recommended (escalating counts). The upper bound is the Wilson 95% interval: with few cases, a 0% rate is weak evidence, so the check asks how high the true rate could plausibly be. Time per case always comes from `opened_at`, never `notified_at`, because time since notification includes time waiting in the queue.
210
+
211
+ Every threshold lives in the config file (`stampcheck init` writes them all with comments), and every report prints the values it used.
212
+
213
+ ## Output, exit codes, CI
214
+
215
+ `stampcheck check` prints a summary and writes two files to `--out` (default: the current folder):
216
+
217
+ - `report.html`: self-contained (no network). Verdict per approval step, a scatter of time per case against disagreement with the danger zone shaded, weekly trends, how verdicts are decided, and a data-quality section (rows read, rows skipped and why, missing columns, checks that could not run).
218
+ - `result.json`: the same results for scripts.
219
+
220
+ Exit codes: `0` nothing is RED, `1` something is RED, `2` input error. That makes it usable from cron or CI.
221
+
222
+ To get a Slack message only when something is RED or newly drifting:
223
+
224
+ ```bash
225
+ stampcheck check --source "$DB_URL" --query "SELECT * FROM refund_reviews" --alert "slack:$SLACK_WEBHOOK_URL"
226
+ ```
227
+
228
+ "Newly" is judged against the previous `result.json` in the output folder. A ready-to-copy weekly GitHub Actions workflow is in [examples/github-actions/stampcheck.yml](https://github.com/noahberry01123/stampcheck/blob/main/examples/github-actions/stampcheck.yml).
229
+
230
+ ## Reviewers are people
231
+
232
+ Alerts are team-level and step-level by default: they say "1 of 2 reviewers matches the rubber-stamp pattern", not who. Add `--per-reviewer` to name reviewers in alerts, and `--pseudonymize` to replace reviewer IDs with salted hashes everywhere (set `pseudonymize_salt` in the config so hashes stay stable between runs). The terminal output and the local report show reviewer IDs, because you already have that data.
233
+
234
+ A rubber-stamp pattern usually points to a system problem: queues that are too long, a model that is right so often that checking feels pointless, or a timeout default that fails open. Patterns in review data are evidence to look into, not proof that anyone did anything wrong.
235
+
236
+ In some countries, monitoring individual employees needs agreement first. In Germany, for example, it usually needs the works council's (Betriebsrat) agreement. Start at team level.
237
+
238
+ ## Development
239
+
240
+ ```bash
241
+ pip install -e ".[dev,yaml]"
242
+ pytest
243
+ python tests/make_messy.py # regenerate examples/messy.csv after changing the demo
244
+ ```
245
+
246
+ Python 3.10 or newer. No runtime dependencies. MIT licence.
247
+
248
+ ## Compliance
249
+
250
+ These checks relate to GDPR Art. 22, which covers decisions based solely on automated processing (official guidance says human involvement only counts if it is meaningful, not a token rubber stamp), and to EU AI Act Art. 14, which requires effective human oversight of high-risk AI systems from December 2027. The tool gives you evidence about your review step. It isn't legal advice.
251
+
252
+ Using this at work and need something for your DPO, auditor or a customer audit? Tell us what you need in [GitHub Discussions](https://github.com/noahberry01123/stampcheck/discussions).
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "stampcheck"
7
+ version = "0.1.0"
8
+ description = "Check whether your human approval step still filters anything, or has become a rubber stamp."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Noah Berry" }]
13
+ requires-python = ">=3.10"
14
+ dependencies = []
15
+ keywords = ["human-in-the-loop", "human review", "approval", "rubber stamp", "automation bias", "audit"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Operating System :: OS Independent",
19
+ "Intended Audience :: Developers",
20
+ "Topic :: Software Development :: Quality Assurance",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/noahberry01123/stampcheck"
25
+ Repository = "https://github.com/noahberry01123/stampcheck"
26
+ Issues = "https://github.com/noahberry01123/stampcheck/issues"
27
+ Discussions = "https://github.com/noahberry01123/stampcheck/discussions"
28
+
29
+ [project.optional-dependencies]
30
+ postgres = ["psycopg[binary]>=3.1"]
31
+ yaml = ["PyYAML>=6"]
32
+ dev = ["pytest>=7"]
33
+
34
+ [project.scripts]
35
+ stampcheck = "stampcheck.cli:main"
36
+
37
+ [tool.setuptools]
38
+ packages = ["stampcheck"]
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """Check whether a human approval step still filters anything, or has become a rubber stamp."""
2
+ from .config import NAME, VERSION as __version__
3
+ from .record import record_review, review
4
+
5
+ __all__ = ["NAME", "record_review", "review", "__version__"]
@@ -0,0 +1,46 @@
1
+ """Slack alert: posts only when something is RED or a drift finding is new since the last run."""
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ from urllib.request import Request, urlopen
6
+
7
+ from .checks import AMBER, RED
8
+ from .config import NAME
9
+
10
+
11
+ def parse_target(spec: str) -> str:
12
+ """'slack:https://hooks.slack.com/...' -> the webhook URL. Raises ValueError otherwise."""
13
+ kind, _, url = spec.partition(":")
14
+ if kind != "slack" or not url.startswith("https://"):
15
+ raise ValueError(f"--alert must look like slack:https://hooks.slack.com/services/..., got {spec!r}")
16
+ return url
17
+
18
+
19
+ def _drifting(result: dict | None) -> set[tuple[str, str]]:
20
+ if not result:
21
+ return set()
22
+ return {(kind, name) for kind in ("steps", "reviewers") for name, item in result.get(kind, {}).items()
23
+ for f in item["findings"] if f["check"] == "drift" and f["verdict"] in (RED, AMBER)}
24
+
25
+
26
+ def should_alert(result: dict, previous: dict | None) -> bool:
27
+ return result["red"] or bool(_drifting(result) - _drifting(previous))
28
+
29
+
30
+ def message(result: dict, previous: dict | None, per_reviewer: bool, report: str) -> str:
31
+ new = _drifting(result) - _drifting(previous)
32
+ lines = [f"*{NAME}*: an approval review check needs a look (data up to {result['period']['to'][:10]})"]
33
+ for kind in ("steps", "reviewers") if per_reviewer else ("steps",):
34
+ for name, item in sorted(result[kind].items()):
35
+ hits = [f["message"] for f in item["findings"]
36
+ if f["verdict"] == RED or (f["check"] == "drift" and (kind, name) in new and f["verdict"] == AMBER)]
37
+ if hits:
38
+ lines.append(f"- {item['verdict']} {name}: {' '.join(hits)}")
39
+ lines.append(f"Report: {report}")
40
+ return "\n".join(lines)
41
+
42
+
43
+ def send(url: str, text: str) -> None:
44
+ req = Request(url, data=json.dumps({"text": text}).encode(), headers={"Content-Type": "application/json"})
45
+ with urlopen(req, timeout=10) as resp:
46
+ resp.read()