Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion agent-skills/skills/hosts/snowflake-coco/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,47 @@ Snowflake destination before the session ends. Never describe a scratch path as
plan a workflow that reads an artifact back in a later session without first confirming storage
lifetime.

### 3.2 Link check — a read-only cell before any table is built

The snapshot warns about a link only when **fewer than half** of its rows match
(`kumoai-reference/references/troubleshooting_signals.md` §1a), so a link that loses a few percent
of its rows passes silently. Every training notebook therefore carries this cell right after the
connector, before any `Table`: one line per confirmed link, written verbatim from the proposal.
It prints diagnostic counts only — it never raises, filters or writes, and nothing it reads reaches
the graph.

```python
def q(name):
return '"' + name.replace('"', '""') + '"'

LINKS = [('<child>', '<fk>', '<parent>', '<pk>')] # every confirmed link, names as in the catalog
for child, fk, parent, pk in LINKS:
try:
r = session.sql(
f'SELECT COUNT(*) AS N, COUNT(c.{q(fk)}) AS NON_NULL, '
f'COUNT_IF(c.{q(fk)} IS NOT NULL AND p.K IS NULL) AS UNMATCHED, '

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Stability & Availability · Quick win

Wrap the unmatched count in COALESCE so fully matched links do not fail.

Snowflake's COUNT_IF returns NULL when no row satisfies its condition. A link with no unmatched rows, or a child with no non-null keys, gives UNMATCHED = None. The subtraction on line 167 then raises a TypeError. That line is outside the try block, so the link report is lost and the check fails before the remaining links are printed. Wrap the aggregate in COALESCE(..., 0). Fully matched links then report 100%, and links with unmatched rows keep their existing counts.

Suggested fix

--- "a/agent-skills/skills/hosts/snowflake-coco/runtime.md"
+++ "b/agent-skills/skills/hosts/snowflake-coco/runtime.md"
@@ -156,7 +156,7 @@
     try:
         r = session.sql(
             f'SELECT COUNT(*) AS N, COUNT(c.{q(fk)}) AS NON_NULL, '
-            f'COUNT_IF(c.{q(fk)} IS NOT NULL AND p.K IS NULL) AS UNMATCHED, '
+            f'COALESCE(COUNT_IF(c.{q(fk)} IS NOT NULL AND p.K IS NULL), 0) AS UNMATCHED, '
             f'COUNT(DISTINCT IFF(p.K IS NULL, c.{q(fk)}, NULL)) AS UNMATCHED_VALUES '
             f'FROM {DATABASE}.{SCHEMA}.{q(child)} c LEFT JOIN '
             f'(SELECT DISTINCT {q(pk)} AS K FROM {DATABASE}.{SCHEMA}.{q(parent)}) p '
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
f'COUNT_IF(c.{q(fk)} IS NOT NULL AND p.K IS NULL) AS UNMATCHED, '
f'COALESCE(COUNT_IF(c.{q(fk)} IS NOT NULL AND p.K IS NULL), 0) AS UNMATCHED, '

f'COUNT(DISTINCT IFF(p.K IS NULL, c.{q(fk)}, NULL)) AS UNMATCHED_VALUES '
f'FROM {DATABASE}.{SCHEMA}.{q(child)} c LEFT JOIN '
f'(SELECT DISTINCT {q(pk)} AS K FROM {DATABASE}.{SCHEMA}.{q(parent)}) p '
f'ON c.{q(fk)} = p.K').collect()[0]
except Exception as err: # e.g. the two sides hold different types
print(f'LINK CHECK {child}.{fk} -> {parent}.{pk}: could not compare: {err}')
continue
matched = r['NON_NULL'] - r['UNMATCHED']
share = matched / r['NON_NULL'] if r['NON_NULL'] else 0.0
print(f'LINK CHECK {child}.{fk} -> {parent}.{pk}: {matched} of {r["NON_NULL"]} non-null rows '
f'matched ({share:.1%}); {r["UNMATCHED"]} unmatched rows, {r["UNMATCHED_VALUES"]} distinct '
f'unmatched values; {r["N"] - r["NON_NULL"]} null')
```

**Read its output before anything else the run reports.** Every link's line goes into your reply
with its share. A link with any unmatched rows is a finding about the data, not a code problem:
lead the reply with the table, column, unmatched rows and distinct values, say the likely cause —
parent rows missing from the parent table, values that differ in format (`007` vs `7`), or a wrong
link when few or none match — and ask the user to choose: fix the source upstream, correct the
link, or continue knowing those rows get no edge. Stop there; a fix to an unrelated code error
waits for their answer. Never filter the rows, add parents, or cast either side in the notebook.


