continuo-python-runtime 0.12.0__py3-none-any.whl → 0.14.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ """The distributions installed in the running Python environment.
2
+
3
+ ``continuo-runtime packages`` prints them, so that a producer bundle records exactly
4
+ what the image its service runs holds.
5
+ """
6
+
7
+ import logging
8
+ import re
9
+ from importlib import metadata
10
+
11
+ logger = logging.getLogger(__name__)
12
+
13
+ _NAME_SEPARATORS = re.compile(r"[-_.]+")
14
+
15
+
16
+ def _normalise_name(name: str) -> str:
17
+ """The PEP 503 normalised form of a distribution name: lower case, every run of ``-``, ``_`` and ``.`` one ``-``."""
18
+ return _NAME_SEPARATORS.sub("-", name).lower()
19
+
20
+
21
+ def installed_packages() -> dict[str, str]:
22
+ """Every installed distribution, as ``{normalised name: version}``.
23
+
24
+ When two distributions normalise to the same name (one on each of two ``sys.path``
25
+ entries), the version ``importlib.metadata.version`` resolves wins: the one an
26
+ ``import`` of the package would find. When the metadata cannot resolve the name
27
+ (a folder that does not carry its distribution's name), the first one found wins.
28
+ A distribution whose metadata has no name or no version is logged and left out,
29
+ since it names nothing a release can record.
30
+ """
31
+ packages: dict[str, str] = {}
32
+ for dist in metadata.distributions():
33
+ name = dist.metadata.get("Name")
34
+ version = dist.metadata.get("Version")
35
+ if not name or not version:
36
+ logger.warning(
37
+ "skipping a distribution under %s: its metadata has name %r and version %r",
38
+ dist.locate_file(""),
39
+ name,
40
+ version,
41
+ )
42
+ continue
43
+ key = _normalise_name(name)
44
+ if key not in packages:
45
+ packages[key] = version
46
+ continue
47
+ try:
48
+ packages[key] = metadata.version(key)
49
+ except metadata.PackageNotFoundError:
50
+ logger.warning(
51
+ "%s appears twice and importlib.metadata cannot tell which one it resolves, "
52
+ "keeping the first one found (%s)",
53
+ key,
54
+ packages[key],
55
+ )
56
+ return packages
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: continuo-python-runtime
3
- Version: 0.12.0
3
+ Version: 0.14.0
4
4
  Summary: Runtime harness, contract tooling, and CI lint for Continuo python nodes.
5
5
  Author: Simone Carolini
6
6
  Maintainer: Simone Carolini
@@ -12,7 +12,7 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: Programming Language :: Python :: 3.14
13
13
  Requires-Python: >=3.14
14
14
  Requires-Dist: boto3==1.43.114
15
- Requires-Dist: continuo-contracts==0.1.0
15
+ Requires-Dist: continuo-contracts==0.4.1
16
16
  Requires-Dist: continuo-engine-contract==0.10.0
17
17
  Requires-Dist: pyarrow==26.0.0
18
18
  Requires-Dist: pyyaml==6.0.3
@@ -27,18 +27,19 @@ Description-Content-Type: text/markdown
27
27
 
28
28
  Runtime harness, contract tooling, and CI lint for Continuo python nodes.
29
29
  This repo is what domain data teams (marketing, finance, …) template from to
30
- ship a python node into Continuo: write a contract + a `run(ctx)` script,
31
- push to `main`, and CI does the rest — lint, validate, merge, build, publish,
32
- and register the release with Continuo.
30
+ ship a python node into Continuo: write an ODCS contract and a `run(ctx)`
31
+ script, push to `main`, and CI does the rest — lint, validate, build and push
32
+ the image, pack the contracts, upload the bundle and register the release with
33
+ Continuo.
33
34
 
34
35
  ## What this repo is
35
36
 
36
37
  Five artifacts come out of this repository:
37
38
 
38
39
  - **The `continuo-python-runtime` PyPI package** — the `continuo-runtime` CLI
39
- (`validate` / `merge` / `hash` / `lint` / `run` / `validation-op`) and the
40
- harness library (`conform()`, `RunContext`, the error taxonomy) that domain
41
- repos install.
40
+ (`validate` / `pack` / `hash` / `packages` / `lint` / `run` /
41
+ `validation-op`) and the harness library (`conform()`, `RunContext`, the
42
+ error taxonomy) that domain repos install.
42
43
  - **The `continuo-engine-contract` PyPI package** — the `WarehouseAdapter`
43
44
  port, the contract schema, the shared SQL/type/config guards, and the
