Skip to content

spec: Clarify metadata override semantics#1624

Draft
amacneil wants to merge 1 commit intomainfrom
cursor/spec-metadata-last-write-wins-0acd
Draft

spec: Clarify metadata override semantics#1624
amacneil wants to merge 1 commit intomainfrom
cursor/spec-metadata-last-write-wins-0acd

Conversation

@amacneil
Copy link
Copy Markdown
Contributor

@amacneil amacneil commented Mar 31, 2026

Update MCAP spec to clarify how readers should interpret multiple metadata records with the same name:

  • recommend merge behavior in file order so later records overwrite earlier values for the same key
  • clarify that readers may additionally expose an interface returning all metadata records without merging

claude[bot]

This comment was marked as outdated.

@amacneil amacneil changed the title Clarify metadata name override semantics Clarify metadata name semantics Mar 31, 2026
@amacneil amacneil changed the title Clarify metadata name semantics spec: Clarify metadata override semantics Mar 31, 2026
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved the prior MUST-level concern — SHOULD/MAY is the right call given none of the readers implement this today.

Two open questions on the current version: (1) merge vs. replace semantics — the switch from the original commit's replace behavior to merge has real implications for stale keys, and (2) no writer-side guidance, which leaves the motivation for duplicate names implicit. The use case context from the prior review thread is still unanswered.

| 4 + N | metadata | `Map<string, string>` | Example keys: `part_id`, `serial`, `board_revision` |

Multiple metadata records MAY share the same `name`.
When resolving metadata by name, readers SHOULD merge key-value pairs from all metadata records with that `name` in file order, such that later records overwrite earlier values for the same key.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge vs. replace — is merge intentional here? The original commit used replace semantics (last record wins entirely), and this revision switched to merge (combine key-value pairs, last-write-wins per key). These are meaningfully different.

Consider: record 1 has {part_id: "A", serial: "123"}, record 2 has {part_id: "B"} (serial was removed). Merge produces {part_id: "B", serial: "123"} — silently carrying forward a stale key. Replace produces {part_id: "B"}.

Merge makes it impossible to "unset" a key, which could lead to subtle bugs when the intent is to publish a corrected/updated version of the metadata. Replace is simpler and avoids stale-data leakage. If merge is the desired behavior, it would help to document why — and maybe call out that keys cannot be removed, only overwritten.

Also: none of the six reader implementations do merge today (they all return all matching records individually), so either way this is new behavior that nobody implements yet. Worth noting in the PR description so it's clear this is aspirational guidance for future implementations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge is intentional. The Go cli uses merge when using mcap get metadata --name right?

The closest you can get to unsetting a key is to set it to an empty string.

| 4 + N | name | String | Example: `my_company_name_hardware_info`. |
| 4 + N | metadata | `Map<string, string>` | Example keys: `part_id`, `serial`, `board_revision` |

Multiple metadata records MAY share the same `name`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any guidance for writers? The spec now tells readers what to do with duplicate names, but is silent on when/why a writer would produce them. Something like "Writers MAY write multiple metadata records with the same name to override or extend previously written metadata" would clarify intent and make the reader recommendation less surprising.

Also — what's the motivating use case? File concatenation? Writers appending corrected metadata? That context would help reviewers (and future spec readers) evaluate whether merge or replace is the right call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant