Skip to content
31 changes: 31 additions & 0 deletions agent-skills/skills/hosts/databricks-genie/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,37 @@ def run_sql(statement):

---

### 3.1 Required read-only diagnostics

After defining `run_sql`, before `graph.snapshot()` or training, emit the checks specified in
`kumoai-reference/references/troubleshooting_signals.md` §0.1. Translate the reference's
Snowflake examples to Unity Catalog SQL executed with `run_sql`, on `WAREHOUSE_ID` and the same
`ws` identity as the connector; never use an active Snowpark session or Spark:

- **Keys not probed in preflight:** count rows, non-null keys and distinct keys. Report empty
tables separately; stop on missing or repeated keys. For shared id-like scope columns, count
pairs via a grouped subquery and require both components non-null before reporting a scoped key.
- **Every confirmed link:** join to distinct parent keys; report matched of non-null child rows,
the share, unmatched rows, distinct unmatched values and nulls. Quote catalog/schema/table and
columns with `q`. Use `COALESCE(SUM(CASE WHEN ... THEN 1 ELSE 0 END), 0)` for conditional counts
and convert returned string counts to integers. Report incompatible key types before the
comparison; implicit SQL coercion is not evidence of a healthy link. For leading-zero
diagnostics use `CAST(... AS STRING)`, `LENGTH` and `LPAD`, with a length guard so a longer
child value can never be truncated into a padded match.
- **Unprobed event links:** count non-null and distinct foreign-key values. A unique link is an
observation for confirmation, not proof of an incorrect key. Retain it after recording the
user's specific confirmation; do not silently substitute another column.

Print each link's counts and unmatched values' distinct count before asking the user to fix the
source, correct the link or explicitly accept its measured loss. Keep continuation approvals
per link, and preserve §0.1's default stops and confirmation requirements. When a query fails,
returns no usable counts, or lacks permission, name the unresolved check and raise before
snapshot/training; never report success or train on `coverage: not measured yet`. The notebook
contains executable adapted checks, not a request for the user to write SQL. All reads are
read-only evidence: no filtering, casting or padding changes the model input or confirmed graph.

---

## 4. Destinations and read-back

A confirmed destination `catalog.schema.table` is written through a connector on its own catalog
Expand Down
26 changes: 26 additions & 0 deletions agent-skills/skills/hosts/generic/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,32 @@ destination.

---

### 2.2 Required read-only diagnostics

After connecting and before `graph.snapshot()` or any training, generate the checks in
`kumoai-reference/references/troubleshooting_signals.md` §0.1: unprobed primary-key nulls and
uniqueness (including shared id-like scope columns), every link's coverage and leading-zero
comparison, and unprobed event-link repetition. Use the source's reader, never a Snowpark
session assumed to exist on this host:

| Source | Reader and adaptation |
|---|---|
| Snowflake | `connector.session().sql(...).collect()` with Snowflake quoted identifiers. Use the §1/§2 reference examples and the connector's access context. |
| BigQuery | `bigquery.Client(project=PROJECT_ID, credentials=BQ_CREDENTIALS).query(sql).result()` with the dataset's own location. Quote all identifiers with `bq_name`. Use `COUNTIF`, `IF`, and `CAST(... AS STRING)` instead of Snowflake-only functions; count composite-key groups in a subquery and check both components for nulls. |
| Databricks | The statement API on the connector's confirmed SQL warehouse and the same identity (§2, §3). A cluster-only connector has no diagnostic SQL reader specified here: report the missing reader and stop; do not invent a warehouse. Use `q` for identifiers, `SUM(CASE WHEN ... THEN 1 ELSE 0 END)` with a zero default for conditional counts, and `CAST(... AS STRING)` for the diagnostic-only padding comparison. Statement results are strings: convert counts to integers, retaining null handling. |
| Files, S3, GCS | `pyarrow.dataset` on the confirmed source paths and formats, using the same filesystem credentials as the connector (§2, §3.1). Project only key and scope columns; do not sample these checks. Count nulls, distinct values and pairs, and test non-null child membership against distinct non-null parent keys. Compute diagnostic string padding separately with the length guard; never write or feed transformed arrays into Kumo. |

Use source paths and table names confirmed at intake, not output locations. Report the counts
and choices defined by §0.1. A unique event link needs specific confirmation, not an automatic
rejection; unmatched rows need the user's decision even when most rows match. Record approved
continuations per link. If credentials, unsupported formats/types, resource limits or reader
errors prevent a required measurement, report it as unresolved and emit a raising guard before
snapshot/training. Never silently skip a check, invent zero counts, or train with coverage still
`not measured yet`. The emitted artifact must contain the adapted checks, not just a comment
asking the user to implement them. Diagnostics never change source data or graph choices.

