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
This commit is contained in:
dckc committed 2026-11-14 15:50:50 -06:00
1 parent 5c477151cc
commit ff600b84f6
1 file changed
+7 -2
+7 -2
View File
@@ -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