Skip to content

feat(agent-context): add okf.<key> filter alias for OKF frontmatter extensions - #21888

Open
shirshanka wants to merge 1 commit into
okf-agent-toolsfrom
okf-extension-filter-alias
Open

shirshanka wants to merge 1 commit into
okf-agent-toolsfrom
okf-extension-filter-alias

Conversation

@shirshanka

@shirshanka shirshanka commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #21876. Review that one first; this PR only adds the commit on top.

What

Agents can filter OKF documents by any custom frontmatter key with okf.<key>:

okf.domain = finance
okf.x-domain = finance AND okf_type = guide
okf.audience IN (analysts, "analysts, engineers")
okf.x-team.lead = alice
okf.domain IS NOT NULL

The server side is #21886, which indexes those keys as key=value entries in the okfExtensions field.

How it maps

  • okf.<key> = v (and IN) becomes okfExtensions IEQUAL ["<key>=v", "x-<key>=v"]. It's case-insensitive, like the other okf_* aliases.
  • Both spellings: OKF 0.3 prefixes custom keys with x- (x-domain), while earlier bundles use bare keys (domain). The index keeps keys as written, so okf.domain and okf.x-domain both send both spellings. This costs one extra value in the same criterion, and agents don't need to know which version a bundle uses.
  • != / NOT negates that condition.
  • IS NOT NULL becomes okfExtensions START_WITH ["<key>=", "x-<key>="], which finds documents that declare the key. IS NULL is its negation.
  • >, < and similar operators are rejected with a clear error, since values are stored as text. So are okf. and okf.x- without a key.
  • A list value matches only as its whole joined value (analysts, engineers), and a nested key uses dots (x-team.lead), as indexed by feat(okf): make OKF frontmatter extensions searchable and filterable #21886.

The search_documents tool description and FILTER_DOCS describe okf.<key> and add an example. On a server without #21886, the field doesn't exist and the filter matches nothing.

Tests

  • tests/unit/cli/test_search_filter_parser.py: both spellings, case, IN with a joined value, nested keys and values with =, negation, null checks, combining with okf_type, and rejected forms.
  • The feat(okf): make OKF frontmatter extensions searchable and filterable #21886 smoke test runs the exact IEQUAL and START_WITH criteria this alias sends against a live server, on Search V3 and V2.

Local: :metadata-ingestion:testSingle on the parser tests (42 pass), :datahub-agent-context:testFull (689 pass) and :datahub-agent-context:lint are clean. :metadata-ingestion:lint reports no errors in these files.

Checklist

  • PR title follows the Contributing Guideline
  • Tests added/updated

🤖 Opened with cclaude on behalf of @shirshanka


Summary by cubic

Adds an okf.<key> filter alias so agents can filter OKF documents by any custom frontmatter key, backed by the okfExtensions index field from the server-side change in #21886.

  • okf.<key> = v, IN, !=, and IS [NOT] NULL map to case-insensitive IEQUAL / START_WITH criteria on okfExtensions.
  • Both key spellings are matched: bare keys (domain) and OKF 0.3's x- prefixed form (x-domain), so agents don't need to know which bundle version uses which.
  • Comparison operators (>, <) and keyless forms (okf., okf.x-) are rejected with a clear error.
  • On a server without feat(okf): make OKF frontmatter extensions searchable and filterable #21886, the filter matches nothing (the index field doesn't exist).

Tests cover both spellings, case, joined list values, nested keys, negation, null checks, and rejection of unsupported forms.

Written for commit 3bb1d70. Summary will update on new commits.

View guided diff Turn on auto-fix

@github-actions github-actions Bot added the ingestion PR or Issue related to the ingestion of metadata label Dec 4, 2026
@cclaude-datahub-project cclaude-datahub-project Bot added the cclaude Opened from a cclaude box label Dec 4, 2026
@cursor

cursor Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Adds okf.<key> to the SQL-like document search filter parser so agents can target arbitrary OKF frontmatter extensions (e.g. okf.domain = finance, okf.x-team.lead = alice, okf.audience IN (...)).

Filters compile to okfExtensions criteria: equality/IN use case-insensitive IEQUAL on "key=value" strings, with both bare and x- key spellings emitted so OKF 0.2 and 0.3 bundles match without callers knowing which format was indexed. IS [NOT] NULL uses START_WITH on "key=" prefixes; >, <, etc. on extension fields raise a clear error. search_documents and FILTER_DOCS document the syntax and add an example workflow.

Unit tests cover spellings, case, IN, nested keys, values containing =, negation, null checks, composition with okf_type, and invalid forms.

