Repository navigation
agent-skills: state each link's basis and report its value coverage (data-prep case 10) #462
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
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 |
|---|---|---|
|
|
@@ -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, ' | ||
| 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). | ||
|
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. 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). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
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. Regenerate This PR changes Run the script and commit the regenerated 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 | ||
|
|
@@ -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. | ||
|
|
||
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.
Wrap the unmatched count in
COALESCEso fully matched links do not fail.Snowflake's
COUNT_IFreturnsNULLwhen no row satisfies its condition. A link with no unmatched rows, or a child with no non-null keys, givesUNMATCHED = None. The subtraction on line 167 then raises aTypeError. That line is outside thetryblock, so the link report is lost and the check fails before the remaining links are printed. Wrap the aggregate inCOALESCE(..., 0). Fully matched links then report 100%, and links with unmatched rows keep their existing counts.Suggested fix
Committable suggestion