Skip to content

Declare discrete values on metadata columns - #135

Merged
kevindetry-milaboratories merged 1 commit into
mainfrom
kevindetry/metadata-discrete-values
Sep 24, 2026
Merged

kevindetry-milaboratories merged 1 commit into
mainfrom
kevindetry/metadata-discrete-values

Conversation

@kevindetry-milaboratories

@kevindetry-milaboratories kevindetry-milaboratories commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Every metadata column with at least one value now carries two annotations:

  • pl7.app/isDiscreteFilter: "true"
  • pl7.app/discreteValues: the distinct values of the column, as a JSON array of strings

Numbers sort in numeric order, other values in string order. Downstream blocks such as Graph Maker and repertoire-labeling can offer the column as a discrete filter or a grouping property without a read of its data.

The values come from the block args, so no data resource is read. The set is sorted from Go-map iteration order, never from a pre-sorted list, since slices.quickSortInPlace recurses O(n) deep on sorted input.

Also includes the upgrade-sdk changes and a Tengo unit test for the new functions.

RetriggerConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking performance and usability concern for high-cardinality metadata columns.

Fix All in Claude CodeFindings

  1. P2 Unbounded discrete-value annotations ▶
Fix with agent prompt
### Issue 1
workflow/src/metadata.lib.tengo:53-56
Every nonempty metadata column embeds its complete distinct-value set in the PColumn spec. For realistic high-cardinality columns such as per-sample identifiers, this duplicates thousands of values into the annotation and advertises an impractical discrete filter, increasing the exported-spec payload and downstream processing cost. Apply a cardinality threshold and omit the discrete-filter annotations when it is exceeded.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR derives sorted, distinct metadata values from block arguments and publishes them as PColumn annotations so downstream blocks can configure filters and grouping without reading column data. It also adds Tengo tests and applies the associated Platforma SDK structure and dependency upgrades.

  • Adds discreteValues and metadataColumnSpec, then uses them for exported metadata columns.
  • Adds tests for string, numeric, mixed, missing, empty, and global-column cases.
  • Upgrades the Platforma SDK catalog, lockfile, structure version, and model Node typings.
  • The main non-blocking concern is unbounded annotation growth for high-cardinality metadata.

Important touched terms

  • MTColumn / metadata column: A typed per-sample field represented by a sample-ID-to-value map. Its exported specification now receives discrete-value annotations when it contains values.
  • PColumn specification: The schema describing an exported platform column, including type, domain, axes, and annotations. Metadata PColumn construction is now centralized in metadataColumnSpec.
  • pl7.app/isDiscreteFilter: An annotation indicating that downstream blocks may treat a column as a discrete filter. It is now set to "true" on every nonempty metadata column.
  • pl7.app/discreteValues: A JSON-encoded array of distinct string representations available in the column. It is now computed from block arguments and attached to the PColumn specification.
  • discreteValues: The new Tengo helper that deduplicates values, skips undefined, sorts numeric columns numerically, and returns strings.
  • ll.toStrict: The workflow SDK helper used to expose a strict module object. The metadata module now uses it while exporting the new helpers alongside createMetadata.
  • Structure version 3: The refreshed block-project structure generated by the SDK upgrade; .structure moves from version 2 to version 3.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Block args: MTColumn.data"] --> B["discreteValues"]
  B --> C{"Any values?"}
  C -- Yes --> D["Add isDiscreteFilter and discreteValues annotations"]
  C -- No --> E["Keep label annotation only"]
  A --> F["createJsonPColumnData"]
  D --> G["Exported metadata PColumn"]
  E --> G
  F --> G
  G --> H["Downstream filtering and grouping"]
Loading

Reviews (1) · Last reviewed commit: "Declare discrete values on metadata colu..."

Every metadata column with at least one value now carries two
annotations:

- `pl7.app/isDiscreteFilter`: `"true"`
- `pl7.app/discreteValues`: the distinct values of the column, as a
  JSON array of strings

Numbers sort in numeric order, other values in string order. Downstream
blocks such as Graph Maker and repertoire-labeling can offer the column
as a discrete filter or a grouping property without a read of its data.

The values come from the block args, so no data resource is read. The
set is sorted from Go-map iteration order, never from a pre-sorted
list, since `slices.quickSortInPlace` recurses O(n) deep on sorted
input.

Also includes the `upgrade-sdk` changes and a Tengo unit test for the
new functions.
Comment thread workflow/src/metadata.lib.tengo

@julenmendieta julenmendieta left a comment

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.

Looks good to me

@kevindetry-milaboratories
kevindetry-milaboratories added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit 7b2a9e5 Sep 24, 2026
11 checks passed
@kevindetry-milaboratories
kevindetry-milaboratories deleted the kevindetry/metadata-discrete-values branch September 24, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants