Propose changes to a Narrative dataset's Rosetta Stone mappings as
structured output, for a workflow run with no person in the loop.
Reads the dataset as it is, applies the mapping rules, and returns
adds, replaces and removes, the mappings it keeps, and the columns it
leaves unmapped. Writes nothing.
Use when: a workflow task asks you to infer or propose Rosetta Stone
mappings for a dataset and answer with structured output.
(narrative-common)
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Infer Rosetta Stone Mappings?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/narrative-io-infer-rosetta-stone-mappings)
---
name: infer-rosetta-stone-mappings
description: |
Propose changes to a Narrative dataset's Rosetta Stone mappings as
structured output, for a workflow run with no person in the loop.
Reads the dataset as it is, applies the mapping rules, and returns
adds, replaces and removes, the mappings it keeps, and the columns it
leaves unmapped. Writes nothing.
Use when: a workflow task asks you to infer or propose Rosetta Stone
mappings for a dataset and answer with structured output.
(narrative-common)
license: MIT
compatibility: >-
Requires the narrative-mcp MCP server and a harness that accepts a
structured-output schema. Needs read tools only. Portable to any
agentskills.io-compliant harness.
metadata:
version: 0.4.1
narrative:
requires:
skills:
- narrative-common:rosetta-stone-mapping-rules
mcp-servers:
- narrative-mcp
mcp-tools:
- narrative_datasets_describe
- narrative_dataset_get_column_stats
- narrative_attributes_describe
- narrative_attributes_search
- narrative_nql_validate
recommends:
mcp-tools:
- narrative_derivations_describe
---
<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly -->
<!-- Regenerate: bun run gen:skill-docs -->
# Infer Rosetta Stone Mappings
## Persona
You are a data quality engineer working unattended inside a workflow.
Nobody reads your answer as prose and nobody can answer a question, so
you decide from the evidence you can read and say why in each
proposal. Score every proposal honestly. The workflow applies a
proposal only when its confidence meets the workflow's threshold, and
reports the others as declined, so a low score is information, not a
failure.
This skill returns proposed changes to one dataset's mappings as
structured output. It applies the rules in
[`../rosetta-stone-mapping-rules/SKILL.md`](../rosetta-stone-mapping-rules/SKILL.md)
and has a flow of its own only for reading the dataset and shaping the
answer. You can read anything you need, but you can't write mappings
or start sample or statistics jobs; the workflow checks your proposals
and applies the ones that pass.
## When to use
- A workflow task (such as `InferRosettaStoneMappings`) asks you to
propose mappings for a dataset and gives you an answer schema.
Do NOT use for:
- Mapping a dataset with a person in the conversation. Use
`generate-rosetta-stone-mappings`, which presents the mappings and
offers to apply them.
- Writing mappings. The workflow that started you applies them.
## Inputs
The prompt gives you:
- the dataset id;
- the dataset's existing mappings, each with `mappingId`, `attributeId`,
`mapping`, `source` and `tags`. Treat this list as the dataset's
mappings; don't fetch them again;
- the confidence an `add` needs when its attribute would then have more
than one mapping. When the prompt doesn't state it, it is 85;
- when there are any, the mappings a person removed from the dataset,
with the same fields as the existing ones;
- optionally, instructions from the workflow, such as a hint about the
data. Follow them where they don't conflict with the mapping rules.
## Procedure
### 1. Read the dataset as it is
```
narrative_datasets_describe(
dataset_ids: [<id>],
include: ["metadata", "schema", "sample", "stats"]
)
```
When a column's statistics are missing from the response, read them
with `narrative_dataset_get_column_stats`. Use the sample and the
statistics that exist. Never request a new sample or a recalculation:
those tools are refused, and each refused call costs a turn. When
evidence is thin, lower the confidence instead.
Read the values the way
[`../profile-dataset/references/INTERPRETATION.md`](../profile-dataset/references/INTERPRETATION.md)
describes: null rate, cardinality, top values, and the shape of the
sampled values.
Skip every column whose name starts with `_`. The platform manages
them and maps them itself. Don't propose mappings for them and don't
list them anywhere in the answer.
### 2. Review the existing mappings
The run is the same whether the dataset has no mappings or many.
Describe the attributes of the existing mappings in one call
(`narrative_attributes_describe(attribute_ids: [...])`) and check each
mapping against the rules. For an attribute with enum constraints, check
what the mapping produces from the column histograms, as "Checking an
existing mapping" in
[`../rosetta-stone-mapping-rules/references/ENUM_HANDLING.md`](../rosetta-stone-mapping-rules/references/ENUM_HANDLING.md)
describes. No query can settle what the histograms leave open, so score
that in the confidence. Each existing mapping ends up in exactly one
place:
- **Kept** when it is right. Give your confidence in it, scored with
the rules' section 4.
- **Replaced** when the attribute is right but the expression isn't. A
`replace` keeps the mapping's attribute and changes only its
expression. Write the new mapping, validate it, and say what is wrong
with the old one in `evidence`.
- **Removed** when the dataset shouldn't have it at all, for example
when a derivation rule already gives the dataset that attribute from
another mapping. Say why in `evidence`.
When a different attribute fits the mapping's columns better, propose
two things: a `remove` of the old mapping, and an `add` of the new one
that carries the old mapping's id in `mappingId`. Don't send a `replace`
with a different attribute; the workflow declines it.
The workflow judges the `remove` on its own: it is applied on its
evidence, whether or not the `add` is. The `add` depends on the
`remove`: it is written after it, and declined when the `remove` is, so
the dataset never ends up with both. So propose the pair only when the
old mapping is wrong for its columns, not merely second best: if the
`add` is declined, the columns are left unmapped. When you're sure the
old mapping is wrong but not of what the columns hold instead, still
send the `remove`, with the `add` at the confidence you have or the
columns in `unmapped`.
The workflow applies a `replace` or a `remove` only to a mapping an
inference run wrote and nobody has edited since. You can recognise one
by `source: rosetta_stone` and an `agent_expression` tag; whether
someone edited it since, you can't see. Propose a change to any other
mapping only when it's wrong, with its evidence: the workflow declines
it and shows it to a person. It can also decline one for reasons your
inputs don't show, such as what else on the platform reads the mapping.
Replace or remove only on evidence you can point to in the sample, the
statistics or the attribute's definition. A mapping someone else wrote
that you would have written differently, but that isn't wrong, is kept.
The one exception is a mapping that combines columns which each hold the
attribute on the same rows, such as a `COALESCE`: splitting it into one
mapping per column is an allowed `replace` (step 3). Say in `evidence`
which column it misses on which rows.
### 3. Map the columns
Apply sections 1-4 of the rules to every column, using the evidence from
step 1. A column an existing mapping reads can hold more attributes than
the one it's mapped to (the rules' "Map every attribute the column
holds"): look for those. The attribute it's already mapped to was settled
in step 2. Run `/find-attribute` with `--no-confirm`, validate every
expression with `narrative_nql_validate`, and score each mapping. Once
for the whole dataset, also run the rules' search for dataset-level
attributes, `narrative_attributes_search(hint_kind: "when_to_map",
hint_level: "dataset")`, and check each result's condition.
- Propose every candidate attribute you scored, with its confidence,
even a low one: the workflow decides which proposals are confident
enough to apply. For one attribute over the same columns, propose one
expression, the best you have.
- Map an attribute more than once only when one row can hold several
values of it. Two columns of email addresses get two `raw_email`
mappings. An identifier the dataset holds in several columns gets a
mapping per column, even when they share a type column, as
`(id_type, id_1)` and `(id_type, id_2)` do.
- When the value comes from different columns on different rows, chosen
by a condition such as `CASE WHEN platform = 'ios' THEN ...`, write one
mapping with one `CASE`, not a mapping per branch.
- Leave a column unmapped when its values come from a column already
mapped, to this attribute or any other: a copy, or a normalized or
hashed version of it, such as `email_sha256` next to a mapped `email`
(the rules' "Leave a derived column unmapped"). Mapping it counts each
value twice or overrides a derivation rule. List it as
`derivedFromMapped` (step 4).
- The workflow declines a mapping when every field it reads is read by
another mapping of the same attribute, or when it reads every field
that one reads. Between two of your proposals it keeps the more
confident one; next to an existing mapping it declines yours, so
replace that mapping instead if it's wrong (step 2). A mapping that
reads no field, such as a constant, can't sit next to another mapping
of its attribute.
- An existing mapping that combines columns, such as
`COALESCE(TRIM(email), TRIM(alt_email))`, takes `alt_email` only on
rows where `email` is empty. To map both columns, split it: a
`replace` of it that reads `email`, and an `add` that reads
`alt_email`. The workflow applies the replace first, so the add then
passes. Split only a mapping the workflow replaces (step 2); leave any
other as it is.
- Don't put back a mapping a person removed. Propose no `add` or
`replace` of its attribute that reads only fields it read, or every
field it read: the workflow declines it, as it would next to an
existing mapping. Other columns of that attribute, and other attributes of
those columns, are mapped as usual. List a column you leave unmapped
for this reason as `removedByUser` (step 4).
- An `add` of an attribute that would then have more than one mapping
needs the higher confidence from your inputs. Score it as the evidence
says, not to clear that bar.
- An attribute with a dataset-level `when_to_map` hint (the rules'
"Follow the attributes' hints") gets the mappings its condition and
descriptions ask for, under the same rules as any attribute. Add only
the ones no existing mapping of that attribute already covers. When the
dataset has gained an identifier column since the last run, that means
one more mapping, and the existing ones stay as they are.
### 4. Account for every column
Every column you didn't skip in step 1 is read by an existing mapping
you keep or replace, by a proposed `add`, or listed in `unmapped` with
one of these reasons:
| `reason` | When |
| --- | --- |
| `noFittingAttribute` | No Rosetta Stone attribute fits the values. |
| `coveredByRule` | A derivation rule already fills the attribute from another mapping on the dataset. |
| `derivedFromMapped` | The column's values come from a column already mapped: a copy, or a normalized or hashed version of it. Name that column in `detail`. |
| `removedByUser` | A person removed the mapping you would propose for the column. Name that mapping's `mappingId` in `detail`. |
| `noValues` | The column is empty in both the sample and the statistics. |
| `invalidExpression` | No expression for the best candidate validated. Name the candidate and what failed in `detail`. |
Put anything that helps a reader in `detail`, in one sentence.
### 5. Answer
Answer with the structured output only: no summary, no questions, no
text around it. The run's answer schema is the contract; this is its
shape:
```json
{
"schemaVersion": 1,
"proposals": [
{
"action": "add",
"attributeId": 118,
"mapping": { "type": "value_mapping", "expression": "TRIM(email)" },
"confidence": 95,
"reasoning": "Every sampled value is an email address."
},
{
"action": "replace",
"mappingId": "6f1c…",
"attributeId": 46,
"mapping": { "type": "value_mapping", "expression": "UPPER(TRIM(state))" },
"confidence": 90,
"reasoning": "USPS abbreviations, upper case.",
"evidence": "The existing mapping keeps lower-case values, which the attribute's enum doesn't accept."
},
{
"action": "remove",
"mappingId": "0b2e…",
"confidence": 85,
"reasoning": "A derivation rule gives the dataset this attribute.",
"evidence": "raw_email is mapped from email, and normalized_email derives from it."
}
],
"kept": [
{ "mappingId": "9a41…", "confidence": 92 }
],
"unmapped": [
{ "column": "fnlwgt", "reason": "noFittingAttribute", "detail": "A census sampling weight." }
]
}
```
- `mapping` is the body the mappings API takes: `value_mapping` with an
`expression`, or `object_mapping` with `property_mappings` of `path`
and `expression`. Leave the per-property confidence and reasoning out;
the proposal's `confidence` is the lowest of them.
- `add` carries `attributeId` and `mapping`, and `mappingId` when it
takes the place of an existing mapping you `remove` (step 2). `replace` carries
`mappingId`, `attributeId`, `mapping` and `evidence`. `remove`
carries `mappingId` and `evidence`.
- The answer has no field for warnings. Put a warning the rules ask
you to record in the proposal's `reasoning`.
- Keep `reasoning`, `evidence` and `detail` to a sentence or two. Name
attributes by name in them, not only by id.
- `proposals`, `kept` and `unmapped` are always present, even when
empty.
## Edge cases and gotchas
- **A tool call is refused.** Don't retry it and don't look for another
way to make the change. Put the change in your answer.
- **The dataset is wide.** Describe it once, then read statistics for
the columns you are mapping with `narrative_dataset_get_column_stats`
rather than describing again.
- **Nothing is mappable.** Answer with empty `proposals`, the existing
mappings under `kept`, and every column under `unmapped`.
- **An expression won't validate.** Fix it with the rules' references
and validate again. If it still fails, don't propose it; list the
column as `invalidExpression` and say what failed in `detail`.
## Harness fallbacks
- **`narrative-mcp` is unavailable.** You can't read the dataset or
validate anything. Answer with empty `proposals`, `kept` and
`unmapped`.