---

## 3. Destinations and read-back

Build the output connector for the destination's own system, and the `PredictionOutputConfig` in
Expand Down
50 changes: 49 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,54 @@ 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 after graph validation

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 after building
and validating the confirmed graph, before `graph.snapshot()` or training: one line per confirmed
link, written verbatim from the proposal. `graph.validate()` must succeed before any coverage is
reported: it rejects incompatible key types (such as numeric `7` versus text `007`) while allowing
lossless integer widening. An implicit SQL conversion must never count as evidence of a healthy
link. Report any validation error with the key columns and types; do not cast them to proceed.
The cell prints diagnostic counts and raises if a comparison cannot run, before snapshot/training.
It never filters or writes, and nothing it reads reaches the graph. Use `connector.session()` so
the check sees the same rows as Kumo; never fall back to the active Snowpark session.

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

graph.validate() # reject incompatible key types before SQL can coerce them into a match
LINKS = [('<child>', '<fk>', '<parent>', '<pk>')] # every confirmed link, names as in the catalog
for child, fk, parent, pk in LINKS:
try:
r = connector.session().sql(
f'SELECT COUNT(*) AS N, COUNT(c.{q(fk)}) AS NON_NULL, '
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
raise RuntimeError(
f'LINK CHECK {child}.{fk} -> {parent}.{pk}: unresolved comparison: {err}'
) from err
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 @@ -192,7 +240,7 @@ Two further facts: the target destination must be writable by the identity's pri
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).
5. Tables → graph → `validate()` → predictive query → `snapshot()` → train → predict
5. Tables → graph → `validate()` → link check (§3.2) → predictive query → `snapshot()` → train → predict

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 · Quick win

Snowflake setup order skips the required pre-snapshot probes.

The skill requires read-only probes before graph.snapshot() for each primary key that preflight did not probe, and for each event-table link that preflight did not probe. The canonical Snowflake order goes from the link check to the predictive query and snapshot(). It has no step for these probes, so a Snowflake run can reach snapshot without them. Kumo keeps one row per repeated key and drops the rest without an error, so an unprobed key can lose rows silently. Add these probes to the sequence before snapshot().

Suggested fix

--- "a/agent-skills/skills/hosts/snowflake-coco/runtime.md"
+++ "b/agent-skills/skills/hosts/snowflake-coco/runtime.md"
@@ -240,7 +240,7 @@
 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).
-5. Tables → graph → `validate()` → link check (§3.2) → predictive query → `snapshot()` → train → predict
+5. Tables → graph → `validate()` → link check (§3.2) → probes for unprobed primary keys and event links (`troubleshooting_signals.md` §0.1) → 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).
 
Committable suggestion

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

Suggested change
5. Tables → graph → `validate()` → link check (§3.2) → predictive query → `snapshot()` → train → predict
5. Tables → graph → `validate()` → link check (§3.2) → probes for unprobed primary keys and event links (`troubleshooting_signals.md` §0.1) → 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
52 changes: 41 additions & 11 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 Expand Up @@ -178,16 +178,31 @@ preflight inside it.
Present the graph proposal — seeds, tables,
primary keys, time columns, links, `table_mode: all-connected [default]` — each line tagged
`[supplied]` / `[declared]` / `[inferred]` / `[inferred, unverified]` / `[default]`. A semantic
view is resolved by `accept/semantic_view.md`, read only for a semantic view. If the user asked for embeddings, say they are included. **Stop and wait for confirmation.**
view is resolved by `accept/semantic_view.md`, read only for a semantic view. If the user asked for embeddings, say they are included. Every time column carries
its reason and the table's other timestamp columns; a table with several asks which one is the
event time (`accept/preflight.md` §4). **Stop and wait for confirmation.**
User-supplied values take precedence over inferred ones.

**Mandatory column-availability pass.** Before presenting the graph, decide the selected columns
for every included table and add an `Excluded columns` section to the proposal.