44
45
  sentinel result-block format. Adapter authors outside this repo pin it.
@@ -70,9 +71,8 @@ amd64 + arm64 digests one multi-arch tag. See `CONTRIBUTING.md` (Releasing).
70
71
  ### What this repo owns
71
72
 
72
73
  This repository owns the entire python-node surface: the engine contract, the three
73
- engine adapters, the validation runner, and the node harness. The former
74
- `continuo-validation` repository was merged in — there is no longer a separate
75
- validation-side port, adapter class, entry-point group, or image. One
74
+ engine adapters, the validation runner, and the node harness. There is no
75
+ separate validation-side port, adapter class, entry-point group or image: one
76
76
  `WarehouseAdapter` per engine serves both the data plane (`fetch` /
77
77
  `ensure_table` / `load`, plus the opt-in `table_columns` / `append` / `upsert`
78
78
  capabilities) and validation (`ensure_schema` / `drop_schema` /
@@ -128,7 +128,7 @@ the Go parser has not been taught is a production outage, not a refactor.
128
128
  service name (one service name per domain repo).
129
129
  3. Configure repository variables in GitHub (Settings → Secrets and
130
130
  variables → Actions): `REGISTRY` (your Docker registry), `BUCKET` (your
131
- S3 bucket for contract artifacts), `RELEASE_ENDPOINT` (the base
131
+ S3 bucket for the contract bundle), `RELEASE_ENDPOINT` (the base
132
132
  URL of your continuo install, `scheme://host[:port]` with no path, the origin of continuo's
133
133
  `auth.publicUrl`). The
134
134
  workflow calls `<RELEASE_ENDPOINT>/api/v1/releases` with its GitHub Actions
@@ -141,128 +141,282 @@ the Go parser has not been taught is a production outage, not a refactor.
141
141
  `packages: write`) — no registry secret is needed for that. If you point
142
142
  `REGISTRY` at a different or private registry, add your own `docker
143
143
  login` step to `release.yml`.
144
- 5. Write a contract file under `contracts/` (see
145
- `template/contracts/example.yml`) and a script under `scripts/` that
146
- implements `run(ctx)` (see `template/scripts/example.py`). A node that
147
- only needs to land a csv file needs no script at all — see
148
- `template/contracts/example_csv.yml` and "Node kinds" below.
144
+ 5. Write one ODCS contract per node under `contracts/`, named
145
+ `<table>.odcs.yaml` (see `template/contracts/example.odcs.yaml` and
146
+ "Contract files" below), and a script under `scripts/` that implements
147
+ `run(ctx)` (see `template/scripts/example.py`). A node that only needs to
148
+ land a csv file needs no script at all — see
149
+ `template/contracts/example_csv.odcs.yaml` and "Node kinds" below.
149
150
  6. Push to `main`. The `release.yml` workflow lints the scripts, validates
