✓ Human-authored analysis; AI used for formatting and proofreading.

Every integration project that joins two name conventions hits the same problem. One side has columns: block_public_acls, kms_master_key_id, versioning_enabled. The other side has dotted paths: properties.storage.controls.public_access_block.block_public_acls, properties.messaging.sqs.kms_key_id, properties.storage.versioning.enabled. A human can read both and produce the join in their head. Encoding that intuition in code is the actual work.

I needed to auto-generate ~98 mapping files joining Steampipe AWS table columns to Stave's per-asset JSON Schema property paths. The hand-authored ground truth was 11 files. The target was 80% accuracy against that corpus. The first pass got 5%. Four passes later it was at 79%, and most of that last jump came from a lookup table rather than a rule. Here is the strategy, the curve, and why the difference matters.

The corpus

The hand-authored mappings (11 files, 107 column → path pairs total) come from review work. Each pair encodes a small judgement call: when Steampipe gives you a column called name, which schema path should it land at? For an IAM role: properties.identity.role_name (overrides the generic naming). For a Lambda function: properties.compute.name (follows the generic naming). For an S3 bucket: properties.storage.name. Same column, three answers, three rules.

The auto-generator must reproduce those answers without seeing the rules.

Pass 1: exact leaf match

The first heuristic: index every schema path by its leaf segment, look up each Steampipe column in the index. For column block_public_acls, find any path ending in block_public_acls; emit the mapping.

candidates = {} for path in paths: leaf = path.split(".")[-1].lower() candidates.setdefault(leaf, path) field_map = {} for col in columns: if col.lower() in candidates: field_map[col] = candidates[col.lower()] 

Result: 5% accuracy. Out of 107 expected (column, path) pairs, only 5 were correct, and that's after adding the properties. prefix (reason 3 below). Compared literally, it was 0.

Why so low? Three reasons:

  1. Most hand-authored paths use namespaced identity fields (properties.storage.name, properties.identity.role_name, properties.compute.name) that no control predicate reads, so they don't appear in the schema. The leaf-index has nothing to match name to.

  2. Leaf collisions go to the wrong path. enabled appears as a leaf on dozens of schema paths (logging.enabled, versioning.enabled, encryption.enabled, mfa.enabled). The first-wins dictionary puts whichever path it encountered first; the column versioning_enabled lands at properties.storage.logging.enabled.

  3. Path-prefix drift. Hand-authored YAMLs prepend properties. to every path. The schema walker doesn't (the schema describes the properties block, not the wrapper). The literal-tuple comparison treats storage.access.public_read ≠ properties.storage.access.public_read.

These are gaps between what the heuristic encodes and what a human reviewer does without thinking.

Pass 2: convention fallback + namespace-per-asset

The first two fixes are mechanical:

  • Always emit paths with properties. prefix.
  • For columns that the schema-index misses, fall back to a naming convention: column foo_bar → properties.<namespace>.foo_bar where <namespace> is derived from the asset type (aws_iam_* → identity, aws_s3_* → storage, aws_lambda_* → compute, etc.).
NAMESPACE_BY_PREFIX = { "aws_s3_": "storage", "aws_iam_role": "identity", "aws_lambda_": "compute", "aws_kms_": "cryptography", "aws_cloudtrail_": "audit", "aws_sqs_": "messaging", ... } def namespace_for(asset_type): for prefix, ns in NAMESPACE_BY_PREFIX.items(): if asset_type.startswith(prefix): return ns return "asset" 

The convention recovers the context columns (name, create_date, region, raw policy bytes) that aren't in the schema because no control reads them, whenever the hand-authored file used the generic name. Pass 2 result: 36% accuracy. Up from 5% with two rules.

Pass 3: multi-token scoring

versioning_enabled was still landing at the wrong path. The leaf was enabled; my candidate dict had enabled mapped to whichever path I'd encountered first.

The fix: when multiple paths share a leaf, prefer the one whose other segments also share tokens with the column name.

def _best_candidate_for_column(col_norm, paths): col_tokens = set(col_norm.split("_")) best_path, best_score = "", -1 for p in paths: path_tokens = set(p.lower().replace(".", "_").split("_")) score = len(col_tokens & path_tokens) if score > best_score or (score == best_score and best_path and len(p) < len(best_path)): best_score = score best_path = p return best_path if best_score > 0 else "" 

Column versioning_enabled has tokens {versioning, enabled}. Path storage.versioning.enabled has tokens {storage, versioning, enabled} with overlap of 2. Path storage.logging.enabled has tokens {storage, logging, enabled} with overlap of 1. Winner: versioning.enabled. The scorer resolves a collision whenever the column name carries the disambiguating word.

Pass 3 result: 36% accuracy. It fixed exactly one more pair: this corpus has few leaf collisions. The rule matters more on wide tables than on these 11 files, but the number didn't move.

Pass 4: per-asset overrides

Some pairs cannot be derived from any general rule. aws_iam_role.name → properties.identity.role_name is one. Reasonable people disagree on whether to call it role_name or name; the hand-authored file picked role_name. The convention says name. The override map records the empirical choice:

