feat(agent-context): add okf.<key> filter alias for OKF frontmatter extensions
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(andIN) becomesokfExtensions IEQUAL ["<key>=v", "x-<key>=v"]. It's case-insensitive, like the otherokf_*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, sookf.domainandokf.x-domainboth send both spellings. This costs one extra value in the same criterion, and agents don't need to know which version a bundle uses. !=/NOTnegates that condition.IS NOT NULLbecomesokfExtensions START_WITH ["<key>=", "x-<key>="], which finds documents that declare the key.IS NULLis its negation.>,<and similar operators are rejected with a clear error, since values are stored as text. So areokf.andokf.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 #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,INwith a joined value, nested keys and values with=, negation, null checks, combining withokf_type, and rejected forms.- The #21886 smoke test runs the exact
IEQUALandSTART_WITHcriteria 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,!=, andIS [NOT] NULLmap to case-insensitiveIEQUAL/START_WITHcriteria onokfExtensions.- Both key spellings are matched: bare keys (
domain) and OKF 0.3'sx-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 #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.