150
- and merges the contracts, builds and pushes the image, uploads the merged
151
- contract to S3, and POSTs the release.
152
-
153
- ### Upgrading an existing domain repo
154
-
155
- `validate` / `merge` / `hash` now hand every declared read to a real SQL
156
- parser (sqlglot, via `continuo_engine_contract.sql.ensure_single_read`)
157
- instead of scanning it for a leading `SELECT`/`WITH`. Two things follow for a
158
- repo written before this, on its next release: SQL a driver would accept but
159
- a parser will not — most commonly a driver-specific bind placeholder like
160
- psycopg2's `%(name)s`, which `ctx.read(name)` could never have used anyway —
161
- now fails validation, and engine-specific syntax (postgres `~`, `@>`, …)
162
- needs `--dialect <engine>`, which a repo should be passing regardless since
163
- Continuo bind-checks every read in the install's own warehouse dialect. Run
164
- the pre-flight check once before your next release; it reports every affected
165
- read at once:
151
+ the contracts, builds and pushes the image, packs the contracts into
152
+ `odcs-bundle.json`, uploads it to S3, and POSTs the release with
153
+ `"kind": "python-odcs"`.
154
+
155
+ ## Contract files
156
+
157
+ Each node has one contract: an ODCS v3.2.0 data contract in `contracts/`,
158
+ named after its table, `<table>.odcs.yaml`, or `<schema>.<table>.odcs.yaml`
159
+ when two nodes of one service share a table name. The `continuo-contracts`
160
+ library reads each file strictly (YAML 1.2 core, with no aliases, no duplicate
161
+ keys and one document per file) and checks it. `validate`, `pack`, `hash` and
162
+ the harness load the folder the same way; the harness skips the read-query
163
+ checks.
164
+
165
+ ```yaml
166
+ apiVersion: v3.2.0
167
+ kind: DataContract
168
+ id: analytics.example # <schema>.<table>, in lower case
169
+ name: example # the table
170
+ version: "0" # continuo numbers published versions itself; this value is ignored
171
+ description:
172
+ purpose: Replace with your node
173
+ team:
174
+ name: your-team # the team that owns the node
175
+ customProperties:
176
+ - {vendor: continuo, property: schedule, value: daily}
177
+ - {vendor: continuo, property: criticality, value: SECONDARY}
178
+ - {vendor: continuo, property: script, value: scripts/example.py}
179
+ - vendor: continuo
180
+ property: readQueries
181
+ value:
182
+ orders: select order_id, customer_id, amount from analytics.upstream_orders
183
+ customers: select customer_id, name from analytics.upstream_customers
184
+ schema:
185
+ - name: example
186
+ physicalType: table
187
+ properties:
188
+ - {name: order_id, physicalType: INTEGER, required: true}
189
+ - {name: customer_name, physicalType: "VARCHAR(64)"}
190
+ - {name: amount, physicalType: "NUMERIC(10,2)", required: true}
191
+ ```
192
+
193
+ - `id` is `<schema>.<table>` in lower case; `name` and the schema object's
194
+ `name` are the table.
195
+ - `team.name` is the node's owner and `description.purpose` its description.
196
+ - continuo's own settings are `customProperties` items with
197
+ `vendor: continuo`. Every node sets `schedule` and `criticality`
198
+ (`REGULATORY`, `CORE` or `SECONDARY`); the node's kind decides the rest
199
+ (see "Node kinds" below). An optional `service` names the node's service,
200
+ and `pack` and `validate --service` refuse a contract whose `service` is not
201
+ their `--service`.
202
+ - A contract may also bind its table and its columns to the company's ontology
203
+ (see "Checking against the ontology" below).
204
+ - The contract has exactly one schema object, `physicalType: table`. Its
205
+ `properties` are the table's columns, in order: each has a `name`, a
206
+ `physicalType` (`BIGINT`, `INTEGER` or `INT`, `DOUBLE PRECISION`,
207
+ `NUMERIC(p,s)` or `DECIMAL(p,s)`, `VARCHAR(n)`, `CHAR(n)`, `TEXT`,
208
+ `TIMESTAMP`, `DATE` or `BOOLEAN`) and, for a column that never holds NULL,
209
+ `required: true`.
210
+
211
+ `validate` refuses any other file in `contracts/` whose name ends in `.yml` or
212
+ `.yaml`, in any case, two files that declare the same table, and a folder with
213
+ no contract. `docs/boundary-contract.md` lists every field a contract may
214
+ carry, and how a contract in another format converts to ODCS.
215
+
216
+ ### Read queries
217
+
218
+ `validate`, `pack` and `hash` hand every read query to a real SQL parser
219
+ (sqlglot, through `continuo_engine_contract.sql.ensure_single_read`). Each
220
+ query must be one `SELECT` (or `WITH`) statement, and every table it reads
221
+ must name its schema: `analytics.orders`, never `orders`. The one name that
222
+ goes without a schema is a reference to a CTE that is in scope where the name
223
+ is used, so in `WITH orders AS (SELECT * FROM orders) SELECT * FROM orders` the
224
+ `orders` inside the CTE is a table and must name its schema. continuo refuses,
225
+ when it resolves a release, a read query that names a table without its schema,
226
+ so CI refuses at least what the release refuses.
227
+
228
+ SQL a driver accepts but a parser refuses fails these checks, most often a
229
+ driver's bind placeholder such as psycopg2's `%(name)s`, which `ctx.read(name)`
230
+ could never fill. Engine-specific syntax (postgres `~`, `@>`, …) needs
231
+ `--dialect <engine>`, which a repo should pass anyway, since Continuo parses
232
+ and bind-checks every read in the install's own warehouse dialect:
166
233
 
167
234
  ```bash
168
235
  continuo-runtime validate contracts/ --dialect postgres # or trino, duckdb
169
236
  ```
170
237
 
171
- The runtime image does not re-run this gate, so a read that passes here is
172
- not re-judged under a different grammar in production. See
173
- `docs/boundary-contract.md` §13.1.
238
+ The harness does not run these read checks again when a node starts, so a
239
+ read that passes here is not judged again under a different grammar in
240
+ production. See `docs/boundary-contract.md` §13.1.
241
+
242
+ ### Checking against the ontology
243
+
244
+ A company that keeps an ontology file, the things its data is about and the
245
+ services that own them, can have each contract bind its table and its columns
246
+ to it. The bindings are optional `continuo` properties: `entity`, `grain`,
247
+ `fixed` and `filter` on the schema object, and `property`, `local` and
248
+ `aggregate` on a column (`docs/boundary-contract.md` gives their values):
249
+
250
+ ```yaml
251
+ schema:
252
+ - name: example
253
+ physicalType: table
254
+ customProperties:
255
+ - {vendor: continuo, property: entity, value: Order}
256
+ properties:
257
+ - name: order_id
258
+ physicalType: INTEGER
259
+ required: true
260
+ customProperties:
261
+ - {vendor: continuo, property: property, value: Order.order_id}
262
+ - name: note
263
+ physicalType: "VARCHAR(64)"
264
+ customProperties:
265
+ - {vendor: continuo, property: local, value: true}
266
+ ```
267
+
268
+ If `Order` has a key part or a property named `order_id`, the check would bind
269
+ that column itself; the binding is written out for clarity.
270
+
271
+ A contract with bindings loads, validates, packs and runs like any other, and
272
+ its `content_hash` is the one it has without them. To check the bindings in your
273
+ CI, keep a copy of the company's ontology file in your own repository, for
274
+ example at `ontology/ontology.yaml`, and give `validate` the name of your
275
+ service and the path of that copy:
276
+
277
+ ```bash
278
+ continuo-runtime validate contracts --service <name> --ontology ontology/ontology.yaml
279
+ ```
280
+
281
+ Copy the file from the company's ontology repository, never from continuo, and
282
+ keep it outside `contracts/`, where `validate` refuses any other YAML file. The
283
+ copy is yours to keep current: when the ontology changes, you update it. A copy
284
+ that is behind the ontology can pass here and still be refused by the release,
285
+ which checks against the ontology the install runs. The library's dbt check,
286
+ `continuo-contracts dbt check`, takes the same file with `--ontology`.
287
+
288
+ `--service` alone refuses a contract whose `service` property names another
289
+ service. `--ontology` needs `--service`; without it `validate` exits 2. With
290
+ both, every contract is checked as a contract of that service by the rules of
291
+ `continuo-contracts` that need no other service: `contract`, `coverage`,
292
+ `quality` and `privacy`. The rules that read the whole estate (`access`,
293
+ `order` and `drift`) cannot run on one service's contracts and are not run
294
+ here. `validate` logs, on stderr and at the level of its severity (ERROR,
295
+ WARNING or INFO), one line for each finding,
296
+ `<severity> [<rule>] <subject>: <message>`, then one INFO line that counts them,
297
+ `<e> error(s), <w> warning(s), <i> info: <name>`. It exits 1 when any finding is
298
+ an error and 0 otherwise, and it prints nothing to stdout.
299
+
300
+ - When the ontology declares the service, each contract names exactly one of
301
+ `entity` or `grain`, so a contract that names neither, or both, is an error.
302
+ A column that carries no binding is a warning, unless its name is a key part
303
+ or a property of the table's entity, in which case the check binds it itself.
304
+ - When the ontology does not declare the service, none of its contracts is
305
+ checked: `validate` logs one INFO line, `not declared in the ontology: none
306
+ of this service's contracts is checked`, and one WARNING for each contract
307
+ that writes bindings, and exits 0.
308
+ - A file that cannot be read, is not UTF-8 text or is not an ontology is one
309
+ ERROR line, `<file>: <reason>`, and exit 1. The reason of an invalid
310
+ ontology is the library's, with the path to the first fault.
311
+ - A file that is an ontology but that the library's `ontology` rule refuses (a
312
+ thing owned by a domain the file does not declare, a service of a domain it
313
+ does not declare, a personal property no access rule names) is refused the
314
+ same way, whatever the service, and no contract is checked against it: one
315
+ ERROR line, `<file>: the ontology file has <n> error(s): run
316
+ continuo-contracts ontology check <file>`, and exit 1. That command lists the
317
+ errors. Findings of that rule that are not errors do not stop the check.
318
+
319
+ A company without an ontology adds nothing: without the two flags `validate`
320
+ runs the checks above and no others.
174
321
 
175
322
  ## Node kinds
176
323
 
177
- A contract node's `kind:` field selects how the node produces its rows.
178
- Every rule below (`extra_columns`, `output_columns`, "Conform rules") applies
179
- to both kinds identically — `kind` only changes how the pre-conform table is
324
+ The `kind` property (a `customProperties` item, not the contract's root
325
+ `kind: DataContract`) selects how the node produces its rows.
326
+ Every rule below (`extraColumns`, the columns, "Conform rules") applies to
327
+ every kind identically — `kind` only changes how the pre-conform table is
180
328
  produced, never how it is checked or written.
