From ff600b84f692fbf55718ef3e1386ac4c61ac9375 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 14 Nov 2026 15:50:50 -0600 Subject: [PATCH] no-ambient-authority: tests don't check logs; note DPY010 :memory: bug Logging is an operational side effect, not output, so tests check stdout and return values, never log records. This follows from the style guide's choice to call logging directly rather than inject it. Moved here from py-doctest, where it was orthogonal. The checker flags sqlite3.connect(':memory:'), which isn't I/O. Note it beside "treat each finding as a bug" until the checker learns the exemption. Generated-by: Claude Opus 5.5 --- no-ambient-authority/SKILL.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/no-ambient-authority/SKILL.md b/no-ambient-authority/SKILL.md index 3384acc..c0acd44 100644 --- a/no-ambient-authority/SKILL.md +++ b/no-ambient-authority/SKILL.md @@ -1,7 +1,7 @@ --- name: no-ambient-authority description: >- - Use when writing or reviewing code whose functions touch I/O, clocks, random number generators, process.env, fetch, or filesystem; before writing or refactoring any Python script (DisciplinedPython style guide and checker); when someone says "ambient authority", "wash your mouth out", or "that function shouldn't reach for that"; when debating dependency injection or default-arg seams; when asked what OCap discipline is. Source: the Agoric wiki's OCap Discipline page. + Use when writing or reviewing code whose functions touch I/O, clocks, random number generators, process.env, fetch, or filesystem; before writing or refactoring any Python script (DisciplinedPython style guide and checker); when someone says "ambient authority", "wash your mouth out", or "that function shouldn't reach for that"; when debating dependency injection or default-arg seams; when tempted to inject a logger or assert on log output; when asked what OCap discipline is. Source: the Agoric wiki's OCap Discipline page. --- # OCap Discipline @@ -53,12 +53,17 @@ before writing or refactoring a Python script; don't invent conventions. guard, authorities passed by name), standard authority names (`argv`, `cwd`, `stdout`, `connect`, `run`, `urlopen`, `now`), prompt attenuation in `main`, and **status goes through `logging.info(...)` directly**: not - `print`, not `stderr` writes, not an injected logger. + `print`, not `stderr` writes, not an injected logger. Logging is an + operational side effect, not output: tests check `stdout` and return + values, never log records, since correctness doesn't depend on logging. - [disciplined-python-attenuation.md](https://codeberg.org/dckc/awesome-ocap/src/branch/master/style-guide/disciplined-python-attenuation.md): narrowing authority function by function. - Checker: run `~/projects/awesome-ocap/tools/disciplined_python_check.py path/to/script.py` and treat each finding as a bug. It points at matching before/after examples in `tests/fixtures/disciplined_python/{errors,fixed}/`. + Known checker bug: it flags `sqlite3.connect(':memory:')` as DPY010, + but an in-memory database is private to the process, not I/O; leave + that call in place. - Calibration: Python can't enforce a capability boundary (name mangling and introspection get around any wrapper), so for a small script, attenuation that lives mostly in names is fine. An example: a read-only