---
## 4. What the Snowflake runtime provides
Expand Down Expand Up @@ -191,7 +232,7 @@ Two further facts: the target destination must be writable by the identity's pri
2. Create a writable scratch directory (§1.2).
3. `kumo.configure(scratch_dir=...)`, then the connector, in the §3 order: `from_spcs_env`,
`from_connection_toml`, key pair from secrets.
4. Assert `connector.table_names()` (§3).
4. Assert `connector.table_names()` (§3), then the link check (§3.2).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Heavy lift

Pause execution before training on unmatched links.

When a user runs the notebook with Run All, the link check prints unmatched counts but does not stop execution. The following cells can train before the user chooses whether to continue. Require a pause between the check and table construction, and resume only after the user decides.

5. Tables → graph → `validate()` → predictive query → `snapshot()` → train → predict
(portable core; `snapshot=` is required on `fit` and `predict`).
6. Write results to a durable Snowflake destination before the session ends (§3.1, §7).
Expand Down
6 changes: 3 additions & 3 deletions agent-skills/skills/kumo-data-science/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ trainer, and `predict` runs against an explicitly rebuilt graph snapshot (see St
- Choose the predictive problem, target, horizon, graph, or tuning for the user — refuse and name
the minimum inputs needed
- Join, clean, deduplicate, aggregate, create labels, or transform data **as model input**.
Diagnostic scalar aggregates during preflight — reported as proposal evidence, never written and
never fed to training — are not this; they exist so a key can be checked before it silently
discards rows
Diagnostic scalar aggregates during preflight or in a notebook's read-only check cell — reported
as evidence, never written and never fed to training — are not this; they exist so a key or a
link can be checked before it silently discards rows
- Search for, rank, or curate tables by business relevance
- Retry or resume jobs, or keep state across sessions. The one execution the agent performs is
Step 3, and only when the user asks.
Expand Down
19 changes: 17 additions & 2 deletions agent-skills/skills/kumo-data-science/accept/preflight.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ A link is proposed when a column in table A has the **same name** as the primary
taken as well, where the source declares any. Nothing else is inferred — no fuzzy matching,
no value overlap checks, no joins executed.

Each link line names its basis: `declared`, `same name`, or `[supplied]` for a link the user
named. A column whose name only resembles another table's key — a prefix or suffix added, a
synonym, an abbreviation (`buyer_id` or `xuser_id` beside `user_id`, `sku` beside `product_id`) —
is never linked on that resemblance: list it under `Not found` as a possible link, say which key it
might reference, and let the user name it. Once named, it is `[supplied]`, and the user's
confirmation is the only basis it has.

Value overlap never creates a link, but it is how every link is checked. For each link the graph
uses, report the share of its non-null values found in the parent key, so a wrong link stands out:
measured here when you can read rows (a scalar count, as for keys), otherwise by the notebook's link
check before training (`hosts/<host>/runtime.md`), and shown on the link line as `coverage: not
measured yet` until then. When it is measured, every link's share goes to the user; a low one means
the link, or the parent table, is wrong.

Comment on lines +179 to +192

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Data Integrity & Integration · Quick win

Regenerate skills/ after editing the kumo-data-science skill sources.

This PR changes agent-skills/skills/kumo-data-science/SKILL.md and accept/preflight.md, but it does not refresh the published copy under skills/kumo-data-science/. test_the_published_copy_matches_the_source calls publish_nvskills.stale() and fails on both files. The test job reports 1 failed, 348 passed. The publish script's contract requires a PR that changes a skill to run the script and commit the result. Merging without that commit would also publish the old preflight text through NVSkills.

Run the script and commit the regenerated skills/ directory. Do not edit skills/ by hand, because a refresh overwrites that directory. The same run also updates kumo-custom-populations/references/populations.md, kumoai-reference/references/kumo_finetuning_sdk.md, and kumoai-reference/references/task_journeys.md. This PR does not edit those sources, so review those changes separately from this PR's content.

python3 agent-skills/scripts/publish_nvskills.py
git add skills/

## 7. Seeds and table mode

- **Seeds** are the tables behind `prediction_entity` and `prediction_target` (for link
Expand Down Expand Up @@ -209,7 +223,7 @@ Metadata
- ...

Links
- fraud_events.CUSTOMER_ID -> customers.CUSTOMER_ID [inferred]
- fraud_events.CUSTOMER_ID -> customers.CUSTOMER_ID [inferred] — same name; coverage: 99.6% of non-null values found
- ...

Excluded columns
Expand All @@ -232,7 +246,8 @@ format.

- Prepare, transform, aggregate or materialize **model inputs** — joining, cleaning,
deduplicating, creating labels. A diagnostic scalar aggregate over source rows is permitted
solely as evidence for the proposal: row, distinct and null counts for a proposed or candidate key. Its
solely as evidence for the proposal: row, distinct and null counts for a proposed or candidate key,
and the matched share of a proposed link (§6). Its
result is reported and then discarded; it is never written anywhere and never reaches training.
- Rank tables by relevance or drop tables the user did not ask to drop.
- Proceed to PQL before the proposal is confirmed.
Expand Down
Loading