Reviewed by Cursor Bugbot for commit 3bb1d70. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Smart test selection

pytest smoke tests

Mode: active. Only the selection below runs for the pytest smoke tests on this PR (applied: smart).

  • Selection: smart: tests for the tagged features, plus always-run modules, this PR's changed tests, and the plumbing sample if the PR changes the pytest harness
  • Size: 188 of 859 tests in 1 batch, predicted longest batch ~3 min
  • Tags: feature-dev: search-indexing, sql-lineage; feature-user: documentation, search; technical-layer: cli
  • Confidence: HIGH (3 changed files)
  • Classifier reasoning: Adds okf.<key> extension filtering to document search and the CLI filter parser, with unit tests; touches document search and CLI search filter parsing.
Selected scopes (40 files or classes, 188 tests)
  • tests/e2e/actions/doc_propagation/test_propagation.py
  • tests/e2e/authorization/test_self_entity_auth.py
  • tests/e2e/browse/browse_test.py
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchBasic
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchDiagnose
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchDryRun
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchErrorHandling
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchFilterCombinations
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchFiltersByEntityType
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchFiltersByPlatform
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchPagination
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchProjectionLive
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchWhereFilter
  • tests/e2e/delete/delete_assertion_cascade_test.py
  • tests/e2e/frontend/test_static_asset_encodings.py
  • tests/e2e/institutional_memory/institutional_memory_test.py
  • tests/e2e/knowledge/document_change_history_test.py
  • tests/e2e/knowledge/document_search_filter_test.py
  • tests/e2e/knowledge/test_document_crud.py::TestDocumentCrudAndMutations
  • tests/e2e/knowledge/test_document_hierarchy_settings.py::TestDocumentHierarchyAndSettings
  • tests/e2e/knowledge/test_document_search_history.py::TestDocumentSearchAndHistory
  • tests/e2e/knowledge/test_okf_reimport.py
  • tests/e2e/managed_ingestion/ingestion_source_run_events_test.py
  • tests/e2e/mcp/mcp_test.py
  • tests/e2e/query_projection/test_query_projection_smoke.py
  • tests/e2e/read_only/test_search.py
  • tests/e2e/read_only/test_services_up.py
  • tests/e2e/search/test_lineage_search_index_fields.py
  • tests/e2e/search/test_search_projection.py::TestSearchProjection
  • tests/e2e/semantic/test_classical_embedding_provider.py::TestClassicalEmbeddingProvider
  • tests/e2e/semantic/test_config_fingerprint.py::TestConfigFingerprint
  • tests/e2e/semantic/test_current_offset_api.py
  • tests/e2e/semantic/test_event_driven_docs.py::TestEventDrivenDocumentIngestion
  • tests/e2e/semantic/test_event_mode_fallback.py::TestEventModeFallback
  • tests/e2e/semantic/test_local_embedding_provider.py::TestLocalEmbeddingProvider
  • tests/e2e/semantic/test_semantic_search.py::TestSemanticSearchWithIngestion
  • tests/e2e/semantic/test_source_type_filtering.py::TestSourceTypeFiltering
  • tests/e2e/semantic/test_stateful_ingestion.py::TestStatefulIngestion
  • tests/e2e/siblings/siblings_search_batching_test.py
  • tests/e2e/test_e2e.py

Add the run-all-tests:pytest label to run the full pytest suite on this PR.

commit 3bb1d70 · workflow run

@codecov

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3bb1d70. Configure here.

"START_WITH",
[f"{spelling}=" for spelling in _okf_extension_spellings(extension_key)],
)
return declared if negated else F.not_(declared)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Null checks ignore key case

Medium Severity

okf.&lt;key&gt; IS [NOT] NULL is a START_WITH prefix on okfExtensions, while = and IN use IEQUAL. On Search V3 that wildcard is case-sensitive, and a lowercase copy is added only when the prefix itself contains uppercase. okf.domain IS NOT NULL therefore misses a key stored as Domain or DOMAIN, and IS NULL treats that key as absent. Equality still matches those keys. The re-added x- spelling is always lowercase, so an X-domain key is missing from the prefix list entirely.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3bb1d70. Configure here.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 3 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@datahub-connector-tests

Copy link
Copy Markdown

Connector Tests Results

Connector tests failed for commit 3bb1d70

View full test logs →

To skip connector tests, add the skip-connector-tests label (org members only).

Autogenerated by the connector-tests CI pipeline.

This branch was successfully deployed

1 active deployment
Preview — 3bb1d705 Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cclaude Opened from a cclaude box ingestion PR or Issue related to the ingestion of metadata

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant