From b943d2be2c44eb70aed600d4ec7705c0b9e355f6 Mon Sep 17 00:00:00 2001 From: igutierrez Date: Sat, 21 Nov 2026 17:39:58 -0600 Subject: [PATCH] agent-skills: state each link's basis and report its value coverage (data-prep case 10) Links are proposed only on a declared constraint or an exact name match. A column whose name merely resembles another table's key is listed as a possible link for the user to name, never linked on the resemblance, and each link line now says how it was found. Every link's share of non-null values found in the parent key is reported, measured in preflight when rows can be read or by the Snowflake notebook's read-only link check before training, so a wrong link stands out. Co-Authored-By: Claude Opus 5.5 --- .../skills/hosts/snowflake-coco/runtime.md | 43 ++++++++++++++++++- .../skills/kumo-data-science/SKILL.md | 6 +-- .../kumo-data-science/accept/preflight.md | 19 +++++++- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/agent-skills/skills/hosts/snowflake-coco/runtime.md b/agent-skills/skills/hosts/snowflake-coco/runtime.md index d8e316852..b65684e85 100644 --- a/agent-skills/skills/hosts/snowflake-coco/runtime.md +++ b/agent-skills/skills/hosts/snowflake-coco/runtime.md @@ -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 = [('', '', '', '')] # 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, ' + 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 @@ -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). 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). diff --git a/agent-skills/skills/kumo-data-science/SKILL.md b/agent-skills/skills/kumo-data-science/SKILL.md index 0668c6cf5..cc674ec6b 100644 --- a/agent-skills/skills/kumo-data-science/SKILL.md +++ b/agent-skills/skills/kumo-data-science/SKILL.md @@ -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. diff --git a/agent-skills/skills/kumo-data-science/accept/preflight.md b/agent-skills/skills/kumo-data-science/accept/preflight.md index abed8b5ba..8c27f680b 100644 --- a/agent-skills/skills/kumo-data-science/accept/preflight.md +++ b/agent-skills/skills/kumo-data-science/accept/preflight.md @@ -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//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. + ## 7. Seeds and table mode - **Seeds** are the tables behind `prediction_entity` and `prediction_target` (for link @@ -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 @@ -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.