Repository navigation
feat(contract): mode_type and primary_key contract fields #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
71d34eb
a9138ca
a92fefa
54116be
c587b88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
|
|
||
| from continuo_python_runtime.closure import resolve_closure | ||
| from continuo_python_runtime.contract.loader import load_contract_dir | ||
| from continuo_python_runtime.contract.model import CONTRACT_VERSION, Node | ||
| from continuo_python_runtime.contract.model import CONTRACT_VERSION, DEFAULT_MODE_TYPE, Node | ||
| from continuo_python_runtime.contract.paths import resolve_script_path | ||
| from continuo_python_runtime.errors import ContractError | ||
| from continuo_python_runtime.hashing import hash_parts | ||
|
|
@@ -20,7 +20,10 @@ def node_entry(node: Node) -> dict: | |
| Returns the node as a dict with all fields, output_columns as list of | ||
| dicts. The entry carries no hash fields: build_wire_contract adds all | ||
| four (source_hash, shared_code_hash, config_hash, content_hash). The | ||
| nullable field is always present in output_columns. | ||
| nullable field is always present in output_columns. ``secret_ref``, | ||
| ``mode_type`` and ``primary_key`` appear only when they differ from their | ||
| default, so a node that does not use them has the entry (and hashes) it | ||
| had before they existed. | ||
| """ | ||
| entry = { | ||
| "schema": node.schema, | ||
|
|
@@ -47,6 +50,12 @@ def node_entry(node: Node) -> dict: | |
| # only when set keeps every other node's config_hash unchanged. | ||
| if node.secret_ref: | ||
| entry["secret_ref"] = node.secret_ref | ||
| # Same reasoning: every replace node's entry, config_hash and content_hash | ||
| # stay byte-identical, so contract_version stays 1. | ||
| if node.mode_type != DEFAULT_MODE_TYPE: | ||
| entry["mode_type"] = node.mode_type | ||
| if node.mode_type == "upsert": | ||
| entry["primary_key"] = list(node.primary_key) | ||
|
Comment on lines
+55
to
+58
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cross-repository rollout dependency: land the consumer parser update before using the new wire entries. Continuo's current The coordinated series needs the companion parser update before these entries reach an install. The shared fixture should be exercised through that consumer as well as this producer to verify the completed integration. This is a series rollout check given the PR's stated R1 scope and single-tag release plan.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted — this is a cross-repository dependency outside continuo-python-runtime (this repo is scoped to the runtime only). The companion update to continuo's |
||
| return entry | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Series release requirement: honor append/upsert before executing these contracts.
At this commit,
run_node()accepts a valid append/upsert contract throughload_contract_dir(..., check_reads=False), then unconditionally callsactive_adapter.load(...). The port and all three shipped adapters define that operation as replacement: Postgres truncates, DuckDB deletes all rows, and Trino swaps in a replacement table. For example, existingid=1plus a run producing onlyid=2leaves onlyid=2and reports success; an empty batch removes all existing rows.The PR explicitly defers writer support to R6 and holds release until the series is complete. Please ensure R6 implements the mode dispatch and regression coverage for preserving existing rows under append/upsert before the single tag. If these contracts can be run before the new writers are available, reject unsupported modes before any writes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in c587b88 (this branch).
run_nodenow rejects any non-replacemode_typewith aLoadErrorimmediately after node selection — before the script runs orensure_table/loadis called — so an accepted append/upsert contract can no longer silently replace a table. A test asserts both modes return the error sentinel with no adapter write and no script side effect. This is an interim guard; R6 replaces it with the per-mode_WRITERSdispatch + capability check and adds the row-preservation end-to-end coverage, all before the singlev0.9.0tag.