181
329
 
182
- - **`python-node`** (the default; the field may be omitted) — a script node.
183
- It requires `script:` and a `reads:` map of one or more named SQL queries,
184
- as described in "The script API" below.
185
- - **`python-csv`** — a contract-only node: it has no script and its `reads:`
186
- map must be exactly `{csv: <uri>}`, where the uri is `s3://bucket/key` or
187
- an `https://` url (`http://` is rejected at validate time, not run time).
330
+ - **`python-node`** (the default; the property may be left out) — a script
331
+ node. It needs `script` and `readQueries`, a mapping of one or more named
332
+ SQL queries, as described in "The script API" below.
333
+ - **`python-csv`** — a contract-only node: it has no script and reads no
334
+ table. Its `csvSource` is the file's address, `s3://bucket/key` or an
335
+ `https://` url (`http://` is refused by `validate`, not at run time).
188
336
  The harness fetches the file, parses it with RFC 4180 defaults, and feeds
189
- the result straight into `conform()` — declared `output_columns` types
190
- decide the warehouse schema, not whatever pyarrow infers from the csv.
191
- Because there is no script, `script:` is a forbidden key for this kind;
192
- `continuo-runtime validate`/`merge`/`lint` reject one that sets it. The
193
- csv's header row must contain every declared output column (checked again,
194
- independently, at release time before promotion); columns present in the
195
- header but not declared are governed by the same `extra_columns` policy as
196
- a script node's output — `raise` (default) fails the run, `warn` drops
197
- them and logs a warning. See `template/contracts/example_csv.yml`.
337
+ the result straight into `conform()` — the declared column types decide
338
+ the warehouse schema, not whatever pyarrow infers from the csv. Because
339
+ there is no script, `script`, `readQueries`, `secretRef` and `assets` are
340
+ refused on this kind. The csv's header row must contain every declared
341
+ column (checked again, independently, at release time before promotion);
342
+ columns present in the header but not declared are governed by the same
343
+ `extraColumns` policy as a script node's output — `raise` (default) fails
344
+ the run, `warn` drops them and logs a warning. See
345
+ `template/contracts/example_csv.odcs.yaml`.
198
346
  - **`python-api`** — a script node that fetches its own data (typically over
199
- HTTP) and declares no `reads:`. `ctx.read` has nothing to return. It may name
200
- one Kubernetes Secret with `secret_ref: continuo-api-<name>`; continuo
201
- attaches that Secret to the node's pod, so each of its keys is an env var the
202
- script reads with `os.environ[...]`. The contract never holds a secret value
203
- or env var name; the Secret itself is created in the cluster by the operator.
347
+ HTTP) and declares no `readQueries`. `ctx.read` has nothing to return. It
348
+ may name one Kubernetes Secret with `secretRef: continuo-api-<name>`;
349
+ continuo attaches that Secret to the node's pod, so each of its keys is an
350
+ env var the script reads with `os.environ[...]`. The contract never holds a
351
+ secret value or env var name; the Secret itself is created in the cluster
352
+ by the operator.
204
353
 
205
354
  ### Files a script reads (`assets`)
206
355
 
207
356
  A `python-node` or `python-api` script that reads a file from the repository
208
- (a model, a lookup table, a JSON config) lists it under `assets:`, one path
209
- relative to the repository root per entry, written with forward slashes and
210
- without a `..` segment:
357
+ (a model, a lookup table, a JSON config) lists it in the `assets` property,
358
+ one path relative to the repository root per entry, written with forward
359
+ slashes and with no empty, `.` or `..` part:
211
360
 
212
361
  ```yaml
213
- - schema: analytics
214
- table: scored_orders
215
- kind: python-node
216
- script: scripts/scored_orders.py
217
- assets: [data/rates.json, models/scorer.bin]
362
+ customProperties:
363
+ - {vendor: continuo, property: script, value: scripts/scored_orders.py}
364
+ - vendor: continuo
365
+ property: assets
366
+ value: [data/rates.json, models/scorer.bin]
218
367
  ```
219
368
 
220
- `merge` reads each listed file and folds its bytes into `shared_code_hash`
369
+ `pack` reads each listed file and folds its bytes into `shared_code_hash`
221
370
  under its path, so editing one changes the node's `content_hash` and starts a