- When a table's `time_column` marks the beginning of a row's validity or an interval, exclude any
candidate feature whose value is determined only after that time: the interval's eventual
endpoint, its realized duration, or a summary of the completed interval. At the row timestamp
those values are future information. Decide by semantic role, never by matching column names.
- When a table's `time_column` marks the beginning of a row's validity or an interval, the column
that marks when the row stops being valid is the table's **end time column**: declare it with
`end_time_column=`, never as a feature and never dropped (`accept/preflight.md` §4). Exclude any
other candidate feature whose value is determined only after that time: the interval's realized
duration, or a summary of the completed interval. At the row timestamp those values are future
information. Decide by semantic role, never by matching column names.
- For a query with a time window, flag every **current-state attribute**: a column on a
one-row-per-entity table that describes a state the entity can move in and out of (status,
plan, tier, stage, active or closed flag, current balance), when the table has no time column
recording when that value took effect and no end-time column. A creation or signup date does not
count: it dates the row, not the value. Such a column holds only today's value, so every past
anchor in training sees today's state — leakage when the state follows the outcome (a status
set by recent activity, for a churn or activity target). Fixed traits (birth year, signup
channel) are not flagged. List each under a `Flagged columns` section as
`<table>.<column> — current-state attribute, <row count> rows, no history [inferred]` and ask
whether its past values exist, for example as a history table with a time column. Flag only:
it stays selected unless the user chooses to leave it out or supplies the history.
- Separate the target column from columns derived from it; both rules apply at once.
- The target column itself **always stays** in the positional column list. The query references
it by name, so dropping it fails with a missing column.
Expand All @@ -207,6 +222,16 @@ Carry the confirmed exclusion set into code generation: a table with any exclusi
with an explicit positional column list, because omitting it silently restores every source
column.

**Column types.** `infer_metadata()` types each column from its name, its physical type and its
sampled values (`kumoai-reference/references/graph_construction.md` *How a semantic type is
inferred*), and those rules can contradict what a column means. Add a `Column types` section to
the proposal with one line for every selected non-key column a rule there matches: the type Kumo
will give it, the rule behind it, and the type its meaning calls for. Where the two differ, the
choice is the user's, at this gate; the notebook declares the confirmed type with
`with_column(...)`. A type confirmed here is a declaration, like a foreign key's `ID` — not a
change made to silence a data message (`kumoai-reference/references/troubleshooting_signals.md`
§1a).

**Assert what preflight could not find.** The proposal must state these explicitly rather than
leaving them unmentioned, because each one changes whether the task is expressible:

Expand All @@ -217,6 +242,8 @@ leaving them unmentioned, because each one changes whether the task is expressib
conclude from a failed heuristic that the table must be an event or fact table.
- a time-ranged target whose referenced table has no usable time column — say so, and say what
would make the task expressible. A timestamp on another table does not repair the target.
- two links from one table to the same table — name the pair and ask which direction the user
wants (`accept/preflight.md` §6). Proposing both without comment is not a confirmation of both.

| Condition | Transition |
|---|---|
Expand All @@ -235,7 +262,7 @@ generated before the task is confirmed:
- Entity: one prediction per <table>.<key>
- Outcome: <positive-label condition> / <interaction>
- Window: <0 to N days after the prediction anchor> | static
- Task type: <temporal binary classification | link prediction | ...>
- Task type: <temporal binary classification | link prediction | ...> — <why: the query's shape, and the target column's type where it decides>
- Output: predictions written to <destination, verbatim> in the same notebook | notebook only, no predictions written
- Scoring population (static tasks): rows whose <target> is NULL | all <entity> rows, staged at <DB.SCHEMA.TABLE>
- Threshold (binary classification, written or local): <the user's value [supplied] | 0.5 [default]>
Expand Down Expand Up @@ -312,7 +339,9 @@ After ACCEPT, load `kumoai-reference/SKILL.md` and hand off the confirmed payloa
describing the one line to add a destination later. That example is markdown text, never a
code cell: a notebook with no confirmed destination contains no code that writes. Inside
the markdown, show the code as text (a `text` fence), never as a `python` code block —
one that would run is a code cell that writes.
one that would run is a code cell that writes. A confirmed population table is not a
destination: staging it is the notebook's only write, and its name never implies an
output table.
The predict call is part of the artifact, not a separate job the agent manages. The agent
still executes nothing (Step 3 is opt-in).

Expand All @@ -338,7 +367,8 @@ in the same or a later turn. Then, per `kumoai-reference/references/kumo_finetun
- Report the outcome: the training metrics, or the exception and the cell that raised it
- **Read what Kumo said about the data first.** A warning or error about the data — duplicate
primary keys, a foreign key that matched few rows, invalid values read as null, a float or
mismatched key, an empty training table — leads the report, with the table, column and count,
mismatched key, an empty training table — or a link check line with unmatched rows
(`hosts/<host>/runtime.md`, where it has one) leads the report, with the table, column and count,
and the decision goes to the user: fix the source, change the key or link, or accept the loss.
A run that finished is not a success until they have decided. Never change the data, a column's
type or the query to make such a message go away
Expand Down
Loading
Loading