no-ambient-authority: point Python work at the DisciplinedPython guide and checker
Trigger on any Python script work, and link the awesome-ocap style guide, attenuation notes, and disciplined_python_check.py, so conventions such as logging.info for status come from the guide rather than being invented. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d25d46557e
commit
b1cdb74e75
1 file changed
+19
-1
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: no-ambient-authority
|
name: no-ambient-authority
|
||||||
description: >-
|
description: >-
|
||||||
Use when writing or reviewing code whose functions touch I/O, clocks, random number generators, process.env, fetch, or filesystem; 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 asked what OCap discipline is. Source: the Agoric wiki's OCap Discipline page.
|
||||||
---
|
---
|
||||||
|
|
||||||
# OCap Discipline
|
# OCap Discipline
|
||||||
@@ -42,6 +42,24 @@ capability-based languages, systems, papers, and talks.
|
|||||||
authority they need, then *delegate* it downward.
|
authority they need, then *delegate* it downward.
|
||||||
3. **Test scripts** are named `test-*.js`; tests export nothing.
|
3. **Test scripts** are named `test-*.js`; tests export nothing.
|
||||||
|
|
||||||
|
## Python: DisciplinedPython
|
||||||
|
|
||||||
|
For Python, the rules above are spelled out in the DisciplinedPython style
|
||||||
|
guide in awesome-ocap (local checkout `~/projects/awesome-ocap`). Read it
|
||||||
|
before writing or refactoring a Python script; don't invent conventions.
|
||||||
|
|
||||||
|
- [ocap-py-style-guide.md](https://codeberg.org/dckc/awesome-ocap/src/branch/master/style-guide/ocap-py-style-guide.md):
|
||||||
|
the script recipe (`main(...)` plus `_script_io()` under the `__main__`
|
||||||
|
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.
|
||||||
|
- [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}/`.
|
||||||
|
|
||||||
## how this shows up in review
|
## how this shows up in review
|
||||||
|
|
||||||
- `crypto.getRandomValues()` called inside an exported function →
|
- `crypto.getRandomValues()` called inside an exported function →
|
||||||
|
|||||||
Reference in new issue
Block a user