222
- validation. A path that is also an import of the script is one unit. `merge`
223
- fails with a `ContractError` for a path that is missing, is not a file or
224
- resolves outside the repository, and a path listed twice is refused. The image
225
- must `COPY` the files, because `assets` only tells the hash about them. A
226
- `python-csv` node has no script, so `assets` is refused on it.
371
+ validation. A path that is also an import of the script is one unit. `pack`
372
+ and `hash` fail with a `ContractError` for a path that is missing, is not a
373
+ file or resolves outside the repository, and `validate` refuses a path listed
374
+ twice. The image must `COPY` the files, because `assets` only tells the hash
375
+ about them. A `python-csv` node has no script, so `assets` is refused on it.
227
376
 
228
377
  ### Task timeout
229
378
 
230
- Any node may set `timeout_minutes:` — an integer from 1 to 10,080 (one week) —
379
+ Any node may set `timeoutMinutes` — an integer from 1 to 10,080 (one week) —
231
380
  to declare how long its task may run before continuo gives up on it. A value
232
- outside that range, or one that is not an integer, fails
233
- `continuo-runtime validate`/`merge`/`lint`. Like `owner`, `schedule`,
234
- `criticality` and `description`, it is outside the code projection that
235
- `config_hash` hashes, so changing it never changes the node's `content_hash`.
381
+ outside that range, or one that is not an integer, fails `validate`, `pack`
382
+ and `hash`. Like the owner (`team.name`), `schedule`, `criticality` and the
383
+ description, it is outside the code projection that `config_hash` hashes, so
384
+ changing it never changes the node's `content_hash`.
236
385
 
237
386
  ## Write modes
238
387
 
239
- `mode_type:` chooses how the harness writes a node's table on each run:
388
+ The `modeType` property chooses how the harness writes a node's table on each
389
+ run:
240
390
 
241
- | `mode_type` | Each run | Rows from earlier runs |
391
+ | `modeType` | Each run | Rows from earlier runs |
242
392
  | --- | --- | --- |
243
393
  | `replace` (default) | empties the table, inserts this run's rows | gone |
244
394
  | `append` | inserts this run's rows | kept |
245
395
  | `upsert` | inserts rows with a new key, overwrites rows whose key exists | kept unless overwritten; never deleted |
246
396
 
247
397
  ```yaml
248
- - schema: fx
249
- table: fx_rates
250
- kind: python-api
251
- mode_type: upsert
252
- primary_key: [rate_date, base, quote]
253
- output_columns:
254
- - {name: rate_date, type: DATE, nullable: false}
255
- - {name: base, type: VARCHAR(3), nullable: false}
256
- - {name: quote, type: VARCHAR(3), nullable: false}
257
- - {name: rate, type: DECIMAL(12,6)}
398
+ customProperties:
399
+ - {vendor: continuo, property: kind, value: python-api}
400
+ - {vendor: continuo, property: modeType, value: upsert}
401
+ schema:
402
+ - name: fx_rates
403
+ physicalType: table
404
+ properties:
405
+ - {name: rate_date, physicalType: DATE, required: true, primaryKey: true, primaryKeyPosition: 1}
406
+ - {name: base, physicalType: "VARCHAR(3)", required: true, primaryKey: true, primaryKeyPosition: 2}
407
+ - {name: quote, physicalType: "VARCHAR(3)", required: true, primaryKey: true, primaryKeyPosition: 3}
408
+ - {name: rate, physicalType: "DECIMAL(12,6)"}
258
409
  ```
259
410
 
260
411
  - `python-csv` nodes only `replace`.
261
- - `primary_key` is required for `upsert` and rejected otherwise: a non-empty
262
- list of output columns declared `nullable: false` (a NULL key never
263
- matches), each spelled exactly as in `output_columns`, names unique
264
- case-insensitively. A Postgres `replace` table that
265
- wants uniqueness uses `config.indexes` with `unique: true`.
412
+ - An `upsert` node needs a key: `primaryKey: true` on each key column. Each
413
+ key column is `required: true` (a NULL key never matches) and is not
414
+ `DOUBLE PRECISION`; a key of several columns numbers its columns with
415
+ `primaryKeyPosition`, from 1. The key's names are unique
416
+ case-insensitively. On a `replace` or `append` node a key only describes
417
+ the table: the harness writes no key and the hash leaves it out. A
418
+ Postgres `replace` table that wants uniqueness uses `indexes` with
419
+ `unique: true` in its `config` property.
266
420
  - Every write is atomic: all of the run's rows or none. An `append` or
267
421
  `upsert` run with zero rows writes nothing (a `replace` run with zero rows
268
422
  still empties the table).
@@ -271,7 +425,7 @@ outside that range, or one that is not an integer, fails
271
425
  - An `upsert` run whose own rows repeat a key fails with `ConformError` and
