diff --git a/no-ambient-authority/SKILL.md b/no-ambient-authority/SKILL.md index 72478be..b8cd9a5 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; 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 @@ -42,6 +42,24 @@ capability-based languages, systems, papers, and talks. authority they need, then *delegate* it downward. 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 - `crypto.getRandomValues()` called inside an exported function →