Skip to content

Commit d4eef1e

Browse files
authored
docs: documentation for upstream 1.1.0, one place per fact (#514)
* docs: keep each fact in the doc comment of its declaration README.md is an overview. Pages that mirrored the API are removed or cut to cross-component material, and each declaration fact lives in its /// doc comment. Doc comments that the code contradicted are corrected. mkdocs navigation drops the removed pages. No code changes. * fix(docs): repair trimmed documentation checks * docs: restore event-loop state docs and the _closeBusy parameter reference * dcm: record the lower calculate-metrics count (12 to 9)
1 parent 49f03c4 commit d4eef1e

68 files changed

Lines changed: 652 additions & 3558 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ jobs:
125125
test -s out-mk/llms.txt
126126
test -s out-mk/llms-full.txt
127127
n=$(find out-mk -name '*.md' | wc -l)
128-
echo "raw .md endpoints: $n (floor 24)"
129-
[ "$n" -ge 24 ] || { echo "FAIL: expected at least 24 raw .md endpoints, found $n"; exit 1; }
128+
echo "raw .md endpoints: $n (floor 19)"
129+
[ "$n" -ge 19 ] || { echo "FAIL: expected at least 19 raw .md endpoints, found $n"; exit 1; }
130130
131131
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
132132
if: always()

‎CONTRIBUTING.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ bash example/web/run.sh
6969
```bash
7070
bash tool/gate.sh # Run ALL quality checks
7171
bash tool/test_python_ladder.sh # Python ladder (WASM, headless Chrome)
72+
bash tool/check_core_ref.sh # Check the shared core Git ref
73+
bash tool/check_no_core_src_imports.sh # Keep imports on core's public API
7274
```
7375

76+
`tool/check_core_ref.sh` keeps every tracked YAML core reference on the pin in
77+
`pubspec.yaml`. `tool/check_no_core_src_imports.sh` rejects imports from core
78+
implementation libraries.
79+
7480
## Code Quality
7581

7682
Run these checks after every code change:
@@ -298,7 +304,8 @@ After publishing:
298304
The project has a single `CHANGELOG.md` at the root. During development, add
299305
entries under `## Unreleased`. Before publishing, rename `## Unreleased` to the
300306
version heading. pub.dev displays the CHANGELOG entry matching the published
301-
version as the release notes.
307+
version as the release notes. Document every breaking change. Pin versions and
308+
read the changelog before upgrading.
302309

303310
### pub.dev admin setup (one-time)
304311

‎README.md‎

Lines changed: 43 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -8,148 +8,74 @@
88
[![Pages](https://github.com/runyaga/dart_monty/actions/workflows/pages.yaml/badge.svg)](https://runyaga.github.io/dart_monty/)
99
[![codecov](https://codecov.io/gh/runyaga/dart_monty/graph/badge.svg)](https://codecov.io/gh/runyaga/dart_monty)
1010

11-
[Live Demo](https://runyaga.github.io/dart_monty/) | [Documentation](https://github.com/runyaga/dart_monty/tree/main/docs) | [GitHub](https://github.com/runyaga/dart_monty)
11+
`dart_monty` runs restricted Python from Dart and Flutter on native and web
12+
platforms. It adds stateful runtimes, Dart host functions, extensions, event
13+
streams, and OS-call policy to the pool and session primitives supplied by
14+
`dart_monty_core`.
1215

13-
Sandboxed Python interpreter for Dart and Flutter. Run Python from native, web, and mobile — one package, every platform.
16+
## Installation
1417

15-
## Quick Start
16-
17-
### Install
18-
19-
```sh
20-
dart pub add dart_monty
21-
```
22-
23-
The low-level bindings (`dart_monty_core`) are pulled in transitively.
24-
25-
Flutter Web uses the worker assets declared by core's `flutter.assets`
26-
stanza and core's asset-path probe. Both packages remain pure Dart; no
27-
Flutter SDK dependency or initialization call is added to core.
28-
See [installation](docs/user/install.md#flutter-web) for bundling details.
29-
30-
For local development against a worktree, override with `path:`
31-
deps:
18+
The package and its core dependency are released from matching Git tags. Add
19+
the package and override core in the application `pubspec.yaml`:
3220

3321
```yaml
3422
dependencies:
3523
dart_monty:
36-
path: /path/to/dart_monty
37-
dart_monty_core:
38-
path: /path/to/dart_monty_core
39-
```
24+
git:
25+
url: https://github.com/runyaga/dart_monty.git
26+
ref: v0.110.0-dev.4
4027

41-
Then import the package:
42-
43-
```dart
44-
import 'package:dart_monty/dart_monty.dart';
28+
dependency_overrides:
29+
dart_monty_core:
30+
git:
31+
url: https://github.com/runyaga/dart_monty_core.git
32+
ref: v0.110.0-dev.4
4533
```
4634
47-
Now you can use `dart_monty` in three ways:
35+
See [Installation](docs/user/install.md) for direct core imports and local
36+
worktree dependencies.
4837
49-
**1. One-shot execution**
50-
51-
Use a pool and a session for execution:
38+
## Quick start
5239
5340
```dart
54-
final value = await Monty.withPool(
55-
(pool) => pool.withSession((session) => session.feedRun('2 + 2')),
56-
);
57-
print(value.dartValue); // 4
58-
```
59-
60-
**2. Stateful session**
41+
import 'package:dart_monty/dart_monty.dart';
6142

62-
```dart
63-
await Monty.withPool((pool) async {
64-
final session = await pool.checkout(typeCheck: true);
43+
Future<void> main() async {
44+
final runtime = await MontyRuntime.start();
6545
try {
66-
await session.feedRun('x: int = 42');
67-
final result = await session.feedRun('x * 2');
68-
print(result.dartValue); // 84
46+
await runtime.execute('x = 41').result;
47+
final value = await runtime.execute('x + 1').result;
48+
print(value.dartValue); // 42
6949
} finally {
70-
await session.close();
50+
await runtime.dispose();
7151
}
72-
});
73-
```
74-
75-
Type checking happens before each feed runs. A rejected feed throws
76-
`MontyTypingError`, available from core's public library. See the
77-
[type-checking example](example/type_check_demo.dart) for `typeCheckStubs`.
78-
79-
**3. Runtime with host functions and extensions**
80-
81-
`MontyRuntime` manages host functions, extensions, and long-lived sessions.
82-
Register `HostFunction`s to expose Dart callbacks to Python:
83-
84-
```dart
85-
Future<void> main() async {
86-
final runtime = (await MontyRuntime.start())
87-
..register(HostFunction(
88-
schema: const HostFunctionSchema(
89-
name: 'fetch',
90-
description: 'Fetch a URL',
91-
params: [HostParam(name: 'url', type: HostParamType.string)],
92-
),
93-
// DispatchMode.future lets Python `await fetch(url)` directly.
94-
// asyncio.gather over multiple calls runs them concurrently.
95-
dispatch: DispatchMode.future,
96-
handler: (args, _) async => httpClient.get(args['url']! as String),
97-
));
98-
99-
final result = await runtime.execute(
100-
'await fetch(base_url)',
101-
inputs: {'base_url': 'https://example.com/api'},
102-
).result;
103-
print(result.dartValue);
104-
await runtime.dispose();
10552
}
10653
```
10754

108-
For plugin-style wiring, pass `extensions`:
109-
110-
```dart
111-
final runtime = await MontyRuntime.start(
112-
extensions: [EventLoopExtension()],
113-
);
114-
```
115-
116-
## Examples
117-
118-
Runnable end-to-end demos, all platform-agnostic (FFI on the VM, WASM
119-
in Chrome — `Monty` dispatches to the same Rust ABI on every backend):
55+
See [Choosing an API](docs/user/api-reference.md) for the runtime and direct
56+
session tradeoffs.
12057

121-
| File | What it shows |
122-
|---|---|
123-
| [`example/example.dart`](example/example.dart) | Minimal pool/session one-shots, including error handling. |
124-
| [`example/type_check_demo.dart`](example/type_check_demo.dart) | Session type checking with `checkout(typeCheck: true)` and `typeCheckStubs`. |
125-
| [`example/dataclass_demo.dart`](example/dataclass_demo.dart) | Stateful dataclass round-trip across `MontyRuntime.execute` calls — produce, attribute-access, return, and re-bind a `@dataclass`, hydrating into a typed Dart `User` on the way back. |
58+
## Platform support
12659

127-
Run any of them with `dart run example/<file>.dart` from the repo root.
128-
For the native and web runners (with built Rust library and a COOP/COEP
129-
server), see `example/native/run.sh` and `example/web/run.sh`.
60+
The Dart VM and Flutter native targets use core's native worker. Browser
61+
targets use its Web Worker and WASM assets. Web deployments require the
62+
worker assets and cross-origin isolation headers. Native applications that use
63+
`MountDir` or self-contained executables must opt in to core's worker build.
64+
See [Deployment and Bundling](docs/user/deployment.md) for those constraints.
13065

13166
## Documentation
13267

133-
- [**Installation**](docs/user/install.md) — Add to your project
134-
- [**Overview**](docs/help.md) — API summary and quick start
135-
- [**Architecture**](docs/architecture/overview.md) — Module structure and internals
136-
- [**REPL Guide**](docs/user/repl.md) — Stateful interactive execution
137-
- [**Extensions**](docs/user/extensions.md) — EventLoop, Sandbox
138-
- [**Contributing**](CONTRIBUTING.md) — Build, run tests, gate scripts, release process
139-
- [**Contributor Setup**](docs/contributor/setup.md) — Toolchain install (Rust, Dart, Python)
140-
141-
## Stability and versioning
142-
143-
This package does **not** follow semantic versioning. Breaking changes can
144-
land in any release. The [CHANGELOG](CHANGELOG.md) is kept up-to-date with
145-
every breaking change, so pin to a specific version and read the changelog
146-
before upgrading.
68+
- [Stateful and concurrent execution](docs/deep-dives/bridge-concurrency.md)
69+
- [Host functions](docs/tutorials/host-functions-intro.md)
70+
- [Extensions](docs/deep-dives/extension-system.md)
71+
- [Sandbox lifecycle and isolation](docs/deep-dives/sandbox-architecture.md)
72+
- [Filesystem and workspace policy](docs/deep-dives/oscall-vfs.md)
73+
- [Failure propagation](docs/deep-dives/error-hierarchy.md)
74+
- [Testing](docs/contributor/testing.md)
14775

148-
We expect to stabilise the API and adopt semver when the package goes into
149-
production — roughly 1–3 months from now. If you are planning to depend on
150-
this package, please open an issue so we can factor your use-case into the
151-
stabilisation work.
76+
The public declarations are listed in
77+
[`lib/dart_monty.dart`](lib/dart_monty.dart).
15278

15379
## License
15480

155-
MIT License. See [LICENSE](LICENSE).
81+
The package uses the [MIT License](LICENSE).

‎docs/architecture/core-boundary.md‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
# Core and dart_monty ownership
22

3-
`dart_monty` pins the complete M6 core at
4-
`e962659e47d41e7b6bce3f15408f521940a3fcc7`. All five YAML references, browser
5-
asset links and examples agree on that commit.
3+
`dart_monty_core` owns sessions, worker transport, Python values, resource
4+
limits, host mounts, memory files, and OS-call defaults. Applications import
5+
additional core primitives from its public library. `dart_monty` imports no
6+
core implementation libraries.
67

7-
Core owns sessions, worker transport, values, OSAccess memory files, host mounts
8-
and OS-call defaults. Applications import those primitives from core's public
9-
library. dm exports nine selected core names and 36 dm names (45 total after
10-
D4a), and imports no core implementation libraries.
8+
`dart_monty` owns bridge events, host-function dispatch, extensions, runtime
9+
state, and private sandbox workspace composition. Workspace code uses core's
10+
public `OSAccess`, `MemoryFile`, snapshot, and mount operations.
1111

12-
The bridge drives public session feeds and reports host events. Extensions own
13-
application capabilities. Private workspace composition owns sandbox copy-in,
14-
collection, read-only protection, caps and disposal leases; it uses public
15-
`OSAccess` and `MemoryFile` operations. No legacy filesystem implementations or
16-
conditional filesystem exports remain in dm.
12+
`OSAccess` is a memory namespace. `MountDir` is native host backing. Native
13+
backing stays behind conditional imports so browser builds do not load native
14+
helpers.
1715

18-
`OSAccess` is a memory namespace; `MountDir` is native host backing. They are
19-
different facilities. D4b supplies owned native backing, a private driver over
20-
public snapshots, and bounded persistent transfer sessions. Conditional imports
21-
keep native helpers out of web builds. Child checkout remains the D1-8 stub
22-
until D5. D5 keeps child state and error implementation details private.
16+
The facade in `lib/dart_monty.dart` is the supported package surface.
17+
[dart_monty.dart](https://github.com/runyaga/dart_monty/blob/main/lib/dart_monty.dart)
18+
exports the core and high-level declarations.
2319

24-
See [workspace policy](../deep-dives/oscall-vfs.md) for the current transfer and
25-
accounting contract. Surface goldens and compiler fixtures enforce the facade;
26-
`tool/check_core_ref.sh` and `tool/check_no_core_src_imports.sh` enforce the
27-
pin and package boundary.
20+
See [Filesystem and workspace policy](../deep-dives/oscall-vfs.md) for transfer,
21+
accounting, and disposal guarantees.

0 commit comments

Comments
 (0)