272
426
  writes nothing.
273
427
  - Before an `append` or `upsert` the harness compares the live table with
274
- `output_columns` — names case-insensitively, nullability exactly; order and
428
+ the contract's columns — names case-insensitively, nullability exactly; order and
275
429
  types are not compared — and fails with `LoadError` naming every missing
276
430
  column, unexpected column and nullability mismatch. Changing an `append` or
277
431
  `upsert` table (columns, types, nullability, key or mode) needs a new table
@@ -300,9 +454,9 @@ def run(ctx):
300
454
  ```
301
455
 
302
456
  - `ctx` is a `RunContext` (`continuo_python_runtime.context.RunContext`).
303
- Its only method is `ctx.read(name)`, where `name` is one of the read
304
- names declared under the node's `reads:` map in the contract — reading
305
- anything else raises `ReadError`. Each declared read is fetched once and
457
+ Its only method is `ctx.read(name)`, where `name` is one of the query
458
+ names of the contract's `readQueries` — reading anything else raises
459
+ `ReadError`. Each declared read is fetched once and
306
460
  memoized; `ctx.read(name)` returns a `pyarrow.Table`.
307
461
  - `run(ctx)` can return anything Arrow-convertible: a `pyarrow.Table`
308
462
  as-is, a pandas `DataFrame` (converted via
@@ -334,7 +488,7 @@ def run(ctx):
334
488
  change to `sys.path` (`append`, `insert`, assignment, `del`, and
335
489
  `site.addsitedir`), a `sitecustomize` or `usercustomize` module (and a file
336
490
  of that name), `compile()` and `types.FunctionType`, and `pickle.load`,
337
- `pickle.loads` and `pickle.Unpickler`. `merge` applies the same rules to
491
+ `pickle.loads` and `pickle.Unpickler`. `pack` applies the same rules to
338
492
  every file in a node's import closure, and refuses a `sitecustomize.py` or
339
493
  `usercustomize.py` at the repository root, which Python imports before the
340
494
  harness starts. A file a script reads, such as a model or a lookup table,
@@ -362,17 +516,17 @@ def run(ctx):
362
516
 
363
517
  ## Conform rules
364
518
 
365
- `conform()` (`continuo_python_runtime/conform.py`) enforces the node's
366
- declared `output_columns` on the table `run()` returned, in this order:
519
+ `conform()` (`continuo_python_runtime/conform.py`) enforces the columns the
520
+ node's contract declares on the table `run()` returned, in this order:
367
521
 
368
522
  | Check | Behavior |
369
523
  | --- | --- |
370
524
  | Duplicate columns | Any duplicate column name in the returned table always raises `ConformError`. |
371
- | Extra columns | Governed by the node's `extra_columns` policy: `raise` (default) fails the run; `warn` drops the undeclared column(s) and logs a warning. |
525
+ | Extra columns | Governed by the contract's `extraColumns` policy: `raise` (default) fails the run; `warn` drops the undeclared column(s) and logs a warning. |
372
526
  | Missing columns | Any declared column absent from the returned table always raises `ConformError`. |
373
527
  | Column order | The table is reselected into the declared column order. |
374
528
  | Strict cast | Each column is cast to its declared Arrow type with `safe=True`. Casts pyarrow's `safe=True` would silently accept but that are not value-lossless are rejected before the cast even runs: floating → decimal (rounds to scale), non-boolean → boolean (coerces truthiness), timestamp → date (drops time-of-day). Any other cast failure also raises `ConformError`. |
375
- | Not-null | A column declared `nullable: false` that contains any null raises `ConformError`. |
529
+ | Not-null | A column declared `required: true` that contains any null raises `ConformError`. |
376
530
  | VARCHAR/CHAR length | A column declared `VARCHAR(n)`/`CHAR(n)` whose longest value exceeds `n` raises `ConformError`. |
377
531
 
378
532
  ## Error taxonomy
@@ -387,12 +541,12 @@ the result block out of the log before storing it.
387
541
 
388
542
  | Class | Meaning | Typical fix target |
389
543
  | --- | --- | --- |
390
- | `ContractError` | Contract missing or invalid, node not found for `NODE_ID`, or the declared script is missing/unreachable. | The contract yaml or the `script:` path. |
544
+ | `ContractError` | Contract missing or invalid, node not found for `NODE_ID`, or the declared script is missing/unreachable. | The contract file or its `script` path. |
391
545
  | `ImageContractMismatch` (a `ContractError`) | The image does not hold the contract, script, imports or assets the release hashed: the `content_hash` in `CONTENT_HASH` differs from the one the image's files give, or a file the release hashed is missing from the image. The block also carries `"reason":"image_contract_mismatch"`. | Rebuild the image from the released commit, with CI and the image on the same runtime. |
392
- | `ReadError` | `ctx.read()` was called with an undeclared name, or a declared read failed at the warehouse. | The `reads:` map, or the upstream query/warehouse access. |
546
+ | `ReadError` | `ctx.read()` was called with an undeclared name, or a declared read failed at the warehouse. | The contract's `readQueries`, or the upstream query/warehouse access. |
393
547
  | `ScriptError` | `run()` raised, has no callable `run`, or returned a value that isn't Arrow-convertible. | The node script. |
394
- | `ConformError` | Structural mismatch (extra/missing/duplicate columns), a strict-cast failure, a not-null violation, a VARCHAR/CHAR overflow, or an `upsert` run whose rows repeat a primary key. | The script's output shape, or the `output_columns` declaration. |
395
- | `LoadError` | Adapter construction failed, the installed engine does not support the node's `mode_type`, the live table's shape differs from `output_columns` (append/upsert), or the DDL/INSERT failed at the warehouse during the write. | Warehouse connectivity/permissions, the engine image, or the target table. |
548
+ | `ConformError` | Structural mismatch (extra/missing/duplicate columns), a strict-cast failure, a not-null violation, a VARCHAR/CHAR overflow, or an `upsert` run whose rows repeat a primary key. | The script's output shape, or the contract's columns. |
549
+ | `LoadError` | Adapter construction failed, the installed engine does not support the node's `modeType`, the live table's shape differs from the contract's columns (append/upsert), or the DDL/INSERT failed at the warehouse during the write. | Warehouse connectivity/permissions, the engine image, or the target table. |
396
550
 
397
551
  ## Engine selection
398
552
 
@@ -400,11 +554,11 @@ A domain repo picks its warehouse engine by which base image it builds
400
554
  `FROM`:
401
555
 
402
556
  ```dockerfile