COLUMN_OVERRIDES = { "aws_iam_role": { "name": "properties.identity.role_name", "assume_role_policy_document": "properties.identity.trust_policy.raw", }, "aws_iam_user": { "name": "properties.identity.user_name", "login_profile": "properties.identity.console_access.enabled", }, "aws_kms_key": { "id": "properties.cryptography.key_id", "key_manager": "properties.cryptography.is_aws_managed", "enabled": "properties.cryptography.is_disabled", }, ... } 

Two rules govern when to add an override:

  1. The convention says X, the hand-authored YAML says Y, both are defensible. If reviewers disagreed even briefly, the convention probably isn't the answer; record the override.
  2. The hand-authored choice is opinionated (negation, rename, restructure). kms_key.enabled → is_disabled is a negation. kms_key.id → key_id is a rename. aws_cognito_user_pool.policies → password_policy.raw is a restructure. Conventions don't do these; overrides do.

I populated the override map by running the validator on the ground truth, listing every manual_only field per asset type, and writing the override that would have produced the hand-authored answer. 52 overrides across 11 asset types.

Pass 4 result: 79% accuracy. 85 correct out of 107 expected pairs, one pair short of the 80% target.

The accuracy curve

Pass Rule added Accuracy (11 hand-authored files, 107 pairs)
1 Exact leaf match 5%
2 + properties. prefix + namespace convention fallback 36%
3 + multi-token scoring for leaf collisions 36%
4 + per-asset override map (52 entries) 79%

These numbers are reproducible: they come from today's generator with each rule switched off in turn, scored against the 11 hand-authored files. (The intermediate passes from the original development weren't committed, so an earlier draft of this post quoted numbers that can't be checked.)

What the 79% does and doesn't prove

The curve doesn't flatten the way you'd hope. The general rules (passes 1–3) reach 36%. The override map adds 43 points, and 50 of the 107 expected pairs are answered directly by an override entry.

That matters because the overrides were written by reading these same 11 files. Scoring them against those files measures how well the table memorised its source, not how well the approach generalises. The honest reading is:

  • 36% is what the rules achieve on a table they've never seen.
  • 79% is the ceiling once a reviewer has mapped that table by hand and the overrides are recorded.

The real test of generalisation is the next asset type: run the generator before writing any overrides for it, and score that.

One more trap: the validator scores every mapping file in the folder, including the 6 that the generator itself produced (marked _auto_generated: true). Counting those, it reports 84% (149/177). Those files were generated, then reviewed, so they largely agree with the generator by construction. Exclude them when quoting accuracy.

The remaining 21%

The brief said:

Target: 80%+ accuracy on automatic matching. The remaining 20% are non-trivial name differences (e.g., server_side_encryption_configuration → properties.storage.encryption.raw_configuration) that require manual mapping.

The 21% that remains is mostly:

  • Multi-target JSON-path extracts. One column (server_side_encryption_configuration) splits into two paths (encryption.algorithm AND encryption.kms_key_id). A name-similarity matcher cannot synthesise the split.
  • Boolean derivation from nested JSON. encryption_at_rest_options is an object; the catalog wants encryption.at_rest_enabled as a flat boolean derived from the nested .Enabled field.
  • Per-column ID fallbacks. SNS topics have no arn column — they have topic_arn. SQS queues have queue_arn. The asset-id picker needs to know "if arn is absent, find anything ending in _arn."

The third one I fixed automatically. The first two I left manual; the generator marks them in _unmatched_paths: so the reviewer sees what needs hand work.

The pattern generalises beyond Steampipe and Stave. Any time you join "source columns" to "target dotted paths" — Salesforce → CRM contract, Snowflake → analytics schema, OpenAPI spec → SDK method names, AWS Config → CSPM model — the four rules above apply, in this order:

  1. Per-target override map for the opinionated rewrites. Author by reading existing hand-mapped examples.
  2. Token-aware schema-path lookup for collisions. Single-rule fallback dictionaries fail; multi-token scoring is one extra loop.
  3. Naming convention as the fallback for context fields the target schema doesn't enumerate. column foo_bar → <namespace>.foo_bar recovers identity, regions, timestamps, tags.
  4. Explicit unmatched lists in the generator output. Reviewers know what to look at; nothing gets silently dropped.

Pass 1 was a smart-looking algorithm that hid its misses behind a no match branch. Pass 4 is the same general approach with the dishonesty replaced by marker fields. Reviewers trust output that flags its own uncertainty; they don't trust output that pretends to be complete.

What it cost

About 520 lines of Python plus a 222-line cached column catalog committed to the repo. Two commands:

# Generate mappings for asset types that don't have one yet python3 scripts/gen-steampipe-mappings.py \ --columns scripts/steampipe-columns.json \ --output internal/contracts/steampipe/ \ --skip-existing # Score the generator against the mappings in the folder python3 scripts/gen-steampipe-mappings.py \ --columns scripts/steampipe-columns.json \ --validate-against internal/contracts/steampipe/ 

The validator runs on demand as a sanity check; the generator runs whenever a new asset type joins the catalog. Six asset types were auto-generated and committed in the first run after the heuristic stabilised; each carries _auto_generated: true and _review_required: N so the reviewer queue is bounded.

The hand-authored corpus grew, because the generator's _unmatched_paths: output is the natural review checklist for converting an auto-generated YAML into a hand-authored one. The generator bounds the human review.

Code is at gen-steampipe-mappings.py for reference.