feat(agent-context): return OKF document properties and add okf_* filter aliases
What
Agents using the datahub-agent-context document tools now see OKF metadata and can filter on it. The same change for the standalone MCP server is in acryldata/mcp-server-datahub#301. The two keep separate copies of the tools.
- Fields:
search_documents(keyword and semantic) andget_entitieson a document returnokfProperties:type,status,conceptId,declaredId,description,staleAfter,bundle { location rootPath okfVersion }andfrontmatter. The frontmatter comes back as a JSON object. AboveOKF_FRONTMATTER_CHAR_LIMIT(4000 chars, env-configurable) it is left out andfrontmatterOmittedsays why. Documents without OKF get nothing extra (DocumentMapperreturns null for them). - Filter aliases in the shared parser (
metadata-ingestion/src/datahub/cli/search_filter_parser.py, which agent-context re-exports anddatahub search --wherealso uses), all matched withIEQUAL:okf_type→okfTypeokf_status→okfStatusokf_bundle→okfBundleLocationokf_id→okfConceptIdORokfDeclaredIdokf_stale_after→okfStaleAfter, for>/</IS NULL(epoch ms)- A missing status is stable, as OKF specifies. So
okf_status = stable(or anINlist containing it) becomesokfStatus IEQUAL stable OR (NOT EXISTS okfStatus AND EXISTS okfConceptId). Every OKF document has a conceptId, so that term keeps non-OKF documents out.okf_status != stableexcludes documents without a status. Other values match as written. - The descriptions say
okf_stale_after IS NULLis not "never stale": it also matches documents whosestale_aftervalue could not be read.
NOT okf_id = xandokf_id != xnegate both fields (De Morgan), since_Notcan't negate a multi-clause OR.IS [NOT] NULLworks on every alias.
As a side effect,NOT (a = x OR b = y)over plain custom fields now compiles toa != x AND b != y. It used to raise "Cannot negate a filter with multiple OR clauses".
- Docs:
FILTER_DOCSand thesearch_documents/get_entitiesdescriptions cover the aliases, searching by OKF id (query="guide:mau", Search V3), and thattypemeans entity type, so document types go throughsubtype/okf_type.
Why it sits where it does
- The aliases belong in the shared CLI parser. It is the one parser behind agent-context and
datahub search --where, so both pick them up. get_entitiesreads OKF with its own smallGetDocumentOkfPropertiesquery and does not add it toGetEntity.GetEntity's Document arm is a#[NEWER_GMS]block, which is off on non-Cloud servers, so OKF placed there would never reach OSS.- The new selections are untagged.
strip_unsupported_fields=Trueprojects them away on servers beforeokfPropertiesexisted.
Testing
-
metadata-ingestion/tests/unit/cli/test_search_filter_parser.py, next to the parser: each alias,okf_idand its negation,IS [NOT] NULL,okf_stale_aftercomparisons, andtypestill meaning entity type. Every new parser line is covered. -
New
test_okf_documents.py: the gql selections, frontmatter parse and omission, andget_entities(adds OKF for documents, survives a failed lookup, skips other entities). -
Checked by hand that the three queries validate against this branch's GraphQL schema.
-
:datahub-agent-context:lintpasses, and:datahub-agent-context:testFullpasses (689 passed). -
:metadata-ingestion:testSingleontests/unit/cli/test_search_filter_parser.pypasses (28 passed). -
:metadata-ingestion:lint: ruff passes. mypy reports errors only inazure_data_factoryfiles this PR doesn't touch. -
PR title follows the format
-
Tests added
-
Docs (tool descriptions) updated
-
No breaking changes
🤖 Opened with cclaude on behalf of @shirshanka