403
- FROM ghcr.io/carolsimone/continuo-python-runtime-postgres:v0.12.0
557
+ FROM ghcr.io/carolsimone/continuo-python-runtime-postgres:v0.14.0
404
558
  # or
405
- FROM ghcr.io/carolsimone/continuo-python-runtime-trino:v0.12.0
559
+ FROM ghcr.io/carolsimone/continuo-python-runtime-trino:v0.14.0
406
560
  # or
407
- FROM ghcr.io/carolsimone/continuo-python-runtime-duckdb:v0.12.0
561
+ FROM ghcr.io/carolsimone/continuo-python-runtime-duckdb:v0.14.0
408
562
  ```
409
563
 
410
564
  The engine is part of the image **name**; the tag is the bare version, so
@@ -421,9 +575,11 @@ single image serves every node in the service and the release-time
421
575
  validation Job for it. The executor injects the warehouse connection as
422
576
  environment variables (engine-native, e.g.
423
577
  `POSTGRES_HOST`/`POSTGRES_DB`/`POSTGRES_USER`) plus the node-selection
424
- environment (`NODE_ID`, `TABLE_NAME`, `TARGET_SCHEMA`, and optionally
425
- `CONTRACT_DIR`/`APP_ROOT`) that `continuo-runtime run` reads to dispatch the
426
- right node's script.
578
+ environment (`NODE_ID`, `TABLE_NAME`, `TARGET_SCHEMA`) that
579
+ `continuo-runtime run` reads to pick the node. `CONTRACT_DIR`, the folder of
580
+ the image's `*.odcs.yaml` contracts (`/app/contracts` by default), and
581
+ `APP_ROOT`, the repository root a node's `script` path is resolved against,
582
+ are optional.
427
583
 
428
584
  ### Build your own container
429
585
 
@@ -521,8 +677,7 @@ unexpected error is exit 2.
521
677
 
522
678
  ## Further reading
523
679
 
524
- - `docs/superpowers/specs/2026-07-31-python-runtime-design.md` — this
525
- repo's design.
526
- - `docs/boundary-contract.md` — the parent design's boundary contract (§13):
527
- the five surfaces (S3 artifact, `content_hash`, the release call, the
528
- runtime image, and the domain repo's CI/CD) that this repo implements.
680
+ - `docs/boundary-contract.md` — the boundary between continuo and a domain
681
+ repo (§13): the five surfaces (the contract bundle, the hashes `pack`
682
+ computes, the release call, the runtime image, and the domain repo's CI)
683
+ that this repo implements, and every field a contract may carry.