Skip to content

[Docs] Interactive notebook tutorial runnable in Colab #137

@dgenio

Description

@dgenio

Summary

Add a Jupyter notebook version of the 5-minute tutorial (docs/tutorial.md) that runs top-to-bottom in Google Colab from a fresh environment, with an "Open in Colab" badge in the README.

Why this matters

A notebook is the lowest-friction first-run experience: no clone, no venv, no editor — pip install weaver-kernel in cell one and a working capability grant by cell three. For a security library whose value is best understood by seeing a denial and an audit trace happen, an interactive walkthrough converts curiosity into comprehension faster than any README.

Proposed scope

  • examples/notebooks/tutorial.ipynb: mirrors the tutorial flow (register → grant → invoke → deny → expand → explain), each step with a short markdown cell explaining what just happened and which invariant it demonstrates.
  • First cell: %pip install weaver-kernel + setting WEAVER_KERNEL_SECRET (with a note about what that secret is).
  • A deliberate PolicyDenied cell showing the structured denial explanation, and a final cell printing the full audit trail.
  • README badge ("Open in Colab") next to the tutorial link.
  • CI execution via jupyter nbconvert --execute (or nbclient) in the docs/test job so the notebook can't drift from the API — same philosophy as the CI-executed README quickstart.

Implementation notes

  • Async: notebooks have a running event loop; use await kernel.invoke(...) directly (top-level await works in IPython) rather than asyncio.run() — worth a one-line callout since it differs from the script examples.
  • Keep outputs stripped in git (pre-commit or nbstripout guidance in CONTRIBUTING) so diffs stay reviewable; CI re-executes to validate.
  • Pin nothing in the notebook; it should track the released package (pip install weaver-kernel) but CI should execute it against the working tree (editable install) to catch breakage before release.

Acceptance criteria

  • Notebook runs top-to-bottom in a fresh Colab runtime with no errors.
  • Covers grant, invoke, denial with explanation, handle expansion, and explain/audit.
  • Executed in CI against the working tree.
  • README carries an Open-in-Colab badge.

Out of scope

  • Multiple notebooks (one excellent tutorial first; federation/firewall deep-dives can follow).
  • Binder/JupyterLite hosting.

References

  • In-repo: docs/tutorial.md, examples/tutorial.py, tests/test_readme_quickstart.py (docs-can't-drift pattern).

Priority: P2 · Effort: S · Impact: Medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions